2021-12-19 01:06:50 +00:00
|
|
|
{ config, lib, pkgs, utils, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
# Type for a valid systemd unit option. Needed for correctly passing "timerConfig" to "systemd.timers"
|
2021-12-19 01:06:50 +00:00
|
|
|
inherit (utils.systemdUtils.unitOptions) unitOption;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.restic.backups = mkOption {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Periodic backups to create with Restic.
|
|
|
|
'';
|
2021-10-28 06:52:43 +00:00
|
|
|
type = types.attrsOf (types.submodule ({ config, name, ... }: {
|
2020-04-24 23:36:52 +00:00
|
|
|
options = {
|
|
|
|
passwordFile = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Read the repository password from a file.
|
|
|
|
'';
|
|
|
|
example = "/etc/nixos/restic-password";
|
|
|
|
};
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
environmentFile = mkOption {
|
|
|
|
type = with types; nullOr str;
|
2023-11-16 04:20:00 +00:00
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-10-28 06:52:43 +00:00
|
|
|
file containing the credentials to access the repository, in the
|
|
|
|
format of an EnvironmentFile as described by systemd.exec(5)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
rcloneOptions = mkOption {
|
|
|
|
type = with types; nullOr (attrsOf (oneOf [ str bool ]));
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-07-18 16:06:22 +00:00
|
|
|
Options to pass to rclone to control its behavior.
|
2022-08-12 12:06:08 +00:00
|
|
|
See <https://rclone.org/docs/#options> for
|
2020-07-18 16:06:22 +00:00
|
|
|
available options. When specifying option names, strip the
|
2022-08-12 12:06:08 +00:00
|
|
|
leading `--`. To set a flag such as
|
|
|
|
`--drive-use-trash`, which does not take a value,
|
|
|
|
set the value to the Boolean `true`.
|
2020-07-18 16:06:22 +00:00
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
bwlimit = "10M";
|
|
|
|
drive-use-trash = "true";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
rcloneConfig = mkOption {
|
|
|
|
type = with types; nullOr (attrsOf (oneOf [ str bool ]));
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-07-18 16:06:22 +00:00
|
|
|
Configuration for the rclone remote being used for backup.
|
|
|
|
See the remote's specific options under rclone's docs at
|
2022-08-12 12:06:08 +00:00
|
|
|
<https://rclone.org/docs/>. When specifying
|
2020-08-20 17:08:02 +00:00
|
|
|
option names, use the "config" name specified in the docs.
|
2022-08-12 12:06:08 +00:00
|
|
|
For example, to set `--b2-hard-delete` for a B2
|
|
|
|
remote, use `hard_delete = true` in the
|
2020-07-18 16:06:22 +00:00
|
|
|
attribute set.
|
|
|
|
Warning: Secrets set in here will be world-readable in the Nix
|
2022-08-12 12:06:08 +00:00
|
|
|
store! Consider using the `rcloneConfigFile`
|
2020-07-18 16:06:22 +00:00
|
|
|
option instead to specify secret values separately. Note that
|
|
|
|
options set here will override those set in the config file.
|
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
type = "b2";
|
|
|
|
account = "xxx";
|
|
|
|
key = "xxx";
|
|
|
|
hard_delete = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
rcloneConfigFile = mkOption {
|
|
|
|
type = with types; nullOr path;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-07-18 16:06:22 +00:00
|
|
|
Path to the file containing rclone configuration. This file
|
|
|
|
must contain configuration for the remote specified in this backup
|
|
|
|
set and also must be readable by root. Options set in
|
2022-08-12 12:06:08 +00:00
|
|
|
`rcloneConfig` will override those set in this
|
2020-07-18 16:06:22 +00:00
|
|
|
file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
repository = mkOption {
|
2022-06-16 17:23:12 +00:00
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
repository to backup to.
|
|
|
|
'';
|
|
|
|
example = "sftp:backup@192.168.1.100:/backups/${name}";
|
|
|
|
};
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
repositoryFile = mkOption {
|
|
|
|
type = with types; nullOr path;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-06-16 17:23:12 +00:00
|
|
|
Path to the file containing the repository location to backup to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
paths = mkOption {
|
2023-11-16 04:20:00 +00:00
|
|
|
# This is nullable for legacy reasons only. We should consider making it a pure listOf
|
|
|
|
# after some time has passed since this comment was added.
|
2021-03-23 19:22:30 +00:00
|
|
|
type = types.nullOr (types.listOf types.str);
|
2023-11-16 04:20:00 +00:00
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2023-11-16 04:20:00 +00:00
|
|
|
Which paths to backup, in addition to ones specified via
|
|
|
|
`dynamicFilesFrom`. If null or an empty array and
|
|
|
|
`dynamicFilesFrom` is also null, no backup command will be run.
|
|
|
|
This can be used to create a prune-only job.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"/var/lib/postgresql"
|
|
|
|
"/home/user/backup"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
exclude = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2023-02-02 18:25:31 +00:00
|
|
|
Patterns to exclude when backing up. See
|
|
|
|
https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files for
|
|
|
|
details on syntax.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"/var/cache"
|
|
|
|
"/home/*/.cache"
|
|
|
|
".git"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
timerConfig = mkOption {
|
2023-11-16 04:20:00 +00:00
|
|
|
type = types.nullOr (types.attrsOf unitOption);
|
2020-04-24 23:36:52 +00:00
|
|
|
default = {
|
|
|
|
OnCalendar = "daily";
|
2023-05-24 13:37:59 +00:00
|
|
|
Persistent = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2023-11-16 04:20:00 +00:00
|
|
|
When to run the backup. See {manpage}`systemd.timer(5)` for
|
|
|
|
details. If null no timer is created and the backup will only
|
|
|
|
run when explicitly started.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
OnCalendar = "00:05";
|
|
|
|
RandomizedDelaySec = "5h";
|
2023-05-24 13:37:59 +00:00
|
|
|
Persistent = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "root";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
As which user the backup should run.
|
|
|
|
'';
|
|
|
|
example = "postgresql";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraBackupArgs = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2022-06-16 17:23:12 +00:00
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Extra arguments passed to restic backup.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"--exclude-file=/etc/nixos/restic-ignore"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2022-06-16 17:23:12 +00:00
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Extra extended options to be passed to the restic --option flag.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"sftp.command='ssh backup@192.168.1.100 -i /home/user/.ssh/id_rsa -s sftp'"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
initialize = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Create the repository if it doesn't exist.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
pruneOpts = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2022-06-16 17:23:12 +00:00
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-09-09 14:08:57 +00:00
|
|
|
A list of options (--keep-\* et al.) for 'restic forget
|
2020-04-24 23:36:52 +00:00
|
|
|
--prune', to automatically prune old snapshots. The
|
|
|
|
'forget' command is run *after* the 'backup' command, so
|
2022-09-09 14:08:57 +00:00
|
|
|
keep that in mind when constructing the --keep-\* options.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 5"
|
|
|
|
"--keep-monthly 12"
|
|
|
|
"--keep-yearly 75"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
checkOpts = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-10-21 18:38:19 +00:00
|
|
|
A list of options for 'restic check', which is run after
|
|
|
|
pruning.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"--with-cache"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
dynamicFilesFrom = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A script that produces a list of files to back up. The
|
|
|
|
results of this command are given to the '--files-from'
|
2023-11-16 04:20:00 +00:00
|
|
|
option. The result is merged with paths specified via `paths`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
example = "find /home/matt/git -type d -name .git";
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
backupPrepareCommand = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-06-16 17:23:12 +00:00
|
|
|
A script that must run before starting the backup process.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
backupCleanupCommand = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-06-16 17:23:12 +00:00
|
|
|
A script that must run after finishing the backup process.
|
|
|
|
'';
|
|
|
|
};
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "restic" { };
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
createWrapper = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Whether to generate and add a script to the system path, that has the same environment variables set
|
|
|
|
as the systemd service. This can be used to e.g. mount snapshots or perform other opterations, without
|
|
|
|
having to manually specify most options.
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}));
|
2022-06-16 17:23:12 +00:00
|
|
|
default = { };
|
2020-04-24 23:36:52 +00:00
|
|
|
example = {
|
|
|
|
localbackup = {
|
|
|
|
paths = [ "/home" ];
|
2023-02-02 18:25:31 +00:00
|
|
|
exclude = [ "/home/*/.cache" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
repository = "/mnt/backup-hdd";
|
|
|
|
passwordFile = "/etc/nixos/secrets/restic-password";
|
|
|
|
initialize = true;
|
|
|
|
};
|
|
|
|
remotebackup = {
|
|
|
|
paths = [ "/home" ];
|
|
|
|
repository = "sftp:backup@host:/backups/home";
|
|
|
|
passwordFile = "/etc/nixos/secrets/restic-password";
|
|
|
|
extraOptions = [
|
|
|
|
"sftp.command='ssh backup@host -i /etc/nixos/secrets/backup-private-key -s sftp'"
|
|
|
|
];
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "00:05";
|
|
|
|
RandomizedDelaySec = "5h";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2023-02-02 18:25:31 +00:00
|
|
|
assertions = mapAttrsToList (n: v: {
|
|
|
|
assertion = (v.repository == null) != (v.repositoryFile == null);
|
|
|
|
message = "services.restic.backups.${n}: exactly one of repository or repositoryFile should be set";
|
|
|
|
}) config.services.restic.backups;
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services =
|
2022-06-16 17:23:12 +00:00
|
|
|
mapAttrs'
|
|
|
|
(name: backup:
|
|
|
|
let
|
|
|
|
extraOptions = concatMapStrings (arg: " -o ${arg}") backup.extraOptions;
|
2022-08-12 12:06:08 +00:00
|
|
|
resticCmd = "${backup.package}/bin/restic${extraOptions}";
|
2023-07-15 17:15:38 +00:00
|
|
|
excludeFlags = optional (backup.exclude != []) "--exclude-file=${pkgs.writeText "exclude-patterns" (concatStringsSep "\n" backup.exclude)}";
|
2022-06-16 17:23:12 +00:00
|
|
|
filesFromTmpFile = "/run/restic-backups-${name}/includes";
|
2023-11-16 04:20:00 +00:00
|
|
|
doBackup = (backup.dynamicFilesFrom != null) || (backup.paths != null && backup.paths != []);
|
2022-06-16 17:23:12 +00:00
|
|
|
pruneCmd = optionals (builtins.length backup.pruneOpts > 0) [
|
2023-03-24 00:07:29 +00:00
|
|
|
(resticCmd + " forget --prune " + (concatStringsSep " " backup.pruneOpts))
|
|
|
|
(resticCmd + " check " + (concatStringsSep " " backup.checkOpts))
|
2022-06-16 17:23:12 +00:00
|
|
|
];
|
|
|
|
# Helper functions for rclone remotes
|
|
|
|
rcloneRemoteName = builtins.elemAt (splitString ":" backup.repository) 1;
|
|
|
|
rcloneAttrToOpt = v: "RCLONE_" + toUpper (builtins.replaceStrings [ "-" ] [ "_" ] v);
|
|
|
|
rcloneAttrToConf = v: "RCLONE_CONFIG_" + toUpper (rcloneRemoteName + "_" + v);
|
|
|
|
toRcloneVal = v: if lib.isBool v then lib.boolToString v else v;
|
|
|
|
in
|
|
|
|
nameValuePair "restic-backups-${name}" ({
|
|
|
|
environment = {
|
2023-10-09 19:29:22 +00:00
|
|
|
# not %C, because that wouldn't work in the wrapper script
|
|
|
|
RESTIC_CACHE_DIR = "/var/cache/restic-backups-${name}";
|
2022-06-16 17:23:12 +00:00
|
|
|
RESTIC_PASSWORD_FILE = backup.passwordFile;
|
|
|
|
RESTIC_REPOSITORY = backup.repository;
|
|
|
|
RESTIC_REPOSITORY_FILE = backup.repositoryFile;
|
|
|
|
} // optionalAttrs (backup.rcloneOptions != null) (mapAttrs'
|
|
|
|
(name: value:
|
|
|
|
nameValuePair (rcloneAttrToOpt name) (toRcloneVal value)
|
|
|
|
)
|
|
|
|
backup.rcloneOptions) // optionalAttrs (backup.rcloneConfigFile != null) {
|
|
|
|
RCLONE_CONFIG = backup.rcloneConfigFile;
|
|
|
|
} // optionalAttrs (backup.rcloneConfig != null) (mapAttrs'
|
|
|
|
(name: value:
|
|
|
|
nameValuePair (rcloneAttrToConf name) (toRcloneVal value)
|
|
|
|
)
|
|
|
|
backup.rcloneConfig);
|
2023-10-09 19:29:22 +00:00
|
|
|
path = [ config.programs.ssh.package ];
|
2022-06-16 17:23:12 +00:00
|
|
|
restartIfChanged = false;
|
2023-10-09 19:29:22 +00:00
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
2022-06-16 17:23:12 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
2023-11-16 04:20:00 +00:00
|
|
|
ExecStart = (optionals doBackup [ "${resticCmd} backup ${concatStringsSep " " (backup.extraBackupArgs ++ excludeFlags)} --files-from=${filesFromTmpFile}" ])
|
2022-06-16 17:23:12 +00:00
|
|
|
++ pruneCmd;
|
|
|
|
User = backup.user;
|
|
|
|
RuntimeDirectory = "restic-backups-${name}";
|
|
|
|
CacheDirectory = "restic-backups-${name}";
|
|
|
|
CacheDirectoryMode = "0700";
|
2023-05-24 13:37:59 +00:00
|
|
|
PrivateTmp = true;
|
2022-06-16 17:23:12 +00:00
|
|
|
} // optionalAttrs (backup.environmentFile != null) {
|
|
|
|
EnvironmentFile = backup.environmentFile;
|
|
|
|
};
|
2023-11-16 04:20:00 +00:00
|
|
|
} // optionalAttrs (backup.initialize || doBackup || backup.backupPrepareCommand != null) {
|
2022-06-16 17:23:12 +00:00
|
|
|
preStart = ''
|
|
|
|
${optionalString (backup.backupPrepareCommand != null) ''
|
|
|
|
${pkgs.writeScript "backupPrepareCommand" backup.backupPrepareCommand}
|
|
|
|
''}
|
|
|
|
${optionalString (backup.initialize) ''
|
|
|
|
${resticCmd} snapshots || ${resticCmd} init
|
|
|
|
''}
|
2023-11-16 04:20:00 +00:00
|
|
|
${optionalString (backup.paths != null && backup.paths != []) ''
|
|
|
|
cat ${pkgs.writeText "staticPaths" (concatStringsSep "\n" backup.paths)} >> ${filesFromTmpFile}
|
|
|
|
''}
|
2022-06-16 17:23:12 +00:00
|
|
|
${optionalString (backup.dynamicFilesFrom != null) ''
|
2023-11-16 04:20:00 +00:00
|
|
|
${pkgs.writeScript "dynamicFilesFromScript" backup.dynamicFilesFrom} >> ${filesFromTmpFile}
|
2022-06-16 17:23:12 +00:00
|
|
|
''}
|
|
|
|
'';
|
2023-11-16 04:20:00 +00:00
|
|
|
} // optionalAttrs (doBackup || backup.backupCleanupCommand != null) {
|
2022-08-12 12:06:08 +00:00
|
|
|
postStop = ''
|
2022-06-16 17:23:12 +00:00
|
|
|
${optionalString (backup.backupCleanupCommand != null) ''
|
|
|
|
${pkgs.writeScript "backupCleanupCommand" backup.backupCleanupCommand}
|
|
|
|
''}
|
2023-11-16 04:20:00 +00:00
|
|
|
${optionalString doBackup ''
|
2022-06-16 17:23:12 +00:00
|
|
|
rm ${filesFromTmpFile}
|
|
|
|
''}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
)
|
|
|
|
config.services.restic.backups;
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.timers =
|
2022-06-16 17:23:12 +00:00
|
|
|
mapAttrs'
|
|
|
|
(name: backup: nameValuePair "restic-backups-${name}" {
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
timerConfig = backup.timerConfig;
|
|
|
|
})
|
2023-11-16 04:20:00 +00:00
|
|
|
(filterAttrs (_: backup: backup.timerConfig != null) config.services.restic.backups);
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# generate wrapper scripts, as described in the createWrapper option
|
|
|
|
environment.systemPackages = lib.mapAttrsToList (name: backup: let
|
|
|
|
extraOptions = lib.concatMapStrings (arg: " -o ${arg}") backup.extraOptions;
|
|
|
|
resticCmd = "${backup.package}/bin/restic${extraOptions}";
|
|
|
|
in pkgs.writeShellScriptBin "restic-${name}" ''
|
|
|
|
set -a # automatically export variables
|
|
|
|
${lib.optionalString (backup.environmentFile != null) "source ${backup.environmentFile}"}
|
|
|
|
# set same environment variables as the systemd service
|
|
|
|
${lib.pipe config.systemd.services."restic-backups-${name}".environment [
|
2024-01-02 11:29:13 +00:00
|
|
|
(lib.filterAttrs (n: v: v != null && n != "PATH"))
|
2023-10-09 19:29:22 +00:00
|
|
|
(lib.mapAttrsToList (n: v: "${n}=${v}"))
|
|
|
|
(lib.concatStringsSep "\n")
|
|
|
|
]}
|
2024-01-02 11:29:13 +00:00
|
|
|
PATH=${config.systemd.services."restic-backups-${name}".environment.PATH}:$PATH
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
exec ${resticCmd} $@
|
|
|
|
'') (lib.filterAttrs (_: v: v.createWrapper) config.services.restic.backups);
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|