Flake-based, multi-host NixOS configuration.
flake.nix -- defines nixosConfigurations per machine
machines/<name>/default.nix -- machine-specific: hostname, imports, stateVersion
machines/<name>/system/hardware.nix -- machine-generated (nixos-generate-config), never hand-written
machines/<name>/system/*.nix -- config specific to this one host only (CPU microcode, etc.)
machines/<name>/users/<user>/default.nix -- per-user account + home-manager config for that machine
modules/nixos/system/ -- base config applied to every machine unconditionally
(bootloader, audio, networking, locale, nix settings,
packages, home-manager wiring)
modules/nixos/<category>/*.nix -- shared but opt-in modules (e.g. hardware/nvidia.nix,
desktop/niri.nix) that a machine pulls in by importing
the file directly, only if it needs it
Adding a new machine later (laptop, homelab, vps) means adding
machines/<name>/ and one line in flake.nix. A module every machine should
get goes in modules/nixos/system; a module only some machines want (a GPU
driver, a desktop session, a server-only service) goes in its own
modules/nixos/<category>/ file and gets imported explicitly by the
machines that need it; anything specific to one physical machine and not
meant to be reused stays in that machine's own tree.
- Boot the target machine from a NixOS installer ISO.
- Partition/format the disk and mount it at
/mnt(UEFI + systemd-boot expects an ESP mounted at/mnt/boot). - Generate the real hardware config:
nixos-generate-config --root /mnt - Copy
/mnt/etc/nixos/hardware-configuration.nixovermachines/desktop/system/hardware.nixin this repo, replacing the placeholder. - Adjust
modules/nixos/system/locale.nix(timezone) andmachines/desktop/users/alexthvest/default.nix(username/description) if needed. - Install:
nixos-install --root /mnt --flake .#desktop - Reboot, log in with the
initialPasswordset inusers.nix, then immediately runpasswdand remove/replace that line.
sudo nixos-rebuild switch --flake .#desktop
Desktop session is niri (Wayland compositor), greeted by ReGreet via greetd.