diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix index 333fdd494e3b..a0de1124c661 100644 --- a/nixos/modules/services/backup/restic.nix +++ b/nixos/modules/services/backup/restic.nix @@ -222,6 +222,15 @@ in A script that must run after finishing the backup process. ''; }; + + package = mkOption { + type = types.package; + default = pkgs.restic; + defaultText = literalExpression "pkgs.restic"; + description = '' + Restic package to use. + ''; + }; }; })); default = { }; @@ -254,7 +263,7 @@ in (name: backup: let extraOptions = concatMapStrings (arg: " -o ${arg}") backup.extraOptions; - resticCmd = "${pkgs.restic}/bin/restic${extraOptions}"; + resticCmd = "${backup.package}/bin/restic${extraOptions}"; filesFromTmpFile = "/run/restic-backups-${name}/includes"; backupPaths = if (backup.dynamicFilesFrom == null) diff --git a/nixos/tests/restic.nix b/nixos/tests/restic.nix index 7523d5e5ed5d..75fffe9d9a84 100644 --- a/nixos/tests/restic.nix +++ b/nixos/tests/restic.nix @@ -63,6 +63,12 @@ import ./make-test-python.nix ( inherit repository passwordFile; pruneOpts = [ "--keep-last 1" ]; }; + custompackage = { + inherit repository passwordFile paths; + package = pkgs.writeShellScriptBin "restic" '' + echo "$@" >> /tmp/fake-restic.log; + ''; + }; }; environment.sessionVariables.RCLONE_CONFIG_LOCAL_TYPE = "local"; @@ -76,6 +82,7 @@ import ./make-test-python.nix ( "${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots", '${pkgs.restic}/bin/restic --repository-file ${repositoryFile} -p ${passwordFile} snapshots"', "${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots", + "grep 'backup .* /opt' /tmp/fake-restic.log", ) server.succeed( "mkdir -p /opt", @@ -89,6 +96,8 @@ import ./make-test-python.nix ( '${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"', '${pkgs.restic}/bin/restic --repository-file ${repositoryFile} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"', '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"', + "systemctl start restic-backups-custompackage.service", + "grep 'backup .* /opt' /tmp/fake-restic.log", "timedatectl set-time '2017-12-13 13:45'", "systemctl start restic-backups-remotebackup.service", "rm /opt/backupCleanupCommand",