2023-05-03 16:40:21 +02:00
|
|
|
{ config, inputs, lib, ... }:
|
2021-02-14 14:13:31 +01:00
|
|
|
|
2021-09-25 16:36:57 +02:00
|
|
|
{
|
2021-09-25 13:31:43 +02:00
|
|
|
imports = [
|
|
|
|
inputs.agenix.nixosModules.age
|
|
|
|
];
|
|
|
|
|
2021-09-24 18:37:36 +02:00
|
|
|
config.age = {
|
|
|
|
secrets =
|
|
|
|
let
|
2021-09-25 19:01:03 +02:00
|
|
|
toName = lib.removeSuffix ".age";
|
2021-09-26 19:19:35 +02:00
|
|
|
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", ... }: {
|
2021-09-24 18:37:36 +02:00
|
|
|
file = ./. + "/${name}";
|
2021-09-26 19:19:35 +02:00
|
|
|
owner = lib.mkDefault (userIfExists owner);
|
2021-09-24 18:37:36 +02:00
|
|
|
};
|
2021-09-25 19:01:03 +02:00
|
|
|
convertSecrets = n: v: lib.nameValuePair (toName n) (toSecret n v);
|
2021-09-24 18:37:36 +02:00
|
|
|
secrets = import ./secrets.nix;
|
|
|
|
in
|
|
|
|
lib.mapAttrs' convertSecrets secrets;
|
|
|
|
};
|
2021-02-14 14:13:31 +01:00
|
|
|
}
|