about summary refs log tree commit diff
path: root/modules/secrets/default.nix
blob: e6f3a7ba26c43381a131c4032fb9b95654db0d9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{ config, inputs, lib, options, ... }:

{
  imports = [ inputs.agenix.nixosModules.age ];

  config.age = {
    secrets = let
      toName = lib.removeSuffix ".age";
      userExists = u: builtins.hasAttr u config.users.users;
      # Only set the user if it exists, to avoid warnings
      userIfExists = u: if userExists u then u else "root";
      toSecret = name:
        { owner ? "root", ... }: {
          file = ./. + "/${name}";
          owner = lib.mkDefault (userIfExists owner);
        };
      convertSecrets = n: v: lib.nameValuePair (toName n) (toSecret n v);
      secrets = import ./secrets.nix;
    in lib.mapAttrs' convertSecrets secrets;

    identityPaths = options.age.identityPaths.default
      ++ [ "/home/fcuny/.ssh/id_ed25519" ];
  };
}