From 0025a4bb2a77bd8a21f2771717c1cc90068d3391 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 3 Sep 2023 21:18:50 +0200 Subject: [PATCH] checks: add age dummy secrets NixOS module --- .../modules/nixos/age-dummy-secrets.nix | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 packages/checks/modules/nixos/age-dummy-secrets.nix 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; +}