summaryrefslogtreecommitdiff
path: root/modules/nixos/traits/secrets.nix
blob: 042318313f8da707e6b140b4525f319c286323db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
  config,
  lib,
  inputs,
  ...
}:

let
  cfg = config.traits.secrets;
in

{
  options.traits.secrets = {
    enable = lib.mkEnableOption "secrets management";

    secretsDir = lib.mkOption {
      type = lib.types.path;
      default = inputs.self + "/secrets/${config.networking.hostName}";
      defaultText = lib.literalExample "inputs.self + \"/secrets/\${config.networking.hostName}\"";
      description = "Path to your `secrets.nix` subdirectory.";
    };
  };

  imports = [ inputs.agenix.nixosModules.default ];

  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        _module.args = {
          inherit (cfg) secretsDir;
        };

        age = {
          identityPaths = [ "/etc/age/key" ];
        };
      }
    ]
  );
}