{ pkgs, lib, config, ... }:
let
- inherit (builtins) head listToAttrs match split;
+ inherit (builtins) dirOf head listToAttrs match split;
inherit (lib) types;
inherit (config.security) pass;
- dirname = p:
- let dir = match "^(.+)/[^/]*$" p; in
- if dir == [] then "." else head dir;
escapeUnitName = name:
lib.concatMapStrings (s: if lib.isList s then "-" else s)
(split "[^a-zA-Z0-9_.\\-]+" name);
};
};
config = lib.mkIf (pass.secrets != {}) {
- #systemd.tmpfiles.rules = [ "d /run/secrets 0755 root root -" ];
systemd.services =
lib.mapAttrs' (target: secret:
lib.nameValuePair (lib.removeSuffix ".service" secret.service) {
Environment = "GNUPGHOME=${secret.gnupgHome}";
PrivateTmp = true;
RemainAfterExit = true;
- WorkingDirectory = dirname secret.gnupgHome;
+ WorkingDirectory = dirOf secret.gnupgHome;
} // lib.optionalAttrs (match "^/.*" target == null) {
- RuntimeDirectory = lib.removePrefix "/run/" (dirname secret.path);
+ RuntimeDirectory = lib.removePrefix "/run/" (dirOf secret.path);
RuntimeDirectoryMode = "711";
RuntimeDirectoryPreserve = false;
};