nixfiles/nixos/modules/secrets.nix

26 lines
635 B
Nix
Raw Normal View History

2022-02-22 00:59:57 +00:00
{ lib, config, secretsPath, ... }:
let
inherit (builtins) mapAttrs;
2022-02-22 01:30:27 +00:00
inherit (lib) mkMerge mkIf;
2022-02-22 00:59:57 +00:00
inherit (lib.my) mkOpt';
cfg = config.my.secrets;
in
{
options.my.secrets = with lib.types; {
key = mkOpt' (nullOr str) null "Public key that secrets for this system should be encrypted for.";
files = mkOpt' (attrsOf unspecified) { } "Secrets to decrypt with agenix.";
};
2022-02-22 01:30:27 +00:00
config = mkMerge [
{
age.secrets = mapAttrs (f: opts: {
file = "${secretsPath}/${f}.age";
} // opts) cfg.files;
}
(mkIf config.my.build.isDevVM {
age.identityPaths = [ "/tmp/xchg/dev.key" ];
})
];
2022-02-22 00:59:57 +00:00
}