2020-11-15 13:44:38 +00:00
{ qtModule
, qtdeclarative , qtquickcontrols , qtlocation , qtwebchannel
2020-04-24 23:36:52 +00:00
2024-06-20 14:57:18 +00:00
, bison , flex , git , gperf , ninja , pkg-config , python , which
, nodejs , perl
2023-11-16 04:20:00 +00:00
, buildPackages
, pkgsBuildTarget
, pkgsBuildBuild
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
2023-08-22 20:05:09 +00:00
, pulseaudio
2020-04-24 23:36:52 +00:00
, libcap
, pciutils
, systemd
, enableProprietaryCodecs ? true
, gn
2023-02-02 18:25:31 +00:00
, cctools , libobjc , libpm , libunwind , sandbox , xnu
2021-08-22 07:53:02 +00:00
, ApplicationServices , AVFoundation , Foundation , ForceFeedback , GameController , AppKit
, ImageCaptureCore , CoreBluetooth , IOBluetooth , CoreWLAN , Quartz , Cocoa , LocalAuthentication
2023-04-29 16:46:19 +00:00
, MediaPlayer , MediaAccessibility , SecurityInterface , Vision , CoreML , OpenDirectory , Accelerate
2024-06-20 14:57:18 +00:00
, cups , openbsm , xcbuild , writeScriptBin
2022-02-10 20:34:41 +00:00
, ffmpeg_4 ? null
2024-06-05 15:53:02 +00:00
, lib , stdenv
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 ? " "
2023-11-16 04:20:00 +00:00
, nspr
, lndir
2020-04-24 23:36:52 +00:00
} :
2023-11-16 04:20:00 +00:00
let
# qtwebengine expects to find an executable in $PATH which runs on
# the build platform yet knows about the host `.pc` files. Most
# configury allows setting $PKG_CONFIG to point to an
# arbitrarily-named script which serves this purpose; however QT
# insists that it is named `pkg-config` with no target prefix. So
# we re-wrap the host platform's pkg-config.
pkg-config-wrapped-without-prefix = stdenv . mkDerivation {
name = " p k g - c o n f i g - w r a p p e r - w i t h o u t - t a r g e t - p r e f i x " ;
dontUnpack = true ;
dontBuild = true ;
installPhase = ''
mkdir - p $ out/bin
ln - s ' $ { buildPackages . pkg-config } /bin / $ { buildPackages . pkg-config . targetPrefix } pkg-config' $ out/bin/pkg-config
'' ;
} ;
in
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
nativeBuildInputs = [
2024-06-20 14:57:18 +00:00
bison flex git gperf ninja pkg-config ( python . withPackages ( ps : [ ps . html5lib ] ) ) which gn nodejs
2023-11-16 04:20:00 +00:00
] ++ lib . optionals ( stdenv . buildPlatform != stdenv . hostPlatform ) [
perl
lndir ( lib . getDev pkgsBuildTarget . targetPackages . qt5 . qtbase )
pkgsBuildBuild . pkg-config
( lib . getDev pkgsBuildTarget . targetPackages . qt5 . qtquickcontrols )
pkg-config-wrapped-without-prefix
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
2023-01-20 10:41:00 +00:00
'' + 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 ( ''
2021-08-22 07:53:02 +00:00
substituteInPlace src/buildtools/config/mac_osx.pri \
- - replace ' QMAKE_CLANG_DIR = " / u s r " ' ' QMAKE_CLANG_DIR = " ${ stdenv . cc } " '
2023-01-20 10:41:00 +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
2021-08-22 07:53:02 +00:00
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
- - replace ' $ sysroot/usr ' " ${ xnu } "
2023-01-20 10:41:00 +00:00
# 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 ] "
2023-02-02 18:25:31 +00:00
# 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 " " "
2023-01-20 10:41:00 +00:00
'' ) + p o s t P a t c h ;
2020-04-24 23:36:52 +00:00
2023-11-16 04:20:00 +00:00
env = {
NIX_CFLAGS_COMPILE =
toString (
lib . optionals ( stdenv . buildPlatform != stdenv . hostPlatform ) [
" - w "
] ++ 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 "
] ++ 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 "
] ) ;
} // lib . optionalAttrs ( stdenv . buildPlatform != stdenv . hostPlatform ) {
NIX_CFLAGS_LINK = " - W l , - - n o - w a r n - s e a r c h - m i s m a t c h " ;
" N I X _ C F L A G S _ L I N K _ ${ buildPackages . stdenv . cc . suffixSalt } " = " - W l , - - n o - w a r n - s e a r c h - m i s m a t c h " ;
} ;
2020-04-24 23:36:52 +00:00
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
2023-11-16 04:20:00 +00:00
'' + l i b . o p t i o n a l S t r i n g ( s t d e n v . h o s t P l a t f o r m ! = s t d e n v . b u i l d P l a t f o r m ) ''
export QMAKE_CC = $ CC
export QMAKE_CXX = $ CXX
export QMAKE_LINK = $ CXX
export QMAKE_AR = $ AR
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 " ]
2023-11-16 04:20:00 +00:00
++ lib . optional ( pipewireSupport && stdenv . buildPlatform == stdenv . hostPlatform ) " - 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 = [
2023-11-16 04:20:00 +00:00
qtdeclarative qtquickcontrols qtlocation qtwebchannel
2020-04-24 23:36:52 +00:00
# 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
2023-08-22 20:05:09 +00:00
pulseaudio
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
2023-01-20 10:41:00 +00:00
] ++ lib . optionals pipewireSupport [
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
2023-02-02 18:25:31 +00:00
MediaPlayer
MediaAccessibility
SecurityInterface
Vision
CoreML
2023-04-29 16:46:19 +00:00
OpenDirectory
Accelerate
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
2023-02-02 18:25:31 +00:00
libpm
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 ;
2023-11-16 04:20:00 +00:00
postInstall = lib . optionalString ( stdenv . buildPlatform != stdenv . hostPlatform ) ''
mkdir - p $ out/libexec
'' + 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 L i n u x ''
2020-04-24 23:36:52 +00:00
cat > $ out/libexec/qt.conf < < EOF
[ Paths ]
Prefix = . .
EOF
2023-01-20 10:41:00 +00:00
2023-03-24 00:07:29 +00:00
'' + ''
2021-04-05 15:23:46 +00:00
# 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 ; {
2024-06-20 14:57:18 +00:00
description = " 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 " ;
2024-04-21 15:54:59 +00:00
mainProgram = " q w e b e n g i n e _ c o n v e r t _ d i c t " ;
2020-04-24 23:36:52 +00:00
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."
2023-11-16 04:20:00 +00:00
platforms = with lib . systems . inspect . patterns ;
let inherit ( lib . systems . inspect ) patternLogicalAnd ;
in concatMap ( patternLogicalAnd isUnix ) ( lib . concatMap lib . toList [
isx86_32
isx86_64
isAarch32
isAarch64
( patternLogicalAnd isMips isLittleEndian )
] ) ;
2022-04-27 09:35:20 +00:00
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
} ;
2023-11-16 04:20:00 +00:00
} // lib . optionalAttrs ( stdenv . buildPlatform != stdenv . hostPlatform ) {
configurePlatforms = [ ] ;
# to get progress output in `nix-build` and `nix build -L`
preBuild = ''
export TERM = dumb
'' ;
depsBuildBuild = [
pkgsBuildBuild . stdenv
zlib
nss
nspr
] ;
} )