1
0
Fork 0
NixOS configuration
Find a file
2025-12-11 20:25:29 +01:00
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

  1. Create hosts/<hostname>/ directory
  2. Add hardware-configuration.nix (from nixos-generate-config)
  3. Add default.nix with host-specific system config
  4. Create home/<hostname>.nix that imports ./default.nix
  5. Optionally create home/modules/<hostname>/ for host-specific home modules and non-nix config files
  6. Add host to flake.nix:
nixosConfigurations = {
  # ...existing hosts...
  newhost = mkHost { hostname = "newhost"; };
};

Adding a new home module

  1. Create home/modules/<module-name>.nix
  2. 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.nixenvironment.persistence
  • Home: home/default.nixhome.persistence

Add new directories as needed when installing new applications.