lib.mapAttrs' (target: secret:
lib.nameValuePair (lib.removeSuffix ".service" secret.service) {
description = "Install secret ${secret.path}";
- after = [ "network.target" "network-online.target" ];
- wantedBy = lib.mkIf (!config.boot.isContainer) [ "multi-user.target" ];
script = ''
set -o pipefail
set -eux
serviceConfig = {
Type = "oneshot";
PrivateTmp = true;
+ RemainAfterExit = true;
WorkingDirectory = dirname secret.gnupgHome;
} // lib.optionalAttrs (match "^/.*" target == null) {
- RuntimeDirectory = dirname secret.path;
+ RuntimeDirectory = lib.removePrefix "/run/" (dirname secret.path);
RuntimeDirectoryMode = "711";
- RuntimeDirectoryPreserve = false; # FIXME: when does the removal actualy occur with with Type=oneshot?
+ RuntimeDirectoryPreserve = false;
};
}
) pass.secrets;
enable = true;
shellScript = lib.mkBefore ''
PATH="$PATH:${with pkgs; lib.makeBinPath [gnupg openssh]}"
+ (
set -x
gpg --decrypt '${pass.store}/root/key.pass.gpg' |
ssh '${config.install.target}' install -D -m 400 -o root -g root /dev/stdin /root/key.pass
+ )
'';
};
security.pass = {