diff --git a/packages/checks/modules/nixos/age-dummy-secrets.nix b/packages/checks/modules/nixos/age-dummy-secrets.nix new file mode 100644 index 0000000..05c120b --- /dev/null +++ b/packages/checks/modules/nixos/age-dummy-secrets.nix @@ -0,0 +1,33 @@ +{ config, lib, ... }: +with lib; + +let + t = { + string = default: mkOption { + type = types.str; + inherit default; + }; + }; +in + +{ + options.age.secrets = mkOption { + type = types.attrsOf (types.submodule ({ name, config, ... }: { + options = { + file = mkSinkUndeclaredOptions {}; + owner = t.string "root"; + group = t.string "root"; + mode = t.string "400"; + path = t.string "/etc/dummy-secrets/${name}"; + }; + })); + }; + config.environment.etc = mapAttrs' (name: secret: { + name = removePrefix "/etc/" secret.path; + value = mapAttrs (const mkDefault) { + user = secret.owner; + inherit (secret) mode group; + text = builtins.hashString "md5" name; + }; + }) config.age.secrets; +}