about summary refs log tree commit diff
path: root/pkgs/development/libraries/qt-5
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-11-05 06:00:55 +0000
committerGitHub <noreply@github.com>2023-11-05 06:00:55 +0000
commitda4d99e016fdaac92c67847482dc6682abfde8bc (patch)
tree5643e4504c819c1686e36976b68f7b84e89b258f /pkgs/development/libraries/qt-5
parentc2088a45896220dffcebaecd2f7b4ae3db48309b (diff)
parentb425c7dbf9a4a2406c9dadc2e8946f3bf4cc70a4 (diff)
Merge master into staging-next
Diffstat (limited to 'pkgs/development/libraries/qt-5')
-rw-r--r--pkgs/development/libraries/qt-5/5.15/default.nix12
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtbase.nix62
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtdeclarative.nix10
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtimageformats.nix12
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebchannel.nix9
-rw-r--r--pkgs/development/libraries/qt-5/modules/qtwebengine.nix117
-rw-r--r--pkgs/development/libraries/qt-5/qtModule.nix21
7 files changed, 196 insertions, 47 deletions
diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix
index 8469dd70793df..fde5716b99ef2 100644
--- a/pkgs/development/libraries/qt-5/5.15/default.nix
+++ b/pkgs/development/libraries/qt-5/5.15/default.nix
@@ -329,7 +329,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;
@@ -354,6 +356,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
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;
   };
 
-})
+}))
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
+  '';
 }
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
+  ];
 }
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" ];
 }
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 <<EOF
     [Paths]
     Prefix = ..
@@ -245,21 +297,32 @@ qtModule {
 
     # qtwebengine-5.15.8: "QtWebEngine can only be built for x86,
     # x86-64, ARM, Aarch64, and MIPSel architectures."
-    platforms =
-      lib.trivial.pipe lib.systems.doubles.all [
-        (map (double: lib.systems.elaborate { system = double; }))
-        (lib.lists.filter (parsedPlatform: with parsedPlatform;
-          isUnix &&
-          (isx86_32  ||
-           isx86_64  ||
-           isAarch32 ||
-           isAarch64 ||
-           (isMips && isLittleEndian))))
-        (map (plat: plat.system))
-      ];
+    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)
+      ]);
     broken = stdenv.isDarwin && stdenv.isx86_64;
 
     # This build takes a long time; particularly on slow architectures
     timeout = 24 * 3600;
   };
-}
+
+} // 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
+  ];
+
+})
diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix
index 7d73e652b6ffb..54d24e46092f2 100644
--- a/pkgs/development/libraries/qt-5/qtModule.nix
+++ b/pkgs/development/libraries/qt-5/qtModule.nix
@@ -1,4 +1,13 @@
-{ lib, mkDerivation, perl, qmake, patches, srcs }:
+{ lib
+, stdenv
+, buildPackages
+, mkDerivation
+, perl
+, qmake
+, patches
+, srcs
+, pkgsHostTarget
+}:
 
 let inherit (lib) licenses maintainers platforms; in
 
@@ -14,10 +23,18 @@ 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 []);
+} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+  depsBuildBuild = [ buildPackages.stdenv.cc ] ++ (args.depsBuildBuild or []);
+} // {
 
   outputs = args.outputs or [ "out" "dev" ];
   setOutputFlags = args.setOutputFlags or false;