54 enableProprietaryCodecs ? true,
66 pipewireSupport ? stdenv.hostPlatform.isLinux,
74 # qtwebengine expects to find an executable in $PATH which runs on
75 # the build platform yet knows about the host `.pc` files. Most
76 # configury allows setting $PKG_CONFIG to point to an
77 # arbitrarily-named script which serves this purpose; however QT
78 # insists that it is named `pkg-config` with no target prefix. So
79 # we re-wrap the host platform's pkg-config.
80 pkg-config-wrapped-without-prefix = stdenv.mkDerivation {
81 name = "pkg-config-wrapper-without-target-prefix";
86 ln -s '${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' $out/bin/pkg-config
94 pname = "qtwebengine";
103 (python.withPackages (ps: [ ps.html5lib ]))
108 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
111 (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtbase)
112 pkgsBuildBuild.pkg-config
113 (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols)
114 pkg-config-wrapped-without-prefix
116 ++ lib.optional stdenv.hostPlatform.isDarwin [
127 enableParallelBuilding = true;
129 # Don’t use the gn setup hook
130 dontUseGnConfigure = true;
132 # ninja builds some components with -Wno-format,
133 # which cannot be set at the same time as -Wformat-security
134 hardeningDisable = [ "format" ];
139 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/14074e4d789167bd776939037fe6df8d4d7dc0b3/qt5-webengine-ffmpeg5.patch";
140 hash = "sha256-jTbJFXBPwRMzr8IeTxrv9dtS+/xDS/zR4dysV/bRg3I=";
142 extraPrefix = "src/3rdparty/";
147 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/e8fb4f86104243b90966b69cdfaa967273d834b6/qt5-webengine-ffmpeg7.patch";
148 hash = "sha256-YNeHmOVp0M5HB+b91AOxxJxl+ktBtLYVdHlq13F7xtY=";
150 extraPrefix = "src/3rdparty/chromium/";
153 # Support PipeWire ≥ 0.3
155 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/c9db2cd9e144bd7a5e9246f5f7a01fe52fd089ba/qt5-webengine-pipewire-0.3.patch";
156 hash = "sha256-mGexRfVDF3yjNzSi9BjavhzPtsXI0BooSr/rZ1z/BDo=";
158 extraPrefix = "src/3rdparty/";
164 # Patch Chromium build tools
166 cd src/3rdparty/chromium;
170 # support for building with python 3.12
171 name = "python312-imp.patch";
172 url = "https://codereview.qt-project.org/gitweb?p=qt/qtwebengine-chromium.git;a=patch;h=3664134f749f4851a14ab1953a9ee460a1fe0b68";
173 hash = "sha256-XY0dEdeuOTRMR7onmuNg1Axld8+pquKAzOfDAGSIzI4=";
178 # support for building with python 3.12
179 name = "python312-six.patch";
180 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/raw/6b0c0e76e0934db2f84be40cb5978cee47266e78/python3.12-six.patch";
181 hash = "sha256-YgP9Sq5+zTC+U7+0hQjZokwb+fytk0UEIJztUXFhTkI=";
185 # Manually fix unsupported shebangs
186 substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
187 --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" || true
189 # TODO: be more precise
193 # Prevent Chromium build script from making the path to `clang` relative to
194 # the build directory. `clang_base_path` is the value of `QMAKE_CLANG_DIR`
195 # from `src/core/config/mac_osx.pri`.
196 + lib.optionalString stdenv.hostPlatform.isDarwin ''
197 substituteInPlace ./src/3rdparty/chromium/build/toolchain/mac/BUILD.gn \
198 --replace 'prefix = rebase_path("$clang_base_path/bin/", root_build_dir)' 'prefix = "$clang_base_path/bin/"'
200 # Patch library paths in Qt sources
203 -e "s,QLibraryInfo::location(QLibraryInfo::DataPath),QLatin1String(\"$out\"),g" \
204 -e "s,QLibraryInfo::location(QLibraryInfo::TranslationsPath),QLatin1String(\"$out/translations\"),g" \
205 -e "s,QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath),QLatin1String(\"$out/libexec\"),g" \
206 src/core/web_engine_library_info.cpp
208 # Patch library paths in Chromium sources
209 + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
210 sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
211 src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
213 sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
214 src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
216 + lib.optionalString stdenv.hostPlatform.isDarwin (''
217 substituteInPlace src/buildtools/config/mac_osx.pri \
218 --replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'
221 echo "gn_args += use_system_ffmpeg=true" >> src/core/config/mac_osx.pri
222 echo "LIBS += -lavformat -lavcodec -lavutil" >> src/core/core_common.pri
228 NIX_CFLAGS_COMPILE = toString (
229 lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
232 ++ lib.optionals stdenv.cc.isGNU [
233 # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
234 "-Wno-class-memaccess"
236 ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [
237 # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
238 # TODO: investigate and fix properly
241 ++ lib.optionals stdenv.cc.isClang [
242 "-Wno-elaborated-enum-base"
246 // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
247 NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch";
248 "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch";
253 export NINJAFLAGS=-j$NIX_BUILD_CORES
255 if [ -d "$PWD/tools/qmake" ]; then
256 QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
259 + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
261 export QMAKE_CXX=$CXX
262 export QMAKE_LINK=$CXX
272 pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform
273 ) "-webengine-webrtc-pipewire"
274 ++ lib.optional enableProprietaryCodecs "-proprietary-codecs";
276 propagatedBuildInputs =
303 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
336 ++ lib.optionals pipewireSupport [
341 # FIXME These dependencies shouldn't be needed but can't find a way
342 # around it. Chromium pulls this in while bootstrapping GN.
343 ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools.libtool ];
345 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
348 # `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py`
349 # to get some information about the host platform.
350 (writeScriptBin "sw_vers" ''
353 while [ $# -gt 0 ]; do
355 -buildVersion) echo "17E199";;
364 dontUseNinjaBuild = true;
365 dontUseNinjaInstall = true;
368 lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
369 mkdir -p $out/libexec
371 + lib.optionalString stdenv.hostPlatform.isLinux ''
372 cat > $out/libexec/qt.conf <<EOF
379 # Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3)
380 sed 's/${lib.head (lib.splitString "-" version)} /${qtCompatVersion} /' -i "$out"/lib/cmake/*/*Config.cmake
383 requiredSystemFeatures = [ "big-parallel" ];
386 description = "Web engine based on the Chromium web browser";
387 mainProgram = "qwebengine_convert_dict";
388 maintainers = with maintainers; [ matthewbauer ];
390 # qtwebengine-5.15.8: "QtWebEngine can only be built for x86,
391 # x86-64, ARM, Aarch64, and MIPSel architectures."
393 with lib.systems.inspect.patterns;
395 inherit (lib.systems.inspect) patternLogicalAnd;
397 concatMap (patternLogicalAnd isUnix) (
398 lib.concatMap lib.toList [
403 (patternLogicalAnd isMips isLittleEndian)
407 # This build takes a long time; particularly on slow architectures
412 // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
413 configurePlatforms = [ ];
414 # to get progress output in `nix-build` and `nix build -L`
419 pkgsBuildBuild.stdenv