Skip to content

Commit

Permalink
Merge pull request #56 from LoganBarnett/agenix-rekey-command-notify-…
Browse files Browse the repository at this point in the history
…which-node-is-missing

indicate which node is missing agenix and agenix-rekey modules
  • Loading branch information
oddlama authored Dec 14, 2024
2 parents 662522c + 4198b6e commit 1472730
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions apps/rekey.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let
concatMapStrings
concatStringsSep
escapeShellArg
filter
filterAttrs
flip
hasPrefix
Expand Down Expand Up @@ -40,8 +39,24 @@ let
drvPathFor =
hostCfg: builtins.unsafeDiscardStringContext (toString (derivationFor hostCfg).drvPath);

nodesWithDerivationStorage = filter (x: x.config.age.rekey.storageMode == "derivation") (
attrValues nodes
nodesWithDerivationStorage = attrValues (
filterAttrs (
n: v:
# This is our first time accessing the age and age.rekey properties.
# If both agenix and agenix-rekey are not loaded onto the node being
# processed, `agenix rekey` will fail. This is our opportunity to
# inform the user which node is problematic and what must be done to
# address the issue.
assert assertMsg (v.config ? age) ''
Node "${n}" is missing the agenix module.
agenix-rekey cannot continue until all nodes include the agenix module.
'';
assert assertMsg (v.config.age ? rekey) ''
Node "${n}" is missing the agenix-rekey module.
agenix-rekey cannot continue until all nodes include the agenix-rekey module.
'';
v.config.age.rekey.storageMode == "derivation"
) nodes
);

rekeyCommandsForHost =
Expand Down

0 comments on commit 1472730

Please sign in to comment.