From 02e810b25175cd3ae04eda2ba3411084f0e07bbd Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 17 May 2024 12:28:14 +0200 Subject: [PATCH 01/28] ffmpeg: small first attempt --- pkgs/development/libraries/ffmpeg/generic.nix | 24 ++++++++++++----- pkgs/development/libraries/ffmpeg/options.nix | 27 +++++++++++++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/libraries/ffmpeg/options.nix diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 92a28d8a7705b..2b72c58ea5943 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -33,8 +33,6 @@ , fetchpatch2 # Feature flags -, withAlsa ? withHeadlessDeps && stdenv.isLinux # Alsa in/output supporT -, withAom ? withFullDeps # AV1 reference encoder , withAppKit ? withHeadlessDeps && stdenv.isDarwin # Apple AppKit framework , withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1" # ARIB STD-B24 Caption Decoder/Renderer , withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering @@ -321,6 +319,8 @@ * Testing */ , testers + +, configuration ? { } }: /* Maintainer notes: @@ -338,6 +338,18 @@ let inherit (lib) optional optionals optionalString enableFeature versionOlder versionAtLeast; + eval = lib.evalModules { + modules = [ + ./options.nix + configuration + { + _module.args = { + inherit stdenv; + }; + } + ]; + }; + inherit (eval) config; in @@ -531,8 +543,8 @@ stdenv.mkDerivation (finalAttrs: { /* * External libraries */ - (enableFeature withAlsa "alsa") - (enableFeature withAom "libaom") + (enableFeature config.alsa "alsa") + (enableFeature config.aom "libaom") (enableFeature withAppKit "appkit") ] ++ optionals (versionAtLeast version "6.1") [ (enableFeature withAribcaption "libaribcaption") @@ -682,8 +694,8 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals withCudaLLVM [ clang ]; buildInputs = [] - ++ optionals withAlsa [ alsa-lib ] - ++ optionals withAom [ libaom ] + ++ optionals config.alsa [ alsa-lib ] + ++ optionals config.aom [ libaom ] ++ optionals withAppKit [ AppKit ] ++ optionals withAribcaption [ libaribcaption ] ++ optionals withAss [ libass ] diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix new file mode 100644 index 0000000000000..4df0d06addf20 --- /dev/null +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -0,0 +1,27 @@ +{ + lib, + config, + stdenv, + ... +}: + +{ + options = { + headlessDeps = lib.mkOption { + default = true; + description = ""; + }; + fullDeps = lib.mkOption { + default = false; + description = ""; + }; + alsa = lib.mkOption { + default = config.headlessDeps && stdenv.isLinux; + description = "Alsa in/output support"; + }; + aom = lib.mkOption { + default = config.fullDeps; + description = "AV1 reference encoder"; + }; + }; +} From 0d3005f5f9392df72b541441488fa62034d637f1 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 17 May 2024 12:40:19 +0200 Subject: [PATCH 02/28] mlterm: initial mini-module conversion --- .../terminal-emulators/mlterm/default.nix | 39 ++++++++----------- .../terminal-emulators/mlterm/options.nix | 38 ++++++++++++++++++ 2 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 pkgs/applications/terminal-emulators/mlterm/options.nix diff --git a/pkgs/applications/terminal-emulators/mlterm/default.nix b/pkgs/applications/terminal-emulators/mlterm/default.nix index 28f027401bd74..4d3411950da25 100644 --- a/pkgs/applications/terminal-emulators/mlterm/default.nix +++ b/pkgs/applications/terminal-emulators/mlterm/default.nix @@ -20,17 +20,6 @@ , gtk ? gtk3 # List of gui libraries to use. According to `./configure --help` ran on # release 3.9.3, options are: (xlib|win32|fb|quartz|console|wayland|sdl2|beos) -, enableGuis ? { - xlib = enableX11; - # From some reason, upstream's ./configure script disables compilation of the - # external tool `mlconfig` if `enableGuis.fb == true`. This behavior is not - # documentd in `./configure --help`, and it is reported here: - # https://github.com/arakiken/mlterm/issues/73 - fb = false; - quartz = stdenv.isDarwin; - wayland = stdenv.isLinux; - sdl2 = true; -} , libxkbcommon , wayland # for the "wayland" --with-gui option , SDL2 # for the "sdl" --with-gui option @@ -74,17 +63,8 @@ # Open Type layout support, (substituting glyphs with opentype fonts) otl = true; } -# Configure the Exec directive in the generated .desktop file -, desktopBinary ? ( - if enableGuis.xlib then - "mlterm" - else if enableGuis.wayland then - "mlterm-wl" - else if enableGuis.sdl2 then - "mlterm-sdl2" - else - throw "mlterm: couldn't figure out what desktopBinary to use." - ) + +, configuration ? { } }: let @@ -96,6 +76,19 @@ let in lib.withFeatureAs (commaSepList != "") featureName commaSepList ; + eval = lib.evalModules { + modules = [ + ./options.nix + configuration + { + _module.args = { + inherit stdenv; + }; + } + ]; + }; + inherit (eval) config; + enableGuis = config.gui; in stdenv.mkDerivation (finalAttrs: { pname = "mlterm"; version = "3.9.3"; @@ -193,7 +186,7 @@ in stdenv.mkDerivation (finalAttrs: { desktopItem = makeDesktopItem { name = "mlterm"; - exec = "${desktopBinary} %U"; + exec = "${config.desktopBinary} %U"; icon = "mlterm"; type = "Application"; comment = "Multi Lingual TERMinal emulator"; diff --git a/pkgs/applications/terminal-emulators/mlterm/options.nix b/pkgs/applications/terminal-emulators/mlterm/options.nix new file mode 100644 index 0000000000000..8402640dd13c3 --- /dev/null +++ b/pkgs/applications/terminal-emulators/mlterm/options.nix @@ -0,0 +1,38 @@ +{ + lib, + config, + stdenv, + ... +}: + +{ + options = { + gui = { + xlib = lib.mkOption { default = config.x11; }; + # From some reason, upstream's ./configure script disables compilation of the + # external tool `mlconfig` if `config.gui.fb == true`. This behavior is not + # documentd in `./configure --help`, and it is reported here: + # https://github.com/arakiken/mlterm/issues/73 + fb = lib.mkOption { default = false; }; + quartz = lib.mkOption { default = stdenv.isDarwin; }; + wayland = lib.mkOption { default = stdenv.isLinux; }; + sdl2 = lib.mkOption { default = true; }; + }; + + # Whether to enable the X window system + x11 = lib.mkOption { default = stdenv.isLinux; }; + + desktopBinary = lib.mkOption { + default = + # Configure the Exec directive in the generated .desktop file + if config.gui.xlib then + "mlterm" + else if config.gui.wayland then + "mlterm-wl" + else if config.gui.sdl2 then + "mlterm-sdl2" + else + throw "mlterm: couldn't figure out what desktopBinary to use."; + }; + }; +} From 77762e48fc053e95b912014fd1d8d2e51c7f6448 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 17 May 2024 12:45:48 +0200 Subject: [PATCH 03/28] mlterm: further conversion --- .../terminal-emulators/mlterm/default.nix | 12 ++---------- .../terminal-emulators/mlterm/options.nix | 8 ++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/terminal-emulators/mlterm/default.nix b/pkgs/applications/terminal-emulators/mlterm/default.nix index 4d3411950da25..f79dc57b1a008 100644 --- a/pkgs/applications/terminal-emulators/mlterm/default.nix +++ b/pkgs/applications/terminal-emulators/mlterm/default.nix @@ -23,13 +23,6 @@ , libxkbcommon , wayland # for the "wayland" --with-gui option , SDL2 # for the "sdl" --with-gui option -# List of typing engines, the default list enables compiling all of the -# available ones, as recorded on release 3.9.3 -, enableTypeEngines ? { - xcore = false; # Considered legacy - xft = enableX11; - cairo = true; -} , libX11 , libXft , cairo @@ -47,8 +40,6 @@ registobmp = true; mlfc = true; } -# Whether to enable the X window system -, enableX11 ? stdenv.isLinux # Most of the input methods and other build features are enabled by default, # the following attribute set can be used to disable some of them. It's parsed # when we set `configureFlags`. If you find other configure Flags that require @@ -89,6 +80,7 @@ let }; inherit (eval) config; enableGuis = config.gui; + enableTypeEngines = config.typeEngines; in stdenv.mkDerivation (finalAttrs: { pname = "mlterm"; version = "3.9.3"; @@ -166,7 +158,7 @@ in stdenv.mkDerivation (finalAttrs: { (withFeaturesList "type-engines" enableTypeEngines) (withFeaturesList "tools" enableTools) (withFeaturesList "gui" enableGuis) - (lib.withFeature enableX11 "x") + (lib.withFeature config.x11 "x") ] ++ lib.optionals (gtk != null) [ "--with-gtk=${lib.versions.major gtk.version}.0" ] ++ (lib.mapAttrsToList (n: v: lib.enableFeature v n) enableFeatures) ++ [ diff --git a/pkgs/applications/terminal-emulators/mlterm/options.nix b/pkgs/applications/terminal-emulators/mlterm/options.nix index 8402640dd13c3..362aeed4af5f5 100644 --- a/pkgs/applications/terminal-emulators/mlterm/options.nix +++ b/pkgs/applications/terminal-emulators/mlterm/options.nix @@ -22,6 +22,14 @@ # Whether to enable the X window system x11 = lib.mkOption { default = stdenv.isLinux; }; + typeEngines = { + # List of typing engines, the default list enables compiling all of the + # available ones, as recorded on release 3.9.3 + xcore = lib.mkOption { default = false; }; # Considered legacy + xft = lib.mkOption { default = config.x11; }; + cairo = lib.mkOption { default = true; }; + }; + desktopBinary = lib.mkOption { default = # Configure the Exec directive in the generated .desktop file From 33ac36670b295413a0d607c17d4a8231d8481556 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 17 May 2024 12:52:29 +0200 Subject: [PATCH 04/28] mlterm: finish conversion using helper function --- .../terminal-emulators/mlterm/default.nix | 32 ++------------- .../terminal-emulators/mlterm/options.nix | 41 +++++++++++++++++-- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/pkgs/applications/terminal-emulators/mlterm/default.nix b/pkgs/applications/terminal-emulators/mlterm/default.nix index f79dc57b1a008..7961437dcdcad 100644 --- a/pkgs/applications/terminal-emulators/mlterm/default.nix +++ b/pkgs/applications/terminal-emulators/mlterm/default.nix @@ -26,35 +26,6 @@ , libX11 , libXft , cairo -# List of external tools to create, this default list includes all default -# tools, as recorded on release 3.9.3. -, enableTools ? { - mlclient = true; - mlconfig = true; - mlcc = true; - mlterm-menu = true; - # Note that according to upstream's ./configure script, to disable - # mlimgloader you have to disable _all_ tools. See: - # https://github.com/arakiken/mlterm/issues/69 - mlimgloader = true; - registobmp = true; - mlfc = true; -} -# Most of the input methods and other build features are enabled by default, -# the following attribute set can be used to disable some of them. It's parsed -# when we set `configureFlags`. If you find other configure Flags that require -# dependencies, it'd be nice to make that contribution here. -, enableFeatures ? { - uim = !stdenv.isDarwin; - ibus = !stdenv.isDarwin; - fcitx = !stdenv.isDarwin; - m17n = !stdenv.isDarwin; - ssh2 = true; - bidi = true; - # Open Type layout support, (substituting glyphs with opentype fonts) - otl = true; -} - , configuration ? { } }: @@ -79,8 +50,11 @@ let ]; }; inherit (eval) config; + # For compat in order to not need to touch the entire drv enableGuis = config.gui; enableTypeEngines = config.typeEngines; + enableTools = config.tools; + enableFeatures = config.features; in stdenv.mkDerivation (finalAttrs: { pname = "mlterm"; version = "3.9.3"; diff --git a/pkgs/applications/terminal-emulators/mlterm/options.nix b/pkgs/applications/terminal-emulators/mlterm/options.nix index 362aeed4af5f5..ff6e3af12ba07 100644 --- a/pkgs/applications/terminal-emulators/mlterm/options.nix +++ b/pkgs/applications/terminal-emulators/mlterm/options.nix @@ -5,6 +5,11 @@ ... }: +let + # For prototyping. In reality you may want to declare options manually + quickConvert = lib.mapAttrs (n: v: lib.mkOption { default = v; }); +in + { options = { gui = { @@ -25,9 +30,39 @@ typeEngines = { # List of typing engines, the default list enables compiling all of the # available ones, as recorded on release 3.9.3 - xcore = lib.mkOption { default = false; }; # Considered legacy - xft = lib.mkOption { default = config.x11; }; - cairo = lib.mkOption { default = true; }; + xcore = lib.mkOption { default = false; }; # Considered legacy + xft = lib.mkOption { default = config.x11; }; + cairo = lib.mkOption { default = true; }; + }; + + # Most of the input methods and other build features are enabled by default, + # the following attribute set can be used to disable some of them. It's parsed + # when we set `configureFlags`. If you find other configure Flags that require + # dependencies, it'd be nice to make that contribution here. + features = quickConvert { + uim = !stdenv.isDarwin; + ibus = !stdenv.isDarwin; + fcitx = !stdenv.isDarwin; + m17n = !stdenv.isDarwin; + ssh2 = true; + bidi = true; + # Open Type layout support, (substituting glyphs with opentype fonts) + otl = true; + }; + + # List of external tools to create, this default list includes all default + # tools, as recorded on release 3.9.3. + tools = quickConvert { + mlclient = true; + mlconfig = true; + mlcc = true; + mlterm-menu = true; + # Note that according to upstream's ./configure script, to disable + # mlimgloader you have to disable _all_ tools. See: + # https://github.com/arakiken/mlterm/issues/69 + mlimgloader = true; + registobmp = true; + mlfc = true; }; desktopBinary = lib.mkOption { From 8943decf7cf12f6ad636e5ec30211ee1ae314b1f Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 17 May 2024 14:04:16 +0200 Subject: [PATCH 05/28] mlterm: fix all-packages override --- pkgs/top-level/all-packages.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 05aca9f4018f1..627e313bee623 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3009,7 +3009,9 @@ with pkgs; mlterm = darwin.apple_sdk_11_0.callPackage ../applications/terminal-emulators/mlterm { }; mlterm-wayland = mlterm.override { - enableX11 = false; + configuration = { + x11 = false; + }; }; mrxvt = callPackage ../applications/terminal-emulators/mrxvt { }; From 5676088d25c0fec95972b4a92048569165a9b341 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sun, 18 Aug 2024 01:36:06 +0200 Subject: [PATCH 06/28] wip new options system with type --- pkgs/development/libraries/ffmpeg/options.nix | 144 ++++++++++++++++-- 1 file changed, 128 insertions(+), 16 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 4df0d06addf20..f181d1f3062c4 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -2,26 +2,138 @@ lib, config, stdenv, + pkgs, # TODO ... }: + +let + ffmpegFlag = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Whether to enable this flag."; + packages = lib.mkOption { + type = with lib.types; attrsOf package; + default = { }; + description = "The dependencies required to enable this flag."; + }; + version = lib.mkOption { + type = lib.types.str; + default = "0"; # Unknown/Enable in any version + description = "Minimum version that understands this flag. Flag will not be passed when lower."; + }; + variant = lib.mkOption { + type = lib.types.enum [ "headless" "small" "full" ]; + default = "headless"; + # description = policy here + }; + }; + }; + + mkFfmpegOption = name: default: lib.mkOption { + description = "Whether to enable ${name} in ffmpeg"; + type = ffmpegFlag; + inherit default; # Default done via ffmpegFlag type + }; + + featureOptions = + with pkgs; + { + config.alsa = { packages = { inherit alsa-lib; }; }; + config.aom = { packages = { inherit libaom; }; }; + appkit = { packages = { inherit AppKit; }; }; + aribcaption = { packages = { inherit libaribcaption; }; }; + ass = { packages = { inherit libass; }; }; + audiotoolbox = { packages = { inherit AudioToolbox; }; }; + avfoundation = { packages = { inherit AVFoundation; }; }; + avisynth = { packages = { inherit avisynthplus; }; }; + bluray = { packages = { inherit libbluray; }; }; + bs2b = { packages = { inherit libbs2b; }; }; + bzlib = { packages = { inherit bzip2; }; }; + caca = { packages = { inherit libcaca; }; }; + celt = { packages = { inherit celt; }; }; + chromaprint = { packages = { inherit chromaprint; }; }; + codec2 = { packages = { inherit codec2; }; }; + coreimage = { packages = { inherit CoreImage; }; }; + dav1d = { packages = { inherit dav1d; }; }; + dc1394 = { packages = { inherit libdc1394 libraw1394; }; }; + drm = { packages = { inherit libdrm; }; }; + dvdnav = { packages = { inherit libdvdnav; }; }; + dvdread = { packages = { inherit libdvdread; }; }; + fdkaac = { packages = { inherit fdk_aac; }; }; + nvcodec = { packages = { inherit (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers); }; }; + flite = { packages = { inherit flite; }; }; + fontconfig = { packages = { inherit fontconfig; }; }; + freetype = { packages = { inherit freetype; }; }; + frei0r = { packages = { inherit frei0r; }; }; + fribidi = { packages = { inherit fribidi; }; }; + gme = { packages = { inherit game-music-emu; }; }; + gnutls = { packages = { inherit gnutls; }; }; + gsm = { packages = { inherit gsm; }; }; + harfbuzz = { packages = { inherit harfbuzz; }; }; + iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? + jack = { packages = { inherit libjack2; }; }; + jxl = { packages = { inherit libjxl; }; }; + ladspa = { packages = { inherit ladspaH; }; }; + lzma = { packages = { inherit xz; }; }; + mfx = { packages = { inherit intel-media-sdk; }; }; + modplug = { packages = { inherit libmodplug; }; }; + mp3lame = { packages = { inherit lame; }; }; + mysofa = { packages = { inherit libmysofa; }; }; + ogg = { packages = { inherit libogg; }; }; + openal = { packages = { inherit openal; }; }; + opencl = { packages = { inherit ocl-icd opencl-headers; }; }; + hopencoreamrnb = { packages = { inherit opencore-amr; }; }; + opengl = { packages = { inherit libGL libGLU; }; }; + openh264 = { packages = { inherit openh264; }; }; + openjpeg = { packages = { inherit openjpeg; }; }; + openmpt = { packages = { inherit libopenmpt; }; }; + opus = { packages = { inherit libopus; }; }; + placebo = { packages = { inherit (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) vulkan-headers; }; }; + pulse = { packages = { inherit libpulseaudio; }; }; + qrencode = { packages = { inherit qrencode; }; }; + quirc = { packages = { inherit quirc; }; }; + rav1e = { packages = { inherit rav1e; }; }; + rtmp = { packages = { inherit rtmpdump; }; }; + samba = { packages = { inherit samba; }; }; + sdl2 = { packages = { inherit SDL2; }; }; + shaderc = { packages = { inherit shaderc; }; }; + soxr = { packages = { inherit soxr; }; }; + speex = { packages = { inherit speex; }; }; + srt = { packages = { inherit srt; }; }; + ssh = { packages = { inherit libssh; }; }; + svg = { packages = { inherit librsvg; }; }; + svtav1 = { packages = { inherit svt-av1; }; }; + tensorflow = { packages = { inherit libtensorflow; }; }; + theora = { packages = { inherit libtheora; }; }; + v4l2 = { packages = { inherit libv4l; }; }; + vaapi = { packages = { inherit (if withSmallDeps then libva else libva-minimal); }; }; + vdpau = { packages = { inherit libvdpau; }; }; + videotoolbox = { packages = { inherit VideoToolbox; }; }; + vidstab = { packages = { inherit vid-stab; }; }; + vmaf = { packages = { inherit libvmaf; }; }; + voamrwbenc = { packages = { inherit vo-amrwbenc; }; }; + vorbis = { packages = { inherit libvorbis; }; }; + vpl = { packages = { inherit libvpl; }; }; + vpx = { packages = { inherit libvpx; }; }; + vulkan = { packages = { inherit vulkan-headers vulkan-loader; }; }; + webp = { packages = { inherit libwebp; }; }; + x264 = { packages = { inherit x264; }; }; + x265 = { packages = { inherit x265; }; }; + xavs = { packages = { inherit xavs; }; }; + xcb = { packages = { inherit libxcb; }; }; + xevd = { packages = { inherit xevd; }; }; + xeve = { packages = { inherit xeve; }; }; + xlib = { packages = { inherit libX11 libXv libXext; }; }; + xml2 = { packages = { inherit libxml2; }; }; + xvid = { packages = { inherit xvidcore; }; }; + zimg = { packages = { inherit zimg; }; }; + zlib = { packages = { inherit zlib; }; }; + zmq = { packages = { inherit zeromq4; }; }; + }; +in + { options = { - headlessDeps = lib.mkOption { - default = true; - description = ""; - }; - fullDeps = lib.mkOption { - default = false; - description = ""; - }; - alsa = lib.mkOption { - default = config.headlessDeps && stdenv.isLinux; - description = "Alsa in/output support"; - }; - aom = lib.mkOption { - default = config.fullDeps; - description = "AV1 reference encoder"; - }; + }; } From 3afb8b1956face5cc555545adecd99ed37415bb4 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 23 Aug 2024 16:36:30 +0200 Subject: [PATCH 07/28] port buildInputs Now produces the same buildInputs (modulo order) as the regular ffmpeg --- pkgs/development/libraries/ffmpeg/generic.nix | 111 +---- pkgs/development/libraries/ffmpeg/options.nix | 471 +++++++++++++++--- 2 files changed, 408 insertions(+), 174 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 2b72c58ea5943..33ed8e974b960 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -321,6 +321,7 @@ , testers , configuration ? { } +, pkgs # TODO }: /* Maintainer notes: @@ -338,18 +339,21 @@ let inherit (lib) optional optionals optionalString enableFeature versionOlder versionAtLeast; + variants = lib.genAttrs [ "headless" "small" "full" ] lib.id; eval = lib.evalModules { modules = [ ./options.nix configuration { _module.args = { - inherit stdenv; + inherit stdenv pkgs version variants; + variant = ffmpegVariant; }; } ]; }; inherit (eval) config; + inherit (config) features; in @@ -543,8 +547,8 @@ stdenv.mkDerivation (finalAttrs: { /* * External libraries */ - (enableFeature config.alsa "alsa") - (enableFeature config.aom "libaom") + (enableFeature features.alsa.enable "alsa") + (enableFeature features.aom.enable "libaom") (enableFeature withAppKit "appkit") ] ++ optionals (versionAtLeast version "6.1") [ (enableFeature withAribcaption "libaribcaption") @@ -693,99 +697,12 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ removeReferencesTo addOpenGLRunpath perl pkg-config texinfo yasm ] ++ optionals withCudaLLVM [ clang ]; - buildInputs = [] - ++ optionals config.alsa [ alsa-lib ] - ++ optionals config.aom [ libaom ] - ++ optionals withAppKit [ AppKit ] - ++ optionals withAribcaption [ libaribcaption ] - ++ optionals withAss [ libass ] - ++ optionals withAudioToolbox [ AudioToolbox ] - ++ optionals withAvFoundation [ AVFoundation ] - ++ optionals withAvisynth [ avisynthplus ] - ++ optionals withBluray [ libbluray ] - ++ optionals withBs2b [ libbs2b ] - ++ optionals withBzlib [ bzip2 ] - ++ optionals withCaca [ libcaca ] - ++ optionals withCelt [ celt ] - ++ optionals withChromaprint [ chromaprint ] - ++ optionals withCodec2 [ codec2 ] - ++ optionals withCoreImage [ CoreImage ] - ++ optionals withDav1d [ dav1d ] - ++ optionals withDc1394 [ libdc1394 libraw1394 ] - ++ optionals withDrm [ libdrm ] - ++ optionals withDvdnav [ libdvdnav ] - ++ optionals withDvdread [ libdvdread ] - ++ optionals withFdkAac [ fdk_aac ] - ++ optionals withNvcodec [ (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers) ] - ++ optionals withFlite [ flite ] - ++ optionals withFontconfig [ fontconfig ] - ++ optionals withFreetype [ freetype ] - ++ optionals withFrei0r [ frei0r ] - ++ optionals withFribidi [ fribidi ] - ++ optionals withGme [ game-music-emu ] - ++ optionals withGnutls [ gnutls ] - ++ optionals withGsm [ gsm ] - ++ optionals withHarfbuzz [ harfbuzz ] - ++ optionals withIconv [ libiconv ] # On Linux this should be in libc, do we really need it? - ++ optionals withJack [ libjack2 ] - ++ optionals withJxl [ libjxl ] - ++ optionals withLadspa [ ladspaH ] - ++ optionals withLzma [ xz ] - ++ optionals withMfx [ intel-media-sdk ] - ++ optionals withModplug [ libmodplug ] - ++ optionals withMp3lame [ lame ] - ++ optionals withMysofa [ libmysofa ] - ++ optionals withOgg [ libogg ] - ++ optionals withOpenal [ openal ] - ++ optionals withOpencl [ ocl-icd opencl-headers ] - ++ optionals (withOpencoreAmrnb || withOpencoreAmrwb) [ opencore-amr ] - ++ optionals withOpengl [ libGL libGLU ] - ++ optionals withOpenh264 [ openh264 ] - ++ optionals withOpenjpeg [ openjpeg ] - ++ optionals withOpenmpt [ libopenmpt ] - ++ optionals withOpus [ libopus ] - ++ optionals withPlacebo [ (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) vulkan-headers ] - ++ optionals withPulse [ libpulseaudio ] - ++ optionals withQrencode [ qrencode ] - ++ optionals withQuirc [ quirc ] - ++ optionals withRav1e [ rav1e ] - ++ optionals withRtmp [ rtmpdump ] - ++ optionals withSamba [ samba ] - ++ optionals withSdl2 [ SDL2 ] - ++ optionals withShaderc [ shaderc ] - ++ optionals withSoxr [ soxr ] - ++ optionals withSpeex [ speex ] - ++ optionals withSrt [ srt ] - ++ optionals withSsh [ libssh ] - ++ optionals withSvg [ librsvg ] - ++ optionals withSvtav1 [ svt-av1 ] - ++ optionals withTensorflow [ libtensorflow ] - ++ optionals withTheora [ libtheora ] - ++ optionals withV4l2 [ libv4l ] - ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] - ++ optionals withVdpau [ libvdpau ] - ++ optionals withVideoToolbox [ VideoToolbox ] - ++ optionals withVidStab [ vid-stab ] - ++ optionals withVmaf [ libvmaf ] - ++ optionals withVoAmrwbenc [ vo-amrwbenc ] - ++ optionals withVorbis [ libvorbis ] - ++ optionals withVpl [ libvpl ] - ++ optionals withVpx [ libvpx ] - ++ optionals withVulkan [ vulkan-headers vulkan-loader ] - ++ optionals withWebp [ libwebp ] - ++ optionals withX264 [ x264 ] - ++ optionals withX265 [ x265 ] - ++ optionals withXavs [ xavs ] - ++ optionals withXcb [ libxcb ] - ++ optionals withXevd [ xevd ] - ++ optionals withXeve [ xeve ] - ++ optionals withXlib [ libX11 libXv libXext ] - ++ optionals withXml2 [ libxml2 ] - ++ optionals withXvid [ xvidcore ] - ++ optionals withZimg [ zimg ] - ++ optionals withZlib [ zlib ] - ++ optionals withZmq [ zeromq4 ] - ; + buildInputs = lib.pipe eval.config.features [ + (lib.filterAttrs (n: v: v.enable)) + (lib.filterAttrs (n: v: lib.versionAtLeast version v.version)) + (lib.mapAttrsToList (n: v: lib.attrValues v.packages)) + lib.flatten + ]; buildFlags = [ "all" ] ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable @@ -835,6 +752,8 @@ stdenv.mkDerivation (finalAttrs: { enableParallelBuilding = true; passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + passthru.config = config; + passthru.variants = variants; meta = with lib; { description = "A complete, cross-platform solution to record, convert and stream audio and video"; diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index f181d1f3062c4..2e847ac97bce5 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -3,18 +3,34 @@ config, stdenv, pkgs, # TODO + version, + variant, + variants, ... }: let - ffmpegFlag = lib.types.submodule { + isInVariant = v: + let + checks = rec { + full = variant == variants.full; + small = variant == variants.small || full; + headless = variant == variants.headless || small; + }; + in checks.${v} or false; + ffmpegFlag = lib.types.submodule ({ config, ... }: { options = { - enable = lib.mkEnableOption "Whether to enable this flag."; + enable = lib.mkEnableOption "Whether to enable this feature." // lib.mkOption { + # TODO this works but doesn't allow for convenient overrides yet. You + # can easily override enable = true but it will still be gated behind + # the variant check. + default = isInVariant config.variant && config.gate; + }; packages = lib.mkOption { type = with lib.types; attrsOf package; default = { }; - description = "The dependencies required to enable this flag."; + description = "The dependencies required to enable this feature."; }; version = lib.mkOption { type = lib.types.str; @@ -26,8 +42,19 @@ let default = "headless"; # description = policy here }; + + # TODO how to handle this better? + # Could you make use of priorities here? + # Use config = ? + gate = lib.mkOption { + default = true; + description = '' + Gates the default value for {option}`enable` behind a boolean. Use + this to disable certain features on certain platforms by default. + ''; + }; }; - }; + }); mkFfmpegOption = name: default: lib.mkOption { description = "Whether to enable ${name} in ffmpeg"; @@ -35,105 +62,393 @@ let inherit default; # Default done via ffmpegFlag type }; - featureOptions = + inherit (variants) headless small full; + + featureOptions = config: + # FIXME with pkgs; + with pkgs.darwin.apple_sdk.frameworks; + with pkgs.xorg; { - config.alsa = { packages = { inherit alsa-lib; }; }; - config.aom = { packages = { inherit libaom; }; }; - appkit = { packages = { inherit AppKit; }; }; - aribcaption = { packages = { inherit libaribcaption; }; }; - ass = { packages = { inherit libass; }; }; - audiotoolbox = { packages = { inherit AudioToolbox; }; }; - avfoundation = { packages = { inherit AVFoundation; }; }; - avisynth = { packages = { inherit avisynthplus; }; }; - bluray = { packages = { inherit libbluray; }; }; - bs2b = { packages = { inherit libbs2b; }; }; + alsa = { packages = { inherit alsa-lib; }; }; + aom = { + variant = full; + packages = { inherit libaom; }; + }; + appkit = { + gate = stdenv.isDarwin; + packages = { inherit AppKit; }; + }; + aribcaption = { + variant = full; + packages = { inherit libaribcaption; }; + }; + ass = { + gate = stdenv.hostPlatform == stdenv.buildPlatform; + packages = { inherit libass; }; + }; + audiotoolbox = { + gate = stdenv.isDarwin; + packages = { inherit AudioToolbox; }; + }; + avfoundation = { + gate = stdenv.isDarwin; + packages = { inherit AVFoundation; }; + }; + avisynth = { + variant = full; + packages = { inherit avisynthplus; }; + }; + bluray = { + variant = full; + packages = { inherit libbluray; }; + }; + bs2b = { + variant = full; + packages = { inherit libbs2b; }; + }; bzlib = { packages = { inherit bzip2; }; }; - caca = { packages = { inherit libcaca; }; }; - celt = { packages = { inherit celt; }; }; - chromaprint = { packages = { inherit chromaprint; }; }; - codec2 = { packages = { inherit codec2; }; }; - coreimage = { packages = { inherit CoreImage; }; }; + caca = { + variant = full; + packages = { inherit libcaca; }; + }; + celt = { + variant = full; + packages = { inherit celt; }; + }; + chromaprint = { + variant = full; + packages = { inherit chromaprint; }; + }; + codec2 = { + variant = full; + packages = { inherit codec2; }; + }; + coreimage = { + gate = stdenv.isDarwin; + packages = { inherit CoreImage; }; + }; + cuda = { + inherit (config.nvcodec) gate; + variant = full; + }; + cudallvm = { + variant = full; + }; + cuvid = { + inherit (config.nvcodec) gate; + }; dav1d = { packages = { inherit dav1d; }; }; - dc1394 = { packages = { inherit libdc1394 libraw1394; }; }; - drm = { packages = { inherit libdrm; }; }; - dvdnav = { packages = { inherit libdvdnav; }; }; - dvdread = { packages = { inherit libdvdread; }; }; - fdkaac = { packages = { inherit fdk_aac; }; }; - nvcodec = { packages = { inherit (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers); }; }; - flite = { packages = { inherit flite; }; }; + dc1394 = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libdc1394 libraw1394; }; + }; + drm = { + gate = with stdenv; isLinux || isFreeBSD; + packages = { inherit libdrm; }; + }; + dvdnav = { + gate = config.gpl; + variant = full; + version = "7"; + packages = { inherit libdvdnav; }; + }; + dvdread = { + gate = config.gpl; + variant = full; + version = "7"; + packages = { inherit libdvdread; }; + }; + fdkaac = { + gate = with config; !gpl || unfree; + variant = full; + packages = { inherit fdk_aac; }; + }; + nvcodec = { + gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; + packages = { + nv-codec-headers = + if lib.versionAtLeast version "6" + then nv-codec-headers-12 + else nv-codec-headers; + }; + }; + flite = { + variant = full; + packages = { inherit flite; }; + }; fontconfig = { packages = { inherit fontconfig; }; }; freetype = { packages = { inherit freetype; }; }; - frei0r = { packages = { inherit frei0r; }; }; - fribidi = { packages = { inherit fribidi; }; }; - gme = { packages = { inherit game-music-emu; }; }; + frei0r = { + gate = config.gpl; + variant = full; + packages = { inherit frei0r; }; + }; + fribidi = { + variant = full; + packages = { inherit fribidi; }; + }; + gme = { + variant = full; + packages = { inherit game-music-emu; }; + }; gnutls = { packages = { inherit gnutls; }; }; - gsm = { packages = { inherit gsm; }; }; - harfbuzz = { packages = { inherit harfbuzz; }; }; + gsm = { + variant = full; + packages = { inherit gsm; }; + }; + harfbuzz = { + version = "6.1"; + packages = { inherit harfbuzz; }; + }; iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? - jack = { packages = { inherit libjack2; }; }; - jxl = { packages = { inherit libjxl; }; }; - ladspa = { packages = { inherit ladspaH; }; }; + jack = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libjack2; }; + }; + jxl = { + variant = full; + version = "5"; + packages = { inherit libjxl; }; + }; + ladspa = { + variant = full; + packages = { inherit ladspaH; }; + }; lzma = { packages = { inherit xz; }; }; - mfx = { packages = { inherit intel-media-sdk; }; }; - modplug = { packages = { inherit libmodplug; }; }; + mfx = { + gate = with stdenv.hostPlatform; isLinux && !isAarch; + variant = full; + packages = { inherit intel-media-sdk; }; + }; + modplug = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libmodplug; }; + }; mp3lame = { packages = { inherit lame; }; }; - mysofa = { packages = { inherit libmysofa; }; }; + mysofa = { + variant = full; + packages = { inherit libmysofa; }; + }; + nvdec = { + inherit (config.nvcodec) gate; + }; + nvenc = { + inherit (config.nvcodec) gate; + }; ogg = { packages = { inherit libogg; }; }; - openal = { packages = { inherit openal; }; }; - opencl = { packages = { inherit ocl-icd opencl-headers; }; }; - hopencoreamrnb = { packages = { inherit opencore-amr; }; }; - opengl = { packages = { inherit libGL libGLU; }; }; - openh264 = { packages = { inherit openh264; }; }; - openjpeg = { packages = { inherit openjpeg; }; }; - openmpt = { packages = { inherit libopenmpt; }; }; + openal = { + variant = full; + packages = { inherit openal; }; + }; + opencl = { + variant = full; + packages = { inherit ocl-icd opencl-headers; }; + }; + opencoreamrnb = { + gate = config.gplv3; + variant = full; + packages = { inherit opencore-amr; }; + }; + opengl = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libGL libGLU; }; + }; + openh264 = { + variant = full; + packages = { inherit openh264; }; + }; + openjpeg = { + variant = full; + packages = { inherit openjpeg; }; + }; + openmpt = { + variant = full; + packages = { inherit libopenmpt; }; + }; opus = { packages = { inherit libopus; }; }; - placebo = { packages = { inherit (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) vulkan-headers; }; }; - pulse = { packages = { inherit libpulseaudio; }; }; - qrencode = { packages = { inherit qrencode; }; }; - quirc = { packages = { inherit quirc; }; }; - rav1e = { packages = { inherit rav1e; }; }; - rtmp = { packages = { inherit rtmpdump; }; }; - samba = { packages = { inherit samba; }; }; - sdl2 = { packages = { inherit SDL2; }; }; - shaderc = { packages = { inherit shaderc; }; }; + placebo = { + gate = !stdenv.isDarwin; + variant = full; + packages = { + inherit vulkan-headers; + libplacebo = + if lib.versionAtLeast version "6.1" + then libplacebo + else libplacebo_5; + }; + }; + pulse = { + gate = stdenv.isLinux; + variant = small; + packages = { inherit libpulseaudio; }; + }; + qrencode = { + variant = full; + version = "7"; + packages = { inherit qrencode; }; + }; + quirc = { + variant = full; + version = "7"; + packages = { inherit quirc; }; + }; + rav1e = { + variant = full; + packages = { inherit rav1e; }; + }; + rtmp = { + variant = full; + packages = { inherit rtmpdump; }; + }; + samba = { + variant = full; + packages = { inherit samba; }; + }; + sdl2 = { + variant = small; + packages = { inherit SDL2; }; + }; + shaderc = { + gate = !stdenv.isDarwin; + variant = full; + version = "5"; + packages = { inherit shaderc; }; + }; soxr = { packages = { inherit soxr; }; }; speex = { packages = { inherit speex; }; }; srt = { packages = { inherit srt; }; }; ssh = { packages = { inherit libssh; }; }; - svg = { packages = { inherit librsvg; }; }; - svtav1 = { packages = { inherit svt-av1; }; }; - tensorflow = { packages = { inherit libtensorflow; }; }; + svg = { + variant = full; + packages = { inherit librsvg; }; + }; + svtav1 = { + gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; + packages = { inherit svt-av1; }; + }; + tensorflow = { + gate = false; + packages = { inherit libtensorflow; }; + }; theora = { packages = { inherit libtheora; }; }; - v4l2 = { packages = { inherit libv4l; }; }; - vaapi = { packages = { inherit (if withSmallDeps then libva else libva-minimal); }; }; - vdpau = { packages = { inherit libvdpau; }; }; - videotoolbox = { packages = { inherit VideoToolbox; }; }; - vidstab = { packages = { inherit vid-stab; }; }; - vmaf = { packages = { inherit libvmaf; }; }; - voamrwbenc = { packages = { inherit vo-amrwbenc; }; }; + v4l2 = { + gate = stdenv.isLinux; + packages = { inherit libv4l; }; + }; + vaapi = { + gate = with stdenv; isLinux || isFreeBSD; + packages = { + libva = if variant == headless then libva-minimal else libva; + }; + }; + vdpau = { + gate = !stdenv.hostPlatform.isMinGW; + variant = small; + packages = { inherit libvdpau; }; + }; + videotoolbox = { + gate = stdenv.isDarwin; + packages = { inherit VideoToolbox; }; + }; + vidstab = { + gate = config.gpl; + variant = full; + packages = { inherit vid-stab; }; + }; + vmaf = { + gate = !stdenv.isAarch64; + variant = full; + version = "5"; + packages = { inherit libvmaf; }; + }; + voamrwbenc = { + gate = config.gplv3; + variant = full; + packages = { inherit vo-amrwbenc; }; + }; vorbis = { packages = { inherit libvorbis; }; }; - vpl = { packages = { inherit libvpl; }; }; - vpx = { packages = { inherit libvpx; }; }; - vulkan = { packages = { inherit vulkan-headers vulkan-loader; }; }; - webp = { packages = { inherit libwebp; }; }; - x264 = { packages = { inherit x264; }; }; - x265 = { packages = { inherit x265; }; }; - xavs = { packages = { inherit xavs; }; }; - xcb = { packages = { inherit libxcb; }; }; - xevd = { packages = { inherit xevd; }; }; - xeve = { packages = { inherit xeve; }; }; - xlib = { packages = { inherit libX11 libXv libXext; }; }; - xml2 = { packages = { inherit libxml2; }; }; - xvid = { packages = { inherit xvidcore; }; }; + vpl = { + gate = false; + packages = { inherit libvpl; }; + }; + vpx = { + gate = stdenv.buildPlatform == stdenv.hostPlatform; + packages = { inherit libvpx; }; + }; + vulkan = { + gate = !stdenv.isDarwin; + variant = small; + packages = { inherit vulkan-headers vulkan-loader; }; }; + webp = { + variant = full; + packages = { inherit libwebp; }; + }; + x264 = { + gate = config.gpl; + packages = { inherit x264; }; + }; + x265 = { + gate = config.gpl; + packages = { inherit x265; }; + }; + xavs = { + gate = config.gpl; + variant = full; + packages = { inherit xavs; }; + }; + xcb = { + gate = with (lib.mapAttrs (n: v: v.enable) config); xcbshape || xcbshm || xcbxfixes; + packages = { inherit libxcb; }; + }; + xcbshape = { variant = full; }; + xcbshm = { variant = full; }; + xcbxfixes = { variant = full; }; + xevd = { + gate = stdenv.hostPlatform.isx86; + variant = full; + version = "7"; + packages = { inherit xevd; }; + }; + xeve = { + gate = stdenv.hostPlatform.isx86; + variant = full; + version = "7"; + packages = { inherit xeve; }; + }; + xlib = { + variant = full; + packages = { inherit libX11 libXv libXext; }; + }; + xml2 = { + variant = full; + packages = { inherit libxml2; }; + }; + xvid = { + gate = config.gpl; + packages = { inherit xvidcore; }; + }; zimg = { packages = { inherit zimg; }; }; zlib = { packages = { inherit zlib; }; }; - zmq = { packages = { inherit zeromq4; }; }; + zmq = { + variant = full; + packages = { inherit zeromq4; }; + }; }; in { options = { + features = lib.mapAttrs mkFfmpegOption (featureOptions (config.features // { gpl = true; gplv3 = true; unfree = false; })); # TODO + foo = lib.mkOption { default = isInVariant "full"; }; }; + + # config = { + # features.tensorflow.gate = true; + # }; } From 698eafe304a9ec9a679d9a25a302a554ffdce09f Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 26 Aug 2024 20:30:15 +0200 Subject: [PATCH 08/28] port configureFlags --- pkgs/development/libraries/ffmpeg/generic.nix | 128 +------------- pkgs/development/libraries/ffmpeg/options.nix | 163 +++++++++++++++--- 2 files changed, 146 insertions(+), 145 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 33ed8e974b960..c60913eb7bc57 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -544,128 +544,6 @@ stdenv.mkDerivation (finalAttrs: { ] ++ optionals withDoc [ "--docdir=${placeholder "doc"}/share/doc/ffmpeg" ] ++ [ - /* - * External libraries - */ - (enableFeature features.alsa.enable "alsa") - (enableFeature features.aom.enable "libaom") - (enableFeature withAppKit "appkit") - ] ++ optionals (versionAtLeast version "6.1") [ - (enableFeature withAribcaption "libaribcaption") - ] ++ [ - (enableFeature withAss "libass") - (enableFeature withAudioToolbox "audiotoolbox") - (enableFeature withAvFoundation "avfoundation") - (enableFeature withAvisynth "avisynth") - (enableFeature withBluray "libbluray") - (enableFeature withBs2b "libbs2b") - (enableFeature withBzlib "bzlib") - (enableFeature withCaca "libcaca") - (enableFeature withCelt "libcelt") - (enableFeature withChromaprint "chromaprint") - (enableFeature withCodec2 "libcodec2") - (enableFeature withCoreImage "coreimage") - (enableFeature withCuda "cuda") - (enableFeature withCudaLLVM "cuda-llvm") - (enableFeature withCuvid "cuvid") - (enableFeature withDav1d "libdav1d") - (enableFeature withDc1394 "libdc1394") - (enableFeature withDrm "libdrm") - ] ++ optionals (versionAtLeast version "7") [ - (enableFeature withDvdnav "libdvdnav") - (enableFeature withDvdread "libdvdread") - ] ++ [ - (enableFeature withFdkAac "libfdk-aac") - (enableFeature withNvcodec "ffnvcodec") - (enableFeature withFlite "libflite") - (enableFeature withFontconfig "fontconfig") - (enableFeature withFontconfig "libfontconfig") - (enableFeature withFreetype "libfreetype") - (enableFeature withFrei0r "frei0r") - (enableFeature withFribidi "libfribidi") - (enableFeature withGme "libgme") - (enableFeature withGnutls "gnutls") - (enableFeature withGsm "libgsm") - ] ++ optionals (versionAtLeast version "6.1") [ - (enableFeature withHarfbuzz "libharfbuzz") - ] ++ [ - (enableFeature withIconv "iconv") - (enableFeature withJack "libjack") - ] ++ optionals (versionAtLeast finalAttrs.version "5.0") [ - (enableFeature withJxl "libjxl") - ] ++ [ - (enableFeature withLadspa "ladspa") - (enableFeature withLzma "lzma") - (enableFeature withMfx "libmfx") - (enableFeature withModplug "libmodplug") - (enableFeature withMp3lame "libmp3lame") - (enableFeature withMysofa "libmysofa") - (enableFeature withNvdec "nvdec") - (enableFeature withNvenc "nvenc") - (enableFeature withOpenal "openal") - (enableFeature withOpencl "opencl") - (enableFeature withOpencoreAmrnb "libopencore-amrnb") - (enableFeature withOpencoreAmrwb "libopencore-amrwb") - (enableFeature withOpengl "opengl") - (enableFeature withOpenh264 "libopenh264") - (enableFeature withOpenjpeg "libopenjpeg") - (enableFeature withOpenmpt "libopenmpt") - (enableFeature withOpus "libopus") - ] ++ optionals (versionAtLeast version "5.0") [ - (enableFeature withPlacebo "libplacebo") - ] ++ [ - (enableFeature withPulse "libpulse") - ] ++ optionals (versionAtLeast version "7") [ - (enableFeature withQrencode "libqrencode") - (enableFeature withQuirc "libquirc") - ] ++ [ - (enableFeature withRav1e "librav1e") - (enableFeature withRtmp "librtmp") - (enableFeature withSamba "libsmbclient") - (enableFeature withSdl2 "sdl2") - ] ++ optionals (versionAtLeast version "5.0") [ - (enableFeature withShaderc "libshaderc") - ] ++ [ - (enableFeature withSoxr "libsoxr") - (enableFeature withSpeex "libspeex") - (enableFeature withSrt "libsrt") - (enableFeature withSsh "libssh") - (enableFeature withSvg "librsvg") - (enableFeature withSvtav1 "libsvtav1") - (enableFeature withTensorflow "libtensorflow") - (enableFeature withTheora "libtheora") - (enableFeature withV4l2 "libv4l2") - (enableFeature withV4l2M2m "v4l2-m2m") - (enableFeature withVaapi "vaapi") - (enableFeature withVdpau "vdpau") - ] ++ optionals (versionAtLeast version "6.0") [ - (enableFeature withVpl "libvpl") - ] ++ [ - (enableFeature withVideoToolbox "videotoolbox") - (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 - (enableFeature withVmaf "libvmaf") - (enableFeature withVoAmrwbenc "libvo-amrwbenc") - (enableFeature withVorbis "libvorbis") - (enableFeature withVpx "libvpx") - (enableFeature withVulkan "vulkan") - (enableFeature withWebp "libwebp") - (enableFeature withX264 "libx264") - (enableFeature withX265 "libx265") - (enableFeature withXavs "libxavs") - (enableFeature withXcb "libxcb") - (enableFeature withXcbShape "libxcb-shape") - (enableFeature withXcbShm "libxcb-shm") - (enableFeature withXcbxfixes "libxcb-xfixes") - ] ++ optionals (versionAtLeast version "7") [ - (enableFeature withXevd "libxevd") - (enableFeature withXeve "libxeve") - ] ++ [ - (enableFeature withXlib "xlib") - (enableFeature withXml2 "libxml2") - (enableFeature withXvid "libxvid") - (enableFeature withZimg "libzimg") - (enableFeature withZlib "zlib") - (enableFeature withZmq "libzmq") /* * Developer flags */ @@ -680,7 +558,11 @@ stdenv.mkDerivation (finalAttrs: { ] ++ optionals stdenv.cc.isClang [ "--cc=clang" "--cxx=clang++" - ]; + ] ++ lib.pipe eval.config.features [ + (lib.filterAttrs (n: v: lib.versionAtLeast version v.version)) + (lib.mapAttrsToList (n: feature: (map (lib.enableFeature feature.enable) feature.flags))) + lib.flatten + ]); # ffmpeg embeds the configureFlags verbatim in its binaries and because we # configure binary, include, library dir etc., this causes references in diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 2e847ac97bce5..323e45552469a 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -19,7 +19,7 @@ let headless = variant == variants.headless || small; }; in checks.${v} or false; - ffmpegFlag = lib.types.submodule ({ config, ... }: { + ffmpegFlag = lib.types.submodule ({ config, name, ... }: { options = { enable = lib.mkEnableOption "Whether to enable this feature." // lib.mkOption { # TODO this works but doesn't allow for convenient overrides yet. You @@ -53,6 +53,22 @@ let this to disable certain features on certain platforms by default. ''; }; + + flags = lib.mkOption { + type = with lib.types; listOf str; + default = [ (config.flagPrefix + name) ]; + description = '' + Flags to be passed to the configure script for this feature. + ''; + }; + + flagPrefix = lib.mkOption { + default = ""; + example = "lib"; + description = '' + Which prefix the configure enable flag has. Frequently `lib`. + ''; + }; }; }); @@ -74,6 +90,7 @@ let aom = { variant = full; packages = { inherit libaom; }; + flagPrefix = "lib"; }; appkit = { gate = stdenv.isDarwin; @@ -82,10 +99,12 @@ let aribcaption = { variant = full; packages = { inherit libaribcaption; }; + flagPrefix = "lib"; }; ass = { gate = stdenv.hostPlatform == stdenv.buildPlatform; packages = { inherit libass; }; + flagPrefix = "lib"; }; audiotoolbox = { gate = stdenv.isDarwin; @@ -102,19 +121,23 @@ let bluray = { variant = full; packages = { inherit libbluray; }; + flagPrefix = "lib"; }; bs2b = { variant = full; packages = { inherit libbs2b; }; + flagPrefix = "lib"; }; bzlib = { packages = { inherit bzip2; }; }; caca = { variant = full; packages = { inherit libcaca; }; + flagPrefix = "lib"; }; celt = { variant = full; packages = { inherit celt; }; + flagPrefix = "lib"; }; chromaprint = { variant = full; @@ -123,6 +146,7 @@ let codec2 = { variant = full; packages = { inherit codec2; }; + flagPrefix = "lib"; }; coreimage = { gate = stdenv.isDarwin; @@ -132,38 +156,46 @@ let inherit (config.nvcodec) gate; variant = full; }; - cudallvm = { + cuda-llvm = { variant = full; }; cuvid = { inherit (config.nvcodec) gate; }; - dav1d = { packages = { inherit dav1d; }; }; + dav1d = { + packages = { inherit dav1d; }; + flagPrefix = "lib"; + }; dc1394 = { gate = !stdenv.isDarwin; variant = full; packages = { inherit libdc1394 libraw1394; }; + flagPrefix = "lib"; }; drm = { gate = with stdenv; isLinux || isFreeBSD; packages = { inherit libdrm; }; + flagPrefix = "lib"; }; dvdnav = { gate = config.gpl; variant = full; version = "7"; packages = { inherit libdvdnav; }; + flagPrefix = "lib"; }; dvdread = { gate = config.gpl; variant = full; version = "7"; packages = { inherit libdvdread; }; + flagPrefix = "lib"; }; - fdkaac = { + fdk-aac = { gate = with config; !gpl || unfree; variant = full; packages = { inherit fdk_aac; }; + flagPrefix = "lib"; }; nvcodec = { gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; @@ -173,13 +205,21 @@ let then nv-codec-headers-12 else nv-codec-headers; }; + flagPrefix = "ff"; }; flite = { variant = full; packages = { inherit flite; }; + flagPrefix = "lib"; + }; + fontconfig = { + packages = { inherit fontconfig; }; + flags = [ "fontconfig" "libfontconfig" ]; + }; + freetype = { + packages = { inherit freetype; }; + flagPrefix = "lib"; }; - fontconfig = { packages = { inherit fontconfig; }; }; - freetype = { packages = { inherit freetype; }; }; frei0r = { gate = config.gpl; variant = full; @@ -188,30 +228,36 @@ let fribidi = { variant = full; packages = { inherit fribidi; }; + flagPrefix = "lib"; }; gme = { variant = full; packages = { inherit game-music-emu; }; + flagPrefix = "lib"; }; gnutls = { packages = { inherit gnutls; }; }; gsm = { variant = full; packages = { inherit gsm; }; + flagPrefix = "lib"; }; harfbuzz = { version = "6.1"; packages = { inherit harfbuzz; }; + flagPrefix = "lib"; }; iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? jack = { gate = !stdenv.isDarwin; variant = full; packages = { inherit libjack2; }; + flagPrefix = "lib"; }; jxl = { variant = full; version = "5"; packages = { inherit libjxl; }; + flagPrefix = "lib"; }; ladspa = { variant = full; @@ -222,16 +268,22 @@ let gate = with stdenv.hostPlatform; isLinux && !isAarch; variant = full; packages = { inherit intel-media-sdk; }; + flagPrefix = "lib"; }; modplug = { gate = !stdenv.isDarwin; variant = full; packages = { inherit libmodplug; }; + flagPrefix = "lib"; + }; + mp3lame = { + packages = { inherit lame; }; + flagPrefix = "lib"; }; - mp3lame = { packages = { inherit lame; }; }; mysofa = { variant = full; packages = { inherit libmysofa; }; + flagPrefix = "lib"; }; nvdec = { inherit (config.nvcodec) gate; @@ -239,7 +291,10 @@ let nvenc = { inherit (config.nvcodec) gate; }; - ogg = { packages = { inherit libogg; }; }; + ogg = { + packages = { inherit libogg; }; + flags = [ ]; # There is no flag for OGG?! + }; openal = { variant = full; packages = { inherit openal; }; @@ -248,10 +303,11 @@ let variant = full; packages = { inherit ocl-icd opencl-headers; }; }; - opencoreamrnb = { + opencore-amr = { gate = config.gplv3; variant = full; packages = { inherit opencore-amr; }; + flags = [ "libopencore-amrnb" "libopencore-amrwb" ]; }; opengl = { gate = !stdenv.isDarwin; @@ -261,16 +317,22 @@ let openh264 = { variant = full; packages = { inherit openh264; }; + flagPrefix = "lib"; }; openjpeg = { variant = full; packages = { inherit openjpeg; }; + flagPrefix = "lib"; }; openmpt = { variant = full; packages = { inherit libopenmpt; }; + flagPrefix = "lib"; + }; + opus = { + packages = { inherit libopus; }; + flagPrefix = "lib"; }; - opus = { packages = { inherit libopus; }; }; placebo = { gate = !stdenv.isDarwin; variant = full; @@ -281,33 +343,40 @@ let then libplacebo else libplacebo_5; }; + flagPrefix = "lib"; }; pulse = { gate = stdenv.isLinux; variant = small; packages = { inherit libpulseaudio; }; + flagPrefix = "lib"; }; qrencode = { variant = full; version = "7"; packages = { inherit qrencode; }; + flagPrefix = "lib"; }; quirc = { variant = full; version = "7"; packages = { inherit quirc; }; + flagPrefix = "lib"; }; rav1e = { variant = full; packages = { inherit rav1e; }; + flagPrefix = "lib"; }; rtmp = { variant = full; packages = { inherit rtmpdump; }; + flagPrefix = "lib"; }; samba = { variant = full; packages = { inherit samba; }; + flags = [ "libsmbclient" ]; }; sdl2 = { variant = small; @@ -318,27 +387,47 @@ let variant = full; version = "5"; packages = { inherit shaderc; }; + flagPrefix = "lib"; + }; + soxr = { + packages = { inherit soxr; }; + flagPrefix = "lib"; + }; + speex = { + packages = { inherit speex; }; + flagPrefix = "lib"; + }; + srt = { + packages = { inherit srt; }; + flagPrefix = "lib"; + }; + ssh = { + packages = { inherit libssh; }; + flagPrefix = "lib"; }; - soxr = { packages = { inherit soxr; }; }; - speex = { packages = { inherit speex; }; }; - srt = { packages = { inherit srt; }; }; - ssh = { packages = { inherit libssh; }; }; svg = { variant = full; packages = { inherit librsvg; }; + flags = [ "librsvg" ]; }; svtav1 = { gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; packages = { inherit svt-av1; }; + flagPrefix = "lib"; }; tensorflow = { gate = false; packages = { inherit libtensorflow; }; + flagPrefix = "lib"; + }; + theora = { + packages = { inherit libtheora; }; + flagPrefix = "lib"; }; - theora = { packages = { inherit libtheora; }; }; v4l2 = { gate = stdenv.isLinux; packages = { inherit libv4l; }; + flags = [ "libv4l2" "v4l2-m2m" ]; }; vaapi = { gate = with stdenv; isLinux || isFreeBSD; @@ -359,26 +448,34 @@ let gate = config.gpl; variant = full; packages = { inherit vid-stab; }; + flagPrefix = "lib"; }; vmaf = { gate = !stdenv.isAarch64; variant = full; version = "5"; packages = { inherit libvmaf; }; + flagPrefix = "lib"; }; - voamrwbenc = { + vo-amrwbenc = { gate = config.gplv3; variant = full; packages = { inherit vo-amrwbenc; }; + flagPrefix = "lib"; + }; + vorbis = { + packages = { inherit libvorbis; }; + flagPrefix = "lib"; }; - vorbis = { packages = { inherit libvorbis; }; }; vpl = { gate = false; packages = { inherit libvpl; }; + flagPrefix = "lib"; }; vpx = { gate = stdenv.buildPlatform == stdenv.hostPlatform; packages = { inherit libvpx; }; + flagPrefix = "lib"; }; vulkan = { gate = !stdenv.isDarwin; @@ -387,38 +484,54 @@ let webp = { variant = full; packages = { inherit libwebp; }; + flagPrefix = "lib"; }; x264 = { gate = config.gpl; packages = { inherit x264; }; + flagPrefix = "lib"; }; x265 = { gate = config.gpl; packages = { inherit x265; }; + flagPrefix = "lib"; }; xavs = { gate = config.gpl; variant = full; packages = { inherit xavs; }; + flagPrefix = "lib"; }; xcb = { - gate = with (lib.mapAttrs (n: v: v.enable) config); xcbshape || xcbshm || xcbxfixes; + gate = with (lib.mapAttrs (n: v: v.enable) config); xcb-shape || xcb-shm || xcb-xfixes; packages = { inherit libxcb; }; + flagPrefix = "lib"; + }; + xcb-shape = { + variant = full; + flagPrefix = "lib"; + }; + xcb-shm = { + variant = full; + flagPrefix = "lib"; + }; + xcb-xfixes = { + variant = full; + flagPrefix = "lib"; }; - xcbshape = { variant = full; }; - xcbshm = { variant = full; }; - xcbxfixes = { variant = full; }; xevd = { gate = stdenv.hostPlatform.isx86; variant = full; version = "7"; packages = { inherit xevd; }; + flagPrefix = "lib"; }; xeve = { gate = stdenv.hostPlatform.isx86; variant = full; version = "7"; packages = { inherit xeve; }; + flagPrefix = "lib"; }; xlib = { variant = full; @@ -427,16 +540,22 @@ let xml2 = { variant = full; packages = { inherit libxml2; }; + flagPrefix = "lib"; }; xvid = { gate = config.gpl; packages = { inherit xvidcore; }; + flagPrefix = "lib"; + }; + zimg = { + packages = { inherit zimg; }; + flagPrefix = "lib"; }; - zimg = { packages = { inherit zimg; }; }; zlib = { packages = { inherit zlib; }; }; zmq = { variant = full; packages = { inherit zeromq4; }; + flagPrefix = "lib"; }; }; in From 39606cc5ca24f79e6c744708ca87b984b314bf37 Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 26 Aug 2024 20:50:35 +0200 Subject: [PATCH 09/28] cleanup --- pkgs/development/libraries/ffmpeg/options.nix | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 323e45552469a..bdcd7835d9d71 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -40,12 +40,8 @@ let variant = lib.mkOption { type = lib.types.enum [ "headless" "small" "full" ]; default = "headless"; - # description = policy here }; - # TODO how to handle this better? - # Could you make use of priorities here? - # Use config = ? gate = lib.mkOption { default = true; description = '' @@ -564,10 +560,5 @@ in options = { features = lib.mapAttrs mkFfmpegOption (featureOptions (config.features // { gpl = true; gplv3 = true; unfree = false; })); # TODO foo = lib.mkOption { default = isInVariant "full"; }; - }; - - # config = { - # features.tensorflow.gate = true; - # }; } From fc770c58d4ae71fedd2df3179215394f4f6ba4ec Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 26 Aug 2024 21:48:31 +0200 Subject: [PATCH 10/28] move variant description to option description --- pkgs/development/libraries/ffmpeg/generic.nix | 14 -------------- pkgs/development/libraries/ffmpeg/options.nix | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index c60913eb7bc57..d9afa9d8d7e2f 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -11,22 +11,8 @@ } , ffmpegVariant ? "small" # Decides which dependencies are enabled by default - - # Build with headless deps; excludes dependencies that are only necessary for - # GUI applications. To be used for purposes that don't generally need such - # components and i.e. only depend on libav , withHeadlessDeps ? ffmpegVariant == "headless" || withSmallDeps - - # Dependencies a user might customarily expect from a regular ffmpeg build. - # /All/ packages that depend on ffmpeg and some of its feaures should depend - # on the small variant. Small means the minimal set of features that satisfies - # all dependants in Nixpkgs , withSmallDeps ? ffmpegVariant == "small" || withFullDeps - - # Everything enabled; only guarded behind platform exclusivity or brokeness. - # If you need to depend on ffmpeg-full because ffmpeg is missing some feature - # your package needs, you should enable that feature in regular ffmpeg - # instead. , withFullDeps ? ffmpegVariant == "full" , fetchgit diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index bdcd7835d9d71..07a46d5c3bf0a 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -40,6 +40,25 @@ let variant = lib.mkOption { type = lib.types.enum [ "headless" "small" "full" ]; default = "headless"; + description = '' + Which variant this feature should be enabled in. + + Headless: Build with dependency set that is necessary for headless + operation; excludes dependencies that are only necessary for GUI + applications. Intended for purposes that don't generally need such + components and i.e. only depend on libav and for bootstrapping. + + Small: Dependencies a user might customarily expect from a regular + ffmpeg build. /All/ packages that depend on ffmpeg and some of its + feaures should depend on the small variant. Small means the minimal + set of features that satisfies all dependants in Nixpkgs + + Full: All dependencies enabled; only guarded behind platform + exclusivity, brokeness or extreme closure sizes that make more sense + in a specific ffmpeg variant. If you need to depend on ffmpeg-full + because ffmpeg is missing some feature your package needs, you should + enable that feature in regular ffmpeg instead. + ''; }; gate = lib.mkOption { From 20a4a42d3ab75dee4f8a3bbdaa5df9dcc14cace9 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 6 Sep 2024 22:27:20 +0200 Subject: [PATCH 11/28] convert non-feature options --- pkgs/development/libraries/ffmpeg/generic.nix | 224 +++--------------- pkgs/development/libraries/ffmpeg/options.nix | 125 +++++++++- 2 files changed, 139 insertions(+), 210 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index d9afa9d8d7e2f..94ca2b27d14cf 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -18,131 +18,11 @@ , fetchgit , fetchpatch2 - # Feature flags -, withAppKit ? withHeadlessDeps && stdenv.isDarwin # Apple AppKit framework -, withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1" # ARIB STD-B24 Caption Decoder/Renderer -, withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering -, withAudioToolbox ? withHeadlessDeps && stdenv.isDarwin # Apple AudioToolbox -, withAvFoundation ? withHeadlessDeps && stdenv.isDarwin # Apple AVFoundation framework -, withAvisynth ? withFullDeps # AviSynth script files reading -, withBluray ? withFullDeps # BluRay reading -, withBs2b ? withFullDeps # bs2b DSP library -, withBzlib ? withHeadlessDeps -, withCaca ? withFullDeps # Textual display (ASCII art) -, withCelt ? withFullDeps # CELT decoder -, withChromaprint ? withFullDeps # Audio fingerprinting -, withCodec2 ? withFullDeps # codec2 en/decoding -, withCoreImage ? withHeadlessDeps && stdenv.isDarwin # Apple CoreImage framework -, withCuda ? withFullDeps && withNvcodec -, withCudaLLVM ? withFullDeps -, withCuvid ? withHeadlessDeps && withNvcodec -, withDav1d ? withHeadlessDeps # AV1 decoder (focused on speed and correctness) -, withDc1394 ? withFullDeps && !stdenv.isDarwin # IIDC-1394 grabbing (ieee 1394) -, withDrm ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # libdrm support -, withDvdnav ? withFullDeps && withGPL && lib.versionAtLeast version "7" # needed for DVD demuxing -, withDvdread ? withFullDeps && withGPL && lib.versionAtLeast version "7" # needed for DVD demuxing -, withFdkAac ? withFullDeps && (!withGPL || withUnfree) # Fraunhofer FDK AAC de/encoder -, withNvcodec ? withHeadlessDeps && (with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform) # dynamically linked Nvidia code -, withFlite ? withFullDeps # Voice Synthesis -, withFontconfig ? withHeadlessDeps # Needed for drawtext filter -, withFreetype ? withHeadlessDeps # Needed for drawtext filter -, withFrei0r ? withFullDeps && withGPL # frei0r video filtering -, withFribidi ? withFullDeps # Needed for drawtext filter -, withGme ? withFullDeps # Game Music Emulator -, withGnutls ? withHeadlessDeps -, withGsm ? withFullDeps # GSM de/encoder -, withHarfbuzz ? withHeadlessDeps && lib.versionAtLeast version "6.1" # Needed for drawtext filter -, withIconv ? withHeadlessDeps -, withJack ? withFullDeps && !stdenv.isDarwin # Jack audio -, withJxl ? withFullDeps && lib.versionAtLeast version "5" # JPEG XL de/encoding -, withLadspa ? withFullDeps # LADSPA audio filtering -, withLzma ? withHeadlessDeps # xz-utils -, withMfx ? withFullDeps && (with stdenv.hostPlatform; isLinux && !isAarch) # Hardware acceleration via intel-media-sdk/libmfx -, withModplug ? withFullDeps && !stdenv.isDarwin # ModPlug support -, withMp3lame ? withHeadlessDeps # LAME MP3 encoder -, withMysofa ? withFullDeps # HRTF support via SOFAlizer -, withNvdec ? withHeadlessDeps && withNvcodec -, withNvenc ? withHeadlessDeps && withNvcodec -, withOgg ? withHeadlessDeps # Ogg container used by vorbis & theora -, withOpenal ? withFullDeps # OpenAL 1.1 capture support -, withOpencl ? withFullDeps -, withOpencoreAmrnb ? withFullDeps && withVersion3 # AMR-NB de/encoder -, withOpencoreAmrwb ? withFullDeps && withVersion3 # AMR-WB decoder -, withOpengl ? withFullDeps && !stdenv.isDarwin # OpenGL rendering -, withOpenh264 ? withFullDeps # H.264/AVC encoder -, withOpenjpeg ? withFullDeps # JPEG 2000 de/encoder -, withOpenmpt ? withFullDeps # Tracked music files decoder -, withOpus ? withHeadlessDeps # Opus de/encoder -, withPlacebo ? withFullDeps && !stdenv.isDarwin # libplacebo video processing library -, withPulse ? withSmallDeps && stdenv.isLinux # Pulseaudio input support -, withQrencode ? withFullDeps && lib.versionAtLeast version "7" # QR encode generation -, withQuirc ? withFullDeps && lib.versionAtLeast version "7" # QR decoding -, withRav1e ? withFullDeps # AV1 encoder (focused on speed and safety) -, withRtmp ? withFullDeps # RTMP[E] support -, withSamba ? withFullDeps && !stdenv.isDarwin && withGPLv3 # Samba protocol -, withSdl2 ? withSmallDeps -, withShaderc ? withFullDeps && !stdenv.isDarwin && lib.versionAtLeast version "5.0" -, withSoxr ? withHeadlessDeps # Resampling via soxr -, withSpeex ? withHeadlessDeps # Speex de/encoder -, withSrt ? withHeadlessDeps # Secure Reliable Transport (SRT) protocol -, withSsh ? withHeadlessDeps # SFTP protocol -, withSvg ? withFullDeps # SVG protocol -, withSvtav1 ? withHeadlessDeps && !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW # AV1 encoder/decoder (focused on speed and correctness) -, withTensorflow ? false # Tensorflow dnn backend support (Increases closure size by ~390 MiB) -, withTheora ? withHeadlessDeps # Theora encoder -, withV4l2 ? withHeadlessDeps && stdenv.isLinux # Video 4 Linux support -, withV4l2M2m ? withV4l2 -, withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # Vaapi hardware acceleration -, withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW # Vdpau hardware acceleration -, withVideoToolbox ? withHeadlessDeps && stdenv.isDarwin # Apple VideoToolbox -, withVidStab ? withFullDeps && withGPL # Video stabilization -, withVmaf ? withFullDeps && !stdenv.isAarch64 && lib.versionAtLeast version "5" # Netflix's VMAF (Video Multi-Method Assessment Fusion) -, withVoAmrwbenc ? withFullDeps && withVersion3 # AMR-WB encoder -, withVorbis ? withHeadlessDeps # Vorbis de/encoding, native encoder exists -, withVpl ? false # Hardware acceleration via intel libvpl -, withVpx ? withHeadlessDeps && stdenv.buildPlatform == stdenv.hostPlatform # VP8 & VP9 de/encoding -, withVulkan ? withSmallDeps && !stdenv.isDarwin -, withWebp ? withFullDeps # WebP encoder -, withX264 ? withHeadlessDeps && withGPL # H.264/AVC encoder -, withX265 ? withHeadlessDeps && withGPL # H.265/HEVC encoder -, withXavs ? withFullDeps && withGPL # AVS encoder -, withXcb ? withXcbShm || withXcbxfixes || withXcbShape # X11 grabbing using XCB -, withXcbShape ? withFullDeps # X11 grabbing shape rendering -, withXcbShm ? withFullDeps # X11 grabbing shm communication -, withXcbxfixes ? withFullDeps # X11 grabbing mouse rendering -, withXevd ? withFullDeps && lib.versionAtLeast version "7" && stdenv.hostPlatform.isx86 # MPEG-5 EVC decoding -, withXeve ? withFullDeps && lib.versionAtLeast version "7" && stdenv.hostPlatform.isx86 # MPEG-5 EVC encoding -, withXlib ? withFullDeps # Xlib support -, withXml2 ? withFullDeps # libxml2 support, for IMF and DASH demuxers -, withXvid ? withHeadlessDeps && withGPL # Xvid encoder, native encoder exists -, withZimg ? withHeadlessDeps -, withZlib ? withHeadlessDeps -, withZmq ? withFullDeps # Message passing - -/* - * Licensing options (yes some are listed twice, filters and such are not listed) - */ -, withGPL ? true -, withVersion3 ? true # When withGPL is set this implies GPLv3 otherwise it is LGPLv3 -, withGPLv3 ? withGPL && withVersion3 -, withUnfree ? false /* * Build options */ -, withSmallBuild ? false # Optimize for size instead of speed -, withRuntimeCPUDetection ? true # Detect CPU capabilities at runtime (disable to compile natively) -, withGrayscale ? withFullDeps # Full grayscale support -, withSwscaleAlpha ? buildSwscale # Alpha channel support in swscale. You probably want this when buildSwscale. -, withHardcodedTables ? withHeadlessDeps # Hardcode decode tables instead of runtime generation -, withSafeBitstreamReader ? withHeadlessDeps # Buffer boundary checking in bitreaders -, withMultithread ? true # Multithreading via pthreads/win32 threads -, withNetwork ? withHeadlessDeps # Network support , withPixelutils ? withHeadlessDeps # Pixel utils in libavutil -, withStatic ? stdenv.hostPlatform.isStatic -, withShared ? !stdenv.hostPlatform.isStatic -, withPic ? true -, withThumb ? false # On some ARM platforms /* * Program options @@ -150,8 +30,8 @@ , buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable , buildFfplay ? withSmallDeps # Build ffplay executable , buildFfprobe ? withHeadlessDeps # Build ffprobe executable -, buildQtFaststart ? withFullDeps # Build qt-faststart executable -, withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart +, buildQtFaststart ? withFullDeps # Build qt-faststart executable # TODO +, withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart # TODO /* * Library options */ @@ -166,7 +46,7 @@ , buildPostproc ? withHeadlessDeps # Build postproc library , buildSwresample ? withHeadlessDeps # Build swresample library , buildSwscale ? withHeadlessDeps # Build swscale library -, withLib ? buildAvcodec +, withLib ? buildAvcodec # TODO || buildAvdevice || buildAvfilter || buildAvformat @@ -177,22 +57,14 @@ /* * Documentation options */ -, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc +, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc # TODO , withHtmlDoc ? withHeadlessDeps # HTML documentation pages , withManPages ? withHeadlessDeps # Man documentation pages , withPodDoc ? withHeadlessDeps # POD documentation pages , withTxtDoc ? withHeadlessDeps # Text documentation pages # Whether a "doc" output will be produced. Note that withManPages does not produce # a "doc" output because its files go to "man". -, withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc) - -/* - * Developer options - */ -, withDebug ? false -, withOptimisations ? true -, withExtraWarnings ? false -, withStripping ? false +, withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc) # TODO /* * External libraries options @@ -340,6 +212,23 @@ let }; inherit (eval) config; inherit (config) features; + + # Feature flags + withCuda = features.cuda.enable; + withCudaLLVM = features.cuda-llvm.enable; + withCuvid = features.cuvid.enable; + withNvcodec = features.nvcodec.enable; + withFrei0r = features.frei0r.enable; + withMfx = features.mfx.enable; + withNvdec = features.nvdec.enable; + withNvenc = features.nvenc.enable; + withVpl = features.vpl.enable; + withVulkan = features.vulkan.enable; + withGPL = features.gpl.enable; + withVersion3 = features.version3.enable; + withGPLv3 = features.gplv3.enable; + withUnfree = features.unfree.enable; + in @@ -453,99 +342,38 @@ stdenv.mkDerivation (finalAttrs: { configurePlatforms = []; setOutputFlags = false; # Only accepts some of them - configureFlags = [ + configureFlags = (lib.sort (p: q: lib.compare p q == -1)) ([ #mingw64 is internally treated as mingw32, so 32 and 64 make no difference here "--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}" "--arch=${stdenv.hostPlatform.parsed.cpu.name}" "--pkg-config=${buildPackages.pkg-config.targetPrefix}pkg-config" - /* - * Licensing flags - */ - (enableFeature withGPL "gpl") - (enableFeature withVersion3 "version3") - (enableFeature withUnfree "nonfree") - /* - * Build flags - */ - (enableFeature withStatic "static") - (enableFeature withShared "shared") - (enableFeature withPic "pic") - (enableFeature withThumb "thumb") - - (enableFeature withSmallBuild "small") - (enableFeature withRuntimeCPUDetection "runtime-cpudetect") - (enableFeature withGrayscale "gray") - (enableFeature withSwscaleAlpha "swscale-alpha") - (enableFeature withHardcodedTables "hardcoded-tables") - (enableFeature withSafeBitstreamReader "safe-bitstream-reader") - - (enableFeature (withMultithread && stdenv.hostPlatform.isUnix) "pthreads") - (enableFeature (withMultithread && stdenv.hostPlatform.isWindows) "w32threads") - "--disable-os2threads" # We don't support OS/2 - - (enableFeature withNetwork "network") - (enableFeature withPixelutils "pixelutils") "--datadir=${placeholder "data"}/share/ffmpeg" - - /* - * Program flags - */ - (enableFeature buildFfmpeg "ffmpeg") - (enableFeature buildFfplay "ffplay") - (enableFeature buildFfprobe "ffprobe") ] ++ optionals withBin [ "--bindir=${placeholder "bin"}/bin" ] ++ [ - /* - * Library flags - */ - (enableFeature buildAvcodec "avcodec") - (enableFeature buildAvdevice "avdevice") - (enableFeature buildAvfilter "avfilter") - (enableFeature buildAvformat "avformat") ] ++ optionals (lib.versionOlder version "5") [ - # Ffmpeg > 4 doesn't know about the flag anymore - (enableFeature buildAvresample "avresample") ] ++ [ - (enableFeature buildAvutil "avutil") - (enableFeature (buildPostproc && withGPL) "postproc") - (enableFeature buildSwresample "swresample") - (enableFeature buildSwscale "swscale") ] ++ optionals withLib [ "--libdir=${placeholder "lib"}/lib" "--incdir=${placeholder "dev"}/include" ] ++ [ - /* - * Documentation flags - */ - (enableFeature withDocumentation "doc") - (enableFeature withHtmlDoc "htmlpages") - (enableFeature withManPages "manpages") ] ++ optionals withManPages [ "--mandir=${placeholder "man"}/share/man" ] ++ [ - (enableFeature withPodDoc "podpages") - (enableFeature withTxtDoc "txtpages") ] ++ optionals withDoc [ "--docdir=${placeholder "doc"}/share/doc/ffmpeg" ] ++ [ - /* - * Developer flags - */ - (enableFeature withDebug "debug") - (enableFeature withOptimisations "optimizations") - (enableFeature withExtraWarnings "extra-warnings") - (enableFeature withStripping "stripping") ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "--cross-prefix=${stdenv.cc.targetPrefix}" - "--enable-cross-compile" + "--enable-cross-compile" # TODO "--host-cc=${buildPackages.stdenv.cc}/bin/cc" ] ++ optionals stdenv.cc.isClang [ "--cc=clang" "--cxx=clang++" ] ++ lib.pipe eval.config.features [ (lib.filterAttrs (n: v: lib.versionAtLeast version v.version)) + (lib.filterAttrs (n: v: lib.versionOlder version v.versionMax)) (lib.mapAttrsToList (n: feature: (map (lib.enableFeature feature.enable) feature.flags))) lib.flatten ]); @@ -568,8 +396,10 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = lib.pipe eval.config.features [ (lib.filterAttrs (n: v: v.enable)) (lib.filterAttrs (n: v: lib.versionAtLeast version v.version)) + (lib.filterAttrs (n: v: lib.versionOlder version v.versionMax)) (lib.mapAttrsToList (n: v: lib.attrValues v.packages)) lib.flatten + (lib.sort (p: q: lib.compare (p.pname or "") (q.pname or "") == -1)) ]; buildFlags = [ "all" ] diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 07a46d5c3bf0a..47111d04cb223 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -37,6 +37,11 @@ let default = "0"; # Unknown/Enable in any version description = "Minimum version that understands this flag. Flag will not be passed when lower."; }; + versionMax = lib.mkOption { + type = lib.types.str; + default = "99999999"; # Unknown/Enable in any version + description = "Maximum version that understands this flag. Flag will not be passed when higher."; + }; variant = lib.mkOption { type = lib.types.enum [ "headless" "small" "full" ]; default = "headless"; @@ -100,7 +105,101 @@ let with pkgs; with pkgs.darwin.apple_sdk.frameworks; with pkgs.xorg; + let + enable = lib.mapAttrs (n: v: v.enable) config; + in { + /* + * Licensing flags + */ + gpl = { }; + version3 = { }; + gplv3 = { + gate = enable.gpl && enable.version3; + flags = [ ]; # internal + }; + unfree = { + enable = false; + flags = [ "nonfree" ]; + }; + /* + * Build flags + */ + static = { gate = stdenv.hostPlatform.isStatic; }; + shared = { gate = !stdenv.hostPlatform.isStatic; }; + pic = { }; + thumb = { enable = false; }; + small = { enable = false; }; + runtime-cpudetect = { }; + gray = { variant = full; }; + swscale-alpha = { }; # TODO same as swscale? + hardcoded-tables = { }; + safe-bitstream-reader = { }; + + small = { }; + runtime-cpudetect = { }; + gray = { }; + swscale-alpha = { }; + hardcoded-tables = { }; + safe-bitstream-reader = { }; + + multithread = { flags = [ ]; }; + pthreads = { + gate = enable.multithread && stdenv.hostPlatform.isUnix; + }; + w32threads = { + gate = enable.multithread && stdenv.hostPlatform.isWindows; + }; + os2threads = { + # We don't support OS/2 + enable = false; + }; + + network = { }; + pixelutils = { }; + + /* + * Program flags + */ + ffmpeg = { }; + ffplay = { variant = small; }; + ffprobe = { }; + + /* + * Library flags + */ + avcodec = { }; + avdevice = { }; + avfilter = { }; + avformat = { }; + avresample = { + # Ffmpeg > 4 doesn't know about the flag anymore + versionMax = "5"; + }; + + avutil = { }; + postproc = { gate = enable.gpl; }; + swresample = { }; + swscale = { }; + + /* + * Documentation flags + */ + doc = { }; + htmlpages = { }; + manpages = { }; + podpages = { }; + txtpages = { }; + + /* + * Developer flags + */ + debug = { enable = false; }; + optimizations = { }; + extra-warnings = { enable = false; }; + stripping = { enable = false; }; + + # Feature flags alsa = { packages = { inherit alsa-lib; }; }; aom = { variant = full; @@ -193,21 +292,21 @@ let flagPrefix = "lib"; }; dvdnav = { - gate = config.gpl; + gate = enable.gpl; variant = full; version = "7"; packages = { inherit libdvdnav; }; flagPrefix = "lib"; }; dvdread = { - gate = config.gpl; + gate = enable.gpl; variant = full; version = "7"; packages = { inherit libdvdread; }; flagPrefix = "lib"; }; fdk-aac = { - gate = with config; !gpl || unfree; + gate = with enable; !gpl || unfree; variant = full; packages = { inherit fdk_aac; }; flagPrefix = "lib"; @@ -236,7 +335,7 @@ let flagPrefix = "lib"; }; frei0r = { - gate = config.gpl; + gate = enable.gpl; variant = full; packages = { inherit frei0r; }; }; @@ -319,7 +418,7 @@ let packages = { inherit ocl-icd opencl-headers; }; }; opencore-amr = { - gate = config.gplv3; + gate = enable.gplv3; variant = full; packages = { inherit opencore-amr; }; flags = [ "libopencore-amrnb" "libopencore-amrwb" ]; @@ -460,7 +559,7 @@ let packages = { inherit VideoToolbox; }; }; vidstab = { - gate = config.gpl; + gate = enable.gpl; variant = full; packages = { inherit vid-stab; }; flagPrefix = "lib"; @@ -473,7 +572,7 @@ let flagPrefix = "lib"; }; vo-amrwbenc = { - gate = config.gplv3; + gate = enable.gplv3; variant = full; packages = { inherit vo-amrwbenc; }; flagPrefix = "lib"; @@ -502,23 +601,23 @@ let flagPrefix = "lib"; }; x264 = { - gate = config.gpl; + gate = enable.gpl; packages = { inherit x264; }; flagPrefix = "lib"; }; x265 = { - gate = config.gpl; + gate = enable.gpl; packages = { inherit x265; }; flagPrefix = "lib"; }; xavs = { - gate = config.gpl; + gate = enable.gpl; variant = full; packages = { inherit xavs; }; flagPrefix = "lib"; }; xcb = { - gate = with (lib.mapAttrs (n: v: v.enable) config); xcb-shape || xcb-shm || xcb-xfixes; + gate = with enable; xcb-shape || xcb-shm || xcb-xfixes; packages = { inherit libxcb; }; flagPrefix = "lib"; }; @@ -558,7 +657,7 @@ let flagPrefix = "lib"; }; xvid = { - gate = config.gpl; + gate = enable.gpl; packages = { inherit xvidcore; }; flagPrefix = "lib"; }; @@ -577,7 +676,7 @@ in { options = { - features = lib.mapAttrs mkFfmpegOption (featureOptions (config.features // { gpl = true; gplv3 = true; unfree = false; })); # TODO + features = lib.mapAttrs mkFfmpegOption (featureOptions (config.features)); foo = lib.mkOption { default = isInVariant "full"; }; }; } From 767516fa1d61e0b81c2c6158f907ec0f2343ddf7 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 6 Sep 2024 23:17:12 +0200 Subject: [PATCH 12/28] add back descriptions as first-class data entry --- pkgs/development/libraries/ffmpeg/generic.nix | 1 + pkgs/development/libraries/ffmpeg/options.nix | 75 ++++++++++++++++++- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 94ca2b27d14cf..6f70724a8c11c 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -451,6 +451,7 @@ stdenv.mkDerivation (finalAttrs: { passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; passthru.config = config; + passthru.options = eval.options; passthru.variants = variants; meta = with lib; { diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 47111d04cb223..8192065f341e3 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -89,13 +89,25 @@ let Which prefix the configure enable flag has. Frequently `lib`. ''; }; + + description = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + readOnly = true; + }; }; }); mkFfmpegOption = name: default: lib.mkOption { - description = "Whether to enable ${name} in ffmpeg"; type = ffmpegFlag; inherit default; # Default done via ffmpegFlag type + description = + let + additionalDescription = ": ${default.description}."; + hasDescription = default.description or null != null; + in + "Whether to enable ${name} in ffmpeg" + + (if hasDescription then additionalDescription else "."); }; inherit (variants) headless small full; @@ -113,7 +125,9 @@ let * Licensing flags */ gpl = { }; - version3 = { }; + version3 = { + description = "When {option}`gpl` is set this implies {option}`gplv3`. Otherwise the license is LGPLv3"; + }; gplv3 = { gate = enable.gpl && enable.version3; flags = [ ]; # internal @@ -205,6 +219,7 @@ let variant = full; packages = { inherit libaom; }; flagPrefix = "lib"; + description = "AV1 reference encoder"; }; appkit = { gate = stdenv.isDarwin; @@ -214,11 +229,13 @@ let variant = full; packages = { inherit libaribcaption; }; flagPrefix = "lib"; + description = "ARIB STD-B24 Caption Decoder/Renderer"; }; ass = { gate = stdenv.hostPlatform == stdenv.buildPlatform; packages = { inherit libass; }; flagPrefix = "lib"; + description = "(Advanced) SubStation Alpha subtitle rendering"; }; audiotoolbox = { gate = stdenv.isDarwin; @@ -231,6 +248,7 @@ let avisynth = { variant = full; packages = { inherit avisynthplus; }; + description = "AviSynth script processing"; }; bluray = { variant = full; @@ -247,6 +265,7 @@ let variant = full; packages = { inherit libcaca; }; flagPrefix = "lib"; + description = "Textual display (ASCII art)"; }; celt = { variant = full; @@ -256,6 +275,7 @@ let chromaprint = { variant = full; packages = { inherit chromaprint; }; + description = "Audio fingerprinting"; }; codec2 = { variant = full; @@ -279,12 +299,14 @@ let dav1d = { packages = { inherit dav1d; }; flagPrefix = "lib"; + description = "AV1 decoder (focused on speed and correctness)"; }; dc1394 = { gate = !stdenv.isDarwin; variant = full; packages = { inherit libdc1394 libraw1394; }; flagPrefix = "lib"; + description = "IIDC-1394 grabbing (ieee 1394/Firewire)"; }; drm = { gate = with stdenv; isLinux || isFreeBSD; @@ -297,6 +319,7 @@ let version = "7"; packages = { inherit libdvdnav; }; flagPrefix = "lib"; + description = "DVD demuxing"; }; dvdread = { gate = enable.gpl; @@ -304,12 +327,14 @@ let version = "7"; packages = { inherit libdvdread; }; flagPrefix = "lib"; + description = "DVD demuxing"; }; fdk-aac = { gate = with enable; !gpl || unfree; variant = full; packages = { inherit fdk_aac; }; flagPrefix = "lib"; + description = "Fraunhofer FDK AAC de/encoder"; }; nvcodec = { gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; @@ -320,34 +345,41 @@ let else nv-codec-headers; }; flagPrefix = "ff"; + description = "Dynamically linked Nvidia code"; }; flite = { variant = full; packages = { inherit flite; }; flagPrefix = "lib"; + description = "Voice synthesis"; }; fontconfig = { packages = { inherit fontconfig; }; flags = [ "fontconfig" "libfontconfig" ]; + description = "Font support for i.e. the drawtext filter"; }; freetype = { packages = { inherit freetype; }; flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; }; frei0r = { gate = enable.gpl; variant = full; packages = { inherit frei0r; }; + description = "Frei0r video filtering"; }; fribidi = { variant = full; packages = { inherit fribidi; }; flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; }; gme = { variant = full; packages = { inherit game-music-emu; }; flagPrefix = "lib"; + description = "Game Music Emulator"; }; gnutls = { packages = { inherit gnutls; }; }; gsm = { @@ -359,6 +391,7 @@ let version = "6.1"; packages = { inherit harfbuzz; }; flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; }; iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? jack = { @@ -376,6 +409,7 @@ let ladspa = { variant = full; packages = { inherit ladspaH; }; + description = "LADSPA audio filtering"; }; lzma = { packages = { inherit xz; }; }; mfx = { @@ -383,6 +417,7 @@ let variant = full; packages = { inherit intel-media-sdk; }; flagPrefix = "lib"; + description = "Hardware acceleration via intel-media-sdk/libmfx (incompatible with {option}`vpl`)"; }; modplug = { gate = !stdenv.isDarwin; @@ -398,6 +433,7 @@ let variant = full; packages = { inherit libmysofa; }; flagPrefix = "lib"; + description = "HRTF support via SOFAlizer"; }; nvdec = { inherit (config.nvcodec) gate; @@ -408,10 +444,12 @@ let ogg = { packages = { inherit libogg; }; flags = [ ]; # There is no flag for OGG?! + description = "Ogg container used by vorbis & theora"; }; openal = { variant = full; packages = { inherit openal; }; + description = "OpenAL 1.1 capture support"; }; opencl = { variant = full; @@ -427,6 +465,7 @@ let gate = !stdenv.isDarwin; variant = full; packages = { inherit libGL libGLU; }; + description = "OpenGL rendering"; }; openh264 = { variant = full; @@ -442,6 +481,7 @@ let variant = full; packages = { inherit libopenmpt; }; flagPrefix = "lib"; + description = "Tracked music files decoder"; }; opus = { packages = { inherit libopus; }; @@ -458,29 +498,34 @@ let else libplacebo_5; }; flagPrefix = "lib"; + description = "libplacebo video processing library"; }; pulse = { gate = stdenv.isLinux; variant = small; packages = { inherit libpulseaudio; }; flagPrefix = "lib"; + description = "Pulseaudio input support"; }; qrencode = { variant = full; version = "7"; packages = { inherit qrencode; }; flagPrefix = "lib"; + description = "QR encode generation"; }; quirc = { variant = full; version = "7"; packages = { inherit quirc; }; flagPrefix = "lib"; + description = "QR decoding"; }; rav1e = { variant = full; packages = { inherit rav1e; }; flagPrefix = "lib"; + description = "AV1 encoder (focused on speed and safety)"; }; rtmp = { variant = full; @@ -506,6 +551,7 @@ let soxr = { packages = { inherit soxr; }; flagPrefix = "lib"; + description = "Resampling via soxr"; }; speex = { packages = { inherit speex; }; @@ -514,10 +560,12 @@ let srt = { packages = { inherit srt; }; flagPrefix = "lib"; + description = "Secure Reliable Transport (SRT) protocol"; }; ssh = { packages = { inherit libssh; }; flagPrefix = "lib"; + description = "SFTP protocol"; }; svg = { variant = full; @@ -528,11 +576,13 @@ let gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; packages = { inherit svt-av1; }; flagPrefix = "lib"; + description = "AV1 encoder/decoder (focused on speed and correctness)"; }; tensorflow = { - gate = false; + gate = false; # Increases closure size by ~390 MiB and is rather specialised purpose packages = { inherit libtensorflow; }; flagPrefix = "lib"; + description = "Tensorflow dnn backend support"; }; theora = { packages = { inherit libtheora; }; @@ -542,17 +592,20 @@ let gate = stdenv.isLinux; packages = { inherit libv4l; }; flags = [ "libv4l2" "v4l2-m2m" ]; + description = "Video 4 Linux"; }; vaapi = { gate = with stdenv; isLinux || isFreeBSD; packages = { libva = if variant == headless then libva-minimal else libva; }; + description = "Vaapi hardware acceleration"; }; vdpau = { gate = !stdenv.hostPlatform.isMinGW; variant = small; packages = { inherit libvdpau; }; + description = "Vdpau hardware acceleration"; }; videotoolbox = { gate = stdenv.isDarwin; @@ -563,6 +616,7 @@ let variant = full; packages = { inherit vid-stab; }; flagPrefix = "lib"; + description = "Video stabilization"; }; vmaf = { gate = !stdenv.isAarch64; @@ -570,6 +624,7 @@ let version = "5"; packages = { inherit libvmaf; }; flagPrefix = "lib"; + description = "Netflix's VMAF (Video Multi-Method Assessment Fusion)"; }; vo-amrwbenc = { gate = enable.gplv3; @@ -580,16 +635,21 @@ let vorbis = { packages = { inherit libvorbis; }; flagPrefix = "lib"; + description = "Vorbis de/encoding, native encoder exists"; # TODO shouldn't we be using it then? }; vpl = { + # It is currently unclear whether this breaks support for old GPUs. See + # https://github.com/NixOS/nixpkgs/issues/303074 gate = false; packages = { inherit libvpl; }; flagPrefix = "lib"; + description = "Hardware acceleration via intel libvpl (incompatible with {option}`mfx`)"; }; vpx = { gate = stdenv.buildPlatform == stdenv.hostPlatform; packages = { inherit libvpx; }; flagPrefix = "lib"; + description = "VP8 & VP9 de/encoding"; }; vulkan = { gate = !stdenv.isDarwin; @@ -620,18 +680,22 @@ let gate = with enable; xcb-shape || xcb-shm || xcb-xfixes; packages = { inherit libxcb; }; flagPrefix = "lib"; + description = "X11 grabbing using XCB"; }; xcb-shape = { variant = full; flagPrefix = "lib"; + description = "X11 grabbing shape rendering"; }; xcb-shm = { variant = full; flagPrefix = "lib"; + description = "X11 grabbing shm communication"; }; xcb-xfixes = { variant = full; flagPrefix = "lib"; + description = "X11 grabbing mouse rendering"; }; xevd = { gate = stdenv.hostPlatform.isx86; @@ -639,6 +703,7 @@ let version = "7"; packages = { inherit xevd; }; flagPrefix = "lib"; + description = "MPEG-5 EVC decoding"; }; xeve = { gate = stdenv.hostPlatform.isx86; @@ -646,6 +711,7 @@ let version = "7"; packages = { inherit xeve; }; flagPrefix = "lib"; + description = "MPEG-5 EVC encoding"; }; xlib = { variant = full; @@ -655,11 +721,13 @@ let variant = full; packages = { inherit libxml2; }; flagPrefix = "lib"; + description = "libxml2 support, for IMF and DASH demuxers"; }; xvid = { gate = enable.gpl; packages = { inherit xvidcore; }; flagPrefix = "lib"; + description = "Xvid encoder, native encoder exists"; # TODO shouldn't we be using it then? }; zimg = { packages = { inherit zimg; }; @@ -670,6 +738,7 @@ let variant = full; packages = { inherit zeromq4; }; flagPrefix = "lib"; + description = "Message passing"; }; }; in From 42ae1cd4c17d400f553bb649fc36b3a538231632 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 6 Sep 2024 23:28:04 +0200 Subject: [PATCH 13/28] small improvements --- pkgs/development/libraries/ffmpeg/options.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 8192065f341e3..4c06e2d73174f 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -11,17 +11,19 @@ let - isInVariant = v: + # Checks whether the given variant of the flag is contained in the currently + # active variant. full ⊃ small ⊃ headless + isInVariant = flagVariant: let - checks = rec { + checks = { full = variant == variants.full; - small = variant == variants.small || full; - headless = variant == variants.headless || small; + small = variant == variants.small || checks.full; + headless = variant == variants.headless || checks.small; }; - in checks.${v} or false; + in checks.${flagVariant} or false; ffmpegFlag = lib.types.submodule ({ config, name, ... }: { options = { - enable = lib.mkEnableOption "Whether to enable this feature." // lib.mkOption { + enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg." // lib.mkOption { # TODO this works but doesn't allow for convenient overrides yet. You # can easily override enable = true but it will still be gated behind # the variant check. @@ -30,7 +32,7 @@ let packages = lib.mkOption { type = with lib.types; attrsOf package; default = { }; - description = "The dependencies required to enable this feature."; + description = "The dependencies required to enable ${name} support."; }; version = lib.mkOption { type = lib.types.str; @@ -106,7 +108,7 @@ let additionalDescription = ": ${default.description}."; hasDescription = default.description or null != null; in - "Whether to enable ${name} in ffmpeg" + "Control ${name} support in ffmpeg" + (if hasDescription then additionalDescription else "."); }; From 40490d1bc19d0bbfdbaa9e28b5c2053fe6950038 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 7 Sep 2024 00:05:58 +0200 Subject: [PATCH 14/28] slight description simplification --- pkgs/development/libraries/ffmpeg/options.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix index 4c06e2d73174f..e42fc153a9d39 100644 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ b/pkgs/development/libraries/ffmpeg/options.nix @@ -105,11 +105,10 @@ let inherit default; # Default done via ffmpegFlag type description = let - additionalDescription = ": ${default.description}."; hasDescription = default.description or null != null; + additionalDescription = lib.optionalString hasDescription ": ${default.description}"; in - "Control ${name} support in ffmpeg" - + (if hasDescription then additionalDescription else "."); + "Control ${name} support in ffmpeg${additionalDescription}."; }; inherit (variants) headless small full; From cff4b07f54064f84d8643bccdc2bf79cd7014b48 Mon Sep 17 00:00:00 2001 From: Atemu Date: Thu, 12 Sep 2024 05:48:38 +0200 Subject: [PATCH 15/28] cleanup module eval application --- pkgs/development/libraries/ffmpeg/generic.nix | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 6f70724a8c11c..f483287abb841 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -196,7 +196,7 @@ */ let - inherit (lib) optional optionals optionalString enableFeature versionOlder versionAtLeast; + inherit (lib) optional optionals optionalString versionOlder versionAtLeast; variants = lib.genAttrs [ "headless" "small" "full" ] lib.id; eval = lib.evalModules { modules = [ @@ -342,7 +342,7 @@ stdenv.mkDerivation (finalAttrs: { configurePlatforms = []; setOutputFlags = false; # Only accepts some of them - configureFlags = (lib.sort (p: q: lib.compare p q == -1)) ([ + configureFlags = [ #mingw64 is internally treated as mingw32, so 32 and 64 make no difference here "--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}" "--arch=${stdenv.hostPlatform.parsed.cpu.name}" @@ -351,19 +351,13 @@ stdenv.mkDerivation (finalAttrs: { "--datadir=${placeholder "data"}/share/ffmpeg" ] ++ optionals withBin [ "--bindir=${placeholder "bin"}/bin" - ] ++ [ - ] ++ optionals (lib.versionOlder version "5") [ - ] ++ [ ] ++ optionals withLib [ "--libdir=${placeholder "lib"}/lib" "--incdir=${placeholder "dev"}/include" - ] ++ [ ] ++ optionals withManPages [ "--mandir=${placeholder "man"}/share/man" - ] ++ [ ] ++ optionals withDoc [ "--docdir=${placeholder "doc"}/share/doc/ffmpeg" - ] ++ [ ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" # TODO @@ -372,11 +366,10 @@ stdenv.mkDerivation (finalAttrs: { "--cc=clang" "--cxx=clang++" ] ++ lib.pipe eval.config.features [ - (lib.filterAttrs (n: v: lib.versionAtLeast version v.version)) - (lib.filterAttrs (n: v: lib.versionOlder version v.versionMax)) + (lib.filterAttrs (n: v: lib.versionAtLeast version v.version && lib.versionOlder version v.versionMax)) (lib.mapAttrsToList (n: feature: (map (lib.enableFeature feature.enable) feature.flags))) lib.flatten - ]); + ]; # ffmpeg embeds the configureFlags verbatim in its binaries and because we # configure binary, include, library dir etc., this causes references in @@ -394,12 +387,9 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals withCudaLLVM [ clang ]; buildInputs = lib.pipe eval.config.features [ - (lib.filterAttrs (n: v: v.enable)) - (lib.filterAttrs (n: v: lib.versionAtLeast version v.version)) - (lib.filterAttrs (n: v: lib.versionOlder version v.versionMax)) + (lib.filterAttrs (n: v: v.enable && lib.versionAtLeast version v.version && lib.versionOlder version v.versionMax)) (lib.mapAttrsToList (n: v: lib.attrValues v.packages)) lib.flatten - (lib.sort (p: q: lib.compare (p.pname or "") (q.pname or "") == -1)) ]; buildFlags = [ "all" ] From 43831977432ee3fb27ad83a50d4373569fe55a0a Mon Sep 17 00:00:00 2001 From: Atemu Date: Thu, 12 Sep 2024 05:50:53 +0200 Subject: [PATCH 16/28] move options declaration to generic.nix Slightly less nice but necessary because we pass packages individually --- pkgs/development/libraries/ffmpeg/generic.nix | 744 +++++++++++++++++- 1 file changed, 733 insertions(+), 11 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index f483287abb841..abb59527e73c0 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -179,7 +179,6 @@ , testers , configuration ? { } -, pkgs # TODO }: /* Maintainer notes: @@ -198,15 +197,741 @@ let inherit (lib) optional optionals optionalString versionOlder versionAtLeast; variants = lib.genAttrs [ "headless" "small" "full" ] lib.id; + module = + { + config, + ... + }: + + let + # Checks whether the given variant of the flag is contained in the currently + # active variant. full ⊃ small ⊃ headless + isInVariant = flagVariant: + let + checks = { + full = ffmpegVariant == variants.full; + small = ffmpegVariant == variants.small || checks.full; + headless = ffmpegVariant == variants.headless || checks.small; + }; + in checks.${flagVariant} or false; + ffmpegFlag = lib.types.submodule ({ config, name, ... }: { + options = { + enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg." // lib.mkOption { + # TODO this works but doesn't allow for convenient overrides yet. You + # can easily override enable = true but it will still be gated behind + # the variant check. + default = isInVariant config.variant && config.gate; + }; + packages = lib.mkOption { + type = with lib.types; attrsOf package; + default = { }; + description = "The dependencies required to enable ${name} support."; + }; + version = lib.mkOption { + type = lib.types.str; + default = "0"; # Unknown/Enable in any version + description = "Minimum version that understands this flag. Flag will not be passed when lower."; + }; + versionMax = lib.mkOption { + type = lib.types.str; + default = "99999999"; # Unknown/Enable in any version + description = "Maximum version that understands this flag. Flag will not be passed when higher."; + }; + variant = lib.mkOption { + type = lib.types.enum [ "headless" "small" "full" ]; + default = "headless"; + description = '' + Which variant this feature should be enabled in. + + Headless: Build with dependency set that is necessary for headless + operation; excludes dependencies that are only necessary for GUI + applications. Intended for purposes that don't generally need such + components and i.e. only depend on libav and for bootstrapping. + + Small: Dependencies a user might customarily expect from a regular + ffmpeg build. /All/ packages that depend on ffmpeg and some of its + feaures should depend on the small variant. Small means the minimal + set of features that satisfies all dependants in Nixpkgs + + Full: All dependencies enabled; only guarded behind platform + exclusivity, brokeness or extreme closure sizes that make more sense + in a specific ffmpeg variant. If you need to depend on ffmpeg-full + because ffmpeg is missing some feature your package needs, you should + enable that feature in regular ffmpeg instead. + ''; + }; + + gate = lib.mkOption { + default = true; + description = '' + Gates the default value for {option}`enable` behind a boolean. Use + this to disable certain features on certain platforms by default. + ''; + }; + + flags = lib.mkOption { + type = with lib.types; listOf str; + default = [ (config.flagPrefix + name) ]; + description = '' + Flags to be passed to the configure script for this feature. + ''; + }; + + flagPrefix = lib.mkOption { + default = ""; + example = "lib"; + description = '' + Which prefix the configure enable flag has. Frequently `lib`. + ''; + }; + + description = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + readOnly = true; + }; + }; + }); + + mkFfmpegOption = name: default: lib.mkOption { + type = ffmpegFlag; + inherit default; # Default done via ffmpegFlag type + description = + let + hasDescription = default.description or null != null; + additionalDescription = lib.optionalString hasDescription ": ${default.description}"; + in + "Control ${name} support in ffmpeg${additionalDescription}."; + }; + + inherit (variants) headless small full; + + featureOptions = config: + let + enable = lib.mapAttrs (n: v: v.enable) config; + in + { + # Licensing flags + gpl = { }; + version3 = { + description = "When {option}`gpl` is set this implies {option}`gplv3`. Otherwise the license is LGPLv3"; + }; + gplv3 = { + gate = enable.gpl && enable.version3; + flags = [ ]; # internal + }; + unfree = { + enable = false; + flags = [ "nonfree" ]; + }; + # Build flags + static = { gate = stdenv.hostPlatform.isStatic; }; + shared = { gate = !stdenv.hostPlatform.isStatic; }; + pic = { }; + thumb = { enable = false; }; + small = { enable = false; }; + runtime-cpudetect = { }; + gray = { variant = full; }; + swscale-alpha = { }; # TODO same as swscale? + hardcoded-tables = { }; + safe-bitstream-reader = { }; + + small = { }; + runtime-cpudetect = { }; + gray = { }; + swscale-alpha = { }; + hardcoded-tables = { }; + safe-bitstream-reader = { }; + + multithread = { flags = [ ]; }; + pthreads = { + gate = enable.multithread && stdenv.hostPlatform.isUnix; + }; + w32threads = { + gate = enable.multithread && stdenv.hostPlatform.isWindows; + }; + os2threads = { + # We don't support OS/2 + enable = false; + }; + + network = { }; + pixelutils = { }; + + # Program flags + ffmpeg = { }; + ffplay = { variant = small; }; + ffprobe = { }; + + # Library flags + avcodec = { }; + avdevice = { }; + avfilter = { }; + avformat = { }; + avresample = { + # Ffmpeg > 4 doesn't know about the flag anymore + versionMax = "5"; + }; + + avutil = { }; + postproc = { gate = enable.gpl; }; + swresample = { }; + swscale = { }; + + # Documentation flags + doc = { }; + htmlpages = { }; + manpages = { }; + podpages = { }; + txtpages = { }; + + # Developer flags + debug = { enable = false; }; + optimizations = { }; + extra-warnings = { enable = false; }; + stripping = { enable = false; }; + + # Feature flags + alsa = { packages = { inherit alsa-lib; }; }; + aom = { + variant = full; + packages = { inherit libaom; }; + flagPrefix = "lib"; + description = "AV1 reference encoder"; + }; + appkit = { + gate = stdenv.isDarwin; + packages = { inherit AppKit; }; + }; + aribcaption = { + variant = full; + packages = { inherit libaribcaption; }; + flagPrefix = "lib"; + description = "ARIB STD-B24 Caption Decoder/Renderer"; + }; + ass = { + gate = stdenv.hostPlatform == stdenv.buildPlatform; + packages = { inherit libass; }; + flagPrefix = "lib"; + description = "(Advanced) SubStation Alpha subtitle rendering"; + }; + audiotoolbox = { + gate = stdenv.isDarwin; + packages = { inherit AudioToolbox; }; + }; + avfoundation = { + gate = stdenv.isDarwin; + packages = { inherit AVFoundation; }; + }; + avisynth = { + variant = full; + packages = { inherit avisynthplus; }; + description = "AviSynth script processing"; + }; + bluray = { + variant = full; + packages = { inherit libbluray; }; + flagPrefix = "lib"; + }; + bs2b = { + variant = full; + packages = { inherit libbs2b; }; + flagPrefix = "lib"; + }; + bzlib = { packages = { inherit bzip2; }; }; + caca = { + variant = full; + packages = { inherit libcaca; }; + flagPrefix = "lib"; + description = "Textual display (ASCII art)"; + }; + celt = { + variant = full; + packages = { inherit celt; }; + flagPrefix = "lib"; + }; + chromaprint = { + variant = full; + packages = { inherit chromaprint; }; + description = "Audio fingerprinting"; + }; + codec2 = { + variant = full; + packages = { inherit codec2; }; + flagPrefix = "lib"; + }; + coreimage = { + gate = stdenv.isDarwin; + packages = { inherit CoreImage; }; + }; + cuda = { + inherit (config.nvcodec) gate; + variant = full; + }; + cuda-llvm = { + variant = full; + }; + cuvid = { + inherit (config.nvcodec) gate; + }; + dav1d = { + packages = { inherit dav1d; }; + flagPrefix = "lib"; + description = "AV1 decoder (focused on speed and correctness)"; + }; + dc1394 = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libdc1394 libraw1394; }; + flagPrefix = "lib"; + description = "IIDC-1394 grabbing (ieee 1394/Firewire)"; + }; + drm = { + gate = with stdenv; isLinux || isFreeBSD; + packages = { inherit libdrm; }; + flagPrefix = "lib"; + }; + dvdnav = { + gate = enable.gpl; + variant = full; + version = "7"; + packages = { inherit libdvdnav; }; + flagPrefix = "lib"; + description = "DVD demuxing"; + }; + dvdread = { + gate = enable.gpl; + variant = full; + version = "7"; + packages = { inherit libdvdread; }; + flagPrefix = "lib"; + description = "DVD demuxing"; + }; + fdk-aac = { + gate = with enable; !gpl || unfree; + variant = full; + packages = { inherit fdk_aac; }; + flagPrefix = "lib"; + description = "Fraunhofer FDK AAC de/encoder"; + }; + nvcodec = { + gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; + packages = { + nv-codec-headers = + if lib.versionAtLeast version "6" + then nv-codec-headers-12 + else nv-codec-headers; + }; + flagPrefix = "ff"; + description = "Dynamically linked Nvidia code"; + }; + flite = { + variant = full; + packages = { inherit flite; }; + flagPrefix = "lib"; + description = "Voice synthesis"; + }; + fontconfig = { + packages = { inherit fontconfig; }; + flags = [ "fontconfig" "libfontconfig" ]; + description = "Font support for i.e. the drawtext filter"; + }; + freetype = { + packages = { inherit freetype; }; + flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; + }; + frei0r = { + gate = enable.gpl; + variant = full; + packages = { inherit frei0r; }; + description = "Frei0r video filtering"; + }; + fribidi = { + variant = full; + packages = { inherit fribidi; }; + flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; + }; + gme = { + variant = full; + packages = { inherit game-music-emu; }; + flagPrefix = "lib"; + description = "Game Music Emulator"; + }; + gnutls = { packages = { inherit gnutls; }; }; + gsm = { + variant = full; + packages = { inherit gsm; }; + flagPrefix = "lib"; + }; + harfbuzz = { + version = "6.1"; + packages = { inherit harfbuzz; }; + flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; + }; + iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? + jack = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libjack2; }; + flagPrefix = "lib"; + }; + jxl = { + variant = full; + version = "5"; + packages = { inherit libjxl; }; + flagPrefix = "lib"; + }; + ladspa = { + variant = full; + packages = { inherit ladspaH; }; + description = "LADSPA audio filtering"; + }; + lzma = { packages = { inherit xz; }; }; + mfx = { + gate = with stdenv.hostPlatform; isLinux && !isAarch; + variant = full; + packages = { inherit intel-media-sdk; }; + flagPrefix = "lib"; + description = "Hardware acceleration via intel-media-sdk/libmfx (incompatible with {option}`vpl`)"; + }; + modplug = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libmodplug; }; + flagPrefix = "lib"; + }; + mp3lame = { + packages = { inherit lame; }; + flagPrefix = "lib"; + }; + mysofa = { + variant = full; + packages = { inherit libmysofa; }; + flagPrefix = "lib"; + description = "HRTF support via SOFAlizer"; + }; + nvdec = { + inherit (config.nvcodec) gate; + }; + nvenc = { + inherit (config.nvcodec) gate; + }; + ogg = { + packages = { inherit libogg; }; + flags = [ ]; # There is no flag for OGG?! + description = "Ogg container used by vorbis & theora"; + }; + openal = { + variant = full; + packages = { inherit openal; }; + description = "OpenAL 1.1 capture support"; + }; + opencl = { + variant = full; + packages = { inherit ocl-icd opencl-headers; }; + }; + opencore-amr = { + gate = enable.gplv3; + variant = full; + packages = { inherit opencore-amr; }; + flags = [ "libopencore-amrnb" "libopencore-amrwb" ]; + }; + opengl = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libGL libGLU; }; + description = "OpenGL rendering"; + }; + openh264 = { + variant = full; + packages = { inherit openh264; }; + flagPrefix = "lib"; + }; + openjpeg = { + variant = full; + packages = { inherit openjpeg; }; + flagPrefix = "lib"; + }; + openmpt = { + variant = full; + packages = { inherit libopenmpt; }; + flagPrefix = "lib"; + description = "Tracked music files decoder"; + }; + opus = { + packages = { inherit libopus; }; + flagPrefix = "lib"; + }; + placebo = { + gate = !stdenv.isDarwin; + variant = full; + packages = { + inherit vulkan-headers; + libplacebo = + if lib.versionAtLeast version "6.1" + then libplacebo + else libplacebo_5; + }; + flagPrefix = "lib"; + description = "libplacebo video processing library"; + }; + pulse = { + gate = stdenv.isLinux; + variant = small; + packages = { inherit libpulseaudio; }; + flagPrefix = "lib"; + description = "Pulseaudio input support"; + }; + qrencode = { + variant = full; + version = "7"; + packages = { inherit qrencode; }; + flagPrefix = "lib"; + description = "QR encode generation"; + }; + quirc = { + variant = full; + version = "7"; + packages = { inherit quirc; }; + flagPrefix = "lib"; + description = "QR decoding"; + }; + rav1e = { + variant = full; + packages = { inherit rav1e; }; + flagPrefix = "lib"; + description = "AV1 encoder (focused on speed and safety)"; + }; + rtmp = { + variant = full; + packages = { inherit rtmpdump; }; + flagPrefix = "lib"; + }; + samba = { + variant = full; + packages = { inherit samba; }; + flags = [ "libsmbclient" ]; + }; + sdl2 = { + variant = small; + packages = { inherit SDL2; }; + }; + shaderc = { + gate = !stdenv.isDarwin; + variant = full; + version = "5"; + packages = { inherit shaderc; }; + flagPrefix = "lib"; + }; + soxr = { + packages = { inherit soxr; }; + flagPrefix = "lib"; + description = "Resampling via soxr"; + }; + speex = { + packages = { inherit speex; }; + flagPrefix = "lib"; + }; + srt = { + packages = { inherit srt; }; + flagPrefix = "lib"; + description = "Secure Reliable Transport (SRT) protocol"; + }; + ssh = { + packages = { inherit libssh; }; + flagPrefix = "lib"; + description = "SFTP protocol"; + }; + svg = { + variant = full; + packages = { inherit librsvg; }; + flags = [ "librsvg" ]; + }; + svtav1 = { + gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; + packages = { inherit svt-av1; }; + flagPrefix = "lib"; + description = "AV1 encoder/decoder (focused on speed and correctness)"; + }; + tensorflow = { + gate = false; # Increases closure size by ~390 MiB and is rather specialised purpose + packages = { inherit libtensorflow; }; + flagPrefix = "lib"; + description = "Tensorflow dnn backend support"; + }; + theora = { + packages = { inherit libtheora; }; + flagPrefix = "lib"; + }; + v4l2 = { + gate = stdenv.isLinux; + packages = { inherit libv4l; }; + flags = [ "libv4l2" "v4l2-m2m" ]; + description = "Video 4 Linux"; + }; + vaapi = { + gate = with stdenv; isLinux || isFreeBSD; + packages = { + libva = if ffmpegVariant == headless then libva-minimal else libva; + }; + description = "Vaapi hardware acceleration"; + }; + vdpau = { + gate = !stdenv.hostPlatform.isMinGW; + variant = small; + packages = { inherit libvdpau; }; + description = "Vdpau hardware acceleration"; + }; + videotoolbox = { + gate = stdenv.isDarwin; + packages = { inherit VideoToolbox; }; + }; + vidstab = { + gate = enable.gpl; + variant = full; + packages = { inherit vid-stab; }; + flagPrefix = "lib"; + description = "Video stabilization"; + }; + vmaf = { + gate = !stdenv.isAarch64; + variant = full; + version = "5"; + packages = { inherit libvmaf; }; + flagPrefix = "lib"; + description = "Netflix's VMAF (Video Multi-Method Assessment Fusion)"; + }; + vo-amrwbenc = { + gate = enable.gplv3; + variant = full; + packages = { inherit vo-amrwbenc; }; + flagPrefix = "lib"; + }; + vorbis = { + packages = { inherit libvorbis; }; + flagPrefix = "lib"; + description = "Vorbis de/encoding, native encoder exists"; # TODO shouldn't we be using it then? + }; + vpl = { + # It is currently unclear whether this breaks support for old GPUs. See + # https://github.com/NixOS/nixpkgs/issues/303074 + gate = false; + packages = { inherit libvpl; }; + flagPrefix = "lib"; + description = "Hardware acceleration via intel libvpl (incompatible with {option}`mfx`)"; + }; + vpx = { + gate = stdenv.buildPlatform == stdenv.hostPlatform; + packages = { inherit libvpx; }; + flagPrefix = "lib"; + description = "VP8 & VP9 de/encoding"; + }; + vulkan = { + gate = !stdenv.isDarwin; + variant = small; + packages = { inherit vulkan-headers vulkan-loader; }; }; + webp = { + variant = full; + packages = { inherit libwebp; }; + flagPrefix = "lib"; + }; + x264 = { + gate = enable.gpl; + packages = { inherit x264; }; + flagPrefix = "lib"; + }; + x265 = { + gate = enable.gpl; + packages = { inherit x265; }; + flagPrefix = "lib"; + }; + xavs = { + gate = enable.gpl; + variant = full; + packages = { inherit xavs; }; + flagPrefix = "lib"; + }; + xcb = { + gate = with enable; xcb-shape || xcb-shm || xcb-xfixes; + packages = { inherit libxcb; }; + flagPrefix = "lib"; + description = "X11 grabbing using XCB"; + }; + xcb-shape = { + variant = full; + flagPrefix = "lib"; + description = "X11 grabbing shape rendering"; + }; + xcb-shm = { + variant = full; + flagPrefix = "lib"; + description = "X11 grabbing shm communication"; + }; + xcb-xfixes = { + variant = full; + flagPrefix = "lib"; + description = "X11 grabbing mouse rendering"; + }; + xevd = { + gate = stdenv.hostPlatform.isx86; + variant = full; + version = "7"; + packages = { inherit xevd; }; + flagPrefix = "lib"; + description = "MPEG-5 EVC decoding"; + }; + xeve = { + gate = stdenv.hostPlatform.isx86; + variant = full; + version = "7"; + packages = { inherit xeve; }; + flagPrefix = "lib"; + description = "MPEG-5 EVC encoding"; + }; + xlib = { + variant = full; + packages = { inherit libX11 libXv libXext; }; + }; + xml2 = { + variant = full; + packages = { inherit libxml2; }; + flagPrefix = "lib"; + description = "libxml2 support, for IMF and DASH demuxers"; + }; + xvid = { + gate = enable.gpl; + packages = { inherit xvidcore; }; + flagPrefix = "lib"; + description = "Xvid encoder, native encoder exists"; # TODO shouldn't we be using it then? + }; + zimg = { + packages = { inherit zimg; }; + flagPrefix = "lib"; + }; + zlib = { packages = { inherit zlib; }; }; + zmq = { + variant = full; + packages = { inherit zeromq4; }; + flagPrefix = "lib"; + description = "Message passing"; + }; + }; + in + { + options = { + features = lib.mapAttrs mkFfmpegOption (featureOptions (config.features)); + }; + }; + eval = lib.evalModules { modules = [ - ./options.nix + module configuration { - _module.args = { - inherit stdenv pkgs version variants; - variant = ffmpegVariant; - }; + _module.args = { variant = ffmpegVariant; }; } ]; }; @@ -228,11 +953,9 @@ let withVersion3 = features.version3.enable; withGPLv3 = features.gplv3.enable; withUnfree = features.unfree.enable; - in - -assert lib.elem ffmpegVariant [ "headless" "small" "full" ]; +assert builtins.hasAttr ffmpegVariant variants; /* * Licensing dependencies @@ -440,9 +1163,8 @@ stdenv.mkDerivation (finalAttrs: { enableParallelBuilding = true; passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; - passthru.config = config; - passthru.options = eval.options; passthru.variants = variants; + passthru.eval = eval; meta = with lib; { description = "A complete, cross-platform solution to record, convert and stream audio and video"; From 726b8b5d9178a35779f29195bce8ec849d3e944a Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 13:18:27 +0200 Subject: [PATCH 17/28] get rid of with aliases --- pkgs/development/libraries/ffmpeg/generic.nix | 236 +++++++----------- 1 file changed, 93 insertions(+), 143 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index abb59527e73c0..2c8258374f836 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -11,64 +11,11 @@ } , ffmpegVariant ? "small" # Decides which dependencies are enabled by default -, withHeadlessDeps ? ffmpegVariant == "headless" || withSmallDeps -, withSmallDeps ? ffmpegVariant == "small" || withFullDeps -, withFullDeps ? ffmpegVariant == "full" , fetchgit , fetchpatch2 - -/* - * Build options - */ -, withPixelutils ? withHeadlessDeps # Pixel utils in libavutil - -/* - * Program options - */ -, buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable -, buildFfplay ? withSmallDeps # Build ffplay executable -, buildFfprobe ? withHeadlessDeps # Build ffprobe executable -, buildQtFaststart ? withFullDeps # Build qt-faststart executable # TODO -, withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart # TODO -/* - * Library options - */ -, buildAvcodec ? withHeadlessDeps # Build avcodec library -, buildAvdevice ? withHeadlessDeps # Build avdevice library -, buildAvfilter ? withHeadlessDeps # Build avfilter library -, buildAvformat ? withHeadlessDeps # Build avformat library -# Deprecated but depended upon by some packages. -# https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991) -, buildAvresample ? withHeadlessDeps && lib.versionOlder version "5" # Build avresample library -, buildAvutil ? withHeadlessDeps # Build avutil library -, buildPostproc ? withHeadlessDeps # Build postproc library -, buildSwresample ? withHeadlessDeps # Build swresample library -, buildSwscale ? withHeadlessDeps # Build swscale library -, withLib ? buildAvcodec # TODO - || buildAvdevice - || buildAvfilter - || buildAvformat - || buildAvutil - || buildPostproc - || buildSwresample - || buildSwscale -/* - * Documentation options - */ -, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc # TODO -, withHtmlDoc ? withHeadlessDeps # HTML documentation pages -, withManPages ? withHeadlessDeps # Man documentation pages -, withPodDoc ? withHeadlessDeps # POD documentation pages -, withTxtDoc ? withHeadlessDeps # Text documentation pages -# Whether a "doc" output will be produced. Note that withManPages does not produce -# a "doc" output because its files go to "man". -, withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc) # TODO - -/* - * External libraries options - */ + # Feature inputs , alsa-lib , avisynthplus , bzip2 @@ -356,18 +303,33 @@ let }; network = { }; - pixelutils = { }; + pixelutils = { + description = "Pixel utils in libavutil"; + }; # Program flags - ffmpeg = { }; - ffplay = { variant = small; }; - ffprobe = { }; + ffmpeg = { + description = "Build ffmpeg executable"; + }; + ffplay = { + variant = small; + description = "Build ffplay executable"; + }; + ffprobe = { + description = "Build ffprobe executable"; + }; + qt-faststart = { + description = "Build qt-faststart executable"; + flags = [ ]; # Does not have a flag, needs its dir to be passed to make manually + }; # Library flags avcodec = { }; avdevice = { }; avfilter = { }; avformat = { }; + # Deprecated but depended upon by some packages. + # https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991 avresample = { # Ffmpeg > 4 doesn't know about the flag anymore versionMax = "5"; @@ -379,7 +341,9 @@ let swscale = { }; # Documentation flags - doc = { }; + doc = { + gate = with enable; htmlpages || manpages || podpages || txtpages; + }; htmlpages = { }; manpages = { }; podpages = { }; @@ -937,63 +901,45 @@ let }; inherit (eval) config; inherit (config) features; + enable = lib.mapAttrs (n: v: v.enable) features; - # Feature flags - withCuda = features.cuda.enable; - withCudaLLVM = features.cuda-llvm.enable; - withCuvid = features.cuvid.enable; - withNvcodec = features.nvcodec.enable; - withFrei0r = features.frei0r.enable; - withMfx = features.mfx.enable; - withNvdec = features.nvdec.enable; - withNvenc = features.nvenc.enable; - withVpl = features.vpl.enable; - withVulkan = features.vulkan.enable; - withGPL = features.gpl.enable; - withVersion3 = features.version3.enable; - withGPLv3 = features.gplv3.enable; - withUnfree = features.unfree.enable; + withLib = + with enable; + avcodec + || avdevice + || avfilter + || avformat + || avutil + || postproc + || swresample + || swscale; + withBin = with enable; ffmpeg || ffplay || ffprobe || qt-faststart; + # Whether a "doc" output will be produced. Note that manpages does not produce + # a "doc" output because its files go to "man". + withDoc = with enable; doc && (htmlpages || podpages || txtpages); in assert builtins.hasAttr ffmpegVariant variants; -/* - * Licensing dependencies - */ -assert withGPLv3 -> withGPL && withVersion3; +# Licensing dependencies +assert with enable; gplv3 -> gpl && version3; -/* - * Build dependencies - */ -assert withPixelutils -> buildAvutil; -assert !(withMfx && withVpl); # incompatible features -/* - * Program dependencies - */ -assert buildFfmpeg -> buildAvcodec - && buildAvfilter - && buildAvformat - && (buildSwresample || buildAvresample); -assert buildFfplay -> buildAvcodec - && buildAvformat - && buildSwscale - && (buildSwresample || buildAvresample); -assert buildFfprobe -> buildAvcodec && buildAvformat; -/* - * Library dependencies - */ -assert buildAvcodec -> buildAvutil; # configure flag since 0.6 -assert buildAvdevice -> buildAvformat - && buildAvcodec - && buildAvutil; # configure flag since 0.6 -assert buildAvformat -> buildAvcodec && buildAvutil; # configure flag since 0.6 -assert buildPostproc -> buildAvutil; -assert buildSwscale -> buildAvutil; +# Build dependencies +assert with enable; pixelutils -> avutil; +assert with enable; !(mfx && vpl); # incompatible features +# Program dependencies +assert with enable; ffmpeg -> avcodec && avfilter && avformat && (swresample || avresample); +assert with enable; ffplay -> avcodec && avformat && swscale && (swresample || avresample); +assert with enable; ffprobe -> avcodec && avformat; +# Library dependencies +assert with enable; avcodec -> avutil; # configure flag since 0.6 +assert with enable; avdevice -> avformat && avcodec && avutil; # configure flag since 0.6 +assert with enable; avformat -> avcodec && avutil; # configure flag since 0.6 +assert with enable; postproc -> avutil; +assert with enable; swscale -> avutil; -/* - * External Library dependencies - */ -assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; +# External Library dependencies +assert with enable; (cuda || cuvid || nvdec || nvenc) -> nvcodec; stdenv.mkDerivation (finalAttrs: { pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); @@ -1002,7 +948,7 @@ stdenv.mkDerivation (finalAttrs: { postPatch = '' patchShebangs . - '' + lib.optionalString withFrei0r '' + '' + lib.optionalString enable.frei0r '' substituteInPlace libavfilter/vf_frei0r.c \ --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 substituteInPlace doc/filters.texi \ @@ -1077,7 +1023,7 @@ stdenv.mkDerivation (finalAttrs: { ] ++ optionals withLib [ "--libdir=${placeholder "lib"}/lib" "--incdir=${placeholder "dev"}/include" - ] ++ optionals withManPages [ + ] ++ optionals enable.manpages [ "--mandir=${placeholder "man"}/share/man" ] ++ optionals withDoc [ "--docdir=${placeholder "doc"}/share/doc/ffmpeg" @@ -1107,7 +1053,7 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; nativeBuildInputs = [ removeReferencesTo addOpenGLRunpath perl pkg-config texinfo yasm ] - ++ optionals withCudaLLVM [ clang ]; + ++ optionals enable.cuda-llvm [ clang ]; buildInputs = lib.pipe eval.config.features [ (lib.filterAttrs (n: v: v.enable && lib.versionAtLeast version v.version && lib.versionOlder version v.versionMax)) @@ -1116,7 +1062,7 @@ stdenv.mkDerivation (finalAttrs: { ]; buildFlags = [ "all" ] - ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable + ++ optional enable.qt-faststart "tools/qt-faststart"; # Build qt-faststart executable doCheck = stdenv.hostPlatform == stdenv.buildPlatform; @@ -1124,15 +1070,15 @@ stdenv.mkDerivation (finalAttrs: { checkPhase = let ldLibraryPathEnv = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; libsToLink = [ ] - ++ optional buildAvcodec "libavcodec" - ++ optional buildAvdevice "libavdevice" - ++ optional buildAvfilter "libavfilter" - ++ optional buildAvformat "libavformat" - ++ optional buildAvresample "libavresample" - ++ optional buildAvutil "libavutil" - ++ optional buildPostproc "libpostproc" - ++ optional buildSwresample "libswresample" - ++ optional buildSwscale "libswscale" + ++ optional enable.avcodec "libavcodec" + ++ optional enable.avdevice "libavdevice" + ++ optional enable.avfilter "libavfilter" + ++ optional enable.avformat "libavformat" + ++ optional enable.avresample "libavresample" + ++ optional enable.avutil "libavutil" + ++ optional enable.postproc "libpostproc" + ++ optional enable.swresample "libswresample" + ++ optional enable.swscale "libswscale" ; in '' ${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES @@ -1141,11 +1087,11 @@ stdenv.mkDerivation (finalAttrs: { outputs = optionals withBin [ "bin" ] # The first output is the one that gets symlinked by default! ++ optionals withLib [ "lib" "dev" ] ++ optionals withDoc [ "doc" ] - ++ optionals withManPages [ "man" ] + ++ optionals enable.manpages [ "man" ] ++ [ "data" "out" ] # We need an "out" output because we get an error otherwise. It's just an empty dir. ; - postInstall = optionalString buildQtFaststart '' + postInstall = optionalString enable.qt-faststart '' install -D tools/qt-faststart -t $bin/bin ''; @@ -1156,7 +1102,7 @@ stdenv.mkDerivation (finalAttrs: { addOpenGLRunpath ${placeholder "lib"}/lib/libavutil.so '' # https://trac.ffmpeg.org/ticket/10809 - + optionalString (versionAtLeast version "5.0" && withVulkan && !stdenv.hostPlatform.isMinGW) '' + + optionalString (versionAtLeast version "5.0" && enable.vulkan && !stdenv.hostPlatform.isMinGW) '' patchelf $lib/lib/libavcodec.so --add-needed libvulkan.so --add-rpath ${lib.makeLibraryPath [ vulkan-loader ]} ''; @@ -1166,7 +1112,7 @@ stdenv.mkDerivation (finalAttrs: { passthru.variants = variants; passthru.eval = eval; - meta = with lib; { + meta = { description = "A complete, cross-platform solution to record, convert and stream audio and video"; homepage = "https://www.ffmpeg.org/"; changelog = "https://github.com/FFmpeg/FFmpeg/blob/n${version}/Changelog"; @@ -1177,26 +1123,30 @@ stdenv.mkDerivation (finalAttrs: { No matter if they were designed by some standards committee, the community or a corporation. ''; - license = with licenses; [ lgpl21Plus ] - ++ optional withGPL gpl2Plus - ++ optional withVersion3 lgpl3Plus - ++ optional withGPLv3 gpl3Plus - ++ optional withUnfree unfreeRedistributable - ++ optional (withGPL && withUnfree) unfree; + license = + let + l = lib.licenses; + in + [ l.lgpl21Plus ] + ++ optional enable.gpl l.gpl2Plus + ++ optional enable.version3 l.lgpl3Plus + ++ optional enable.gplv3 l.gpl3Plus + ++ optional enable.unfree l.unfreeRedistributable + ++ optional (enable.gpl && enable.unfree) l.unfree; pkgConfigModules = [ ] - ++ optional buildAvcodec "libavcodec" - ++ optional buildAvdevice "libavdevice" - ++ optional buildAvfilter "libavfilter" - ++ optional buildAvformat "libavformat" - ++ optional buildAvresample "libavresample" - ++ optional buildAvutil "libavutil" - ++ optional buildPostproc "libpostproc" - ++ optional buildSwresample "libswresample" - ++ optional buildSwscale "libswscale"; - platforms = platforms.all; + ++ optional enable.avcodec "libavcodec" + ++ optional enable.avdevice "libavdevice" + ++ optional enable.avfilter "libavfilter" + ++ optional enable.avformat "libavformat" + ++ optional enable.avresample "libavresample" + ++ optional enable.avutil "libavutil" + ++ optional enable.postproc "libpostproc" + ++ optional enable.swresample "libswresample" + ++ optional enable.swscale "libswscale"; + platforms = lib.platforms.all; # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; - maintainers = with maintainers; [ atemu arthsmn jopejoe1 ]; + maintainers = with lib.maintainers; [ atemu arthsmn jopejoe1 ]; mainProgram = "ffmpeg"; }; }) From 40259ce8cd3b05445ffad4f17436eb3dade07f7d Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 13:30:54 +0200 Subject: [PATCH 18/28] get rid of remaining with* variables --- pkgs/development/libraries/ffmpeg/generic.nix | 60 +++++++++++-------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 2c8258374f836..37001b89b6303 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -218,7 +218,7 @@ let flags = lib.mkOption { type = with lib.types; listOf str; - default = [ (config.flagPrefix + name) ]; + default = lib.optionals (!config.internal) [ (config.flagPrefix + name) ]; description = '' Flags to be passed to the configure script for this feature. ''; @@ -237,6 +237,10 @@ let default = null; readOnly = true; }; + + internal = lib.mkEnableOption "" // lib.mkOption { + description = "Whether this flag is internal and does not have a corresponding configureFlag"; + }; }; }); @@ -265,7 +269,7 @@ let }; gplv3 = { gate = enable.gpl && enable.version3; - flags = [ ]; # internal + internal = true; }; unfree = { enable = false; @@ -290,7 +294,7 @@ let hardcoded-tables = { }; safe-bitstream-reader = { }; - multithread = { flags = [ ]; }; + multithread = { internal = true; }; pthreads = { gate = enable.multithread && stdenv.hostPlatform.isUnix; }; @@ -320,7 +324,11 @@ let }; qt-faststart = { description = "Build qt-faststart executable"; - flags = [ ]; # Does not have a flag, needs its dir to be passed to make manually + internal = true; # Does not have a flag, needs its dir to be passed to make manually + }; + bin-output = { + gate = with enable; ffmpeg || ffplay || ffprobe || qt-faststart; + internal = true; }; # Library flags @@ -334,6 +342,12 @@ let # Ffmpeg > 4 doesn't know about the flag anymore versionMax = "5"; }; + lib-output = { + gate = + with enable; + avcodec || avdevice || avfilter || avformat || avutil || postproc || swresample || swscale; + internal = true; + }; avutil = { }; postproc = { gate = enable.gpl; }; @@ -348,6 +362,15 @@ let manpages = { }; podpages = { }; txtpages = { }; + doc-output = { + gate = with enable; doc && (htmlpages || podpages || txtpages); + description = '' + Whether a "doc" output will be produced. Note that + {option}`manpages` does not produce a "doc" output because its + files go to "man". + ''; + internal = true; + }; # Developer flags debug = { enable = false; }; @@ -902,21 +925,6 @@ let inherit (eval) config; inherit (config) features; enable = lib.mapAttrs (n: v: v.enable) features; - - withLib = - with enable; - avcodec - || avdevice - || avfilter - || avformat - || avutil - || postproc - || swresample - || swscale; - withBin = with enable; ffmpeg || ffplay || ffprobe || qt-faststart; - # Whether a "doc" output will be produced. Note that manpages does not produce - # a "doc" output because its files go to "man". - withDoc = with enable; doc && (htmlpages || podpages || txtpages); in assert builtins.hasAttr ffmpegVariant variants; @@ -1018,14 +1026,14 @@ stdenv.mkDerivation (finalAttrs: { "--pkg-config=${buildPackages.pkg-config.targetPrefix}pkg-config" "--datadir=${placeholder "data"}/share/ffmpeg" - ] ++ optionals withBin [ + ] ++ optionals enable.bin-output [ "--bindir=${placeholder "bin"}/bin" - ] ++ optionals withLib [ + ] ++ optionals enable.lib-output [ "--libdir=${placeholder "lib"}/lib" "--incdir=${placeholder "dev"}/include" ] ++ optionals enable.manpages [ "--mandir=${placeholder "man"}/share/man" - ] ++ optionals withDoc [ + ] ++ optionals enable.doc-output [ "--docdir=${placeholder "doc"}/share/doc/ffmpeg" ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "--cross-prefix=${stdenv.cc.targetPrefix}" @@ -1084,9 +1092,9 @@ stdenv.mkDerivation (finalAttrs: { ${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES ''; - outputs = optionals withBin [ "bin" ] # The first output is the one that gets symlinked by default! - ++ optionals withLib [ "lib" "dev" ] - ++ optionals withDoc [ "doc" ] + outputs = optionals enable.bin-output [ "bin" ] # The first output is the one that gets symlinked by default! + ++ optionals enable.lib-output [ "lib" "dev" ] + ++ optionals enable.doc-output [ "doc" ] ++ optionals enable.manpages [ "man" ] ++ [ "data" "out" ] # We need an "out" output because we get an error otherwise. It's just an empty dir. ; @@ -1097,7 +1105,7 @@ stdenv.mkDerivation (finalAttrs: { # Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found. # See the explanation in addOpenGLRunpath. - postFixup = optionalString (stdenv.isLinux && withLib) '' + postFixup = optionalString (stdenv.isLinux && enable.lib-output) '' addOpenGLRunpath ${placeholder "lib"}/lib/libavcodec.so addOpenGLRunpath ${placeholder "lib"}/lib/libavutil.so '' From 218ef87dae88b89e23e85541da910b4f6e54422b Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 13:49:45 +0200 Subject: [PATCH 19/28] small refactors --- pkgs/development/libraries/ffmpeg/generic.nix | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 37001b89b6303..f889d95282856 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -144,6 +144,8 @@ let inherit (lib) optional optionals optionalString versionOlder versionAtLeast; variants = lib.genAttrs [ "headless" "small" "full" ] lib.id; + inherit (variants) headless small full; + module = { config, @@ -161,12 +163,15 @@ let headless = ffmpegVariant == variants.headless || checks.small; }; in checks.${flagVariant} or false; + + # Represents a feature flag for ffmpeg. Each feature flag controls which + # packages should be added to buildInputs and which configureFlags should + # be set to enable the feature. It also offers easy controls to + # enable/disable features by default depending on the variant, version and + # custom logic. ffmpegFlag = lib.types.submodule ({ config, name, ... }: { options = { enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg." // lib.mkOption { - # TODO this works but doesn't allow for convenient overrides yet. You - # can easily override enable = true but it will still be gated behind - # the variant check. default = isInVariant config.variant && config.gate; }; packages = lib.mkOption { @@ -239,14 +244,17 @@ let }; internal = lib.mkEnableOption "" // lib.mkOption { - description = "Whether this flag is internal and does not have a corresponding configureFlag"; + description = '' + Whether this flag is an internal ffmpeg derivation implementation + detail and does not have a corresponding upstream configureFlag. + ''; }; }; }); mkFfmpegOption = name: default: lib.mkOption { type = ffmpegFlag; - inherit default; # Default done via ffmpegFlag type + inherit default; # Detailed defaults are implemented in the ffmpegFlag type description = let hasDescription = default.description or null != null; @@ -255,8 +263,7 @@ let "Control ${name} support in ffmpeg${additionalDescription}."; }; - inherit (variants) headless small full; - + # This is the source of truth for the default set of features activated in ffmpeg featureOptions = config: let enable = lib.mapAttrs (n: v: v.enable) config; @@ -272,15 +279,15 @@ let internal = true; }; unfree = { - enable = false; + gate = false; flags = [ "nonfree" ]; }; # Build flags static = { gate = stdenv.hostPlatform.isStatic; }; shared = { gate = !stdenv.hostPlatform.isStatic; }; pic = { }; - thumb = { enable = false; }; - small = { enable = false; }; + thumb = { gate = false; }; + small = { gate = false; }; runtime-cpudetect = { }; gray = { variant = full; }; swscale-alpha = { }; # TODO same as swscale? @@ -303,7 +310,7 @@ let }; os2threads = { # We don't support OS/2 - enable = false; + gate = false; }; network = { }; @@ -373,10 +380,10 @@ let }; # Developer flags - debug = { enable = false; }; + debug = { gate = false; }; optimizations = { }; - extra-warnings = { enable = false; }; - stripping = { enable = false; }; + extra-warnings = { gate = false; }; + stripping = { gate = false; }; # Feature flags alsa = { packages = { inherit alsa-lib; }; }; @@ -927,7 +934,10 @@ let enable = lib.mapAttrs (n: v: v.enable) features; in -assert builtins.hasAttr ffmpegVariant variants; +# Assertions to help the user reach a sane config + +# General +assert builtins.hasAttr ffmpegVariant variants; # We must know the ffmpeg variant # Licensing dependencies assert with enable; gplv3 -> gpl && version3; From 9ec60441dc196e0b9c5447a52be9f481be3323ec Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 14:13:11 +0200 Subject: [PATCH 20/28] refactor check env var You can simply pass it to make, no need for a custom checkPhase --- pkgs/development/libraries/ffmpeg/generic.nix | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index f889d95282856..8f02c25e4d78b 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -932,6 +932,19 @@ let inherit (eval) config; inherit (config) features; enable = lib.mapAttrs (n: v: v.enable) features; + + # All library .so files that this ffmpeg exposes + exposedLibNames = lib.concatMap (name: lib.optional (builtins.getAttr name enable) "lib${name}") [ + "avcodec" + "avdevice" + "avfilter" + "avformat" + "avresample" + "avutil" + "postproc" + "swresample" + "swscale" + ]; in # Assertions to help the user reach a sane config @@ -1085,22 +1098,11 @@ stdenv.mkDerivation (finalAttrs: { doCheck = stdenv.hostPlatform == stdenv.buildPlatform; # Fails with SIGABRT otherwise FIXME: Why? - checkPhase = let - ldLibraryPathEnv = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; - libsToLink = [ ] - ++ optional enable.avcodec "libavcodec" - ++ optional enable.avdevice "libavdevice" - ++ optional enable.avfilter "libavfilter" - ++ optional enable.avformat "libavformat" - ++ optional enable.avresample "libavresample" - ++ optional enable.avutil "libavutil" - ++ optional enable.postproc "libpostproc" - ++ optional enable.swresample "libswresample" - ++ optional enable.swscale "libswscale" - ; - in '' - ${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES - ''; + checkFlags = + let + ldEnvVar = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; + in + "${ldEnvVar}=${lib.concatStringsSep ":" exposedLibNames}"; outputs = optionals enable.bin-output [ "bin" ] # The first output is the one that gets symlinked by default! ++ optionals enable.lib-output [ "lib" "dev" ] @@ -1151,16 +1153,7 @@ stdenv.mkDerivation (finalAttrs: { ++ optional enable.gplv3 l.gpl3Plus ++ optional enable.unfree l.unfreeRedistributable ++ optional (enable.gpl && enable.unfree) l.unfree; - pkgConfigModules = [ ] - ++ optional enable.avcodec "libavcodec" - ++ optional enable.avdevice "libavdevice" - ++ optional enable.avfilter "libavfilter" - ++ optional enable.avformat "libavformat" - ++ optional enable.avresample "libavresample" - ++ optional enable.avutil "libavutil" - ++ optional enable.postproc "libpostproc" - ++ optional enable.swresample "libswresample" - ++ optional enable.swscale "libswscale"; + pkgConfigModules = exposedLibNames; platforms = lib.platforms.all; # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; From 297dd9260fe3618b1b1a3150200ae984a16c9a0f Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 14:19:41 +0200 Subject: [PATCH 21/28] fix formatting --- pkgs/development/libraries/ffmpeg/generic.nix | 1268 ++++++++--------- 1 file changed, 634 insertions(+), 634 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 8f02c25e4d78b..6b798c24e6a8d 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -268,651 +268,651 @@ let let enable = lib.mapAttrs (n: v: v.enable) config; in - { - # Licensing flags - gpl = { }; - version3 = { - description = "When {option}`gpl` is set this implies {option}`gplv3`. Otherwise the license is LGPLv3"; - }; - gplv3 = { - gate = enable.gpl && enable.version3; - internal = true; - }; - unfree = { - gate = false; - flags = [ "nonfree" ]; - }; - # Build flags - static = { gate = stdenv.hostPlatform.isStatic; }; - shared = { gate = !stdenv.hostPlatform.isStatic; }; - pic = { }; - thumb = { gate = false; }; - small = { gate = false; }; - runtime-cpudetect = { }; - gray = { variant = full; }; - swscale-alpha = { }; # TODO same as swscale? - hardcoded-tables = { }; - safe-bitstream-reader = { }; + { + # Licensing flags + gpl = { }; + version3 = { + description = "When {option}`gpl` is set this implies {option}`gplv3`. Otherwise the license is LGPLv3"; + }; + gplv3 = { + gate = enable.gpl && enable.version3; + internal = true; + }; + unfree = { + gate = false; + flags = [ "nonfree" ]; + }; + # Build flags + static = { gate = stdenv.hostPlatform.isStatic; }; + shared = { gate = !stdenv.hostPlatform.isStatic; }; + pic = { }; + thumb = { gate = false; }; + small = { gate = false; }; + runtime-cpudetect = { }; + gray = { variant = full; }; + swscale-alpha = { }; # TODO same as swscale? + hardcoded-tables = { }; + safe-bitstream-reader = { }; - small = { }; - runtime-cpudetect = { }; - gray = { }; - swscale-alpha = { }; - hardcoded-tables = { }; - safe-bitstream-reader = { }; + small = { }; + runtime-cpudetect = { }; + gray = { }; + swscale-alpha = { }; + hardcoded-tables = { }; + safe-bitstream-reader = { }; - multithread = { internal = true; }; - pthreads = { - gate = enable.multithread && stdenv.hostPlatform.isUnix; - }; - w32threads = { - gate = enable.multithread && stdenv.hostPlatform.isWindows; - }; - os2threads = { - # We don't support OS/2 - gate = false; - }; + multithread = { internal = true; }; + pthreads = { + gate = enable.multithread && stdenv.hostPlatform.isUnix; + }; + w32threads = { + gate = enable.multithread && stdenv.hostPlatform.isWindows; + }; + os2threads = { + # We don't support OS/2 + gate = false; + }; - network = { }; - pixelutils = { - description = "Pixel utils in libavutil"; - }; + network = { }; + pixelutils = { + description = "Pixel utils in libavutil"; + }; - # Program flags - ffmpeg = { - description = "Build ffmpeg executable"; - }; - ffplay = { - variant = small; - description = "Build ffplay executable"; - }; - ffprobe = { - description = "Build ffprobe executable"; - }; - qt-faststart = { - description = "Build qt-faststart executable"; - internal = true; # Does not have a flag, needs its dir to be passed to make manually - }; - bin-output = { - gate = with enable; ffmpeg || ffplay || ffprobe || qt-faststart; - internal = true; - }; + # Program flags + ffmpeg = { + description = "Build ffmpeg executable"; + }; + ffplay = { + variant = small; + description = "Build ffplay executable"; + }; + ffprobe = { + description = "Build ffprobe executable"; + }; + qt-faststart = { + description = "Build qt-faststart executable"; + internal = true; # Does not have a flag, needs its dir to be passed to make manually + }; + bin-output = { + gate = with enable; ffmpeg || ffplay || ffprobe || qt-faststart; + internal = true; + }; - # Library flags - avcodec = { }; - avdevice = { }; - avfilter = { }; - avformat = { }; - # Deprecated but depended upon by some packages. - # https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991 - avresample = { - # Ffmpeg > 4 doesn't know about the flag anymore - versionMax = "5"; - }; - lib-output = { - gate = - with enable; - avcodec || avdevice || avfilter || avformat || avutil || postproc || swresample || swscale; - internal = true; - }; + # Library flags + avcodec = { }; + avdevice = { }; + avfilter = { }; + avformat = { }; + # Deprecated but depended upon by some packages. + # https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991 + avresample = { + # Ffmpeg > 4 doesn't know about the flag anymore + versionMax = "5"; + }; + lib-output = { + gate = + with enable; + avcodec || avdevice || avfilter || avformat || avutil || postproc || swresample || swscale; + internal = true; + }; - avutil = { }; - postproc = { gate = enable.gpl; }; - swresample = { }; - swscale = { }; + avutil = { }; + postproc = { gate = enable.gpl; }; + swresample = { }; + swscale = { }; - # Documentation flags - doc = { - gate = with enable; htmlpages || manpages || podpages || txtpages; - }; - htmlpages = { }; - manpages = { }; - podpages = { }; - txtpages = { }; - doc-output = { - gate = with enable; doc && (htmlpages || podpages || txtpages); - description = '' - Whether a "doc" output will be produced. Note that - {option}`manpages` does not produce a "doc" output because its - files go to "man". - ''; - internal = true; - }; + # Documentation flags + doc = { + gate = with enable; htmlpages || manpages || podpages || txtpages; + }; + htmlpages = { }; + manpages = { }; + podpages = { }; + txtpages = { }; + doc-output = { + gate = with enable; doc && (htmlpages || podpages || txtpages); + description = '' + Whether a "doc" output will be produced. Note that + {option}`manpages` does not produce a "doc" output because its + files go to "man". + ''; + internal = true; + }; - # Developer flags - debug = { gate = false; }; - optimizations = { }; - extra-warnings = { gate = false; }; - stripping = { gate = false; }; + # Developer flags + debug = { gate = false; }; + optimizations = { }; + extra-warnings = { gate = false; }; + stripping = { gate = false; }; - # Feature flags - alsa = { packages = { inherit alsa-lib; }; }; - aom = { - variant = full; - packages = { inherit libaom; }; - flagPrefix = "lib"; - description = "AV1 reference encoder"; - }; - appkit = { - gate = stdenv.isDarwin; - packages = { inherit AppKit; }; - }; - aribcaption = { - variant = full; - packages = { inherit libaribcaption; }; - flagPrefix = "lib"; - description = "ARIB STD-B24 Caption Decoder/Renderer"; - }; - ass = { - gate = stdenv.hostPlatform == stdenv.buildPlatform; - packages = { inherit libass; }; - flagPrefix = "lib"; - description = "(Advanced) SubStation Alpha subtitle rendering"; - }; - audiotoolbox = { - gate = stdenv.isDarwin; - packages = { inherit AudioToolbox; }; - }; - avfoundation = { - gate = stdenv.isDarwin; - packages = { inherit AVFoundation; }; - }; - avisynth = { - variant = full; - packages = { inherit avisynthplus; }; - description = "AviSynth script processing"; - }; - bluray = { - variant = full; - packages = { inherit libbluray; }; - flagPrefix = "lib"; - }; - bs2b = { - variant = full; - packages = { inherit libbs2b; }; - flagPrefix = "lib"; - }; - bzlib = { packages = { inherit bzip2; }; }; - caca = { - variant = full; - packages = { inherit libcaca; }; - flagPrefix = "lib"; - description = "Textual display (ASCII art)"; - }; - celt = { - variant = full; - packages = { inherit celt; }; - flagPrefix = "lib"; - }; - chromaprint = { - variant = full; - packages = { inherit chromaprint; }; - description = "Audio fingerprinting"; - }; - codec2 = { - variant = full; - packages = { inherit codec2; }; - flagPrefix = "lib"; - }; - coreimage = { - gate = stdenv.isDarwin; - packages = { inherit CoreImage; }; - }; - cuda = { - inherit (config.nvcodec) gate; - variant = full; - }; - cuda-llvm = { - variant = full; - }; - cuvid = { - inherit (config.nvcodec) gate; - }; - dav1d = { - packages = { inherit dav1d; }; - flagPrefix = "lib"; - description = "AV1 decoder (focused on speed and correctness)"; - }; - dc1394 = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libdc1394 libraw1394; }; - flagPrefix = "lib"; - description = "IIDC-1394 grabbing (ieee 1394/Firewire)"; - }; - drm = { - gate = with stdenv; isLinux || isFreeBSD; - packages = { inherit libdrm; }; - flagPrefix = "lib"; - }; - dvdnav = { - gate = enable.gpl; - variant = full; - version = "7"; - packages = { inherit libdvdnav; }; - flagPrefix = "lib"; - description = "DVD demuxing"; - }; - dvdread = { - gate = enable.gpl; - variant = full; - version = "7"; - packages = { inherit libdvdread; }; - flagPrefix = "lib"; - description = "DVD demuxing"; - }; - fdk-aac = { - gate = with enable; !gpl || unfree; - variant = full; - packages = { inherit fdk_aac; }; - flagPrefix = "lib"; - description = "Fraunhofer FDK AAC de/encoder"; - }; - nvcodec = { - gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; - packages = { - nv-codec-headers = - if lib.versionAtLeast version "6" - then nv-codec-headers-12 - else nv-codec-headers; - }; - flagPrefix = "ff"; - description = "Dynamically linked Nvidia code"; - }; - flite = { - variant = full; - packages = { inherit flite; }; - flagPrefix = "lib"; - description = "Voice synthesis"; - }; - fontconfig = { - packages = { inherit fontconfig; }; - flags = [ "fontconfig" "libfontconfig" ]; - description = "Font support for i.e. the drawtext filter"; - }; - freetype = { - packages = { inherit freetype; }; - flagPrefix = "lib"; - description = "Font support for i.e. the drawtext filter"; - }; - frei0r = { - gate = enable.gpl; - variant = full; - packages = { inherit frei0r; }; - description = "Frei0r video filtering"; - }; - fribidi = { - variant = full; - packages = { inherit fribidi; }; - flagPrefix = "lib"; - description = "Font support for i.e. the drawtext filter"; - }; - gme = { - variant = full; - packages = { inherit game-music-emu; }; - flagPrefix = "lib"; - description = "Game Music Emulator"; - }; - gnutls = { packages = { inherit gnutls; }; }; - gsm = { - variant = full; - packages = { inherit gsm; }; - flagPrefix = "lib"; - }; - harfbuzz = { - version = "6.1"; - packages = { inherit harfbuzz; }; - flagPrefix = "lib"; - description = "Font support for i.e. the drawtext filter"; - }; - iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? - jack = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libjack2; }; - flagPrefix = "lib"; - }; - jxl = { - variant = full; - version = "5"; - packages = { inherit libjxl; }; - flagPrefix = "lib"; - }; - ladspa = { - variant = full; - packages = { inherit ladspaH; }; - description = "LADSPA audio filtering"; - }; - lzma = { packages = { inherit xz; }; }; - mfx = { - gate = with stdenv.hostPlatform; isLinux && !isAarch; - variant = full; - packages = { inherit intel-media-sdk; }; - flagPrefix = "lib"; - description = "Hardware acceleration via intel-media-sdk/libmfx (incompatible with {option}`vpl`)"; - }; - modplug = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libmodplug; }; - flagPrefix = "lib"; - }; - mp3lame = { - packages = { inherit lame; }; - flagPrefix = "lib"; - }; - mysofa = { - variant = full; - packages = { inherit libmysofa; }; - flagPrefix = "lib"; - description = "HRTF support via SOFAlizer"; - }; - nvdec = { - inherit (config.nvcodec) gate; - }; - nvenc = { - inherit (config.nvcodec) gate; - }; - ogg = { - packages = { inherit libogg; }; - flags = [ ]; # There is no flag for OGG?! - description = "Ogg container used by vorbis & theora"; - }; - openal = { - variant = full; - packages = { inherit openal; }; - description = "OpenAL 1.1 capture support"; - }; - opencl = { - variant = full; - packages = { inherit ocl-icd opencl-headers; }; - }; - opencore-amr = { - gate = enable.gplv3; - variant = full; - packages = { inherit opencore-amr; }; - flags = [ "libopencore-amrnb" "libopencore-amrwb" ]; - }; - opengl = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libGL libGLU; }; - description = "OpenGL rendering"; - }; - openh264 = { - variant = full; - packages = { inherit openh264; }; - flagPrefix = "lib"; - }; - openjpeg = { - variant = full; - packages = { inherit openjpeg; }; - flagPrefix = "lib"; - }; - openmpt = { - variant = full; - packages = { inherit libopenmpt; }; - flagPrefix = "lib"; - description = "Tracked music files decoder"; - }; - opus = { - packages = { inherit libopus; }; - flagPrefix = "lib"; - }; - placebo = { - gate = !stdenv.isDarwin; - variant = full; - packages = { - inherit vulkan-headers; - libplacebo = - if lib.versionAtLeast version "6.1" - then libplacebo - else libplacebo_5; - }; - flagPrefix = "lib"; - description = "libplacebo video processing library"; - }; - pulse = { - gate = stdenv.isLinux; - variant = small; - packages = { inherit libpulseaudio; }; - flagPrefix = "lib"; - description = "Pulseaudio input support"; - }; - qrencode = { - variant = full; - version = "7"; - packages = { inherit qrencode; }; - flagPrefix = "lib"; - description = "QR encode generation"; - }; - quirc = { - variant = full; - version = "7"; - packages = { inherit quirc; }; - flagPrefix = "lib"; - description = "QR decoding"; - }; - rav1e = { - variant = full; - packages = { inherit rav1e; }; - flagPrefix = "lib"; - description = "AV1 encoder (focused on speed and safety)"; - }; - rtmp = { - variant = full; - packages = { inherit rtmpdump; }; - flagPrefix = "lib"; - }; - samba = { - variant = full; - packages = { inherit samba; }; - flags = [ "libsmbclient" ]; - }; - sdl2 = { - variant = small; - packages = { inherit SDL2; }; - }; - shaderc = { - gate = !stdenv.isDarwin; - variant = full; - version = "5"; - packages = { inherit shaderc; }; - flagPrefix = "lib"; - }; - soxr = { - packages = { inherit soxr; }; - flagPrefix = "lib"; - description = "Resampling via soxr"; - }; - speex = { - packages = { inherit speex; }; - flagPrefix = "lib"; - }; - srt = { - packages = { inherit srt; }; - flagPrefix = "lib"; - description = "Secure Reliable Transport (SRT) protocol"; - }; - ssh = { - packages = { inherit libssh; }; - flagPrefix = "lib"; - description = "SFTP protocol"; - }; - svg = { - variant = full; - packages = { inherit librsvg; }; - flags = [ "librsvg" ]; - }; - svtav1 = { - gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; - packages = { inherit svt-av1; }; - flagPrefix = "lib"; - description = "AV1 encoder/decoder (focused on speed and correctness)"; - }; - tensorflow = { - gate = false; # Increases closure size by ~390 MiB and is rather specialised purpose - packages = { inherit libtensorflow; }; - flagPrefix = "lib"; - description = "Tensorflow dnn backend support"; - }; - theora = { - packages = { inherit libtheora; }; - flagPrefix = "lib"; - }; - v4l2 = { - gate = stdenv.isLinux; - packages = { inherit libv4l; }; - flags = [ "libv4l2" "v4l2-m2m" ]; - description = "Video 4 Linux"; - }; - vaapi = { - gate = with stdenv; isLinux || isFreeBSD; - packages = { - libva = if ffmpegVariant == headless then libva-minimal else libva; - }; - description = "Vaapi hardware acceleration"; - }; - vdpau = { - gate = !stdenv.hostPlatform.isMinGW; - variant = small; - packages = { inherit libvdpau; }; - description = "Vdpau hardware acceleration"; - }; - videotoolbox = { - gate = stdenv.isDarwin; - packages = { inherit VideoToolbox; }; - }; - vidstab = { - gate = enable.gpl; - variant = full; - packages = { inherit vid-stab; }; - flagPrefix = "lib"; - description = "Video stabilization"; - }; - vmaf = { - gate = !stdenv.isAarch64; - variant = full; - version = "5"; - packages = { inherit libvmaf; }; - flagPrefix = "lib"; - description = "Netflix's VMAF (Video Multi-Method Assessment Fusion)"; - }; - vo-amrwbenc = { - gate = enable.gplv3; - variant = full; - packages = { inherit vo-amrwbenc; }; - flagPrefix = "lib"; - }; - vorbis = { - packages = { inherit libvorbis; }; - flagPrefix = "lib"; - description = "Vorbis de/encoding, native encoder exists"; # TODO shouldn't we be using it then? - }; - vpl = { - # It is currently unclear whether this breaks support for old GPUs. See - # https://github.com/NixOS/nixpkgs/issues/303074 - gate = false; - packages = { inherit libvpl; }; - flagPrefix = "lib"; - description = "Hardware acceleration via intel libvpl (incompatible with {option}`mfx`)"; - }; - vpx = { - gate = stdenv.buildPlatform == stdenv.hostPlatform; - packages = { inherit libvpx; }; - flagPrefix = "lib"; - description = "VP8 & VP9 de/encoding"; - }; - vulkan = { - gate = !stdenv.isDarwin; - variant = small; - packages = { inherit vulkan-headers vulkan-loader; }; }; - webp = { - variant = full; - packages = { inherit libwebp; }; - flagPrefix = "lib"; - }; - x264 = { - gate = enable.gpl; - packages = { inherit x264; }; - flagPrefix = "lib"; - }; - x265 = { - gate = enable.gpl; - packages = { inherit x265; }; - flagPrefix = "lib"; - }; - xavs = { - gate = enable.gpl; - variant = full; - packages = { inherit xavs; }; - flagPrefix = "lib"; - }; - xcb = { - gate = with enable; xcb-shape || xcb-shm || xcb-xfixes; - packages = { inherit libxcb; }; - flagPrefix = "lib"; - description = "X11 grabbing using XCB"; - }; - xcb-shape = { - variant = full; - flagPrefix = "lib"; - description = "X11 grabbing shape rendering"; - }; - xcb-shm = { - variant = full; - flagPrefix = "lib"; - description = "X11 grabbing shm communication"; - }; - xcb-xfixes = { - variant = full; - flagPrefix = "lib"; - description = "X11 grabbing mouse rendering"; - }; - xevd = { - gate = stdenv.hostPlatform.isx86; - variant = full; - version = "7"; - packages = { inherit xevd; }; - flagPrefix = "lib"; - description = "MPEG-5 EVC decoding"; - }; - xeve = { - gate = stdenv.hostPlatform.isx86; - variant = full; - version = "7"; - packages = { inherit xeve; }; - flagPrefix = "lib"; - description = "MPEG-5 EVC encoding"; - }; - xlib = { - variant = full; - packages = { inherit libX11 libXv libXext; }; - }; - xml2 = { - variant = full; - packages = { inherit libxml2; }; - flagPrefix = "lib"; - description = "libxml2 support, for IMF and DASH demuxers"; - }; - xvid = { - gate = enable.gpl; - packages = { inherit xvidcore; }; - flagPrefix = "lib"; - description = "Xvid encoder, native encoder exists"; # TODO shouldn't we be using it then? - }; - zimg = { - packages = { inherit zimg; }; - flagPrefix = "lib"; - }; - zlib = { packages = { inherit zlib; }; }; - zmq = { - variant = full; - packages = { inherit zeromq4; }; - flagPrefix = "lib"; - description = "Message passing"; + # Feature flags + alsa = { packages = { inherit alsa-lib; }; }; + aom = { + variant = full; + packages = { inherit libaom; }; + flagPrefix = "lib"; + description = "AV1 reference encoder"; + }; + appkit = { + gate = stdenv.isDarwin; + packages = { inherit AppKit; }; + }; + aribcaption = { + variant = full; + packages = { inherit libaribcaption; }; + flagPrefix = "lib"; + description = "ARIB STD-B24 Caption Decoder/Renderer"; + }; + ass = { + gate = stdenv.hostPlatform == stdenv.buildPlatform; + packages = { inherit libass; }; + flagPrefix = "lib"; + description = "(Advanced) SubStation Alpha subtitle rendering"; + }; + audiotoolbox = { + gate = stdenv.isDarwin; + packages = { inherit AudioToolbox; }; + }; + avfoundation = { + gate = stdenv.isDarwin; + packages = { inherit AVFoundation; }; + }; + avisynth = { + variant = full; + packages = { inherit avisynthplus; }; + description = "AviSynth script processing"; + }; + bluray = { + variant = full; + packages = { inherit libbluray; }; + flagPrefix = "lib"; + }; + bs2b = { + variant = full; + packages = { inherit libbs2b; }; + flagPrefix = "lib"; + }; + bzlib = { packages = { inherit bzip2; }; }; + caca = { + variant = full; + packages = { inherit libcaca; }; + flagPrefix = "lib"; + description = "Textual display (ASCII art)"; + }; + celt = { + variant = full; + packages = { inherit celt; }; + flagPrefix = "lib"; + }; + chromaprint = { + variant = full; + packages = { inherit chromaprint; }; + description = "Audio fingerprinting"; + }; + codec2 = { + variant = full; + packages = { inherit codec2; }; + flagPrefix = "lib"; + }; + coreimage = { + gate = stdenv.isDarwin; + packages = { inherit CoreImage; }; + }; + cuda = { + inherit (config.nvcodec) gate; + variant = full; + }; + cuda-llvm = { + variant = full; + }; + cuvid = { + inherit (config.nvcodec) gate; + }; + dav1d = { + packages = { inherit dav1d; }; + flagPrefix = "lib"; + description = "AV1 decoder (focused on speed and correctness)"; + }; + dc1394 = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libdc1394 libraw1394; }; + flagPrefix = "lib"; + description = "IIDC-1394 grabbing (ieee 1394/Firewire)"; + }; + drm = { + gate = with stdenv; isLinux || isFreeBSD; + packages = { inherit libdrm; }; + flagPrefix = "lib"; + }; + dvdnav = { + gate = enable.gpl; + variant = full; + version = "7"; + packages = { inherit libdvdnav; }; + flagPrefix = "lib"; + description = "DVD demuxing"; + }; + dvdread = { + gate = enable.gpl; + variant = full; + version = "7"; + packages = { inherit libdvdread; }; + flagPrefix = "lib"; + description = "DVD demuxing"; + }; + fdk-aac = { + gate = with enable; !gpl || unfree; + variant = full; + packages = { inherit fdk_aac; }; + flagPrefix = "lib"; + description = "Fraunhofer FDK AAC de/encoder"; + }; + nvcodec = { + gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; + packages = { + nv-codec-headers = + if lib.versionAtLeast version "6" + then nv-codec-headers-12 + else nv-codec-headers; + }; + flagPrefix = "ff"; + description = "Dynamically linked Nvidia code"; + }; + flite = { + variant = full; + packages = { inherit flite; }; + flagPrefix = "lib"; + description = "Voice synthesis"; + }; + fontconfig = { + packages = { inherit fontconfig; }; + flags = [ "fontconfig" "libfontconfig" ]; + description = "Font support for i.e. the drawtext filter"; + }; + freetype = { + packages = { inherit freetype; }; + flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; + }; + frei0r = { + gate = enable.gpl; + variant = full; + packages = { inherit frei0r; }; + description = "Frei0r video filtering"; + }; + fribidi = { + variant = full; + packages = { inherit fribidi; }; + flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; + }; + gme = { + variant = full; + packages = { inherit game-music-emu; }; + flagPrefix = "lib"; + description = "Game Music Emulator"; + }; + gnutls = { packages = { inherit gnutls; }; }; + gsm = { + variant = full; + packages = { inherit gsm; }; + flagPrefix = "lib"; + }; + harfbuzz = { + version = "6.1"; + packages = { inherit harfbuzz; }; + flagPrefix = "lib"; + description = "Font support for i.e. the drawtext filter"; + }; + iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? + jack = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libjack2; }; + flagPrefix = "lib"; + }; + jxl = { + variant = full; + version = "5"; + packages = { inherit libjxl; }; + flagPrefix = "lib"; + }; + ladspa = { + variant = full; + packages = { inherit ladspaH; }; + description = "LADSPA audio filtering"; + }; + lzma = { packages = { inherit xz; }; }; + mfx = { + gate = with stdenv.hostPlatform; isLinux && !isAarch; + variant = full; + packages = { inherit intel-media-sdk; }; + flagPrefix = "lib"; + description = "Hardware acceleration via intel-media-sdk/libmfx (incompatible with {option}`vpl`)"; + }; + modplug = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libmodplug; }; + flagPrefix = "lib"; + }; + mp3lame = { + packages = { inherit lame; }; + flagPrefix = "lib"; + }; + mysofa = { + variant = full; + packages = { inherit libmysofa; }; + flagPrefix = "lib"; + description = "HRTF support via SOFAlizer"; + }; + nvdec = { + inherit (config.nvcodec) gate; + }; + nvenc = { + inherit (config.nvcodec) gate; + }; + ogg = { + packages = { inherit libogg; }; + flags = [ ]; # There is no flag for OGG?! + description = "Ogg container used by vorbis & theora"; + }; + openal = { + variant = full; + packages = { inherit openal; }; + description = "OpenAL 1.1 capture support"; + }; + opencl = { + variant = full; + packages = { inherit ocl-icd opencl-headers; }; + }; + opencore-amr = { + gate = enable.gplv3; + variant = full; + packages = { inherit opencore-amr; }; + flags = [ "libopencore-amrnb" "libopencore-amrwb" ]; + }; + opengl = { + gate = !stdenv.isDarwin; + variant = full; + packages = { inherit libGL libGLU; }; + description = "OpenGL rendering"; + }; + openh264 = { + variant = full; + packages = { inherit openh264; }; + flagPrefix = "lib"; + }; + openjpeg = { + variant = full; + packages = { inherit openjpeg; }; + flagPrefix = "lib"; + }; + openmpt = { + variant = full; + packages = { inherit libopenmpt; }; + flagPrefix = "lib"; + description = "Tracked music files decoder"; + }; + opus = { + packages = { inherit libopus; }; + flagPrefix = "lib"; + }; + placebo = { + gate = !stdenv.isDarwin; + variant = full; + packages = { + inherit vulkan-headers; + libplacebo = + if lib.versionAtLeast version "6.1" + then libplacebo + else libplacebo_5; + }; + flagPrefix = "lib"; + description = "libplacebo video processing library"; + }; + pulse = { + gate = stdenv.isLinux; + variant = small; + packages = { inherit libpulseaudio; }; + flagPrefix = "lib"; + description = "Pulseaudio input support"; + }; + qrencode = { + variant = full; + version = "7"; + packages = { inherit qrencode; }; + flagPrefix = "lib"; + description = "QR encode generation"; + }; + quirc = { + variant = full; + version = "7"; + packages = { inherit quirc; }; + flagPrefix = "lib"; + description = "QR decoding"; + }; + rav1e = { + variant = full; + packages = { inherit rav1e; }; + flagPrefix = "lib"; + description = "AV1 encoder (focused on speed and safety)"; + }; + rtmp = { + variant = full; + packages = { inherit rtmpdump; }; + flagPrefix = "lib"; + }; + samba = { + variant = full; + packages = { inherit samba; }; + flags = [ "libsmbclient" ]; + }; + sdl2 = { + variant = small; + packages = { inherit SDL2; }; + }; + shaderc = { + gate = !stdenv.isDarwin; + variant = full; + version = "5"; + packages = { inherit shaderc; }; + flagPrefix = "lib"; + }; + soxr = { + packages = { inherit soxr; }; + flagPrefix = "lib"; + description = "Resampling via soxr"; + }; + speex = { + packages = { inherit speex; }; + flagPrefix = "lib"; + }; + srt = { + packages = { inherit srt; }; + flagPrefix = "lib"; + description = "Secure Reliable Transport (SRT) protocol"; + }; + ssh = { + packages = { inherit libssh; }; + flagPrefix = "lib"; + description = "SFTP protocol"; + }; + svg = { + variant = full; + packages = { inherit librsvg; }; + flags = [ "librsvg" ]; + }; + svtav1 = { + gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; + packages = { inherit svt-av1; }; + flagPrefix = "lib"; + description = "AV1 encoder/decoder (focused on speed and correctness)"; + }; + tensorflow = { + gate = false; # Increases closure size by ~390 MiB and is rather specialised purpose + packages = { inherit libtensorflow; }; + flagPrefix = "lib"; + description = "Tensorflow dnn backend support"; + }; + theora = { + packages = { inherit libtheora; }; + flagPrefix = "lib"; + }; + v4l2 = { + gate = stdenv.isLinux; + packages = { inherit libv4l; }; + flags = [ "libv4l2" "v4l2-m2m" ]; + description = "Video 4 Linux"; + }; + vaapi = { + gate = with stdenv; isLinux || isFreeBSD; + packages = { + libva = if ffmpegVariant == headless then libva-minimal else libva; }; + description = "Vaapi hardware acceleration"; + }; + vdpau = { + gate = !stdenv.hostPlatform.isMinGW; + variant = small; + packages = { inherit libvdpau; }; + description = "Vdpau hardware acceleration"; + }; + videotoolbox = { + gate = stdenv.isDarwin; + packages = { inherit VideoToolbox; }; + }; + vidstab = { + gate = enable.gpl; + variant = full; + packages = { inherit vid-stab; }; + flagPrefix = "lib"; + description = "Video stabilization"; + }; + vmaf = { + gate = !stdenv.isAarch64; + variant = full; + version = "5"; + packages = { inherit libvmaf; }; + flagPrefix = "lib"; + description = "Netflix's VMAF (Video Multi-Method Assessment Fusion)"; + }; + vo-amrwbenc = { + gate = enable.gplv3; + variant = full; + packages = { inherit vo-amrwbenc; }; + flagPrefix = "lib"; + }; + vorbis = { + packages = { inherit libvorbis; }; + flagPrefix = "lib"; + description = "Vorbis de/encoding, native encoder exists"; # TODO shouldn't we be using it then? + }; + vpl = { + # It is currently unclear whether this breaks support for old GPUs. See + # https://github.com/NixOS/nixpkgs/issues/303074 + gate = false; + packages = { inherit libvpl; }; + flagPrefix = "lib"; + description = "Hardware acceleration via intel libvpl (incompatible with {option}`mfx`)"; + }; + vpx = { + gate = stdenv.buildPlatform == stdenv.hostPlatform; + packages = { inherit libvpx; }; + flagPrefix = "lib"; + description = "VP8 & VP9 de/encoding"; + }; + vulkan = { + gate = !stdenv.isDarwin; + variant = small; + packages = { inherit vulkan-headers vulkan-loader; }; }; + webp = { + variant = full; + packages = { inherit libwebp; }; + flagPrefix = "lib"; + }; + x264 = { + gate = enable.gpl; + packages = { inherit x264; }; + flagPrefix = "lib"; + }; + x265 = { + gate = enable.gpl; + packages = { inherit x265; }; + flagPrefix = "lib"; }; + xavs = { + gate = enable.gpl; + variant = full; + packages = { inherit xavs; }; + flagPrefix = "lib"; + }; + xcb = { + gate = with enable; xcb-shape || xcb-shm || xcb-xfixes; + packages = { inherit libxcb; }; + flagPrefix = "lib"; + description = "X11 grabbing using XCB"; + }; + xcb-shape = { + variant = full; + flagPrefix = "lib"; + description = "X11 grabbing shape rendering"; + }; + xcb-shm = { + variant = full; + flagPrefix = "lib"; + description = "X11 grabbing shm communication"; + }; + xcb-xfixes = { + variant = full; + flagPrefix = "lib"; + description = "X11 grabbing mouse rendering"; + }; + xevd = { + gate = stdenv.hostPlatform.isx86; + variant = full; + version = "7"; + packages = { inherit xevd; }; + flagPrefix = "lib"; + description = "MPEG-5 EVC decoding"; + }; + xeve = { + gate = stdenv.hostPlatform.isx86; + variant = full; + version = "7"; + packages = { inherit xeve; }; + flagPrefix = "lib"; + description = "MPEG-5 EVC encoding"; + }; + xlib = { + variant = full; + packages = { inherit libX11 libXv libXext; }; + }; + xml2 = { + variant = full; + packages = { inherit libxml2; }; + flagPrefix = "lib"; + description = "libxml2 support, for IMF and DASH demuxers"; + }; + xvid = { + gate = enable.gpl; + packages = { inherit xvidcore; }; + flagPrefix = "lib"; + description = "Xvid encoder, native encoder exists"; # TODO shouldn't we be using it then? + }; + zimg = { + packages = { inherit zimg; }; + flagPrefix = "lib"; + }; + zlib = { packages = { inherit zlib; }; }; + zmq = { + variant = full; + packages = { inherit zeromq4; }; + flagPrefix = "lib"; + description = "Message passing"; + }; + }; in { options = { From ccb7b7fbe3f3517689d31602d7128a0c26c87ba8 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 14:37:33 +0200 Subject: [PATCH 22/28] remove debug passthru --- pkgs/development/libraries/ffmpeg/generic.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 6b798c24e6a8d..e1bbc02227a8d 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -1129,7 +1129,6 @@ stdenv.mkDerivation (finalAttrs: { enableParallelBuilding = true; passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; - passthru.variants = variants; passthru.eval = eval; meta = { From 2ba00979cc5b59747541d87893b26c877b40cfaf Mon Sep 17 00:00:00 2001 From: Atemu Date: Sat, 14 Sep 2024 14:45:21 +0200 Subject: [PATCH 23/28] actually delete options.nix Forgot to actually delete it a few commits ago --- pkgs/development/libraries/ffmpeg/options.nix | 752 ------------------ 1 file changed, 752 deletions(-) delete mode 100644 pkgs/development/libraries/ffmpeg/options.nix diff --git a/pkgs/development/libraries/ffmpeg/options.nix b/pkgs/development/libraries/ffmpeg/options.nix deleted file mode 100644 index e42fc153a9d39..0000000000000 --- a/pkgs/development/libraries/ffmpeg/options.nix +++ /dev/null @@ -1,752 +0,0 @@ -{ - lib, - config, - stdenv, - pkgs, # TODO - version, - variant, - variants, - ... -}: - - -let - # Checks whether the given variant of the flag is contained in the currently - # active variant. full ⊃ small ⊃ headless - isInVariant = flagVariant: - let - checks = { - full = variant == variants.full; - small = variant == variants.small || checks.full; - headless = variant == variants.headless || checks.small; - }; - in checks.${flagVariant} or false; - ffmpegFlag = lib.types.submodule ({ config, name, ... }: { - options = { - enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg." // lib.mkOption { - # TODO this works but doesn't allow for convenient overrides yet. You - # can easily override enable = true but it will still be gated behind - # the variant check. - default = isInVariant config.variant && config.gate; - }; - packages = lib.mkOption { - type = with lib.types; attrsOf package; - default = { }; - description = "The dependencies required to enable ${name} support."; - }; - version = lib.mkOption { - type = lib.types.str; - default = "0"; # Unknown/Enable in any version - description = "Minimum version that understands this flag. Flag will not be passed when lower."; - }; - versionMax = lib.mkOption { - type = lib.types.str; - default = "99999999"; # Unknown/Enable in any version - description = "Maximum version that understands this flag. Flag will not be passed when higher."; - }; - variant = lib.mkOption { - type = lib.types.enum [ "headless" "small" "full" ]; - default = "headless"; - description = '' - Which variant this feature should be enabled in. - - Headless: Build with dependency set that is necessary for headless - operation; excludes dependencies that are only necessary for GUI - applications. Intended for purposes that don't generally need such - components and i.e. only depend on libav and for bootstrapping. - - Small: Dependencies a user might customarily expect from a regular - ffmpeg build. /All/ packages that depend on ffmpeg and some of its - feaures should depend on the small variant. Small means the minimal - set of features that satisfies all dependants in Nixpkgs - - Full: All dependencies enabled; only guarded behind platform - exclusivity, brokeness or extreme closure sizes that make more sense - in a specific ffmpeg variant. If you need to depend on ffmpeg-full - because ffmpeg is missing some feature your package needs, you should - enable that feature in regular ffmpeg instead. - ''; - }; - - gate = lib.mkOption { - default = true; - description = '' - Gates the default value for {option}`enable` behind a boolean. Use - this to disable certain features on certain platforms by default. - ''; - }; - - flags = lib.mkOption { - type = with lib.types; listOf str; - default = [ (config.flagPrefix + name) ]; - description = '' - Flags to be passed to the configure script for this feature. - ''; - }; - - flagPrefix = lib.mkOption { - default = ""; - example = "lib"; - description = '' - Which prefix the configure enable flag has. Frequently `lib`. - ''; - }; - - description = lib.mkOption { - type = with lib.types; nullOr str; - default = null; - readOnly = true; - }; - }; - }); - - mkFfmpegOption = name: default: lib.mkOption { - type = ffmpegFlag; - inherit default; # Default done via ffmpegFlag type - description = - let - hasDescription = default.description or null != null; - additionalDescription = lib.optionalString hasDescription ": ${default.description}"; - in - "Control ${name} support in ffmpeg${additionalDescription}."; - }; - - inherit (variants) headless small full; - - featureOptions = config: - # FIXME - with pkgs; - with pkgs.darwin.apple_sdk.frameworks; - with pkgs.xorg; - let - enable = lib.mapAttrs (n: v: v.enable) config; - in - { - /* - * Licensing flags - */ - gpl = { }; - version3 = { - description = "When {option}`gpl` is set this implies {option}`gplv3`. Otherwise the license is LGPLv3"; - }; - gplv3 = { - gate = enable.gpl && enable.version3; - flags = [ ]; # internal - }; - unfree = { - enable = false; - flags = [ "nonfree" ]; - }; - /* - * Build flags - */ - static = { gate = stdenv.hostPlatform.isStatic; }; - shared = { gate = !stdenv.hostPlatform.isStatic; }; - pic = { }; - thumb = { enable = false; }; - small = { enable = false; }; - runtime-cpudetect = { }; - gray = { variant = full; }; - swscale-alpha = { }; # TODO same as swscale? - hardcoded-tables = { }; - safe-bitstream-reader = { }; - - small = { }; - runtime-cpudetect = { }; - gray = { }; - swscale-alpha = { }; - hardcoded-tables = { }; - safe-bitstream-reader = { }; - - multithread = { flags = [ ]; }; - pthreads = { - gate = enable.multithread && stdenv.hostPlatform.isUnix; - }; - w32threads = { - gate = enable.multithread && stdenv.hostPlatform.isWindows; - }; - os2threads = { - # We don't support OS/2 - enable = false; - }; - - network = { }; - pixelutils = { }; - - /* - * Program flags - */ - ffmpeg = { }; - ffplay = { variant = small; }; - ffprobe = { }; - - /* - * Library flags - */ - avcodec = { }; - avdevice = { }; - avfilter = { }; - avformat = { }; - avresample = { - # Ffmpeg > 4 doesn't know about the flag anymore - versionMax = "5"; - }; - - avutil = { }; - postproc = { gate = enable.gpl; }; - swresample = { }; - swscale = { }; - - /* - * Documentation flags - */ - doc = { }; - htmlpages = { }; - manpages = { }; - podpages = { }; - txtpages = { }; - - /* - * Developer flags - */ - debug = { enable = false; }; - optimizations = { }; - extra-warnings = { enable = false; }; - stripping = { enable = false; }; - - # Feature flags - alsa = { packages = { inherit alsa-lib; }; }; - aom = { - variant = full; - packages = { inherit libaom; }; - flagPrefix = "lib"; - description = "AV1 reference encoder"; - }; - appkit = { - gate = stdenv.isDarwin; - packages = { inherit AppKit; }; - }; - aribcaption = { - variant = full; - packages = { inherit libaribcaption; }; - flagPrefix = "lib"; - description = "ARIB STD-B24 Caption Decoder/Renderer"; - }; - ass = { - gate = stdenv.hostPlatform == stdenv.buildPlatform; - packages = { inherit libass; }; - flagPrefix = "lib"; - description = "(Advanced) SubStation Alpha subtitle rendering"; - }; - audiotoolbox = { - gate = stdenv.isDarwin; - packages = { inherit AudioToolbox; }; - }; - avfoundation = { - gate = stdenv.isDarwin; - packages = { inherit AVFoundation; }; - }; - avisynth = { - variant = full; - packages = { inherit avisynthplus; }; - description = "AviSynth script processing"; - }; - bluray = { - variant = full; - packages = { inherit libbluray; }; - flagPrefix = "lib"; - }; - bs2b = { - variant = full; - packages = { inherit libbs2b; }; - flagPrefix = "lib"; - }; - bzlib = { packages = { inherit bzip2; }; }; - caca = { - variant = full; - packages = { inherit libcaca; }; - flagPrefix = "lib"; - description = "Textual display (ASCII art)"; - }; - celt = { - variant = full; - packages = { inherit celt; }; - flagPrefix = "lib"; - }; - chromaprint = { - variant = full; - packages = { inherit chromaprint; }; - description = "Audio fingerprinting"; - }; - codec2 = { - variant = full; - packages = { inherit codec2; }; - flagPrefix = "lib"; - }; - coreimage = { - gate = stdenv.isDarwin; - packages = { inherit CoreImage; }; - }; - cuda = { - inherit (config.nvcodec) gate; - variant = full; - }; - cuda-llvm = { - variant = full; - }; - cuvid = { - inherit (config.nvcodec) gate; - }; - dav1d = { - packages = { inherit dav1d; }; - flagPrefix = "lib"; - description = "AV1 decoder (focused on speed and correctness)"; - }; - dc1394 = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libdc1394 libraw1394; }; - flagPrefix = "lib"; - description = "IIDC-1394 grabbing (ieee 1394/Firewire)"; - }; - drm = { - gate = with stdenv; isLinux || isFreeBSD; - packages = { inherit libdrm; }; - flagPrefix = "lib"; - }; - dvdnav = { - gate = enable.gpl; - variant = full; - version = "7"; - packages = { inherit libdvdnav; }; - flagPrefix = "lib"; - description = "DVD demuxing"; - }; - dvdread = { - gate = enable.gpl; - variant = full; - version = "7"; - packages = { inherit libdvdread; }; - flagPrefix = "lib"; - description = "DVD demuxing"; - }; - fdk-aac = { - gate = with enable; !gpl || unfree; - variant = full; - packages = { inherit fdk_aac; }; - flagPrefix = "lib"; - description = "Fraunhofer FDK AAC de/encoder"; - }; - nvcodec = { - gate = with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform; - packages = { - nv-codec-headers = - if lib.versionAtLeast version "6" - then nv-codec-headers-12 - else nv-codec-headers; - }; - flagPrefix = "ff"; - description = "Dynamically linked Nvidia code"; - }; - flite = { - variant = full; - packages = { inherit flite; }; - flagPrefix = "lib"; - description = "Voice synthesis"; - }; - fontconfig = { - packages = { inherit fontconfig; }; - flags = [ "fontconfig" "libfontconfig" ]; - description = "Font support for i.e. the drawtext filter"; - }; - freetype = { - packages = { inherit freetype; }; - flagPrefix = "lib"; - description = "Font support for i.e. the drawtext filter"; - }; - frei0r = { - gate = enable.gpl; - variant = full; - packages = { inherit frei0r; }; - description = "Frei0r video filtering"; - }; - fribidi = { - variant = full; - packages = { inherit fribidi; }; - flagPrefix = "lib"; - description = "Font support for i.e. the drawtext filter"; - }; - gme = { - variant = full; - packages = { inherit game-music-emu; }; - flagPrefix = "lib"; - description = "Game Music Emulator"; - }; - gnutls = { packages = { inherit gnutls; }; }; - gsm = { - variant = full; - packages = { inherit gsm; }; - flagPrefix = "lib"; - }; - harfbuzz = { - version = "6.1"; - packages = { inherit harfbuzz; }; - flagPrefix = "lib"; - description = "Font support for i.e. the drawtext filter"; - }; - iconv = { packages = { inherit libiconv; }; }; # On Linux this should be in libc, do we really need it? - jack = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libjack2; }; - flagPrefix = "lib"; - }; - jxl = { - variant = full; - version = "5"; - packages = { inherit libjxl; }; - flagPrefix = "lib"; - }; - ladspa = { - variant = full; - packages = { inherit ladspaH; }; - description = "LADSPA audio filtering"; - }; - lzma = { packages = { inherit xz; }; }; - mfx = { - gate = with stdenv.hostPlatform; isLinux && !isAarch; - variant = full; - packages = { inherit intel-media-sdk; }; - flagPrefix = "lib"; - description = "Hardware acceleration via intel-media-sdk/libmfx (incompatible with {option}`vpl`)"; - }; - modplug = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libmodplug; }; - flagPrefix = "lib"; - }; - mp3lame = { - packages = { inherit lame; }; - flagPrefix = "lib"; - }; - mysofa = { - variant = full; - packages = { inherit libmysofa; }; - flagPrefix = "lib"; - description = "HRTF support via SOFAlizer"; - }; - nvdec = { - inherit (config.nvcodec) gate; - }; - nvenc = { - inherit (config.nvcodec) gate; - }; - ogg = { - packages = { inherit libogg; }; - flags = [ ]; # There is no flag for OGG?! - description = "Ogg container used by vorbis & theora"; - }; - openal = { - variant = full; - packages = { inherit openal; }; - description = "OpenAL 1.1 capture support"; - }; - opencl = { - variant = full; - packages = { inherit ocl-icd opencl-headers; }; - }; - opencore-amr = { - gate = enable.gplv3; - variant = full; - packages = { inherit opencore-amr; }; - flags = [ "libopencore-amrnb" "libopencore-amrwb" ]; - }; - opengl = { - gate = !stdenv.isDarwin; - variant = full; - packages = { inherit libGL libGLU; }; - description = "OpenGL rendering"; - }; - openh264 = { - variant = full; - packages = { inherit openh264; }; - flagPrefix = "lib"; - }; - openjpeg = { - variant = full; - packages = { inherit openjpeg; }; - flagPrefix = "lib"; - }; - openmpt = { - variant = full; - packages = { inherit libopenmpt; }; - flagPrefix = "lib"; - description = "Tracked music files decoder"; - }; - opus = { - packages = { inherit libopus; }; - flagPrefix = "lib"; - }; - placebo = { - gate = !stdenv.isDarwin; - variant = full; - packages = { - inherit vulkan-headers; - libplacebo = - if lib.versionAtLeast version "6.1" - then libplacebo - else libplacebo_5; - }; - flagPrefix = "lib"; - description = "libplacebo video processing library"; - }; - pulse = { - gate = stdenv.isLinux; - variant = small; - packages = { inherit libpulseaudio; }; - flagPrefix = "lib"; - description = "Pulseaudio input support"; - }; - qrencode = { - variant = full; - version = "7"; - packages = { inherit qrencode; }; - flagPrefix = "lib"; - description = "QR encode generation"; - }; - quirc = { - variant = full; - version = "7"; - packages = { inherit quirc; }; - flagPrefix = "lib"; - description = "QR decoding"; - }; - rav1e = { - variant = full; - packages = { inherit rav1e; }; - flagPrefix = "lib"; - description = "AV1 encoder (focused on speed and safety)"; - }; - rtmp = { - variant = full; - packages = { inherit rtmpdump; }; - flagPrefix = "lib"; - }; - samba = { - variant = full; - packages = { inherit samba; }; - flags = [ "libsmbclient" ]; - }; - sdl2 = { - variant = small; - packages = { inherit SDL2; }; - }; - shaderc = { - gate = !stdenv.isDarwin; - variant = full; - version = "5"; - packages = { inherit shaderc; }; - flagPrefix = "lib"; - }; - soxr = { - packages = { inherit soxr; }; - flagPrefix = "lib"; - description = "Resampling via soxr"; - }; - speex = { - packages = { inherit speex; }; - flagPrefix = "lib"; - }; - srt = { - packages = { inherit srt; }; - flagPrefix = "lib"; - description = "Secure Reliable Transport (SRT) protocol"; - }; - ssh = { - packages = { inherit libssh; }; - flagPrefix = "lib"; - description = "SFTP protocol"; - }; - svg = { - variant = full; - packages = { inherit librsvg; }; - flags = [ "librsvg" ]; - }; - svtav1 = { - gate = !stdenv.isAarch64 && !stdenv.hostPlatform.isMinGW; - packages = { inherit svt-av1; }; - flagPrefix = "lib"; - description = "AV1 encoder/decoder (focused on speed and correctness)"; - }; - tensorflow = { - gate = false; # Increases closure size by ~390 MiB and is rather specialised purpose - packages = { inherit libtensorflow; }; - flagPrefix = "lib"; - description = "Tensorflow dnn backend support"; - }; - theora = { - packages = { inherit libtheora; }; - flagPrefix = "lib"; - }; - v4l2 = { - gate = stdenv.isLinux; - packages = { inherit libv4l; }; - flags = [ "libv4l2" "v4l2-m2m" ]; - description = "Video 4 Linux"; - }; - vaapi = { - gate = with stdenv; isLinux || isFreeBSD; - packages = { - libva = if variant == headless then libva-minimal else libva; - }; - description = "Vaapi hardware acceleration"; - }; - vdpau = { - gate = !stdenv.hostPlatform.isMinGW; - variant = small; - packages = { inherit libvdpau; }; - description = "Vdpau hardware acceleration"; - }; - videotoolbox = { - gate = stdenv.isDarwin; - packages = { inherit VideoToolbox; }; - }; - vidstab = { - gate = enable.gpl; - variant = full; - packages = { inherit vid-stab; }; - flagPrefix = "lib"; - description = "Video stabilization"; - }; - vmaf = { - gate = !stdenv.isAarch64; - variant = full; - version = "5"; - packages = { inherit libvmaf; }; - flagPrefix = "lib"; - description = "Netflix's VMAF (Video Multi-Method Assessment Fusion)"; - }; - vo-amrwbenc = { - gate = enable.gplv3; - variant = full; - packages = { inherit vo-amrwbenc; }; - flagPrefix = "lib"; - }; - vorbis = { - packages = { inherit libvorbis; }; - flagPrefix = "lib"; - description = "Vorbis de/encoding, native encoder exists"; # TODO shouldn't we be using it then? - }; - vpl = { - # It is currently unclear whether this breaks support for old GPUs. See - # https://github.com/NixOS/nixpkgs/issues/303074 - gate = false; - packages = { inherit libvpl; }; - flagPrefix = "lib"; - description = "Hardware acceleration via intel libvpl (incompatible with {option}`mfx`)"; - }; - vpx = { - gate = stdenv.buildPlatform == stdenv.hostPlatform; - packages = { inherit libvpx; }; - flagPrefix = "lib"; - description = "VP8 & VP9 de/encoding"; - }; - vulkan = { - gate = !stdenv.isDarwin; - variant = small; - packages = { inherit vulkan-headers vulkan-loader; }; }; - webp = { - variant = full; - packages = { inherit libwebp; }; - flagPrefix = "lib"; - }; - x264 = { - gate = enable.gpl; - packages = { inherit x264; }; - flagPrefix = "lib"; - }; - x265 = { - gate = enable.gpl; - packages = { inherit x265; }; - flagPrefix = "lib"; - }; - xavs = { - gate = enable.gpl; - variant = full; - packages = { inherit xavs; }; - flagPrefix = "lib"; - }; - xcb = { - gate = with enable; xcb-shape || xcb-shm || xcb-xfixes; - packages = { inherit libxcb; }; - flagPrefix = "lib"; - description = "X11 grabbing using XCB"; - }; - xcb-shape = { - variant = full; - flagPrefix = "lib"; - description = "X11 grabbing shape rendering"; - }; - xcb-shm = { - variant = full; - flagPrefix = "lib"; - description = "X11 grabbing shm communication"; - }; - xcb-xfixes = { - variant = full; - flagPrefix = "lib"; - description = "X11 grabbing mouse rendering"; - }; - xevd = { - gate = stdenv.hostPlatform.isx86; - variant = full; - version = "7"; - packages = { inherit xevd; }; - flagPrefix = "lib"; - description = "MPEG-5 EVC decoding"; - }; - xeve = { - gate = stdenv.hostPlatform.isx86; - variant = full; - version = "7"; - packages = { inherit xeve; }; - flagPrefix = "lib"; - description = "MPEG-5 EVC encoding"; - }; - xlib = { - variant = full; - packages = { inherit libX11 libXv libXext; }; - }; - xml2 = { - variant = full; - packages = { inherit libxml2; }; - flagPrefix = "lib"; - description = "libxml2 support, for IMF and DASH demuxers"; - }; - xvid = { - gate = enable.gpl; - packages = { inherit xvidcore; }; - flagPrefix = "lib"; - description = "Xvid encoder, native encoder exists"; # TODO shouldn't we be using it then? - }; - zimg = { - packages = { inherit zimg; }; - flagPrefix = "lib"; - }; - zlib = { packages = { inherit zlib; }; }; - zmq = { - variant = full; - packages = { inherit zeromq4; }; - flagPrefix = "lib"; - description = "Message passing"; - }; - }; -in - -{ - options = { - features = lib.mapAttrs mkFfmpegOption (featureOptions (config.features)); - foo = lib.mkOption { default = isInVariant "full"; }; - }; -} From a0a07accfecb759f28ce94a2b16dd631f25f55f5 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sun, 15 Sep 2024 06:22:46 +0200 Subject: [PATCH 24/28] merge ffmpegFlags with default values --- pkgs/development/libraries/ffmpeg/generic.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index e1bbc02227a8d..3971ddc954199 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -169,7 +169,7 @@ let # be set to enable the feature. It also offers easy controls to # enable/disable features by default depending on the variant, version and # custom logic. - ffmpegFlag = lib.types.submodule ({ config, name, ... }: { + ffmpegFlag = default: lib.types.submodule ({ config, name, ... }: { options = { enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg." // lib.mkOption { default = isInVariant config.variant && config.gate; @@ -250,11 +250,16 @@ let ''; }; }; + + # Default is passed as the submodule's config in order to merge with + # user-supplied values rather than being overridden entirely. + # https://github.com/NixOS/nixpkgs/pull/312432#discussion_r1759740858 + config = default; }); mkFfmpegOption = name: default: lib.mkOption { - type = ffmpegFlag; - inherit default; # Detailed defaults are implemented in the ffmpegFlag type + type = ffmpegFlag default; + default = { }; description = let hasDescription = default.description or null != null; From c2afc380ac8ac5a90572e2621bdaeded3c427a7f Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 16 Sep 2024 14:49:02 +0200 Subject: [PATCH 25/28] make description internal --- pkgs/development/libraries/ffmpeg/generic.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 3971ddc954199..2c7dd059e351d 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -241,6 +241,7 @@ let type = with lib.types; nullOr str; default = null; readOnly = true; + internal = true; }; internal = lib.mkEnableOption "" // lib.mkOption { From ba6e0f98648c00cd1eeea9e98dea1f92b3d21078 Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 16 Sep 2024 14:49:33 +0200 Subject: [PATCH 26/28] improve descriptions --- pkgs/development/libraries/ffmpeg/generic.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 2c7dd059e351d..fa5ca1c59458e 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -171,7 +171,7 @@ let # custom logic. ffmpegFlag = default: lib.types.submodule ({ config, name, ... }: { options = { - enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg." // lib.mkOption { + enable = lib.mkEnableOption "Whether to enable ${name} support in ffmpeg" // lib.mkOption { default = isInVariant config.variant && config.gate; }; packages = lib.mkOption { @@ -266,7 +266,7 @@ let hasDescription = default.description or null != null; additionalDescription = lib.optionalString hasDescription ": ${default.description}"; in - "Control ${name} support in ffmpeg${additionalDescription}."; + "Control `${name}` support in ffmpeg${additionalDescription}."; }; # This is the source of truth for the default set of features activated in ffmpeg From 1dd2070badb1043c4e5f68496a4fe4df322c6848 Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 16 Sep 2024 14:52:58 +0200 Subject: [PATCH 27/28] missing alsa gate Darwin eval works now --- pkgs/development/libraries/ffmpeg/generic.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index fa5ca1c59458e..60b0aa26e93d1 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -392,7 +392,10 @@ let stripping = { gate = false; }; # Feature flags - alsa = { packages = { inherit alsa-lib; }; }; + alsa = { + gate = stdenv.isLinux; + packages = { inherit alsa-lib; }; + }; aom = { variant = full; packages = { inherit libaom; }; From 456029010fb4a6e38846538941ddad1f0b6b556f Mon Sep 17 00:00:00 2001 From: Atemu Date: Mon, 16 Sep 2024 14:58:53 +0200 Subject: [PATCH 28/28] qt-faststart only in full --- pkgs/development/libraries/ffmpeg/generic.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 60b0aa26e93d1..75a8c243f52ac 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -336,6 +336,7 @@ let description = "Build ffprobe executable"; }; qt-faststart = { + variant = full; description = "Build qt-faststart executable"; internal = true; # Does not have a flag, needs its dir to be passed to make manually };