# modules/home/sops.nix — sops-nix for the user: secrets/ (everything outside # secrets/system/), encrypted to the user's age key only (.sops.yaml) and # decrypted into $XDG_RUNTIME_DIR/secrets.d (symlinked at ~/.config/sops-nix/secrets) # by a user service at login, readable only by daemonsec. # # Use this for secrets that belong to the user's programs (API tokens an app # reads from a file, an rclone config, …); use modules/hosts/laptop/sops.nix for # anything a system service needs. System secrets live in secrets/system/ and # this key cannot decrypt them; edit those as root (see that file). # # Edit a user secret: TMPDIR=/dev/shm sops secrets/ # # sops.secrets.example = { }; # → ~/.config/sops-nix/secrets/example # sops.secrets.rclone = { path = "${config.xdg.configHome}/rclone/rclone.conf"; }; # # secretspec (modules/home/shell.nix) is the complement: per-project runtime # secrets pulled from the keyring at `secretspec run`, declared next to the # project in secretspec.toml, not in this repo. { ... }: { flake.homeModules.sops = { config, inputs, pkgs, lib, ... }: { imports = [ inputs.sops-nix.homeManagerModules.sops ]; sops = { defaultSopsFile = ../../secrets/secrets.yaml; age.keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt"; age.sshKeyPaths = [ ]; gnupg.sshKeyPaths = [ ]; }; home.packages = with pkgs; [ sops age ssh-to-age # turn an ssh-ed25519 key into an age recipient when adding another machine ]; # sops-nix's activation step restarts the sops-nix user unit. That unit is a # home-manager file (~/.config/systemd/user/sops-nix.service), linked by the # linkGeneration step, and the user systemd manager only sees new unit # files after a daemon-reload, which home-manager runs at the very end. With # the extra steps this config adds, the DAG happened to order sops-nix # before linkGeneration, so the first switch died with "Unit # sops-nix.service not found". This entry pins the order: linkGeneration → # daemon-reload → sops-nix. home.activation.reloadUserUnitsForSops = lib.hm.dag.entryBetween [ "sops-nix" ] [ "linkGeneration" "installPackages" ] '' ${pkgs.systemd}/bin/systemctl --user daemon-reload 2>/dev/null || true ''; } ; }