Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 479 lines 15 kB view raw
1{ 2 qtModule, 3 qtdeclarative, 4 qtquickcontrols, 5 qtlocation, 6 qtwebchannel, 7 fetchpatch, 8 fetchpatch2, 9 10 bison, 11 flex, 12 gperf, 13 ninja, 14 pkg-config, 15 python, 16 which, 17 nodejs, 18 perl, 19 buildPackages, 20 pkgsBuildTarget, 21 pkgsBuildBuild, 22 23 xorg, 24 libXcursor, 25 libXScrnSaver, 26 libXrandr, 27 libXtst, 28 fontconfig, 29 freetype, 30 harfbuzz, 31 icu, 32 dbus, 33 libdrm, 34 zlib, 35 minizip, 36 libjpeg, 37 libpng, 38 libtiff, 39 libwebp, 40 libopus, 41 jsoncpp, 42 protobuf, 43 libvpx, 44 srtp, 45 snappy, 46 nss, 47 libevent, 48 alsa-lib, 49 pulseaudio, 50 libcap, 51 pciutils, 52 systemd, 53 enableProprietaryCodecs ? true, 54 gn, 55 cctools, 56 cups, 57 bootstrap_cmds, 58 xcbuild, 59 writeScriptBin, 60 ffmpeg ? null, 61 lib, 62 stdenv, 63 version ? null, 64 qtCompatVersion, 65 pipewireSupport ? stdenv.hostPlatform.isLinux, 66 pipewire, 67 postPatch ? "", 68 nspr, 69 lndir, 70}: 71 72let 73 # qtwebengine expects to find an executable in $PATH which runs on 74 # the build platform yet knows about the host `.pc` files. Most 75 # configury allows setting $PKG_CONFIG to point to an 76 # arbitrarily-named script which serves this purpose; however QT 77 # insists that it is named `pkg-config` with no target prefix. So 78 # we re-wrap the host platform's pkg-config. 79 pkg-config-wrapped-without-prefix = stdenv.mkDerivation { 80 name = "pkg-config-wrapper-without-target-prefix"; 81 dontUnpack = true; 82 dontBuild = true; 83 installPhase = '' 84 mkdir -p $out/bin 85 ln -s '${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' $out/bin/pkg-config 86 ''; 87 }; 88 89in 90 91qtModule ( 92 { 93 pname = "qtwebengine"; 94 nativeBuildInputs = [ 95 bison 96 flex 97 gperf 98 ninja 99 pkg-config 100 (python.withPackages (ps: [ ps.html5lib ])) 101 which 102 gn 103 nodejs 104 ] 105 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 106 perl 107 lndir 108 (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtbase) 109 pkgsBuildBuild.pkg-config 110 (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols) 111 pkg-config-wrapped-without-prefix 112 ] 113 ++ lib.optional stdenv.hostPlatform.isDarwin [ 114 bootstrap_cmds 115 xcbuild 116 ]; 117 doCheck = true; 118 outputs = [ 119 "bin" 120 "dev" 121 "out" 122 ]; 123 124 enableParallelBuilding = true; 125 126 # Don’t use the gn setup hook 127 dontUseGnConfigure = true; 128 129 # ninja builds some components with -Wno-format, 130 # which cannot be set at the same time as -Wformat-security 131 hardeningDisable = [ "format" ]; 132 133 patches = [ 134 # Support FFmpeg 5 135 (fetchpatch2 { 136 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/14074e4d789167bd776939037fe6df8d4d7dc0b3/qt5-webengine-ffmpeg5.patch"; 137 hash = "sha256-jTbJFXBPwRMzr8IeTxrv9dtS+/xDS/zR4dysV/bRg3I="; 138 stripLen = 1; 139 extraPrefix = "src/3rdparty/"; 140 }) 141 142 # Support FFmpeg 7 143 (fetchpatch2 { 144 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/e8fb4f86104243b90966b69cdfaa967273d834b6/qt5-webengine-ffmpeg7.patch"; 145 hash = "sha256-YNeHmOVp0M5HB+b91AOxxJxl+ktBtLYVdHlq13F7xtY="; 146 stripLen = 1; 147 extraPrefix = "src/3rdparty/chromium/"; 148 }) 149 150 # Support PipeWire ≥ 0.3 151 (fetchpatch2 { 152 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/c9db2cd9e144bd7a5e9246f5f7a01fe52fd089ba/qt5-webengine-pipewire-0.3.patch"; 153 hash = "sha256-mGexRfVDF3yjNzSi9BjavhzPtsXI0BooSr/rZ1z/BDo="; 154 stripLen = 1; 155 extraPrefix = "src/3rdparty/"; 156 }) 157 158 # Fix race condition exposed by missing dependency 159 # https://bugs.gentoo.org/933368 160 ./qtwebengine-fix_build_pdf_extension_util.patch 161 162 # The latest version of Clang changed what macros it predefines on Apple 163 # targets, causing errors about predefined macros in zlib. 164 (fetchpatch2 { 165 url = "https://github.com/chromium/chromium/commit/2f39ac8d0a414dd65c0e1d5aae38c8f97aa06ae9.patch"; 166 hash = "sha256-3kA2os0IntxIiJwzS5nPd7QWYlOWOpoLKYsOQFYv0Sk="; 167 stripLen = 1; 168 extraPrefix = "src/3rdparty/chromium/"; 169 }) 170 171 # The latest version of Clang changed what macros it predefines on Apple 172 # targets, causing errors about predefined macros in libpng. 173 (fetchpatch2 { 174 url = "https://github.com/chromium/chromium/commit/66defc14abe47c0494da9faebebfa0a5b6efcf38.patch"; 175 hash = "sha256-ErS5Eycls5+xQLGYKz1r/tQC6IcRJWb/WoGsUyzO9WY="; 176 stripLen = 1; 177 extraPrefix = "src/3rdparty/chromium/"; 178 }) 179 180 # https://trac.macports.org/ticket/71563 181 # src/3rdparty/chromium/third_party/freetype/src/src/gzip/ftzconf.h:228:12: error: unknown type name 'Byte' 182 (fetchpatch2 { 183 url = "https://github.com/macports/macports-ports/raw/f9a4136c48020b01ecc6dffa99b88333c360f056/aqua/qt5/files/patch-qtwebengine-chromium-freetype-gzip.diff"; 184 hash = "sha256-NeLmMfYMo80u3h+5GTenMANWfWLPeS35cKg+h3vzW4g="; 185 extraPrefix = ""; 186 }) 187 188 # src/3rdparty/chromium/base/process/process_metrics_mac.cc:303:17: error: static assertion expression is not an integral constant expression 189 (fetchpatch2 { 190 url = "https://github.com/macports/macports-ports/raw/f9a4136c48020b01ecc6dffa99b88333c360f056/aqua/qt5/files/patch-qtwebengine_chromium_static_page_size.diff"; 191 hash = "sha256-8TFN5XU0SUvPJCFU6wvcKP5a8HCd0ygUnLT8BF4MZ/E="; 192 extraPrefix = ""; 193 }) 194 195 # Add "-target-feature +aes" to the arm crc32c build flags 196 (fetchpatch2 { 197 url = "https://github.com/chromium/chromium/commit/9f43d823b6b4cdea62f0cc7563ff01f9239b8970.patch"; 198 hash = "sha256-2WCx+ZOWA8ZyV2yiSQLx9uFZOoeWQHxLqwLEZsV41QU="; 199 stripLen = 1; 200 extraPrefix = "src/3rdparty/chromium/"; 201 }) 202 203 # Fix build with clang and libc++ 19 204 # https://github.com/freebsd/freebsd-ports/commit/0ddd6468fb3cb9ba390973520517cb1ca2cd690d 205 (fetchpatch2 { 206 url = "https://github.com/freebsd/freebsd-ports/raw/0ddd6468fb3cb9ba390973520517cb1ca2cd690d/www/qt5-webengine/files/patch-libc++19"; 207 hash = "sha256-pSVPnuEpjFHW60dbId5sZ3zHP709EWG4LSWoS+TkgcQ="; 208 extraPrefix = ""; 209 }) 210 (fetchpatch2 { 211 url = "https://github.com/freebsd/freebsd-ports/raw/0ddd6468fb3cb9ba390973520517cb1ca2cd690d/www/qt5-webengine/files/patch-src_3rdparty_chromium_third__party_blink_renderer_platform_wtf_hash__table.h"; 212 hash = "sha256-+vyWC7Indd1oBhvL5fMTlIH4mM4INgISZFAbHsq32Lg="; 213 extraPrefix = ""; 214 }) 215 (fetchpatch2 { 216 url = "https://github.com/freebsd/freebsd-ports/raw/0ddd6468fb3cb9ba390973520517cb1ca2cd690d/www/qt5-webengine/files/patch-src_3rdparty_chromium_third__party_perfetto_include_perfetto_tracing_internal_track__event__data__source.h"; 217 hash = "sha256-DcAYOV9b30ogPCiedvQimEmiZpUJquk5j6WLjJxR54U="; 218 extraPrefix = ""; 219 }) 220 ]; 221 222 postPatch = '' 223 # Patch Chromium build tools 224 ( 225 cd src/3rdparty/chromium; 226 227 patch -p1 < ${ 228 (fetchpatch { 229 # support for building with python 3.12 230 name = "python312-six.patch"; 231 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/6b0c0e76e0934db2f84be40cb5978cee47266e78/python3.12-six.patch"; 232 hash = "sha256-YgP9Sq5+zTC+U7+0hQjZokwb+fytk0UEIJztUXFhTkI="; 233 }) 234 } 235 236 # Manually fix unsupported shebangs 237 substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \ 238 --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" || true 239 240 # TODO: be more precise 241 patchShebangs . 242 ) 243 '' 244 # Prevent Chromium build script from making the path to `clang` relative to 245 # the build directory. `clang_base_path` is the value of `QMAKE_CLANG_DIR` 246 # from `src/core/config/mac_osx.pri`. 247 + lib.optionalString stdenv.hostPlatform.isDarwin '' 248 substituteInPlace ./src/3rdparty/chromium/build/toolchain/mac/BUILD.gn \ 249 --replace 'prefix = rebase_path("$clang_base_path/bin/", root_build_dir)' 'prefix = "$clang_base_path/bin/"' 250 '' 251 # Patch library paths in Qt sources 252 + '' 253 sed -i \ 254 -e "s,QLibraryInfo::location(QLibraryInfo::DataPath),QLatin1String(\"$out\"),g" \ 255 -e "s,QLibraryInfo::location(QLibraryInfo::TranslationsPath),QLatin1String(\"$out/translations\"),g" \ 256 -e "s,QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath),QLatin1String(\"$out/libexec\"),g" \ 257 src/core/web_engine_library_info.cpp 258 '' 259 # Patch library paths in Chromium sources 260 + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 261 sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \ 262 src/3rdparty/chromium/device/udev_linux/udev?_loader.cc 263 264 sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \ 265 src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc 266 '' 267 + lib.optionalString stdenv.hostPlatform.isDarwin ('' 268 substituteInPlace src/buildtools/config/mac_osx.pri \ 269 --replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"' 270 271 # Use system ffmpeg 272 echo "gn_args += use_system_ffmpeg=true" >> src/core/config/mac_osx.pri 273 echo "LIBS += -lavformat -lavcodec -lavutil" >> src/core/core_common.pri 274 '') 275 + postPatch; 276 277 env = { 278 NIX_CFLAGS_COMPILE = toString ( 279 lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 280 "-w " 281 ] 282 ++ lib.optionals stdenv.cc.isGNU [ 283 # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit 284 "-Wno-class-memaccess" 285 ] 286 ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ 287 # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 288 # TODO: investigate and fix properly 289 "-march=westmere" 290 ] 291 ++ lib.optionals stdenv.cc.isClang [ 292 "-Wno-elaborated-enum-base" 293 # 5.15.17: need to silence these two warnings 294 # https://trac.macports.org/ticket/70850 295 "-Wno-enum-constexpr-conversion" 296 "-Wno-unused-but-set-variable" 297 # Clang 19 298 "-Wno-error=missing-template-arg-list-after-template-kw" 299 ] 300 ); 301 } 302 // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { 303 NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch"; 304 "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch"; 305 }; 306 307 preConfigure = '' 308 export NINJAFLAGS=-j$NIX_BUILD_CORES 309 310 if [ -d "$PWD/tools/qmake" ]; then 311 QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH" 312 fi 313 '' 314 + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' 315 export QMAKE_CC=$CC 316 export QMAKE_CXX=$CXX 317 export QMAKE_LINK=$CXX 318 export QMAKE_AR=$AR 319 ''; 320 321 qmakeFlags = [ 322 "--" 323 "-system-ffmpeg" 324 ] 325 ++ lib.optional ( 326 pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform 327 ) "-webengine-webrtc-pipewire" 328 ++ lib.optional enableProprietaryCodecs "-proprietary-codecs"; 329 330 propagatedBuildInputs = [ 331 qtdeclarative 332 qtquickcontrols 333 qtlocation 334 qtwebchannel 335 336 # Image formats 337 libjpeg 338 libpng 339 libtiff 340 libwebp 341 342 # Video formats 343 srtp 344 libvpx 345 346 # Audio formats 347 libopus 348 349 # Text rendering 350 harfbuzz 351 icu 352 353 libevent 354 ffmpeg 355 ] 356 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ 357 dbus 358 zlib 359 minizip 360 snappy 361 nss 362 protobuf 363 jsoncpp 364 365 # Audio formats 366 alsa-lib 367 pulseaudio 368 369 # Text rendering 370 fontconfig 371 freetype 372 373 libcap 374 pciutils 375 376 # X11 libs 377 xorg.xrandr 378 libXScrnSaver 379 libXcursor 380 libXrandr 381 xorg.libpciaccess 382 libXtst 383 xorg.libXcomposite 384 xorg.libXdamage 385 libdrm 386 xorg.libxkbfile 387 388 ] 389 ++ lib.optionals pipewireSupport [ 390 # Pipewire 391 pipewire 392 ] 393 394 # FIXME These dependencies shouldn't be needed but can't find a way 395 # around it. Chromium pulls this in while bootstrapping GN. 396 ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools.libtool ]; 397 398 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ 399 cups 400 401 # `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py` 402 # to get some information about the host platform. 403 (writeScriptBin "sw_vers" '' 404 #!${stdenv.shell} 405 406 while [ $# -gt 0 ]; do 407 case "$1" in 408 -buildVersion) echo "17E199";; 409 *) break ;; 410 411 esac 412 shift 413 done 414 '') 415 ]; 416 417 dontUseNinjaBuild = true; 418 dontUseNinjaInstall = true; 419 420 postInstall = 421 lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' 422 mkdir -p $out/libexec 423 '' 424 + lib.optionalString stdenv.hostPlatform.isLinux '' 425 cat > $out/libexec/qt.conf <<EOF 426 [Paths] 427 Prefix = .. 428 EOF 429 430 '' 431 + '' 432 # Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3) 433 sed 's/${lib.head (lib.splitString "-" version)} /${qtCompatVersion} /' -i "$out"/lib/cmake/*/*Config.cmake 434 ''; 435 436 requiredSystemFeatures = [ "big-parallel" ]; 437 438 meta = with lib; { 439 description = "Web engine based on the Chromium web browser"; 440 mainProgram = "qwebengine_convert_dict"; 441 maintainers = with maintainers; [ matthewbauer ]; 442 443 # qtwebengine-5.15.8: "QtWebEngine can only be built for x86, 444 # x86-64, ARM, Aarch64, and MIPSel architectures." 445 platforms = 446 with lib.systems.inspect.patterns; 447 let 448 inherit (lib.systems.inspect) patternLogicalAnd; 449 in 450 concatMap (patternLogicalAnd isUnix) ( 451 lib.concatMap lib.toList [ 452 isx86_32 453 isx86_64 454 isAarch32 455 isAarch64 456 (patternLogicalAnd isMips isLittleEndian) 457 ] 458 ); 459 460 # This build takes a long time; particularly on slow architectures 461 timeout = 24 * 3600; 462 }; 463 464 } 465 // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { 466 configurePlatforms = [ ]; 467 # to get progress output in `nix-build` and `nix build -L` 468 preBuild = '' 469 export TERM=dumb 470 ''; 471 depsBuildBuild = [ 472 pkgsBuildBuild.stdenv 473 zlib 474 nss 475 nspr 476 ]; 477 478 } 479)