yt-dlp: generate config if settings or extraConfig are defined (#4018)

Previously, the config was generated only if settings were defined. In a
case where settings weren't defined, extraConfig was ignored.
This commit is contained in:
Dany Marcoux 2023-05-25 15:06:34 +02:00 committed by GitHub
parent 58eb968c21
commit d1f04b0f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 5 deletions

View File

@ -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";
};
};
}

View File

@ -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;
}

View File

@ -0,0 +1,2 @@
--config-locations /home/user/.yt-dlp.conf

View File

@ -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
}
'';
}