2020-11-15 13:44:38 +00:00
{ qtModule
, qtdeclarative , qtquickcontrols , qtlocation , qtwebchannel
2020-04-24 23:36:52 +00:00
2021-02-05 17:12:51 +00:00
, bison , coreutils , flex , git , gperf , ninja , pkg-config , python2 , 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
, alsaLib
, libcap
, pciutils
, systemd
2021-05-28 09:39:13 +00:00
, pipewire_0_2
2020-04-24 23:36:52 +00:00
, enableProprietaryCodecs ? true
, gn
2020-09-25 04:45:31 +00:00
, cups , darwin , openbsm , runCommand , xcbuild , writeScriptBin
2021-05-20 23:08:51 +00:00
, ffmpeg ? 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
2020-04-24 23:36:52 +00:00
} :
2021-02-05 17:12:51 +00:00
with lib ;
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 = [
2021-03-20 04:20:00 +00:00
bison coreutils flex git gperf ninja pkg-config python2 which gn nodejs
2020-04-24 23:36:52 +00:00
] ++ optional stdenv . isDarwin xcbuild ;
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 " ] ;
postPatch =
''
2021-03-20 04:20:00 +00:00
# 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
patchShebangs .
)
2020-04-24 23:36:52 +00:00
''
2020-09-25 04:45:31 +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 ( " $ 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 / " '
''
2020-04-24 23:36:52 +00:00
# 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
+ optionalString ( ! stdenv . isDarwin ) ''
2020-09-25 04:45:31 +00:00
sed - i - e ' /lib_loader. * Load/s ! " \( l i b u d e v \. s o \) ! " $ { lib . getLib systemd } /lib / \ 1 ! ' \
2020-04-24 23:36:52 +00:00
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
''
2021-02-05 17:12:51 +00:00
+ optionalString stdenv . isDarwin (
( 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 ''
2020-04-24 23:36:52 +00:00
substituteInPlace src/core/config/mac_osx.pri \
2020-09-25 04:45:31 +00:00
- - replace ' QMAKE_CLANG_DIR = " / u s r " ' ' QMAKE_CLANG_DIR = " ${ stdenv . cc } " '
2021-02-05 17:12:51 +00:00
'' )
2020-09-25 04:45:31 +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
2020-11-15 13:44:38 +00:00
+ ''
2020-04-24 23:36:52 +00:00
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
- - replace ' $ sysroot/usr ' " ${ darwin . xnu } "
2020-11-15 13:44:38 +00:00
''
2020-04-24 23:36:52 +00:00
# Apple has some secret stuff they don't share with OpenBSM
2021-02-05 17:12:51 +00:00
+ ( 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 ''
2020-04-24 23:36:52 +00:00
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 ] "
2021-03-23 19:22:30 +00:00
'' ) ) ;
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 "
] ++ 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 "
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 " ]
2021-05-28 09:39:13 +00:00
++ optional ( stdenv . isLinux && ( 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-05-20 23:08:51 +00:00
++ 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
2021-05-20 23:08:51 +00:00
ffmpeg
2020-04-24 23:36:52 +00:00
] ++ optionals ( ! stdenv . isDarwin ) [
dbus zlib minizip snappy nss protobuf jsoncpp
# Audio formats
alsaLib
# Text rendering
fontconfig freetype
libcap
pciutils
# X11 libs
xorg . xrandr libXScrnSaver libXcursor libXrandr xorg . libpciaccess libXtst
xorg . libXcomposite xorg . libXdamage libdrm
2021-05-28 09:39:13 +00:00
] ++ optionals ( stdenv . isLinux && ( lib . versionAtLeast qtCompatVersion " 5 . 1 5 " ) ) [
# 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.
++ 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-09-25 04:45:31 +00:00
LocalAuthentication
2020-04-24 23:36:52 +00:00
openbsm
libunwind
] ) ;
buildInputs = optionals stdenv . isDarwin ( with darwin ; [
cups
2021-03-23 19:22:30 +00:00
apple_sdk . libs . 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
'' )
2020-04-24 23:36:52 +00:00
] ) ;
dontUseNinjaBuild = true ;
dontUseNinjaInstall = true ;
dontUseXcbuild = 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 ] ;
platforms = platforms . unix ;
2021-02-17 17:02:09 +00:00
# This build takes a long time; particularly on slow architectures
timeout = 24 * 3600 ;
2020-04-24 23:36:52 +00:00
} ;
}