sops: Add assertions to validate secret existence at eval time

This commit is contained in:
SebastianStork 2026-02-26 19:27:34 +01:00
parent 1a78e2b1f0
commit 653a6f310b
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q

View file

@ -36,5 +36,13 @@ in
age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ]; age.sshKeyPaths = [ "${config.home.homeDirectory}/.ssh/id_ed25519" ];
defaultSopsFile = cfg.secretsFile; defaultSopsFile = cfg.secretsFile;
}; };
assertions =
config.sops.secrets
|> lib.attrNames
|> lib.map (secretPath: {
assertion = cfg.secrets |> lib.hasAttrByPath (secretPath |> lib.splitString "/");
message = "Sops secret `${secretPath}` must be defined in secrets.json";
});
}; };
} }