NixOS configuration
| home | ||
| hosts | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
NixOS Configuration
Modular NixOS + Home Manager configuration with impermanence.
Structure
.
├── flake.nix # Flake definition with all hosts
├── hosts/
│ ├── shared.nix # Shared system configuration
│ ├── hyades/ # hyades
│ │ ├── default.nix # Host-specific system config
│ │ └── hardware-configuration.nix
└── home/
├── default.nix # Base home config (imports all modules)
├── hyades.nix # hyades home (extends default)
└── modules/
├── base.nix # Core packages, git, gpg
├── terminal.nix # kitty, zsh, starship, helix, yazi
├── gui.nix # GUI applications
├── dev.nix # Development tools
├── files/ # Non-nix config files
│ └── config.toml
└── hyades/ # hyades-specific home modules
├── files/ # hyades-specific non-nix config files
│ └── config.toml
└── default.nix
Usage
Rebuild system
# Rebuild current host
sudo nixos-rebuild switch --flake ~/nixos
# Rebuild specific host
sudo nixos-rebuild switch --flake ~/nixos#hyades
Update flake inputs
sudo nix flake update nixos
sudo nixos-rebuild switch --flake ~/nixos
Garbage collection
# Clean old generations
sudo nix-collect-garbage -d
nix-collect-garbage -d
# Or use the alias
gc
Adding a new host
- Create
hosts/<hostname>/directory - Add
hardware-configuration.nix(fromnixos-generate-config) - Add
default.nixwith host-specific system config - Create
home/<hostname>.nixthat imports./default.nix - Optionally create
home/modules/<hostname>/for host-specific home modules and non-nix config files - Add host to
flake.nix:
nixosConfigurations = {
# ...existing hosts...
newhost = mkHost { hostname = "newhost"; };
};
Adding a new home module
- Create
home/modules/<module-name>.nix - Import it in
home/default.nix(for all hosts) or specific host file
External config files
For configs that can't be managed via Nix, place them in home/modules/files/ and reference them:
home.file.".config/app/config.toml".source = ./files/app-config.toml;
Persistence
Persisted directories are defined in:
- System:
hosts/shared.nix→environment.persistence - Home:
home/default.nix→home.persistence
Add new directories as needed when installing new applications.