From 0e3b8203010732d6036854904a33cd96e13ad50b Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Thu, 2 Nov 2023 18:30:35 -0700 Subject: [PATCH 01/17] qutebrowser: repair vandalism Our qutebrowser package has been vandalized by various commits, such as c9cc3a2e3eb4661b49176e0c62afd097793c9626 and ad0bbaf1d21f3b5da9c9cf68f0583d487c295782, which made erroneous assertions such as "since qutebrowser 3.0.0 the derivation is only building for qt6." This commit repairs the vandalism. --- .../networking/browsers/qutebrowser/default.nix | 9 +++++++-- pkgs/development/libraries/qt-5/5.15/default.nix | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/browsers/qutebrowser/default.nix b/pkgs/applications/networking/browsers/qutebrowser/default.nix index 03b03724aeef1..200f8e48c7e01 100644 --- a/pkgs/applications/networking/browsers/qutebrowser/default.nix +++ b/pkgs/applications/networking/browsers/qutebrowser/default.nix @@ -15,6 +15,7 @@ }: let + isQt6 = lib.versions.major qtbase.version == "6"; pdfjs = let version = "3.9.179"; in @@ -50,10 +51,14 @@ python3.pkgs.buildPythonApplication { ]; propagatedBuildInputs = with python3.pkgs; ([ - pyyaml pyqt6-webengine jinja2 pygments + pyyaml (if isQt6 then pyqt6-webengine else pyqtwebengine) jinja2 pygments # scripts and userscripts libs tldextract beautifulsoup4 - readability-lxml pykeepass stem + readability-lxml pykeepass + ] ++ lib.optionals ((builtins.tryEval stem.outPath).success) [ + # error: stem-1.8.2 not supported for interpreter python3.11 + stem + ] ++ [ pynacl # extensive ad blocking adblock diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 8a859af37e9d5..b8ad76854728f 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -339,5 +339,6 @@ let finalScope = baseScope.overrideScope(final: prev: { qttranslations = bootstrapScope.qttranslations; + qutebrowser = final.callPackage ../../../../applications/networking/browsers/qutebrowser { }; }); in finalScope From 1048c9063b30f2826441dbd8a824370c7b646cc5 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 21 Aug 2023 14:38:53 -0700 Subject: [PATCH 02/17] lib.systems.inspect: add patternLogicalAnd --- lib/systems/inspect.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 022e459c3945a..073df78797c72 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -100,6 +100,32 @@ rec { ]; }; + # given two patterns, return a pattern which is their logical AND. + # Since a pattern is a list-of-disjuncts, this needs to + patternLogicalAnd = pat1_: pat2_: + let + # patterns can be either a list or a (bare) singleton; turn + # them into singletons for uniform handling + pat1 = lib.toList pat1_; + pat2 = lib.toList pat2_; + in + lib.concatMap (attr1: + map (attr2: + lib.recursiveUpdateUntil + (path: subattr1: subattr2: + if (builtins.intersectAttrs subattr1 subattr2) == {} || subattr1 == subattr2 + then true + else throw '' + pattern conflict at path ${toString path}: + ${builtins.toJSON subattr1} + ${builtins.toJSON subattr2} + '') + attr1 + attr2 + ) + pat2) + pat1; + matchAnyAttrs = patterns: if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns else matchAttrs patterns; From 4ef828d5d426d052a686cb200f9c08f9f6718733 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 21:55:10 -0700 Subject: [PATCH 03/17] qt5.qtdeclarative: add postFixup if cross compiling --- .../libraries/qt-5/modules/qtdeclarative.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix b/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix index 892498da43b29..3e2136f39bcd9 100644 --- a/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix +++ b/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix @@ -1,4 +1,6 @@ -{ qtModule, lib, python3, qtbase, qtsvg }: +{ lib +, stdenv +, qtModule, python3, qtbase, qtsvg }: qtModule { pname = "qtdeclarative"; @@ -21,4 +23,10 @@ qtModule { "bin/qmlscene" "bin/qmltestrunner" ]; + postFixup = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + mv $dev/bin/qmlformat $bin/bin/qmlformat + mv $dev/bin/qmltyperegistrar $bin/bin/qmltyperegistrar + ln -s $bin/bin/qmlformat $dev/bin/qmlformat + ln -s $bin/bin/qmltyperegistrar $dev/bin/qmltyperegistrar + ''; } From 760d596e3358c74b60dbc4eae955fbacfbfa29ec Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 21:56:55 -0700 Subject: [PATCH 04/17] qt5.qtModule: reformat arguments --- pkgs/development/libraries/qt-5/qtModule.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index 7d73e652b6ffb..9e943a5f3aa0e 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -1,4 +1,11 @@ -{ lib, mkDerivation, perl, qmake, patches, srcs }: +{ lib +, stdenv +, mkDerivation +, perl +, qmake +, patches +, srcs +}: let inherit (lib) licenses maintainers platforms; in From e42b9650e670513bfa8e4608b63d7d8969cfd83a Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 21:58:12 -0700 Subject: [PATCH 05/17] qt5.qtModule: add buildPackages.stdenv.cc to depsBuildBuild if cross compiling --- pkgs/development/libraries/qt-5/qtModule.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index 9e943a5f3aa0e..e5d1e1f5422e9 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -1,5 +1,6 @@ { lib , stdenv +, buildPackages , mkDerivation , perl , qmake @@ -25,6 +26,9 @@ mkDerivation (args // { propagatedBuildInputs = (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or []) ++ (args.propagatedBuildInputs or []); +} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + depsBuildBuild = [ buildPackages.stdenv.cc ] ++ (args.depsBuildBuild or []); +} // { outputs = args.outputs or [ "out" "dev" ]; setOutputFlags = args.setOutputFlags or false; From 129b22f3af0e2ed30878f9ebeb05aafae25e7fca Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 21:59:25 -0700 Subject: [PATCH 06/17] qt5.qtModule: add explicit pkgsHostTarget.qt5.qtbase.dev to nativeBuildInputs if cross compiling --- pkgs/development/libraries/qt-5/qtModule.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index e5d1e1f5422e9..54d24e46092f2 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -6,6 +6,7 @@ , qmake , patches , srcs +, pkgsHostTarget }: let inherit (lib) licenses maintainers platforms; in @@ -22,7 +23,12 @@ mkDerivation (args // { inherit pname version src; patches = (args.patches or []) ++ (patches.${pname} or []); - nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ perl qmake ]; + nativeBuildInputs = + (args.nativeBuildInputs or []) ++ [ + perl qmake + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + pkgsHostTarget.qt5.qtbase.dev + ]; propagatedBuildInputs = (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or []) ++ (args.propagatedBuildInputs or []); From 80c437cb3d035c74bff54a80f8300ef2f914ff2d Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 22:00:22 -0700 Subject: [PATCH 07/17] qt5.qtwebchannel: omit "bin" output when cross compiling --- pkgs/development/libraries/qt-5/modules/qtwebchannel.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix b/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix index 118a5d4f96f69..e7d6be534409e 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix @@ -1,7 +1,12 @@ -{ qtModule, qtbase, qtdeclarative }: +{ lib +, stdenv +, qtModule +, qtbase +, qtdeclarative +}: qtModule { pname = "qtwebchannel"; propagatedBuildInputs = [ qtbase qtdeclarative ]; - outputs = [ "out" "dev" "bin" ]; + outputs = [ "out" "dev" ] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "bin" ]; } From 88568bb4fdcd665dc6f0c52705092daa6c45bb5c Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 22:07:12 -0700 Subject: [PATCH 08/17] qt5.qtwebengine: fix cross --- .../libraries/qt-5/modules/qtwebengine.nix | 117 ++++++++++++++---- 1 file changed, 90 insertions(+), 27 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix index 777430af0217f..58f90763a2452 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix @@ -1,8 +1,11 @@ { qtModule , qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel -, bison, flex, git, gperf, ninja, pkg-config, python, which +, bison, flex, git, gperf, ninja, pkg-config, python, which, python3 , nodejs, qtbase, perl +, buildPackages +, pkgsBuildTarget +, pkgsBuildBuild , xorg, libXcursor, libXScrnSaver, libXrandr, libXtst , fontconfig, freetype, harfbuzz, icu, dbus, libdrm @@ -27,12 +30,45 @@ , pipewireSupport ? stdenv.isLinux , pipewire_0_2 , postPatch ? "" +, nspr +, lndir +, dbusSupport ? !stdenv.isDarwin, expat }: -qtModule { +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 = "pkg-config-wrapper-without-target-prefix"; + 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 + ''; + }; + + qtPlatformCross = plat: with plat; + if isLinux + then "linux-generic-g++" + else throw "Please add a qtPlatformCross entry for ${plat.config}"; + +in + +qtModule ({ pname = "qtwebengine"; nativeBuildInputs = [ bison flex git gperf ninja pkg-config python which gn nodejs + ] ++ 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 ] ++ lib.optional stdenv.isDarwin xcbuild; doCheck = true; outputs = [ "bin" "dev" "out" ]; @@ -108,16 +144,25 @@ qtModule { --replace "-Wl,-fatal_warnings" "" '') + postPatch; - env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ - # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit - "-Wno-class-memaccess" - ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ - # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 - # TODO: investigate and fix properly - "-march=westmere" - ] ++ lib.optionals stdenv.cc.isClang [ - "-Wno-elaborated-enum-base" - ]); + 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 + "-Wno-class-memaccess" + ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ + # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 + # TODO: investigate and fix properly + "-march=westmere" + ] ++ lib.optionals stdenv.cc.isClang [ + "-Wno-elaborated-enum-base" + ]); + } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch"; + "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch"; + }; preConfigure = '' export NINJAFLAGS=-j$NIX_BUILD_CORES @@ -125,10 +170,15 @@ qtModule { if [ -d "$PWD/tools/qmake" ]; then QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH" fi + '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + export QMAKE_CC=$CC + export QMAKE_CXX=$CXX + export QMAKE_LINK=$CXX + export QMAKE_AR=$AR ''; qmakeFlags = [ "--" "-system-ffmpeg" ] - ++ lib.optional pipewireSupport "-webengine-webrtc-pipewire" + ++ lib.optional (pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform) "-webengine-webrtc-pipewire" ++ lib.optional enableProprietaryCodecs "-proprietary-codecs"; propagatedBuildInputs = [ @@ -226,7 +276,9 @@ qtModule { dontUseNinjaBuild = true; dontUseNinjaInstall = true; - postInstall = lib.optionalString stdenv.isLinux '' + postInstall = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + mkdir -p $out/libexec + '' + lib.optionalString stdenv.isLinux '' cat > $out/libexec/qt.conf < Date: Fri, 3 Nov 2023 22:14:31 -0700 Subject: [PATCH 09/17] qt5.qttranslations: disable if cross to prevent infinite recursion --- pkgs/development/libraries/qt-5/5.15/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index b8ad76854728f..56b7f86ba6c4d 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -338,7 +338,12 @@ let }); finalScope = baseScope.overrideScope(final: prev: { - qttranslations = bootstrapScope.qttranslations; + # qttranslations causes eval-time infinite recursion when + # cross-compiling; disabled for now. + qttranslations = + if stdenv.buildPlatform == stdenv.hostPlatform + then bootstrapScope.qttranslations + else null; qutebrowser = final.callPackage ../../../../applications/networking/browsers/qutebrowser { }; }); in finalScope From 08b8c3eaf414f0bed6c9098f846a24eee9d4a9ae Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 22:14:43 -0700 Subject: [PATCH 10/17] qt5.qtbase: fix cross --- .../libraries/qt-5/modules/qtbase.nix | 62 +++++++++++++++---- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 9f0feaf94e584..67e9bd5440d11 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -29,13 +29,18 @@ , developerBuild ? false , decryptSslTraffic ? false , testers +, buildPackages }: let debugSymbols = debug || developerBuild; + qtPlatformCross = plat: with plat; + if isLinux + then "linux-generic-g++" + else throw "Please add a qtPlatformCross entry for ${plat.config}"; in -stdenv.mkDerivation (finalAttrs: { +stdenv.mkDerivation (finalAttrs: ({ pname = "qtbase"; inherit qtCompatVersion src version; debug = debugSymbols; @@ -83,6 +88,13 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which ] ++ lib.optionals stdenv.isDarwin [ xcbuild ]; + } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + # `qtbase` expects to find `cc` (with no prefix) in the + # `$PATH`, so the following is needed even if + # `stdenv.buildPlatform.canExecute stdenv.hostPlatform` + depsBuildBuild = [ buildPackages.stdenv.cc ]; + } // { + propagatedNativeBuildInputs = [ lndir ]; # libQt5Core links calls CoreFoundation APIs that call into the system ICU. Binaries linked @@ -162,6 +174,13 @@ stdenv.mkDerivation (finalAttrs: { export MAKEFLAGS+=" -j$NIX_BUILD_CORES" ./bin/syncqt.pl -version $version + '' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + # QT's configure script will refuse to use pkg-config unless these two environment variables are set + export PKG_CONFIG_SYSROOT_DIR=/ + export PKG_CONFIG_LIBDIR=${lib.getLib pkg-config}/lib + echo "QMAKE_LFLAGS=''${LDFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf + echo "QMAKE_CFLAGS=''${CFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf + echo "QMAKE_CXXFLAGS=''${CXXFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf ''; postConfigure = '' @@ -186,21 +205,34 @@ stdenv.mkDerivation (finalAttrs: { done ''; - env.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"'' - ''-DLIBRESOLV_SO="${stdenv.cc.libc.out}/lib/libresolv"'' - ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"'' - ] ++ lib.optional libGLSupported ''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"'' + env = { + NIX_CFLAGS_COMPILE = toString ([ + "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-Wno-warn=free-nonheap-object" + "-Wno-free-nonheap-object" + "-w" + ] ++ [ + ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"'' + ''-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" ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-darwin") [ # ignore "is only available on macOS 10.12.2 or newer" in obj-c code "-Wno-error=unguarded-availability" ] ++ 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"); + ''-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.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + NIX_CFLAGS_COMPILE_FOR_BUILD = toString ([ + "-Wno-warn=free-nonheap-object" + "-Wno-free-nonheap-object" + "-w" + ]); + }; prefixKey = "-prefix "; @@ -209,6 +241,9 @@ stdenv.mkDerivation (finalAttrs: { # To prevent these failures, we need to override PostgreSQL detection. PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq"; + } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + configurePlatforms = [ ]; + } // { # TODO Remove obsolete and useless flags once the build will be totally mastered configureFlags = [ "-plugindir $(out)/$(qtPluginPrefix)" @@ -235,11 +270,16 @@ stdenv.mkDerivation (finalAttrs: { "-L" "${icu.out}/lib" "-I" "${icu.dev}/include" "-pch" + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-device ${qtPlatformCross stdenv.hostPlatform}" + "-device-option CROSS_COMPILE=${stdenv.cc.targetPrefix}" ] ++ lib.optional debugSymbols "-debug" ++ lib.optionals developerBuild [ "-developer-build" "-no-warnings-are-errors" + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-no-warnings-are-errors" ] ++ (if (!stdenv.hostPlatform.isx86_64) then [ "-no-sse2" ] else [ @@ -381,4 +421,4 @@ stdenv.mkDerivation (finalAttrs: { platforms = platforms.unix; }; -}) +})) From c8c7a452bb35fb1030d7270f490c89e4bc65c614 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 22:20:23 -0700 Subject: [PATCH 11/17] qt5.pyqtwebengine: fix cross --- .../python-modules/pyqtwebengine/default.nix | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/pyqtwebengine/default.nix b/pkgs/development/python-modules/pyqtwebengine/default.nix index 7ad39633b7e51..71abe839a7893 100644 --- a/pkgs/development/python-modules/pyqtwebengine/default.nix +++ b/pkgs/development/python-modules/pyqtwebengine/default.nix @@ -1,13 +1,14 @@ { lib, stdenv, pythonPackages, fetchPypi, pkg-config -, qmake, qtbase, qtsvg, qtwebengine +, qmake, qtbase, qtsvg, qtwebengine, qtwebchannel, qtdeclarative , wrapQtAppsHook , darwin +, buildPackages }: let inherit (pythonPackages) buildPythonPackage python isPy27 pyqt5 sip pyqt-builder; inherit (darwin) autoSignDarwinBinariesHook; -in buildPythonPackage rec { +in buildPythonPackage (rec { pname = "PyQtWebEngine"; version = "5.15.4"; format = "pyproject"; @@ -29,12 +30,18 @@ in buildPythonPackage rec { nativeBuildInputs = [ pkg-config qmake + ] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ sip + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + buildPackages.python3Packages.sip + ] ++ [ qtbase qtsvg qtwebengine pyqt-builder pythonPackages.setuptools + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + qtdeclarative ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ]; @@ -44,6 +51,9 @@ in buildPythonPackage rec { qtbase qtsvg qtwebengine + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + qtwebchannel + qtdeclarative ]; propagatedBuildInputs = [ pyqt5 ]; @@ -71,6 +81,13 @@ in buildPythonPackage rec { description = "Python bindings for Qt5"; homepage = "http://www.riverbankcomputing.co.uk"; license = licenses.gpl3; - platforms = lib.lists.intersectLists qtwebengine.meta.platforms platforms.mesaPlatforms; + hydraPlatforms = lib.lists.intersectLists qtwebengine.meta.platforms platforms.mesaPlatforms; }; -} +} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + # TODO: figure out why the env hooks aren't adding these inclusions automatically + env.NIX_CFLAGS_COMPILE = + lib.concatStringsSep " " [ + "-I${lib.getDev qtbase}/include/QtPrintSupport/" + "-I${lib.getDev qtwebchannel}/include/QtWebChannel/" + ]; +}) From dc61c9062709546b1feec1e4ae1aaeefe32b031d Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 22:25:17 -0700 Subject: [PATCH 12/17] pyqt5: fix cross --- pkgs/development/python-modules/pyqt/5.x.nix | 55 ++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/pyqt/5.x.nix b/pkgs/development/python-modules/pyqt/5.x.nix index 12d2ea182af02..c514b9f835843 100644 --- a/pkgs/development/python-modules/pyqt/5.x.nix +++ b/pkgs/development/python-modules/pyqt/5.x.nix @@ -12,6 +12,7 @@ , pyqt5_sip , pyqt-builder , libsForQt5 +, enableVerbose ? true , withConnectivity ? false , withMultimedia ? false , withWebKit ? false @@ -19,6 +20,9 @@ , withLocation ? false , withSerialPort ? false , withTools ? false +, pkgsBuildTarget +, buildPackages +, dbusSupport ? !stdenv.isDarwin }: buildPythonPackage rec { @@ -45,6 +49,7 @@ buildPythonPackage rec { # be more verbose '' cat >> pyproject.toml < PyQt_PrintDialog + # QT_NO_PRINTER => PyQt_Printer + # QT_NO_PRINTPREVIEWDIALOG => PyQt_PrintPreviewDialog + # QT_NO_PRINTPREVIEWWIDGET => PyQt_PrintPreviewWidget + # QT_NO_SSL => PyQt_SSL + # QT_SHARED || QT_DLL => shared (otherwise static) + # QT_NO_PROCESS => PyQt_Process + # QT_NO_FPU || Q_PROCESSOR_ARM || Q_OS_WINCE => PyQt_qreal_double + # sizeof (qreal) != sizeof (double) => PyQt_qreal_double + # !Q_COMPILER_CONSTEXPR !Q_COMPILER_UNIFORM_INIT => PyQt_CONSTEXPR + # QT_NO_ACCESSIBILITY => PyQt_Accessibility + # QT_NO_OPENGL => PyQt_OpenGL PyQt_Desktop_OpenGL + # defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_ES_3) => PyQt_Desktop_OpenGL + # QT_NO_RAWFONT => PyQt_RawFont + # QT_NO_SESSIONMANAGER => PyQt_SessionManager + # + + lib.optionalString (!(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) '' + rm config-tests/cfgtest_QtCore.cpp + rm config-tests/cfgtest_QtGui.cpp + rm config-tests/cfgtest_QtNetwork.cpp + rm config-tests/cfgtest_QtPrintSupport.cpp ''; enableParallelBuilding = true; @@ -68,16 +104,27 @@ buildPythonPackage rec { export MAKEFLAGS+="''${enableParallelBuilding:+-j$NIX_BUILD_CORES}" ''; + # tons of warnings from subpackages, no point in playing whack-a-mole + env = lib.optionalAttrs (!enableVerbose) { + NIX_CFLAGS_COMPILE = "-w"; + }; + outputs = [ "out" "dev" ]; dontWrapQtApps = true; - nativeBuildInputs = with libsForQt5; [ + nativeBuildInputs = [ pkg-config - qmake + ] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ + libsForQt5.qmake + ] ++ [ setuptools lndir sip + ] ++ (with pkgsBuildTarget.targetPackages.libsForQt5; [ + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + qmake + ] ++ [ qtbase qtsvg qtdeclarative @@ -90,11 +137,13 @@ buildPythonPackage rec { ++ lib.optional withLocation qtlocation ++ lib.optional withSerialPort qtserialport ++ lib.optional withTools qttools - ; + ); buildInputs = with libsForQt5; [ dbus + ] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ qtbase + ] ++ [ qtsvg qtdeclarative pyqt-builder From 228288885b9dc7e33812ab8feac461259f5752df Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 4 Nov 2023 00:57:23 -0700 Subject: [PATCH 13/17] jasper: mark broken if cross --- pkgs/by-name/ja/jasper/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/ja/jasper/package.nix b/pkgs/by-name/ja/jasper/package.nix index 4e10eaa80ad83..23171c71fbecb 100644 --- a/pkgs/by-name/ja/jasper/package.nix +++ b/pkgs/by-name/ja/jasper/package.nix @@ -48,5 +48,8 @@ stdenv.mkDerivation (finalAttrs: { license = lib.licenses.mit; maintainers = with lib.maintainers; [ AndersonTorres ]; platforms = lib.platforms.unix; + + # The value of __STDC_VERSION__ cannot be automatically determined when cross-compiling. + broken = stdenv.buildPlatform != stdenv.hostPlatform; }; }) From de70669d022c29311eb259f5c2fa4e72efd3d171 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 4 Nov 2023 00:58:04 -0700 Subject: [PATCH 14/17] qt5.qtimageformats: do not try to use broken libraries --- .../libraries/qt-5/modules/qtimageformats.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtimageformats.nix b/pkgs/development/libraries/qt-5/modules/qtimageformats.nix index f099fc6799b50..4775bb0b0383f 100644 --- a/pkgs/development/libraries/qt-5/modules/qtimageformats.nix +++ b/pkgs/development/libraries/qt-5/modules/qtimageformats.nix @@ -1,4 +1,6 @@ -{ qtModule +{ lib +, stdenv +, qtModule , qtbase , libwebp , jasper @@ -8,5 +10,11 @@ qtModule { pname = "qtimageformats"; - propagatedBuildInputs = [ qtbase libwebp jasper libmng libtiff ]; + propagatedBuildInputs = [ + qtbase libwebp + ] ++ lib.optionals (!jasper.meta.broken) [ + jasper + ] ++ [ + libmng libtiff + ]; } From 930a63167bf45527558e3ffa927d6724d9877e33 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 3 Nov 2023 21:53:31 -0700 Subject: [PATCH 15/17] qt5.qmake-hook: move libs to depsTargetTargetPropagated --- pkgs/development/libraries/qt-5/5.15/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 56b7f86ba6c4d..df60188800ab8 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -313,7 +313,9 @@ let qmake = callPackage ({ qtbase }: makeSetupHook { name = "qmake-hook"; - propagatedBuildInputs = [ qtbase.dev ]; + ${if stdenv.buildPlatform == stdenv.hostPlatform + then "propagatedBuildInputs" + else "depsTargetTargetPropagated"} = [ qtbase.dev ]; substitutions = { inherit debug; fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh; From 274da99d2db424b89d422627a0a935a8b584249d Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 4 Nov 2023 15:31:19 -0700 Subject: [PATCH 16/17] qutebrowser: take python3 from buildPackages --- pkgs/applications/networking/browsers/qutebrowser/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/qutebrowser/default.nix b/pkgs/applications/networking/browsers/qutebrowser/default.nix index 200f8e48c7e01..62bed5a34f0e6 100644 --- a/pkgs/applications/networking/browsers/qutebrowser/default.nix +++ b/pkgs/applications/networking/browsers/qutebrowser/default.nix @@ -12,6 +12,7 @@ , widevine-cdm , enableVulkan ? stdenv.isLinux , vulkan-loader +, buildPackages }: let @@ -85,7 +86,7 @@ python3.pkgs.buildPythonApplication { runHook preInstall make -f misc/Makefile \ - PYTHON=${python3}/bin/python3 \ + PYTHON=${buildPackages.python3}/bin/python3 \ PREFIX=. \ DESTDIR="$out" \ DATAROOTDIR=/share \ From 753bf0e2933c4d66c0eb8481b60157419bae3629 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 4 Nov 2023 14:55:44 -0700 Subject: [PATCH 17/17] test.cross.sanity: add qt5.qutebrowser, firefox --- pkgs/test/cross/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/test/cross/default.nix b/pkgs/test/cross/default.nix index f844fc2b8ec55..9f8209de17ed2 100644 --- a/pkgs/test/cross/default.nix +++ b/pkgs/test/cross/default.nix @@ -151,6 +151,10 @@ let # lots of interesting corner cases. Only expected to work for # x86_64-linux buildPlatform. pkgs.pkgsMusl.pkgsCross.gnu64.hello + + # Two web browsers -- exercises almost the entire packageset + pkgs.pkgsCross.aarch64-multiplatform.qt5.qutebrowser + pkgs.pkgsCross.aarch64-multiplatform.firefox ]; in {