2024-01-19 12:30:40 +00:00
{ qtModule
, qtdeclarative , qtquickcontrols , qtlocation , qtwebchannel
, bison , flex , git , gperf , ninja , pkg-config , python , which
, nodejs , qtbase , perl
, 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
, alsa-lib
, libcap
, pciutils
, systemd
, enableProprietaryCodecs ? true
, gn
, cctools , libobjc , libpm , libunwind , sandbox , xnu
, ApplicationServices , AVFoundation , Foundation , ForceFeedback , GameController , AppKit
, ImageCaptureCore , CoreBluetooth , IOBluetooth , CoreWLAN , Quartz , Cocoa , LocalAuthentication
, MediaPlayer , MediaAccessibility , SecurityInterface , Vision , CoreML
, cups , openbsm , runCommand , xcbuild , writeScriptBin
, ffmpeg_4 ? null
, lib , stdenv , fetchpatch
, version ? null
, qtCompatVersion
, pipewireSupport ? stdenv . isLinux
, pipewire_0_2
, postPatch ? " "
} :
qtModule {
pname = " q t w e b e n g i n e " ;
qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ] ;
nativeBuildInputs = [
bison flex git gperf ninja pkg-config python which gn nodejs
] ++ lib . 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 = ''
# 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 ) ''
2024-04-10 11:50:08 +00:00
#sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
# src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
2024-01-19 12:30:40 +00:00
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 ( ''
substituteInPlace src/buildtools/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
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 ] "
# 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'
# ld: fatal warning(s) induced error (-fatal_warnings)
substituteInPlace src/3rdparty/chromium/build/config/compiler/BUILD.gn \
- - replace " - W l , - f a t a l _ w a r n i n g s " " "
'' ) + p o s t P a t c h ;
2024-01-19 15:23:26 +00:00
NIX_CFLAGS_COMPILE = toString ( lib . optionals stdenv . cc . isGNU [
2024-01-19 12:30:40 +00:00
# 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 "
] ++ lib . optionals ( stdenv . hostPlatform . gcc . arch or " " == " s a n d y b r i d g e " ) [
# 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 . cc . isClang [
" - W n o - e l a b o r a t e d - e n u m - b a s e "
] ) ;
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
'' ;
qmakeFlags = [ " - - " " - s y s t e m - f f m p e g " ]
++ lib . optional pipewireSupport " - w e b e n g i n e - w e b r t c - p i p e w i r e "
++ lib . optional enableProprietaryCodecs " - p r o p r i e t a r y - c o d e c s " ;
propagatedBuildInputs = [
# Image formats
libjpeg libpng libtiff libwebp
# Video formats
srtp libvpx
# Audio formats
libopus
# Text rendering
harfbuzz icu
libevent
ffmpeg_4
] ++ lib . optionals ( ! stdenv . isDarwin ) [
dbus zlib minizip snappy nss protobuf jsoncpp
# Audio formats
alsa-lib
# Text rendering
fontconfig freetype
libcap
pciutils
# X11 libs
xorg . xrandr libXScrnSaver libXcursor libXrandr xorg . libpciaccess libXtst
xorg . libXcomposite xorg . libXdamage libdrm xorg . libxkbfile
] ++ lib . optionals pipewireSupport [
# 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 [
libobjc
cctools
# frameworks
ApplicationServices
AVFoundation
Foundation
ForceFeedback
GameController
AppKit
ImageCaptureCore
CoreBluetooth
IOBluetooth
CoreWLAN
Quartz
Cocoa
LocalAuthentication
MediaPlayer
MediaAccessibility
SecurityInterface
Vision
CoreML
openbsm
libunwind
] ;
buildInputs = lib . optionals stdenv . isDarwin [
cups
libpm
sandbox
# `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
'' )
] ;
dontUseNinjaBuild = true ;
dontUseNinjaInstall = true ;
postInstall = lib . optionalString stdenv . isLinux ''
cat > $ out/libexec/qt.conf < < EOF
[ Paths ]
Prefix = . .
EOF
'' + ''
# 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
'' ;
requiredSystemFeatures = [ " b i g - p a r a l l e l " ] ;
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 ] ;
# 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 ) )
] ;
broken = stdenv . isDarwin && stdenv . isx86_64 ;
# This build takes a long time; particularly on slow architectures
timeout = 24 * 3600 ;
} ;
}