|
15 | 15 | "x86_64-darwin" |
16 | 16 | "aarch64-darwin" |
17 | 17 | ]; |
| 18 | + |
18 | 19 | forEachSupportedSystem = |
19 | 20 | f: |
20 | 21 | inputs.nixpkgs.lib.genAttrs supportedSystems ( |
21 | 22 | system: |
22 | 23 | f { |
23 | | - pkgs = import inputs.nixpkgs { inherit system; }; |
24 | | - pkgsStatic = import inputs.nixpkgs { |
| 24 | + pkgs = import inputs.nixpkgs { |
25 | 25 | inherit system; |
26 | 26 | }; |
27 | | - pkgsWindows = import inputs.nixpkgs { |
| 27 | + |
| 28 | + pkgsStatic = import inputs.nixpkgs { |
28 | 29 | inherit system; |
29 | | - crossSystem = { |
30 | | - config = "x86_64-w64-mingw32"; |
31 | | - }; |
32 | | - config = { |
33 | | - allowBroken = true; |
34 | | - }; |
35 | 30 | }; |
| 31 | + |
| 32 | + pkgsWindows = ( |
| 33 | + import inputs.nixpkgs { |
| 34 | + inherit system; |
| 35 | + crossSystem = { |
| 36 | + config = "x86_64-w64-mingw32"; |
| 37 | + }; |
| 38 | + config = { |
| 39 | + allowBroken = true; |
| 40 | + }; |
| 41 | + } |
| 42 | + ); |
36 | 43 | } |
37 | 44 | ); |
38 | 45 | in |
|
46 | 53 | let |
47 | 54 | mkPackage = |
48 | 55 | pkgsForBuild: pkgsForHost: isStatic: isWindows: |
49 | | - pkgsForHost.stdenv.mkDerivation { |
| 56 | + let |
| 57 | + baseStdenv = pkgsForHost.stdenv; |
| 58 | + |
| 59 | + # On Windows, use win32 threads to get a fully static binary |
| 60 | + stdenv' = |
| 61 | + if isWindows && baseStdenv.cc.isGNU && baseStdenv.targetPlatform.isWindows then |
| 62 | + let |
| 63 | + buildPkgs = pkgsForHost.buildPackages; |
| 64 | + gccWin32 = buildPkgs.wrapCC ( |
| 65 | + buildPkgs.gcc-unwrapped.override { |
| 66 | + threadsCross = { |
| 67 | + model = "win32"; |
| 68 | + package = null; |
| 69 | + }; |
| 70 | + } |
| 71 | + ); |
| 72 | + in |
| 73 | + pkgsForHost.overrideCC baseStdenv gccWin32 |
| 74 | + else |
| 75 | + baseStdenv; |
| 76 | + |
| 77 | + # zlib-ng in zlib-compatible mode |
| 78 | + zlibNgCompat = pkgsForHost.zlib-ng.override { |
| 79 | + withZlibCompat = true; |
| 80 | + }; |
| 81 | + |
| 82 | + # Use zlib-ng and force it to be static-only (we mainly care on Windows) |
| 83 | + zlibNgStatic = zlibNgCompat.overrideAttrs (old: { |
| 84 | + dontDisableStatic = true; |
| 85 | + cmakeFlags = (old.cmakeFlags or [ ]) ++ [ |
| 86 | + "-DBUILD_SHARED_LIBS=OFF" |
| 87 | + ]; |
| 88 | + }); |
| 89 | + |
| 90 | + # libpng that uses zlib-ng instead of plain zlib |
| 91 | + libpngWithZlibNg = pkgsForHost.libpng.override { |
| 92 | + zlib = zlibNgStatic; |
| 93 | + }; |
| 94 | + |
| 95 | + in |
| 96 | + stdenv'.mkDerivation { |
50 | 97 | pname = "ffmpegthumbnailer"; |
51 | 98 | version = "dev"; |
52 | 99 |
|
|
65 | 112 | if isStatic || isWindows then |
66 | 113 | (ffmpeg-headless.override { |
67 | 114 | withGPL = true; |
| 115 | + withShared = false; |
| 116 | + withStatic = true; |
| 117 | + zlib = zlibNgStatic; |
| 118 | + |
| 119 | + # Disable CUDA/LLVM to avoid compiler-rt dependency |
| 120 | + withCuda = false; |
| 121 | + withCudaLLVM = false; |
| 122 | + withCudaNVCC = false; |
68 | 123 | buildAvdevice = false; |
69 | 124 | buildSwresample = false; |
70 | 125 | buildFfmpeg = false; |
|
89 | 144 | withSpeex = false; |
90 | 145 | withSoxr = false; |
91 | 146 | withAmf = false; |
| 147 | + withCelt = false; |
92 | 148 | # Disable X11 for headless |
93 | 149 | withXcb = false; |
94 | 150 | withFontconfig = false; |
|
118 | 174 | withDrm = false; |
119 | 175 | # only needed for dash demuxing |
120 | 176 | withXml2 = false; |
121 | | - # These deps are only neede for encoding |
| 177 | + # These deps are only needed for encoding |
122 | 178 | withWebp = false; |
123 | 179 | withTheora = false; |
124 | 180 | withX264 = false; |
125 | 181 | withX265 = false; |
126 | 182 | withXvid = false; |
127 | 183 | withSvtav1 = false; |
128 | 184 | # Disable dav1d for static macOS builds |
129 | | - withDav1d = if (isStatic && stdenv.isDarwin) then false else true; |
| 185 | + withDav1d = if (isStatic && stdenv'.isDarwin) then false else true; |
130 | 186 | }).overrideAttrs |
131 | 187 | (old: { |
132 | 188 | doCheck = false; |
|
140 | 196 | else |
141 | 197 | ffmpeg-headless |
142 | 198 | ) |
143 | | - libjpeg |
144 | | - libpng |
| 199 | + # Use static versions of libpng and libjpeg for Windows |
| 200 | + ( |
| 201 | + if isWindows then |
| 202 | + libjpeg.override { |
| 203 | + enableStatic = true; |
| 204 | + enableShared = false; |
| 205 | + } |
| 206 | + else |
| 207 | + libjpeg |
| 208 | + ) |
| 209 | + ( |
| 210 | + if isWindows then |
| 211 | + libpngWithZlibNg.overrideAttrs (old: { |
| 212 | + dontDisableStatic = true; |
| 213 | + configureFlags = (old.configureFlags or [ ]) ++ [ |
| 214 | + "--enable-static" |
| 215 | + "--disable-shared" |
| 216 | + ]; |
| 217 | + }) |
| 218 | + else |
| 219 | + libpng |
| 220 | + ) |
| 221 | + |
145 | 222 | ] |
146 | 223 | ++ pkgsForHost.lib.optionals isWindows [ |
147 | 224 | # ffmpeg transitive dependencies needed for linking on Windows |
148 | | - bzip2 |
149 | | - xz |
| 225 | + zlibNgStatic |
| 226 | + (xz.overrideAttrs (old: { |
| 227 | + dontDisableStatic = true; |
| 228 | + configureFlags = (old.configureFlags or [ ]) ++ [ |
| 229 | + "--enable-static" |
| 230 | + "--disable-shared" |
| 231 | + ]; |
| 232 | + })) |
| 233 | + (bzip2.overrideAttrs (old: { |
| 234 | + dontDisableStatic = true; |
| 235 | + configureFlags = (old.configureFlags or [ ]) ++ [ |
| 236 | + "--enable-static" |
| 237 | + "--disable-shared" |
| 238 | + ]; |
| 239 | + })) |
| 240 | + (libiconv.overrideAttrs (old: { |
| 241 | + dontDisableStatic = true; |
| 242 | + configureFlags = (old.configureFlags or [ ]) ++ [ |
| 243 | + "--enable-static" |
| 244 | + "--disable-shared" |
| 245 | + ]; |
| 246 | + })) |
| 247 | + (dav1d.overrideAttrs (old: { |
| 248 | + mesonFlags = (old.mesonFlags or [ ]) ++ [ |
| 249 | + "-Ddefault_library=static" |
| 250 | + "-Denable_tools=false" |
| 251 | + "-Denable_tests=false" |
| 252 | + ]; |
| 253 | + })) |
150 | 254 | ] |
151 | 255 | ++ pkgsForHost.lib.optionals (pkgsForHost.stdenv.isLinux && !isStatic) [ |
152 | 256 | glib |
|
0 commit comments