feat(sops): integrate sops-nix for declarative secrets management#8
Open
Hastyshell wants to merge 4 commits into
Open
feat(sops): integrate sops-nix for declarative secrets management#8Hastyshell wants to merge 4 commits into
Hastyshell wants to merge 4 commits into
Conversation
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.
8600318 to
451405a
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sops-nixflake input and inject NixOS + home-manager sops modules intomkHost/etc/ssh/ssh_host_ed25519_key) for decryption~/.config/sops/age/keys.txt).sops.yamlwith age public keys and per-host creation rulessecrets.yamlfor bothhasty-desktopandvmware-desktopManual steps required after merge
vmware-desktop age key: Replace
PLACEHOLDER_RUN_ssh-to-age_ON_VMWARE_DESKTOPin.sops.yamlwith 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.yamlPersonal age key has been generated at
~/.config/sops/age/keys.txton this machineTest plan
nix eval .#nixosConfigurations.hasty-desktop.config.sops.defaultSopsFileevaluates correctlynixos-rebuild build --flake .#hasty-desktopsucceedsnixos-rebuild switch, verify/run/secrets/directory existssops hosts/nixos/hasty-desktop/secrets.yamlopens editor with decrypted content