diff --git a/pkgs/applications/graphics/ImageMagick/default.nix b/pkgs/applications/graphics/ImageMagick/default.nix index 75c8ca574bff..f1c1f7f933be 100644 --- a/pkgs/applications/graphics/ImageMagick/default.nix +++ b/pkgs/applications/graphics/ImageMagick/default.nix @@ -1,51 +1,85 @@ -{ lib -, stdenv -, fetchFromGitHub -, pkg-config -, libtool -, bzip2Support ? true, bzip2 -, zlibSupport ? true, zlib -, libX11Support ? !stdenv.hostPlatform.isMinGW, libX11 -, libXtSupport ? !stdenv.hostPlatform.isMinGW, libXt -, fontconfigSupport ? true, fontconfig -, freetypeSupport ? true, freetype -, ghostscriptSupport ? false, ghostscript -, libjpegSupport ? true, libjpeg -, djvulibreSupport ? true, djvulibre -, lcms2Support ? true, lcms2 -, openexrSupport ? !stdenv.hostPlatform.isMinGW, openexr -, libjxlSupport ? true, libjxl -, libpngSupport ? true, libpng -, liblqr1Support ? true, liblqr1 -, librawSupport ? true, libraw -, librsvgSupport ? !stdenv.hostPlatform.isMinGW, librsvg, pango -, libtiffSupport ? true, libtiff -, libxml2Support ? true, libxml2 -, openjpegSupport ? !stdenv.hostPlatform.isMinGW, openjpeg -, libwebpSupport ? !stdenv.hostPlatform.isMinGW, libwebp -, libheifSupport ? true, libheif -, fftwSupport ? true, fftw -, potrace -, coreutils -, curl -, ApplicationServices -, Foundation -, testers -, nixos-icons -, perlPackages -, python3 +{ + lib, + stdenv, + fetchFromGitHub, + pkg-config, + libtool, + bzip2Support ? true, + bzip2, + zlibSupport ? true, + zlib, + libX11Support ? !stdenv.hostPlatform.isMinGW, + libX11, + libXtSupport ? !stdenv.hostPlatform.isMinGW, + libXt, + fontconfigSupport ? true, + fontconfig, + freetypeSupport ? true, + freetype, + ghostscriptSupport ? false, + ghostscript, + libjpegSupport ? true, + libjpeg, + djvulibreSupport ? true, + djvulibre, + lcms2Support ? true, + lcms2, + openexrSupport ? !stdenv.hostPlatform.isMinGW, + openexr, + libjxlSupport ? true, + libjxl, + libpngSupport ? true, + libpng, + liblqr1Support ? true, + liblqr1, + librawSupport ? true, + libraw, + librsvgSupport ? !stdenv.hostPlatform.isMinGW, + librsvg, + pango, + libtiffSupport ? true, + libtiff, + libxml2Support ? true, + libxml2, + openjpegSupport ? !stdenv.hostPlatform.isMinGW, + openjpeg, + libwebpSupport ? !stdenv.hostPlatform.isMinGW, + libwebp, + libheifSupport ? true, + libheif, + fftwSupport ? true, + fftw, + potrace, + coreutils, + curl, + ApplicationServices, + Foundation, + testers, + nixos-icons, + perlPackages, + python3, }: assert libXtSupport -> libX11Support; let arch = - if stdenv.hostPlatform.system == "i686-linux" then "i686" - else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64" - else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l" - else if stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" then "aarch64" - else if stdenv.hostPlatform.system == "powerpc64le-linux" then "ppc64le" - else null; + if stdenv.hostPlatform.system == "i686-linux" then + "i686" + else if + stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" + then + "x86-64" + else if stdenv.hostPlatform.system == "armv7l-linux" then + "armv7l" + else if + stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" + then + "aarch64" + else if stdenv.hostPlatform.system == "powerpc64le-linux" then + "ppc64le" + else + null; in stdenv.mkDerivation (finalAttrs: { @@ -59,33 +93,44 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-DsJRTLMyjU2mMEGq/2qEJvjdYa698TEZZqkxuWtd/A4="; }; - outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big + outputs = [ + "out" + "dev" + "doc" + ]; # bin/ isn't really big outputMan = "out"; # it's tiny enableParallelBuilding = true; - configureFlags = [ - # specify delegates explicitly otherwise `convert` will invoke the build - # coreutils for filetypes it doesn't natively support. - "MVDelegate=${lib.getExe' coreutils "mv"}" - "RMDelegate=${lib.getExe' coreutils "rm"}" - "--with-frozenpaths" - (lib.withFeatureAs (arch != null) "gcc-arch" arch) - (lib.withFeature librsvgSupport "rsvg") - (lib.withFeature librsvgSupport "pango") - (lib.withFeature liblqr1Support "lqr") - (lib.withFeature libjxlSupport "jxl") - (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts") - (lib.withFeature ghostscriptSupport "gslib") - (lib.withFeature fftwSupport "fftw") - ] ++ lib.optionals stdenv.hostPlatform.isMinGW [ - # due to libxml2 being without DLLs ATM - "--enable-static" "--disable-shared" + configureFlags = + [ + # specify delegates explicitly otherwise `convert` will invoke the build + # coreutils for filetypes it doesn't natively support. + "MVDelegate=${lib.getExe' coreutils "mv"}" + "RMDelegate=${lib.getExe' coreutils "rm"}" + "--with-frozenpaths" + (lib.withFeatureAs (arch != null) "gcc-arch" arch) + (lib.withFeature librsvgSupport "rsvg") + (lib.withFeature librsvgSupport "pango") + (lib.withFeature liblqr1Support "lqr") + (lib.withFeature libjxlSupport "jxl") + (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts") + (lib.withFeature ghostscriptSupport "gslib") + (lib.withFeature fftwSupport "fftw") + ] + ++ lib.optionals stdenv.hostPlatform.isMinGW [ + # due to libxml2 being without DLLs ATM + "--enable-static" + "--disable-shared" + ]; + + nativeBuildInputs = [ + pkg-config + libtool ]; - nativeBuildInputs = [ pkg-config libtool ]; - - buildInputs = [ potrace ] + buildInputs = + [ potrace ] ++ lib.optional zlibSupport zlib ++ lib.optional fontconfigSupport fontconfig ++ lib.optional ghostscriptSupport ghostscript @@ -108,7 +153,8 @@ stdenv.mkDerivation (finalAttrs: { Foundation ]; - propagatedBuildInputs = [ curl ] + propagatedBuildInputs = + [ curl ] ++ lib.optional bzip2Support bzip2 ++ lib.optional freetypeSupport freetype ++ lib.optional libjpegSupport libjpeg @@ -118,24 +164,26 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional libwebpSupport libwebp ++ lib.optional fftwSupport fftw; - postInstall = '' - (cd "$dev/include" && ln -s ImageMagick* ImageMagick) - # Q16HDRI = 16 bit quantum depth with HDRI support, and is the default ImageMagick configuration - # If the default is changed, or the derivation is modified to use a different configuration - # this will need to be changed below. - moveToOutput "bin/*-config" "$dev" - moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params - configDestination=($out/share/ImageMagick-*) - grep -v '/nix/store' $dev/lib/ImageMagick-*/config-Q16HDRI/configure.xml > $configDestination/configure.xml - for file in "$dev"/bin/*-config; do - substituteInPlace "$file" --replace pkg-config \ - "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'" - done - '' + lib.optionalString ghostscriptSupport '' - for la in $out/lib/*.la; do - sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la - done - ''; + postInstall = + '' + (cd "$dev/include" && ln -s ImageMagick* ImageMagick) + # Q16HDRI = 16 bit quantum depth with HDRI support, and is the default ImageMagick configuration + # If the default is changed, or the derivation is modified to use a different configuration + # this will need to be changed below. + moveToOutput "bin/*-config" "$dev" + moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params + configDestination=($out/share/ImageMagick-*) + grep -v '/nix/store' $dev/lib/ImageMagick-*/config-Q16HDRI/configure.xml > $configDestination/configure.xml + for file in "$dev"/bin/*-config; do + substituteInPlace "$file" --replace pkg-config \ + "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'" + done + '' + + lib.optionalString ghostscriptSupport '' + for la in $out/lib/*.la; do + sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la + done + ''; passthru.tests = { version = testers.testVersion { package = finalAttrs.finalPackage; }; @@ -152,9 +200,16 @@ stdenv.mkDerivation (finalAttrs: { homepage = "http://www.imagemagick.org/"; changelog = "https://github.com/ImageMagick/Website/blob/main/ChangeLog.md"; description = "Software suite to create, edit, compose, or convert bitmap images"; - pkgConfigModules = [ "ImageMagick" "MagickWand" ]; - platforms = platforms.linux ++ platforms.darwin; - maintainers = with maintainers; [ dotlambda rhendric bloxx12 ]; + pkgConfigModules = [ + "ImageMagick" + "MagickWand" + ]; + platforms = platforms.unix; + maintainers = with maintainers; [ + dotlambda + rhendric + bloxx12 + ]; license = licenses.asl20; mainProgram = "magick"; }; diff --git a/pkgs/by-name/al/alsa-lib/package.nix b/pkgs/by-name/al/alsa-lib/package.nix index f21d216a63bb..2ae87a0533a1 100644 --- a/pkgs/by-name/al/alsa-lib/package.nix +++ b/pkgs/by-name/al/alsa-lib/package.nix @@ -65,7 +65,7 @@ stdenv.mkDerivation (finalAttrs: { "alsa" "alsa-topology" ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.freebsd; maintainers = with maintainers; [ l-as ]; }; }) diff --git a/pkgs/by-name/al/alsa-topology-conf/package.nix b/pkgs/by-name/al/alsa-topology-conf/package.nix index 7f881bbe6a66..87cb278760da 100644 --- a/pkgs/by-name/al/alsa-topology-conf/package.nix +++ b/pkgs/by-name/al/alsa-topology-conf/package.nix @@ -35,6 +35,6 @@ stdenv.mkDerivation rec { license = licenses.bsd3; maintainers = [ maintainers.roastiek ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.freebsd; }; } diff --git a/pkgs/by-name/al/alsa-ucm-conf/package.nix b/pkgs/by-name/al/alsa-ucm-conf/package.nix index 9d727e8d21ab..ea27eed8fbc6 100644 --- a/pkgs/by-name/al/alsa-ucm-conf/package.nix +++ b/pkgs/by-name/al/alsa-ucm-conf/package.nix @@ -18,31 +18,36 @@ stdenv.mkDerivation (finalAttrs: { dontBuild = true; - installPhase = '' - runHook preInstall + installPhase = + '' + runHook preInstall - substituteInPlace ucm2/lib/card-init.conf \ - --replace-fail "/bin/rm" "${coreutils}/bin/rm" \ - --replace-fail "/bin/mkdir" "${coreutils}/bin/mkdir" + substituteInPlace ucm2/lib/card-init.conf \ + --replace-fail "/bin/rm" "${coreutils}/bin/rm" \ + --replace-fail "/bin/mkdir" "${coreutils}/bin/mkdir" - files=( - "ucm2/HDA/HDA.conf" - "ucm2/codecs/rt715/init.conf" - "ucm2/codecs/rt715-sdca/init.conf" - "ucm2/Intel/cht-bsw-rt5672/cht-bsw-rt5672.conf" - "ucm2/Intel/bytcr-rt5640/bytcr-rt5640.conf" - ) + files=( + "ucm2/HDA/HDA.conf" + "ucm2/codecs/rt715/init.conf" + "ucm2/codecs/rt715-sdca/init.conf" + "ucm2/Intel/cht-bsw-rt5672/cht-bsw-rt5672.conf" + "ucm2/Intel/bytcr-rt5640/bytcr-rt5640.conf" + ) - for file in "''${files[@]}"; do - substituteInPlace "$file" \ - --replace-fail '/sbin/modprobe' '${kmod}/bin/modprobe' - done + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + for file in "''${files[@]}"; do + substituteInPlace "$file" \ + --replace-fail '/sbin/modprobe' '${kmod}/bin/modprobe' + done + '' + + '' - mkdir -p $out/share/alsa - cp -r ucm ucm2 $out/share/alsa + mkdir -p $out/share/alsa + cp -r ucm ucm2 $out/share/alsa - runHook postInstall - ''; + runHook postInstall + ''; passthru.updateScript = directoryListingUpdater { url = "https://www.alsa-project.org/files/pub/lib/"; @@ -59,6 +64,6 @@ stdenv.mkDerivation (finalAttrs: { license = lib.licenses.bsd3; maintainers = [ lib.maintainers.roastiek ]; - platforms = lib.platforms.linux; + platforms = lib.platforms.linux ++ lib.platforms.freebsd; }; }) diff --git a/pkgs/by-name/fr/frei0r/package.nix b/pkgs/by-name/fr/frei0r/package.nix index b8afe3eca36b..77df045e964d 100644 --- a/pkgs/by-name/fr/frei0r/package.nix +++ b/pkgs/by-name/fr/frei0r/package.nix @@ -49,6 +49,6 @@ stdenv.mkDerivation rec { description = "Minimalist, cross-platform, shared video plugins"; license = licenses.gpl2Plus; maintainers = [ ]; - platforms = platforms.linux ++ platforms.darwin; + platforms = platforms.unix; }; } diff --git a/pkgs/by-name/li/libcamera/package.nix b/pkgs/by-name/li/libcamera/package.nix index a26adf10b65e..b9e321fd4dcf 100644 --- a/pkgs/by-name/li/libcamera/package.nix +++ b/pkgs/by-name/li/libcamera/package.nix @@ -132,6 +132,7 @@ stdenv.mkDerivation rec { changelog = "https://git.libcamera.org/libcamera/libcamera.git/tag/?h=${src.rev}"; license = licenses.lgpl2Plus; maintainers = with maintainers; [ citadelcore ]; + platforms = platforms.linux; badPlatforms = [ # Mandatory shared libraries. lib.systems.inspect.platformPatterns.isStatic diff --git a/pkgs/by-name/li/libvisual/package.nix b/pkgs/by-name/li/libvisual/package.nix index 944ea60409c7..a2a559deccf2 100644 --- a/pkgs/by-name/li/libvisual/package.nix +++ b/pkgs/by-name/li/libvisual/package.nix @@ -53,6 +53,6 @@ stdenv.mkDerivation rec { description = "Abstraction library for audio visualisations"; homepage = "https://sourceforge.net/projects/libvisual/"; license = lib.licenses.lgpl21Plus; - platforms = lib.platforms.linux; + platforms = lib.platforms.linux ++ lib.platforms.freebsd; }; } diff --git a/pkgs/by-name/qu/quirc/package.nix b/pkgs/by-name/qu/quirc/package.nix index 0251561a2262..f20be686b7c1 100644 --- a/pkgs/by-name/qu/quirc/package.nix +++ b/pkgs/by-name/qu/quirc/package.nix @@ -56,8 +56,8 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-WLQK7vy34VmgJzppTnRjAcZoSGWVaXQSaGq9An8W0rw="; }) ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # Disable building of linux-only demos on darwin systems + ++ lib.optionals (!stdenv.hostPlatform.isLinux) [ + # Disable building of linux-only demos on non-linux systems ./0001-Don-t-build-demos.patch ]; @@ -84,9 +84,6 @@ stdenv.mkDerivation (finalAttrs: { description = "Small QR code decoding library"; license = lib.licenses.isc; maintainers = [ lib.maintainers.raskin ]; - platforms = lib.platforms.linux ++ [ - "x86_64-darwin" - "aarch64-darwin" - ]; + platforms = lib.platforms.unix; }; }) diff --git a/pkgs/by-name/so/socat/package.nix b/pkgs/by-name/so/socat/package.nix index ea9e1f9fa238..da08ab588569 100644 --- a/pkgs/by-name/so/socat/package.nix +++ b/pkgs/by-name/so/socat/package.nix @@ -25,9 +25,13 @@ stdenv.mkDerivation rec { --replace /sbin/ifconfig ifconfig ''; - configureFlags = lib.optionals (!stdenv.hostPlatform.isLinux) [ - "--disable-posixmq" - ]; + configureFlags = + lib.optionals (!stdenv.hostPlatform.isLinux) [ + "--disable-posixmq" + ] + ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ + "--disable-dccp" + ]; buildInputs = [ openssl diff --git a/pkgs/by-name/x2/x265/package.nix b/pkgs/by-name/x2/x265/package.nix index ddd820c145f5..eec407eeaf1b 100644 --- a/pkgs/by-name/x2/x265/package.nix +++ b/pkgs/by-name/x2/x265/package.nix @@ -87,7 +87,7 @@ stdenv.mkDerivation rec { ] # Clang does not support the endfunc directive so use GCC. ++ lib.optional ( - stdenv.cc.isClang && !stdenv.targetPlatform.isDarwin + stdenv.cc.isClang && !stdenv.targetPlatform.isDarwin && !stdenv.targetPlatform.isFreeBSD ) "-DCMAKE_ASM_COMPILER=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc"; cmakeStaticLibFlags = diff --git a/pkgs/by-name/xa/xavs/package.nix b/pkgs/by-name/xa/xavs/package.nix index a4116ab1f807..e136438e09c7 100644 --- a/pkgs/by-name/xa/xavs/package.nix +++ b/pkgs/by-name/xa/xavs/package.nix @@ -49,7 +49,7 @@ stdenv.mkDerivation rec { mainProgram = "xavs"; homepage = "https://xavs.sourceforge.net/"; license = licenses.lgpl2; - platforms = platforms.linux ++ platforms.darwin; + platforms = platforms.unix; maintainers = with maintainers; [ codyopel ]; }; } diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 94e86bfa09ad..650db88130ad 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -1,934 +1,1016 @@ -{ lib, config, stdenv, buildPackages, removeReferencesTo, addDriverRunpath, pkg-config, perl, texinfo, texinfo6, yasm +{ + lib, + config, + stdenv, + buildPackages, + removeReferencesTo, + addDriverRunpath, + pkg-config, + perl, + texinfo, + texinfo6, + yasm, # You can fetch any upstream version using this derivation by specifying version and hash # NOTICE: Always use this argument to override the version. Do not use overrideAttrs. -, version # ffmpeg ABI version. Also declare this if you're overriding the source. -, hash ? "" # hash of the upstream source for the given ABI version -, source ? fetchgit { + version, # ffmpeg ABI version. Also declare this if you're overriding the source. + hash ? "", # hash of the upstream source for the given ABI version + source ? fetchgit { url = "https://git.ffmpeg.org/ffmpeg.git"; rev = "n${version}"; inherit hash; - } + }, -, ffmpegVariant ? "small" # Decides which dependencies are enabled by default + 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 + 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 + 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" + withFullDeps ? ffmpegVariant == "full", -, fetchgit -, fetchpatch2 + fetchgit, + fetchpatch2, # Feature flags -, withAlsa ? withHeadlessDeps && stdenv.hostPlatform.isLinux # Alsa in/output supporT -, withAmf ? withHeadlessDeps && lib.meta.availableOn stdenv.hostPlatform amf # AMD Media Framework video encoding -, withAom ? withHeadlessDeps # AV1 reference encoder -, withAribb24 ? withFullDeps # ARIB text and caption decoding -, withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1" # ARIB STD-B24 Caption Decoder/Renderer -, withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering -, withAvisynth ? withFullDeps # AviSynth script files reading -, withBluray ? withHeadlessDeps # BluRay reading -, withBs2b ? withFullDeps # bs2b DSP library -, withBzlib ? withHeadlessDeps -, withCaca ? withFullDeps # Textual display (ASCII art) -, withCdio ? withFullDeps && withGPL # Audio CD grabbing -, withCelt ? withHeadlessDeps # CELT decoder -, withChromaprint ? withFullDeps # Audio fingerprinting -, withCodec2 ? withFullDeps # codec2 en/decoding -, withCuda ? withFullDeps && withNvcodec -, withCudaLLVM ? withHeadlessDeps -, withCudaNVCC ? withFullDeps && withUnfree && config.cudaSupport -, withCuvid ? withHeadlessDeps && withNvcodec -, withDav1d ? withHeadlessDeps # AV1 decoder (focused on speed and correctness) -, withDc1394 ? withFullDeps && !stdenv.hostPlatform.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 ? withHeadlessDeps # 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 -, withIlbc ? withFullDeps # iLBC de/encoding -, withJack ? withFullDeps && !stdenv.hostPlatform.isDarwin # Jack audio -, withJxl ? withFullDeps && lib.versionAtLeast version "5" # JPEG XL de/encoding -, withKvazaar ? withFullDeps # HEVC encoding -, withLadspa ? withFullDeps # LADSPA audio filtering -, withLc3 ? withFullDeps && lib.versionAtLeast version "7.1" # LC3 de/encoding -, withLcevcdec ? false && lib.versionAtLeast version "7.1" # LCEVC decoding # FIXME currently makes ffmpeg crash in any operation on non-AVX CPUs -, withLcms2 ? withFullDeps # ICC profile support via lcms2 -, withLzma ? withHeadlessDeps # xz-utils -, withMetal ? false # Unfree and requires manual downloading of files -, withMfx ? withFullDeps && (with stdenv.hostPlatform; isLinux && !isAarch) # Hardware acceleration via intel-media-sdk/libmfx -, withModplug ? withFullDeps && !stdenv.hostPlatform.isDarwin # ModPlug support -, withMp3lame ? withHeadlessDeps # LAME MP3 encoder -, withMysofa ? withFullDeps # HRTF support via SOFAlizer -, withNpp ? withFullDeps && withUnfree && config.cudaSupport # Nvidia Performance Primitives-based code -, withNvdec ? withHeadlessDeps && withNvcodec -, withNvenc ? withHeadlessDeps && withNvcodec -, withOpenal ? withFullDeps # OpenAL 1.1 capture support -, withOpencl ? withHeadlessDeps -, withOpencoreAmrnb ? withFullDeps && withVersion3 # AMR-NB de/encoder -, withOpencoreAmrwb ? withFullDeps && withVersion3 # AMR-WB decoder -, withOpengl ? withFullDeps && !stdenv.hostPlatform.isDarwin # OpenGL rendering -, withOpenh264 ? withFullDeps # H.264/AVC encoder -, withOpenjpeg ? withHeadlessDeps # JPEG 2000 de/encoder -, withOpenmpt ? withHeadlessDeps # Tracked music files decoder -, withOpus ? withHeadlessDeps # Opus de/encoder -, withPlacebo ? withFullDeps && !stdenv.hostPlatform.isDarwin # libplacebo video processing library -, withPulse ? withSmallDeps && stdenv.hostPlatform.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) -, withRist ? withHeadlessDeps # Reliable Internet Stream Transport (RIST) protocol -, withRtmp ? withFullDeps # RTMP[E] support -, withRubberband ? withFullDeps && withGPL # Rubberband filter -, withSamba ? withFullDeps && !stdenv.hostPlatform.isDarwin && withGPLv3 # Samba protocol -, withSdl2 ? withSmallDeps -, withShaderc ? withFullDeps && !stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "5.0" -, withShine ? withFullDeps # Fixed-point MP3 encoding -, withSnappy ? withFullDeps # Snappy compression, needed for hap encoding -, 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.hostPlatform.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 -, withTwolame ? withFullDeps # MP2 encoding -, withV4l2 ? withHeadlessDeps && stdenv.hostPlatform.isLinux # Video 4 Linux support -, withV4l2M2m ? withV4l2 -, withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # Vaapi hardware acceleration -, withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW # Vdpau hardware acceleration -, withVidStab ? withHeadlessDeps && withGPL # Video stabilization -, withVmaf ? withFullDeps && !stdenv.hostPlatform.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 ? withHeadlessDeps && !stdenv.hostPlatform.isDarwin -, withVvenc ? withFullDeps && lib.versionAtLeast version "7.1" # H.266/VVC encoding -, withWebp ? withHeadlessDeps # 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.1" && !xevd.meta.broken # MPEG-5 EVC decoding -, withXeve ? withFullDeps && lib.versionAtLeast version "7.1" && !xeve.meta.broken # MPEG-5 EVC encoding -, withXlib ? withFullDeps # Xlib support -, withXml2 ? withHeadlessDeps # libxml2 support, for IMF and DASH demuxers -, withXvid ? withHeadlessDeps && withGPL # Xvid encoder, native encoder exists -, withZimg ? withHeadlessDeps -, withZlib ? withHeadlessDeps -, withZmq ? withFullDeps # Message passing -, withZvbi ? withHeadlessDeps # Teletext support + withAlsa ? withHeadlessDeps && stdenv.hostPlatform.isLinux, # Alsa in/output supporT + withAmf ? withHeadlessDeps && lib.meta.availableOn stdenv.hostPlatform amf, # AMD Media Framework video encoding + withAom ? withHeadlessDeps, # AV1 reference encoder + withAribb24 ? withFullDeps, # ARIB text and caption decoding + withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1", # ARIB STD-B24 Caption Decoder/Renderer + withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform, # (Advanced) SubStation Alpha subtitle rendering + withAvisynth ? withFullDeps, # AviSynth script files reading + withBluray ? withHeadlessDeps, # BluRay reading + withBs2b ? withFullDeps, # bs2b DSP library + withBzlib ? withHeadlessDeps, + withCaca ? withFullDeps, # Textual display (ASCII art) + withCdio ? withFullDeps && withGPL, # Audio CD grabbing + withCelt ? withHeadlessDeps, # CELT decoder + withChromaprint ? withFullDeps, # Audio fingerprinting + withCodec2 ? withFullDeps, # codec2 en/decoding + withCuda ? withFullDeps && withNvcodec, + withCudaLLVM ? withHeadlessDeps, + withCudaNVCC ? withFullDeps && withUnfree && config.cudaSupport, + withCuvid ? withHeadlessDeps && withNvcodec, + withDav1d ? withHeadlessDeps, # AV1 decoder (focused on speed and correctness) + withDc1394 ? withFullDeps && !stdenv.hostPlatform.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 ? withHeadlessDeps, # 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, + withIlbc ? withFullDeps, # iLBC de/encoding + withJack ? withFullDeps && !stdenv.hostPlatform.isDarwin, # Jack audio + withJxl ? withFullDeps && lib.versionAtLeast version "5", # JPEG XL de/encoding + withKvazaar ? withFullDeps, # HEVC encoding + withLadspa ? withFullDeps, # LADSPA audio filtering + withLc3 ? withFullDeps && lib.versionAtLeast version "7.1", # LC3 de/encoding + withLcevcdec ? false && lib.versionAtLeast version "7.1", # LCEVC decoding # FIXME currently makes ffmpeg crash in any operation on non-AVX CPUs + withLcms2 ? withFullDeps, # ICC profile support via lcms2 + withLzma ? withHeadlessDeps, # xz-utils + withMetal ? false, # Unfree and requires manual downloading of files + withMfx ? withFullDeps && (with stdenv.hostPlatform; isLinux && !isAarch), # Hardware acceleration via intel-media-sdk/libmfx + withModplug ? withFullDeps && !stdenv.hostPlatform.isDarwin, # ModPlug support + withMp3lame ? withHeadlessDeps, # LAME MP3 encoder + withMysofa ? withFullDeps, # HRTF support via SOFAlizer + withNpp ? withFullDeps && withUnfree && config.cudaSupport, # Nvidia Performance Primitives-based code + withNvdec ? withHeadlessDeps && withNvcodec, + withNvenc ? withHeadlessDeps && withNvcodec, + withOpenal ? withFullDeps, # OpenAL 1.1 capture support + withOpencl ? withHeadlessDeps, + withOpencoreAmrnb ? withFullDeps && withVersion3, # AMR-NB de/encoder + withOpencoreAmrwb ? withFullDeps && withVersion3, # AMR-WB decoder + withOpengl ? withFullDeps && !stdenv.hostPlatform.isDarwin, # OpenGL rendering + withOpenh264 ? withFullDeps, # H.264/AVC encoder + withOpenjpeg ? withHeadlessDeps, # JPEG 2000 de/encoder + withOpenmpt ? withHeadlessDeps, # Tracked music files decoder + withOpus ? withHeadlessDeps, # Opus de/encoder + withPlacebo ? withFullDeps && !stdenv.hostPlatform.isDarwin, # libplacebo video processing library + withPulse ? withSmallDeps && stdenv.hostPlatform.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) + withRist ? withHeadlessDeps, # Reliable Internet Stream Transport (RIST) protocol + withRtmp ? withFullDeps, # RTMP[E] support + withRubberband ? withFullDeps && withGPL && !stdenv.hostPlatform.isFreeBSD, # Rubberband filter + withSamba ? withFullDeps && !stdenv.hostPlatform.isDarwin && withGPLv3, # Samba protocol + withSdl2 ? withSmallDeps, + withShaderc ? withFullDeps && !stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "5.0", + withShine ? withFullDeps, # Fixed-point MP3 encoding + withSnappy ? withFullDeps, # Snappy compression, needed for hap encoding + 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.hostPlatform.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 + withTwolame ? withFullDeps, # MP2 encoding + withV4l2 ? withHeadlessDeps && stdenv.hostPlatform.isLinux, # Video 4 Linux support + withV4l2M2m ? withV4l2, + withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD), # Vaapi hardware acceleration + withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW, # Vdpau hardware acceleration + withVidStab ? withHeadlessDeps && withGPL, # Video stabilization + withVmaf ? withFullDeps && !stdenv.hostPlatform.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 ? withHeadlessDeps && !stdenv.hostPlatform.isDarwin, + withVvenc ? withFullDeps && lib.versionAtLeast version "7.1", # H.266/VVC encoding + withWebp ? withHeadlessDeps, # 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.1" && !xevd.meta.broken, # MPEG-5 EVC decoding + withXeve ? withFullDeps && lib.versionAtLeast version "7.1" && !xeve.meta.broken, # MPEG-5 EVC encoding + withXlib ? withFullDeps, # Xlib support + withXml2 ? withHeadlessDeps, # libxml2 support, for IMF and DASH demuxers + withXvid ? withHeadlessDeps && withGPL, # Xvid encoder, native encoder exists + withZimg ? withHeadlessDeps, + withZlib ? withHeadlessDeps, + withZmq ? withFullDeps, # Message passing + withZvbi ? withHeadlessDeps, # Teletext support -/* - * 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 + # 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 + # 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 - */ -, 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 -/* - * 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 - || buildAvdevice - || buildAvfilter - || buildAvformat - || buildAvutil - || buildPostproc - || buildSwresample - || buildSwscale -/* - * Documentation options - */ -, withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc -, 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) + # Program options + 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, + # 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 + || buildAvdevice + || buildAvfilter + || buildAvformat + || buildAvutil + || buildPostproc + || buildSwresample + || buildSwscale, + # Documentation options + withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc, + 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 + # Developer options + withDebug ? false, + withOptimisations ? true, + withExtraWarnings ? false, + withStripping ? false, -/* - * External libraries options - */ -, alsa-lib -, amf -, amf-headers -, aribb24 -, avisynthplus -, bzip2 -, celt -, chromaprint -, codec2 -, clang -, dav1d -, fdk_aac -, flite -, fontconfig -, freetype -, frei0r -, fribidi -, game-music-emu -, gnutls -, gsm -, harfbuzz -, intel-media-sdk -, kvazaar -, ladspaH -, lame -, lcevcdec -, lcms2 -, libaom -, libaribcaption -, libass -, libbluray -, libbs2b -, libcaca -, libcdio -, libcdio-paranoia -, libdc1394 -, libdrm -, libdvdnav -, libdvdread -, libGL -, libGLU -, libiconv -, libilbc -, libjack2 -, libjxl -, liblc3 -, libmodplug -, libmysofa -, libopenmpt -, libopus -, libplacebo -, libplacebo_5 -, libpulseaudio -, libraw1394 -, librist -, librsvg -, libssh -, libtensorflow -, libtheora -, libv4l -, libva -, libva-minimal -, libvdpau -, libvmaf -, libvorbis -, libvpl -, libvpx -, libwebp -, libX11 -, libxcb -, libXext -, libxml2 -, libXv -, nv-codec-headers -, nv-codec-headers-12 -, ocl-icd # OpenCL ICD -, openal -, opencl-headers # OpenCL headers -, opencore-amr -, openh264 -, openjpeg -, qrencode -, quirc -, rav1e -, rtmpdump -, rubberband -, twolame -, samba -, SDL2 -, shaderc -, shine -, snappy -, soxr -, speex -, srt -, svt-av1 -, vid-stab -, vo-amrwbenc -, vulkan-headers -, vulkan-loader -, vvenc -, x264 -, x265 -, xavs -, xevd -, xeve -, xvidcore -, xz -, zeromq -, zimg -, zlib -, zvbi -/* - * Darwin - */ -, apple-sdk_15 -, xcode # unfree contains metalcc and metallib -/* - * Cuda Packages - */ -, cuda_cudart -, cuda_nvcc -, libnpp -/* - * Testing - */ -, testers + # External libraries options + alsa-lib, + amf, + amf-headers, + aribb24, + avisynthplus, + bzip2, + celt, + chromaprint, + codec2, + clang, + dav1d, + fdk_aac, + flite, + fontconfig, + freetype, + frei0r, + fribidi, + game-music-emu, + gnutls, + gsm, + harfbuzz, + intel-media-sdk, + kvazaar, + ladspaH, + lame, + lcevcdec, + lcms2, + libaom, + libaribcaption, + libass, + libbluray, + libbs2b, + libcaca, + libcdio, + libcdio-paranoia, + libdc1394, + libdrm, + libdvdnav, + libdvdread, + libGL, + libGLU, + libiconv, + libilbc, + libjack2, + libjxl, + liblc3, + libmodplug, + libmysofa, + libopenmpt, + libopus, + libplacebo, + libplacebo_5, + libpulseaudio, + libraw1394, + librist, + librsvg, + libssh, + libtensorflow, + libtheora, + libv4l, + libva, + libva-minimal, + libvdpau, + libvmaf, + libvorbis, + libvpl, + libvpx, + libwebp, + libX11, + libxcb, + libXext, + libxml2, + libXv, + nv-codec-headers, + nv-codec-headers-12, + ocl-icd, # OpenCL ICD + openal, + opencl-headers, # OpenCL headers + opencore-amr, + openh264, + openjpeg, + qrencode, + quirc, + rav1e, + rtmpdump, + rubberband, + twolame, + samba, + SDL2, + shaderc, + shine, + snappy, + soxr, + speex, + srt, + svt-av1, + vid-stab, + vo-amrwbenc, + vulkan-headers, + vulkan-loader, + vvenc, + x264, + x265, + xavs, + xevd, + xeve, + xvidcore, + xz, + zeromq, + zimg, + zlib, + zvbi, + # Darwin + apple-sdk_15, + xcode, # unfree contains metalcc and metallib + # Cuda Packages + cuda_cudart, + cuda_nvcc, + libnpp, + # Testing + testers, }: -/* Maintainer notes: - * - * Version bumps: - * It should always be safe to bump patch releases (e.g. 2.1.x, x being a patch release) - * If adding a new branch, note any configure flags that were added, changed, or deprecated/removed - * and make the necessary changes. - * - * Known issues: - * Cross-compiling will disable features not present on host OS - * (e.g. dxva2 support [DirectX] will not be enabled unless natively compiled on Cygwin) - * - */ +/* + Maintainer notes: + + Version bumps: + It should always be safe to bump patch releases (e.g. 2.1.x, x being a patch release) + If adding a new branch, note any configure flags that were added, changed, or deprecated/removed + and make the necessary changes. + + Known issues: + Cross-compiling will disable features not present on host OS + (e.g. dxva2 support [DirectX] will not be enabled unless natively compiled on Cygwin) +*/ let - inherit (lib) optional optionals optionalString enableFeature versionOlder versionAtLeast; + inherit (lib) + optional + optionals + optionalString + enableFeature + versionOlder + versionAtLeast + ; in +assert lib.elem ffmpegVariant [ + "headless" + "small" + "full" +]; -assert lib.elem ffmpegVariant [ "headless" "small" "full" ]; - -/* - * Licensing dependencies - */ +# Licensing dependencies assert withGPLv3 -> withGPL && withVersion3; -/* - * Build dependencies - */ +# 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); +# Program dependencies +assert + buildFfmpeg + -> buildAvcodec && buildAvfilter && buildAvformat && (buildSwresample || buildAvresample); +assert + buildFfplay + -> buildAvcodec && buildAvformat && buildSwscale && (buildSwresample || buildAvresample); assert buildFfprobe -> buildAvcodec && buildAvformat; -/* - * Library dependencies - */ +# Library dependencies assert buildAvcodec -> buildAvutil; # configure flag since 0.6 -assert buildAvdevice -> buildAvformat - && 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; -/* - * External Library dependencies - */ -assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; +# External Library dependencies +assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; -stdenv.mkDerivation (finalAttrs: { - pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); - inherit version; - src = source; +stdenv.mkDerivation ( + finalAttrs: + { + pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); + inherit version; + src = source; - postPatch = '' - patchShebangs . - '' + lib.optionalString withFrei0r '' - substituteInPlace libavfilter/vf_frei0r.c \ - --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 - substituteInPlace doc/filters.texi \ - --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 - ''; + postPatch = + '' + patchShebangs . + '' + + lib.optionalString withFrei0r '' + substituteInPlace libavfilter/vf_frei0r.c \ + --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 + substituteInPlace doc/filters.texi \ + --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 + ''; - patches = [] - ++ optionals (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") [ - (fetchpatch2 { # this can be removed post 6.1 - name = "fix_build_failure_due_to_PropertyKey_EncoderID"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/cb049d377f54f6b747667a93e4b719380c3e9475"; - hash = "sha256-sxRXKKgUak5vsQTiV7ge8vp+N22CdTIvuczNgVRP72c="; - }) - (fetchpatch2 { - name = "CVE-2024-31582.patch"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/99debe5f823f45a482e1dc08de35879aa9c74bd2"; - hash = "sha256-+CQ9FXR6Vr/AmsbXFiCUXZcxKj1s8nInEdke/Oc/kUA="; - }) - (fetchpatch2 { - name = "CVE-2024-31578.patch"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/3bb00c0a420c3ce83c6fafee30270d69622ccad7"; - hash = "sha256-oZMZysBA+/gwaGEM1yvI+8wCadXWE7qLRL6Emap3b8Q="; - }) - (fetchpatch2 { - name = "CVE-2023-49501.patch"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/4adb93dff05dd947878c67784d98c9a4e13b57a7"; - hash = "sha256-7cwktto3fPMDGvCZCVtB01X8Q9S/4V4bDLUICSNfGgw="; - }) - (fetchpatch2 { - name = "CVE-2023-49502.patch"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/737ede405b11a37fdd61d19cf25df296a0cb0b75"; - hash = "sha256-mpSJwR9TX5ENjjCKvzuM/9e1Aj/AOiQW0+72oOMl9v8="; - }) - (fetchpatch2 { - name = "CVE-2023-50007.patch"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/b1942734c7cbcdc9034034373abcc9ecb9644c47"; - hash = "sha256-v0hNcqBtm8GCGAU9UbRUCE0slodOjZCHrkS8e4TrVcQ="; - }) - (fetchpatch2 { - name = "CVE-2023-50008.patch"; - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/5f87a68cf70dafeab2fb89b42e41a4c29053b89b"; - hash = "sha256-sqUUSOPTPLwu2h8GbAw4SfEf+0oWioz52BcpW1n4v3Y="; - }) - ] - ++ optionals (lib.versionAtLeast version "7.1") [ - ./fix-fate-ffmpeg-spec-disposition-7.1.patch + patches = + [ ] + ++ optionals (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") [ + (fetchpatch2 { + # this can be removed post 6.1 + name = "fix_build_failure_due_to_PropertyKey_EncoderID"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/cb049d377f54f6b747667a93e4b719380c3e9475"; + hash = "sha256-sxRXKKgUak5vsQTiV7ge8vp+N22CdTIvuczNgVRP72c="; + }) + (fetchpatch2 { + name = "CVE-2024-31582.patch"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/99debe5f823f45a482e1dc08de35879aa9c74bd2"; + hash = "sha256-+CQ9FXR6Vr/AmsbXFiCUXZcxKj1s8nInEdke/Oc/kUA="; + }) + (fetchpatch2 { + name = "CVE-2024-31578.patch"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/3bb00c0a420c3ce83c6fafee30270d69622ccad7"; + hash = "sha256-oZMZysBA+/gwaGEM1yvI+8wCadXWE7qLRL6Emap3b8Q="; + }) + (fetchpatch2 { + name = "CVE-2023-49501.patch"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/4adb93dff05dd947878c67784d98c9a4e13b57a7"; + hash = "sha256-7cwktto3fPMDGvCZCVtB01X8Q9S/4V4bDLUICSNfGgw="; + }) + (fetchpatch2 { + name = "CVE-2023-49502.patch"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/737ede405b11a37fdd61d19cf25df296a0cb0b75"; + hash = "sha256-mpSJwR9TX5ENjjCKvzuM/9e1Aj/AOiQW0+72oOMl9v8="; + }) + (fetchpatch2 { + name = "CVE-2023-50007.patch"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/b1942734c7cbcdc9034034373abcc9ecb9644c47"; + hash = "sha256-v0hNcqBtm8GCGAU9UbRUCE0slodOjZCHrkS8e4TrVcQ="; + }) + (fetchpatch2 { + name = "CVE-2023-50008.patch"; + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/5f87a68cf70dafeab2fb89b42e41a4c29053b89b"; + hash = "sha256-sqUUSOPTPLwu2h8GbAw4SfEf+0oWioz52BcpW1n4v3Y="; + }) + ] + ++ optionals (lib.versionAtLeast version "7.1") [ + ./fix-fate-ffmpeg-spec-disposition-7.1.patch - # Expose a private API for Chromium / Qt WebEngine. - (fetchpatch2 { - url = "https://gitlab.archlinux.org/archlinux/packaging/packages/ffmpeg/-/raw/a02c1a15706ea832c0d52a4d66be8fb29499801a/add-av_stream_get_first_dts-for-chromium.patch"; - hash = "sha256-DbH6ieJwDwTjKOdQ04xvRcSLeeLP2Z2qEmqeo8HsPr4="; - }) - ]; + # Expose a private API for Chromium / Qt WebEngine. + (fetchpatch2 { + url = "https://gitlab.archlinux.org/archlinux/packaging/packages/ffmpeg/-/raw/a02c1a15706ea832c0d52a4d66be8fb29499801a/add-av_stream_get_first_dts-for-chromium.patch"; + hash = "sha256-DbH6ieJwDwTjKOdQ04xvRcSLeeLP2Z2qEmqeo8HsPr4="; + }) + ]; - configurePlatforms = []; - setOutputFlags = false; # Only accepts some of them - 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}" - "--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") + configurePlatforms = [ ]; + setOutputFlags = false; # Only accepts some of them + 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}" + "--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 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 (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") + (enableFeature withNetwork "network") + (enableFeature withPixelutils "pixelutils") - "--datadir=${placeholder "data"}/share/ffmpeg" + "--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" - ] ++ [ - /* - * External libraries - */ - (enableFeature withAlsa "alsa") - (enableFeature withAmf "amf") - (enableFeature withAom "libaom") - (enableFeature withAribb24 "libaribb24") - ] ++ optionals (versionAtLeast version "6.1") [ - (enableFeature withAribcaption "libaribcaption") - ] ++ [ - (enableFeature withAss "libass") - (enableFeature withAvisynth "avisynth") - (enableFeature withBluray "libbluray") - (enableFeature withBs2b "libbs2b") - (enableFeature withBzlib "bzlib") - (enableFeature withCaca "libcaca") - (enableFeature withCdio "libcdio") - (enableFeature withCelt "libcelt") - (enableFeature withChromaprint "chromaprint") - (enableFeature withCodec2 "libcodec2") - (enableFeature withCuda "cuda") - (enableFeature withCudaLLVM "cuda-llvm") - (enableFeature withCudaNVCC "cuda-nvcc") - (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 withIlbc "libilbc") - (enableFeature withJack "libjack") - ] ++ optionals (versionAtLeast finalAttrs.version "5.0") [ - (enableFeature withJxl "libjxl") - ] ++ [ - (enableFeature withKvazaar "libkvazaar") - (enableFeature withLadspa "ladspa") - ] ++ optionals (versionAtLeast version "7.1") [ - (enableFeature withLc3 "liblc3") - (enableFeature withLcevcdec "liblcevc-dec") - ] ++ optionals (versionAtLeast version "5.1") [ - (enableFeature withLcms2 "lcms2") - ] ++ [ - (enableFeature withLzma "lzma") - ] ++ optionals (versionAtLeast version "5.0") [ - (enableFeature withMetal "metal") - ] ++ [ - (enableFeature withMfx "libmfx") - (enableFeature withModplug "libmodplug") - (enableFeature withMp3lame "libmp3lame") - (enableFeature withMysofa "libmysofa") - (enableFeature withNpp "libnpp") - (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 withRist "librist") - (enableFeature withRtmp "librtmp") - (enableFeature withRubberband "librubberband") - (enableFeature withSamba "libsmbclient") - (enableFeature withSdl2 "sdl2") - ] ++ optionals (versionAtLeast version "5.0") [ - (enableFeature withShaderc "libshaderc") - ] ++ [ - (enableFeature withShine "libshine") - (enableFeature withSnappy "libsnappy") - (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 withTwolame "libtwolame") - (enableFeature withV4l2 "libv4l2") - (enableFeature withV4l2M2m "v4l2-m2m") - (enableFeature withVaapi "vaapi") - (enableFeature withVdpau "vdpau") - ] ++ optionals (versionAtLeast version "6.0") [ - (enableFeature withVpl "libvpl") - ] ++ [ - (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 - (enableFeature withVmaf "libvmaf") - (enableFeature withVoAmrwbenc "libvo-amrwbenc") - (enableFeature withVorbis "libvorbis") - (enableFeature withVpx "libvpx") - (enableFeature withVulkan "vulkan") - ] ++ optionals (versionAtLeast version "7.1") [ - (enableFeature withVvenc "libvvenc") - ] ++ [ - (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") - (enableFeature withZvbi "libzvbi") - /* - * 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" - "--host-cc=${buildPackages.stdenv.cc}/bin/cc" - ] ++ optionals stdenv.cc.isClang [ - "--cc=${stdenv.cc.targetPrefix}clang" - "--cxx=${stdenv.cc.targetPrefix}clang++" - ] ++ optionals withMetal [ - "--metalcc=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal" - "--metallib=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metallib" - ]; + # 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" + ] + ++ [ + # External libraries + (enableFeature withAlsa "alsa") + (enableFeature withAmf "amf") + (enableFeature withAom "libaom") + (enableFeature withAribb24 "libaribb24") + ] + ++ optionals (versionAtLeast version "6.1") [ + (enableFeature withAribcaption "libaribcaption") + ] + ++ [ + (enableFeature withAss "libass") + (enableFeature withAvisynth "avisynth") + (enableFeature withBluray "libbluray") + (enableFeature withBs2b "libbs2b") + (enableFeature withBzlib "bzlib") + (enableFeature withCaca "libcaca") + (enableFeature withCdio "libcdio") + (enableFeature withCelt "libcelt") + (enableFeature withChromaprint "chromaprint") + (enableFeature withCodec2 "libcodec2") + (enableFeature withCuda "cuda") + (enableFeature withCudaLLVM "cuda-llvm") + (enableFeature withCudaNVCC "cuda-nvcc") + (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 withIlbc "libilbc") + (enableFeature withJack "libjack") + ] + ++ optionals (versionAtLeast finalAttrs.version "5.0") [ + (enableFeature withJxl "libjxl") + ] + ++ [ + (enableFeature withKvazaar "libkvazaar") + (enableFeature withLadspa "ladspa") + ] + ++ optionals (versionAtLeast version "7.1") [ + (enableFeature withLc3 "liblc3") + (enableFeature withLcevcdec "liblcevc-dec") + ] + ++ optionals (versionAtLeast version "5.1") [ + (enableFeature withLcms2 "lcms2") + ] + ++ [ + (enableFeature withLzma "lzma") + ] + ++ optionals (versionAtLeast version "5.0") [ + (enableFeature withMetal "metal") + ] + ++ [ + (enableFeature withMfx "libmfx") + (enableFeature withModplug "libmodplug") + (enableFeature withMp3lame "libmp3lame") + (enableFeature withMysofa "libmysofa") + (enableFeature withNpp "libnpp") + (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 withRist "librist") + (enableFeature withRtmp "librtmp") + (enableFeature withRubberband "librubberband") + (enableFeature withSamba "libsmbclient") + (enableFeature withSdl2 "sdl2") + ] + ++ optionals (versionAtLeast version "5.0") [ + (enableFeature withShaderc "libshaderc") + ] + ++ [ + (enableFeature withShine "libshine") + (enableFeature withSnappy "libsnappy") + (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 withTwolame "libtwolame") + (enableFeature withV4l2 "libv4l2") + (enableFeature withV4l2M2m "v4l2-m2m") + (enableFeature withVaapi "vaapi") + (enableFeature withVdpau "vdpau") + ] + ++ optionals (versionAtLeast version "6.0") [ + (enableFeature withVpl "libvpl") + ] + ++ [ + (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 + (enableFeature withVmaf "libvmaf") + (enableFeature withVoAmrwbenc "libvo-amrwbenc") + (enableFeature withVorbis "libvorbis") + (enableFeature withVpx "libvpx") + (enableFeature withVulkan "vulkan") + ] + ++ optionals (versionAtLeast version "7.1") [ + (enableFeature withVvenc "libvvenc") + ] + ++ [ + (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") + (enableFeature withZvbi "libzvbi") + # 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" + "--host-cc=${buildPackages.stdenv.cc}/bin/cc" + ] + ++ optionals stdenv.cc.isClang [ + "--cc=${stdenv.cc.targetPrefix}clang" + "--cxx=${stdenv.cc.targetPrefix}clang++" + ] + ++ optionals withMetal [ + "--metalcc=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal" + "--metallib=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metallib" + ]; - # ffmpeg embeds the configureFlags verbatim in its binaries and because we - # configure binary, include, library dir etc., this causes references in - # outputs where we don't want them. Patch the generated config.h to remove all - # such references except for data. - postConfigure = let - toStrip = map placeholder (lib.remove "data" finalAttrs.outputs) # We want to keep references to the data dir. - ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.stdenv.cc - ++ lib.optional withMetal xcode; - in - "remove-references-to ${lib.concatStringsSep " " (map (o: "-t ${o}") toStrip)} config.h"; + # ffmpeg embeds the configureFlags verbatim in its binaries and because we + # configure binary, include, library dir etc., this causes references in + # outputs where we don't want them. Patch the generated config.h to remove all + # such references except for data. + postConfigure = + let + toStrip = + map placeholder (lib.remove "data" finalAttrs.outputs) # We want to keep references to the data dir. + ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.stdenv.cc + ++ lib.optional withMetal xcode; + in + "remove-references-to ${lib.concatStringsSep " " (map (o: "-t ${o}") toStrip)} config.h"; - strictDeps = true; + strictDeps = true; - nativeBuildInputs = [ removeReferencesTo addDriverRunpath perl pkg-config yasm ] - # Texinfo version 7.1 introduced breaking changes, which older versions of ffmpeg do not handle. - ++ (if versionOlder version "5" then [ texinfo6 ] else [ texinfo ]) - ++ optionals withCudaLLVM [ clang ] - ++ optionals withCudaNVCC [ cuda_nvcc ]; + nativeBuildInputs = + [ + removeReferencesTo + addDriverRunpath + perl + pkg-config + yasm + ] + # Texinfo version 7.1 introduced breaking changes, which older versions of ffmpeg do not handle. + ++ (if versionOlder version "5" then [ texinfo6 ] else [ texinfo ]) + ++ optionals withCudaLLVM [ clang ] + ++ optionals withCudaNVCC [ cuda_nvcc ]; - buildInputs = [] - ++ optionals stdenv.hostPlatform.isDarwin [ apple-sdk_15 ] - ++ optionals withAlsa [ alsa-lib ] - ++ optionals withAmf [ amf-headers ] - ++ optionals withAom [ libaom ] - ++ optionals withAribb24 [ aribb24 ] - ++ optionals withAribcaption [ libaribcaption ] - ++ optionals withAss [ libass ] - ++ optionals withAvisynth [ avisynthplus ] - ++ optionals withBluray [ libbluray ] - ++ optionals withBs2b [ libbs2b ] - ++ optionals withBzlib [ bzip2 ] - ++ optionals withCaca [ libcaca ] - ++ optionals withCdio [ libcdio libcdio-paranoia ] - ++ optionals withCelt [ celt ] - ++ optionals withChromaprint [ chromaprint ] - ++ optionals withCodec2 [ codec2 ] - ++ optionals withCudaNVCC [ cuda_cudart cuda_nvcc ] - ++ 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 withIlbc [ libilbc ] - ++ optionals withJack [ libjack2 ] - ++ optionals withJxl [ libjxl ] - ++ optionals withKvazaar [ kvazaar ] - ++ optionals withLadspa [ ladspaH ] - ++ optionals withLc3 [ liblc3 ] - ++ optionals withLcevcdec [ lcevcdec ] - ++ optionals withLcms2 [ lcms2 ] - ++ optionals withLzma [ xz ] - ++ optionals withMfx [ intel-media-sdk ] - ++ optionals withModplug [ libmodplug ] - ++ optionals withMp3lame [ lame ] - ++ optionals withMysofa [ libmysofa ] - ++ optionals withNpp [ libnpp cuda_cudart cuda_nvcc ] - ++ 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 withRist [ librist ] - ++ optionals withRtmp [ rtmpdump ] - ++ optionals withRubberband [ rubberband ] - ++ optionals withSamba [ samba ] - ++ optionals withSdl2 [ SDL2 ] - ++ optionals withShaderc [ shaderc ] - ++ optionals withShine [ shine ] - ++ optionals withSnappy [ snappy ] - ++ 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 withTwolame [ twolame ] - ++ optionals withV4l2 [ libv4l ] - ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] - ++ optionals withVdpau [ libvdpau ] - ++ 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 withVvenc [ vvenc ] - ++ 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 [ zeromq ] - ++ optionals withZvbi [ zvbi ] - ; + buildInputs = + [ ] + ++ optionals stdenv.hostPlatform.isDarwin [ apple-sdk_15 ] + ++ optionals withAlsa [ alsa-lib ] + ++ optionals withAmf [ amf-headers ] + ++ optionals withAom [ libaom ] + ++ optionals withAribb24 [ aribb24 ] + ++ optionals withAribcaption [ libaribcaption ] + ++ optionals withAss [ libass ] + ++ optionals withAvisynth [ avisynthplus ] + ++ optionals withBluray [ libbluray ] + ++ optionals withBs2b [ libbs2b ] + ++ optionals withBzlib [ bzip2 ] + ++ optionals withCaca [ libcaca ] + ++ optionals withCdio [ + libcdio + libcdio-paranoia + ] + ++ optionals withCelt [ celt ] + ++ optionals withChromaprint [ chromaprint ] + ++ optionals withCodec2 [ codec2 ] + ++ optionals withCudaNVCC [ + cuda_cudart + cuda_nvcc + ] + ++ optionals withDav1d [ dav1d ] + ++ optionals withDc1394 ([ libdc1394 ] ++ (lib.optional stdenv.hostPlatform.isLinux 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 withIlbc [ libilbc ] + ++ optionals withJack [ libjack2 ] + ++ optionals withJxl [ libjxl ] + ++ optionals withKvazaar [ kvazaar ] + ++ optionals withLadspa [ ladspaH ] + ++ optionals withLc3 [ liblc3 ] + ++ optionals withLcevcdec [ lcevcdec ] + ++ optionals withLcms2 [ lcms2 ] + ++ optionals withLzma [ xz ] + ++ optionals withMfx [ intel-media-sdk ] + ++ optionals withModplug [ libmodplug ] + ++ optionals withMp3lame [ lame ] + ++ optionals withMysofa [ libmysofa ] + ++ optionals withNpp [ + libnpp + cuda_cudart + cuda_nvcc + ] + ++ 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 withRist [ librist ] + ++ optionals withRtmp [ rtmpdump ] + ++ optionals withRubberband [ rubberband ] + ++ optionals withSamba [ samba ] + ++ optionals withSdl2 [ SDL2 ] + ++ optionals withShaderc [ shaderc ] + ++ optionals withShine [ shine ] + ++ optionals withSnappy [ snappy ] + ++ 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 withTwolame [ twolame ] + ++ optionals withV4l2 [ libv4l ] + ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] + ++ optionals withVdpau [ libvdpau ] + ++ 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 withVvenc [ vvenc ] + ++ 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 [ zeromq ] + ++ optionals withZvbi [ zvbi ]; - buildFlags = [ "all" ] - ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable + buildFlags = [ "all" ] ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable - env = lib.optionalAttrs stdenv.cc.isGNU { - NIX_CFLAGS_COMPILE = toString [ - "-Wno-error=incompatible-pointer-types" - "-Wno-error=int-conversion" - ]; - }; + env = lib.optionalAttrs stdenv.cc.isGNU { + NIX_CFLAGS_COMPILE = toString [ + "-Wno-error=incompatible-pointer-types" + "-Wno-error=int-conversion" + ]; + }; - doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; - # Fails with SIGABRT otherwise FIXME: Why? - checkPhase = let - ldLibraryPathEnv = if stdenv.hostPlatform.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" + # Fails with SIGABRT otherwise FIXME: Why? + checkPhase = + let + ldLibraryPathEnv = if stdenv.hostPlatform.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"; + in + '' + ${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" ] + ++ optionals withManPages [ "man" ] + ++ [ + "data" + "out" + ] # We need an "out" output because we get an error otherwise. It's just an empty dir. ; - in '' - ${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" ] - ++ optionals withManPages [ "man" ] - ++ [ "data" "out" ] # We need an "out" output because we get an error otherwise. It's just an empty dir. - ; - - postInstall = optionalString buildQtFaststart '' - install -D tools/qt-faststart -t $bin/bin - ''; - - # Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found. - # See the explanation in addDriverRunpath. - postFixup = optionalString (stdenv.hostPlatform.isLinux && withLib) '' - addDriverRunpath ${placeholder "lib"}/lib/libavcodec.so - addDriverRunpath ${placeholder "lib"}/lib/libavutil.so - '' - # https://trac.ffmpeg.org/ticket/10809 - + optionalString (versionAtLeast version "5.0" && withVulkan && !stdenv.hostPlatform.isMinGW) '' - patchelf $lib/lib/libavcodec.so --add-needed libvulkan.so --add-rpath ${lib.makeLibraryPath [ vulkan-loader ]} - ''; - - enableParallelBuilding = true; - - passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; - - meta = with lib; { - description = "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"; - longDescription = '' - FFmpeg is the leading multimedia framework, able to decode, encode, transcode, - mux, demux, stream, filter and play pretty much anything that humans and machines - have created. It supports the most obscure ancient formats up to the cutting edge. - No matter if they were designed by some standards committee, the community or - a corporation. + postInstall = optionalString buildQtFaststart '' + install -D tools/qt-faststart -t $bin/bin ''; - license = with licenses; [ lgpl21Plus ] - ++ optional withGPL gpl2Plus - ++ optional withVersion3 lgpl3Plus - ++ optional withGPLv3 gpl3Plus - ++ optional withUnfree unfreeRedistributable - ++ optional (withGPL && withUnfree) 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; - # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 - broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; - maintainers = with maintainers; [ atemu jopejoe1 emily ]; - mainProgram = "ffmpeg"; - }; -} // lib.optionalAttrs withCudaLLVM { - # remove once https://github.com/NixOS/nixpkgs/issues/318674 is addressed properly - hardeningDisable = [ "zerocallusedregs" ]; -}) + + # Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addDriverRunpath. + postFixup = + optionalString (stdenv.hostPlatform.isLinux && withLib) '' + addDriverRunpath ${placeholder "lib"}/lib/libavcodec.so + addDriverRunpath ${placeholder "lib"}/lib/libavutil.so + '' + # https://trac.ffmpeg.org/ticket/10809 + + optionalString (versionAtLeast version "5.0" && withVulkan && !stdenv.hostPlatform.isMinGW) '' + patchelf $lib/lib/libavcodec.so --add-needed libvulkan.so --add-rpath ${ + lib.makeLibraryPath [ vulkan-loader ] + } + ''; + + enableParallelBuilding = true; + + passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + + meta = with lib; { + description = "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"; + longDescription = '' + FFmpeg is the leading multimedia framework, able to decode, encode, transcode, + mux, demux, stream, filter and play pretty much anything that humans and machines + have created. It supports the most obscure ancient formats up to the cutting edge. + 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; + 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; + # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 + broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; + maintainers = with maintainers; [ + atemu + jopejoe1 + emily + ]; + mainProgram = "ffmpeg"; + }; + } + // lib.optionalAttrs withCudaLLVM { + # remove once https://github.com/NixOS/nixpkgs/issues/318674 is addressed properly + hardeningDisable = [ "zerocallusedregs" ]; + } +) diff --git a/pkgs/development/libraries/libdvdcss/default.nix b/pkgs/development/libraries/libdvdcss/default.nix index eeb7330f85a5..d0195e668993 100644 --- a/pkgs/development/libraries/libdvdcss/default.nix +++ b/pkgs/development/libraries/libdvdcss/default.nix @@ -20,6 +20,6 @@ stdenv.mkDerivation rec { homepage = "http://www.videolan.org/developers/libdvdcss.html"; description = "Library for decrypting DVDs"; license = licenses.gpl2; - platforms = with platforms; linux ++ darwin; + platforms = platforms.unix; }; } diff --git a/pkgs/development/libraries/libdvdread/default.nix b/pkgs/development/libraries/libdvdread/default.nix index 07ab45310504..5daa6063932f 100644 --- a/pkgs/development/libraries/libdvdread/default.nix +++ b/pkgs/development/libraries/libdvdread/default.nix @@ -27,6 +27,6 @@ stdenv.mkDerivation rec { description = "Library for reading DVDs"; license = lib.licenses.gpl2; maintainers = [ lib.maintainers.wmertens ]; - platforms = with lib.platforms; linux ++ darwin; + platforms = lib.platforms.unix; }; } diff --git a/pkgs/development/libraries/opencv/4.x.nix b/pkgs/development/libraries/opencv/4.x.nix index dd9a3fd73bb2..264fad638389 100644 --- a/pkgs/development/libraries/opencv/4.x.nix +++ b/pkgs/development/libraries/opencv/4.x.nix @@ -1,105 +1,113 @@ -{ lib -, stdenv -, fetchurl -, fetchFromGitHub -, cmake -, pkg-config -, unzip -, zlib -, pcre2 -, hdf5 -, boost -, glib -, glog -, gflags -, protobuf_29 -, config -, ocl-icd -, qimgv -, opencv4 +{ + lib, + stdenv, + fetchurl, + fetchFromGitHub, + cmake, + pkg-config, + unzip, + zlib, + pcre2, + hdf5, + boost, + glib, + glog, + gflags, + protobuf_29, + config, + ocl-icd, + qimgv, + opencv4, -, enableJPEG ? true -, libjpeg -, enablePNG ? true -, libpng -, enableTIFF ? true -, libtiff -, enableWebP ? true -, libwebp -, enableEXR ? !stdenv.hostPlatform.isDarwin -, openexr -, ilmbase -, enableJPEG2000 ? true -, openjpeg -, enableEigen ? true -, eigen -, enableBlas ? true -, blas -, enableVA ? !stdenv.hostPlatform.isDarwin -, libva -, enableContrib ? true + enableJPEG ? true, + libjpeg, + enablePNG ? true, + libpng, + enableTIFF ? true, + libtiff, + enableWebP ? true, + libwebp, + enableEXR ? !stdenv.hostPlatform.isDarwin, + openexr, + ilmbase, + enableJPEG2000 ? true, + openjpeg, + enableEigen ? true, + eigen, + enableBlas ? true, + blas, + enableVA ? !stdenv.hostPlatform.isDarwin, + libva, + enableContrib ? true, -, enableCuda ? config.cudaSupport -, enableCublas ? enableCuda -, enableCudnn ? false # NOTE: CUDNN has a large impact on closure size so we disable it by default -, enableCufft ? enableCuda -, cudaPackages -, nvidia-optical-flow-sdk + enableCuda ? config.cudaSupport, + enableCublas ? enableCuda, + enableCudnn ? false, # NOTE: CUDNN has a large impact on closure size so we disable it by default + enableCufft ? enableCuda, + cudaPackages, + nvidia-optical-flow-sdk, -, enableLto ? true -, enableUnfree ? false -, enableIpp ? false -, enablePython ? false -, pythonPackages -, enableGtk2 ? false -, gtk2 -, enableGtk3 ? false -, gtk3 -, enableVtk ? false -, vtk -, enableFfmpeg ? true -, ffmpeg -, enableGStreamer ? true -, elfutils -, gst_all_1 -, orc -, libunwind -, zstd -, enableTesseract ? false -, tesseract -, leptonica -, enableTbb ? false -, tbb -, enableOvis ? false -, ogre -, enableGPhoto2 ? false -, libgphoto2 -, enableDC1394 ? false -, libdc1394 -, enableDocs ? false -, doxygen -, graphviz-nox + enableLto ? true, + enableUnfree ? false, + enableIpp ? false, + enablePython ? false, + pythonPackages, + enableGtk2 ? false, + gtk2, + enableGtk3 ? false, + gtk3, + enableVtk ? false, + vtk, + enableFfmpeg ? true, + ffmpeg, + enableGStreamer ? true, + elfutils, + gst_all_1, + orc, + libunwind, + zstd, + enableTesseract ? false, + tesseract, + leptonica, + enableTbb ? false, + tbb, + enableOvis ? false, + ogre, + enableGPhoto2 ? false, + libgphoto2, + enableDC1394 ? false, + libdc1394, + enableDocs ? false, + doxygen, + graphviz-nox, -, runAccuracyTests ? true -, runPerformanceTests ? false -# Modules to enable via BUILD_LIST to build a customized opencv. -# An empty lists means this setting is omitted which matches upstreams default. -, enabledModules ? [ ] + runAccuracyTests ? true, + runPerformanceTests ? false, + # Modules to enable via BUILD_LIST to build a customized opencv. + # An empty lists means this setting is omitted which matches upstreams default. + enabledModules ? [ ], -, AVFoundation -, Cocoa -, VideoDecodeAcceleration -, CoreMedia -, MediaToolbox -, Accelerate -, bzip2 -, callPackage + AVFoundation, + Cocoa, + VideoDecodeAcceleration, + CoreMedia, + MediaToolbox, + Accelerate, + bzip2, + callPackage, }@inputs: let inherit (lib.attrsets) mapAttrsToList optionalAttrs; inherit (lib.lists) last optionals; - inherit (lib.strings) cmakeBool cmakeFeature cmakeOptionType concatStrings concatStringsSep optionalString; + inherit (lib.strings) + cmakeBool + cmakeFeature + cmakeOptionType + concatStrings + concatStringsSep + optionalString + ; inherit (lib.trivial) flip; version = "4.11.0"; @@ -135,13 +143,18 @@ let # See opencv/3rdparty/ippicv/ippicv.cmake ippicv = { - src = fetchFromGitHub { - owner = "opencv"; - repo = "opencv_3rdparty"; - rev = "7f55c0c26be418d494615afca15218566775c725"; - hash = "sha256-XbmS+FXUL8MAG7kawbDkb2XHG9R0DpPhiYhq/18eTnY="; - } + "/ippicv"; - files = let name = platform: "ippicv_2021.10.0_${platform}_20230919_general.tgz"; in + src = + fetchFromGitHub { + owner = "opencv"; + repo = "opencv_3rdparty"; + rev = "7f55c0c26be418d494615afca15218566775c725"; + hash = "sha256-XbmS+FXUL8MAG7kawbDkb2XHG9R0DpPhiYhq/18eTnY="; + } + + "/ippicv"; + files = + let + name = platform: "ippicv_2021.10.0_${platform}_20230919_general.tgz"; + in if effectiveStdenv.hostPlatform.system == "x86_64-linux" then { ${name "lnx_intel64"} = ""; } else if effectiveStdenv.hostPlatform.system == "i686-linux" then @@ -233,15 +246,35 @@ let }; # See opencv/cmake/OpenCVDownload.cmake - installExtraFiles = {dst, files, src, ...}: '' - mkdir -p "${dst}" - '' + concatStrings (flip mapAttrsToList files (name: md5: '' - ln -s "${src}/${name}" "${dst}/${md5}-${name}" - '')); - installExtraFile = {dst, md5, name, src, ...}: '' - mkdir -p "${dst}" - ln -s "${src}" "${dst}/${md5}-${name}" - ''; + installExtraFiles = + { + dst, + files, + src, + ... + }: + '' + mkdir -p "${dst}" + '' + + concatStrings ( + flip mapAttrsToList files ( + name: md5: '' + ln -s "${src}/${name}" "${dst}/${md5}-${name}" + '' + ) + ); + installExtraFile = + { + dst, + md5, + name, + src, + ... + }: + '' + mkdir -p "${dst}" + ln -s "${src}" "${dst}/${md5}-${name}" + ''; withOpenblas = (enableBlas && blas.provider.pname == "openblas"); #multithreaded openblas conflicts with opencv multithreading, which manifest itself in hung tests @@ -257,12 +290,14 @@ effectiveStdenv.mkDerivation { pname = "opencv"; inherit version src; - outputs = [ - "out" - "cxxdev" - ] ++ optionals (runAccuracyTests || runPerformanceTests) [ - "package_tests" - ]; + outputs = + [ + "out" + "cxxdev" + ] + ++ optionals (runAccuracyTests || runPerformanceTests) [ + "package_tests" + ]; cudaPropagateToOutput = "cxxdev"; postUnpack = optionalString buildContrib '' @@ -270,11 +305,13 @@ effectiveStdenv.mkDerivation { ''; # Ensures that we use the system OpenEXR rather than the vendored copy of the source included with OpenCV. - patches = [ - ./cmake-don-t-use-OpenCVFindOpenEXR.patch - ] ++ optionals enableCuda [ - ./cuda_opt_flow.patch - ]; + patches = + [ + ./cmake-don-t-use-OpenCVFindOpenEXR.patch + ] + ++ optionals enableCuda [ + ./cuda_opt_flow.patch + ]; # This prevents cmake from using libraries in impure paths (which # causes build failure on non NixOS) @@ -283,129 +320,163 @@ effectiveStdenv.mkDerivation { ''; preConfigure = - installExtraFile ade + - optionalString enableIpp (installExtraFiles ippicv) + ( - optionalString buildContrib '' - cmakeFlagsArray+=("-DOPENCV_EXTRA_MODULES_PATH=$NIX_BUILD_TOP/source/opencv_contrib") + installExtraFile ade + + optionalString enableIpp (installExtraFiles ippicv) + + (optionalString buildContrib '' + cmakeFlagsArray+=("-DOPENCV_EXTRA_MODULES_PATH=$NIX_BUILD_TOP/source/opencv_contrib") - ${installExtraFiles vgg} - ${installExtraFiles boostdesc} - ${installExtraFiles face} - ${installExtraFiles wechat_qrcode} - '' - ); + ${installExtraFiles vgg} + ${installExtraFiles boostdesc} + ${installExtraFiles face} + ${installExtraFiles wechat_qrcode} + ''); postConfigure = '' [ -e modules/core/version_string.inc ] echo '"(build info elided)"' > modules/core/version_string.inc ''; - buildInputs = [ - boost - gflags - glib - glog - pcre2 - protobuf_29 - zlib - ] ++ optionals enablePython [ - pythonPackages.python - ] ++ optionals (effectiveStdenv.buildPlatform == effectiveStdenv.hostPlatform) [ - hdf5 - ] ++ optionals enableGtk2 [ - gtk2 - ] ++ optionals enableGtk3 [ - gtk3 - ] ++ optionals enableVtk [ - vtk - ] ++ optionals enableJPEG [ - libjpeg - ] ++ optionals enablePNG [ - libpng - ] ++ optionals enableTIFF [ - libtiff - ] ++ optionals enableWebP [ - libwebp - ] ++ optionals enableEXR [ - openexr - ilmbase - ] ++ optionals enableJPEG2000 [ - openjpeg - ] ++ optionals enableFfmpeg [ - ffmpeg - ] ++ optionals (enableFfmpeg && effectiveStdenv.hostPlatform.isDarwin) [ - bzip2 - VideoDecodeAcceleration - ] ++ optionals (enableGStreamer && effectiveStdenv.hostPlatform.isLinux) [ - elfutils - gst_all_1.gst-plugins-base - gst_all_1.gst-plugins-good - gst_all_1.gstreamer - libunwind - orc - zstd - ] ++ optionals enableOvis [ - ogre - ] ++ optionals enableGPhoto2 [ - libgphoto2 - ] ++ optionals enableDC1394 [ - libdc1394 - ] ++ optionals enableEigen [ - eigen - ] ++ optionals enableVA [ - libva - ] ++ optionals enableBlas [ - blas.provider - ] ++ optionals enableTesseract [ - # There is seemingly no compile-time flag for Tesseract. It's - # simply enabled automatically if contrib is built, and it detects - # tesseract & leptonica. - tesseract - leptonica - ] ++ optionals enableTbb [ - tbb - ] ++ optionals effectiveStdenv.hostPlatform.isDarwin [ - bzip2 - AVFoundation - Cocoa - VideoDecodeAcceleration - CoreMedia - MediaToolbox - Accelerate - ] ++ optionals enableDocs [ - doxygen - graphviz-nox - ] ++ optionals enableCuda [ - cudaPackages.cuda_cudart - cudaPackages.cuda_cccl # - cudaPackages.libnpp # npp.h - nvidia-optical-flow-sdk - ] ++ optionals enableCublas [ - # May start using the default $out instead once - # https://github.com/NixOS/nixpkgs/issues/271792 - # has been addressed - cudaPackages.libcublas # cublas_v2.h - ] ++ optionals enableCudnn [ - cudaPackages.cudnn # cudnn.h - ] ++ optionals enableCufft [ - cudaPackages.libcufft # cufft.h - ]; + buildInputs = + [ + boost + gflags + glib + glog + pcre2 + protobuf_29 + zlib + ] + ++ optionals enablePython [ + pythonPackages.python + ] + ++ optionals (effectiveStdenv.buildPlatform == effectiveStdenv.hostPlatform) [ + hdf5 + ] + ++ optionals enableGtk2 [ + gtk2 + ] + ++ optionals enableGtk3 [ + gtk3 + ] + ++ optionals enableVtk [ + vtk + ] + ++ optionals enableJPEG [ + libjpeg + ] + ++ optionals enablePNG [ + libpng + ] + ++ optionals enableTIFF [ + libtiff + ] + ++ optionals enableWebP [ + libwebp + ] + ++ optionals enableEXR [ + openexr + ilmbase + ] + ++ optionals enableJPEG2000 [ + openjpeg + ] + ++ optionals enableFfmpeg [ + ffmpeg + ] + ++ optionals (enableFfmpeg && effectiveStdenv.hostPlatform.isDarwin) [ + bzip2 + VideoDecodeAcceleration + ] + ++ optionals (enableGStreamer && effectiveStdenv.hostPlatform.isLinux) [ + elfutils + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-good + gst_all_1.gstreamer + libunwind + orc + zstd + ] + ++ optionals enableOvis [ + ogre + ] + ++ optionals enableGPhoto2 [ + libgphoto2 + ] + ++ optionals enableDC1394 [ + libdc1394 + ] + ++ optionals enableEigen [ + eigen + ] + ++ optionals enableVA [ + libva + ] + ++ optionals enableBlas [ + blas.provider + ] + ++ optionals enableTesseract [ + # There is seemingly no compile-time flag for Tesseract. It's + # simply enabled automatically if contrib is built, and it detects + # tesseract & leptonica. + tesseract + leptonica + ] + ++ optionals enableTbb [ + tbb + ] + ++ optionals effectiveStdenv.hostPlatform.isDarwin [ + bzip2 + AVFoundation + Cocoa + VideoDecodeAcceleration + CoreMedia + MediaToolbox + Accelerate + ] + ++ optionals enableDocs [ + doxygen + graphviz-nox + ] + ++ optionals enableCuda [ + cudaPackages.cuda_cudart + cudaPackages.cuda_cccl # + cudaPackages.libnpp # npp.h + nvidia-optical-flow-sdk + ] + ++ optionals enableCublas [ + # May start using the default $out instead once + # https://github.com/NixOS/nixpkgs/issues/271792 + # has been addressed + cudaPackages.libcublas # cublas_v2.h + ] + ++ optionals enableCudnn [ + cudaPackages.cudnn # cudnn.h + ] + ++ optionals enableCufft [ + cudaPackages.libcufft # cufft.h + ]; propagatedBuildInputs = optionals enablePython [ pythonPackages.numpy ]; - nativeBuildInputs = [ - cmake - pkg-config - unzip - ] ++ optionals enablePython ([ - pythonPackages.pip - pythonPackages.wheel - pythonPackages.setuptools - ] ++ optionals (effectiveStdenv.hostPlatform == effectiveStdenv.buildPlatform) [ - pythonPackages.pythonImportsCheckHook - ]) ++ optionals enableCuda [ - cudaPackages.cuda_nvcc - ]; + nativeBuildInputs = + [ + cmake + pkg-config + unzip + ] + ++ optionals enablePython ( + [ + pythonPackages.pip + pythonPackages.wheel + pythonPackages.setuptools + ] + ++ optionals (effectiveStdenv.hostPlatform == effectiveStdenv.buildPlatform) [ + pythonPackages.pythonImportsCheckHook + ] + ) + ++ optionals enableCuda [ + cudaPackages.cuda_nvcc + ]; env.NIX_CFLAGS_COMPILE = optionalString enableEXR "-I${ilmbase.dev}/include/OpenEXR"; @@ -413,78 +484,86 @@ effectiveStdenv.mkDerivation { OpenBLAS_HOME = optionalString withOpenblas openblas_.dev; OpenBLAS = optionalString withOpenblas openblas_; - cmakeFlags = [ - (cmakeBool "OPENCV_GENERATE_PKGCONFIG" true) - (cmakeBool "WITH_OPENMP" true) - (cmakeBool "BUILD_PROTOBUF" false) - (cmakeBool "PROTOBUF_UPDATE_FILES" true) - (cmakeBool "OPENCV_ENABLE_NONFREE" enableUnfree) - (cmakeBool "BUILD_TESTS" runAccuracyTests) - (cmakeBool "BUILD_PERF_TESTS" runPerformanceTests) - (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) - (cmakeBool "BUILD_DOCS" enableDocs) - # "OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" - # but we have proper separation of build and host libs :), fixes cross - (cmakeBool "OPENCV_ENABLE_PKG_CONFIG" true) - (cmakeBool "WITH_IPP" enableIpp) - (cmakeBool "WITH_TIFF" enableTIFF) - (cmakeBool "WITH_WEBP" enableWebP) - (cmakeBool "WITH_JPEG" enableJPEG) - (cmakeBool "WITH_PNG" enablePNG) - (cmakeBool "WITH_OPENEXR" enableEXR) - (cmakeBool "WITH_OPENJPEG" enableJPEG2000) - (cmakeBool "WITH_JASPER" false) # OpenCV falls back to a vendored copy of Jasper when OpenJPEG is disabled - (cmakeBool "WITH_TBB" enableTbb) + cmakeFlags = + [ + (cmakeBool "OPENCV_GENERATE_PKGCONFIG" true) + (cmakeBool "WITH_OPENMP" true) + (cmakeBool "BUILD_PROTOBUF" false) + (cmakeBool "PROTOBUF_UPDATE_FILES" true) + (cmakeBool "OPENCV_ENABLE_NONFREE" enableUnfree) + (cmakeBool "BUILD_TESTS" runAccuracyTests) + (cmakeBool "BUILD_PERF_TESTS" runPerformanceTests) + (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) + (cmakeBool "BUILD_DOCS" enableDocs) + # "OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" + # but we have proper separation of build and host libs :), fixes cross + (cmakeBool "OPENCV_ENABLE_PKG_CONFIG" true) + (cmakeBool "WITH_IPP" enableIpp) + (cmakeBool "WITH_TIFF" enableTIFF) + (cmakeBool "WITH_WEBP" enableWebP) + (cmakeBool "WITH_JPEG" enableJPEG) + (cmakeBool "WITH_PNG" enablePNG) + (cmakeBool "WITH_OPENEXR" enableEXR) + (cmakeBool "WITH_OPENJPEG" enableJPEG2000) + (cmakeBool "WITH_JASPER" false) # OpenCV falls back to a vendored copy of Jasper when OpenJPEG is disabled + (cmakeBool "WITH_TBB" enableTbb) - # CUDA options - (cmakeBool "WITH_CUDA" enableCuda) - (cmakeBool "WITH_CUBLAS" enableCublas) - (cmakeBool "WITH_CUDNN" enableCudnn) - (cmakeBool "WITH_CUFFT" enableCufft) + # CUDA options + (cmakeBool "WITH_CUDA" enableCuda) + (cmakeBool "WITH_CUBLAS" enableCublas) + (cmakeBool "WITH_CUDNN" enableCudnn) + (cmakeBool "WITH_CUFFT" enableCufft) - # LTO options - (cmakeBool "ENABLE_LTO" enableLto) - (cmakeBool "ENABLE_THIN_LTO" ( - enableLto && ( - # Only clang supports thin LTO, so we must either be using clang through the effectiveStdenv, - effectiveStdenv.cc.isClang || - # or through the backend effectiveStdenv. - (enableCuda && effectiveStdenv.cc.isClang) - ) - )) - ] ++ optionals enableCuda [ - (cmakeBool "CUDA_FAST_MATH" true) - (cmakeFeature "CUDA_NVCC_FLAGS" "--expt-relaxed-constexpr") + # LTO options + (cmakeBool "ENABLE_LTO" enableLto) + (cmakeBool "ENABLE_THIN_LTO" ( + enableLto + && ( + # Only clang supports thin LTO, so we must either be using clang through the effectiveStdenv, + effectiveStdenv.cc.isClang + || + # or through the backend effectiveStdenv. + (enableCuda && effectiveStdenv.cc.isClang) + ) + )) + ] + ++ optionals enableCuda [ + (cmakeBool "CUDA_FAST_MATH" true) + (cmakeFeature "CUDA_NVCC_FLAGS" "--expt-relaxed-constexpr") - # OpenCV respects at least three variables: - # -DCUDA_GENERATION takes a single arch name, e.g. Volta - # -DCUDA_ARCH_BIN takes a semi-colon separated list of real arches, e.g. "8.0;8.6" - # -DCUDA_ARCH_PTX takes the virtual arch, e.g. "8.6" - (cmakeFeature "CUDA_ARCH_BIN" cmakeCudaArchitecturesString) - (cmakeFeature "CUDA_ARCH_PTX" (last cudaCapabilities)) + # OpenCV respects at least three variables: + # -DCUDA_GENERATION takes a single arch name, e.g. Volta + # -DCUDA_ARCH_BIN takes a semi-colon separated list of real arches, e.g. "8.0;8.6" + # -DCUDA_ARCH_PTX takes the virtual arch, e.g. "8.6" + (cmakeFeature "CUDA_ARCH_BIN" cmakeCudaArchitecturesString) + (cmakeFeature "CUDA_ARCH_PTX" (last cudaCapabilities)) - (cmakeOptionType "path" "NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH" nvidia-optical-flow-sdk.outPath) - ] ++ optionals effectiveStdenv.hostPlatform.isDarwin [ - (cmakeBool "WITH_OPENCL" false) - (cmakeBool "WITH_LAPACK" false) + (cmakeOptionType "path" "NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH" nvidia-optical-flow-sdk.outPath) + ] + ++ optionals effectiveStdenv.hostPlatform.isDarwin [ + (cmakeBool "WITH_OPENCL" false) + (cmakeBool "WITH_LAPACK" false) - # Disable unnecessary vendoring that's enabled by default only for Darwin. - # Note that the opencvFlag feature flags listed above still take - # precedence, so we can safely list everything here. - (cmakeBool "BUILD_ZLIB" false) - (cmakeBool "BUILD_TIFF" false) - (cmakeBool "BUILD_OPENJPEG" false) - (cmakeBool "BUILD_JASPER" false) - (cmakeBool "BUILD_JPEG" false) - (cmakeBool "BUILD_PNG" false) - (cmakeBool "BUILD_WEBP" false) - ] ++ optionals (!effectiveStdenv.hostPlatform.isDarwin) [ - (cmakeOptionType "path" "OPENCL_LIBRARY" "${ocl-icd}/lib/libOpenCL.so") - ] ++ optionals enablePython [ - (cmakeOptionType "path" "OPENCV_PYTHON_INSTALL_PATH" pythonPackages.python.sitePackages) - ] ++ optionals (enabledModules != [ ]) [ - (cmakeFeature "BUILD_LIST" (concatStringsSep "," enabledModules)) - ]; + # Disable unnecessary vendoring that's enabled by default only for Darwin. + # Note that the opencvFlag feature flags listed above still take + # precedence, so we can safely list everything here. + (cmakeBool "BUILD_ZLIB" false) + (cmakeBool "BUILD_TIFF" false) + (cmakeBool "BUILD_OPENJPEG" false) + (cmakeBool "BUILD_JASPER" false) + (cmakeBool "BUILD_JPEG" false) + (cmakeBool "BUILD_PNG" false) + (cmakeBool "BUILD_WEBP" false) + ] + ++ optionals (!effectiveStdenv.hostPlatform.isDarwin) [ + (cmakeOptionType "path" "OPENCL_LIBRARY" "${ocl-icd}/lib/libOpenCL.so") + ] + ++ optionals enablePython [ + (cmakeOptionType "path" "OPENCV_PYTHON_INSTALL_PATH" pythonPackages.python.sitePackages) + ] + ++ optionals (enabledModules != [ ]) [ + (cmakeFeature "BUILD_LIST" (concatStringsSep "," enabledModules)) + ]; postBuild = optionalString enableDocs '' make doxygen @@ -494,9 +573,11 @@ effectiveStdenv.mkDerivation { optionalString (runAccuracyTests || runPerformanceTests) '' mkdir $package_tests cp -R $src/samples $package_tests/ - '' + optionalString runAccuracyTests '' + '' + + optionalString runAccuracyTests '' mv ./bin/*test* $package_tests/ - '' + optionalString runPerformanceTests '' + '' + + optionalString runPerformanceTests '' mv ./bin/*perf* $package_tests/ ''; @@ -512,62 +593,74 @@ effectiveStdenv.mkDerivation { # Note that ${exec_prefix} is set to $out but that $out is also appended to # ${exec_prefix}. This causes linker errors in downstream packages so we strip # of $out after the ${exec_prefix} and ${prefix} prefixes: - postInstall = '' - sed -i "s|{exec_prefix}/$out|{exec_prefix}|;s|{prefix}/$out|{prefix}|" \ - "$out/lib/pkgconfig/opencv4.pc" - mkdir "$cxxdev" - '' - # fix deps not propagating from opencv4.cxxdev if cuda is disabled - # see https://github.com/NixOS/nixpkgs/issues/276691 - + optionalString (!enableCuda) '' - mkdir -p "$cxxdev/nix-support" - echo "''${!outputDev}" >> "$cxxdev/nix-support/propagated-build-inputs" - '' - # remove the requirement that the exact same version of CUDA is used in packages - # consuming OpenCV's CMakes files - + optionalString enableCuda '' - substituteInPlace "$out/lib/cmake/opencv4/OpenCVConfig.cmake" \ - --replace-fail \ - 'find_host_package(CUDA ''${OpenCV_CUDA_VERSION} EXACT REQUIRED)' \ - 'find_host_package(CUDA REQUIRED)' \ - --replace-fail \ - 'message(FATAL_ERROR "OpenCV static library was compiled with CUDA' \ - 'message("OpenCV static library was compiled with CUDA' - '' - # install python distribution information, so other packages can `import opencv` - + optionalString enablePython '' - pushd $NIX_BUILD_TOP/$sourceRoot/modules/python/package - python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist . + postInstall = + '' + sed -i "s|{exec_prefix}/$out|{exec_prefix}|;s|{prefix}/$out|{prefix}|" \ + "$out/lib/pkgconfig/opencv4.pc" + mkdir "$cxxdev" + '' + # fix deps not propagating from opencv4.cxxdev if cuda is disabled + # see https://github.com/NixOS/nixpkgs/issues/276691 + + optionalString (!enableCuda) '' + mkdir -p "$cxxdev/nix-support" + echo "''${!outputDev}" >> "$cxxdev/nix-support/propagated-build-inputs" + '' + # remove the requirement that the exact same version of CUDA is used in packages + # consuming OpenCV's CMakes files + + optionalString enableCuda '' + substituteInPlace "$out/lib/cmake/opencv4/OpenCVConfig.cmake" \ + --replace-fail \ + 'find_host_package(CUDA ''${OpenCV_CUDA_VERSION} EXACT REQUIRED)' \ + 'find_host_package(CUDA REQUIRED)' \ + --replace-fail \ + 'message(FATAL_ERROR "OpenCV static library was compiled with CUDA' \ + 'message("OpenCV static library was compiled with CUDA' + '' + # install python distribution information, so other packages can `import opencv` + + optionalString enablePython '' + pushd $NIX_BUILD_TOP/$sourceRoot/modules/python/package + python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist . - pushd dist - python -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache + pushd dist + python -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache - popd - popd - ''; + popd + popd + ''; - pythonImportsCheck = [ "cv2" "cv2.sfm" ]; + pythonImportsCheck = [ + "cv2" + "cv2.sfm" + ]; passthru = { cudaSupport = enableCuda; - tests = { - inherit (gst_all_1) gst-plugins-bad; - } - // optionalAttrs (!effectiveStdenv.hostPlatform.isDarwin) { - inherit qimgv; - withIpp = opencv4.override { enableIpp = true; }; - } - // optionalAttrs (!enablePython) { pythonEnabled = pythonPackages.opencv4; } - // optionalAttrs (effectiveStdenv.buildPlatform != "x86_64-darwin") { - opencv4-tests = callPackage ./tests.nix { - inherit enableGStreamer enableGtk2 enableGtk3 runAccuracyTests runPerformanceTests testDataSrc; - inherit opencv4; + tests = + { + inherit (gst_all_1) gst-plugins-bad; + } + // optionalAttrs (!effectiveStdenv.hostPlatform.isDarwin) { + inherit qimgv; + withIpp = opencv4.override { enableIpp = true; }; + } + // optionalAttrs (!enablePython) { pythonEnabled = pythonPackages.opencv4; } + // optionalAttrs (effectiveStdenv.buildPlatform != "x86_64-darwin") { + opencv4-tests = callPackage ./tests.nix { + inherit + enableGStreamer + enableGtk2 + enableGtk3 + runAccuracyTests + runPerformanceTests + testDataSrc + ; + inherit opencv4; + }; + } + // optionalAttrs (enableCuda) { + no-libstdcxx-errors = callPackage ./libstdcxx-test.nix { attrName = "opencv4"; }; }; - } - // optionalAttrs (enableCuda) { - no-libstdcxx-errors = callPackage ./libstdcxx-test.nix { attrName = "opencv4"; }; - }; } // optionalAttrs enablePython { pythonPath = [ ]; }; meta = { @@ -575,6 +668,6 @@ effectiveStdenv.mkDerivation { homepage = "https://opencv.org/"; license = if enableUnfree then lib.licenses.unfree else lib.licenses.bsd3; maintainers = with lib.maintainers; [ basvandijk ]; - platforms = with lib.platforms; linux ++ darwin; + platforms = lib.platforms.unix; }; } diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix index 9ceec2d760d0..9a07f5355219 100644 --- a/pkgs/development/libraries/science/math/openblas/default.nix +++ b/pkgs/development/libraries/science/math/openblas/default.nix @@ -128,6 +128,14 @@ let DYNAMIC_ARCH = setDynamicArch true; USE_OPENMP = true; }; + + x86_64-freebsd = { + BINARY = 64; + TARGET = setTarget "ATHLON"; + DYNAMIC_ARCH = setDynamicArch true; + NO_AVX512 = !enableAVX512; + USE_OPENMP = true; + }; }; in diff --git a/pkgs/development/python-modules/pycairo/default.nix b/pkgs/development/python-modules/pycairo/default.nix index fe5b332d9132..b1f0e5eba83e 100644 --- a/pkgs/development/python-modules/pycairo/default.nix +++ b/pkgs/development/python-modules/pycairo/default.nix @@ -51,6 +51,6 @@ buildPythonPackage rec { lgpl21Only mpl11 ]; - platforms = lib.platforms.linux ++ lib.platforms.darwin; + platforms = platforms.unix; }; }