nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebengine.nix

246 lines
7.9 KiB
Nix
Raw Normal View History

{ qtModule
, qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel
, bison, coreutils, flex, git, gperf, ninja, pkg-config, python2, which
, nodejs, qtbase, perl
2018-03-13 10:16:03 +00:00
, xorg, libXcursor, libXScrnSaver, libXrandr, libXtst
2018-03-18 16:28:14 +00:00
, fontconfig, freetype, harfbuzz, icu, dbus, libdrm
, zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus
, jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent
, alsa-lib
, libcap
, pciutils
, systemd
2021-05-19 17:14:38 +00:00
, pipewire_0_2
, enableProprietaryCodecs ? true
, gn
2020-08-19 12:55:11 +00:00
, cups, darwin, openbsm, runCommand, xcbuild, writeScriptBin
, ffmpeg ? null
, lib, stdenv, fetchpatch
, version ? null
, qtCompatVersion
}:
2021-01-23 17:15:07 +00:00
with lib;
qtModule {
2021-05-14 10:53:30 +00:00
pname = "qtwebengine";
qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ];
nativeBuildInputs = [
bison coreutils flex git gperf ninja pkg-config python2 which gn nodejs
] ++ optional stdenv.isDarwin xcbuild;
doCheck = true;
outputs = [ "bin" "dev" "out" ];
enableParallelBuilding = true;
# Dont use the gn setup hook
dontUseGnConfigure = true;
# ninja builds some components with -Wno-format,
# which cannot be set at the same time as -Wformat-security
hardeningDisable = [ "format" ];
postPatch =
''
# Patch Chromium build tools
(
cd src/3rdparty/chromium;
# Manually fix unsupported shebangs
substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
--replace "/usr/bin/env -S make -f" "/usr/bin/make -f" || true
patchShebangs .
)
''
2020-08-19 12:55:11 +00:00
# Prevent Chromium build script from making the path to `clang` relative to
# the build directory. `clang_base_path` is the value of `QMAKE_CLANG_DIR`
# from `src/core/config/mac_osx.pri`.
+ optionalString stdenv.isDarwin ''
substituteInPlace ./src/3rdparty/chromium/build/toolchain/mac/BUILD.gn \
--replace 'prefix = rebase_path("$clang_base_path/bin/", root_build_dir)' 'prefix = "$clang_base_path/bin/"'
''
# Patch library paths in Qt sources
+ ''
sed -i \
-e "s,QLibraryInfo::location(QLibraryInfo::DataPath),QLatin1String(\"$out\"),g" \
-e "s,QLibraryInfo::location(QLibraryInfo::TranslationsPath),QLatin1String(\"$out/translations\"),g" \
-e "s,QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath),QLatin1String(\"$out/libexec\"),g" \
src/core/web_engine_library_info.cpp
''
# Patch library paths in Chromium sources
+ optionalString (!stdenv.isDarwin) ''
sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
''
+ optionalString stdenv.isDarwin (
(if (lib.versionAtLeast qtCompatVersion "5.14") then ''
substituteInPlace src/buildtools/config/mac_osx.pri \
--replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'
'' else ''
substituteInPlace src/core/config/mac_osx.pri \
2020-08-19 12:55:11 +00:00
--replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'
'')
2020-08-19 12:55:11 +00:00
# Following is required to prevent a build error:
# 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
+ ''
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
--replace '$sysroot/usr' "${darwin.xnu}"
''
# Apple has some secret stuff they don't share with OpenBSM
+ (if (lib.versionAtLeast qtCompatVersion "5.14") then ''
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_rendezvous.cc \
--replace "audit_token_to_pid(request.trailer.msgh_audit)" "request.trailer.msgh_audit.val[5]"
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/mach/mach_message.cc \
--replace "audit_token_to_pid(audit_trailer->msgh_audit)" "audit_trailer->msgh_audit.val[5]"
'' else ''
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_broker.mm \
--replace "audit_token_to_pid(msg.trailer.msgh_audit)" "msg.trailer.msgh_audit.val[5]"
''));
NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [
# with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
"-Wno-class-memaccess"
] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [
# it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
# TODO: investigate and fix properly
"-march=westmere"
] ++ lib.optionals stdenv.isDarwin [
2020-08-19 12:55:11 +00:00
"-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_12"
"-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_12"
#
# Prevent errors like
# /nix/store/xxx-apple-framework-CoreData/Library/Frameworks/CoreData.framework/Headers/NSEntityDescription.h:51:7:
# error: pointer to non-const type 'id' with no explicit ownership
# id** _kvcPropertyAccessors;
#
# TODO remove when new Apple SDK is in
#
"-fno-objc-arc"
];
preConfigure = ''
export NINJAFLAGS=-j$NIX_BUILD_CORES
if [ -d "$PWD/tools/qmake" ]; then
QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
fi
'';
qmakeFlags = [ "--" "-system-ffmpeg" ]
qtwebengine: only set -webengine-webrtc-pipewire with qt >= 5.15 This fails the build of qt514.qtwebengine otherwise: ``` QMAKEPATH=/nix/store/29n056mi3pji6si51b128pa67b1qr7wq-qtbase-5.14.2-dev:/nix/store/g7wady1f1r23wlmy4q1f3b8j2fj5q2sq-qtdeclarative-dev:/nix/store/xfqnh2pma99915d4gsanls68z1jikcpx-qtsvg-dev:/nix/store/zlnsjdj5yv1ivi1miq49j9gp382byl35-qtlocation-dev:/nix/store/lb7cidi60cabpa7swv51xnss9045vqzi-qtmultimedia-dev:/nix/store/jrk6bcqihxwsszwy6rwy2vnfc2sb4rv9-qtwebchannel-dev qmake PREFIX=/nix/store/pa3jhipp59f6ykh9k8l8z8jf88k52bz8-qtwebengine NIX_OUTPUT_OUT=/nix/store/pa3jhipp59f6ykh9k8l8z8jf88k52bz8-qtwebengine NIX_OUTPUT_DEV=/nix/store/jngs3qilw9iiv97rawb9sb9sd6qdbp2s-qtwebengine-dev NIX_OUTPUT_BIN=/nix/store/91hqv88qvg2wb91lv1h1pd4d8wwrkd5d-qtwebengine-bin NIX_OUTPUT_DOC=/nix/store/jngs3qilw9iiv97rawb9sb9sd6qdbp2s-qtwebengine-dev/share/doc/qt-5.14.2 NIX_OUTPUT_QML=/nix/store/91hqv88qvg2wb91lv1h1pd4d8wwrkd5d-qtwebengine-bin/lib/qt-5.14.2/qml NIX_OUTPUT_PLUGIN=/nix/store/91hqv88qvg2wb91lv1h1pd4d8wwrkd5d-qtwebengine-bin/lib/qt-5.14.2/plugins CONFIG+=release -- -system-ffmpeg -webengine-webrtc-pipewire -proprietary-codecs Info: creating stash file /build/qtwebengine-everywhere-src-5.14.2/.qmake.stash Info: creating cache file /build/qtwebengine-everywhere-src-5.14.2/.qmake.cache ERROR: Unknown command line option '-webengine-webrtc-pipewire'. builder for '/nix/store/g6dvr7789sswmahlxc6zs5pr8k2g5pgy-qtwebengine.drv' failed with exit code 3 ``` Also, only bring in pipewire_0_2 if we enable pipewire support.
2021-05-22 22:26:16 +00:00
++ optional (stdenv.isLinux && (lib.versionAtLeast qtCompatVersion "5.15")) "-webengine-webrtc-pipewire"
++ optional enableProprietaryCodecs "-proprietary-codecs";
propagatedBuildInputs = [
# Image formats
libjpeg libpng libtiff libwebp
# Video formats
srtp libvpx
# Audio formats
libopus
# Text rendering
harfbuzz icu
libevent
ffmpeg
] ++ optionals (!stdenv.isDarwin) [
dbus zlib minizip snappy nss protobuf jsoncpp
# Audio formats
alsa-lib
# Text rendering
fontconfig freetype
libcap
pciutils
# X11 libs
2018-03-13 10:16:03 +00:00
xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
xorg.libXcomposite xorg.libXdamage libdrm xorg.libxkbfile
2021-05-19 17:14:38 +00:00
qtwebengine: only set -webengine-webrtc-pipewire with qt >= 5.15 This fails the build of qt514.qtwebengine otherwise: ``` QMAKEPATH=/nix/store/29n056mi3pji6si51b128pa67b1qr7wq-qtbase-5.14.2-dev:/nix/store/g7wady1f1r23wlmy4q1f3b8j2fj5q2sq-qtdeclarative-dev:/nix/store/xfqnh2pma99915d4gsanls68z1jikcpx-qtsvg-dev:/nix/store/zlnsjdj5yv1ivi1miq49j9gp382byl35-qtlocation-dev:/nix/store/lb7cidi60cabpa7swv51xnss9045vqzi-qtmultimedia-dev:/nix/store/jrk6bcqihxwsszwy6rwy2vnfc2sb4rv9-qtwebchannel-dev qmake PREFIX=/nix/store/pa3jhipp59f6ykh9k8l8z8jf88k52bz8-qtwebengine NIX_OUTPUT_OUT=/nix/store/pa3jhipp59f6ykh9k8l8z8jf88k52bz8-qtwebengine NIX_OUTPUT_DEV=/nix/store/jngs3qilw9iiv97rawb9sb9sd6qdbp2s-qtwebengine-dev NIX_OUTPUT_BIN=/nix/store/91hqv88qvg2wb91lv1h1pd4d8wwrkd5d-qtwebengine-bin NIX_OUTPUT_DOC=/nix/store/jngs3qilw9iiv97rawb9sb9sd6qdbp2s-qtwebengine-dev/share/doc/qt-5.14.2 NIX_OUTPUT_QML=/nix/store/91hqv88qvg2wb91lv1h1pd4d8wwrkd5d-qtwebengine-bin/lib/qt-5.14.2/qml NIX_OUTPUT_PLUGIN=/nix/store/91hqv88qvg2wb91lv1h1pd4d8wwrkd5d-qtwebengine-bin/lib/qt-5.14.2/plugins CONFIG+=release -- -system-ffmpeg -webengine-webrtc-pipewire -proprietary-codecs Info: creating stash file /build/qtwebengine-everywhere-src-5.14.2/.qmake.stash Info: creating cache file /build/qtwebengine-everywhere-src-5.14.2/.qmake.cache ERROR: Unknown command line option '-webengine-webrtc-pipewire'. builder for '/nix/store/g6dvr7789sswmahlxc6zs5pr8k2g5pgy-qtwebengine.drv' failed with exit code 3 ``` Also, only bring in pipewire_0_2 if we enable pipewire support.
2021-05-22 22:26:16 +00:00
] ++ optionals (stdenv.isLinux && (lib.versionAtLeast qtCompatVersion "5.15")) [
2021-05-19 17:14:38 +00:00
# Pipewire
pipewire_0_2
]
# FIXME These dependencies shouldn't be needed but can't find a way
# around it. Chromium pulls this in while bootstrapping GN.
++ lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
libobjc
cctools
# frameworks
ApplicationServices
AVFoundation
Foundation
ForceFeedback
GameController
AppKit
ImageCaptureCore
CoreBluetooth
IOBluetooth
CoreWLAN
Quartz
Cocoa
2020-08-19 12:55:11 +00:00
LocalAuthentication
openbsm
libunwind
]);
buildInputs = optionals stdenv.isDarwin (with darwin; [
cups
apple_sdk.libs.sandbox
2020-08-19 12:55:11 +00:00
# `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py`
# to get some information about the host platform.
(writeScriptBin "sw_vers" ''
#!${stdenv.shell}
while [ $# -gt 0 ]; do
case "$1" in
-buildVersion) echo "17E199";;
*) break ;;
esac
shift
done
'')
]);
dontUseNinjaBuild = true;
dontUseNinjaInstall = true;
dontUseXcbuild = true;
postInstall = lib.optionalString stdenv.isLinux ''
cat > $out/libexec/qt.conf <<EOF
[Paths]
Prefix = ..
EOF
'' + lib.optionalString (lib.versions.majorMinor qtCompatVersion == "5.15") ''
# Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3)
sed 's/${lib.head (lib.splitString "-" version)} /${qtCompatVersion} /' -i "$out"/lib/cmake/*/*Config.cmake
'';
requiredSystemFeatures = [ "big-parallel" ];
meta = with lib; {
description = "A web engine based on the Chromium web browser";
maintainers = with maintainers; [ matthewbauer ];
platforms = platforms.unix;
# This build takes a long time; particularly on slow architectures
timeout = 24 * 3600;
};
}