From 281ca7ed036d338f0f789b83f5ee5ed7e8abf37d Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Mon, 6 Apr 2026 22:36:19 +0200 Subject: [PATCH 1/2] sops: add workmac key --- .sops.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.sops.yaml b/.sops.yaml index 5477595..adfa8d0 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -1,8 +1,9 @@ # XXX: missing: macbook, thinknix?, at some point mobile keys: - &admins age1q80zzsgglj438verw74jghezn8ndpqldvg0mfxzwtaq4v5h7apusqysavz #framenix + - &workmac age1fft2ynhazjwtjmxsvt37qervtekktdln2968gjp4vcp5sp3jeg5segkz3x #workmac # Generate AGE keys from SSH keys with: - # nix-shell -p ssh-to-age --run 'ssh some.example.com /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age' + # nix-shell -p ssh-to-age --run 'ssh some.example.com cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age' - &machine_framenix age1kx93vp8l8jd6kz0kvk379udr5z8a9t6946w0ff5t9a2esn47nqzqlfzvwe creation_rules: # per-host secrets for host specific ones, but for service modules we could store and manage them also per module scope @@ -15,5 +16,6 @@ creation_rules: key_groups: - age: - *admins + - *workmac - *machine_framenix From 22ced0b1e36dbee38377be04bfc4b0a8dba6c48a Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Mon, 6 Apr 2026 22:36:50 +0200 Subject: [PATCH 2/2] sops: fix key path for darwin --- darwin/sops.nix | 2 +- home/modules/sops.nix | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/darwin/sops.nix b/darwin/sops.nix index a819347..3ffd153 100644 --- a/darwin/sops.nix +++ b/darwin/sops.nix @@ -6,7 +6,7 @@ }: { sops = { - age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + age.keyFile = "/Users/os/Library/Application Support/sops/age/keys.txt"; defaultSopsFile = lib.mkDefault ./secrets.yaml; defaultSopsFormat = "yaml"; # is the default. ini had some template rendering issues in practice }; diff --git a/home/modules/sops.nix b/home/modules/sops.nix index 0e18ffe..183d3cb 100644 --- a/home/modules/sops.nix +++ b/home/modules/sops.nix @@ -1,7 +1,32 @@ -{ inputs, ... }: { - sops = { - age.keyFile = "/home/user/.age-key.txt"; # must have no password! - # deliberately not setting `defaultSopsFile` because there is no clear file-hostname-mapping. Each separate home config has to configure this explicitly. - }; -} + inputs, + config, + lib, + pkgs, + ... +}: +let + homeKeys = + if pkgs.stdenv.isDarwin then + "/Users/${config.home.username}/Library/Application Support/sops/age/keys.txt" + else + "/home/${config.home.username}/.config/sops/age/keys.txt"; +in +lib.mkMerge [ + { + home.ensureDirs."${builtins.dirOf homeKeys}".mode = "0700"; + sops = { + age.keyFile = "/home/user/.age-key.txt"; # must have no password! + # deliberately not setting `defaultSopsFile` because there is no clear file-hostname-mapping. Each separate home config has to configure this explicitly. + }; + } + # linux machines: assumption: there is an OpenSSH server of which we are able to use the hostkey, like at the NixOS module. The `keyDir` is only used for the private admin key. + (lib.mkIf pkgs.stdenv.isLinux { + sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + }) + + # darwin: no SSH server, no hostkey => let's use the `keyDir` key both for encryption and decrpytion + (lib.mkIf pkgs.stdenv.isDarwin { + sops.age.keyFile = homeKeys; + }) +]