1

Modules/Agenix: Change to system module

This commit is contained in:
2025-07-09 03:28:52 +02:00
parent f47feb8193
commit 4f6a4dea3e
15 changed files with 34 additions and 45 deletions

View File

@ -0,0 +1,33 @@
{
config,
lib,
mylib,
pkgs,
username,
publicKeys,
...
}: let
inherit (config.modules) agenix;
in {
options.modules.agenix = import ./options.nix {inherit lib mylib;};
config = {
# NOTE: See the generated secrets.nix file in home/christoph/default.nix
# Register generated secrets to the age system module
age.secrets = let
mkSecretIfExists = name:
# If this user has already encrypted the secret...
if builtins.pathExists ./${name}.age
# ...we will register it with age...
then {${name}.file = ./${name}.age;}
# ...otherwise we link to a bogus file.
else {${name}.file = ./void.age;};
in
lib.mkIf
# If this user defined any secrets...
(builtins.hasAttr "${username}" agenix.secrets)
# ...we will register all secrets files that have already been generated.
(lib.mkMerge (builtins.map mkSecretIfExists agenix.secrets.${username}));
};
}