cli/yt-dlp: extraConfig -> settings, use attrs
This commit is contained in:
parent
202de6511f
commit
fed2b4f064
1 changed files with 57 additions and 13 deletions
|
|
@ -8,6 +8,38 @@
|
||||||
let
|
let
|
||||||
name = "yt-dlp";
|
name = "yt-dlp";
|
||||||
cfg = config.nixowos.cli.${name};
|
cfg = config.nixowos.cli.${name};
|
||||||
|
|
||||||
|
serialize =
|
||||||
|
let
|
||||||
|
serializeValue =
|
||||||
|
value: prepend:
|
||||||
|
if builtins.isBool value then
|
||||||
|
""
|
||||||
|
else
|
||||||
|
prepend
|
||||||
|
+ (
|
||||||
|
if builtins.isString value then
|
||||||
|
value
|
||||||
|
else if builtins.isList value then
|
||||||
|
builtins.concatStringsSep "," value
|
||||||
|
else if builtins.isAttrs value then
|
||||||
|
lib.concatMapAttrsStringSep "," (key: value: "${key}:${value}") value
|
||||||
|
else
|
||||||
|
abort "invalid ${name} config value: ${value}"
|
||||||
|
);
|
||||||
|
in
|
||||||
|
|
||||||
|
set:
|
||||||
|
lib.strings.concatMapAttrsStringSep "\n" (
|
||||||
|
key: value:
|
||||||
|
if builtins.isBool value && !value then
|
||||||
|
""
|
||||||
|
else if builtins.stringLength key == 1 then
|
||||||
|
"-${key}${serializeValue value ""}"
|
||||||
|
else
|
||||||
|
"--${key}${serializeValue value "="}"
|
||||||
|
) set
|
||||||
|
+ "\n";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.nixowos.cli.${name} = {
|
options.nixowos.cli.${name} = {
|
||||||
|
|
@ -15,25 +47,37 @@ in
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs name { };
|
package = lib.mkPackageOption pkgs name { };
|
||||||
|
|
||||||
extraConfig = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type =
|
||||||
description = "List of commandline arguments";
|
with lib.types;
|
||||||
default = [
|
attrsOf (oneOf [
|
||||||
"--no-write-auto-subs"
|
bool
|
||||||
"--sub-langs=all,-live_chat"
|
str
|
||||||
|
(listOf str)
|
||||||
|
(attrsOf str)
|
||||||
|
]);
|
||||||
|
|
||||||
"--embed-subs"
|
default = {
|
||||||
"--embed-metadata"
|
no-write-auto-subs = true;
|
||||||
"--embed-chapters"
|
sub-langs = [
|
||||||
"--sponsorblock-mark=all"
|
"all"
|
||||||
|
"-live_chat"
|
||||||
|
];
|
||||||
|
|
||||||
"--paths=temp:/tmp"
|
embed-subs = true;
|
||||||
];
|
embed-metadata = true;
|
||||||
|
embed-chapters = true;
|
||||||
|
sponsorblock-mark = "all";
|
||||||
|
|
||||||
|
paths = {
|
||||||
|
"temp" = "/tmp";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
environment.systemPackages = [ cfg.package ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
environment.etc."${name}.conf".text = builtins.concatStringsSep "\n" cfg.extraConfig;
|
environment.etc."${name}.conf".text = serialize cfg.settings;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue