qt5: remove remaining version checks

This commit is contained in:
K900 2023-01-10 19:22:30 +03:00
parent 5802c30687
commit 7c8ab8cb3b
4 changed files with 42 additions and 102 deletions

View file

@ -9,7 +9,7 @@
, dbus, fontconfig, freetype, glib, harfbuzz, icu, libdrm, libX11, libXcomposite
, libXcursor, libXext, libXi, libXrender, libinput, libjpeg, libpng , libxcb
, libxkbcommon, libxml2, libxslt, openssl, pcre16, pcre2, sqlite, udev, xcbutil
, libxkbcommon, libxml2, libxslt, openssl, pcre2, sqlite, udev, xcbutil
, xcbutilimage, xcbutilkeysyms, xcbutilrenderutil, xcbutilwm , zlib, at-spi2-core
# optional dependencies
@ -27,8 +27,6 @@
}:
let
compareVersion = v: builtins.compareVersions version v;
qmakeCacheName = if compareVersion "5.12.4" < 0 then ".qmake.cache" else ".qmake.stash";
debugSymbols = debug || developerBuild;
in
@ -45,7 +43,7 @@ stdenv.mkDerivation {
# Image formats
libjpeg libpng
(if compareVersion "5.9.0" < 0 then pcre16 else pcre2)
pcre2
] ++ (
if stdenv.isDarwin then [
# TODO: move to buildInputs, this should not be propagated.
@ -116,7 +114,7 @@ stdenv.mkDerivation {
# https://bugs.gentoo.org/803470
sed -i 's/-lpthread/-pthread/' mkspecs/common/linux.conf src/corelib/configure.json
'' + lib.optionalString (compareVersion "5.15.0" >= 0) ''
patchShebangs ./bin
'' + (
if stdenv.isDarwin then ''
@ -146,22 +144,18 @@ stdenv.mkDerivation {
setOutputFlags = false;
preConfigure = ''
export LD_LIBRARY_PATH="$PWD/lib:$PWD/plugins/platforms''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
${lib.optionalString (compareVersion "5.9.0" < 0) ''
# We need to set LD to CXX or otherwise we get nasty compile errors
export LD=$CXX
''}
NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
# paralellize compilation of qtmake, which happens within ./configure
export MAKEFLAGS+=" -j$NIX_BUILD_CORES"
'' + lib.optionalString (compareVersion "5.15.0" >= 0) ''
./bin/syncqt.pl -version $version
'';
postConfigure = ''
qmakeCacheInjectNixOutputs() {
local cache="$1/${qmakeCacheName}"
local cache="$1/.qmake.stash"
echo "qmakeCacheInjectNixOutputs: $cache"
if ! [ -f "$cache" ]; then
echo >&2 "qmakeCacheInjectNixOutputs: WARNING: $cache does not exist"
@ -184,7 +178,7 @@ stdenv.mkDerivation {
NIX_CFLAGS_COMPILE = toString ([
"-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields
''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"''
''-D${if compareVersion "5.11.0" >= 0 then "LIBRESOLV_SO" else "NIXPKGS_LIBRESOLV"}="${stdenv.cc.libc.out}/lib/libresolv"''
''-DLIBRESOLV_SO="${stdenv.cc.libc.out}/lib/libresolv"''
''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"''
] ++ lib.optional libGLSupported ''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"''
++ lib.optional stdenv.isLinux "-DUSE_X11"
@ -192,14 +186,10 @@ stdenv.mkDerivation {
# ignore "is only available on macOS 10.12.2 or newer" in obj-c code
"-Wno-error=unguarded-availability"
]
++ lib.optionals ((compareVersion "5.15.0" >= 0) && stdenv.isDarwin) [
# .moc/moc_qprintdialog.cpp:96:31: error: no member named '_q_togglePageSetCombo' in 'QPrintDialogPrivate'
"-DQ_OS_MAC"
] ++ lib.optionals withGtk3 [
++ lib.optionals withGtk3 [
''-DNIXPKGS_QGTK3_XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}"''
''-DNIXPKGS_QGTK3_GIO_EXTRA_MODULES="${dconf.lib}/lib/gio/modules"''
]
++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC");
] ++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC");
prefixKey = "-prefix ";
@ -233,18 +223,14 @@ stdenv.mkDerivation {
"-L" "${icu.out}/lib"
"-I" "${icu.dev}/include"
"-pch"
] ++ lib.optional debugSymbols "-debug"
++ lib.optionals (compareVersion "5.11.0" < 0) [
"-qml-debug"
] ++ lib.optionals (compareVersion "5.9.0" < 0) [
"-c++11"
"-no-reduce-relocations"
] ++ lib.optionals developerBuild [
]
++ lib.optional debugSymbols "-debug"
++ lib.optionals developerBuild [
"-developer-build"
"-no-warnings-are-errors"
] ++ (if (!stdenv.hostPlatform.isx86_64) then [
"-no-sse2"
] else lib.optionals (compareVersion "5.9.0" >= 0) [
] else [
"-sse2"
"${lib.optionalString (!stdenv.hostPlatform.sse3Support) "-no"}-sse3"
"${lib.optionalString (!stdenv.hostPlatform.ssse3Support) "-no"}-ssse3"
@ -278,7 +264,7 @@ stdenv.mkDerivation {
"-make tools"
''-${lib.optionalString (!buildExamples) "no"}make examples''
''-${lib.optionalString (!buildTests) "no"}make tests''
] ++ lib.optional (compareVersion "5.15.0" < 0) "-v"
]
++ (
if stdenv.isDarwin then [
"-no-fontconfig"
@ -286,9 +272,8 @@ stdenv.mkDerivation {
"-qt-libpng"
"-no-framework"
] else [
"-${lib.optionalString (compareVersion "5.9.0" < 0) "no-"}rpath"
] ++ lib.optional (compareVersion "5.15.0" < 0) "-system-xcb"
++ [
"-rpath"
] ++ [
"-xcb"
"-qpa xcb"
"-L" "${libX11.out}/lib"
@ -303,20 +288,11 @@ stdenv.mkDerivation {
''-${lib.optionalString (cups == null) "no-"}cups''
"-dbus-linked"
"-glib"
] ++ lib.optional (compareVersion "5.15.0" < 0) "-system-libjpeg"
++ [
] ++ [
"-system-libpng"
] ++ lib.optional withGtk3 "-gtk"
++ lib.optional (compareVersion "5.9.0" >= 0) "-inotify"
++ lib.optionals (compareVersion "5.10.0" >= 0) [
# Without these, Qt stops working on kernels < 3.17. See:
# https://github.com/NixOS/nixpkgs/issues/38832
"-no-feature-renameat2"
"-no-feature-getentropy"
] ++ lib.optionals (compareVersion "5.12.1" < 0) [
# use -xkbcommon and -xkbcommon-evdev for versions before 5.12.1
"-system-xkbcommon"
"-xkbcommon-evdev"
++ [
"-inotify"
] ++ lib.optionals (cups != null) [
"-L" "${cups.lib}/lib"
"-I" "${cups.dev}/include"
@ -368,12 +344,6 @@ stdenv.mkDerivation {
license = with licenses; [ fdl13Plus gpl2Plus lgpl21Plus lgpl3Plus ];
maintainers = with maintainers; [ qknight ttuegel periklis bkchr ];
platforms = platforms.unix;
# Qt5 is broken on aarch64-darwin
# the build ends up with the following error:
# error: unknown target CPU 'armv8.3-a+crypto+sha2+aes+crc+fp16+lse+simd+ras+rdm+rcpc'
# note: valid target CPU values are: nocona, core2, penryn, ..., znver1, znver2, x86-64
# it seems the qmake/cmake passes x86_64 as preferred architecture somewhere
broken = stdenv.isDarwin && stdenv.isAarch64 && (compareVersion "5.15.3" < 0);
};
}

View file

@ -11,14 +11,14 @@ qtModule {
# wrapped executables from `wrapQtAppsHook` (see comment in patch for further
# context). Beware: shared among different Qt5 versions.
./qtwayland-app_id.patch
] ++ lib.optional (lib.versionAtLeast qtbase.version "5.15")
# Backport of https://codereview.qt-project.org/c/qt/qtwayland/+/388338
# Pulled from Fedora as they modified it to not apply to KDE as Plasma 5.x
# doesn't behave properly with the patch applied. See the discussion at
# https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/39 for details
# This patch won't apply to versions before 5.15.
(fetchpatch {
url = "https://src.fedoraproject.org/rpms/qt5-qtwayland/raw/46376bb00d4c3dd3db2e82ad7ca5301ce16ea4ab/f/0080-Client-set-constraint-adjustments-for-popups-in-xdg.patch";
sha256 = "sha256-XP+noYCk8fUdA0ItCqMjV7lSXDlNdB7Az9q7NRpupHc=";
});
})
];
}

View file

@ -80,30 +80,21 @@ qtModule {
sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
'' + lib.optionalString stdenv.isDarwin (
(if (lib.versionAtLeast qtCompatVersion "5.14") then ''
'' + lib.optionalString stdenv.isDarwin (''
substituteInPlace src/buildtools/config/mac_osx.pri \
--replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'
'' else ''
substituteInPlace src/core/config/mac_osx.pri \
--replace 'QMAKE_CLANG_DIR = "/usr"' '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.14") then ''
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_rendezvous.cc \
--replace "audit_token_to_pid(request.trailer.msgh_audit)" "request.trailer.msgh_audit.val[5]"
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/mach/mach_message.cc \
--replace "audit_token_to_pid(audit_trailer->msgh_audit)" "audit_trailer->msgh_audit.val[5]"
'' else ''
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_broker.mm \
--replace "audit_token_to_pid(msg.trailer.msgh_audit)" "msg.trailer.msgh_audit.val[5]"
'')) + postPatch;
'') + postPatch;
NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [
# with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
@ -115,8 +106,6 @@ qtModule {
] ++ lib.optionals stdenv.cc.isClang [
"-Wno-elaborated-enum-base"
] ++ lib.optionals stdenv.isDarwin [
"-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_12"
"-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_12"
"-Wno-elaborated-enum-base"
];
@ -129,7 +118,7 @@ qtModule {
'';
qmakeFlags = [ "--" "-system-ffmpeg" ]
++ lib.optional (pipewireSupport && (lib.versionAtLeast qtCompatVersion "5.15")) "-webengine-webrtc-pipewire"
++ lib.optional pipewireSupport "-webengine-webrtc-pipewire"
++ lib.optional enableProprietaryCodecs "-proprietary-codecs";
propagatedBuildInputs = [
@ -163,7 +152,7 @@ qtModule {
xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
xorg.libXcomposite xorg.libXdamage libdrm xorg.libxkbfile
] ++ lib.optionals (pipewireSupport && (lib.versionAtLeast qtCompatVersion "5.15")) [
] ++ lib.optionals pipewireSupport [
# Pipewire
pipewire_0_2
]
@ -221,7 +210,7 @@ qtModule {
[Paths]
Prefix = ..
EOF
'' + lib.optionalString (lib.versions.majorMinor qtCompatVersion == "5.15") ''
# Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3)
sed 's/${lib.head (lib.splitString "-" version)} /${qtCompatVersion} /' -i "$out"/lib/cmake/*/*Config.cmake
'';
@ -249,10 +238,5 @@ qtModule {
# This build takes a long time; particularly on slow architectures
timeout = 24 * 3600;
# 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
broken = stdenv.isDarwin;
};
}

View file

@ -19,35 +19,21 @@ let
'';
buildInputs = [ perl ];
};
usingAnnulenWebkitFork = lib.versionAtLeast qtbase.version "5.11.0";
in
qtModule {
pname = "qtwebkit";
qtInputs = [ qtbase qtdeclarative qtlocation qtsensors ]
++ lib.optional (stdenv.isDarwin && lib.versionAtLeast qtbase.version "5.9.0") qtmultimedia
++ lib.optional usingAnnulenWebkitFork qtwebchannel;
buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base ]
++ lib.optionals stdenv.isDarwin [ ICU OpenGL ]
++ lib.optional usingAnnulenWebkitFork hyphen;
nativeBuildInputs = [
bison flex gdb gperf perl pkg-config python38 ruby
] ++ lib.optional usingAnnulenWebkitFork cmake;
qtInputs = [ qtbase qtdeclarative qtlocation qtsensors qtwebchannel ]
++ lib.optional stdenv.isDarwin qtmultimedia;
buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base hyphen ]
++ lib.optionals stdenv.isDarwin [ ICU OpenGL ];
nativeBuildInputs = [ bison flex gdb gperf perl pkg-config python38 ruby cmake ];
cmakeFlags = lib.optionals usingAnnulenWebkitFork ([ "-DPORT=Qt" ]
cmakeFlags = [ "-DPORT=Qt" ]
++ lib.optionals stdenv.isDarwin [
"-DQt5Multimedia_DIR=${lib.getDev qtmultimedia}/lib/cmake/Qt5Multimedia"
"-DQt5MultimediaWidgets_DIR=${lib.getDev qtmultimedia}/lib/cmake/Qt5MultimediaWidgets"
"-DMACOS_FORCE_SYSTEM_XML_LIBRARIES=OFF"
]);
# QtWebKit overrides qmake's default_pre and default_post features,
# so its custom qmake files must be found first at the front of QMAKEPATH.
preConfigure = lib.optionalString (!usingAnnulenWebkitFork) ''
QMAKEPATH="$PWD/Tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
fixQtBuiltinPaths . '*.pr?'
# Fix hydra's "Log limit exceeded"
export qmakeFlags="$qmakeFlags CONFIG+=silent"
'';
];
NIX_CFLAGS_COMPILE = [
# with gcc7 this warning blows the log over Hydra's limit