mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 12:19:07 +00:00
services/yt-dlp: refactor
This commit is contained in:
parent
0927743845
commit
36909a281f
@ -3,6 +3,8 @@
|
|||||||
let
|
let
|
||||||
cfg = config.services.yt-dlp;
|
cfg = config.services.yt-dlp;
|
||||||
|
|
||||||
|
serviceLevelArgs = lib.escapeShellArgs cfg.extraArgs;
|
||||||
|
|
||||||
jobType = { name, config, options, ... }: {
|
jobType = { name, config, options, ... }: {
|
||||||
options = {
|
options = {
|
||||||
urls = lib.mkOption {
|
urls = lib.mkOption {
|
||||||
@ -148,12 +150,11 @@ in {
|
|||||||
ExecStart = let
|
ExecStart = let
|
||||||
scriptName =
|
scriptName =
|
||||||
"yt-dlp-archive-service-${config.home.username}-${name}";
|
"yt-dlp-archive-service-${config.home.username}-${name}";
|
||||||
|
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
|
||||||
|
urls = lib.escapeShellArgs urls;
|
||||||
archiveScript = pkgs.writeShellScriptBin scriptName ''
|
archiveScript = pkgs.writeShellScriptBin scriptName ''
|
||||||
${cfg.package}/bin/yt-dlp ${lib.escapeShellArgs cfg.extraArgs} ${
|
${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \
|
||||||
lib.escapeShellArgs value.extraArgs
|
${urls} --paths ${lib.escapeShellArg cfg.archivePath}
|
||||||
} ${lib.escapeShellArgs value.urls} --paths ${
|
|
||||||
lib.escapeShellArg cfg.archivePath
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
in "${archiveScript}/bin/${scriptName}";
|
in "${archiveScript}/bin/${scriptName}";
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
let
|
let
|
||||||
cfg = config.services.yt-dlp;
|
cfg = config.services.yt-dlp;
|
||||||
|
|
||||||
|
serviceLevelArgs = lib.escapeShellArgs cfg.extraArgs;
|
||||||
|
|
||||||
jobType = { name, config, options, ... }: {
|
jobType = { name, config, options, ... }: {
|
||||||
options = {
|
options = {
|
||||||
urls = lib.mkOption {
|
urls = lib.mkOption {
|
||||||
@ -125,7 +127,9 @@ in {
|
|||||||
# There's no need to go to the working directory since yt-dlp has the
|
# There's no need to go to the working directory since yt-dlp has the
|
||||||
# `--paths` flag.
|
# `--paths` flag.
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.services = lib.mapAttrs' (name: value:
|
systemd.services = lib.mapAttrs' (name: value: let
|
||||||
|
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
|
||||||
|
in
|
||||||
lib.nameValuePair "yt-dlp-archive-service-${name}" {
|
lib.nameValuePair "yt-dlp-archive-service-${name}" {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
description = "yt-dlp archive job for group '${name}'";
|
description = "yt-dlp archive job for group '${name}'";
|
||||||
@ -136,9 +140,8 @@ in {
|
|||||||
mkdir -p ${lib.escapeShellArg cfg.archivePath}
|
mkdir -p ${lib.escapeShellArg cfg.archivePath}
|
||||||
'';
|
'';
|
||||||
script = ''
|
script = ''
|
||||||
yt-dlp ${lib.escapeShellArgs cfg.extraArgs} ${
|
yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \
|
||||||
lib.escapeShellArgs value.extraArgs
|
${lib.escapeShellArgs value.urls} --paths ${lib.escapeShellArg cfg.archivePath}
|
||||||
} ${lib.escapeShellArgs value.urls} --paths ${cfg.archivePath}
|
|
||||||
'';
|
'';
|
||||||
startAt = value.startAt;
|
startAt = value.startAt;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
Loading…
Reference in New Issue
Block a user