Separate system and home config on hs

This commit is contained in:
Yan Lin 2025-09-07 10:35:36 +02:00
parent 8525cab1d6
commit cb9f29154f
4 changed files with 56 additions and 33 deletions

View file

@ -30,15 +30,22 @@ home-manager switch --flake github:Logan-Lin/nix-config#yanlin@iMac
.
├── flake.nix # Main flake configuration and package definitions
├── hosts/ # Host-specific configurations
│ └── darwin/ # macOS hosts
│ ├── home-default.nix # Common home configuration imported by all hosts
│ ├── system-default.nix # Common system configuration for macOS
│ ├── iMac/ # iMac configuration
│ │ ├── system.nix # System configuration
│ │ └── home.nix # Home configuration (imports ../home-default.nix)
│ └── MacBook-Air/ # MacBook Air configuration
│ ├── system.nix # System configuration
│ └── home.nix # Home configuration (imports ../home-default.nix)
│ ├── darwin/ # macOS hosts
│ │ ├── home-default.nix # Common home configuration for Darwin
│ │ ├── system-default.nix # Common system configuration for macOS
│ │ ├── iMac/ # iMac configuration
│ │ │ ├── system.nix # System configuration
│ │ │ └── home.nix # Home configuration (imports ../home-default.nix)
│ │ └── mba/ # MacBook Air configuration
│ │ ├── system.nix # System configuration
│ │ └── home.nix # Home configuration (imports ../home-default.nix)
│ └── nixos/ # NixOS hosts
│ ├── home-default.nix # Common home configuration for NixOS
│ └── hs/ # Home server configuration
│ ├── system.nix # NixOS system configuration
│ ├── home.nix # Home configuration (imports ../home-default.nix)
│ ├── hardware-configuration.nix # Hardware detection results
│ └── disk-config.nix # ZFS and filesystem configuration
├── modules/ # Home Manager configuration modules
│ ├── git.nix # Git configuration with aliases and settings
│ ├── lazygit.nix # Lazygit with gruvbox theme and custom keybindings
@ -828,33 +835,58 @@ tailscale debug netmap
## 💻 Machine Configurations
### Darwin Hosts (macOS)
- **`iMac`**: iMac configuration
- **`MacBook-Air`**: MacBook Air configuration
Both machines use the same base configuration with potential for machine-specific customizations.
### NixOS Host
- **`hs`**: Home server configuration with ZFS, storage management, and services
All hosts now use a consistent configuration structure with separate system and home management.
### Configuration Structure:
The configuration has been reorganized for better clarity:
- **`hosts/darwin/`**: Contains all host-related configurations
- **`home-default.nix`**: Common home configuration shared by all hosts
The configuration has been reorganized for better clarity and consistency:
#### Darwin Hosts:
- **`hosts/darwin/`**: Contains all Darwin host configurations
- **`home-default.nix`**: Common home configuration shared by all Darwin hosts
- **`system-default.nix`**: Common system configuration for macOS
- **Per-host directories**: Each host has its own directory with:
- **`system.nix`**: Host-specific system configuration (imports ../system-default.nix)
- **`home.nix`**: Host-specific home configuration (imports ../home-default.nix)
The `home-default.nix` file contains all shared home configuration, including:
- Module imports (which now handle both configuration and package installation)
- Common packages not managed by modules
- Base home settings
#### NixOS Host:
- **`hosts/nixos/`**: Contains NixOS host configurations
- **`home-default.nix`**: Common home configuration for NixOS hosts
- **`hs/`**: Home server specific directory with:
- **`system.nix`**: NixOS system configuration (standalone, no home-manager)
- **`home.nix`**: Home configuration (imports ../home-default.nix)
- **`hardware-configuration.nix`**: Hardware-specific configuration
- **`disk-config.nix`**: Disk and filesystem configuration
### Machine-specific Usage:
#### Darwin (macOS) Hosts:
```bash
# For MacBook Air
sudo darwin-rebuild switch --flake .#MacBook-Air
home-manager switch --flake .#yanlin@MacBook-Air
sudo darwin-rebuild switch --flake .#mba
home-manager switch --flake .#yanlin@mba
# For iMac
sudo darwin-rebuild switch --flake .#iMac
home-manager switch --flake .#yanlin@iMac
sudo darwin-rebuild switch --flake .#imac
home-manager switch --flake .#yanlin@imac
```
#### NixOS Host:
```bash
# For home server (hs)
sudo nixos-rebuild switch --flake .#hs
home-manager switch --flake .#yanlin@hs
```
The separation of system and home configurations provides:
- **Consistent workflow** across all platforms
- **Clean separation of concerns** between system and user configurations
- **Independent updates** - update system or home environment separately
- **Better maintainability** with no duplicate configuration references

View file

@ -42,7 +42,6 @@
./hosts/nixos/hs/system.nix
./hosts/nixos/hs/disk-config.nix
];
specialArgs = { inherit home-manager nixvim claude-code; };
};
homeConfigurations = {

View file

@ -1,8 +1,7 @@
{ config, pkgs, home-manager, nixvim, claude-code, ... }: {
{ config, pkgs, ... }: {
imports = [
./hardware-configuration.nix
./disk-config.nix
home-manager.nixosModules.home-manager
../../../modules/tailscale.nix
../../../modules/podman.nix
../../../modules/traefik.nix
@ -218,14 +217,6 @@
# Enable experimental nix features
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Home Manager configuration
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.yanlin = import ./home.nix;
extraSpecialArgs = { inherit claude-code nixvim; };
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave

View file

@ -27,7 +27,8 @@ in
hm = "home-manager";
hms = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname)";
hms-offline = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname) --option substitute false";
nreb = "sudo nixos-rebuild switch --flake ~/.config/nix#$(hostname)";
doss = "sudo darwin-rebuild switch --flake ~/.config/nix#$(hostname)";
noss = "sudo nixos-rebuild switch --flake ~/.config/nix#$(hostname)";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# macOS-specific app aliases