33 lines
884 B
Nix
33 lines
884 B
Nix
{ lib, pkgs, ... }:
|
|
let
|
|
# zAudioFormat because a better video format is preferred and
|
|
# cartesianProductOfSets cycles through the attributes in lexicographic order
|
|
formats = (map
|
|
({ videoFormat, zAudioFormat }: "${videoFormat}+${zAudioFormat}")
|
|
(lib.cartesianProductOfSets {
|
|
videoFormat = [ "bestvideo[vcodec^=av01]" "bestvideo[vcodec^=vp9]" "bestvideo[vcodec^=avc1]" "bestvideo" ];
|
|
zAudioFormat = [ "bestaudio[acodec^=opus]" "bestaudio[acodec^=mp4a]" "bestaudio" ];
|
|
})) ++ [ "best" ];
|
|
|
|
options = {
|
|
format = lib.concatStringsSep "/" formats;
|
|
};
|
|
|
|
textConfig = lib.concatStringsSep
|
|
"\n"
|
|
(lib.mapAttrsToList
|
|
(k: v: "--${k} ${v}")
|
|
options);
|
|
in
|
|
{
|
|
xdg.configFile = {
|
|
"youtube-dl/config".text = textConfig;
|
|
"yt-dlp/config".text = textConfig;
|
|
};
|
|
|
|
home.packages = with pkgs; [
|
|
youtube-dl
|
|
unstable.yt-dlp
|
|
];
|
|
}
|