2020-11-15 13:44:38 +00:00
{ qtModule
, qtdeclarative , qtquickcontrols , qtlocation , qtwebchannel
2020-04-24 23:36:52 +00:00
2022-11-27 09:42:12 +00:00
, bison , flex , git , gperf , ninja , pkg-config , python , which
2021-03-20 04:20:00 +00:00
, nodejs , qtbase , perl
2020-04-24 23:36:52 +00:00
, xorg , libXcursor , libXScrnSaver , libXrandr , libXtst
, fontconfig , freetype , harfbuzz , icu , dbus , libdrm
, zlib , minizip , libjpeg , libpng , libtiff , libwebp , libopus
, jsoncpp , protobuf , libvpx , srtp , snappy , nss , libevent
2021-06-28 23:13:55 +00:00
, alsa-lib
2020-04-24 23:36:52 +00:00
, libcap
, pciutils
, systemd
, enableProprietaryCodecs ? true
, gn
2021-08-22 07:53:02 +00:00
, cctools , libobjc , libunwind , sandbox , xnu
, ApplicationServices , AVFoundation , Foundation , ForceFeedback , GameController , AppKit
, ImageCaptureCore , CoreBluetooth , IOBluetooth , CoreWLAN , Quartz , Cocoa , LocalAuthentication
, cups , openbsm , runCommand , xcbuild , writeScriptBin
2022-02-10 20:34:41 +00:00
, ffmpeg_4 ? null
2020-09-25 04:45:31 +00:00
, lib , stdenv , fetchpatch
2021-04-05 15:23:46 +00:00
, version ? null
2021-02-05 17:12:51 +00:00
, qtCompatVersion
2022-04-15 01:41:22 +00:00
, pipewireSupport ? stdenv . isLinux
, pipewire_0_2
2022-11-27 09:42:12 +00:00
, postPatch ? " "
2020-04-24 23:36:52 +00:00
} :
qtModule {
2021-05-28 09:39:13 +00:00
pname = " q t w e b e n g i n e " ;
2020-04-24 23:36:52 +00:00
qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ] ;
nativeBuildInputs = [
2022-11-27 09:42:12 +00:00
bison flex git gperf ninja pkg-config python which gn nodejs
2021-08-22 07:53:02 +00:00
] ++ lib . optional stdenv . isDarwin xcbuild ;
2020-04-24 23:36:52 +00:00
doCheck = true ;
outputs = [ " b i n " " d e v " " o u t " ] ;
enableParallelBuilding = true ;
# Don’ t 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 = [ " f o r m a t " ] ;
2021-08-22 07:53:02 +00:00
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 " / u s r / b i n / e n v - S m a k e - f " " / u s r / b i n / m a k e - f " || true
# TODO: be more precise
patchShebangs .
)
''
# 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`.
+ lib . optionalString stdenv . isDarwin ''
substituteInPlace ./src/3rdparty/chromium/build/toolchain/mac/BUILD.gn \
- - replace ' prefix = rebase_path ( " $ c l a n g _ b a s e _ p a t h / b i n / " , root_build_dir ) ' ' prefix = " $ c l a n g _ b a s e _ p a t h / b i n / " '
''
# Patch library paths in Qt sources
+ ''
sed - i \
- e " s , Q L i b r a r y I n f o : : l o c a t i o n ( Q L i b r a r y I n f o : : D a t a P a t h ) , Q L a t i n 1 S t r i n g ( \" $ o u t \" ) , g " \
- e " s , Q L i b r a r y I n f o : : l o c a t i o n ( Q L i b r a r y I n f o : : T r a n s l a t i o n s P a t h ) , Q L a t i n 1 S t r i n g ( \" $ o u t / t r a n s l a t i o n s \" ) , g " \
- e " s , Q L i b r a r y I n f o : : l o c a t i o n ( Q L i b r a r y I n f o : : L i b r a r y E x e c u t a b l e s P a t h ) , Q L a t i n 1 S t r i n g ( \" $ o u t / l i b e x e c \" ) , g " \
src/core/web_engine_library_info.cpp
''
# Patch library paths in Chromium sources
+ lib . optionalString ( ! stdenv . isDarwin ) ''
sed - i - e ' /lib_loader. * Load/s ! " \( l i b u d e v \. s o \) ! " $ { lib . getLib systemd } /lib / \ 1 ! ' \
src/3rdparty/chromium/device/udev_linux/udev ? _loader . cc
sed - i - e ' /libpci_loader. * Load/s ! " \( l i b p c i \. s o \) ! " $ { pciutils } /lib / \ 1 ! ' \
src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
'' + l i b . o p t i o n a l S t r i n g s t d e n v . i s D a r w i n (
( if ( lib . versionAtLeast qtCompatVersion " 5 . 1 4 " ) then ''
substituteInPlace src/buildtools/config/mac_osx.pri \
- - replace ' QMAKE_CLANG_DIR = " / u s r " ' ' QMAKE_CLANG_DIR = " ${ stdenv . cc } " '
'' e l s e ''
substituteInPlace src/core/config/mac_osx.pri \
- - replace ' QMAKE_CLANG_DIR = " / u s r " ' ' QMAKE_CLANG_DIR = " ${ stdenv . cc } " '
'' )
# 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 ' " ${ xnu } "
''
# Apple has some secret stuff they don't share with OpenBSM
+ ( if ( lib . versionAtLeast qtCompatVersion " 5 . 1 4 " ) then ''
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_rendezvous.cc \
- - replace " a u d i t _ t o k e n _ t o _ p i d ( r e q u e s t . t r a i l e r . m s g h _ a u d i t ) " " r e q u e s t . t r a i l e r . m s g h _ a u d i t . v a l [ 5 ] "
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/mach/mach_message.cc \
- - replace " a u d i t _ t o k e n _ t o _ p i d ( a u d i t _ t r a i l e r - > m s g h _ a u d i t ) " " a u d i t _ t r a i l e r - > m s g h _ a u d i t . v a l [ 5 ] "
'' e l s e ''
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_broker.mm \
- - replace " a u d i t _ t o k e n _ t o _ p i d ( m s g . t r a i l e r . m s g h _ a u d i t ) " " m s g . t r a i l e r . m s g h _ a u d i t . v a l [ 5 ] "
2022-11-27 09:42:12 +00:00
'' ) ) + p o s t P a t c h ;
2020-04-24 23:36:52 +00:00
NIX_CFLAGS_COMPILE = lib . optionals stdenv . cc . isGNU [
# with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
" - W n o - c l a s s - m e m a c c e s s "
2021-02-05 17:12:51 +00:00
] ++ lib . optionals ( stdenv . hostPlatform . gcc . arch or " " == " s a n d y b r i d g e " ) [
2020-04-24 23:36:52 +00:00
# it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
# TODO: investigate and fix properly
" - m a r c h = w e s t m e r e "
2021-12-26 17:43:05 +00:00
] ++ lib . optionals stdenv . cc . isClang [
" - W n o - e l a b o r a t e d - e n u m - b a s e "
2020-04-24 23:36:52 +00:00
] ++ lib . optionals stdenv . isDarwin [
2020-09-25 04:45:31 +00:00
" - D M A C _ O S _ X _ V E R S I O N _ M A X _ A L L O W E D = M A C _ O S _ X _ V E R S I O N _ 1 0 _ 1 2 "
" - D M A C _ O S _ X _ V E R S I O N _ M I N _ R E Q U I R E D = M A C _ O S _ X _ V E R S I O N _ 1 0 _ 1 2 "
2022-02-10 20:34:41 +00:00
" - W n o - e l a b o r a t e d - e n u m - b a s e "
2020-04-24 23:36:52 +00:00
#
# 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
#
" - f n o - o b j c - a r c "
] ;
preConfigure = ''
export NINJAFLAGS = - j $ NIX_BUILD_CORES
if [ - d " $ P W D / t o o l s / q m a k e " ] ; then
QMAKEPATH = " $ P W D / t o o l s / q m a k e ' ' ${ QMAKEPATH:+: } $ Q M A K E P A T H "
fi
2021-03-20 04:20:00 +00:00
'' ;
2020-04-24 23:36:52 +00:00
2021-05-20 23:08:51 +00:00
qmakeFlags = [ " - - " " - s y s t e m - f f m p e g " ]
2022-04-15 01:41:22 +00:00
++ lib . optional ( pipewireSupport && ( lib . versionAtLeast qtCompatVersion " 5 . 1 5 " ) ) " - w e b e n g i n e - w e b r t c - p i p e w i r e "
2021-08-22 07:53:02 +00:00
++ lib . optional enableProprietaryCodecs " - p r o p r i e t a r y - c o d e c s " ;
2020-04-24 23:36:52 +00:00
propagatedBuildInputs = [
# Image formats
libjpeg libpng libtiff libwebp
# Video formats
srtp libvpx
# Audio formats
libopus
# Text rendering
harfbuzz icu
libevent
2022-02-10 20:34:41 +00:00
ffmpeg_4
2021-08-22 07:53:02 +00:00
] ++ lib . optionals ( ! stdenv . isDarwin ) [
2020-04-24 23:36:52 +00:00
dbus zlib minizip snappy nss protobuf jsoncpp
# Audio formats
2021-06-28 23:13:55 +00:00
alsa-lib
2020-04-24 23:36:52 +00:00
# Text rendering
fontconfig freetype
libcap
pciutils
# X11 libs
xorg . xrandr libXScrnSaver libXcursor libXrandr xorg . libpciaccess libXtst
2021-08-05 21:33:18 +00:00
xorg . libXcomposite xorg . libXdamage libdrm xorg . libxkbfile
2021-05-28 09:39:13 +00:00
2022-04-15 01:41:22 +00:00
] ++ lib . optionals ( pipewireSupport && ( lib . versionAtLeast qtCompatVersion " 5 . 1 5 " ) ) [
2021-05-28 09:39:13 +00:00
# Pipewire
pipewire_0_2
2020-04-24 23:36:52 +00:00
]
# FIXME These dependencies shouldn't be needed but can't find a way
# around it. Chromium pulls this in while bootstrapping GN.
2021-08-22 07:53:02 +00:00
++ lib . optionals stdenv . isDarwin [
2020-04-24 23:36:52 +00:00
libobjc
cctools
# frameworks
ApplicationServices
AVFoundation
Foundation
ForceFeedback
GameController
AppKit
ImageCaptureCore
CoreBluetooth
IOBluetooth
CoreWLAN
Quartz
Cocoa
2020-09-25 04:45:31 +00:00
LocalAuthentication
2020-04-24 23:36:52 +00:00
openbsm
libunwind
2021-08-22 07:53:02 +00:00
] ;
2020-04-24 23:36:52 +00:00
2021-08-22 07:53:02 +00:00
buildInputs = lib . optionals stdenv . isDarwin [
2020-04-24 23:36:52 +00:00
cups
2021-08-22 07:53:02 +00:00
sandbox
2020-04-24 23:36:52 +00:00
2020-09-25 04:45:31 +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 " s w _ v e r s " ''
#!${stdenv.shell}
while [ $ # -gt 0 ]; do
case " $ 1 " in
- buildVersion ) echo " 1 7 E 1 9 9 " ; ;
* ) break ; ;
esac
shift
done
'' )
2021-08-22 07:53:02 +00:00
] ;
2020-04-24 23:36:52 +00:00
dontUseNinjaBuild = true ;
dontUseNinjaInstall = true ;
postInstall = lib . optionalString stdenv . isLinux ''
cat > $ out/libexec/qt.conf < < EOF
[ Paths ]
Prefix = . .
EOF
2021-04-05 15:23:46 +00:00
'' + l i b . o p t i o n a l S t r i n g ( l i b . v e r s i o n s . m a j o r M i n o r q t C o m p a t V e r s i o n = = " 5 . 1 5 " ) ''
# Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3)
sed ' s / $ { lib . head ( lib . splitString " - " version ) } / $ { qtCompatVersion } / ' - i " $ o u t " /lib/cmake /* / * C o n f i g . c m a k e
2020-04-24 23:36:52 +00:00
'' ;
2021-04-26 19:14:03 +00:00
requiredSystemFeatures = [ " b i g - p a r a l l e l " ] ;
2020-04-24 23:36:52 +00:00
meta = with lib ; {
description = " A w e b e n g i n e b a s e d o n t h e C h r o m i u m w e b b r o w s e r " ;
maintainers = with maintainers ; [ matthewbauer ] ;
2022-04-27 09:35:20 +00:00
# qtwebengine-5.15.8: "QtWebEngine can only be built for x86,
# x86-64, ARM, Aarch64, and MIPSel architectures."
platforms =
lib . trivial . pipe lib . systems . doubles . all [
( map ( double : lib . systems . elaborate { system = double ; } ) )
( lib . lists . filter ( parsedPlatform : with parsedPlatform ;
isUnix &&
( isx86_32 ||
isx86_64 ||
isAarch32 ||
isAarch64 ||
( isMips && isLittleEndian ) ) ) )
( map ( plat : plat . system ) )
] ;
2021-02-17 17:02:09 +00:00
# This build takes a long time; particularly on slow architectures
timeout = 24 * 3600 ;
2021-12-26 17:43:05 +00:00
# we are still stuck with MacOS SDK 10.12 on x86_64-darwin
# and qtwebengine 5.14+ requires at least SDK 10.14
# (qtwebengine 5.12 is fine with SDK 10.12)
# on aarch64-darwin we are already at MacOS SDK 11.0
2022-10-30 15:09:59 +00:00
broken = stdenv . isDarwin ;
2020-04-24 23:36:52 +00:00
} ;
}