mirror of
https://github.com/ryantm/agenix.git
synced 2024-11-25 11:08:30 +03:00
service -> services
This commit is contained in:
parent
0b898d9991
commit
2b8f414fa6
1 changed files with 9 additions and 11 deletions
|
@ -101,11 +101,11 @@ let
|
||||||
default = "";
|
default = "";
|
||||||
description = "A script to run when secret is updated.";
|
description = "A script to run when secret is updated.";
|
||||||
};
|
};
|
||||||
service = mkOption {
|
services = mkOption {
|
||||||
type = types.str;
|
type = types.listOf types.str;
|
||||||
default = "";
|
default = [];
|
||||||
description = "The systemd service that uses this secret. Will be restarted when the secret changes.";
|
description = "The systemd services that uses this secret. Will be restarted when the secret changes.";
|
||||||
example = "wireguard-wg0";
|
example = "[ wireguard-wg0 ]";
|
||||||
};
|
};
|
||||||
symlink = mkEnableOption "symlinking secrets to their destination" // { default = true; };
|
symlink = mkEnableOption "symlinking secrets to their destination" // { default = true; };
|
||||||
};
|
};
|
||||||
|
@ -227,18 +227,15 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# services that watch for file changes and exectue the configured action
|
|
||||||
systemd.services = lib.mkMerge
|
systemd.services = lib.mkMerge
|
||||||
(lib.mapAttrsToList
|
(lib.mapAttrsToList
|
||||||
(name: {action, service, file, path, mode, owner, group, ...}:
|
(name: {action, services, file, path, mode, owner, group, ...}:
|
||||||
let
|
let
|
||||||
fileHash = builtins.hashFile "sha256" file;
|
fileHash = builtins.hashFile "sha256" file;
|
||||||
restartTriggers = [ fileHash path mode owner group ];
|
restartTriggers = [ fileHash path mode owner group ];
|
||||||
in
|
in
|
||||||
lib.mkMerge [
|
lib.mkMerge [
|
||||||
(lib.mkIf (service != "") {
|
(lib.genAttrs services (_: { inherit restartTriggers; }))
|
||||||
${service} = { inherit restartTriggers; };
|
|
||||||
})
|
|
||||||
(lib.mkIf (action != "") {
|
(lib.mkIf (action != "") {
|
||||||
"agenix-${name}-action" = {
|
"agenix-${name}-action" = {
|
||||||
inherit restartTriggers;
|
inherit restartTriggers;
|
||||||
|
@ -260,7 +257,8 @@ in
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
})]) cfg.secrets);
|
})
|
||||||
|
]) cfg.secrets);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue