2020-08-04 20:22:43 +00:00
|
|
|
with import <stockholm/lib>;
|
|
|
|
{ config, lib, pkgs, ... }: let
|
2016-02-21 04:27:37 +00:00
|
|
|
cfg = config.krebs.secret;
|
|
|
|
in {
|
|
|
|
options.krebs.secret = {
|
|
|
|
files = mkOption {
|
|
|
|
type = with types; attrsOf secret-file;
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkIf (cfg.files != {}) {
|
2020-08-04 20:22:43 +00:00
|
|
|
systemd.paths =
|
|
|
|
mapAttrs'
|
|
|
|
(name: file: nameValuePair "secret-trigger-${systemd.encodeName name}" {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
pathConfig.PathChanged = file.source-path;
|
|
|
|
})
|
|
|
|
cfg.files;
|
|
|
|
systemd.services =
|
|
|
|
mapAttrs'
|
|
|
|
(name: file: nameValuePair "secret-trigger-${systemd.encodeName name}" {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "${pkgs.systemd}/bin/systemctl restart ${file.service}";
|
|
|
|
};
|
|
|
|
})
|
|
|
|
cfg.files
|
|
|
|
//
|
|
|
|
mapAttrs'
|
|
|
|
(name: file: nameValuePair "secret-${systemd.encodeName name}" {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
ExecStart = toString [
|
|
|
|
"${pkgs.coreutils}/bin/install"
|
|
|
|
"-D"
|
|
|
|
"--compare"
|
|
|
|
"--verbose"
|
|
|
|
"--mode=${file.mode}"
|
|
|
|
"--owner=${file.owner.name}"
|
|
|
|
"--group=${file.group-name}"
|
|
|
|
file.source-path
|
|
|
|
file.path
|
|
|
|
];
|
|
|
|
};
|
|
|
|
})
|
|
|
|
cfg.files;
|
2016-02-21 04:27:37 +00:00
|
|
|
};
|
|
|
|
}
|