From d9811b1d84ae145aad61fd09e27a1570dfe30015 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 21 Jul 2022 09:54:36 +0800 Subject: [PATCH] services/gallery-dl: add job persistence --- modules/home-manager/services/gallery-dl.nix | 15 ++++++++++++++- modules/nixos/services/gallery-dl.nix | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/home-manager/services/gallery-dl.nix b/modules/home-manager/services/gallery-dl.nix index 21cf454e..a2edfa41 100644 --- a/modules/home-manager/services/gallery-dl.nix +++ b/modules/home-manager/services/gallery-dl.nix @@ -39,6 +39,18 @@ let example = "*-*-3/4"; }; + persistent = lib.mkOption { + type = lib.types.bool; + description = '' + Indicates whether job is persistent, starting the service despite the + timer missed. Defaults to true assuming it is used + on the desktop. + ''; + default = true; + defaultText = "true"; + example = "false"; + }; + extraArgs = lib.mkOption { type = with lib.types; listOf str; description = '' @@ -185,7 +197,8 @@ in { Timer = { OnCalendar = value.startAt; - Persistent = true; + Persistent = value.persistent; + RandomizedDelaySec = "2min"; }; Install.WantedBy = [ "timers.target" ]; diff --git a/modules/nixos/services/gallery-dl.nix b/modules/nixos/services/gallery-dl.nix index 9671ac26..27ba5800 100644 --- a/modules/nixos/services/gallery-dl.nix +++ b/modules/nixos/services/gallery-dl.nix @@ -38,6 +38,17 @@ let example = "*-*-3/4"; }; + persistent = lib.mkOption { + type = lib.types.bool; + description = '' + Indicates whether job is persistent, starting the service despite the + timer missed. + ''; + default = false; + defaultText = "false"; + example = "true"; + }; + extraArgs = lib.mkOption { type = with lib.types; listOf str; description = '' @@ -195,5 +206,13 @@ in { SystemCallErrorNumber = "EPERM"; }; }) cfg.jobs; + + systemd.timers = lib.mapAttrs' (name: value: + lib.nameValuePair "gallery-dl-archive-service-${name}" { + timerConfig = { + Persistent = value.persistent; + RandomizedDelaySec = "2min"; + }; + }) cfg.jobs; }; }