diff --git a/modules/programs/yt-dlp.nix b/modules/programs/yt-dlp.nix index af74db16d..599f9a188 100644 --- a/modules/programs/yt-dlp.nix +++ b/modules/programs/yt-dlp.nix @@ -66,9 +66,11 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; - xdg.configFile."yt-dlp/config" = mkIf (cfg.settings != { }) { - text = concatStringsSep "\n" - (remove "" (renderSettings cfg.settings ++ [ cfg.extraConfig ])) + "\n"; - }; + xdg.configFile."yt-dlp/config" = + mkIf (cfg.settings != { } || cfg.extraConfig != "") { + text = concatStringsSep "\n" + (remove "" (renderSettings cfg.settings ++ [ cfg.extraConfig ])) + + "\n"; + }; }; } diff --git a/tests/modules/programs/yt-dlp/default.nix b/tests/modules/programs/yt-dlp/default.nix index 4b09a9c5a..74a664edc 100644 --- a/tests/modules/programs/yt-dlp/default.nix +++ b/tests/modules/programs/yt-dlp/default.nix @@ -1 +1,4 @@ -{ yt-dlp-simple-config = ./yt-dlp-simple-config.nix; } +{ + yt-dlp-simple-config = ./yt-dlp-simple-config.nix; + yt-dlp-extraConfig = ./yt-dlp-extraConfig.nix; +} diff --git a/tests/modules/programs/yt-dlp/yt-dlp-extraConfig-expected b/tests/modules/programs/yt-dlp/yt-dlp-extraConfig-expected new file mode 100644 index 000000000..339606778 --- /dev/null +++ b/tests/modules/programs/yt-dlp/yt-dlp-extraConfig-expected @@ -0,0 +1,2 @@ +--config-locations /home/user/.yt-dlp.conf + diff --git a/tests/modules/programs/yt-dlp/yt-dlp-extraConfig.nix b/tests/modules/programs/yt-dlp/yt-dlp-extraConfig.nix new file mode 100644 index 000000000..c28d44e57 --- /dev/null +++ b/tests/modules/programs/yt-dlp/yt-dlp-extraConfig.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + programs.yt-dlp = { + enable = true; + extraConfig = '' + --config-locations /home/user/.yt-dlp.conf + ''; + }; + + test.stubs.yt-dlp = { }; + + nmt.script = '' + assertFileExists home-files/.config/yt-dlp/config + assertFileContent home-files/.config/yt-dlp/config ${ + ./yt-dlp-extraConfig-expected + } + ''; +}