From 68de43b467efb4252ac68480b2301370f4ef8e8a Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Fri, 27 Nov 2026 00:35:42 +0000 Subject: [PATCH] secrets: Name host keys for slop-broker approvals Approvals list host keys abbreviated, which says little about which box a secret goes to. Write each system's name after its key as the key's comment, which age ignores and slop-broker shows as the name. Co-Authored-By: Claude Opus 5.5 --- docs/slop-broker.md | 5 +++-- secrets.nix | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/slop-broker.md b/docs/slop-broker.md index 3ddd343..6209617 100644 --- a/docs/slop-broker.md +++ b/docs/slop-broker.md @@ -79,8 +79,9 @@ collects garbage in that store on every run, which the roots survive until they `master`'s `secrets.nix`. The approval says which file the content really is and whether the recipients match `master`'s rules for it (see the [design](https://git.nul.ie/dev/slop-broker/src/branch/main/docs/design.md#secrets)). -- `secrets.names` labels `dev` and `slop-broker` in approvals (`lib.my.c.ageKeyFiles`); host keys - are shown abbreviated. +- Approvals label recipients by name: `dev` and `slop-broker` through `secrets.names` + (`lib.my.c.ageKeyFiles`), and host keys through the system name `secrets.nix` writes after each + key as its comment. ### `master` is protected diff --git a/secrets.nix b/secrets.nix index dbbe576..c3822b5 100644 --- a/secrets.nix +++ b/secrets.nix @@ -2,8 +2,8 @@ let self = getFlake (toString ./.); inherit (self) lib; - inherit (builtins) mapAttrs attrValues readFile getFlake; - inherit (lib) fileContents optional flatten zipAttrsWith nameValuePair mapAttrs'; + inherit (builtins) mapAttrs readFile getFlake; + inherit (lib) fileContents optional flatten zipAttrsWith nameValuePair mapAttrs' mapAttrsToList; secretPath = p: "secrets/${p}.age"; @@ -15,12 +15,13 @@ let secretKeys = zipAttrsWith (_: keys: flatten (keys ++ defaultKeys)) - (map - (c: let cfg = c.config.my.secrets; in mapAttrs' + (mapAttrsToList + # The comment names the key in `slop-broker` approvals; age ignores it + (name: c: let cfg = c.config.my.secrets; in mapAttrs' (f: _: nameValuePair (secretPath f) - (optional (cfg.key != null) cfg.key)) + (optional (cfg.key != null) "${cfg.key} ${name}")) cfg.files) - (attrValues self.nixosConfigurations)); + self.nixosConfigurations); in mapAttrs (_: keys: { publicKeys = keys; }) secretKeys