Install notes for this NixOS flake. Built on flake-parts with den and flake-file, using disko, impermanence, sops-nix and home-manager.
Everything lives under modules/, loaded by import-tree — every file is a flake-parts module. flake.nix itself is generated (see Flake inputs).
modules/defaults/— universal baseline; each file is one aspect registered intoden.default, which den applies to every host automatically (boot, networking, nix, security, disko, home-manager, rescue)modules/hosts/<hostname>/— self-contained host: registration (den.hosts), aspect composition, disko export;_config/holds the machine's hardware reality (disko, hardware, gpu, filesystem, secrets)modules/users/— user entities (account, home-manager basics, user secrets)modules/features/— everything else, as den aspects; most register into theworkstationbundle hosts include, per-host choices (plymouth, cachyos-kernel) stay outside itmodules/packages/— custom packages, overlaid onto nixpkgs and exported as flake packages (nix build .#dracula-cursors)
Replace <hostname> with a host folder under modules/hosts.
Format the drive and install in one step with disko-install:
sudo nix --extra-experimental-features "nix-command flakes" \
run "github:nix-community/disko/latest#disko-install" \
-- --flake github:bryewalks/nixos#<hostname> \
--disk main /dev/<disk>sudo rebootAlternatively, format and install as separate steps (avoids disko-install building in the ISO's tmpfs):
sudo nix --extra-experimental-features "nix-command flakes" \
run github:nix-community/disko \
-- --mode destroy,format,mount \
--flake github:bryewalks/nixos#<hostname>sudo nixos-install --flake github:bryewalks/nixos#<hostname>sudo rebootContinue with Post install.
Create modules/hosts/<hostname>/ with:
default.nix— registers the host (den.hosts) with its capabilities (persistRoot— must match the disko mountpoint,themeName, optionallyswapSizeGiBandstorageRoot; leave outpasswordConfigureduntil Post install), exports its disko config (flake.diskoConfigurations), and composes its aspects (workstation, per-host extras; theden.defaultbaseline applies automatically; hostname comes from the entity name) (example)_config/default.nix—sops.defaultSopsFile,system.stateVersion(the release being installed), host options (example)_config/disko.nix— disk layout (example)_config/secrets.yaml— optional; ssh key (sshKey) and user password (hashedPassword), see Secrets management
Format and mount the drive with disko:
sudo nix --extra-experimental-features "nix-command flakes" \
run github:nix-community/disko \
-- --mode destroy,format,mount \
--flake github:bryewalks/nixos#<hostname>Clone the repo into the mounted disk:
sudo git clone https://github.com/bryewalks/nixos /mnt/tmp/nixosGenerate the hardware config:
sudo nixos-generate-config --no-filesystems \
--show-hardware-config \
| sudo tee /mnt/tmp/nixos/modules/hosts/<hostname>/_config/hardware.nix \
> /dev/nullInstall:
sudo nixos-install --flake /mnt/tmp/nixos#<hostname>Commit the hardware config now, or regenerate it after first login.
sudo rebootContinue with Post install.
Copy the sops age key to persistent storage:
sudo cp /path/to/sops/keys.txt /persist/system/var/lib/sops/keys.txtRebuild (activates sops secrets, including the hashed password):
sudo nixos-rebuild switch --flake github:bryewalks/nixos#<hostname>Add passwordConfigured = true; to the host entity in modules/hosts/<hostname>/default.nix and rebuild again. This switches the user from initialPassword = "password" to the sops-managed hashedPassword (and enables openssh) — until then the default plaintext password remains active.
sudo nixos-rebuild switch --flake github:bryewalks/nixos#<hostname>Clone the repo for day-to-day use:
git clone git@github.com:bryewalks/nixosEnable the pre-commit hook (treefmt + flake.nix sync checks, see .githooks/):
git config core.hooksPath .githooksflake.nix is generated by flake-file — never edit it by hand. Each module declares the inputs it consumes via flake-file.inputs (e.g. gaming declares steam-config-nix); core inputs no single feature owns (nixpkgs, den, home-manager) live in modules/den.nix, which also wires the flake-file dendritic flakeModule. Deleting a feature removes its input on the next regeneration.
After adding, removing, or changing an input declaration:
nix run .#write-flakeThen lock the new input and rebuild as usual (nh os switch --update is unaffected by flake-file otherwise). Commit the regenerated flake.nix together with the module change — nix flake check fails if they drift.
If flake.nix is ever lost, restore it from git, or regenerate without an evaluable flake:
nix-shell https://github.com/vic/flake-file/archive/main.tar.gz \
-A flake-file.sh --run write-flakesops-nix with age. Secrets live in per-host secrets.yaml files, decrypted at build/activation time.
Paths:
- Age key file:
/persist/system/var/lib/sops/keys.txt(set inmodules/features/sops/default.nix) - Per-host secrets:
modules/hosts/<hostname>/_config/secrets.yaml(viasops.defaultSopsFilein each host's_config/default.nix)
Expected secrets:
sshKey— private key contents for/home/brye/.ssh/id_ed25519hashedPassword— hashed password used byusers.users.brye.hashedPasswordFile
Generate a key where sops-nix expects it:
mkdir -p /persist/system/var/lib/sops
age-keygen -o /persist/system/var/lib/sops/keys.txtPrint the public key (for secrets.yaml recipients):
age-keygen -y /persist/system/var/lib/sops/keys.txtCreate or edit a secrets file with an explicit recipient:
sops --age <publicKey> modules/hosts/<hostname>/_config/secrets.yamlopenssl passwd -6Check the flake for errors (no build):
nix flake check --no-buildFormat the tree (treefmt + nixfmt, configured in modules/formatter.nix; nix flake check fails on unformatted files):
nix fmtEvaluate a specific host:
nix eval .#nixosConfigurations.<hostname>.config.system.build.toplevel.drvPathGenerate a hardware config on a non-NixOS machine (requires nix):
sudo nix --extra-experimental-features "nix-command flakes" shell nixpkgs#nixos-install-tools -c nixos-generate-config --show-hardware-config > hardware.nix