NixOS
Layout
Configuration lives under conf/:
conf/
├── machines/
│ ├── hp/
│ └── thinkpad/
├── modules/
├── secrets/
└── shared.nix
conf/shared.nix: shared NixOS and Home Manager modules.conf/machines/{machine}/configuration.nix: host-specific settings.conf/machines/{machine}/hardware-configuration.nix: generated hardware.conf/modules/: extra config assets used by Home Manager.conf/secrets/owais.yaml: encrypted SOPS secrets.
Rebuild
sudo nixos-rebuild switch --flake .#$(hostname)
sudo nixos-rebuild test --flake .#$(hostname)
nix flake update
Configurations currently provided by the flake:
nix-haxorus: ThinkPadowais-nix-hp: HP
Add a machine
-
Create
conf/machines/{machine}/. -
Generate hardware config:
sudo nixos-generate-config --show-hardware-config \ > conf/machines/{machine}/hardware-configuration.nix -
Add
configuration.niximporting hardware and(import ../../shared.nix).nixos. -
Add a
nixosConfigurations.{hostname}entry inflake.nix.
SOPS
The system imports sops-nix from conf/shared.nix and exposes secrets under
/run/secrets/.
Useful commands:
SOPS_AGE_KEY_FILE=$(pwd)/age.txt sops conf/secrets/owais.yaml
SOPS_AGE_KEY_FILE=$(pwd)/age.txt sops -d conf/secrets/owais.yaml
sops updatekeys conf/secrets/owais.yaml
The personal age key is documented in age.txt. .sops.yaml controls which
files are encrypted and which recipients can decrypt them.