A modular and declarative configuration for NixOS and Home Manager, powered by flakes and sops-nix for secrets management.
Follow these steps to set up a brand-new machine with this configuration:
nix shell nixpkgs#age --command age-keygen -o keys.txtAdd the public key to .sops.yaml and use for encrypting the following secrets:
secrets/hosts/common.ymlsecrets/hosts/<new-host>.yml
export SOPS_AGE_KEY_FILE=/path/to/master/keys.txt
sops updatekeys secrets/hosts/*
sops updatekeys secrets/users/*Copy the generated keys.txt file to the remote host:
scp keys.txt root@<new-host>:/var/lib/sops-nix/keys.txt- Install the system using your
flake.nix. - Ignore
sops-nix.serviceerrors during first boot — this is expected since user keys are not yet available.
sudo nixos-install --flake .#<new-host>Reboot into the freshly installed NixOS.
For each user, move their private key to:
/home/<username>/.config/sops/age/keys.txt
sudo nixos-rebuild switch --flake .#<new-host>Now everything should work, including host and user secrets decryption.
