2 , qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel
4 , bison, flex, git, gperf, ninja, pkg-config, python, which, python3
10 , xorg, libXcursor, libXScrnSaver, libXrandr, libXtst
11 , fontconfig, freetype, harfbuzz, icu, dbus, libdrm
12 , zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus
13 , jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent
19 , enableProprietaryCodecs ? true
21 , cctools, libobjc, libpm, libunwind, sandbox, xnu
22 , ApplicationServices, AVFoundation, Foundation, ForceFeedback, GameController, AppKit
23 , ImageCaptureCore, CoreBluetooth, IOBluetooth, CoreWLAN, Quartz, Cocoa, LocalAuthentication
24 , MediaPlayer, MediaAccessibility, SecurityInterface, Vision, CoreML, OpenDirectory, Accelerate
25 , cups, openbsm, runCommand, xcbuild, writeScriptBin
27 , lib, stdenv, fetchpatch
30 , pipewireSupport ? stdenv.isLinux
35 , dbusSupport ? !stdenv.isDarwin, expat
39 # qtwebengine expects to find an executable in $PATH which runs on
40 # the build platform yet knows about the host `.pc` files. Most
41 # configury allows setting $PKG_CONFIG to point to an
42 # arbitrarily-named script which serves this purpose; however QT
43 # insists that it is named `pkg-config` with no target prefix. So
44 # we re-wrap the host platform's pkg-config.
45 pkg-config-wrapped-without-prefix = stdenv.mkDerivation {
46 name = "pkg-config-wrapper-without-target-prefix";
51 ln -s '${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' $out/bin/pkg-config
55 qtPlatformCross = plat: with plat;
57 then "linux-generic-g++"
58 else throw "Please add a qtPlatformCross entry for ${plat.config}";
63 pname = "qtwebengine";
65 bison flex git gperf ninja pkg-config python which gn nodejs
66 ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
68 lndir (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtbase)
69 pkgsBuildBuild.pkg-config
70 (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols)
71 pkg-config-wrapped-without-prefix
72 ] ++ lib.optional stdenv.isDarwin xcbuild;
74 outputs = [ "bin" "dev" "out" ];
76 enableParallelBuilding = true;
78 # Don’t use the gn setup hook
79 dontUseGnConfigure = true;
81 # ninja builds some components with -Wno-format,
82 # which cannot be set at the same time as -Wformat-security
83 hardeningDisable = [ "format" ];
86 # Patch Chromium build tools
88 cd src/3rdparty/chromium;
90 # Manually fix unsupported shebangs
91 substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
92 --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" || true
94 # TODO: be more precise
97 # Fix compatibility with python3.11
98 substituteInPlace tools/metrics/ukm/ukm_model.py \
99 --replace "r'^(?i)(|true|false)$'" "r'(?i)^(|true|false)$'"
100 substituteInPlace tools/grit/grit/util.py \
101 --replace "mode = 'rU'" "mode = 'r'"
104 # Prevent Chromium build script from making the path to `clang` relative to
105 # the build directory. `clang_base_path` is the value of `QMAKE_CLANG_DIR`
106 # from `src/core/config/mac_osx.pri`.
107 + lib.optionalString stdenv.isDarwin ''
108 substituteInPlace ./src/3rdparty/chromium/build/toolchain/mac/BUILD.gn \
109 --replace 'prefix = rebase_path("$clang_base_path/bin/", root_build_dir)' 'prefix = "$clang_base_path/bin/"'
111 # Patch library paths in Qt sources
114 -e "s,QLibraryInfo::location(QLibraryInfo::DataPath),QLatin1String(\"$out\"),g" \
115 -e "s,QLibraryInfo::location(QLibraryInfo::TranslationsPath),QLatin1String(\"$out/translations\"),g" \
116 -e "s,QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath),QLatin1String(\"$out/libexec\"),g" \
117 src/core/web_engine_library_info.cpp
119 # Patch library paths in Chromium sources
120 + lib.optionalString (!stdenv.isDarwin) ''
121 sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
122 src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
124 sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
125 src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
126 '' + lib.optionalString stdenv.isDarwin (''
127 substituteInPlace src/buildtools/config/mac_osx.pri \
128 --replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'
130 # Following is required to prevent a build error:
131 # ninja: error: '/nix/store/z8z04p0ph48w22rqzx7ql67gy8cyvidi-SDKs/MacOSX10.12.sdk/usr/include/mach/exc.defs', needed by 'gen/third_party/crashpad/crashpad/util/mach/excUser.c', missing and no known rule to make it
132 substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
133 --replace '$sysroot/usr' "${xnu}"
135 # Apple has some secret stuff they don't share with OpenBSM
136 substituteInPlace src/3rdparty/chromium/base/mac/mach_port_rendezvous.cc \
137 --replace "audit_token_to_pid(request.trailer.msgh_audit)" "request.trailer.msgh_audit.val[5]"
138 substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/mach/mach_message.cc \
139 --replace "audit_token_to_pid(audit_trailer->msgh_audit)" "audit_trailer->msgh_audit.val[5]"
141 # ld: warning: directory not found for option '-L/nix/store/...-xcodebuild-0.1.2-pre/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib'
142 # ld: fatal warning(s) induced error (-fatal_warnings)
143 substituteInPlace src/3rdparty/chromium/build/config/compiler/BUILD.gn \
144 --replace "-Wl,-fatal_warnings" ""
150 lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
152 ] ++ lib.optionals stdenv.cc.isGNU [
153 # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
154 "-Wno-class-memaccess"
155 ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [
156 # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
157 # TODO: investigate and fix properly
159 ] ++ lib.optionals stdenv.cc.isClang [
160 "-Wno-elaborated-enum-base"
162 } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
163 NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch";
164 "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch";
168 export NINJAFLAGS=-j$NIX_BUILD_CORES
170 if [ -d "$PWD/tools/qmake" ]; then
171 QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
173 '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
175 export QMAKE_CXX=$CXX
176 export QMAKE_LINK=$CXX
180 qmakeFlags = [ "--" "-system-ffmpeg" ]
181 ++ lib.optional (pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform) "-webengine-webrtc-pipewire"
182 ++ lib.optional enableProprietaryCodecs "-proprietary-codecs";
184 propagatedBuildInputs = [
185 qtdeclarative qtquickcontrols qtlocation qtwebchannel
188 libjpeg libpng libtiff libwebp
201 ] ++ lib.optionals (!stdenv.isDarwin) [
202 dbus zlib minizip snappy nss protobuf jsoncpp
215 xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
216 xorg.libXcomposite xorg.libXdamage libdrm xorg.libxkbfile
218 ] ++ lib.optionals pipewireSupport [
223 # FIXME These dependencies shouldn't be needed but can't find a way
224 # around it. Chromium pulls this in while bootstrapping GN.
225 ++ lib.optionals stdenv.isDarwin [
255 buildInputs = lib.optionals stdenv.isDarwin [
260 # `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py`
261 # to get some information about the host platform.
262 (writeScriptBin "sw_vers" ''
265 while [ $# -gt 0 ]; do
267 -buildVersion) echo "17E199";;
276 dontUseNinjaBuild = true;
277 dontUseNinjaInstall = true;
279 postInstall = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
280 mkdir -p $out/libexec
281 '' + lib.optionalString stdenv.isLinux ''
282 cat > $out/libexec/qt.conf <<EOF
288 # Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3)
289 sed 's/${lib.head (lib.splitString "-" version)} /${qtCompatVersion} /' -i "$out"/lib/cmake/*/*Config.cmake
292 requiredSystemFeatures = [ "big-parallel" ];
295 description = "A web engine based on the Chromium web browser";
296 maintainers = with maintainers; [ matthewbauer ];
298 # qtwebengine-5.15.8: "QtWebEngine can only be built for x86,
299 # x86-64, ARM, Aarch64, and MIPSel architectures."
300 platforms = with lib.systems.inspect.patterns;
301 let inherit (lib.systems.inspect) patternLogicalAnd;
302 in concatMap (patternLogicalAnd isUnix) (lib.concatMap lib.toList [
307 (patternLogicalAnd isMips isLittleEndian)
310 # This build takes a long time; particularly on slow architectures
314 } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
315 configurePlatforms = [ ];
316 # to get progress output in `nix-build` and `nix build -L`
321 pkgsBuildBuild.stdenv