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:
parent
58eb968c21
commit
d1f04b0f36
|
@ -66,9 +66,11 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."yt-dlp/config" = mkIf (cfg.settings != { }) {
|
xdg.configFile."yt-dlp/config" =
|
||||||
|
mkIf (cfg.settings != { } || cfg.extraConfig != "") {
|
||||||
text = concatStringsSep "\n"
|
text = concatStringsSep "\n"
|
||||||
(remove "" (renderSettings cfg.settings ++ [ cfg.extraConfig ])) + "\n";
|
(remove "" (renderSettings cfg.settings ++ [ cfg.extraConfig ]))
|
||||||
|
+ "\n";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
--config-locations /home/user/.yt-dlp.conf
|
||||||
|
|
19
tests/modules/programs/yt-dlp/yt-dlp-extraConfig.nix
Normal file
19
tests/modules/programs/yt-dlp/yt-dlp-extraConfig.nix
Normal 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
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue