Configuration for my homelab that attempts to follow the Dendritic pattern.
Structure copied from inspired by https://github.com/HarrisonCentner/nixconfig
nix build .#nixosConfigurations.{{host}}.config.system.build.toplevel for one host, or
nix flake check --no-build for the entire flake.
deploy --skip-checks .#{{host}}
nixos-anywhere --flake .#{{host}} --target-host {{user@hostname}}
or, https://github.com/nix-community/disko/blob/master/docs/quickstart.md
Create a new hosts/{{host}}/default.nix, then import ./_configuration.nix
Either manually create and fill in the file or pass in
--generate-hardware-config nixos-generate-config hosts/{{host}}/_configuration.nix
when running nixos-anywhere
Add {{host}} to ciHosts in modules/flake/checks.nix so CI builds it and deploy-schema covers it.
NEW! run ./scripts/new-sops-host.nu
set -gx temp $(mktemp -d) # or export in bash
# use just $temp/etc/ssh if host does not have impermanence
install -d -m 0755 "$temp/persist/etc/ssh"
ssh-keygen -t ed25519 -N "" -C "root@{{host}}" -f "$temp/persist/etc/ssh/ssh_host_ed25519_key"
chmod 0600 "$temp/persist/etc/ssh/ssh_host_ed25519_key"nixos-anywhere --flake .#{{host}} --extra-files "$temp" --target-host {{user@hostname}}
rm -r "$temp"nix build .#nixosConfigurations.{{minimal-iso|kde-iso}}.config.system.build.isoImage
To make the attic cache accessible, pass a reusable, ephemeral, short-expiry auth key:
TS_AUTHKEY=tskey-auth-... nix build --impure .#nixosConfigurations.minimal-iso.config.system.build.isoImageThe installer then enrols itself on boot with --state=mem:.
However, the key is visible in the Nix store, so this must be treated as sensitive.
sops ../nixos-secrets/secrets.yaml
Remember to nix flake update secrets
ssh-to-age -i /path/to/new/host/.ssh/id_ed25519.pub
nvim ../nixos-secrets/.sops.yaml # add the new key
sops updatekeys ../nixos-secrets/secrets.yamlRemember to nix flake update secrets
nvim scripts/patch-nixpkgs.sh # add commits/branches/PRs
GITHUB_TOKEN=$(gh auth token) ./scripts/patch-nixpkgs.sh