fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . yt-dlp ; 8 9renderSettings = mapAttrsToList ( name :value : 10if isBool value then 11if value then "-- ${ name } " else "--no- ${ name } " 12else 13"-- ${ name } ${ toString value } " ); 14 15in { 16meta . maintainers = [ ]; 17 18options . programs . yt-dlp = { 19enable = mkEnableOption "yt-dlp" ; 20 21package = mkOption { 22type = types . package ; 23default = pkgs . yt-dlp ; 24defaultText = literalExpression "pkgs.yt-dlp" ; 25description = "Package providing the {command}`yt-dlp` tool." ; 26}; 27 28settings = mkOption { 29type = with types ; attrsOf ( oneOf [ bool int str ]); 30default = { }; 31example = literalExpression '' 32{ 33embed-thumbnail = true; 34embed-subs = true; 35sub-langs = "all"; 36downloader = "aria2c"; 37downloader-args = "aria2c:'-c -x8 -s8 -k1M'"; 38} 39'' ; 40description = '' 41Configuration written to 42{file}`$XDG_CONFIG_HOME/yt-dlp/config`. 43 44Options must be specified in their "long form", for 45example, `update = true;` instead of `U = true;`. 46Short options can be specified in the `extraConfig` option. 47See <https://github.com/yt-dlp/yt-dlp#configuration> 48for explanation about possible values. 49'' ; 50}; 51 52extraConfig = mkOption { 53type = types . lines ; 54default = "" ; 55example = '' 56--update 57-F 58'' ; 59description = '' 60Extra configuration to add to 61{file}`$XDG_CONFIG_HOME/yt-dlp/config`. 62'' ; 63}; 64}; 65 66config = mkIf cfg . enable { 67home . packages = [ cfg . package ]; 68 69xdg . configFile . "yt-dlp/config" = 70mkIf ( cfg . settings != { } || cfg . extraConfig != "" ) { 71text = concatStringsSep "\n" 72( remove "" ( renderSettings cfg . settings ++ [ cfg . extraConfig ])) 73+ "\n" ; 74}; 75}; 76}