Skip to content

feat(sops): integrate sops-nix for declarative secrets management#8

Open
Hastyshell wants to merge 4 commits into
mainfrom
feat/sops-nix
Open

feat(sops): integrate sops-nix for declarative secrets management#8
Hastyshell wants to merge 4 commits into
mainfrom
feat/sops-nix

Conversation

@Hastyshell
Copy link
Copy Markdown
Owner

Summary

  • Add sops-nix flake input and inject NixOS + home-manager sops modules into mkHost
  • NixOS-level sops uses SSH host keys (/etc/ssh/ssh_host_ed25519_key) for decryption
  • Home-manager-level sops uses personal age key (~/.config/sops/age/keys.txt)
  • Create .sops.yaml with age public keys and per-host creation rules
  • Create initial encrypted secrets.yaml for both hasty-desktop and vmware-desktop

Manual steps required after merge

  1. vmware-desktop age key: Replace PLACEHOLDER_RUN_ssh-to-age_ON_VMWARE_DESKTOP in .sops.yaml with the actual key:

    nix shell nixpkgs#ssh-to-age -c sh -c 'ssh-to-age < /etc/ssh/ssh_host_ed25519_key.pub'

    Then re-encrypt vmware-desktop's secrets: sops updatekeys hosts/nixos/vmware-desktop/secrets.yaml

  2. Personal age key has been generated at ~/.config/sops/age/keys.txt on this machine

Test plan

  • nix eval .#nixosConfigurations.hasty-desktop.config.sops.defaultSopsFile evaluates correctly
  • After filling in vmware-desktop key, nixos-rebuild build --flake .#hasty-desktop succeeds
  • After nixos-rebuild switch, verify /run/secrets/ directory exists
  • sops hosts/nixos/hasty-desktop/secrets.yaml opens editor with decrypted content

Add sops-nix as a flake input and inject both NixOS and home-manager
sops modules into mkHost. NixOS-level sops uses SSH host keys for
decryption; home-manager-level sops uses a personal age key. Includes
.sops.yaml config and initial encrypted secrets.yaml for both hosts.
vmware-desktop does not need secrets management. Add enableSops ? false
to mkHost so sops modules are only injected when explicitly opted in.
Remove vmware-desktop secrets.yaml and its entry from .sops.yaml.
Follow the same pattern as secureboot.nix: declare custom.nixos.sops.enable
as a NixOS option, add modules/system/nixos/sops.nix that always imports
the sops-nix module and conditionally applies config via mkIf. Host-specific
config (defaultSopsFile, age.keyFile) lives in the host's configuration.nix
and home.nix. mkHost is restored to its original clean form.
Add modules/home/share/sops.nix that declares custom.sops options
(enable, defaultSopsFile, keyFile) and configures sops-nix HM module
via mkIf. hasty-desktop/home.nix is reduced to setting the options.
NixOS sops.nix no longer needs to manage sharedModules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant