about summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
authorTheodore Ni <3806110+tjni@users.noreply.github.com>2023-08-26 16:08:02 -0700
committerTheodore Ni <3806110+tjni@users.noreply.github.com>2023-08-26 16:08:02 -0700
commit80a74ec050766415beb2f5765155ab425ac86af3 (patch)
treee3a5baa5e6a6f65822aad855b7e00364b661d6bd /pkgs/development/libraries
parent8adf696a5431332893f14e019a560703000ed648 (diff)
parenta7d27e87ee8a2b5b5a6bd39e5c3cdf7549606923 (diff)
Merge branch 'master' into staging-next
Manually fixed a merge conflict between https://github.com/NixOS/nixpkgs/pull/227900
and https://github.com/NixOS/nixpkgs/pull/246022.
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r--pkgs/development/libraries/qt-5/5.15/default.nix3
-rw-r--r--pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh2
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtbase.nix20
-rw-r--r--pkgs/development/libraries/qt-5/qtModule.nix10
4 files changed, 33 insertions, 2 deletions
diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix
index e6e6b24360a42..12a3fd8e01573 100644
--- a/pkgs/development/libraries/qt-5/5.15/default.nix
+++ b/pkgs/development/libraries/qt-5/5.15/default.nix
@@ -208,7 +208,8 @@ let
         import ../qtModule.nix
         {
           inherit perl;
-          inherit lib;
+          inherit lib stdenv;
+          inherit buildPackages;
           # Use a variant of mkDerivation that does not include wrapQtApplications
           # to avoid cyclic dependencies between Qt modules.
           mkDerivation =
diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
index 1b57d676e1fc5..0e23ec1432182 100644
--- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
+++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
@@ -1,4 +1,5 @@
 if [[ -n "${__nix_qtbase-}" ]]; then
+  if [ -z "${dontWorryAboutQtMismatch-}" ]; then
     # Throw an error if a different version of Qt was already set up.
     if [[ "$__nix_qtbase" != "@dev@" ]]; then
         echo >&2 "Error: detected mismatched Qt dependencies:"
@@ -6,6 +7,7 @@ if [[ -n "${__nix_qtbase-}" ]]; then
         echo >&2 "    $__nix_qtbase"
         exit 1
     fi
+  fi
 else # Only set up Qt once.
 __nix_qtbase="@dev@"
 
diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix
index 9f0feaf94e584..ffd2d06769ff3 100644
--- a/pkgs/development/libraries/qt-5/modules/qtbase.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix
@@ -29,10 +29,15 @@
 , 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: {
@@ -83,6 +88,11 @@ stdenv.mkDerivation (finalAttrs: {
   nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which ]
     ++ lib.optionals stdenv.isDarwin [ xcbuild ];
 
+  # `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 +172,11 @@ stdenv.mkDerivation (finalAttrs: {
     export MAKEFLAGS+=" -j$NIX_BUILD_CORES"
 
     ./bin/syncqt.pl -version $version
+  '' + lib.optionalString (stdenv.buildPlatform != 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_PKG_CONFIG=''$''${CROSS_COMPILE}pkg-config' >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf
   '';
 
   postConfigure = ''
@@ -209,6 +224,8 @@ stdenv.mkDerivation (finalAttrs: {
   # To prevent these failures, we need to override PostgreSQL detection.
   PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq";
 
+  # do not pass --host and --build to configureFlags as QT's configure script doesn't understand them
+  configurePlatforms = [ ];
   # TODO Remove obsolete and useless flags once the build will be totally mastered
   configureFlags = [
     "-plugindir $(out)/$(qtPluginPrefix)"
@@ -235,6 +252,9 @@ 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 [
diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix
index bddbf254c5f7f..75deee58ea604 100644
--- a/pkgs/development/libraries/qt-5/qtModule.nix
+++ b/pkgs/development/libraries/qt-5/qtModule.nix
@@ -1,4 +1,8 @@
-{ lib, mkDerivation, perl }:
+{ lib
+, stdenv
+, mkDerivation, perl
+, buildPackages
+}:
 
 let inherit (lib) licenses maintainers platforms; in
 
@@ -18,6 +22,7 @@ mkDerivation (args // {
 
   nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ perl self.qmake ];
   propagatedBuildInputs = (args.qtInputs or []) ++ (args.propagatedBuildInputs or []);
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   outputs = args.outputs or [ "out" "dev" ];
   setOutputFlags = args.setOutputFlags or false;
@@ -74,4 +79,7 @@ mkDerivation (args // {
     maintainers = with maintainers; [ qknight ttuegel periklis bkchr ];
     platforms = platforms.unix;
   } // (args.meta or {});
+
+} // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
+  dontWorryAboutQtMismatch = true;
 })