various: extremely lightweight fixes to support FreeBSD build (#387230)

authored by

Audrey Dutcher and committed by
GitHub
496ea837 f4e5a303

+1583 -1338
+140 -85
pkgs/applications/graphics/ImageMagick/default.nix
··· 1 - { lib 2 - , stdenv 3 - , fetchFromGitHub 4 - , pkg-config 5 - , libtool 6 - , bzip2Support ? true, bzip2 7 - , zlibSupport ? true, zlib 8 - , libX11Support ? !stdenv.hostPlatform.isMinGW, libX11 9 - , libXtSupport ? !stdenv.hostPlatform.isMinGW, libXt 10 - , fontconfigSupport ? true, fontconfig 11 - , freetypeSupport ? true, freetype 12 - , ghostscriptSupport ? false, ghostscript 13 - , libjpegSupport ? true, libjpeg 14 - , djvulibreSupport ? true, djvulibre 15 - , lcms2Support ? true, lcms2 16 - , openexrSupport ? !stdenv.hostPlatform.isMinGW, openexr 17 - , libjxlSupport ? true, libjxl 18 - , libpngSupport ? true, libpng 19 - , liblqr1Support ? true, liblqr1 20 - , librawSupport ? true, libraw 21 - , librsvgSupport ? !stdenv.hostPlatform.isMinGW, librsvg, pango 22 - , libtiffSupport ? true, libtiff 23 - , libxml2Support ? true, libxml2 24 - , openjpegSupport ? !stdenv.hostPlatform.isMinGW, openjpeg 25 - , libwebpSupport ? !stdenv.hostPlatform.isMinGW, libwebp 26 - , libheifSupport ? true, libheif 27 - , fftwSupport ? true, fftw 28 - , potrace 29 - , coreutils 30 - , curl 31 - , ApplicationServices 32 - , Foundation 33 - , testers 34 - , nixos-icons 35 - , perlPackages 36 - , python3 37 }: 38 39 assert libXtSupport -> libX11Support; 40 41 let 42 arch = 43 - if stdenv.hostPlatform.system == "i686-linux" then "i686" 44 - else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64" 45 - else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l" 46 - else if stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" then "aarch64" 47 - else if stdenv.hostPlatform.system == "powerpc64le-linux" then "ppc64le" 48 - else null; 49 in 50 51 stdenv.mkDerivation (finalAttrs: { ··· 59 hash = "sha256-DsJRTLMyjU2mMEGq/2qEJvjdYa698TEZZqkxuWtd/A4="; 60 }; 61 62 - outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big 63 outputMan = "out"; # it's tiny 64 65 enableParallelBuilding = true; 66 67 - configureFlags = [ 68 - # specify delegates explicitly otherwise `convert` will invoke the build 69 - # coreutils for filetypes it doesn't natively support. 70 - "MVDelegate=${lib.getExe' coreutils "mv"}" 71 - "RMDelegate=${lib.getExe' coreutils "rm"}" 72 - "--with-frozenpaths" 73 - (lib.withFeatureAs (arch != null) "gcc-arch" arch) 74 - (lib.withFeature librsvgSupport "rsvg") 75 - (lib.withFeature librsvgSupport "pango") 76 - (lib.withFeature liblqr1Support "lqr") 77 - (lib.withFeature libjxlSupport "jxl") 78 - (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts") 79 - (lib.withFeature ghostscriptSupport "gslib") 80 - (lib.withFeature fftwSupport "fftw") 81 - ] ++ lib.optionals stdenv.hostPlatform.isMinGW [ 82 - # due to libxml2 being without DLLs ATM 83 - "--enable-static" "--disable-shared" 84 - ]; 85 86 - nativeBuildInputs = [ pkg-config libtool ]; 87 88 - buildInputs = [ potrace ] 89 ++ lib.optional zlibSupport zlib 90 ++ lib.optional fontconfigSupport fontconfig 91 ++ lib.optional ghostscriptSupport ghostscript ··· 108 Foundation 109 ]; 110 111 - propagatedBuildInputs = [ curl ] 112 ++ lib.optional bzip2Support bzip2 113 ++ lib.optional freetypeSupport freetype 114 ++ lib.optional libjpegSupport libjpeg ··· 118 ++ lib.optional libwebpSupport libwebp 119 ++ lib.optional fftwSupport fftw; 120 121 - postInstall = '' 122 - (cd "$dev/include" && ln -s ImageMagick* ImageMagick) 123 - # Q16HDRI = 16 bit quantum depth with HDRI support, and is the default ImageMagick configuration 124 - # If the default is changed, or the derivation is modified to use a different configuration 125 - # this will need to be changed below. 126 - moveToOutput "bin/*-config" "$dev" 127 - moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params 128 - configDestination=($out/share/ImageMagick-*) 129 - grep -v '/nix/store' $dev/lib/ImageMagick-*/config-Q16HDRI/configure.xml > $configDestination/configure.xml 130 - for file in "$dev"/bin/*-config; do 131 - substituteInPlace "$file" --replace pkg-config \ 132 - "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'" 133 - done 134 - '' + lib.optionalString ghostscriptSupport '' 135 - for la in $out/lib/*.la; do 136 - sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la 137 - done 138 - ''; 139 140 passthru.tests = { 141 version = testers.testVersion { package = finalAttrs.finalPackage; }; ··· 152 homepage = "http://www.imagemagick.org/"; 153 changelog = "https://github.com/ImageMagick/Website/blob/main/ChangeLog.md"; 154 description = "Software suite to create, edit, compose, or convert bitmap images"; 155 - pkgConfigModules = [ "ImageMagick" "MagickWand" ]; 156 - platforms = platforms.linux ++ platforms.darwin; 157 - maintainers = with maintainers; [ dotlambda rhendric bloxx12 ]; 158 license = licenses.asl20; 159 mainProgram = "magick"; 160 };
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchFromGitHub, 5 + pkg-config, 6 + libtool, 7 + bzip2Support ? true, 8 + bzip2, 9 + zlibSupport ? true, 10 + zlib, 11 + libX11Support ? !stdenv.hostPlatform.isMinGW, 12 + libX11, 13 + libXtSupport ? !stdenv.hostPlatform.isMinGW, 14 + libXt, 15 + fontconfigSupport ? true, 16 + fontconfig, 17 + freetypeSupport ? true, 18 + freetype, 19 + ghostscriptSupport ? false, 20 + ghostscript, 21 + libjpegSupport ? true, 22 + libjpeg, 23 + djvulibreSupport ? true, 24 + djvulibre, 25 + lcms2Support ? true, 26 + lcms2, 27 + openexrSupport ? !stdenv.hostPlatform.isMinGW, 28 + openexr, 29 + libjxlSupport ? true, 30 + libjxl, 31 + libpngSupport ? true, 32 + libpng, 33 + liblqr1Support ? true, 34 + liblqr1, 35 + librawSupport ? true, 36 + libraw, 37 + librsvgSupport ? !stdenv.hostPlatform.isMinGW, 38 + librsvg, 39 + pango, 40 + libtiffSupport ? true, 41 + libtiff, 42 + libxml2Support ? true, 43 + libxml2, 44 + openjpegSupport ? !stdenv.hostPlatform.isMinGW, 45 + openjpeg, 46 + libwebpSupport ? !stdenv.hostPlatform.isMinGW, 47 + libwebp, 48 + libheifSupport ? true, 49 + libheif, 50 + fftwSupport ? true, 51 + fftw, 52 + potrace, 53 + coreutils, 54 + curl, 55 + ApplicationServices, 56 + Foundation, 57 + testers, 58 + nixos-icons, 59 + perlPackages, 60 + python3, 61 }: 62 63 assert libXtSupport -> libX11Support; 64 65 let 66 arch = 67 + if stdenv.hostPlatform.system == "i686-linux" then 68 + "i686" 69 + else if 70 + stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" 71 + then 72 + "x86-64" 73 + else if stdenv.hostPlatform.system == "armv7l-linux" then 74 + "armv7l" 75 + else if 76 + stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" 77 + then 78 + "aarch64" 79 + else if stdenv.hostPlatform.system == "powerpc64le-linux" then 80 + "ppc64le" 81 + else 82 + null; 83 in 84 85 stdenv.mkDerivation (finalAttrs: { ··· 93 hash = "sha256-DsJRTLMyjU2mMEGq/2qEJvjdYa698TEZZqkxuWtd/A4="; 94 }; 95 96 + outputs = [ 97 + "out" 98 + "dev" 99 + "doc" 100 + ]; # bin/ isn't really big 101 outputMan = "out"; # it's tiny 102 103 enableParallelBuilding = true; 104 105 + configureFlags = 106 + [ 107 + # specify delegates explicitly otherwise `convert` will invoke the build 108 + # coreutils for filetypes it doesn't natively support. 109 + "MVDelegate=${lib.getExe' coreutils "mv"}" 110 + "RMDelegate=${lib.getExe' coreutils "rm"}" 111 + "--with-frozenpaths" 112 + (lib.withFeatureAs (arch != null) "gcc-arch" arch) 113 + (lib.withFeature librsvgSupport "rsvg") 114 + (lib.withFeature librsvgSupport "pango") 115 + (lib.withFeature liblqr1Support "lqr") 116 + (lib.withFeature libjxlSupport "jxl") 117 + (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts") 118 + (lib.withFeature ghostscriptSupport "gslib") 119 + (lib.withFeature fftwSupport "fftw") 120 + ] 121 + ++ lib.optionals stdenv.hostPlatform.isMinGW [ 122 + # due to libxml2 being without DLLs ATM 123 + "--enable-static" 124 + "--disable-shared" 125 + ]; 126 127 + nativeBuildInputs = [ 128 + pkg-config 129 + libtool 130 + ]; 131 132 + buildInputs = 133 + [ potrace ] 134 ++ lib.optional zlibSupport zlib 135 ++ lib.optional fontconfigSupport fontconfig 136 ++ lib.optional ghostscriptSupport ghostscript ··· 153 Foundation 154 ]; 155 156 + propagatedBuildInputs = 157 + [ curl ] 158 ++ lib.optional bzip2Support bzip2 159 ++ lib.optional freetypeSupport freetype 160 ++ lib.optional libjpegSupport libjpeg ··· 164 ++ lib.optional libwebpSupport libwebp 165 ++ lib.optional fftwSupport fftw; 166 167 + postInstall = 168 + '' 169 + (cd "$dev/include" && ln -s ImageMagick* ImageMagick) 170 + # Q16HDRI = 16 bit quantum depth with HDRI support, and is the default ImageMagick configuration 171 + # If the default is changed, or the derivation is modified to use a different configuration 172 + # this will need to be changed below. 173 + moveToOutput "bin/*-config" "$dev" 174 + moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params 175 + configDestination=($out/share/ImageMagick-*) 176 + grep -v '/nix/store' $dev/lib/ImageMagick-*/config-Q16HDRI/configure.xml > $configDestination/configure.xml 177 + for file in "$dev"/bin/*-config; do 178 + substituteInPlace "$file" --replace pkg-config \ 179 + "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'" 180 + done 181 + '' 182 + + lib.optionalString ghostscriptSupport '' 183 + for la in $out/lib/*.la; do 184 + sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la 185 + done 186 + ''; 187 188 passthru.tests = { 189 version = testers.testVersion { package = finalAttrs.finalPackage; }; ··· 200 homepage = "http://www.imagemagick.org/"; 201 changelog = "https://github.com/ImageMagick/Website/blob/main/ChangeLog.md"; 202 description = "Software suite to create, edit, compose, or convert bitmap images"; 203 + pkgConfigModules = [ 204 + "ImageMagick" 205 + "MagickWand" 206 + ]; 207 + platforms = platforms.unix; 208 + maintainers = with maintainers; [ 209 + dotlambda 210 + rhendric 211 + bloxx12 212 + ]; 213 license = licenses.asl20; 214 mainProgram = "magick"; 215 };
+1 -1
pkgs/by-name/al/alsa-lib/package.nix
··· 65 "alsa" 66 "alsa-topology" 67 ]; 68 - platforms = platforms.linux; 69 maintainers = with maintainers; [ l-as ]; 70 }; 71 })
··· 65 "alsa" 66 "alsa-topology" 67 ]; 68 + platforms = platforms.linux ++ platforms.freebsd; 69 maintainers = with maintainers; [ l-as ]; 70 }; 71 })
+1 -1
pkgs/by-name/al/alsa-topology-conf/package.nix
··· 35 36 license = licenses.bsd3; 37 maintainers = [ maintainers.roastiek ]; 38 - platforms = platforms.linux; 39 }; 40 }
··· 35 36 license = licenses.bsd3; 37 maintainers = [ maintainers.roastiek ]; 38 + platforms = platforms.linux ++ platforms.freebsd; 39 }; 40 }
+26 -21
pkgs/by-name/al/alsa-ucm-conf/package.nix
··· 18 19 dontBuild = true; 20 21 - installPhase = '' 22 - runHook preInstall 23 24 - substituteInPlace ucm2/lib/card-init.conf \ 25 - --replace-fail "/bin/rm" "${coreutils}/bin/rm" \ 26 - --replace-fail "/bin/mkdir" "${coreutils}/bin/mkdir" 27 28 - files=( 29 - "ucm2/HDA/HDA.conf" 30 - "ucm2/codecs/rt715/init.conf" 31 - "ucm2/codecs/rt715-sdca/init.conf" 32 - "ucm2/Intel/cht-bsw-rt5672/cht-bsw-rt5672.conf" 33 - "ucm2/Intel/bytcr-rt5640/bytcr-rt5640.conf" 34 - ) 35 36 - for file in "''${files[@]}"; do 37 - substituteInPlace "$file" \ 38 - --replace-fail '/sbin/modprobe' '${kmod}/bin/modprobe' 39 - done 40 41 - mkdir -p $out/share/alsa 42 - cp -r ucm ucm2 $out/share/alsa 43 44 - runHook postInstall 45 - ''; 46 47 passthru.updateScript = directoryListingUpdater { 48 url = "https://www.alsa-project.org/files/pub/lib/"; ··· 59 60 license = lib.licenses.bsd3; 61 maintainers = [ lib.maintainers.roastiek ]; 62 - platforms = lib.platforms.linux; 63 }; 64 })
··· 18 19 dontBuild = true; 20 21 + installPhase = 22 + '' 23 + runHook preInstall 24 25 + substituteInPlace ucm2/lib/card-init.conf \ 26 + --replace-fail "/bin/rm" "${coreutils}/bin/rm" \ 27 + --replace-fail "/bin/mkdir" "${coreutils}/bin/mkdir" 28 29 + files=( 30 + "ucm2/HDA/HDA.conf" 31 + "ucm2/codecs/rt715/init.conf" 32 + "ucm2/codecs/rt715-sdca/init.conf" 33 + "ucm2/Intel/cht-bsw-rt5672/cht-bsw-rt5672.conf" 34 + "ucm2/Intel/bytcr-rt5640/bytcr-rt5640.conf" 35 + ) 36 37 + '' 38 + + lib.optionalString stdenv.hostPlatform.isLinux '' 39 + for file in "''${files[@]}"; do 40 + substituteInPlace "$file" \ 41 + --replace-fail '/sbin/modprobe' '${kmod}/bin/modprobe' 42 + done 43 + '' 44 + + '' 45 46 + mkdir -p $out/share/alsa 47 + cp -r ucm ucm2 $out/share/alsa 48 49 + runHook postInstall 50 + ''; 51 52 passthru.updateScript = directoryListingUpdater { 53 url = "https://www.alsa-project.org/files/pub/lib/"; ··· 64 65 license = lib.licenses.bsd3; 66 maintainers = [ lib.maintainers.roastiek ]; 67 + platforms = lib.platforms.linux ++ lib.platforms.freebsd; 68 }; 69 })
+1 -1
pkgs/by-name/fr/frei0r/package.nix
··· 49 description = "Minimalist, cross-platform, shared video plugins"; 50 license = licenses.gpl2Plus; 51 maintainers = [ ]; 52 - platforms = platforms.linux ++ platforms.darwin; 53 }; 54 }
··· 49 description = "Minimalist, cross-platform, shared video plugins"; 50 license = licenses.gpl2Plus; 51 maintainers = [ ]; 52 + platforms = platforms.unix; 53 }; 54 }
+1
pkgs/by-name/li/libcamera/package.nix
··· 132 changelog = "https://git.libcamera.org/libcamera/libcamera.git/tag/?h=${src.rev}"; 133 license = licenses.lgpl2Plus; 134 maintainers = with maintainers; [ citadelcore ]; 135 badPlatforms = [ 136 # Mandatory shared libraries. 137 lib.systems.inspect.platformPatterns.isStatic
··· 132 changelog = "https://git.libcamera.org/libcamera/libcamera.git/tag/?h=${src.rev}"; 133 license = licenses.lgpl2Plus; 134 maintainers = with maintainers; [ citadelcore ]; 135 + platforms = platforms.linux; 136 badPlatforms = [ 137 # Mandatory shared libraries. 138 lib.systems.inspect.platformPatterns.isStatic
+1 -1
pkgs/by-name/li/libvisual/package.nix
··· 53 description = "Abstraction library for audio visualisations"; 54 homepage = "https://sourceforge.net/projects/libvisual/"; 55 license = lib.licenses.lgpl21Plus; 56 - platforms = lib.platforms.linux; 57 }; 58 }
··· 53 description = "Abstraction library for audio visualisations"; 54 homepage = "https://sourceforge.net/projects/libvisual/"; 55 license = lib.licenses.lgpl21Plus; 56 + platforms = lib.platforms.linux ++ lib.platforms.freebsd; 57 }; 58 }
+3 -6
pkgs/by-name/qu/quirc/package.nix
··· 56 hash = "sha256-WLQK7vy34VmgJzppTnRjAcZoSGWVaXQSaGq9An8W0rw="; 57 }) 58 ] 59 - ++ lib.optionals stdenv.hostPlatform.isDarwin [ 60 - # Disable building of linux-only demos on darwin systems 61 ./0001-Don-t-build-demos.patch 62 ]; 63 ··· 84 description = "Small QR code decoding library"; 85 license = lib.licenses.isc; 86 maintainers = [ lib.maintainers.raskin ]; 87 - platforms = lib.platforms.linux ++ [ 88 - "x86_64-darwin" 89 - "aarch64-darwin" 90 - ]; 91 }; 92 })
··· 56 hash = "sha256-WLQK7vy34VmgJzppTnRjAcZoSGWVaXQSaGq9An8W0rw="; 57 }) 58 ] 59 + ++ lib.optionals (!stdenv.hostPlatform.isLinux) [ 60 + # Disable building of linux-only demos on non-linux systems 61 ./0001-Don-t-build-demos.patch 62 ]; 63 ··· 84 description = "Small QR code decoding library"; 85 license = lib.licenses.isc; 86 maintainers = [ lib.maintainers.raskin ]; 87 + platforms = lib.platforms.unix; 88 }; 89 })
+7 -3
pkgs/by-name/so/socat/package.nix
··· 25 --replace /sbin/ifconfig ifconfig 26 ''; 27 28 - configureFlags = lib.optionals (!stdenv.hostPlatform.isLinux) [ 29 - "--disable-posixmq" 30 - ]; 31 32 buildInputs = [ 33 openssl
··· 25 --replace /sbin/ifconfig ifconfig 26 ''; 27 28 + configureFlags = 29 + lib.optionals (!stdenv.hostPlatform.isLinux) [ 30 + "--disable-posixmq" 31 + ] 32 + ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ 33 + "--disable-dccp" 34 + ]; 35 36 buildInputs = [ 37 openssl
+1 -1
pkgs/by-name/x2/x265/package.nix
··· 87 ] 88 # Clang does not support the endfunc directive so use GCC. 89 ++ lib.optional ( 90 - stdenv.cc.isClang && !stdenv.targetPlatform.isDarwin 91 ) "-DCMAKE_ASM_COMPILER=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc"; 92 93 cmakeStaticLibFlags =
··· 87 ] 88 # Clang does not support the endfunc directive so use GCC. 89 ++ lib.optional ( 90 + stdenv.cc.isClang && !stdenv.targetPlatform.isDarwin && !stdenv.targetPlatform.isFreeBSD 91 ) "-DCMAKE_ASM_COMPILER=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc"; 92 93 cmakeStaticLibFlags =
+1 -1
pkgs/by-name/xa/xavs/package.nix
··· 49 mainProgram = "xavs"; 50 homepage = "https://xavs.sourceforge.net/"; 51 license = licenses.lgpl2; 52 - platforms = platforms.linux ++ platforms.darwin; 53 maintainers = with maintainers; [ codyopel ]; 54 }; 55 }
··· 49 mainProgram = "xavs"; 50 homepage = "https://xavs.sourceforge.net/"; 51 license = licenses.lgpl2; 52 + platforms = platforms.unix; 53 maintainers = with maintainers; [ codyopel ]; 54 }; 55 }
+946 -864
pkgs/development/libraries/ffmpeg/generic.nix
··· 1 - { lib, config, stdenv, buildPackages, removeReferencesTo, addDriverRunpath, pkg-config, perl, texinfo, texinfo6, yasm 2 3 # You can fetch any upstream version using this derivation by specifying version and hash 4 # NOTICE: Always use this argument to override the version. Do not use overrideAttrs. 5 - , version # ffmpeg ABI version. Also declare this if you're overriding the source. 6 - , hash ? "" # hash of the upstream source for the given ABI version 7 - , source ? fetchgit { 8 url = "https://git.ffmpeg.org/ffmpeg.git"; 9 rev = "n${version}"; 10 inherit hash; 11 - } 12 13 - , ffmpegVariant ? "small" # Decides which dependencies are enabled by default 14 15 # Build with headless deps; excludes dependencies that are only necessary for 16 # GUI applications. To be used for purposes that don't generally need such 17 # components and i.e. only depend on libav 18 - , withHeadlessDeps ? ffmpegVariant == "headless" || withSmallDeps 19 20 # Dependencies a user might customarily expect from a regular ffmpeg build. 21 # /All/ packages that depend on ffmpeg and some of its feaures should depend 22 # on the small variant. Small means the minimal set of features that satisfies 23 # all dependants in Nixpkgs 24 - , withSmallDeps ? ffmpegVariant == "small" || withFullDeps 25 26 # Everything enabled; only guarded behind platform exclusivity or brokeness. 27 # If you need to depend on ffmpeg-full because ffmpeg is missing some feature 28 # your package needs, you should enable that feature in regular ffmpeg 29 # instead. 30 - , withFullDeps ? ffmpegVariant == "full" 31 32 - , fetchgit 33 - , fetchpatch2 34 35 # Feature flags 36 - , withAlsa ? withHeadlessDeps && stdenv.hostPlatform.isLinux # Alsa in/output supporT 37 - , withAmf ? withHeadlessDeps && lib.meta.availableOn stdenv.hostPlatform amf # AMD Media Framework video encoding 38 - , withAom ? withHeadlessDeps # AV1 reference encoder 39 - , withAribb24 ? withFullDeps # ARIB text and caption decoding 40 - , withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1" # ARIB STD-B24 Caption Decoder/Renderer 41 - , withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform # (Advanced) SubStation Alpha subtitle rendering 42 - , withAvisynth ? withFullDeps # AviSynth script files reading 43 - , withBluray ? withHeadlessDeps # BluRay reading 44 - , withBs2b ? withFullDeps # bs2b DSP library 45 - , withBzlib ? withHeadlessDeps 46 - , withCaca ? withFullDeps # Textual display (ASCII art) 47 - , withCdio ? withFullDeps && withGPL # Audio CD grabbing 48 - , withCelt ? withHeadlessDeps # CELT decoder 49 - , withChromaprint ? withFullDeps # Audio fingerprinting 50 - , withCodec2 ? withFullDeps # codec2 en/decoding 51 - , withCuda ? withFullDeps && withNvcodec 52 - , withCudaLLVM ? withHeadlessDeps 53 - , withCudaNVCC ? withFullDeps && withUnfree && config.cudaSupport 54 - , withCuvid ? withHeadlessDeps && withNvcodec 55 - , withDav1d ? withHeadlessDeps # AV1 decoder (focused on speed and correctness) 56 - , withDc1394 ? withFullDeps && !stdenv.hostPlatform.isDarwin # IIDC-1394 grabbing (ieee 1394) 57 - , withDrm ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # libdrm support 58 - , withDvdnav ? withFullDeps && withGPL && lib.versionAtLeast version "7" # needed for DVD demuxing 59 - , withDvdread ? withFullDeps && withGPL && lib.versionAtLeast version "7" # needed for DVD demuxing 60 - , withFdkAac ? withFullDeps && (!withGPL || withUnfree) # Fraunhofer FDK AAC de/encoder 61 - , withNvcodec ? withHeadlessDeps && (with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform) # dynamically linked Nvidia code 62 - , withFlite ? withFullDeps # Voice Synthesis 63 - , withFontconfig ? withHeadlessDeps # Needed for drawtext filter 64 - , withFreetype ? withHeadlessDeps # Needed for drawtext filter 65 - , withFrei0r ? withFullDeps && withGPL # frei0r video filtering 66 - , withFribidi ? withHeadlessDeps # Needed for drawtext filter 67 - , withGme ? withFullDeps # Game Music Emulator 68 - , withGnutls ? withHeadlessDeps 69 - , withGsm ? withFullDeps # GSM de/encoder 70 - , withHarfbuzz ? withHeadlessDeps && lib.versionAtLeast version "6.1" # Needed for drawtext filter 71 - , withIconv ? withHeadlessDeps 72 - , withIlbc ? withFullDeps # iLBC de/encoding 73 - , withJack ? withFullDeps && !stdenv.hostPlatform.isDarwin # Jack audio 74 - , withJxl ? withFullDeps && lib.versionAtLeast version "5" # JPEG XL de/encoding 75 - , withKvazaar ? withFullDeps # HEVC encoding 76 - , withLadspa ? withFullDeps # LADSPA audio filtering 77 - , withLc3 ? withFullDeps && lib.versionAtLeast version "7.1" # LC3 de/encoding 78 - , withLcevcdec ? false && lib.versionAtLeast version "7.1" # LCEVC decoding # FIXME currently makes ffmpeg crash in any operation on non-AVX CPUs 79 - , withLcms2 ? withFullDeps # ICC profile support via lcms2 80 - , withLzma ? withHeadlessDeps # xz-utils 81 - , withMetal ? false # Unfree and requires manual downloading of files 82 - , withMfx ? withFullDeps && (with stdenv.hostPlatform; isLinux && !isAarch) # Hardware acceleration via intel-media-sdk/libmfx 83 - , withModplug ? withFullDeps && !stdenv.hostPlatform.isDarwin # ModPlug support 84 - , withMp3lame ? withHeadlessDeps # LAME MP3 encoder 85 - , withMysofa ? withFullDeps # HRTF support via SOFAlizer 86 - , withNpp ? withFullDeps && withUnfree && config.cudaSupport # Nvidia Performance Primitives-based code 87 - , withNvdec ? withHeadlessDeps && withNvcodec 88 - , withNvenc ? withHeadlessDeps && withNvcodec 89 - , withOpenal ? withFullDeps # OpenAL 1.1 capture support 90 - , withOpencl ? withHeadlessDeps 91 - , withOpencoreAmrnb ? withFullDeps && withVersion3 # AMR-NB de/encoder 92 - , withOpencoreAmrwb ? withFullDeps && withVersion3 # AMR-WB decoder 93 - , withOpengl ? withFullDeps && !stdenv.hostPlatform.isDarwin # OpenGL rendering 94 - , withOpenh264 ? withFullDeps # H.264/AVC encoder 95 - , withOpenjpeg ? withHeadlessDeps # JPEG 2000 de/encoder 96 - , withOpenmpt ? withHeadlessDeps # Tracked music files decoder 97 - , withOpus ? withHeadlessDeps # Opus de/encoder 98 - , withPlacebo ? withFullDeps && !stdenv.hostPlatform.isDarwin # libplacebo video processing library 99 - , withPulse ? withSmallDeps && stdenv.hostPlatform.isLinux # Pulseaudio input support 100 - , withQrencode ? withFullDeps && lib.versionAtLeast version "7" # QR encode generation 101 - , withQuirc ? withFullDeps && lib.versionAtLeast version "7" # QR decoding 102 - , withRav1e ? withFullDeps # AV1 encoder (focused on speed and safety) 103 - , withRist ? withHeadlessDeps # Reliable Internet Stream Transport (RIST) protocol 104 - , withRtmp ? withFullDeps # RTMP[E] support 105 - , withRubberband ? withFullDeps && withGPL # Rubberband filter 106 - , withSamba ? withFullDeps && !stdenv.hostPlatform.isDarwin && withGPLv3 # Samba protocol 107 - , withSdl2 ? withSmallDeps 108 - , withShaderc ? withFullDeps && !stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "5.0" 109 - , withShine ? withFullDeps # Fixed-point MP3 encoding 110 - , withSnappy ? withFullDeps # Snappy compression, needed for hap encoding 111 - , withSoxr ? withHeadlessDeps # Resampling via soxr 112 - , withSpeex ? withHeadlessDeps # Speex de/encoder 113 - , withSrt ? withHeadlessDeps # Secure Reliable Transport (SRT) protocol 114 - , withSsh ? withHeadlessDeps # SFTP protocol 115 - , withSvg ? withFullDeps # SVG protocol 116 - , withSvtav1 ? withHeadlessDeps && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMinGW # AV1 encoder/decoder (focused on speed and correctness) 117 - , withTensorflow ? false # Tensorflow dnn backend support (Increases closure size by ~390 MiB) 118 - , withTheora ? withHeadlessDeps # Theora encoder 119 - , withTwolame ? withFullDeps # MP2 encoding 120 - , withV4l2 ? withHeadlessDeps && stdenv.hostPlatform.isLinux # Video 4 Linux support 121 - , withV4l2M2m ? withV4l2 122 - , withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD) # Vaapi hardware acceleration 123 - , withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW # Vdpau hardware acceleration 124 - , withVidStab ? withHeadlessDeps && withGPL # Video stabilization 125 - , withVmaf ? withFullDeps && !stdenv.hostPlatform.isAarch64 && lib.versionAtLeast version "5" # Netflix's VMAF (Video Multi-Method Assessment Fusion) 126 - , withVoAmrwbenc ? withFullDeps && withVersion3 # AMR-WB encoder 127 - , withVorbis ? withHeadlessDeps # Vorbis de/encoding, native encoder exists 128 - , withVpl ? false # Hardware acceleration via intel libvpl 129 - , withVpx ? withHeadlessDeps && stdenv.buildPlatform == stdenv.hostPlatform # VP8 & VP9 de/encoding 130 - , withVulkan ? withHeadlessDeps && !stdenv.hostPlatform.isDarwin 131 - , withVvenc ? withFullDeps && lib.versionAtLeast version "7.1" # H.266/VVC encoding 132 - , withWebp ? withHeadlessDeps # WebP encoder 133 - , withX264 ? withHeadlessDeps && withGPL # H.264/AVC encoder 134 - , withX265 ? withHeadlessDeps && withGPL # H.265/HEVC encoder 135 - , withXavs ? withFullDeps && withGPL # AVS encoder 136 - , withXcb ? withXcbShm || withXcbxfixes || withXcbShape # X11 grabbing using XCB 137 - , withXcbShape ? withFullDeps # X11 grabbing shape rendering 138 - , withXcbShm ? withFullDeps # X11 grabbing shm communication 139 - , withXcbxfixes ? withFullDeps # X11 grabbing mouse rendering 140 - , withXevd ? withFullDeps && lib.versionAtLeast version "7.1" && !xevd.meta.broken # MPEG-5 EVC decoding 141 - , withXeve ? withFullDeps && lib.versionAtLeast version "7.1" && !xeve.meta.broken # MPEG-5 EVC encoding 142 - , withXlib ? withFullDeps # Xlib support 143 - , withXml2 ? withHeadlessDeps # libxml2 support, for IMF and DASH demuxers 144 - , withXvid ? withHeadlessDeps && withGPL # Xvid encoder, native encoder exists 145 - , withZimg ? withHeadlessDeps 146 - , withZlib ? withHeadlessDeps 147 - , withZmq ? withFullDeps # Message passing 148 - , withZvbi ? withHeadlessDeps # Teletext support 149 150 - /* 151 - * Licensing options (yes some are listed twice, filters and such are not listed) 152 - */ 153 - , withGPL ? true 154 - , withVersion3 ? true # When withGPL is set this implies GPLv3 otherwise it is LGPLv3 155 - , withGPLv3 ? withGPL && withVersion3 156 - , withUnfree ? false 157 158 - /* 159 - * Build options 160 - */ 161 - , withSmallBuild ? false # Optimize for size instead of speed 162 - , withRuntimeCPUDetection ? true # Detect CPU capabilities at runtime (disable to compile natively) 163 - , withGrayscale ? withFullDeps # Full grayscale support 164 - , withSwscaleAlpha ? buildSwscale # Alpha channel support in swscale. You probably want this when buildSwscale. 165 - , withHardcodedTables ? withHeadlessDeps # Hardcode decode tables instead of runtime generation 166 - , withSafeBitstreamReader ? withHeadlessDeps # Buffer boundary checking in bitreaders 167 - , withMultithread ? true # Multithreading via pthreads/win32 threads 168 - , withNetwork ? withHeadlessDeps # Network support 169 - , withPixelutils ? withHeadlessDeps # Pixel utils in libavutil 170 - , withStatic ? stdenv.hostPlatform.isStatic 171 - , withShared ? !stdenv.hostPlatform.isStatic 172 - , withPic ? true 173 - , withThumb ? false # On some ARM platforms 174 175 - /* 176 - * Program options 177 - */ 178 - , buildFfmpeg ? withHeadlessDeps # Build ffmpeg executable 179 - , buildFfplay ? withSmallDeps # Build ffplay executable 180 - , buildFfprobe ? withHeadlessDeps # Build ffprobe executable 181 - , buildQtFaststart ? withFullDeps # Build qt-faststart executable 182 - , withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart 183 - /* 184 - * Library options 185 - */ 186 - , buildAvcodec ? withHeadlessDeps # Build avcodec library 187 - , buildAvdevice ? withHeadlessDeps # Build avdevice library 188 - , buildAvfilter ? withHeadlessDeps # Build avfilter library 189 - , buildAvformat ? withHeadlessDeps # Build avformat library 190 - # Deprecated but depended upon by some packages. 191 - # https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991) 192 - , buildAvresample ? withHeadlessDeps && lib.versionOlder version "5" # Build avresample library 193 - , buildAvutil ? withHeadlessDeps # Build avutil library 194 - , buildPostproc ? withHeadlessDeps # Build postproc library 195 - , buildSwresample ? withHeadlessDeps # Build swresample library 196 - , buildSwscale ? withHeadlessDeps # Build swscale library 197 - , withLib ? buildAvcodec 198 - || buildAvdevice 199 - || buildAvfilter 200 - || buildAvformat 201 - || buildAvutil 202 - || buildPostproc 203 - || buildSwresample 204 - || buildSwscale 205 - /* 206 - * Documentation options 207 - */ 208 - , withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc 209 - , withHtmlDoc ? withHeadlessDeps # HTML documentation pages 210 - , withManPages ? withHeadlessDeps # Man documentation pages 211 - , withPodDoc ? withHeadlessDeps # POD documentation pages 212 - , withTxtDoc ? withHeadlessDeps # Text documentation pages 213 - # Whether a "doc" output will be produced. Note that withManPages does not produce 214 - # a "doc" output because its files go to "man". 215 - , withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc) 216 217 /* 218 - * Developer options 219 - */ 220 - , withDebug ? false 221 - , withOptimisations ? true 222 - , withExtraWarnings ? false 223 - , withStripping ? false 224 225 - /* 226 - * External libraries options 227 - */ 228 - , alsa-lib 229 - , amf 230 - , amf-headers 231 - , aribb24 232 - , avisynthplus 233 - , bzip2 234 - , celt 235 - , chromaprint 236 - , codec2 237 - , clang 238 - , dav1d 239 - , fdk_aac 240 - , flite 241 - , fontconfig 242 - , freetype 243 - , frei0r 244 - , fribidi 245 - , game-music-emu 246 - , gnutls 247 - , gsm 248 - , harfbuzz 249 - , intel-media-sdk 250 - , kvazaar 251 - , ladspaH 252 - , lame 253 - , lcevcdec 254 - , lcms2 255 - , libaom 256 - , libaribcaption 257 - , libass 258 - , libbluray 259 - , libbs2b 260 - , libcaca 261 - , libcdio 262 - , libcdio-paranoia 263 - , libdc1394 264 - , libdrm 265 - , libdvdnav 266 - , libdvdread 267 - , libGL 268 - , libGLU 269 - , libiconv 270 - , libilbc 271 - , libjack2 272 - , libjxl 273 - , liblc3 274 - , libmodplug 275 - , libmysofa 276 - , libopenmpt 277 - , libopus 278 - , libplacebo 279 - , libplacebo_5 280 - , libpulseaudio 281 - , libraw1394 282 - , librist 283 - , librsvg 284 - , libssh 285 - , libtensorflow 286 - , libtheora 287 - , libv4l 288 - , libva 289 - , libva-minimal 290 - , libvdpau 291 - , libvmaf 292 - , libvorbis 293 - , libvpl 294 - , libvpx 295 - , libwebp 296 - , libX11 297 - , libxcb 298 - , libXext 299 - , libxml2 300 - , libXv 301 - , nv-codec-headers 302 - , nv-codec-headers-12 303 - , ocl-icd # OpenCL ICD 304 - , openal 305 - , opencl-headers # OpenCL headers 306 - , opencore-amr 307 - , openh264 308 - , openjpeg 309 - , qrencode 310 - , quirc 311 - , rav1e 312 - , rtmpdump 313 - , rubberband 314 - , twolame 315 - , samba 316 - , SDL2 317 - , shaderc 318 - , shine 319 - , snappy 320 - , soxr 321 - , speex 322 - , srt 323 - , svt-av1 324 - , vid-stab 325 - , vo-amrwbenc 326 - , vulkan-headers 327 - , vulkan-loader 328 - , vvenc 329 - , x264 330 - , x265 331 - , xavs 332 - , xevd 333 - , xeve 334 - , xvidcore 335 - , xz 336 - , zeromq 337 - , zimg 338 - , zlib 339 - , zvbi 340 - /* 341 - * Darwin 342 - */ 343 - , apple-sdk_15 344 - , xcode # unfree contains metalcc and metallib 345 - /* 346 - * Cuda Packages 347 - */ 348 - , cuda_cudart 349 - , cuda_nvcc 350 - , libnpp 351 - /* 352 - * Testing 353 - */ 354 - , testers 355 - }: 356 357 - /* Maintainer notes: 358 - * 359 - * Version bumps: 360 - * It should always be safe to bump patch releases (e.g. 2.1.x, x being a patch release) 361 - * If adding a new branch, note any configure flags that were added, changed, or deprecated/removed 362 - * and make the necessary changes. 363 - * 364 - * Known issues: 365 - * Cross-compiling will disable features not present on host OS 366 - * (e.g. dxva2 support [DirectX] will not be enabled unless natively compiled on Cygwin) 367 - * 368 - */ 369 370 let 371 - inherit (lib) optional optionals optionalString enableFeature versionOlder versionAtLeast; 372 in 373 374 - 375 - assert lib.elem ffmpegVariant [ "headless" "small" "full" ]; 376 377 - /* 378 - * Licensing dependencies 379 - */ 380 assert withGPLv3 -> withGPL && withVersion3; 381 382 - /* 383 - * Build dependencies 384 - */ 385 assert withPixelutils -> buildAvutil; 386 assert !(withMfx && withVpl); # incompatible features 387 - /* 388 - * Program dependencies 389 - */ 390 - assert buildFfmpeg -> buildAvcodec 391 - && buildAvfilter 392 - && buildAvformat 393 - && (buildSwresample || buildAvresample); 394 - assert buildFfplay -> buildAvcodec 395 - && buildAvformat 396 - && buildSwscale 397 - && (buildSwresample || buildAvresample); 398 assert buildFfprobe -> buildAvcodec && buildAvformat; 399 - /* 400 - * Library dependencies 401 - */ 402 assert buildAvcodec -> buildAvutil; # configure flag since 0.6 403 - assert buildAvdevice -> buildAvformat 404 - && buildAvcodec 405 - && buildAvutil; # configure flag since 0.6 406 assert buildAvformat -> buildAvcodec && buildAvutil; # configure flag since 0.6 407 assert buildPostproc -> buildAvutil; 408 assert buildSwscale -> buildAvutil; 409 410 - /* 411 - * External Library dependencies 412 - */ 413 - assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; 414 415 - stdenv.mkDerivation (finalAttrs: { 416 - pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); 417 - inherit version; 418 - src = source; 419 420 - postPatch = '' 421 - patchShebangs . 422 - '' + lib.optionalString withFrei0r '' 423 - substituteInPlace libavfilter/vf_frei0r.c \ 424 - --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 425 - substituteInPlace doc/filters.texi \ 426 - --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 427 - ''; 428 429 - patches = [] 430 - ++ optionals (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") [ 431 - (fetchpatch2 { # this can be removed post 6.1 432 - name = "fix_build_failure_due_to_PropertyKey_EncoderID"; 433 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/cb049d377f54f6b747667a93e4b719380c3e9475"; 434 - hash = "sha256-sxRXKKgUak5vsQTiV7ge8vp+N22CdTIvuczNgVRP72c="; 435 - }) 436 - (fetchpatch2 { 437 - name = "CVE-2024-31582.patch"; 438 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/99debe5f823f45a482e1dc08de35879aa9c74bd2"; 439 - hash = "sha256-+CQ9FXR6Vr/AmsbXFiCUXZcxKj1s8nInEdke/Oc/kUA="; 440 - }) 441 - (fetchpatch2 { 442 - name = "CVE-2024-31578.patch"; 443 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/3bb00c0a420c3ce83c6fafee30270d69622ccad7"; 444 - hash = "sha256-oZMZysBA+/gwaGEM1yvI+8wCadXWE7qLRL6Emap3b8Q="; 445 - }) 446 - (fetchpatch2 { 447 - name = "CVE-2023-49501.patch"; 448 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/4adb93dff05dd947878c67784d98c9a4e13b57a7"; 449 - hash = "sha256-7cwktto3fPMDGvCZCVtB01X8Q9S/4V4bDLUICSNfGgw="; 450 - }) 451 - (fetchpatch2 { 452 - name = "CVE-2023-49502.patch"; 453 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/737ede405b11a37fdd61d19cf25df296a0cb0b75"; 454 - hash = "sha256-mpSJwR9TX5ENjjCKvzuM/9e1Aj/AOiQW0+72oOMl9v8="; 455 - }) 456 - (fetchpatch2 { 457 - name = "CVE-2023-50007.patch"; 458 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/b1942734c7cbcdc9034034373abcc9ecb9644c47"; 459 - hash = "sha256-v0hNcqBtm8GCGAU9UbRUCE0slodOjZCHrkS8e4TrVcQ="; 460 - }) 461 - (fetchpatch2 { 462 - name = "CVE-2023-50008.patch"; 463 - url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/5f87a68cf70dafeab2fb89b42e41a4c29053b89b"; 464 - hash = "sha256-sqUUSOPTPLwu2h8GbAw4SfEf+0oWioz52BcpW1n4v3Y="; 465 - }) 466 - ] 467 - ++ optionals (lib.versionAtLeast version "7.1") [ 468 - ./fix-fate-ffmpeg-spec-disposition-7.1.patch 469 470 - # Expose a private API for Chromium / Qt WebEngine. 471 - (fetchpatch2 { 472 - url = "https://gitlab.archlinux.org/archlinux/packaging/packages/ffmpeg/-/raw/a02c1a15706ea832c0d52a4d66be8fb29499801a/add-av_stream_get_first_dts-for-chromium.patch"; 473 - hash = "sha256-DbH6ieJwDwTjKOdQ04xvRcSLeeLP2Z2qEmqeo8HsPr4="; 474 - }) 475 - ]; 476 477 - configurePlatforms = []; 478 - setOutputFlags = false; # Only accepts some of them 479 - configureFlags = [ 480 - #mingw64 is internally treated as mingw32, so 32 and 64 make no difference here 481 - "--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}" 482 - "--arch=${stdenv.hostPlatform.parsed.cpu.name}" 483 - "--pkg-config=${buildPackages.pkg-config.targetPrefix}pkg-config" 484 - /* 485 - * Licensing flags 486 - */ 487 - (enableFeature withGPL "gpl") 488 - (enableFeature withVersion3 "version3") 489 - (enableFeature withUnfree "nonfree") 490 - /* 491 - * Build flags 492 - */ 493 - (enableFeature withStatic "static") 494 - (enableFeature withShared "shared") 495 - (enableFeature withPic "pic") 496 - (enableFeature withThumb "thumb") 497 498 - (enableFeature withSmallBuild "small") 499 - (enableFeature withRuntimeCPUDetection "runtime-cpudetect") 500 - (enableFeature withGrayscale "gray") 501 - (enableFeature withSwscaleAlpha "swscale-alpha") 502 - (enableFeature withHardcodedTables "hardcoded-tables") 503 - (enableFeature withSafeBitstreamReader "safe-bitstream-reader") 504 505 - (enableFeature (withMultithread && stdenv.hostPlatform.isUnix) "pthreads") 506 - (enableFeature (withMultithread && stdenv.hostPlatform.isWindows) "w32threads") 507 - "--disable-os2threads" # We don't support OS/2 508 509 - (enableFeature withNetwork "network") 510 - (enableFeature withPixelutils "pixelutils") 511 512 - "--datadir=${placeholder "data"}/share/ffmpeg" 513 514 - /* 515 - * Program flags 516 - */ 517 - (enableFeature buildFfmpeg "ffmpeg") 518 - (enableFeature buildFfplay "ffplay") 519 - (enableFeature buildFfprobe "ffprobe") 520 - ] ++ optionals withBin [ 521 - "--bindir=${placeholder "bin"}/bin" 522 - ] ++ [ 523 - /* 524 - * Library flags 525 - */ 526 - (enableFeature buildAvcodec "avcodec") 527 - (enableFeature buildAvdevice "avdevice") 528 - (enableFeature buildAvfilter "avfilter") 529 - (enableFeature buildAvformat "avformat") 530 - ] ++ optionals (lib.versionOlder version "5") [ 531 - # Ffmpeg > 4 doesn't know about the flag anymore 532 - (enableFeature buildAvresample "avresample") 533 - ] ++ [ 534 - (enableFeature buildAvutil "avutil") 535 - (enableFeature (buildPostproc && withGPL) "postproc") 536 - (enableFeature buildSwresample "swresample") 537 - (enableFeature buildSwscale "swscale") 538 - ] ++ optionals withLib [ 539 - "--libdir=${placeholder "lib"}/lib" 540 - "--incdir=${placeholder "dev"}/include" 541 - ] ++ [ 542 - /* 543 - * Documentation flags 544 - */ 545 - (enableFeature withDocumentation "doc") 546 - (enableFeature withHtmlDoc "htmlpages") 547 - (enableFeature withManPages "manpages") 548 - ] ++ optionals withManPages [ 549 - "--mandir=${placeholder "man"}/share/man" 550 - ] ++ [ 551 - (enableFeature withPodDoc "podpages") 552 - (enableFeature withTxtDoc "txtpages") 553 - ] ++ optionals withDoc [ 554 - "--docdir=${placeholder "doc"}/share/doc/ffmpeg" 555 - ] ++ [ 556 - /* 557 - * External libraries 558 - */ 559 - (enableFeature withAlsa "alsa") 560 - (enableFeature withAmf "amf") 561 - (enableFeature withAom "libaom") 562 - (enableFeature withAribb24 "libaribb24") 563 - ] ++ optionals (versionAtLeast version "6.1") [ 564 - (enableFeature withAribcaption "libaribcaption") 565 - ] ++ [ 566 - (enableFeature withAss "libass") 567 - (enableFeature withAvisynth "avisynth") 568 - (enableFeature withBluray "libbluray") 569 - (enableFeature withBs2b "libbs2b") 570 - (enableFeature withBzlib "bzlib") 571 - (enableFeature withCaca "libcaca") 572 - (enableFeature withCdio "libcdio") 573 - (enableFeature withCelt "libcelt") 574 - (enableFeature withChromaprint "chromaprint") 575 - (enableFeature withCodec2 "libcodec2") 576 - (enableFeature withCuda "cuda") 577 - (enableFeature withCudaLLVM "cuda-llvm") 578 - (enableFeature withCudaNVCC "cuda-nvcc") 579 - (enableFeature withCuvid "cuvid") 580 - (enableFeature withDav1d "libdav1d") 581 - (enableFeature withDc1394 "libdc1394") 582 - (enableFeature withDrm "libdrm") 583 - ] ++ optionals (versionAtLeast version "7") [ 584 - (enableFeature withDvdnav "libdvdnav") 585 - (enableFeature withDvdread "libdvdread") 586 - ] ++ [ 587 - (enableFeature withFdkAac "libfdk-aac") 588 - (enableFeature withNvcodec "ffnvcodec") 589 - (enableFeature withFlite "libflite") 590 - (enableFeature withFontconfig "fontconfig") 591 - (enableFeature withFontconfig "libfontconfig") 592 - (enableFeature withFreetype "libfreetype") 593 - (enableFeature withFrei0r "frei0r") 594 - (enableFeature withFribidi "libfribidi") 595 - (enableFeature withGme "libgme") 596 - (enableFeature withGnutls "gnutls") 597 - (enableFeature withGsm "libgsm") 598 - ] ++ optionals (versionAtLeast version "6.1") [ 599 - (enableFeature withHarfbuzz "libharfbuzz") 600 - ] ++ [ 601 - (enableFeature withIconv "iconv") 602 - (enableFeature withIlbc "libilbc") 603 - (enableFeature withJack "libjack") 604 - ] ++ optionals (versionAtLeast finalAttrs.version "5.0") [ 605 - (enableFeature withJxl "libjxl") 606 - ] ++ [ 607 - (enableFeature withKvazaar "libkvazaar") 608 - (enableFeature withLadspa "ladspa") 609 - ] ++ optionals (versionAtLeast version "7.1") [ 610 - (enableFeature withLc3 "liblc3") 611 - (enableFeature withLcevcdec "liblcevc-dec") 612 - ] ++ optionals (versionAtLeast version "5.1") [ 613 - (enableFeature withLcms2 "lcms2") 614 - ] ++ [ 615 - (enableFeature withLzma "lzma") 616 - ] ++ optionals (versionAtLeast version "5.0") [ 617 - (enableFeature withMetal "metal") 618 - ] ++ [ 619 - (enableFeature withMfx "libmfx") 620 - (enableFeature withModplug "libmodplug") 621 - (enableFeature withMp3lame "libmp3lame") 622 - (enableFeature withMysofa "libmysofa") 623 - (enableFeature withNpp "libnpp") 624 - (enableFeature withNvdec "nvdec") 625 - (enableFeature withNvenc "nvenc") 626 - (enableFeature withOpenal "openal") 627 - (enableFeature withOpencl "opencl") 628 - (enableFeature withOpencoreAmrnb "libopencore-amrnb") 629 - (enableFeature withOpencoreAmrwb "libopencore-amrwb") 630 - (enableFeature withOpengl "opengl") 631 - (enableFeature withOpenh264 "libopenh264") 632 - (enableFeature withOpenjpeg "libopenjpeg") 633 - (enableFeature withOpenmpt "libopenmpt") 634 - (enableFeature withOpus "libopus") 635 - ] ++ optionals (versionAtLeast version "5.0") [ 636 - (enableFeature withPlacebo "libplacebo") 637 - ] ++ [ 638 - (enableFeature withPulse "libpulse") 639 - ] ++ optionals (versionAtLeast version "7") [ 640 - (enableFeature withQrencode "libqrencode") 641 - (enableFeature withQuirc "libquirc") 642 - ] ++ [ 643 - (enableFeature withRav1e "librav1e") 644 - (enableFeature withRist "librist") 645 - (enableFeature withRtmp "librtmp") 646 - (enableFeature withRubberband "librubberband") 647 - (enableFeature withSamba "libsmbclient") 648 - (enableFeature withSdl2 "sdl2") 649 - ] ++ optionals (versionAtLeast version "5.0") [ 650 - (enableFeature withShaderc "libshaderc") 651 - ] ++ [ 652 - (enableFeature withShine "libshine") 653 - (enableFeature withSnappy "libsnappy") 654 - (enableFeature withSoxr "libsoxr") 655 - (enableFeature withSpeex "libspeex") 656 - (enableFeature withSrt "libsrt") 657 - (enableFeature withSsh "libssh") 658 - (enableFeature withSvg "librsvg") 659 - (enableFeature withSvtav1 "libsvtav1") 660 - (enableFeature withTensorflow "libtensorflow") 661 - (enableFeature withTheora "libtheora") 662 - (enableFeature withTwolame "libtwolame") 663 - (enableFeature withV4l2 "libv4l2") 664 - (enableFeature withV4l2M2m "v4l2-m2m") 665 - (enableFeature withVaapi "vaapi") 666 - (enableFeature withVdpau "vdpau") 667 - ] ++ optionals (versionAtLeast version "6.0") [ 668 - (enableFeature withVpl "libvpl") 669 - ] ++ [ 670 - (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 671 - (enableFeature withVmaf "libvmaf") 672 - (enableFeature withVoAmrwbenc "libvo-amrwbenc") 673 - (enableFeature withVorbis "libvorbis") 674 - (enableFeature withVpx "libvpx") 675 - (enableFeature withVulkan "vulkan") 676 - ] ++ optionals (versionAtLeast version "7.1") [ 677 - (enableFeature withVvenc "libvvenc") 678 - ] ++ [ 679 - (enableFeature withWebp "libwebp") 680 - (enableFeature withX264 "libx264") 681 - (enableFeature withX265 "libx265") 682 - (enableFeature withXavs "libxavs") 683 - (enableFeature withXcb "libxcb") 684 - (enableFeature withXcbShape "libxcb-shape") 685 - (enableFeature withXcbShm "libxcb-shm") 686 - (enableFeature withXcbxfixes "libxcb-xfixes") 687 - ] ++ optionals (versionAtLeast version "7") [ 688 - (enableFeature withXevd "libxevd") 689 - (enableFeature withXeve "libxeve") 690 - ] ++ [ 691 - (enableFeature withXlib "xlib") 692 - (enableFeature withXml2 "libxml2") 693 - (enableFeature withXvid "libxvid") 694 - (enableFeature withZimg "libzimg") 695 - (enableFeature withZlib "zlib") 696 - (enableFeature withZmq "libzmq") 697 - (enableFeature withZvbi "libzvbi") 698 - /* 699 - * Developer flags 700 - */ 701 - (enableFeature withDebug "debug") 702 - (enableFeature withOptimisations "optimizations") 703 - (enableFeature withExtraWarnings "extra-warnings") 704 - (enableFeature withStripping "stripping") 705 - ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 706 - "--cross-prefix=${stdenv.cc.targetPrefix}" 707 - "--enable-cross-compile" 708 - "--host-cc=${buildPackages.stdenv.cc}/bin/cc" 709 - ] ++ optionals stdenv.cc.isClang [ 710 - "--cc=${stdenv.cc.targetPrefix}clang" 711 - "--cxx=${stdenv.cc.targetPrefix}clang++" 712 - ] ++ optionals withMetal [ 713 - "--metalcc=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal" 714 - "--metallib=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metallib" 715 - ]; 716 717 - # ffmpeg embeds the configureFlags verbatim in its binaries and because we 718 - # configure binary, include, library dir etc., this causes references in 719 - # outputs where we don't want them. Patch the generated config.h to remove all 720 - # such references except for data. 721 - postConfigure = let 722 - toStrip = map placeholder (lib.remove "data" finalAttrs.outputs) # We want to keep references to the data dir. 723 - ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.stdenv.cc 724 - ++ lib.optional withMetal xcode; 725 - in 726 - "remove-references-to ${lib.concatStringsSep " " (map (o: "-t ${o}") toStrip)} config.h"; 727 728 - strictDeps = true; 729 730 - nativeBuildInputs = [ removeReferencesTo addDriverRunpath perl pkg-config yasm ] 731 - # Texinfo version 7.1 introduced breaking changes, which older versions of ffmpeg do not handle. 732 - ++ (if versionOlder version "5" then [ texinfo6 ] else [ texinfo ]) 733 - ++ optionals withCudaLLVM [ clang ] 734 - ++ optionals withCudaNVCC [ cuda_nvcc ]; 735 736 - buildInputs = [] 737 - ++ optionals stdenv.hostPlatform.isDarwin [ apple-sdk_15 ] 738 - ++ optionals withAlsa [ alsa-lib ] 739 - ++ optionals withAmf [ amf-headers ] 740 - ++ optionals withAom [ libaom ] 741 - ++ optionals withAribb24 [ aribb24 ] 742 - ++ optionals withAribcaption [ libaribcaption ] 743 - ++ optionals withAss [ libass ] 744 - ++ optionals withAvisynth [ avisynthplus ] 745 - ++ optionals withBluray [ libbluray ] 746 - ++ optionals withBs2b [ libbs2b ] 747 - ++ optionals withBzlib [ bzip2 ] 748 - ++ optionals withCaca [ libcaca ] 749 - ++ optionals withCdio [ libcdio libcdio-paranoia ] 750 - ++ optionals withCelt [ celt ] 751 - ++ optionals withChromaprint [ chromaprint ] 752 - ++ optionals withCodec2 [ codec2 ] 753 - ++ optionals withCudaNVCC [ cuda_cudart cuda_nvcc ] 754 - ++ optionals withDav1d [ dav1d ] 755 - ++ optionals withDc1394 [ libdc1394 libraw1394 ] 756 - ++ optionals withDrm [ libdrm ] 757 - ++ optionals withDvdnav [ libdvdnav ] 758 - ++ optionals withDvdread [ libdvdread ] 759 - ++ optionals withFdkAac [ fdk_aac ] 760 - ++ optionals withNvcodec [ (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers) ] 761 - ++ optionals withFlite [ flite ] 762 - ++ optionals withFontconfig [ fontconfig ] 763 - ++ optionals withFreetype [ freetype ] 764 - ++ optionals withFrei0r [ frei0r ] 765 - ++ optionals withFribidi [ fribidi ] 766 - ++ optionals withGme [ game-music-emu ] 767 - ++ optionals withGnutls [ gnutls ] 768 - ++ optionals withGsm [ gsm ] 769 - ++ optionals withHarfbuzz [ harfbuzz ] 770 - ++ optionals withIconv [ libiconv ] # On Linux this should be in libc, do we really need it? 771 - ++ optionals withIlbc [ libilbc ] 772 - ++ optionals withJack [ libjack2 ] 773 - ++ optionals withJxl [ libjxl ] 774 - ++ optionals withKvazaar [ kvazaar ] 775 - ++ optionals withLadspa [ ladspaH ] 776 - ++ optionals withLc3 [ liblc3 ] 777 - ++ optionals withLcevcdec [ lcevcdec ] 778 - ++ optionals withLcms2 [ lcms2 ] 779 - ++ optionals withLzma [ xz ] 780 - ++ optionals withMfx [ intel-media-sdk ] 781 - ++ optionals withModplug [ libmodplug ] 782 - ++ optionals withMp3lame [ lame ] 783 - ++ optionals withMysofa [ libmysofa ] 784 - ++ optionals withNpp [ libnpp cuda_cudart cuda_nvcc ] 785 - ++ optionals withOpenal [ openal ] 786 - ++ optionals withOpencl [ ocl-icd opencl-headers ] 787 - ++ optionals (withOpencoreAmrnb || withOpencoreAmrwb) [ opencore-amr ] 788 - ++ optionals withOpengl [ libGL libGLU ] 789 - ++ optionals withOpenh264 [ openh264 ] 790 - ++ optionals withOpenjpeg [ openjpeg ] 791 - ++ optionals withOpenmpt [ libopenmpt ] 792 - ++ optionals withOpus [ libopus ] 793 - ++ optionals withPlacebo [ (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) vulkan-headers ] 794 - ++ optionals withPulse [ libpulseaudio ] 795 - ++ optionals withQrencode [ qrencode ] 796 - ++ optionals withQuirc [ quirc ] 797 - ++ optionals withRav1e [ rav1e ] 798 - ++ optionals withRist [ librist ] 799 - ++ optionals withRtmp [ rtmpdump ] 800 - ++ optionals withRubberband [ rubberband ] 801 - ++ optionals withSamba [ samba ] 802 - ++ optionals withSdl2 [ SDL2 ] 803 - ++ optionals withShaderc [ shaderc ] 804 - ++ optionals withShine [ shine ] 805 - ++ optionals withSnappy [ snappy ] 806 - ++ optionals withSoxr [ soxr ] 807 - ++ optionals withSpeex [ speex ] 808 - ++ optionals withSrt [ srt ] 809 - ++ optionals withSsh [ libssh ] 810 - ++ optionals withSvg [ librsvg ] 811 - ++ optionals withSvtav1 [ svt-av1 ] 812 - ++ optionals withTensorflow [ libtensorflow ] 813 - ++ optionals withTheora [ libtheora ] 814 - ++ optionals withTwolame [ twolame ] 815 - ++ optionals withV4l2 [ libv4l ] 816 - ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] 817 - ++ optionals withVdpau [ libvdpau ] 818 - ++ optionals withVidStab [ vid-stab ] 819 - ++ optionals withVmaf [ libvmaf ] 820 - ++ optionals withVoAmrwbenc [ vo-amrwbenc ] 821 - ++ optionals withVorbis [ libvorbis ] 822 - ++ optionals withVpl [ libvpl ] 823 - ++ optionals withVpx [ libvpx ] 824 - ++ optionals withVulkan [ vulkan-headers vulkan-loader ] 825 - ++ optionals withVvenc [ vvenc ] 826 - ++ optionals withWebp [ libwebp ] 827 - ++ optionals withX264 [ x264 ] 828 - ++ optionals withX265 [ x265 ] 829 - ++ optionals withXavs [ xavs ] 830 - ++ optionals withXcb [ libxcb ] 831 - ++ optionals withXevd [ xevd ] 832 - ++ optionals withXeve [ xeve ] 833 - ++ optionals withXlib [ libX11 libXv libXext ] 834 - ++ optionals withXml2 [ libxml2 ] 835 - ++ optionals withXvid [ xvidcore ] 836 - ++ optionals withZimg [ zimg ] 837 - ++ optionals withZlib [ zlib ] 838 - ++ optionals withZmq [ zeromq ] 839 - ++ optionals withZvbi [ zvbi ] 840 - ; 841 842 - buildFlags = [ "all" ] 843 - ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable 844 845 - env = lib.optionalAttrs stdenv.cc.isGNU { 846 - NIX_CFLAGS_COMPILE = toString [ 847 - "-Wno-error=incompatible-pointer-types" 848 - "-Wno-error=int-conversion" 849 - ]; 850 - }; 851 852 - doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; 853 854 - # Fails with SIGABRT otherwise FIXME: Why? 855 - checkPhase = let 856 - ldLibraryPathEnv = if stdenv.hostPlatform.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; 857 - libsToLink = [ ] 858 - ++ optional buildAvcodec "libavcodec" 859 - ++ optional buildAvdevice "libavdevice" 860 - ++ optional buildAvfilter "libavfilter" 861 - ++ optional buildAvformat "libavformat" 862 - ++ optional buildAvresample "libavresample" 863 - ++ optional buildAvutil "libavutil" 864 - ++ optional buildPostproc "libpostproc" 865 - ++ optional buildSwresample "libswresample" 866 - ++ optional buildSwscale "libswscale" 867 ; 868 - in '' 869 - ${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES 870 - ''; 871 872 - outputs = optionals withBin [ "bin" ] # The first output is the one that gets symlinked by default! 873 - ++ optionals withLib [ "lib" "dev" ] 874 - ++ optionals withDoc [ "doc" ] 875 - ++ optionals withManPages [ "man" ] 876 - ++ [ "data" "out" ] # We need an "out" output because we get an error otherwise. It's just an empty dir. 877 - ; 878 - 879 - postInstall = optionalString buildQtFaststart '' 880 - install -D tools/qt-faststart -t $bin/bin 881 - ''; 882 883 - # Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found. 884 - # See the explanation in addDriverRunpath. 885 - postFixup = optionalString (stdenv.hostPlatform.isLinux && withLib) '' 886 - addDriverRunpath ${placeholder "lib"}/lib/libavcodec.so 887 - addDriverRunpath ${placeholder "lib"}/lib/libavutil.so 888 - '' 889 - # https://trac.ffmpeg.org/ticket/10809 890 - + optionalString (versionAtLeast version "5.0" && withVulkan && !stdenv.hostPlatform.isMinGW) '' 891 - patchelf $lib/lib/libavcodec.so --add-needed libvulkan.so --add-rpath ${lib.makeLibraryPath [ vulkan-loader ]} 892 - ''; 893 894 - enableParallelBuilding = true; 895 896 - passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 897 898 - meta = with lib; { 899 - description = "Complete, cross-platform solution to record, convert and stream audio and video"; 900 - homepage = "https://www.ffmpeg.org/"; 901 - changelog = "https://github.com/FFmpeg/FFmpeg/blob/n${version}/Changelog"; 902 - longDescription = '' 903 - FFmpeg is the leading multimedia framework, able to decode, encode, transcode, 904 - mux, demux, stream, filter and play pretty much anything that humans and machines 905 - have created. It supports the most obscure ancient formats up to the cutting edge. 906 - No matter if they were designed by some standards committee, the community or 907 - a corporation. 908 - ''; 909 - license = with licenses; [ lgpl21Plus ] 910 - ++ optional withGPL gpl2Plus 911 - ++ optional withVersion3 lgpl3Plus 912 - ++ optional withGPLv3 gpl3Plus 913 - ++ optional withUnfree unfreeRedistributable 914 - ++ optional (withGPL && withUnfree) unfree; 915 - pkgConfigModules = [ ] 916 - ++ optional buildAvcodec "libavcodec" 917 - ++ optional buildAvdevice "libavdevice" 918 - ++ optional buildAvfilter "libavfilter" 919 - ++ optional buildAvformat "libavformat" 920 - ++ optional buildAvresample "libavresample" 921 - ++ optional buildAvutil "libavutil" 922 - ++ optional buildPostproc "libpostproc" 923 - ++ optional buildSwresample "libswresample" 924 - ++ optional buildSwscale "libswscale"; 925 - platforms = platforms.all; 926 - # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 927 - broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; 928 - maintainers = with maintainers; [ atemu jopejoe1 emily ]; 929 - mainProgram = "ffmpeg"; 930 - }; 931 - } // lib.optionalAttrs withCudaLLVM { 932 - # remove once https://github.com/NixOS/nixpkgs/issues/318674 is addressed properly 933 - hardeningDisable = [ "zerocallusedregs" ]; 934 - })
··· 1 + { 2 + lib, 3 + config, 4 + stdenv, 5 + buildPackages, 6 + removeReferencesTo, 7 + addDriverRunpath, 8 + pkg-config, 9 + perl, 10 + texinfo, 11 + texinfo6, 12 + yasm, 13 14 # You can fetch any upstream version using this derivation by specifying version and hash 15 # NOTICE: Always use this argument to override the version. Do not use overrideAttrs. 16 + version, # ffmpeg ABI version. Also declare this if you're overriding the source. 17 + hash ? "", # hash of the upstream source for the given ABI version 18 + source ? fetchgit { 19 url = "https://git.ffmpeg.org/ffmpeg.git"; 20 rev = "n${version}"; 21 inherit hash; 22 + }, 23 24 + ffmpegVariant ? "small", # Decides which dependencies are enabled by default 25 26 # Build with headless deps; excludes dependencies that are only necessary for 27 # GUI applications. To be used for purposes that don't generally need such 28 # components and i.e. only depend on libav 29 + withHeadlessDeps ? ffmpegVariant == "headless" || withSmallDeps, 30 31 # Dependencies a user might customarily expect from a regular ffmpeg build. 32 # /All/ packages that depend on ffmpeg and some of its feaures should depend 33 # on the small variant. Small means the minimal set of features that satisfies 34 # all dependants in Nixpkgs 35 + withSmallDeps ? ffmpegVariant == "small" || withFullDeps, 36 37 # Everything enabled; only guarded behind platform exclusivity or brokeness. 38 # If you need to depend on ffmpeg-full because ffmpeg is missing some feature 39 # your package needs, you should enable that feature in regular ffmpeg 40 # instead. 41 + withFullDeps ? ffmpegVariant == "full", 42 43 + fetchgit, 44 + fetchpatch2, 45 46 # Feature flags 47 + withAlsa ? withHeadlessDeps && stdenv.hostPlatform.isLinux, # Alsa in/output supporT 48 + withAmf ? withHeadlessDeps && lib.meta.availableOn stdenv.hostPlatform amf, # AMD Media Framework video encoding 49 + withAom ? withHeadlessDeps, # AV1 reference encoder 50 + withAribb24 ? withFullDeps, # ARIB text and caption decoding 51 + withAribcaption ? withFullDeps && lib.versionAtLeast version "6.1", # ARIB STD-B24 Caption Decoder/Renderer 52 + withAss ? withHeadlessDeps && stdenv.hostPlatform == stdenv.buildPlatform, # (Advanced) SubStation Alpha subtitle rendering 53 + withAvisynth ? withFullDeps, # AviSynth script files reading 54 + withBluray ? withHeadlessDeps, # BluRay reading 55 + withBs2b ? withFullDeps, # bs2b DSP library 56 + withBzlib ? withHeadlessDeps, 57 + withCaca ? withFullDeps, # Textual display (ASCII art) 58 + withCdio ? withFullDeps && withGPL, # Audio CD grabbing 59 + withCelt ? withHeadlessDeps, # CELT decoder 60 + withChromaprint ? withFullDeps, # Audio fingerprinting 61 + withCodec2 ? withFullDeps, # codec2 en/decoding 62 + withCuda ? withFullDeps && withNvcodec, 63 + withCudaLLVM ? withHeadlessDeps, 64 + withCudaNVCC ? withFullDeps && withUnfree && config.cudaSupport, 65 + withCuvid ? withHeadlessDeps && withNvcodec, 66 + withDav1d ? withHeadlessDeps, # AV1 decoder (focused on speed and correctness) 67 + withDc1394 ? withFullDeps && !stdenv.hostPlatform.isDarwin, # IIDC-1394 grabbing (ieee 1394) 68 + withDrm ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD), # libdrm support 69 + withDvdnav ? withFullDeps && withGPL && lib.versionAtLeast version "7", # needed for DVD demuxing 70 + withDvdread ? withFullDeps && withGPL && lib.versionAtLeast version "7", # needed for DVD demuxing 71 + withFdkAac ? withFullDeps && (!withGPL || withUnfree), # Fraunhofer FDK AAC de/encoder 72 + withNvcodec ? 73 + withHeadlessDeps 74 + && ( 75 + with stdenv; !isDarwin && !isAarch32 && !hostPlatform.isRiscV && hostPlatform == buildPlatform 76 + ), # dynamically linked Nvidia code 77 + withFlite ? withFullDeps, # Voice Synthesis 78 + withFontconfig ? withHeadlessDeps, # Needed for drawtext filter 79 + withFreetype ? withHeadlessDeps, # Needed for drawtext filter 80 + withFrei0r ? withFullDeps && withGPL, # frei0r video filtering 81 + withFribidi ? withHeadlessDeps, # Needed for drawtext filter 82 + withGme ? withFullDeps, # Game Music Emulator 83 + withGnutls ? withHeadlessDeps, 84 + withGsm ? withFullDeps, # GSM de/encoder 85 + withHarfbuzz ? withHeadlessDeps && lib.versionAtLeast version "6.1", # Needed for drawtext filter 86 + withIconv ? withHeadlessDeps, 87 + withIlbc ? withFullDeps, # iLBC de/encoding 88 + withJack ? withFullDeps && !stdenv.hostPlatform.isDarwin, # Jack audio 89 + withJxl ? withFullDeps && lib.versionAtLeast version "5", # JPEG XL de/encoding 90 + withKvazaar ? withFullDeps, # HEVC encoding 91 + withLadspa ? withFullDeps, # LADSPA audio filtering 92 + withLc3 ? withFullDeps && lib.versionAtLeast version "7.1", # LC3 de/encoding 93 + withLcevcdec ? false && lib.versionAtLeast version "7.1", # LCEVC decoding # FIXME currently makes ffmpeg crash in any operation on non-AVX CPUs 94 + withLcms2 ? withFullDeps, # ICC profile support via lcms2 95 + withLzma ? withHeadlessDeps, # xz-utils 96 + withMetal ? false, # Unfree and requires manual downloading of files 97 + withMfx ? withFullDeps && (with stdenv.hostPlatform; isLinux && !isAarch), # Hardware acceleration via intel-media-sdk/libmfx 98 + withModplug ? withFullDeps && !stdenv.hostPlatform.isDarwin, # ModPlug support 99 + withMp3lame ? withHeadlessDeps, # LAME MP3 encoder 100 + withMysofa ? withFullDeps, # HRTF support via SOFAlizer 101 + withNpp ? withFullDeps && withUnfree && config.cudaSupport, # Nvidia Performance Primitives-based code 102 + withNvdec ? withHeadlessDeps && withNvcodec, 103 + withNvenc ? withHeadlessDeps && withNvcodec, 104 + withOpenal ? withFullDeps, # OpenAL 1.1 capture support 105 + withOpencl ? withHeadlessDeps, 106 + withOpencoreAmrnb ? withFullDeps && withVersion3, # AMR-NB de/encoder 107 + withOpencoreAmrwb ? withFullDeps && withVersion3, # AMR-WB decoder 108 + withOpengl ? withFullDeps && !stdenv.hostPlatform.isDarwin, # OpenGL rendering 109 + withOpenh264 ? withFullDeps, # H.264/AVC encoder 110 + withOpenjpeg ? withHeadlessDeps, # JPEG 2000 de/encoder 111 + withOpenmpt ? withHeadlessDeps, # Tracked music files decoder 112 + withOpus ? withHeadlessDeps, # Opus de/encoder 113 + withPlacebo ? withFullDeps && !stdenv.hostPlatform.isDarwin, # libplacebo video processing library 114 + withPulse ? withSmallDeps && stdenv.hostPlatform.isLinux, # Pulseaudio input support 115 + withQrencode ? withFullDeps && lib.versionAtLeast version "7", # QR encode generation 116 + withQuirc ? withFullDeps && lib.versionAtLeast version "7", # QR decoding 117 + withRav1e ? withFullDeps, # AV1 encoder (focused on speed and safety) 118 + withRist ? withHeadlessDeps, # Reliable Internet Stream Transport (RIST) protocol 119 + withRtmp ? withFullDeps, # RTMP[E] support 120 + withRubberband ? withFullDeps && withGPL && !stdenv.hostPlatform.isFreeBSD, # Rubberband filter 121 + withSamba ? withFullDeps && !stdenv.hostPlatform.isDarwin && withGPLv3, # Samba protocol 122 + withSdl2 ? withSmallDeps, 123 + withShaderc ? withFullDeps && !stdenv.hostPlatform.isDarwin && lib.versionAtLeast version "5.0", 124 + withShine ? withFullDeps, # Fixed-point MP3 encoding 125 + withSnappy ? withFullDeps, # Snappy compression, needed for hap encoding 126 + withSoxr ? withHeadlessDeps, # Resampling via soxr 127 + withSpeex ? withHeadlessDeps, # Speex de/encoder 128 + withSrt ? withHeadlessDeps, # Secure Reliable Transport (SRT) protocol 129 + withSsh ? withHeadlessDeps, # SFTP protocol 130 + withSvg ? withFullDeps, # SVG protocol 131 + withSvtav1 ? withHeadlessDeps && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMinGW, # AV1 encoder/decoder (focused on speed and correctness) 132 + withTensorflow ? false, # Tensorflow dnn backend support (Increases closure size by ~390 MiB) 133 + withTheora ? withHeadlessDeps, # Theora encoder 134 + withTwolame ? withFullDeps, # MP2 encoding 135 + withV4l2 ? withHeadlessDeps && stdenv.hostPlatform.isLinux, # Video 4 Linux support 136 + withV4l2M2m ? withV4l2, 137 + withVaapi ? withHeadlessDeps && (with stdenv; isLinux || isFreeBSD), # Vaapi hardware acceleration 138 + withVdpau ? withSmallDeps && !stdenv.hostPlatform.isMinGW, # Vdpau hardware acceleration 139 + withVidStab ? withHeadlessDeps && withGPL, # Video stabilization 140 + withVmaf ? withFullDeps && !stdenv.hostPlatform.isAarch64 && lib.versionAtLeast version "5", # Netflix's VMAF (Video Multi-Method Assessment Fusion) 141 + withVoAmrwbenc ? withFullDeps && withVersion3, # AMR-WB encoder 142 + withVorbis ? withHeadlessDeps, # Vorbis de/encoding, native encoder exists 143 + withVpl ? false, # Hardware acceleration via intel libvpl 144 + withVpx ? withHeadlessDeps && stdenv.buildPlatform == stdenv.hostPlatform, # VP8 & VP9 de/encoding 145 + withVulkan ? withHeadlessDeps && !stdenv.hostPlatform.isDarwin, 146 + withVvenc ? withFullDeps && lib.versionAtLeast version "7.1", # H.266/VVC encoding 147 + withWebp ? withHeadlessDeps, # WebP encoder 148 + withX264 ? withHeadlessDeps && withGPL, # H.264/AVC encoder 149 + withX265 ? withHeadlessDeps && withGPL, # H.265/HEVC encoder 150 + withXavs ? withFullDeps && withGPL, # AVS encoder 151 + withXcb ? withXcbShm || withXcbxfixes || withXcbShape, # X11 grabbing using XCB 152 + withXcbShape ? withFullDeps, # X11 grabbing shape rendering 153 + withXcbShm ? withFullDeps, # X11 grabbing shm communication 154 + withXcbxfixes ? withFullDeps, # X11 grabbing mouse rendering 155 + withXevd ? withFullDeps && lib.versionAtLeast version "7.1" && !xevd.meta.broken, # MPEG-5 EVC decoding 156 + withXeve ? withFullDeps && lib.versionAtLeast version "7.1" && !xeve.meta.broken, # MPEG-5 EVC encoding 157 + withXlib ? withFullDeps, # Xlib support 158 + withXml2 ? withHeadlessDeps, # libxml2 support, for IMF and DASH demuxers 159 + withXvid ? withHeadlessDeps && withGPL, # Xvid encoder, native encoder exists 160 + withZimg ? withHeadlessDeps, 161 + withZlib ? withHeadlessDeps, 162 + withZmq ? withFullDeps, # Message passing 163 + withZvbi ? withHeadlessDeps, # Teletext support 164 + 165 + # Licensing options (yes some are listed twice, filters and such are not listed) 166 + withGPL ? true, 167 + withVersion3 ? true, # When withGPL is set this implies GPLv3 otherwise it is LGPLv3 168 + withGPLv3 ? withGPL && withVersion3, 169 + withUnfree ? false, 170 + 171 + # Build options 172 + withSmallBuild ? false, # Optimize for size instead of speed 173 + withRuntimeCPUDetection ? true, # Detect CPU capabilities at runtime (disable to compile natively) 174 + withGrayscale ? withFullDeps, # Full grayscale support 175 + withSwscaleAlpha ? buildSwscale, # Alpha channel support in swscale. You probably want this when buildSwscale. 176 + withHardcodedTables ? withHeadlessDeps, # Hardcode decode tables instead of runtime generation 177 + withSafeBitstreamReader ? withHeadlessDeps, # Buffer boundary checking in bitreaders 178 + withMultithread ? true, # Multithreading via pthreads/win32 threads 179 + withNetwork ? withHeadlessDeps, # Network support 180 + withPixelutils ? withHeadlessDeps, # Pixel utils in libavutil 181 + withStatic ? stdenv.hostPlatform.isStatic, 182 + withShared ? !stdenv.hostPlatform.isStatic, 183 + withPic ? true, 184 + withThumb ? false, # On some ARM platforms 185 186 + # Program options 187 + buildFfmpeg ? withHeadlessDeps, # Build ffmpeg executable 188 + buildFfplay ? withSmallDeps, # Build ffplay executable 189 + buildFfprobe ? withHeadlessDeps, # Build ffprobe executable 190 + buildQtFaststart ? withFullDeps, # Build qt-faststart executable 191 + withBin ? buildFfmpeg || buildFfplay || buildFfprobe || buildQtFaststart, 192 + # Library options 193 + buildAvcodec ? withHeadlessDeps, # Build avcodec library 194 + buildAvdevice ? withHeadlessDeps, # Build avdevice library 195 + buildAvfilter ? withHeadlessDeps, # Build avfilter library 196 + buildAvformat ? withHeadlessDeps, # Build avformat library 197 + # Deprecated but depended upon by some packages. 198 + # https://github.com/NixOS/nixpkgs/pull/211834#issuecomment-1417435991) 199 + buildAvresample ? withHeadlessDeps && lib.versionOlder version "5", # Build avresample library 200 + buildAvutil ? withHeadlessDeps, # Build avutil library 201 + buildPostproc ? withHeadlessDeps, # Build postproc library 202 + buildSwresample ? withHeadlessDeps, # Build swresample library 203 + buildSwscale ? withHeadlessDeps, # Build swscale library 204 + withLib ? 205 + buildAvcodec 206 + || buildAvdevice 207 + || buildAvfilter 208 + || buildAvformat 209 + || buildAvutil 210 + || buildPostproc 211 + || buildSwresample 212 + || buildSwscale, 213 + # Documentation options 214 + withDocumentation ? withHtmlDoc || withManPages || withPodDoc || withTxtDoc, 215 + withHtmlDoc ? withHeadlessDeps, # HTML documentation pages 216 + withManPages ? withHeadlessDeps, # Man documentation pages 217 + withPodDoc ? withHeadlessDeps, # POD documentation pages 218 + withTxtDoc ? withHeadlessDeps, # Text documentation pages 219 + # Whether a "doc" output will be produced. Note that withManPages does not produce 220 + # a "doc" output because its files go to "man". 221 + withDoc ? withDocumentation && (withHtmlDoc || withPodDoc || withTxtDoc), 222 223 + # Developer options 224 + withDebug ? false, 225 + withOptimisations ? true, 226 + withExtraWarnings ? false, 227 + withStripping ? false, 228 229 + # External libraries options 230 + alsa-lib, 231 + amf, 232 + amf-headers, 233 + aribb24, 234 + avisynthplus, 235 + bzip2, 236 + celt, 237 + chromaprint, 238 + codec2, 239 + clang, 240 + dav1d, 241 + fdk_aac, 242 + flite, 243 + fontconfig, 244 + freetype, 245 + frei0r, 246 + fribidi, 247 + game-music-emu, 248 + gnutls, 249 + gsm, 250 + harfbuzz, 251 + intel-media-sdk, 252 + kvazaar, 253 + ladspaH, 254 + lame, 255 + lcevcdec, 256 + lcms2, 257 + libaom, 258 + libaribcaption, 259 + libass, 260 + libbluray, 261 + libbs2b, 262 + libcaca, 263 + libcdio, 264 + libcdio-paranoia, 265 + libdc1394, 266 + libdrm, 267 + libdvdnav, 268 + libdvdread, 269 + libGL, 270 + libGLU, 271 + libiconv, 272 + libilbc, 273 + libjack2, 274 + libjxl, 275 + liblc3, 276 + libmodplug, 277 + libmysofa, 278 + libopenmpt, 279 + libopus, 280 + libplacebo, 281 + libplacebo_5, 282 + libpulseaudio, 283 + libraw1394, 284 + librist, 285 + librsvg, 286 + libssh, 287 + libtensorflow, 288 + libtheora, 289 + libv4l, 290 + libva, 291 + libva-minimal, 292 + libvdpau, 293 + libvmaf, 294 + libvorbis, 295 + libvpl, 296 + libvpx, 297 + libwebp, 298 + libX11, 299 + libxcb, 300 + libXext, 301 + libxml2, 302 + libXv, 303 + nv-codec-headers, 304 + nv-codec-headers-12, 305 + ocl-icd, # OpenCL ICD 306 + openal, 307 + opencl-headers, # OpenCL headers 308 + opencore-amr, 309 + openh264, 310 + openjpeg, 311 + qrencode, 312 + quirc, 313 + rav1e, 314 + rtmpdump, 315 + rubberband, 316 + twolame, 317 + samba, 318 + SDL2, 319 + shaderc, 320 + shine, 321 + snappy, 322 + soxr, 323 + speex, 324 + srt, 325 + svt-av1, 326 + vid-stab, 327 + vo-amrwbenc, 328 + vulkan-headers, 329 + vulkan-loader, 330 + vvenc, 331 + x264, 332 + x265, 333 + xavs, 334 + xevd, 335 + xeve, 336 + xvidcore, 337 + xz, 338 + zeromq, 339 + zimg, 340 + zlib, 341 + zvbi, 342 + # Darwin 343 + apple-sdk_15, 344 + xcode, # unfree contains metalcc and metallib 345 + # Cuda Packages 346 + cuda_cudart, 347 + cuda_nvcc, 348 + libnpp, 349 + # Testing 350 + testers, 351 + }: 352 353 /* 354 + Maintainer notes: 355 356 + Version bumps: 357 + It should always be safe to bump patch releases (e.g. 2.1.x, x being a patch release) 358 + If adding a new branch, note any configure flags that were added, changed, or deprecated/removed 359 + and make the necessary changes. 360 361 + Known issues: 362 + Cross-compiling will disable features not present on host OS 363 + (e.g. dxva2 support [DirectX] will not be enabled unless natively compiled on Cygwin) 364 + */ 365 366 let 367 + inherit (lib) 368 + optional 369 + optionals 370 + optionalString 371 + enableFeature 372 + versionOlder 373 + versionAtLeast 374 + ; 375 in 376 377 + assert lib.elem ffmpegVariant [ 378 + "headless" 379 + "small" 380 + "full" 381 + ]; 382 383 + # Licensing dependencies 384 assert withGPLv3 -> withGPL && withVersion3; 385 386 + # Build dependencies 387 assert withPixelutils -> buildAvutil; 388 assert !(withMfx && withVpl); # incompatible features 389 + # Program dependencies 390 + assert 391 + buildFfmpeg 392 + -> buildAvcodec && buildAvfilter && buildAvformat && (buildSwresample || buildAvresample); 393 + assert 394 + buildFfplay 395 + -> buildAvcodec && buildAvformat && buildSwscale && (buildSwresample || buildAvresample); 396 assert buildFfprobe -> buildAvcodec && buildAvformat; 397 + # Library dependencies 398 assert buildAvcodec -> buildAvutil; # configure flag since 0.6 399 + assert buildAvdevice -> buildAvformat && buildAvcodec && buildAvutil; # configure flag since 0.6 400 assert buildAvformat -> buildAvcodec && buildAvutil; # configure flag since 0.6 401 assert buildPostproc -> buildAvutil; 402 assert buildSwscale -> buildAvutil; 403 404 + # External Library dependencies 405 + assert (withCuda || withCuvid || withNvdec || withNvenc) -> withNvcodec; 406 407 + stdenv.mkDerivation ( 408 + finalAttrs: 409 + { 410 + pname = "ffmpeg" + (optionalString (ffmpegVariant != "small") "-${ffmpegVariant}"); 411 + inherit version; 412 + src = source; 413 414 + postPatch = 415 + '' 416 + patchShebangs . 417 + '' 418 + + lib.optionalString withFrei0r '' 419 + substituteInPlace libavfilter/vf_frei0r.c \ 420 + --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 421 + substituteInPlace doc/filters.texi \ 422 + --replace /usr/local/lib/frei0r-1 ${frei0r}/lib/frei0r-1 423 + ''; 424 425 + patches = 426 + [ ] 427 + ++ optionals (lib.versionAtLeast version "6.1" && lib.versionOlder version "6.2") [ 428 + (fetchpatch2 { 429 + # this can be removed post 6.1 430 + name = "fix_build_failure_due_to_PropertyKey_EncoderID"; 431 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/cb049d377f54f6b747667a93e4b719380c3e9475"; 432 + hash = "sha256-sxRXKKgUak5vsQTiV7ge8vp+N22CdTIvuczNgVRP72c="; 433 + }) 434 + (fetchpatch2 { 435 + name = "CVE-2024-31582.patch"; 436 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/99debe5f823f45a482e1dc08de35879aa9c74bd2"; 437 + hash = "sha256-+CQ9FXR6Vr/AmsbXFiCUXZcxKj1s8nInEdke/Oc/kUA="; 438 + }) 439 + (fetchpatch2 { 440 + name = "CVE-2024-31578.patch"; 441 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/3bb00c0a420c3ce83c6fafee30270d69622ccad7"; 442 + hash = "sha256-oZMZysBA+/gwaGEM1yvI+8wCadXWE7qLRL6Emap3b8Q="; 443 + }) 444 + (fetchpatch2 { 445 + name = "CVE-2023-49501.patch"; 446 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/4adb93dff05dd947878c67784d98c9a4e13b57a7"; 447 + hash = "sha256-7cwktto3fPMDGvCZCVtB01X8Q9S/4V4bDLUICSNfGgw="; 448 + }) 449 + (fetchpatch2 { 450 + name = "CVE-2023-49502.patch"; 451 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/737ede405b11a37fdd61d19cf25df296a0cb0b75"; 452 + hash = "sha256-mpSJwR9TX5ENjjCKvzuM/9e1Aj/AOiQW0+72oOMl9v8="; 453 + }) 454 + (fetchpatch2 { 455 + name = "CVE-2023-50007.patch"; 456 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/b1942734c7cbcdc9034034373abcc9ecb9644c47"; 457 + hash = "sha256-v0hNcqBtm8GCGAU9UbRUCE0slodOjZCHrkS8e4TrVcQ="; 458 + }) 459 + (fetchpatch2 { 460 + name = "CVE-2023-50008.patch"; 461 + url = "https://git.ffmpeg.org/gitweb/ffmpeg.git/patch/5f87a68cf70dafeab2fb89b42e41a4c29053b89b"; 462 + hash = "sha256-sqUUSOPTPLwu2h8GbAw4SfEf+0oWioz52BcpW1n4v3Y="; 463 + }) 464 + ] 465 + ++ optionals (lib.versionAtLeast version "7.1") [ 466 + ./fix-fate-ffmpeg-spec-disposition-7.1.patch 467 468 + # Expose a private API for Chromium / Qt WebEngine. 469 + (fetchpatch2 { 470 + url = "https://gitlab.archlinux.org/archlinux/packaging/packages/ffmpeg/-/raw/a02c1a15706ea832c0d52a4d66be8fb29499801a/add-av_stream_get_first_dts-for-chromium.patch"; 471 + hash = "sha256-DbH6ieJwDwTjKOdQ04xvRcSLeeLP2Z2qEmqeo8HsPr4="; 472 + }) 473 + ]; 474 475 + configurePlatforms = [ ]; 476 + setOutputFlags = false; # Only accepts some of them 477 + configureFlags = 478 + [ 479 + #mingw64 is internally treated as mingw32, so 32 and 64 make no difference here 480 + "--target_os=${ 481 + if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name 482 + }" 483 + "--arch=${stdenv.hostPlatform.parsed.cpu.name}" 484 + "--pkg-config=${buildPackages.pkg-config.targetPrefix}pkg-config" 485 + # Licensing flags 486 + (enableFeature withGPL "gpl") 487 + (enableFeature withVersion3 "version3") 488 + (enableFeature withUnfree "nonfree") 489 + # Build flags 490 + (enableFeature withStatic "static") 491 + (enableFeature withShared "shared") 492 + (enableFeature withPic "pic") 493 + (enableFeature withThumb "thumb") 494 495 + (enableFeature withSmallBuild "small") 496 + (enableFeature withRuntimeCPUDetection "runtime-cpudetect") 497 + (enableFeature withGrayscale "gray") 498 + (enableFeature withSwscaleAlpha "swscale-alpha") 499 + (enableFeature withHardcodedTables "hardcoded-tables") 500 + (enableFeature withSafeBitstreamReader "safe-bitstream-reader") 501 502 + (enableFeature (withMultithread && stdenv.hostPlatform.isUnix) "pthreads") 503 + (enableFeature (withMultithread && stdenv.hostPlatform.isWindows) "w32threads") 504 + "--disable-os2threads" # We don't support OS/2 505 506 + (enableFeature withNetwork "network") 507 + (enableFeature withPixelutils "pixelutils") 508 509 + "--datadir=${placeholder "data"}/share/ffmpeg" 510 + 511 + # Program flags 512 + (enableFeature buildFfmpeg "ffmpeg") 513 + (enableFeature buildFfplay "ffplay") 514 + (enableFeature buildFfprobe "ffprobe") 515 + ] 516 + ++ optionals withBin [ 517 + "--bindir=${placeholder "bin"}/bin" 518 + ] 519 + ++ [ 520 + # Library flags 521 + (enableFeature buildAvcodec "avcodec") 522 + (enableFeature buildAvdevice "avdevice") 523 + (enableFeature buildAvfilter "avfilter") 524 + (enableFeature buildAvformat "avformat") 525 + ] 526 + ++ optionals (lib.versionOlder version "5") [ 527 + # Ffmpeg > 4 doesn't know about the flag anymore 528 + (enableFeature buildAvresample "avresample") 529 + ] 530 + ++ [ 531 + (enableFeature buildAvutil "avutil") 532 + (enableFeature (buildPostproc && withGPL) "postproc") 533 + (enableFeature buildSwresample "swresample") 534 + (enableFeature buildSwscale "swscale") 535 + ] 536 + ++ optionals withLib [ 537 + "--libdir=${placeholder "lib"}/lib" 538 + "--incdir=${placeholder "dev"}/include" 539 + ] 540 + ++ [ 541 + # Documentation flags 542 + (enableFeature withDocumentation "doc") 543 + (enableFeature withHtmlDoc "htmlpages") 544 + (enableFeature withManPages "manpages") 545 + ] 546 + ++ optionals withManPages [ 547 + "--mandir=${placeholder "man"}/share/man" 548 + ] 549 + ++ [ 550 + (enableFeature withPodDoc "podpages") 551 + (enableFeature withTxtDoc "txtpages") 552 + ] 553 + ++ optionals withDoc [ 554 + "--docdir=${placeholder "doc"}/share/doc/ffmpeg" 555 + ] 556 + ++ [ 557 + # External libraries 558 + (enableFeature withAlsa "alsa") 559 + (enableFeature withAmf "amf") 560 + (enableFeature withAom "libaom") 561 + (enableFeature withAribb24 "libaribb24") 562 + ] 563 + ++ optionals (versionAtLeast version "6.1") [ 564 + (enableFeature withAribcaption "libaribcaption") 565 + ] 566 + ++ [ 567 + (enableFeature withAss "libass") 568 + (enableFeature withAvisynth "avisynth") 569 + (enableFeature withBluray "libbluray") 570 + (enableFeature withBs2b "libbs2b") 571 + (enableFeature withBzlib "bzlib") 572 + (enableFeature withCaca "libcaca") 573 + (enableFeature withCdio "libcdio") 574 + (enableFeature withCelt "libcelt") 575 + (enableFeature withChromaprint "chromaprint") 576 + (enableFeature withCodec2 "libcodec2") 577 + (enableFeature withCuda "cuda") 578 + (enableFeature withCudaLLVM "cuda-llvm") 579 + (enableFeature withCudaNVCC "cuda-nvcc") 580 + (enableFeature withCuvid "cuvid") 581 + (enableFeature withDav1d "libdav1d") 582 + (enableFeature withDc1394 "libdc1394") 583 + (enableFeature withDrm "libdrm") 584 + ] 585 + ++ optionals (versionAtLeast version "7") [ 586 + (enableFeature withDvdnav "libdvdnav") 587 + (enableFeature withDvdread "libdvdread") 588 + ] 589 + ++ [ 590 + (enableFeature withFdkAac "libfdk-aac") 591 + (enableFeature withNvcodec "ffnvcodec") 592 + (enableFeature withFlite "libflite") 593 + (enableFeature withFontconfig "fontconfig") 594 + (enableFeature withFontconfig "libfontconfig") 595 + (enableFeature withFreetype "libfreetype") 596 + (enableFeature withFrei0r "frei0r") 597 + (enableFeature withFribidi "libfribidi") 598 + (enableFeature withGme "libgme") 599 + (enableFeature withGnutls "gnutls") 600 + (enableFeature withGsm "libgsm") 601 + ] 602 + ++ optionals (versionAtLeast version "6.1") [ 603 + (enableFeature withHarfbuzz "libharfbuzz") 604 + ] 605 + ++ [ 606 + (enableFeature withIconv "iconv") 607 + (enableFeature withIlbc "libilbc") 608 + (enableFeature withJack "libjack") 609 + ] 610 + ++ optionals (versionAtLeast finalAttrs.version "5.0") [ 611 + (enableFeature withJxl "libjxl") 612 + ] 613 + ++ [ 614 + (enableFeature withKvazaar "libkvazaar") 615 + (enableFeature withLadspa "ladspa") 616 + ] 617 + ++ optionals (versionAtLeast version "7.1") [ 618 + (enableFeature withLc3 "liblc3") 619 + (enableFeature withLcevcdec "liblcevc-dec") 620 + ] 621 + ++ optionals (versionAtLeast version "5.1") [ 622 + (enableFeature withLcms2 "lcms2") 623 + ] 624 + ++ [ 625 + (enableFeature withLzma "lzma") 626 + ] 627 + ++ optionals (versionAtLeast version "5.0") [ 628 + (enableFeature withMetal "metal") 629 + ] 630 + ++ [ 631 + (enableFeature withMfx "libmfx") 632 + (enableFeature withModplug "libmodplug") 633 + (enableFeature withMp3lame "libmp3lame") 634 + (enableFeature withMysofa "libmysofa") 635 + (enableFeature withNpp "libnpp") 636 + (enableFeature withNvdec "nvdec") 637 + (enableFeature withNvenc "nvenc") 638 + (enableFeature withOpenal "openal") 639 + (enableFeature withOpencl "opencl") 640 + (enableFeature withOpencoreAmrnb "libopencore-amrnb") 641 + (enableFeature withOpencoreAmrwb "libopencore-amrwb") 642 + (enableFeature withOpengl "opengl") 643 + (enableFeature withOpenh264 "libopenh264") 644 + (enableFeature withOpenjpeg "libopenjpeg") 645 + (enableFeature withOpenmpt "libopenmpt") 646 + (enableFeature withOpus "libopus") 647 + ] 648 + ++ optionals (versionAtLeast version "5.0") [ 649 + (enableFeature withPlacebo "libplacebo") 650 + ] 651 + ++ [ 652 + (enableFeature withPulse "libpulse") 653 + ] 654 + ++ optionals (versionAtLeast version "7") [ 655 + (enableFeature withQrencode "libqrencode") 656 + (enableFeature withQuirc "libquirc") 657 + ] 658 + ++ [ 659 + (enableFeature withRav1e "librav1e") 660 + (enableFeature withRist "librist") 661 + (enableFeature withRtmp "librtmp") 662 + (enableFeature withRubberband "librubberband") 663 + (enableFeature withSamba "libsmbclient") 664 + (enableFeature withSdl2 "sdl2") 665 + ] 666 + ++ optionals (versionAtLeast version "5.0") [ 667 + (enableFeature withShaderc "libshaderc") 668 + ] 669 + ++ [ 670 + (enableFeature withShine "libshine") 671 + (enableFeature withSnappy "libsnappy") 672 + (enableFeature withSoxr "libsoxr") 673 + (enableFeature withSpeex "libspeex") 674 + (enableFeature withSrt "libsrt") 675 + (enableFeature withSsh "libssh") 676 + (enableFeature withSvg "librsvg") 677 + (enableFeature withSvtav1 "libsvtav1") 678 + (enableFeature withTensorflow "libtensorflow") 679 + (enableFeature withTheora "libtheora") 680 + (enableFeature withTwolame "libtwolame") 681 + (enableFeature withV4l2 "libv4l2") 682 + (enableFeature withV4l2M2m "v4l2-m2m") 683 + (enableFeature withVaapi "vaapi") 684 + (enableFeature withVdpau "vdpau") 685 + ] 686 + ++ optionals (versionAtLeast version "6.0") [ 687 + (enableFeature withVpl "libvpl") 688 + ] 689 + ++ [ 690 + (enableFeature withVidStab "libvidstab") # Actual min. version 2.0 691 + (enableFeature withVmaf "libvmaf") 692 + (enableFeature withVoAmrwbenc "libvo-amrwbenc") 693 + (enableFeature withVorbis "libvorbis") 694 + (enableFeature withVpx "libvpx") 695 + (enableFeature withVulkan "vulkan") 696 + ] 697 + ++ optionals (versionAtLeast version "7.1") [ 698 + (enableFeature withVvenc "libvvenc") 699 + ] 700 + ++ [ 701 + (enableFeature withWebp "libwebp") 702 + (enableFeature withX264 "libx264") 703 + (enableFeature withX265 "libx265") 704 + (enableFeature withXavs "libxavs") 705 + (enableFeature withXcb "libxcb") 706 + (enableFeature withXcbShape "libxcb-shape") 707 + (enableFeature withXcbShm "libxcb-shm") 708 + (enableFeature withXcbxfixes "libxcb-xfixes") 709 + ] 710 + ++ optionals (versionAtLeast version "7") [ 711 + (enableFeature withXevd "libxevd") 712 + (enableFeature withXeve "libxeve") 713 + ] 714 + ++ [ 715 + (enableFeature withXlib "xlib") 716 + (enableFeature withXml2 "libxml2") 717 + (enableFeature withXvid "libxvid") 718 + (enableFeature withZimg "libzimg") 719 + (enableFeature withZlib "zlib") 720 + (enableFeature withZmq "libzmq") 721 + (enableFeature withZvbi "libzvbi") 722 + # Developer flags 723 + (enableFeature withDebug "debug") 724 + (enableFeature withOptimisations "optimizations") 725 + (enableFeature withExtraWarnings "extra-warnings") 726 + (enableFeature withStripping "stripping") 727 + ] 728 + ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 729 + "--cross-prefix=${stdenv.cc.targetPrefix}" 730 + "--enable-cross-compile" 731 + "--host-cc=${buildPackages.stdenv.cc}/bin/cc" 732 + ] 733 + ++ optionals stdenv.cc.isClang [ 734 + "--cc=${stdenv.cc.targetPrefix}clang" 735 + "--cxx=${stdenv.cc.targetPrefix}clang++" 736 + ] 737 + ++ optionals withMetal [ 738 + "--metalcc=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal" 739 + "--metallib=${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metallib" 740 + ]; 741 742 + # ffmpeg embeds the configureFlags verbatim in its binaries and because we 743 + # configure binary, include, library dir etc., this causes references in 744 + # outputs where we don't want them. Patch the generated config.h to remove all 745 + # such references except for data. 746 + postConfigure = 747 + let 748 + toStrip = 749 + map placeholder (lib.remove "data" finalAttrs.outputs) # We want to keep references to the data dir. 750 + ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.stdenv.cc 751 + ++ lib.optional withMetal xcode; 752 + in 753 + "remove-references-to ${lib.concatStringsSep " " (map (o: "-t ${o}") toStrip)} config.h"; 754 755 + strictDeps = true; 756 757 + nativeBuildInputs = 758 + [ 759 + removeReferencesTo 760 + addDriverRunpath 761 + perl 762 + pkg-config 763 + yasm 764 + ] 765 + # Texinfo version 7.1 introduced breaking changes, which older versions of ffmpeg do not handle. 766 + ++ (if versionOlder version "5" then [ texinfo6 ] else [ texinfo ]) 767 + ++ optionals withCudaLLVM [ clang ] 768 + ++ optionals withCudaNVCC [ cuda_nvcc ]; 769 770 + buildInputs = 771 + [ ] 772 + ++ optionals stdenv.hostPlatform.isDarwin [ apple-sdk_15 ] 773 + ++ optionals withAlsa [ alsa-lib ] 774 + ++ optionals withAmf [ amf-headers ] 775 + ++ optionals withAom [ libaom ] 776 + ++ optionals withAribb24 [ aribb24 ] 777 + ++ optionals withAribcaption [ libaribcaption ] 778 + ++ optionals withAss [ libass ] 779 + ++ optionals withAvisynth [ avisynthplus ] 780 + ++ optionals withBluray [ libbluray ] 781 + ++ optionals withBs2b [ libbs2b ] 782 + ++ optionals withBzlib [ bzip2 ] 783 + ++ optionals withCaca [ libcaca ] 784 + ++ optionals withCdio [ 785 + libcdio 786 + libcdio-paranoia 787 + ] 788 + ++ optionals withCelt [ celt ] 789 + ++ optionals withChromaprint [ chromaprint ] 790 + ++ optionals withCodec2 [ codec2 ] 791 + ++ optionals withCudaNVCC [ 792 + cuda_cudart 793 + cuda_nvcc 794 + ] 795 + ++ optionals withDav1d [ dav1d ] 796 + ++ optionals withDc1394 ([ libdc1394 ] ++ (lib.optional stdenv.hostPlatform.isLinux libraw1394)) 797 + ++ optionals withDrm [ libdrm ] 798 + ++ optionals withDvdnav [ libdvdnav ] 799 + ++ optionals withDvdread [ libdvdread ] 800 + ++ optionals withFdkAac [ fdk_aac ] 801 + ++ optionals withNvcodec [ 802 + (if (lib.versionAtLeast version "6") then nv-codec-headers-12 else nv-codec-headers) 803 + ] 804 + ++ optionals withFlite [ flite ] 805 + ++ optionals withFontconfig [ fontconfig ] 806 + ++ optionals withFreetype [ freetype ] 807 + ++ optionals withFrei0r [ frei0r ] 808 + ++ optionals withFribidi [ fribidi ] 809 + ++ optionals withGme [ game-music-emu ] 810 + ++ optionals withGnutls [ gnutls ] 811 + ++ optionals withGsm [ gsm ] 812 + ++ optionals withHarfbuzz [ harfbuzz ] 813 + ++ optionals withIconv [ libiconv ] # On Linux this should be in libc, do we really need it? 814 + ++ optionals withIlbc [ libilbc ] 815 + ++ optionals withJack [ libjack2 ] 816 + ++ optionals withJxl [ libjxl ] 817 + ++ optionals withKvazaar [ kvazaar ] 818 + ++ optionals withLadspa [ ladspaH ] 819 + ++ optionals withLc3 [ liblc3 ] 820 + ++ optionals withLcevcdec [ lcevcdec ] 821 + ++ optionals withLcms2 [ lcms2 ] 822 + ++ optionals withLzma [ xz ] 823 + ++ optionals withMfx [ intel-media-sdk ] 824 + ++ optionals withModplug [ libmodplug ] 825 + ++ optionals withMp3lame [ lame ] 826 + ++ optionals withMysofa [ libmysofa ] 827 + ++ optionals withNpp [ 828 + libnpp 829 + cuda_cudart 830 + cuda_nvcc 831 + ] 832 + ++ optionals withOpenal [ openal ] 833 + ++ optionals withOpencl [ 834 + ocl-icd 835 + opencl-headers 836 + ] 837 + ++ optionals (withOpencoreAmrnb || withOpencoreAmrwb) [ opencore-amr ] 838 + ++ optionals withOpengl [ 839 + libGL 840 + libGLU 841 + ] 842 + ++ optionals withOpenh264 [ openh264 ] 843 + ++ optionals withOpenjpeg [ openjpeg ] 844 + ++ optionals withOpenmpt [ libopenmpt ] 845 + ++ optionals withOpus [ libopus ] 846 + ++ optionals withPlacebo [ 847 + (if (lib.versionAtLeast version "6.1") then libplacebo else libplacebo_5) 848 + vulkan-headers 849 + ] 850 + ++ optionals withPulse [ libpulseaudio ] 851 + ++ optionals withQrencode [ qrencode ] 852 + ++ optionals withQuirc [ quirc ] 853 + ++ optionals withRav1e [ rav1e ] 854 + ++ optionals withRist [ librist ] 855 + ++ optionals withRtmp [ rtmpdump ] 856 + ++ optionals withRubberband [ rubberband ] 857 + ++ optionals withSamba [ samba ] 858 + ++ optionals withSdl2 [ SDL2 ] 859 + ++ optionals withShaderc [ shaderc ] 860 + ++ optionals withShine [ shine ] 861 + ++ optionals withSnappy [ snappy ] 862 + ++ optionals withSoxr [ soxr ] 863 + ++ optionals withSpeex [ speex ] 864 + ++ optionals withSrt [ srt ] 865 + ++ optionals withSsh [ libssh ] 866 + ++ optionals withSvg [ librsvg ] 867 + ++ optionals withSvtav1 [ svt-av1 ] 868 + ++ optionals withTensorflow [ libtensorflow ] 869 + ++ optionals withTheora [ libtheora ] 870 + ++ optionals withTwolame [ twolame ] 871 + ++ optionals withV4l2 [ libv4l ] 872 + ++ optionals withVaapi [ (if withSmallDeps then libva else libva-minimal) ] 873 + ++ optionals withVdpau [ libvdpau ] 874 + ++ optionals withVidStab [ vid-stab ] 875 + ++ optionals withVmaf [ libvmaf ] 876 + ++ optionals withVoAmrwbenc [ vo-amrwbenc ] 877 + ++ optionals withVorbis [ libvorbis ] 878 + ++ optionals withVpl [ libvpl ] 879 + ++ optionals withVpx [ libvpx ] 880 + ++ optionals withVulkan [ 881 + vulkan-headers 882 + vulkan-loader 883 + ] 884 + ++ optionals withVvenc [ vvenc ] 885 + ++ optionals withWebp [ libwebp ] 886 + ++ optionals withX264 [ x264 ] 887 + ++ optionals withX265 [ x265 ] 888 + ++ optionals withXavs [ xavs ] 889 + ++ optionals withXcb [ libxcb ] 890 + ++ optionals withXevd [ xevd ] 891 + ++ optionals withXeve [ xeve ] 892 + ++ optionals withXlib [ 893 + libX11 894 + libXv 895 + libXext 896 + ] 897 + ++ optionals withXml2 [ libxml2 ] 898 + ++ optionals withXvid [ xvidcore ] 899 + ++ optionals withZimg [ zimg ] 900 + ++ optionals withZlib [ zlib ] 901 + ++ optionals withZmq [ zeromq ] 902 + ++ optionals withZvbi [ zvbi ]; 903 904 + buildFlags = [ "all" ] ++ optional buildQtFaststart "tools/qt-faststart"; # Build qt-faststart executable 905 906 + env = lib.optionalAttrs stdenv.cc.isGNU { 907 + NIX_CFLAGS_COMPILE = toString [ 908 + "-Wno-error=incompatible-pointer-types" 909 + "-Wno-error=int-conversion" 910 + ]; 911 + }; 912 913 + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; 914 915 + # Fails with SIGABRT otherwise FIXME: Why? 916 + checkPhase = 917 + let 918 + ldLibraryPathEnv = if stdenv.hostPlatform.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; 919 + libsToLink = 920 + [ ] 921 + ++ optional buildAvcodec "libavcodec" 922 + ++ optional buildAvdevice "libavdevice" 923 + ++ optional buildAvfilter "libavfilter" 924 + ++ optional buildAvformat "libavformat" 925 + ++ optional buildAvresample "libavresample" 926 + ++ optional buildAvutil "libavutil" 927 + ++ optional buildPostproc "libpostproc" 928 + ++ optional buildSwresample "libswresample" 929 + ++ optional buildSwscale "libswscale"; 930 + in 931 + '' 932 + ${ldLibraryPathEnv}="${lib.concatStringsSep ":" libsToLink}" make check -j$NIX_BUILD_CORES 933 + ''; 934 935 + outputs = 936 + optionals withBin [ "bin" ] # The first output is the one that gets symlinked by default! 937 + ++ optionals withLib [ 938 + "lib" 939 + "dev" 940 + ] 941 + ++ optionals withDoc [ "doc" ] 942 + ++ optionals withManPages [ "man" ] 943 + ++ [ 944 + "data" 945 + "out" 946 + ] # We need an "out" output because we get an error otherwise. It's just an empty dir. 947 ; 948 949 + postInstall = optionalString buildQtFaststart '' 950 + install -D tools/qt-faststart -t $bin/bin 951 + ''; 952 953 + # Set RUNPATH so that libnvcuvid and libcuda in /run/opengl-driver(-32)/lib can be found. 954 + # See the explanation in addDriverRunpath. 955 + postFixup = 956 + optionalString (stdenv.hostPlatform.isLinux && withLib) '' 957 + addDriverRunpath ${placeholder "lib"}/lib/libavcodec.so 958 + addDriverRunpath ${placeholder "lib"}/lib/libavutil.so 959 + '' 960 + # https://trac.ffmpeg.org/ticket/10809 961 + + optionalString (versionAtLeast version "5.0" && withVulkan && !stdenv.hostPlatform.isMinGW) '' 962 + patchelf $lib/lib/libavcodec.so --add-needed libvulkan.so --add-rpath ${ 963 + lib.makeLibraryPath [ vulkan-loader ] 964 + } 965 + ''; 966 967 + enableParallelBuilding = true; 968 969 + passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 970 971 + meta = with lib; { 972 + description = "Complete, cross-platform solution to record, convert and stream audio and video"; 973 + homepage = "https://www.ffmpeg.org/"; 974 + changelog = "https://github.com/FFmpeg/FFmpeg/blob/n${version}/Changelog"; 975 + longDescription = '' 976 + FFmpeg is the leading multimedia framework, able to decode, encode, transcode, 977 + mux, demux, stream, filter and play pretty much anything that humans and machines 978 + have created. It supports the most obscure ancient formats up to the cutting edge. 979 + No matter if they were designed by some standards committee, the community or 980 + a corporation. 981 + ''; 982 + license = 983 + with licenses; 984 + [ lgpl21Plus ] 985 + ++ optional withGPL gpl2Plus 986 + ++ optional withVersion3 lgpl3Plus 987 + ++ optional withGPLv3 gpl3Plus 988 + ++ optional withUnfree unfreeRedistributable 989 + ++ optional (withGPL && withUnfree) unfree; 990 + pkgConfigModules = 991 + [ ] 992 + ++ optional buildAvcodec "libavcodec" 993 + ++ optional buildAvdevice "libavdevice" 994 + ++ optional buildAvfilter "libavfilter" 995 + ++ optional buildAvformat "libavformat" 996 + ++ optional buildAvresample "libavresample" 997 + ++ optional buildAvutil "libavutil" 998 + ++ optional buildPostproc "libpostproc" 999 + ++ optional buildSwresample "libswresample" 1000 + ++ optional buildSwscale "libswscale"; 1001 + platforms = platforms.all; 1002 + # See https://github.com/NixOS/nixpkgs/pull/295344#issuecomment-1992263658 1003 + broken = stdenv.hostPlatform.isMinGW && stdenv.hostPlatform.is64bit; 1004 + maintainers = with maintainers; [ 1005 + atemu 1006 + jopejoe1 1007 + emily 1008 + ]; 1009 + mainProgram = "ffmpeg"; 1010 + }; 1011 + } 1012 + // lib.optionalAttrs withCudaLLVM { 1013 + # remove once https://github.com/NixOS/nixpkgs/issues/318674 is addressed properly 1014 + hardeningDisable = [ "zerocallusedregs" ]; 1015 + } 1016 + )
+1 -1
pkgs/development/libraries/libdvdcss/default.nix
··· 20 homepage = "http://www.videolan.org/developers/libdvdcss.html"; 21 description = "Library for decrypting DVDs"; 22 license = licenses.gpl2; 23 - platforms = with platforms; linux ++ darwin; 24 }; 25 }
··· 20 homepage = "http://www.videolan.org/developers/libdvdcss.html"; 21 description = "Library for decrypting DVDs"; 22 license = licenses.gpl2; 23 + platforms = platforms.unix; 24 }; 25 }
+1 -1
pkgs/development/libraries/libdvdread/default.nix
··· 27 description = "Library for reading DVDs"; 28 license = lib.licenses.gpl2; 29 maintainers = [ lib.maintainers.wmertens ]; 30 - platforms = with lib.platforms; linux ++ darwin; 31 }; 32 }
··· 27 description = "Library for reading DVDs"; 28 license = lib.licenses.gpl2; 29 maintainers = [ lib.maintainers.wmertens ]; 30 + platforms = lib.platforms.unix; 31 }; 32 }
+443 -350
pkgs/development/libraries/opencv/4.x.nix
··· 1 - { lib 2 - , stdenv 3 - , fetchurl 4 - , fetchFromGitHub 5 - , cmake 6 - , pkg-config 7 - , unzip 8 - , zlib 9 - , pcre2 10 - , hdf5 11 - , boost 12 - , glib 13 - , glog 14 - , gflags 15 - , protobuf_29 16 - , config 17 - , ocl-icd 18 - , qimgv 19 - , opencv4 20 21 - , enableJPEG ? true 22 - , libjpeg 23 - , enablePNG ? true 24 - , libpng 25 - , enableTIFF ? true 26 - , libtiff 27 - , enableWebP ? true 28 - , libwebp 29 - , enableEXR ? !stdenv.hostPlatform.isDarwin 30 - , openexr 31 - , ilmbase 32 - , enableJPEG2000 ? true 33 - , openjpeg 34 - , enableEigen ? true 35 - , eigen 36 - , enableBlas ? true 37 - , blas 38 - , enableVA ? !stdenv.hostPlatform.isDarwin 39 - , libva 40 - , enableContrib ? true 41 42 - , enableCuda ? config.cudaSupport 43 - , enableCublas ? enableCuda 44 - , enableCudnn ? false # NOTE: CUDNN has a large impact on closure size so we disable it by default 45 - , enableCufft ? enableCuda 46 - , cudaPackages 47 - , nvidia-optical-flow-sdk 48 49 - , enableLto ? true 50 - , enableUnfree ? false 51 - , enableIpp ? false 52 - , enablePython ? false 53 - , pythonPackages 54 - , enableGtk2 ? false 55 - , gtk2 56 - , enableGtk3 ? false 57 - , gtk3 58 - , enableVtk ? false 59 - , vtk 60 - , enableFfmpeg ? true 61 - , ffmpeg 62 - , enableGStreamer ? true 63 - , elfutils 64 - , gst_all_1 65 - , orc 66 - , libunwind 67 - , zstd 68 - , enableTesseract ? false 69 - , tesseract 70 - , leptonica 71 - , enableTbb ? false 72 - , tbb 73 - , enableOvis ? false 74 - , ogre 75 - , enableGPhoto2 ? false 76 - , libgphoto2 77 - , enableDC1394 ? false 78 - , libdc1394 79 - , enableDocs ? false 80 - , doxygen 81 - , graphviz-nox 82 83 - , runAccuracyTests ? true 84 - , runPerformanceTests ? false 85 - # Modules to enable via BUILD_LIST to build a customized opencv. 86 - # An empty lists means this setting is omitted which matches upstreams default. 87 - , enabledModules ? [ ] 88 89 - , AVFoundation 90 - , Cocoa 91 - , VideoDecodeAcceleration 92 - , CoreMedia 93 - , MediaToolbox 94 - , Accelerate 95 - , bzip2 96 - , callPackage 97 }@inputs: 98 99 let 100 inherit (lib.attrsets) mapAttrsToList optionalAttrs; 101 inherit (lib.lists) last optionals; 102 - inherit (lib.strings) cmakeBool cmakeFeature cmakeOptionType concatStrings concatStringsSep optionalString; 103 inherit (lib.trivial) flip; 104 105 version = "4.11.0"; ··· 135 136 # See opencv/3rdparty/ippicv/ippicv.cmake 137 ippicv = { 138 - src = fetchFromGitHub { 139 - owner = "opencv"; 140 - repo = "opencv_3rdparty"; 141 - rev = "7f55c0c26be418d494615afca15218566775c725"; 142 - hash = "sha256-XbmS+FXUL8MAG7kawbDkb2XHG9R0DpPhiYhq/18eTnY="; 143 - } + "/ippicv"; 144 - files = let name = platform: "ippicv_2021.10.0_${platform}_20230919_general.tgz"; in 145 if effectiveStdenv.hostPlatform.system == "x86_64-linux" then 146 { ${name "lnx_intel64"} = ""; } 147 else if effectiveStdenv.hostPlatform.system == "i686-linux" then ··· 233 }; 234 235 # See opencv/cmake/OpenCVDownload.cmake 236 - installExtraFiles = {dst, files, src, ...}: '' 237 - mkdir -p "${dst}" 238 - '' + concatStrings (flip mapAttrsToList files (name: md5: '' 239 - ln -s "${src}/${name}" "${dst}/${md5}-${name}" 240 - '')); 241 - installExtraFile = {dst, md5, name, src, ...}: '' 242 - mkdir -p "${dst}" 243 - ln -s "${src}" "${dst}/${md5}-${name}" 244 - ''; 245 246 withOpenblas = (enableBlas && blas.provider.pname == "openblas"); 247 #multithreaded openblas conflicts with opencv multithreading, which manifest itself in hung tests ··· 257 pname = "opencv"; 258 inherit version src; 259 260 - outputs = [ 261 - "out" 262 - "cxxdev" 263 - ] ++ optionals (runAccuracyTests || runPerformanceTests) [ 264 - "package_tests" 265 - ]; 266 cudaPropagateToOutput = "cxxdev"; 267 268 postUnpack = optionalString buildContrib '' ··· 270 ''; 271 272 # Ensures that we use the system OpenEXR rather than the vendored copy of the source included with OpenCV. 273 - patches = [ 274 - ./cmake-don-t-use-OpenCVFindOpenEXR.patch 275 - ] ++ optionals enableCuda [ 276 - ./cuda_opt_flow.patch 277 - ]; 278 279 # This prevents cmake from using libraries in impure paths (which 280 # causes build failure on non NixOS) ··· 283 ''; 284 285 preConfigure = 286 - installExtraFile ade + 287 - optionalString enableIpp (installExtraFiles ippicv) + ( 288 - optionalString buildContrib '' 289 - cmakeFlagsArray+=("-DOPENCV_EXTRA_MODULES_PATH=$NIX_BUILD_TOP/source/opencv_contrib") 290 291 - ${installExtraFiles vgg} 292 - ${installExtraFiles boostdesc} 293 - ${installExtraFiles face} 294 - ${installExtraFiles wechat_qrcode} 295 - '' 296 - ); 297 298 postConfigure = '' 299 [ -e modules/core/version_string.inc ] 300 echo '"(build info elided)"' > modules/core/version_string.inc 301 ''; 302 303 - buildInputs = [ 304 - boost 305 - gflags 306 - glib 307 - glog 308 - pcre2 309 - protobuf_29 310 - zlib 311 - ] ++ optionals enablePython [ 312 - pythonPackages.python 313 - ] ++ optionals (effectiveStdenv.buildPlatform == effectiveStdenv.hostPlatform) [ 314 - hdf5 315 - ] ++ optionals enableGtk2 [ 316 - gtk2 317 - ] ++ optionals enableGtk3 [ 318 - gtk3 319 - ] ++ optionals enableVtk [ 320 - vtk 321 - ] ++ optionals enableJPEG [ 322 - libjpeg 323 - ] ++ optionals enablePNG [ 324 - libpng 325 - ] ++ optionals enableTIFF [ 326 - libtiff 327 - ] ++ optionals enableWebP [ 328 - libwebp 329 - ] ++ optionals enableEXR [ 330 - openexr 331 - ilmbase 332 - ] ++ optionals enableJPEG2000 [ 333 - openjpeg 334 - ] ++ optionals enableFfmpeg [ 335 - ffmpeg 336 - ] ++ optionals (enableFfmpeg && effectiveStdenv.hostPlatform.isDarwin) [ 337 - bzip2 338 - VideoDecodeAcceleration 339 - ] ++ optionals (enableGStreamer && effectiveStdenv.hostPlatform.isLinux) [ 340 - elfutils 341 - gst_all_1.gst-plugins-base 342 - gst_all_1.gst-plugins-good 343 - gst_all_1.gstreamer 344 - libunwind 345 - orc 346 - zstd 347 - ] ++ optionals enableOvis [ 348 - ogre 349 - ] ++ optionals enableGPhoto2 [ 350 - libgphoto2 351 - ] ++ optionals enableDC1394 [ 352 - libdc1394 353 - ] ++ optionals enableEigen [ 354 - eigen 355 - ] ++ optionals enableVA [ 356 - libva 357 - ] ++ optionals enableBlas [ 358 - blas.provider 359 - ] ++ optionals enableTesseract [ 360 - # There is seemingly no compile-time flag for Tesseract. It's 361 - # simply enabled automatically if contrib is built, and it detects 362 - # tesseract & leptonica. 363 - tesseract 364 - leptonica 365 - ] ++ optionals enableTbb [ 366 - tbb 367 - ] ++ optionals effectiveStdenv.hostPlatform.isDarwin [ 368 - bzip2 369 - AVFoundation 370 - Cocoa 371 - VideoDecodeAcceleration 372 - CoreMedia 373 - MediaToolbox 374 - Accelerate 375 - ] ++ optionals enableDocs [ 376 - doxygen 377 - graphviz-nox 378 - ] ++ optionals enableCuda [ 379 - cudaPackages.cuda_cudart 380 - cudaPackages.cuda_cccl # <thrust/*> 381 - cudaPackages.libnpp # npp.h 382 - nvidia-optical-flow-sdk 383 - ] ++ optionals enableCublas [ 384 - # May start using the default $out instead once 385 - # https://github.com/NixOS/nixpkgs/issues/271792 386 - # has been addressed 387 - cudaPackages.libcublas # cublas_v2.h 388 - ] ++ optionals enableCudnn [ 389 - cudaPackages.cudnn # cudnn.h 390 - ] ++ optionals enableCufft [ 391 - cudaPackages.libcufft # cufft.h 392 - ]; 393 394 propagatedBuildInputs = optionals enablePython [ pythonPackages.numpy ]; 395 396 - nativeBuildInputs = [ 397 - cmake 398 - pkg-config 399 - unzip 400 - ] ++ optionals enablePython ([ 401 - pythonPackages.pip 402 - pythonPackages.wheel 403 - pythonPackages.setuptools 404 - ] ++ optionals (effectiveStdenv.hostPlatform == effectiveStdenv.buildPlatform) [ 405 - pythonPackages.pythonImportsCheckHook 406 - ]) ++ optionals enableCuda [ 407 - cudaPackages.cuda_nvcc 408 - ]; 409 410 env.NIX_CFLAGS_COMPILE = optionalString enableEXR "-I${ilmbase.dev}/include/OpenEXR"; 411 ··· 413 OpenBLAS_HOME = optionalString withOpenblas openblas_.dev; 414 OpenBLAS = optionalString withOpenblas openblas_; 415 416 - cmakeFlags = [ 417 - (cmakeBool "OPENCV_GENERATE_PKGCONFIG" true) 418 - (cmakeBool "WITH_OPENMP" true) 419 - (cmakeBool "BUILD_PROTOBUF" false) 420 - (cmakeBool "PROTOBUF_UPDATE_FILES" true) 421 - (cmakeBool "OPENCV_ENABLE_NONFREE" enableUnfree) 422 - (cmakeBool "BUILD_TESTS" runAccuracyTests) 423 - (cmakeBool "BUILD_PERF_TESTS" runPerformanceTests) 424 - (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) 425 - (cmakeBool "BUILD_DOCS" enableDocs) 426 - # "OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" 427 - # but we have proper separation of build and host libs :), fixes cross 428 - (cmakeBool "OPENCV_ENABLE_PKG_CONFIG" true) 429 - (cmakeBool "WITH_IPP" enableIpp) 430 - (cmakeBool "WITH_TIFF" enableTIFF) 431 - (cmakeBool "WITH_WEBP" enableWebP) 432 - (cmakeBool "WITH_JPEG" enableJPEG) 433 - (cmakeBool "WITH_PNG" enablePNG) 434 - (cmakeBool "WITH_OPENEXR" enableEXR) 435 - (cmakeBool "WITH_OPENJPEG" enableJPEG2000) 436 - (cmakeBool "WITH_JASPER" false) # OpenCV falls back to a vendored copy of Jasper when OpenJPEG is disabled 437 - (cmakeBool "WITH_TBB" enableTbb) 438 439 - # CUDA options 440 - (cmakeBool "WITH_CUDA" enableCuda) 441 - (cmakeBool "WITH_CUBLAS" enableCublas) 442 - (cmakeBool "WITH_CUDNN" enableCudnn) 443 - (cmakeBool "WITH_CUFFT" enableCufft) 444 445 - # LTO options 446 - (cmakeBool "ENABLE_LTO" enableLto) 447 - (cmakeBool "ENABLE_THIN_LTO" ( 448 - enableLto && ( 449 - # Only clang supports thin LTO, so we must either be using clang through the effectiveStdenv, 450 - effectiveStdenv.cc.isClang || 451 - # or through the backend effectiveStdenv. 452 - (enableCuda && effectiveStdenv.cc.isClang) 453 - ) 454 - )) 455 - ] ++ optionals enableCuda [ 456 - (cmakeBool "CUDA_FAST_MATH" true) 457 - (cmakeFeature "CUDA_NVCC_FLAGS" "--expt-relaxed-constexpr") 458 459 - # OpenCV respects at least three variables: 460 - # -DCUDA_GENERATION takes a single arch name, e.g. Volta 461 - # -DCUDA_ARCH_BIN takes a semi-colon separated list of real arches, e.g. "8.0;8.6" 462 - # -DCUDA_ARCH_PTX takes the virtual arch, e.g. "8.6" 463 - (cmakeFeature "CUDA_ARCH_BIN" cmakeCudaArchitecturesString) 464 - (cmakeFeature "CUDA_ARCH_PTX" (last cudaCapabilities)) 465 466 - (cmakeOptionType "path" "NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH" nvidia-optical-flow-sdk.outPath) 467 - ] ++ optionals effectiveStdenv.hostPlatform.isDarwin [ 468 - (cmakeBool "WITH_OPENCL" false) 469 - (cmakeBool "WITH_LAPACK" false) 470 471 - # Disable unnecessary vendoring that's enabled by default only for Darwin. 472 - # Note that the opencvFlag feature flags listed above still take 473 - # precedence, so we can safely list everything here. 474 - (cmakeBool "BUILD_ZLIB" false) 475 - (cmakeBool "BUILD_TIFF" false) 476 - (cmakeBool "BUILD_OPENJPEG" false) 477 - (cmakeBool "BUILD_JASPER" false) 478 - (cmakeBool "BUILD_JPEG" false) 479 - (cmakeBool "BUILD_PNG" false) 480 - (cmakeBool "BUILD_WEBP" false) 481 - ] ++ optionals (!effectiveStdenv.hostPlatform.isDarwin) [ 482 - (cmakeOptionType "path" "OPENCL_LIBRARY" "${ocl-icd}/lib/libOpenCL.so") 483 - ] ++ optionals enablePython [ 484 - (cmakeOptionType "path" "OPENCV_PYTHON_INSTALL_PATH" pythonPackages.python.sitePackages) 485 - ] ++ optionals (enabledModules != [ ]) [ 486 - (cmakeFeature "BUILD_LIST" (concatStringsSep "," enabledModules)) 487 - ]; 488 489 postBuild = optionalString enableDocs '' 490 make doxygen ··· 494 optionalString (runAccuracyTests || runPerformanceTests) '' 495 mkdir $package_tests 496 cp -R $src/samples $package_tests/ 497 - '' + optionalString runAccuracyTests '' 498 mv ./bin/*test* $package_tests/ 499 - '' + optionalString runPerformanceTests '' 500 mv ./bin/*perf* $package_tests/ 501 ''; 502 ··· 512 # Note that ${exec_prefix} is set to $out but that $out is also appended to 513 # ${exec_prefix}. This causes linker errors in downstream packages so we strip 514 # of $out after the ${exec_prefix} and ${prefix} prefixes: 515 - postInstall = '' 516 - sed -i "s|{exec_prefix}/$out|{exec_prefix}|;s|{prefix}/$out|{prefix}|" \ 517 - "$out/lib/pkgconfig/opencv4.pc" 518 - mkdir "$cxxdev" 519 - '' 520 - # fix deps not propagating from opencv4.cxxdev if cuda is disabled 521 - # see https://github.com/NixOS/nixpkgs/issues/276691 522 - + optionalString (!enableCuda) '' 523 - mkdir -p "$cxxdev/nix-support" 524 - echo "''${!outputDev}" >> "$cxxdev/nix-support/propagated-build-inputs" 525 - '' 526 - # remove the requirement that the exact same version of CUDA is used in packages 527 - # consuming OpenCV's CMakes files 528 - + optionalString enableCuda '' 529 - substituteInPlace "$out/lib/cmake/opencv4/OpenCVConfig.cmake" \ 530 - --replace-fail \ 531 - 'find_host_package(CUDA ''${OpenCV_CUDA_VERSION} EXACT REQUIRED)' \ 532 - 'find_host_package(CUDA REQUIRED)' \ 533 - --replace-fail \ 534 - 'message(FATAL_ERROR "OpenCV static library was compiled with CUDA' \ 535 - 'message("OpenCV static library was compiled with CUDA' 536 - '' 537 - # install python distribution information, so other packages can `import opencv` 538 - + optionalString enablePython '' 539 - pushd $NIX_BUILD_TOP/$sourceRoot/modules/python/package 540 - python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist . 541 542 - pushd dist 543 - python -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache 544 545 - popd 546 - popd 547 - ''; 548 549 - pythonImportsCheck = [ "cv2" "cv2.sfm" ]; 550 551 passthru = { 552 cudaSupport = enableCuda; 553 554 - tests = { 555 - inherit (gst_all_1) gst-plugins-bad; 556 - } 557 - // optionalAttrs (!effectiveStdenv.hostPlatform.isDarwin) { 558 - inherit qimgv; 559 - withIpp = opencv4.override { enableIpp = true; }; 560 - } 561 - // optionalAttrs (!enablePython) { pythonEnabled = pythonPackages.opencv4; } 562 - // optionalAttrs (effectiveStdenv.buildPlatform != "x86_64-darwin") { 563 - opencv4-tests = callPackage ./tests.nix { 564 - inherit enableGStreamer enableGtk2 enableGtk3 runAccuracyTests runPerformanceTests testDataSrc; 565 - inherit opencv4; 566 }; 567 - } 568 - // optionalAttrs (enableCuda) { 569 - no-libstdcxx-errors = callPackage ./libstdcxx-test.nix { attrName = "opencv4"; }; 570 - }; 571 } // optionalAttrs enablePython { pythonPath = [ ]; }; 572 573 meta = { ··· 575 homepage = "https://opencv.org/"; 576 license = if enableUnfree then lib.licenses.unfree else lib.licenses.bsd3; 577 maintainers = with lib.maintainers; [ basvandijk ]; 578 - platforms = with lib.platforms; linux ++ darwin; 579 }; 580 }
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchurl, 5 + fetchFromGitHub, 6 + cmake, 7 + pkg-config, 8 + unzip, 9 + zlib, 10 + pcre2, 11 + hdf5, 12 + boost, 13 + glib, 14 + glog, 15 + gflags, 16 + protobuf_29, 17 + config, 18 + ocl-icd, 19 + qimgv, 20 + opencv4, 21 22 + enableJPEG ? true, 23 + libjpeg, 24 + enablePNG ? true, 25 + libpng, 26 + enableTIFF ? true, 27 + libtiff, 28 + enableWebP ? true, 29 + libwebp, 30 + enableEXR ? !stdenv.hostPlatform.isDarwin, 31 + openexr, 32 + ilmbase, 33 + enableJPEG2000 ? true, 34 + openjpeg, 35 + enableEigen ? true, 36 + eigen, 37 + enableBlas ? true, 38 + blas, 39 + enableVA ? !stdenv.hostPlatform.isDarwin, 40 + libva, 41 + enableContrib ? true, 42 43 + enableCuda ? config.cudaSupport, 44 + enableCublas ? enableCuda, 45 + enableCudnn ? false, # NOTE: CUDNN has a large impact on closure size so we disable it by default 46 + enableCufft ? enableCuda, 47 + cudaPackages, 48 + nvidia-optical-flow-sdk, 49 50 + enableLto ? true, 51 + enableUnfree ? false, 52 + enableIpp ? false, 53 + enablePython ? false, 54 + pythonPackages, 55 + enableGtk2 ? false, 56 + gtk2, 57 + enableGtk3 ? false, 58 + gtk3, 59 + enableVtk ? false, 60 + vtk, 61 + enableFfmpeg ? true, 62 + ffmpeg, 63 + enableGStreamer ? true, 64 + elfutils, 65 + gst_all_1, 66 + orc, 67 + libunwind, 68 + zstd, 69 + enableTesseract ? false, 70 + tesseract, 71 + leptonica, 72 + enableTbb ? false, 73 + tbb, 74 + enableOvis ? false, 75 + ogre, 76 + enableGPhoto2 ? false, 77 + libgphoto2, 78 + enableDC1394 ? false, 79 + libdc1394, 80 + enableDocs ? false, 81 + doxygen, 82 + graphviz-nox, 83 84 + runAccuracyTests ? true, 85 + runPerformanceTests ? false, 86 + # Modules to enable via BUILD_LIST to build a customized opencv. 87 + # An empty lists means this setting is omitted which matches upstreams default. 88 + enabledModules ? [ ], 89 90 + AVFoundation, 91 + Cocoa, 92 + VideoDecodeAcceleration, 93 + CoreMedia, 94 + MediaToolbox, 95 + Accelerate, 96 + bzip2, 97 + callPackage, 98 }@inputs: 99 100 let 101 inherit (lib.attrsets) mapAttrsToList optionalAttrs; 102 inherit (lib.lists) last optionals; 103 + inherit (lib.strings) 104 + cmakeBool 105 + cmakeFeature 106 + cmakeOptionType 107 + concatStrings 108 + concatStringsSep 109 + optionalString 110 + ; 111 inherit (lib.trivial) flip; 112 113 version = "4.11.0"; ··· 143 144 # See opencv/3rdparty/ippicv/ippicv.cmake 145 ippicv = { 146 + src = 147 + fetchFromGitHub { 148 + owner = "opencv"; 149 + repo = "opencv_3rdparty"; 150 + rev = "7f55c0c26be418d494615afca15218566775c725"; 151 + hash = "sha256-XbmS+FXUL8MAG7kawbDkb2XHG9R0DpPhiYhq/18eTnY="; 152 + } 153 + + "/ippicv"; 154 + files = 155 + let 156 + name = platform: "ippicv_2021.10.0_${platform}_20230919_general.tgz"; 157 + in 158 if effectiveStdenv.hostPlatform.system == "x86_64-linux" then 159 { ${name "lnx_intel64"} = ""; } 160 else if effectiveStdenv.hostPlatform.system == "i686-linux" then ··· 246 }; 247 248 # See opencv/cmake/OpenCVDownload.cmake 249 + installExtraFiles = 250 + { 251 + dst, 252 + files, 253 + src, 254 + ... 255 + }: 256 + '' 257 + mkdir -p "${dst}" 258 + '' 259 + + concatStrings ( 260 + flip mapAttrsToList files ( 261 + name: md5: '' 262 + ln -s "${src}/${name}" "${dst}/${md5}-${name}" 263 + '' 264 + ) 265 + ); 266 + installExtraFile = 267 + { 268 + dst, 269 + md5, 270 + name, 271 + src, 272 + ... 273 + }: 274 + '' 275 + mkdir -p "${dst}" 276 + ln -s "${src}" "${dst}/${md5}-${name}" 277 + ''; 278 279 withOpenblas = (enableBlas && blas.provider.pname == "openblas"); 280 #multithreaded openblas conflicts with opencv multithreading, which manifest itself in hung tests ··· 290 pname = "opencv"; 291 inherit version src; 292 293 + outputs = 294 + [ 295 + "out" 296 + "cxxdev" 297 + ] 298 + ++ optionals (runAccuracyTests || runPerformanceTests) [ 299 + "package_tests" 300 + ]; 301 cudaPropagateToOutput = "cxxdev"; 302 303 postUnpack = optionalString buildContrib '' ··· 305 ''; 306 307 # Ensures that we use the system OpenEXR rather than the vendored copy of the source included with OpenCV. 308 + patches = 309 + [ 310 + ./cmake-don-t-use-OpenCVFindOpenEXR.patch 311 + ] 312 + ++ optionals enableCuda [ 313 + ./cuda_opt_flow.patch 314 + ]; 315 316 # This prevents cmake from using libraries in impure paths (which 317 # causes build failure on non NixOS) ··· 320 ''; 321 322 preConfigure = 323 + installExtraFile ade 324 + + optionalString enableIpp (installExtraFiles ippicv) 325 + + (optionalString buildContrib '' 326 + cmakeFlagsArray+=("-DOPENCV_EXTRA_MODULES_PATH=$NIX_BUILD_TOP/source/opencv_contrib") 327 328 + ${installExtraFiles vgg} 329 + ${installExtraFiles boostdesc} 330 + ${installExtraFiles face} 331 + ${installExtraFiles wechat_qrcode} 332 + ''); 333 334 postConfigure = '' 335 [ -e modules/core/version_string.inc ] 336 echo '"(build info elided)"' > modules/core/version_string.inc 337 ''; 338 339 + buildInputs = 340 + [ 341 + boost 342 + gflags 343 + glib 344 + glog 345 + pcre2 346 + protobuf_29 347 + zlib 348 + ] 349 + ++ optionals enablePython [ 350 + pythonPackages.python 351 + ] 352 + ++ optionals (effectiveStdenv.buildPlatform == effectiveStdenv.hostPlatform) [ 353 + hdf5 354 + ] 355 + ++ optionals enableGtk2 [ 356 + gtk2 357 + ] 358 + ++ optionals enableGtk3 [ 359 + gtk3 360 + ] 361 + ++ optionals enableVtk [ 362 + vtk 363 + ] 364 + ++ optionals enableJPEG [ 365 + libjpeg 366 + ] 367 + ++ optionals enablePNG [ 368 + libpng 369 + ] 370 + ++ optionals enableTIFF [ 371 + libtiff 372 + ] 373 + ++ optionals enableWebP [ 374 + libwebp 375 + ] 376 + ++ optionals enableEXR [ 377 + openexr 378 + ilmbase 379 + ] 380 + ++ optionals enableJPEG2000 [ 381 + openjpeg 382 + ] 383 + ++ optionals enableFfmpeg [ 384 + ffmpeg 385 + ] 386 + ++ optionals (enableFfmpeg && effectiveStdenv.hostPlatform.isDarwin) [ 387 + bzip2 388 + VideoDecodeAcceleration 389 + ] 390 + ++ optionals (enableGStreamer && effectiveStdenv.hostPlatform.isLinux) [ 391 + elfutils 392 + gst_all_1.gst-plugins-base 393 + gst_all_1.gst-plugins-good 394 + gst_all_1.gstreamer 395 + libunwind 396 + orc 397 + zstd 398 + ] 399 + ++ optionals enableOvis [ 400 + ogre 401 + ] 402 + ++ optionals enableGPhoto2 [ 403 + libgphoto2 404 + ] 405 + ++ optionals enableDC1394 [ 406 + libdc1394 407 + ] 408 + ++ optionals enableEigen [ 409 + eigen 410 + ] 411 + ++ optionals enableVA [ 412 + libva 413 + ] 414 + ++ optionals enableBlas [ 415 + blas.provider 416 + ] 417 + ++ optionals enableTesseract [ 418 + # There is seemingly no compile-time flag for Tesseract. It's 419 + # simply enabled automatically if contrib is built, and it detects 420 + # tesseract & leptonica. 421 + tesseract 422 + leptonica 423 + ] 424 + ++ optionals enableTbb [ 425 + tbb 426 + ] 427 + ++ optionals effectiveStdenv.hostPlatform.isDarwin [ 428 + bzip2 429 + AVFoundation 430 + Cocoa 431 + VideoDecodeAcceleration 432 + CoreMedia 433 + MediaToolbox 434 + Accelerate 435 + ] 436 + ++ optionals enableDocs [ 437 + doxygen 438 + graphviz-nox 439 + ] 440 + ++ optionals enableCuda [ 441 + cudaPackages.cuda_cudart 442 + cudaPackages.cuda_cccl # <thrust/*> 443 + cudaPackages.libnpp # npp.h 444 + nvidia-optical-flow-sdk 445 + ] 446 + ++ optionals enableCublas [ 447 + # May start using the default $out instead once 448 + # https://github.com/NixOS/nixpkgs/issues/271792 449 + # has been addressed 450 + cudaPackages.libcublas # cublas_v2.h 451 + ] 452 + ++ optionals enableCudnn [ 453 + cudaPackages.cudnn # cudnn.h 454 + ] 455 + ++ optionals enableCufft [ 456 + cudaPackages.libcufft # cufft.h 457 + ]; 458 459 propagatedBuildInputs = optionals enablePython [ pythonPackages.numpy ]; 460 461 + nativeBuildInputs = 462 + [ 463 + cmake 464 + pkg-config 465 + unzip 466 + ] 467 + ++ optionals enablePython ( 468 + [ 469 + pythonPackages.pip 470 + pythonPackages.wheel 471 + pythonPackages.setuptools 472 + ] 473 + ++ optionals (effectiveStdenv.hostPlatform == effectiveStdenv.buildPlatform) [ 474 + pythonPackages.pythonImportsCheckHook 475 + ] 476 + ) 477 + ++ optionals enableCuda [ 478 + cudaPackages.cuda_nvcc 479 + ]; 480 481 env.NIX_CFLAGS_COMPILE = optionalString enableEXR "-I${ilmbase.dev}/include/OpenEXR"; 482 ··· 484 OpenBLAS_HOME = optionalString withOpenblas openblas_.dev; 485 OpenBLAS = optionalString withOpenblas openblas_; 486 487 + cmakeFlags = 488 + [ 489 + (cmakeBool "OPENCV_GENERATE_PKGCONFIG" true) 490 + (cmakeBool "WITH_OPENMP" true) 491 + (cmakeBool "BUILD_PROTOBUF" false) 492 + (cmakeBool "PROTOBUF_UPDATE_FILES" true) 493 + (cmakeBool "OPENCV_ENABLE_NONFREE" enableUnfree) 494 + (cmakeBool "BUILD_TESTS" runAccuracyTests) 495 + (cmakeBool "BUILD_PERF_TESTS" runPerformanceTests) 496 + (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) 497 + (cmakeBool "BUILD_DOCS" enableDocs) 498 + # "OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT" 499 + # but we have proper separation of build and host libs :), fixes cross 500 + (cmakeBool "OPENCV_ENABLE_PKG_CONFIG" true) 501 + (cmakeBool "WITH_IPP" enableIpp) 502 + (cmakeBool "WITH_TIFF" enableTIFF) 503 + (cmakeBool "WITH_WEBP" enableWebP) 504 + (cmakeBool "WITH_JPEG" enableJPEG) 505 + (cmakeBool "WITH_PNG" enablePNG) 506 + (cmakeBool "WITH_OPENEXR" enableEXR) 507 + (cmakeBool "WITH_OPENJPEG" enableJPEG2000) 508 + (cmakeBool "WITH_JASPER" false) # OpenCV falls back to a vendored copy of Jasper when OpenJPEG is disabled 509 + (cmakeBool "WITH_TBB" enableTbb) 510 511 + # CUDA options 512 + (cmakeBool "WITH_CUDA" enableCuda) 513 + (cmakeBool "WITH_CUBLAS" enableCublas) 514 + (cmakeBool "WITH_CUDNN" enableCudnn) 515 + (cmakeBool "WITH_CUFFT" enableCufft) 516 517 + # LTO options 518 + (cmakeBool "ENABLE_LTO" enableLto) 519 + (cmakeBool "ENABLE_THIN_LTO" ( 520 + enableLto 521 + && ( 522 + # Only clang supports thin LTO, so we must either be using clang through the effectiveStdenv, 523 + effectiveStdenv.cc.isClang 524 + || 525 + # or through the backend effectiveStdenv. 526 + (enableCuda && effectiveStdenv.cc.isClang) 527 + ) 528 + )) 529 + ] 530 + ++ optionals enableCuda [ 531 + (cmakeBool "CUDA_FAST_MATH" true) 532 + (cmakeFeature "CUDA_NVCC_FLAGS" "--expt-relaxed-constexpr") 533 534 + # OpenCV respects at least three variables: 535 + # -DCUDA_GENERATION takes a single arch name, e.g. Volta 536 + # -DCUDA_ARCH_BIN takes a semi-colon separated list of real arches, e.g. "8.0;8.6" 537 + # -DCUDA_ARCH_PTX takes the virtual arch, e.g. "8.6" 538 + (cmakeFeature "CUDA_ARCH_BIN" cmakeCudaArchitecturesString) 539 + (cmakeFeature "CUDA_ARCH_PTX" (last cudaCapabilities)) 540 541 + (cmakeOptionType "path" "NVIDIA_OPTICAL_FLOW_2_0_HEADERS_PATH" nvidia-optical-flow-sdk.outPath) 542 + ] 543 + ++ optionals effectiveStdenv.hostPlatform.isDarwin [ 544 + (cmakeBool "WITH_OPENCL" false) 545 + (cmakeBool "WITH_LAPACK" false) 546 547 + # Disable unnecessary vendoring that's enabled by default only for Darwin. 548 + # Note that the opencvFlag feature flags listed above still take 549 + # precedence, so we can safely list everything here. 550 + (cmakeBool "BUILD_ZLIB" false) 551 + (cmakeBool "BUILD_TIFF" false) 552 + (cmakeBool "BUILD_OPENJPEG" false) 553 + (cmakeBool "BUILD_JASPER" false) 554 + (cmakeBool "BUILD_JPEG" false) 555 + (cmakeBool "BUILD_PNG" false) 556 + (cmakeBool "BUILD_WEBP" false) 557 + ] 558 + ++ optionals (!effectiveStdenv.hostPlatform.isDarwin) [ 559 + (cmakeOptionType "path" "OPENCL_LIBRARY" "${ocl-icd}/lib/libOpenCL.so") 560 + ] 561 + ++ optionals enablePython [ 562 + (cmakeOptionType "path" "OPENCV_PYTHON_INSTALL_PATH" pythonPackages.python.sitePackages) 563 + ] 564 + ++ optionals (enabledModules != [ ]) [ 565 + (cmakeFeature "BUILD_LIST" (concatStringsSep "," enabledModules)) 566 + ]; 567 568 postBuild = optionalString enableDocs '' 569 make doxygen ··· 573 optionalString (runAccuracyTests || runPerformanceTests) '' 574 mkdir $package_tests 575 cp -R $src/samples $package_tests/ 576 + '' 577 + + optionalString runAccuracyTests '' 578 mv ./bin/*test* $package_tests/ 579 + '' 580 + + optionalString runPerformanceTests '' 581 mv ./bin/*perf* $package_tests/ 582 ''; 583 ··· 593 # Note that ${exec_prefix} is set to $out but that $out is also appended to 594 # ${exec_prefix}. This causes linker errors in downstream packages so we strip 595 # of $out after the ${exec_prefix} and ${prefix} prefixes: 596 + postInstall = 597 + '' 598 + sed -i "s|{exec_prefix}/$out|{exec_prefix}|;s|{prefix}/$out|{prefix}|" \ 599 + "$out/lib/pkgconfig/opencv4.pc" 600 + mkdir "$cxxdev" 601 + '' 602 + # fix deps not propagating from opencv4.cxxdev if cuda is disabled 603 + # see https://github.com/NixOS/nixpkgs/issues/276691 604 + + optionalString (!enableCuda) '' 605 + mkdir -p "$cxxdev/nix-support" 606 + echo "''${!outputDev}" >> "$cxxdev/nix-support/propagated-build-inputs" 607 + '' 608 + # remove the requirement that the exact same version of CUDA is used in packages 609 + # consuming OpenCV's CMakes files 610 + + optionalString enableCuda '' 611 + substituteInPlace "$out/lib/cmake/opencv4/OpenCVConfig.cmake" \ 612 + --replace-fail \ 613 + 'find_host_package(CUDA ''${OpenCV_CUDA_VERSION} EXACT REQUIRED)' \ 614 + 'find_host_package(CUDA REQUIRED)' \ 615 + --replace-fail \ 616 + 'message(FATAL_ERROR "OpenCV static library was compiled with CUDA' \ 617 + 'message("OpenCV static library was compiled with CUDA' 618 + '' 619 + # install python distribution information, so other packages can `import opencv` 620 + + optionalString enablePython '' 621 + pushd $NIX_BUILD_TOP/$sourceRoot/modules/python/package 622 + python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist . 623 624 + pushd dist 625 + python -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache 626 627 + popd 628 + popd 629 + ''; 630 631 + pythonImportsCheck = [ 632 + "cv2" 633 + "cv2.sfm" 634 + ]; 635 636 passthru = { 637 cudaSupport = enableCuda; 638 639 + tests = 640 + { 641 + inherit (gst_all_1) gst-plugins-bad; 642 + } 643 + // optionalAttrs (!effectiveStdenv.hostPlatform.isDarwin) { 644 + inherit qimgv; 645 + withIpp = opencv4.override { enableIpp = true; }; 646 + } 647 + // optionalAttrs (!enablePython) { pythonEnabled = pythonPackages.opencv4; } 648 + // optionalAttrs (effectiveStdenv.buildPlatform != "x86_64-darwin") { 649 + opencv4-tests = callPackage ./tests.nix { 650 + inherit 651 + enableGStreamer 652 + enableGtk2 653 + enableGtk3 654 + runAccuracyTests 655 + runPerformanceTests 656 + testDataSrc 657 + ; 658 + inherit opencv4; 659 + }; 660 + } 661 + // optionalAttrs (enableCuda) { 662 + no-libstdcxx-errors = callPackage ./libstdcxx-test.nix { attrName = "opencv4"; }; 663 }; 664 } // optionalAttrs enablePython { pythonPath = [ ]; }; 665 666 meta = { ··· 668 homepage = "https://opencv.org/"; 669 license = if enableUnfree then lib.licenses.unfree else lib.licenses.bsd3; 670 maintainers = with lib.maintainers; [ basvandijk ]; 671 + platforms = lib.platforms.unix; 672 }; 673 }
+8
pkgs/development/libraries/science/math/openblas/default.nix
··· 128 DYNAMIC_ARCH = setDynamicArch true; 129 USE_OPENMP = true; 130 }; 131 }; 132 in 133
··· 128 DYNAMIC_ARCH = setDynamicArch true; 129 USE_OPENMP = true; 130 }; 131 + 132 + x86_64-freebsd = { 133 + BINARY = 64; 134 + TARGET = setTarget "ATHLON"; 135 + DYNAMIC_ARCH = setDynamicArch true; 136 + NO_AVX512 = !enableAVX512; 137 + USE_OPENMP = true; 138 + }; 139 }; 140 in 141
+1 -1
pkgs/development/python-modules/pycairo/default.nix
··· 51 lgpl21Only 52 mpl11 53 ]; 54 - platforms = lib.platforms.linux ++ lib.platforms.darwin; 55 }; 56 }
··· 51 lgpl21Only 52 mpl11 53 ]; 54 + platforms = platforms.unix; 55 }; 56 }