yt-dlp: allow multiple declarations of the same option

This commit is contained in:
Aguirre Matteo 2026-01-02 13:20:25 -03:00 committed by Robert Helgesson
parent 9ef24320f1
commit b558d54215
3 changed files with 28 additions and 9 deletions

View file

@ -9,12 +9,27 @@ let
cfg = config.programs.yt-dlp;
renderSettings = lib.mapAttrsToList (
configAtom =
with types;
oneOf [
bool
int
str
];
renderSingleOption =
name: value:
if lib.isBool value then
if value then "--${name}" else "--no-${name}"
else
"--${name} ${toString value}"
"--${name} ${toString value}";
renderSettings = lib.mapAttrsToList (
name: value:
if lib.isList value then
lib.concatStringsSep "\n" (map (renderSingleOption name) value)
else
renderSingleOption name value
);
in
@ -27,13 +42,7 @@ in
package = lib.mkPackageOption pkgs "yt-dlp" { };
settings = mkOption {
type =
with types;
attrsOf (oneOf [
bool
int
str
]);
type = with types; attrsOf (either configAtom (listOf configAtom));
default = { };
example = lib.literalExpression ''
{
@ -42,6 +51,10 @@ in
sub-langs = "all";
downloader = "aria2c";
downloader-args = "aria2c:'-c -x8 -s8 -k1M'";
color = [
"stdout:no_color"
"stderr:always"
];
}
'';
description = ''

View file

@ -1,3 +1,5 @@
--color stdout:no_color
--color stderr:always
--downloader aria2c
--downloader-args aria2c:'-c -x8 -s8 -k1M'
--no-embed-subs

View file

@ -8,6 +8,10 @@
downloader = "aria2c";
downloader-args = "aria2c:'-c -x8 -s8 -k1M'";
trim-filenames = 30;
color = [
"stdout:no_color"
"stderr:always"
];
};
extraConfig = ''
--config-locations /home/user/.yt-dlp.conf