Separate system and home config on hs
This commit is contained in:
parent
8525cab1d6
commit
cb9f29154f
4 changed files with 56 additions and 33 deletions
70
README.md
70
README.md
|
|
@ -30,15 +30,22 @@ home-manager switch --flake github:Logan-Lin/nix-config#yanlin@iMac
|
||||||
.
|
.
|
||||||
├── flake.nix # Main flake configuration and package definitions
|
├── flake.nix # Main flake configuration and package definitions
|
||||||
├── hosts/ # Host-specific configurations
|
├── hosts/ # Host-specific configurations
|
||||||
│ └── darwin/ # macOS hosts
|
│ ├── darwin/ # macOS hosts
|
||||||
│ ├── home-default.nix # Common home configuration imported by all hosts
|
│ │ ├── home-default.nix # Common home configuration for Darwin
|
||||||
│ ├── system-default.nix # Common system configuration for macOS
|
│ │ ├── system-default.nix # Common system configuration for macOS
|
||||||
│ ├── iMac/ # iMac configuration
|
│ │ ├── iMac/ # iMac configuration
|
||||||
|
│ │ │ ├── system.nix # System configuration
|
||||||
|
│ │ │ └── home.nix # Home configuration (imports ../home-default.nix)
|
||||||
|
│ │ └── mba/ # MacBook Air configuration
|
||||||
│ │ ├── system.nix # System configuration
|
│ │ ├── system.nix # System configuration
|
||||||
│ │ └── home.nix # Home configuration (imports ../home-default.nix)
|
│ │ └── home.nix # Home configuration (imports ../home-default.nix)
|
||||||
│ └── MacBook-Air/ # MacBook Air configuration
|
│ └── nixos/ # NixOS hosts
|
||||||
│ ├── system.nix # System configuration
|
│ ├── home-default.nix # Common home configuration for NixOS
|
||||||
│ └── home.nix # Home configuration (imports ../home-default.nix)
|
│ └── 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
|
├── modules/ # Home Manager configuration modules
|
||||||
│ ├── git.nix # Git configuration with aliases and settings
|
│ ├── git.nix # Git configuration with aliases and settings
|
||||||
│ ├── lazygit.nix # Lazygit with gruvbox theme and custom keybindings
|
│ ├── lazygit.nix # Lazygit with gruvbox theme and custom keybindings
|
||||||
|
|
@ -828,33 +835,58 @@ tailscale debug netmap
|
||||||
|
|
||||||
## 💻 Machine Configurations
|
## 💻 Machine Configurations
|
||||||
|
|
||||||
|
### Darwin Hosts (macOS)
|
||||||
- **`iMac`**: iMac configuration
|
- **`iMac`**: iMac configuration
|
||||||
- **`MacBook-Air`**: MacBook Air 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:
|
### Configuration Structure:
|
||||||
The configuration has been reorganized for better clarity:
|
The configuration has been reorganized for better clarity and consistency:
|
||||||
- **`hosts/darwin/`**: Contains all host-related configurations
|
|
||||||
- **`home-default.nix`**: Common home configuration shared by all hosts
|
#### 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
|
- **`system-default.nix`**: Common system configuration for macOS
|
||||||
- **Per-host directories**: Each host has its own directory with:
|
- **Per-host directories**: Each host has its own directory with:
|
||||||
- **`system.nix`**: Host-specific system configuration (imports ../system-default.nix)
|
- **`system.nix`**: Host-specific system configuration (imports ../system-default.nix)
|
||||||
- **`home.nix`**: Host-specific home configuration (imports ../home-default.nix)
|
- **`home.nix`**: Host-specific home configuration (imports ../home-default.nix)
|
||||||
|
|
||||||
The `home-default.nix` file contains all shared home configuration, including:
|
#### NixOS Host:
|
||||||
- Module imports (which now handle both configuration and package installation)
|
- **`hosts/nixos/`**: Contains NixOS host configurations
|
||||||
- Common packages not managed by modules
|
- **`home-default.nix`**: Common home configuration for NixOS hosts
|
||||||
- Base home settings
|
- **`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:
|
### Machine-specific Usage:
|
||||||
|
|
||||||
|
#### Darwin (macOS) Hosts:
|
||||||
```bash
|
```bash
|
||||||
# For MacBook Air
|
# For MacBook Air
|
||||||
sudo darwin-rebuild switch --flake .#MacBook-Air
|
sudo darwin-rebuild switch --flake .#mba
|
||||||
home-manager switch --flake .#yanlin@MacBook-Air
|
home-manager switch --flake .#yanlin@mba
|
||||||
|
|
||||||
# For iMac
|
# For iMac
|
||||||
sudo darwin-rebuild switch --flake .#iMac
|
sudo darwin-rebuild switch --flake .#imac
|
||||||
home-manager switch --flake .#yanlin@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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@
|
||||||
./hosts/nixos/hs/system.nix
|
./hosts/nixos/hs/system.nix
|
||||||
./hosts/nixos/hs/disk-config.nix
|
./hosts/nixos/hs/disk-config.nix
|
||||||
];
|
];
|
||||||
specialArgs = { inherit home-manager nixvim claude-code; };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
{ config, pkgs, home-manager, nixvim, claude-code, ... }: {
|
{ config, pkgs, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./disk-config.nix
|
./disk-config.nix
|
||||||
home-manager.nixosModules.home-manager
|
|
||||||
../../../modules/tailscale.nix
|
../../../modules/tailscale.nix
|
||||||
../../../modules/podman.nix
|
../../../modules/podman.nix
|
||||||
../../../modules/traefik.nix
|
../../../modules/traefik.nix
|
||||||
|
|
@ -218,14 +217,6 @@
|
||||||
# Enable experimental nix features
|
# Enable experimental nix features
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
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
|
# This value determines the NixOS release from which the default
|
||||||
# settings for stateful data, like file locations and database versions
|
# settings for stateful data, like file locations and database versions
|
||||||
# on your system were taken. It's perfectly fine and recommended to leave
|
# on your system were taken. It's perfectly fine and recommended to leave
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ in
|
||||||
hm = "home-manager";
|
hm = "home-manager";
|
||||||
hms = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname)";
|
hms = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname)";
|
||||||
hms-offline = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname) --option substitute false";
|
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 {
|
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
|
||||||
# macOS-specific app aliases
|
# macOS-specific app aliases
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue