services/yt-dlp: add job persistence

This commit is contained in:
Gabriel Arazas 2022-07-21 09:54:00 +08:00
parent 2526e552db
commit e9c2c3d226
2 changed files with 37 additions and 3 deletions

View File

@ -23,7 +23,8 @@ let
startAt = lib.mkOption {
type = with lib.types; str;
description = ''
Indicates how frequent the download will occur. The given schedule should follow the format as described from
Indicates how frequent the download will occur. The given schedule
should follow the format as described from
<citerefentry>
<refentrytitle>systemd.time</refentrytitle>
<manvolnum>5</manvolnum>
@ -33,6 +34,18 @@ let
example = "*-*-3/4";
};
persistent = lib.mkOption {
type = lib.types.bool;
description = ''
Indicates whether the service will start if timer has missed.
Defaults to <literal>true</literal> since this module mainly assumes
it is used on the desktop.
'';
default = true;
defaultText = "true";
example = "false";
};
extraArgs = lib.mkOption {
type = with lib.types; listOf str;
description =
@ -155,7 +168,8 @@ in {
Timer = {
OnCalendar = value.startAt;
Persistent = true;
RandomizedDelaySec = "2min";
Persistent = value.persistent;
};
Install.WantedBy = [ "timers.target" ];

View File

@ -23,7 +23,8 @@ let
startAt = lib.mkOption {
type = with lib.types; str;
description = ''
Indicates how frequent the download will occur. The given schedule should follow the format as described from
Indicates how frequent the download will occur. The given schedule
should follow the format as described from
<citerefentry>
<refentrytitle>systemd.time</refentrytitle>
<manvolnum>5</manvolnum>
@ -33,6 +34,17 @@ let
example = "*-*-3/4";
};
persistent = lib.mkOption {
type = lib.types.bool;
description = ''
Indicates whether the job should be persistent, starting the service
if missed.
'';
default = false;
defaultText = "false";
example = "true";
};
extraArgs = lib.mkOption {
type = with lib.types; listOf str;
description =
@ -145,5 +157,13 @@ in {
SystemCallErrorNumber = "EPERM";
};
}) cfg.jobs;
systemd.timers = lib.mapAttrs' (name: value:
lib.nameValuePair "yt-dlp-archive-service-${name}" {
timerConfig = {
Persistent = value.persistent;
RandomizedDelaySec = "2min";
};
}) cfg.jobs;
};
}