sops: Add assertions to validate secret existence at eval time

This commit is contained in:
SebastianStork 2026-02-27 22:26:15 +01:00
parent dab77776f9
commit 87de9e1c4e
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q

View file

@ -34,5 +34,13 @@ in
]; ];
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";
});
}; };
} }