2021-11-20 17:34:13 +00:00
|
|
|
{ config, lib, pkgs, utils, ... }:
|
2018-04-21 10:12:43 +00:00
|
|
|
|
|
|
|
with lib;
|
2019-01-23 20:29:02 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# Type for a valid systemd unit option. Needed for correctly passing "timerConfig" to "systemd.timers"
|
2021-11-20 17:34:13 +00:00
|
|
|
inherit (utils.systemdUtils.unitOptions) unitOption;
|
2019-01-23 20:29:02 +00:00
|
|
|
in
|
2018-04-21 10:12:43 +00:00
|
|
|
{
|
|
|
|
options.services.restic.backups = mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +00:00
|
|
|
Periodic backups to create with Restic.
|
|
|
|
'';
|
2021-08-28 13:17:52 +00:00
|
|
|
type = types.attrsOf (types.submodule ({ config, name, ... }: {
|
2018-04-21 10:12:43 +00:00
|
|
|
options = {
|
|
|
|
passwordFile = mkOption {
|
|
|
|
type = types.str;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +00:00
|
|
|
Read the repository password from a file.
|
|
|
|
'';
|
|
|
|
example = "/etc/nixos/restic-password";
|
2018-05-31 02:30:12 +00:00
|
|
|
};
|
2018-04-21 10:12:43 +00:00
|
|
|
|
2021-08-28 13:17:52 +00:00
|
|
|
environmentFile = mkOption {
|
|
|
|
type = with types; nullOr str;
|
2023-10-27 09:36:31 +00:00
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2021-08-28 13:17:52 +00:00
|
|
|
file containing the credentials to access the repository, in the
|
|
|
|
format of an EnvironmentFile as described by systemd.exec(5)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-07-05 20:25:33 +00:00
|
|
|
rcloneOptions = mkOption {
|
|
|
|
type = with types; nullOr (attrsOf (oneOf [ str bool ]));
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2020-07-05 20:25:33 +00:00
|
|
|
Options to pass to rclone to control its behavior.
|
|
|
|
See <https://rclone.org/docs/#options> for
|
|
|
|
available options. When specifying option names, strip the
|
|
|
|
leading `--`. To set a flag such as
|
|
|
|
`--drive-use-trash`, which does not take a value,
|
|
|
|
set the value to the Boolean `true`.
|
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
bwlimit = "10M";
|
|
|
|
drive-use-trash = "true";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
rcloneConfig = mkOption {
|
|
|
|
type = with types; nullOr (attrsOf (oneOf [ str bool ]));
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2020-07-05 20:25:33 +00:00
|
|
|
Configuration for the rclone remote being used for backup.
|
|
|
|
See the remote's specific options under rclone's docs at
|
|
|
|
<https://rclone.org/docs/>. When specifying
|
2020-08-07 13:43:58 +00:00
|
|
|
option names, use the "config" name specified in the docs.
|
2020-07-05 20:25:33 +00:00
|
|
|
For example, to set `--b2-hard-delete` for a B2
|
|
|
|
remote, use `hard_delete = true` in the
|
|
|
|
attribute set.
|
|
|
|
Warning: Secrets set in here will be world-readable in the Nix
|
|
|
|
store! Consider using the `rcloneConfigFile`
|
|
|
|
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-13 12:54:15 +00:00
|
|
|
description = ''
|
2020-07-05 20:25:33 +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
|
|
|
|
`rcloneConfig` will override those set in this
|
|
|
|
file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-04-21 10:12:43 +00:00
|
|
|
repository = mkOption {
|
2022-06-02 16:40:39 +00:00
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +00:00
|
|
|
repository to backup to.
|
|
|
|
'';
|
|
|
|
example = "sftp:backup@192.168.1.100:/backups/${name}";
|
|
|
|
};
|
|
|
|
|
2022-06-02 16:40:39 +00:00
|
|
|
repositoryFile = mkOption {
|
|
|
|
type = with types; nullOr path;
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-02 16:40:39 +00:00
|
|
|
Path to the file containing the repository location to backup to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-04-21 10:12:43 +00:00
|
|
|
paths = mkOption {
|
2022-12-04 20:40:54 +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-20 00:14:43 +00:00
|
|
|
type = types.nullOr (types.listOf types.str);
|
2022-12-04 20:40:54 +00:00
|
|
|
default = [ ];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-12-04 20:40:54 +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.
|
2018-04-21 10:12:43 +00:00
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"/var/lib/postgresql"
|
|
|
|
"/home/user/backup"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-12-03 23:00:58 +00:00
|
|
|
exclude = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-12-03 23:00:58 +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"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2018-04-21 10:12:43 +00:00
|
|
|
timerConfig = mkOption {
|
2023-08-16 09:42:29 +00:00
|
|
|
type = types.nullOr (types.attrsOf unitOption);
|
2018-04-21 10:12:43 +00:00
|
|
|
default = {
|
|
|
|
OnCalendar = "daily";
|
2023-05-15 08:32:14 +00:00
|
|
|
Persistent = true;
|
2018-04-21 10:12:43 +00:00
|
|
|
};
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2023-08-16 09:42:29 +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.
|
2018-04-21 10:12:43 +00:00
|
|
|
'';
|
|
|
|
example = {
|
|
|
|
OnCalendar = "00:05";
|
|
|
|
RandomizedDelaySec = "5h";
|
2023-05-15 08:32:14 +00:00
|
|
|
Persistent = true;
|
2018-04-21 10:12:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "root";
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +00:00
|
|
|
As which user the backup should run.
|
|
|
|
'';
|
|
|
|
example = "postgresql";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraBackupArgs = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2022-06-02 16:38:39 +00:00
|
|
|
default = [ ];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +00:00
|
|
|
Extra arguments passed to restic backup.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"--exclude-file=/etc/nixos/restic-ignore"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2022-06-02 16:38:39 +00:00
|
|
|
default = [ ];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +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-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-04-21 10:12:43 +00:00
|
|
|
Create the repository if it doesn't exist.
|
|
|
|
'';
|
|
|
|
};
|
2018-07-22 02:24:19 +00:00
|
|
|
|
|
|
|
pruneOpts = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2022-06-02 16:38:39 +00:00
|
|
|
default = [ ];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-08-29 19:48:56 +00:00
|
|
|
A list of options (--keep-\* et al.) for 'restic forget
|
2018-07-22 02:24:19 +00:00
|
|
|
--prune', to automatically prune old snapshots. The
|
|
|
|
'forget' command is run *after* the 'backup' command, so
|
2022-08-29 19:48:56 +00:00
|
|
|
keep that in mind when constructing the --keep-\* options.
|
2018-07-22 02:24:19 +00:00
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 5"
|
|
|
|
"--keep-monthly 12"
|
|
|
|
"--keep-yearly 75"
|
|
|
|
];
|
|
|
|
};
|
2018-08-05 16:53:53 +00:00
|
|
|
|
2022-08-29 23:40:28 +00:00
|
|
|
checkOpts = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-08-29 23:40:28 +00:00
|
|
|
A list of options for 'restic check', which is run after
|
|
|
|
pruning.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"--with-cache"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2018-08-05 16:53:53 +00:00
|
|
|
dynamicFilesFrom = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2018-08-05 16:53:53 +00:00
|
|
|
A script that produces a list of files to back up. The
|
|
|
|
results of this command are given to the '--files-from'
|
2022-12-04 20:40:54 +00:00
|
|
|
option. The result is merged with paths specified via `paths`.
|
2018-08-05 16:53:53 +00:00
|
|
|
'';
|
|
|
|
example = "find /home/matt/git -type d -name .git";
|
|
|
|
};
|
2022-06-02 16:43:03 +00:00
|
|
|
|
|
|
|
backupPrepareCommand = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-02 16:43:03 +00:00
|
|
|
A script that must run before starting the backup process.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
backupCleanupCommand = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-06-02 16:43:03 +00:00
|
|
|
A script that must run after finishing the backup process.
|
|
|
|
'';
|
|
|
|
};
|
2022-07-27 17:47:41 +00:00
|
|
|
|
2023-11-27 00:19:27 +00:00
|
|
|
package = mkPackageOption pkgs "restic" { };
|
2023-08-23 23:31:58 +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.
|
|
|
|
'';
|
|
|
|
};
|
2018-04-21 10:12:43 +00:00
|
|
|
};
|
|
|
|
}));
|
2022-06-02 16:38:39 +00:00
|
|
|
default = { };
|
2018-04-21 10:12:43 +00:00
|
|
|
example = {
|
|
|
|
localbackup = {
|
|
|
|
paths = [ "/home" ];
|
2022-12-03 23:00:58 +00:00
|
|
|
exclude = [ "/home/*/.cache" ];
|
2018-04-21 10:12:43 +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 = {
|
2022-12-03 21:48:44 +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;
|
2018-04-21 10:12:43 +00:00
|
|
|
systemd.services =
|
2022-06-02 16:38:39 +00:00
|
|
|
mapAttrs'
|
|
|
|
(name: backup:
|
|
|
|
let
|
|
|
|
extraOptions = concatMapStrings (arg: " -o ${arg}") backup.extraOptions;
|
2022-07-27 17:47:41 +00:00
|
|
|
resticCmd = "${backup.package}/bin/restic${extraOptions}";
|
2023-06-25 09:47:43 +00:00
|
|
|
excludeFlags = optional (backup.exclude != []) "--exclude-file=${pkgs.writeText "exclude-patterns" (concatStringsSep "\n" backup.exclude)}";
|
2022-06-02 16:38:39 +00:00
|
|
|
filesFromTmpFile = "/run/restic-backups-${name}/includes";
|
2022-12-04 20:40:54 +00:00
|
|
|
doBackup = (backup.dynamicFilesFrom != null) || (backup.paths != null && backup.paths != []);
|
2022-06-02 16:38:39 +00:00
|
|
|
pruneCmd = optionals (builtins.length backup.pruneOpts > 0) [
|
2023-03-11 11:23:24 +00:00
|
|
|
(resticCmd + " forget --prune " + (concatStringsSep " " backup.pruneOpts))
|
|
|
|
(resticCmd + " check " + (concatStringsSep " " backup.checkOpts))
|
2022-06-02 16:38:39 +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-08-23 23:31:58 +00:00
|
|
|
# not %C, because that wouldn't work in the wrapper script
|
|
|
|
RESTIC_CACHE_DIR = "/var/cache/restic-backups-${name}";
|
2022-06-02 16:38:39 +00:00
|
|
|
RESTIC_PASSWORD_FILE = backup.passwordFile;
|
|
|
|
RESTIC_REPOSITORY = backup.repository;
|
2022-06-02 16:40:39 +00:00
|
|
|
RESTIC_REPOSITORY_FILE = backup.repositoryFile;
|
2022-06-02 16:38:39 +00:00
|
|
|
} // 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-08-28 13:02:59 +00:00
|
|
|
path = [ config.programs.ssh.package ];
|
2022-06-02 16:38:39 +00:00
|
|
|
restartIfChanged = false;
|
2023-08-19 00:02:16 +00:00
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
2022-06-02 16:38:39 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
2022-12-04 20:40:54 +00:00
|
|
|
ExecStart = (optionals doBackup [ "${resticCmd} backup ${concatStringsSep " " (backup.extraBackupArgs ++ excludeFlags)} --files-from=${filesFromTmpFile}" ])
|
2022-06-02 16:38:39 +00:00
|
|
|
++ pruneCmd;
|
|
|
|
User = backup.user;
|
|
|
|
RuntimeDirectory = "restic-backups-${name}";
|
|
|
|
CacheDirectory = "restic-backups-${name}";
|
|
|
|
CacheDirectoryMode = "0700";
|
2020-10-06 11:32:58 +00:00
|
|
|
PrivateTmp = true;
|
2022-06-02 16:38:39 +00:00
|
|
|
} // optionalAttrs (backup.environmentFile != null) {
|
|
|
|
EnvironmentFile = backup.environmentFile;
|
|
|
|
};
|
2023-11-01 20:13:11 +00:00
|
|
|
} // optionalAttrs (backup.initialize || doBackup || backup.backupPrepareCommand != null) {
|
2022-06-02 16:38:39 +00:00
|
|
|
preStart = ''
|
2022-06-02 16:43:03 +00:00
|
|
|
${optionalString (backup.backupPrepareCommand != null) ''
|
|
|
|
${pkgs.writeScript "backupPrepareCommand" backup.backupPrepareCommand}
|
|
|
|
''}
|
2022-06-02 16:38:39 +00:00
|
|
|
${optionalString (backup.initialize) ''
|
|
|
|
${resticCmd} snapshots || ${resticCmd} init
|
|
|
|
''}
|
2022-12-04 20:40:54 +00:00
|
|
|
${optionalString (backup.paths != null && backup.paths != []) ''
|
|
|
|
cat ${pkgs.writeText "staticPaths" (concatStringsSep "\n" backup.paths)} >> ${filesFromTmpFile}
|
|
|
|
''}
|
2022-06-02 16:38:39 +00:00
|
|
|
${optionalString (backup.dynamicFilesFrom != null) ''
|
2022-12-04 20:40:54 +00:00
|
|
|
${pkgs.writeScript "dynamicFilesFromScript" backup.dynamicFilesFrom} >> ${filesFromTmpFile}
|
2022-06-02 16:38:39 +00:00
|
|
|
''}
|
|
|
|
'';
|
2023-11-01 20:13:11 +00:00
|
|
|
} // optionalAttrs (doBackup || backup.backupCleanupCommand != null) {
|
2022-07-25 14:53:01 +00:00
|
|
|
postStop = ''
|
2022-06-02 16:43:03 +00:00
|
|
|
${optionalString (backup.backupCleanupCommand != null) ''
|
|
|
|
${pkgs.writeScript "backupCleanupCommand" backup.backupCleanupCommand}
|
|
|
|
''}
|
2023-11-01 20:13:11 +00:00
|
|
|
${optionalString doBackup ''
|
2022-06-02 16:43:03 +00:00
|
|
|
rm ${filesFromTmpFile}
|
|
|
|
''}
|
2022-06-02 16:38:39 +00:00
|
|
|
'';
|
|
|
|
})
|
|
|
|
)
|
|
|
|
config.services.restic.backups;
|
2018-04-21 10:12:43 +00:00
|
|
|
systemd.timers =
|
2022-06-02 16:38:39 +00:00
|
|
|
mapAttrs'
|
|
|
|
(name: backup: nameValuePair "restic-backups-${name}" {
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
timerConfig = backup.timerConfig;
|
|
|
|
})
|
2023-08-16 09:42:29 +00:00
|
|
|
(filterAttrs (_: backup: backup.timerConfig != null) config.services.restic.backups);
|
2023-08-23 23:31:58 +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 [
|
2023-12-12 21:17:06 +00:00
|
|
|
(lib.filterAttrs (n: v: v != null && n != "PATH"))
|
2023-08-23 23:31:58 +00:00
|
|
|
(lib.mapAttrsToList (n: v: "${n}=${v}"))
|
|
|
|
(lib.concatStringsSep "\n")
|
|
|
|
]}
|
2023-12-12 21:17:06 +00:00
|
|
|
PATH=${config.systemd.services."restic-backups-${name}".environment.PATH}:$PATH
|
2023-08-23 23:31:58 +00:00
|
|
|
|
|
|
|
exec ${resticCmd} $@
|
|
|
|
'') (lib.filterAttrs (_: v: v.createWrapper) config.services.restic.backups);
|
2018-04-21 10:12:43 +00:00
|
|
|
};
|
|
|
|
}
|