about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorLin Jian <me@linj.tech>2023-11-10 17:51:14 +0800
committerGitHub <noreply@github.com>2023-11-10 17:51:14 +0800
commit36f4c9052633971cde686d38f70977e5e982f7fb (patch)
tree21651acbc79cf42aceb4d4d0aeacd620abd8a98a /nixos
parentcce2e89b30164695c69a2c236a3f5fcb1353994a (diff)
parent20b202b3c809a3b599742a41fdf5a34a261910fc (diff)
downloadnixlib-36f4c9052633971cde686d38f70977e5e982f7fb.tar
nixlib-36f4c9052633971cde686d38f70977e5e982f7fb.tar.gz
nixlib-36f4c9052633971cde686d38f70977e5e982f7fb.tar.bz2
nixlib-36f4c9052633971cde686d38f70977e5e982f7fb.tar.lz
nixlib-36f4c9052633971cde686d38f70977e5e982f7fb.tar.xz
nixlib-36f4c9052633971cde686d38f70977e5e982f7fb.tar.zst
nixlib-36f4c9052633971cde686d38f70977e5e982f7fb.zip
Merge pull request #266150 from robryk/resticnotimer
nixos/restic: allow timer to be disabled
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/backup/restic.nix8
-rw-r--r--nixos/tests/restic.nix1
2 files changed, 6 insertions, 3 deletions
diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix
index fcdd3082f5a6..87595f39796d 100644
--- a/nixos/modules/services/backup/restic.nix
+++ b/nixos/modules/services/backup/restic.nix
@@ -133,13 +133,15 @@ in
         };
 
         timerConfig = mkOption {
-          type = types.attrsOf unitOption;
+          type = types.nullOr (types.attrsOf unitOption);
           default = {
             OnCalendar = "daily";
             Persistent = true;
           };
           description = lib.mdDoc ''
-            When to run the backup. See {manpage}`systemd.timer(5)` for details.
+            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.
           '';
           example = {
             OnCalendar = "00:05";
@@ -378,7 +380,7 @@ in
           wantedBy = [ "timers.target" ];
           timerConfig = backup.timerConfig;
         })
-        config.services.restic.backups;
+        (filterAttrs (_: backup: backup.timerConfig != null) config.services.restic.backups);
 
     # generate wrapper scripts, as described in the createWrapper option
     environment.systemPackages = lib.mapAttrsToList (name: backup: let
diff --git a/nixos/tests/restic.nix b/nixos/tests/restic.nix
index 868ccb7efd74..4111720cf6be 100644
--- a/nixos/tests/restic.nix
+++ b/nixos/tests/restic.nix
@@ -55,6 +55,7 @@ import ./make-test-python.nix (
               inherit passwordFile paths exclude pruneOpts backupPrepareCommand backupCleanupCommand;
               repository = remoteRepository;
               initialize = true;
+              timerConfig = null; # has no effect here, just checking that it doesn't break the service
             };
             remote-from-file-backup = {
               inherit passwordFile exclude pruneOpts;