diff --git a/modules/programs/yt-dlp.nix b/modules/programs/yt-dlp.nix index 5f0e55c20..c2c87f950 100644 --- a/modules/programs/yt-dlp.nix +++ b/modules/programs/yt-dlp.nix @@ -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 = '' diff --git a/tests/modules/programs/yt-dlp/yt-dlp-simple-config-expected b/tests/modules/programs/yt-dlp/yt-dlp-simple-config-expected index f5062ddeb..cdba0f43e 100644 --- a/tests/modules/programs/yt-dlp/yt-dlp-simple-config-expected +++ b/tests/modules/programs/yt-dlp/yt-dlp-simple-config-expected @@ -1,3 +1,5 @@ +--color stdout:no_color +--color stderr:always --downloader aria2c --downloader-args aria2c:'-c -x8 -s8 -k1M' --no-embed-subs diff --git a/tests/modules/programs/yt-dlp/yt-dlp-simple-config.nix b/tests/modules/programs/yt-dlp/yt-dlp-simple-config.nix index b48782c1b..19b36f1fc 100644 --- a/tests/modules/programs/yt-dlp/yt-dlp-simple-config.nix +++ b/tests/modules/programs/yt-dlp/yt-dlp-simple-config.nix @@ -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