2020-11-09 20:36:08 +00:00
{ qtModule
, qtdeclarative , qtquickcontrols , qtlocation , qtwebchannel
2017-06-17 17:26:19 +01:00
, bison , coreutils , flex , git , gperf , ninja , pkgconfig , python2 , which
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
2017-06-17 17:26:19 +01:00
, zlib , minizip , libjpeg , libpng , libtiff , libwebp , libopus
, jsoncpp , protobuf , libvpx , srtp , snappy , nss , libevent
, alsaLib
, libcap
, pciutils
, systemd
, enableProprietaryCodecs ? true
2019-01-12 14:28:11 +00:00
, gn
2020-08-19 13:55:11 +01:00
, cups , darwin , openbsm , runCommand , xcbuild , writeScriptBin
2020-06-07 13:39:09 +01:00
, ffmpeg_3 ? null
2020-08-25 19:13:45 +01:00
, lib , stdenv , fetchpatch
2017-06-17 17:26:19 +01:00
} :
with stdenv . lib ;
2017-10-24 12:39:54 +01:00
qtModule {
2017-06-17 17:26:19 +01:00
name = " q t w e b e n g i n e " ;
2017-10-24 12:39:54 +01:00
qtInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ] ;
2017-06-17 17:26:19 +01:00
nativeBuildInputs = [
2018-04-25 05:18:35 +01:00
bison coreutils flex git gperf ninja pkgconfig python2 which gn
2019-01-12 14:28:11 +00:00
] ++ optional stdenv . isDarwin xcbuild ;
2017-06-17 17:26:19 +01:00
doCheck = true ;
2017-09-27 01:00:23 +01:00
outputs = [ " b i n " " d e v " " o u t " ] ;
2017-06-17 17:26:19 +01:00
enableParallelBuilding = true ;
2019-06-04 02:42:59 +01:00
# Don’ t use the gn setup hook
dontUseGnConfigure = true ;
2018-05-25 21:22:47 +01:00
# 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 " ] ;
2017-06-17 17:26:19 +01:00
postPatch =
# Patch Chromium build tools
''
( cd src/3rdparty/chromium ; patchShebangs . )
''
2020-08-19 13:55:11 +01: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 / " '
''
2017-06-17 17:26:19 +01: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-08-12 19:15:30 +01:00
sed - i - e ' /lib_loader. * Load/s ! " \( l i b u d e v \. s o \) ! " $ { lib . getLib systemd } /lib / \ 1 ! ' \
2017-06-17 17:26:19 +01: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
2018-04-25 05:18:35 +01:00
''
2019-01-12 14:28:11 +00:00
+ optionalString stdenv . isDarwin ( ''
2018-04-25 05:18:35 +01:00
substituteInPlace src/core/config/mac_osx.pri \
2020-08-19 13:55:11 +01:00
- - replace ' QMAKE_CLANG_DIR = " / u s r " ' ' QMAKE_CLANG_DIR = " ${ stdenv . cc } " '
2019-01-12 14:28:11 +00:00
''
2020-08-19 13:55:11 +01: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-09 20:36:08 +00:00
+ ''
2019-02-26 22:46:40 +00:00
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
- - replace ' $ sysroot/usr ' " ${ darwin . xnu } "
2020-11-09 20:36:08 +00:00
''
2019-01-12 14:28:11 +00:00
+ ''
2018-04-25 05:18:35 +01:00
# Apple has some secret stuff they don't share with OpenBSM
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 ] "
2017-06-17 17:26:19 +01:00
2019-01-12 14:28:11 +00:00
substituteInPlace src/3rdparty/chromium/sandbox/mac/BUILD.gn \
- - replace ' libs = [ " s a n d b o x " ] ' ' libs = [ " / u s r / l i b / l i b s a n d b o x . 1 . d y l i b " ] '
'' ) ;
2019-10-06 23:25:04 +01:00
NIX_CFLAGS_COMPILE = lib . optionals stdenv . cc . isGNU [
2019-09-15 23:19:21 +01: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 . platform . 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 . isDarwin [
2020-08-19 13:55:11 +01: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 "
2019-09-15 23:19:21 +01: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 "
] ;
2018-03-26 20:31:11 +01:00
2017-06-17 17:26:19 +01:00
preConfigure = ''
2018-03-26 20:31:11 +01:00
export NINJAFLAGS = - j $ NIX_BUILD_CORES
2017-10-24 12:39:54 +01:00
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
2018-04-25 05:18:35 +01:00
'' ;
2017-06-17 17:26:19 +01:00
2018-08-15 17:38:47 +01:00
qmakeFlags = if stdenv . hostPlatform . isAarch32 || stdenv . hostPlatform . isAarch64
then [ " - - " " - s y s t e m - f f m p e g " ] ++ optional enableProprietaryCodecs " - p r o p r i e t a r y - c o d e c s "
else optional enableProprietaryCodecs " - - - p r o p r i e t a r y - c o d e c s " ;
2017-06-17 17:26:19 +01:00
propagatedBuildInputs = [
# Image formats
libjpeg libpng libtiff libwebp
# Video formats
srtp libvpx
# Audio formats
libopus
# Text rendering
harfbuzz icu
2018-04-25 05:18:35 +01:00
libevent
2018-08-26 12:04:05 +01:00
] ++ optionals ( stdenv . hostPlatform . isAarch32 || stdenv . hostPlatform . isAarch64 ) [
2020-06-07 13:39:09 +01:00
ffmpeg_3
2018-04-25 05:18:35 +01:00
] ++ optionals ( ! stdenv . isDarwin ) [
dbus zlib minizip snappy nss protobuf jsoncpp
2017-06-17 17:26:19 +01:00
# Audio formats
alsaLib
# Text rendering
fontconfig freetype
libcap
pciutils
# X11 libs
2018-03-13 10:16:03 +00:00
xorg . xrandr libXScrnSaver libXcursor libXrandr xorg . libpciaccess libXtst
2018-03-18 16:28:14 +00:00
xorg . libXcomposite xorg . libXdamage libdrm
2018-04-25 05:18:35 +01: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
2019-01-12 14:28:11 +00:00
AVFoundation
2018-04-25 05:18:35 +01:00
Foundation
2019-01-12 14:28:11 +00:00
ForceFeedback
GameController
2018-04-25 05:18:35 +01:00
AppKit
ImageCaptureCore
CoreBluetooth
IOBluetooth
CoreWLAN
Quartz
Cocoa
2020-08-19 13:55:11 +01:00
LocalAuthentication
2018-04-25 05:18:35 +01:00
openbsm
libunwind
] ) ;
2017-08-27 18:42:21 +01:00
2019-01-12 14:28:11 +00:00
buildInputs = optionals stdenv . isDarwin ( with darwin ; [
2019-01-20 19:57:59 +00:00
cups
2020-08-19 13:55:11 +01: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
'' )
2019-01-12 14:28:11 +00:00
# For sandbox.h include
( runCommand " M a c O S _ S D K _ s a n d b o x . h " { } ''
install - Dm444 " ${ lib . getDev darwin . apple_sdk . sdk } " /include/sandbox.h " $ o u t " /include/sandbox.h
'' )
] ) ;
__impureHostDeps = optional stdenv . isDarwin " / u s r / l i b / l i b s a n d b o x . 1 . d y l i b " ;
2017-08-27 18:42:21 +01:00
dontUseNinjaBuild = true ;
dontUseNinjaInstall = true ;
2019-01-12 14:28:11 +00:00
dontUseXcbuild = true ;
2017-08-27 18:42:21 +01:00
2018-04-25 05:18:35 +01:00
postInstall = lib . optionalString stdenv . isLinux ''
2017-06-17 17:26:19 +01:00
cat > $ out/libexec/qt.conf < < EOF
[ Paths ]
Prefix = . .
EOF
'' ;
2018-04-25 05:18:35 +01: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 ;
} ;
2017-06-17 17:26:19 +01:00
}