mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
nixos/borgbackup: replace activationScript via tmpfiles
This commit is contained in:
parent
1c22b64fc9
commit
8d3cf213db
|
@ -143,20 +143,15 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
# Paths listed in ReadWritePaths must exist before service is started
|
# Paths listed in ReadWritePaths must exist before service is started
|
||||||
mkActivationScript = name: cfg:
|
mkTmpfiles = name: cfg:
|
||||||
let
|
let
|
||||||
install = "install -o ${cfg.user} -g ${cfg.group}";
|
settings = { inherit (cfg) user group; };
|
||||||
in
|
in lib.nameValuePair "borgbackup-job-${name}" ({
|
||||||
nameValuePair "borgbackup-job-${name}" (stringAfter [ "users" ] (''
|
"${config.users.users."${cfg.user}".home}/.config/borg".d = settings;
|
||||||
# Ensure that the home directory already exists
|
"${config.users.users."${cfg.user}".home}/.cache/borg".d = settings;
|
||||||
# We can't assert createHome == true because that's not the case for root
|
} // optionalAttrs (isLocalPath cfg.repo && !cfg.removableDevice) {
|
||||||
cd "${config.users.users.${cfg.user}.home}"
|
"${cfg.repo}".d = settings;
|
||||||
# Create each directory separately to prevent root owned parent dirs
|
});
|
||||||
${install} -d .config .config/borg
|
|
||||||
${install} -d .cache .cache/borg
|
|
||||||
'' + optionalString (isLocalPath cfg.repo && !cfg.removableDevice) ''
|
|
||||||
${install} -d ${escapeShellArg cfg.repo}
|
|
||||||
''));
|
|
||||||
|
|
||||||
mkPassAssertion = name: cfg: {
|
mkPassAssertion = name: cfg: {
|
||||||
assertion = with cfg.encryption;
|
assertion = with cfg.encryption;
|
||||||
|
@ -760,7 +755,7 @@ in {
|
||||||
++ mapAttrsToList mkSourceAssertions jobs
|
++ mapAttrsToList mkSourceAssertions jobs
|
||||||
++ mapAttrsToList mkRemovableDeviceAssertions jobs;
|
++ mapAttrsToList mkRemovableDeviceAssertions jobs;
|
||||||
|
|
||||||
system.activationScripts = mapAttrs' mkActivationScript jobs;
|
systemd.tmpfiles.settings = mapAttrs' mkTmpfiles jobs;
|
||||||
|
|
||||||
systemd.services =
|
systemd.services =
|
||||||
# A job named "foo" is mapped to systemd.services.borgbackup-job-foo
|
# A job named "foo" is mapped to systemd.services.borgbackup-job-foo
|
||||||
|
|
Loading…
Reference in a new issue