From 87de9e1c4e22a9f80e6515b0d430932fd3194c22 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Fri, 27 Feb 2026 22:26:15 +0100 Subject: [PATCH] sops: Add assertions to validate secret existence at eval time --- modules/nixos/sops.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/nixos/sops.nix b/modules/nixos/sops.nix index 4add3a9..760fceb 100644 --- a/modules/nixos/sops.nix +++ b/modules/nixos/sops.nix @@ -34,5 +34,13 @@ in ]; 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"; + }); }; }