Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mingw32 support qtbase #287077

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 74 additions & 64 deletions pkgs/development/libraries/qt-6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let
qtModule = callPackage ./qtModule.nix { };

qtbase = callPackage ./modules/qtbase.nix {
withGtk3 = true;
withGtk3 = !stdenv.hostPlatform.isMinGW;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't gtk3 available on mingw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope

nix build '.#pkgs.pkgsCross.mingw32.gtk3'

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'gtk+3-i686-w64-mingw32-3.24.39'
         whose name attribute is located at /nix/store/kp890n9higzcq3n6bzqimvnl2qkx5i1v-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'buildInputs' of derivation 'gtk+3-i686-w64-mingw32-3.24.39'

         at /nix/store/kp890n9higzcq3n6bzqimvnl2qkx5i1v-source/pkgs/stdenv/generic/make-derivation.nix:400:7:

          399|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          400|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          401|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       error: Package ‘libxkbcommon-1.5.0’ in /nix/store/kp890n9higzcq3n6bzqimvnl2qkx5i1v-source/pkgs/development/libraries/libxkbcommon/default.nix:53 is not available on the requested hostPlatform:
         hostPlatform.config = "i686-w64-mingw32"
         package.meta.platforms = [
           "i686-cygwin"
           "x86_64-cygwin"
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
           "i686-freebsd13"
           "x86_64-freebsd13"
           "x86_64-solaris"
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
           "aarch64-netbsd"
           "armv6l-netbsd"
           "armv7a-netbsd"
           "armv7l-netbsd"
           "i686-netbsd"
           "m68k-netbsd"
           "mipsel-netbsd"
           "powerpc-netbsd"
           "riscv32-netbsd"
           "riscv64-netbsd"
           "x86_64-netbsd"
           "i686-openbsd"
           "x86_64-openbsd"
           "x86_64-redox"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, using !lib.meta.availableOn stdenv.hostPlatform gtk3 is more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a bug in the in the gtk3 package

nix-repl> lib.meta.availableOn pkgsCross.mingw32.stdenv.hostPlatform gtk3
true


nix-repl> :b pkgsCross.mingw32.gtk3
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'gtk+3-i686-w64-mingw32-3.24.39'
         whose name attribute is located at /home/sean/nixpkgs-contributing/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'buildInputs' of derivation 'gtk+3-i686-w64-mingw32-3.24.39'

         at /home/sean/nixpkgs-contributing/pkgs/stdenv/generic/make-derivation.nix:400:7:

          399|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          400|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          401|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       error: Package ‘libxkbcommon-1.5.0’ in /home/sean/nixpkgs-contributing/pkgs/development/libraries/libxkbcommon/default.nix:60 is not available on the requested hostPlatform:
         hostPlatform.config = "i686-w64-mingw32"
         package.meta.platforms = [
           "i686-cygwin"
           "x86_64-cygwin"
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
           "i686-freebsd13"
           "x86_64-freebsd13"
           "x86_64-solaris"
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
           "aarch64-netbsd"
           "armv6l-netbsd"
           "armv7a-netbsd"
           "armv7l-netbsd"
           "i686-netbsd"
           "m68k-netbsd"
           "mipsel-netbsd"
           "powerpc-netbsd"
           "riscv32-netbsd"
           "riscv64-netbsd"
           "x86_64-netbsd"
           "i686-openbsd"
           "x86_64-openbsd"
           "x86_64-redox"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change since gtk3 appears to indicate it has mingw support when in fact it doesn't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should fix this on the gtk3 side.

Copy link
Contributor Author

@seanybaggins seanybaggins Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hope is that we can leave the mingw conditional for now to get initial mingw support for qtbase. When gtk3 actually has mingw support, we can change that line. I suspect that adding mingw support for gtk3 may not be trivial.

inherit (srcs.qtbase) src version;
inherit developerBuild;
inherit (darwin.apple_sdk_11_0.frameworks)
Expand All @@ -69,47 +69,49 @@ let
];
};
env = callPackage ./qt-env.nix { };
full = callPackage ({ env, qtbase }: env "qt-full-${qtbase.version}"
# `with self` is ok to use here because having these spliced is unnecessary
( with self;[
qt3d
qt5compat
qtcharts
qtconnectivity
qtdatavis3d
qtdeclarative
qtdoc
qtgraphs
qtgrpc
qthttpserver
qtimageformats
qtlanguageserver
qtlocation
qtlottie
qtmultimedia
qtmqtt
qtnetworkauth
qtpositioning
qtsensors
qtserialbus
qtserialport
qtshadertools
qtspeech
qtquick3d
qtquick3dphysics
qtquickeffectmaker
qtquicktimeline
qtremoteobjects
qtsvg
qtscxml
qttools
qttranslations
qtvirtualkeyboard
qtwebchannel
qtwebengine
qtwebsockets
qtwebview
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ qtwayland libglvnd ])) { };
full = callPackage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop the formatting changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reconsider this one. Commits have been separated between the formatting and adding mingw support. This is what I have done for every merge request mentioned in these issues
#274274
#272538

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bug in nixpkgs-fmt that the after the callPackage a line break is added. Also it makes the entire PR looking bigger than it is.

({ env, qtbase }: env "qt-full-${qtbase.version}"
# `with self` is ok to use here because having these spliced is unnecessary
(with self;[
qt3d
qt5compat
qtcharts
qtconnectivity
qtdatavis3d
qtdeclarative
qtdoc
qtgraphs
qtgrpc
qthttpserver
qtimageformats
qtlanguageserver
qtlocation
qtlottie
qtmultimedia
qtmqtt
qtnetworkauth
qtpositioning
qtsensors
qtserialbus
qtserialport
qtshadertools
qtspeech
qtquick3d
qtquick3dphysics
qtquickeffectmaker
qtquicktimeline
qtremoteobjects
qtsvg
qtscxml
qttools
qttranslations
qtvirtualkeyboard
qtwebchannel
qtwebengine
qtwebsockets
qtwebview
] ++ lib.optionals (!stdenv.isDarwin) [ qtwayland libglvnd ]))
{ };

qt3d = callPackage ./modules/qt3d.nix { };
qt5compat = callPackage ./modules/qt5compat.nix { };
Expand Down Expand Up @@ -162,11 +164,14 @@ let
GameController ImageCaptureCore LocalAuthentication
MediaAccessibility MediaPlayer MetalKit Network OpenDirectory Quartz
ReplayKit SecurityInterface Vision;
qtModule = callPackage ({ qtModule }: qtModule.override {
stdenv = if stdenv.hostPlatform.isDarwin
then overrideSDK stdenv { darwinMinVersion = "10.13"; darwinSdkVersion = "11.0"; }
else stdenv;
}) { };
qtModule = callPackage
({ qtModule }: qtModule.override {
stdenv =
if stdenv.isDarwin
then overrideSDK stdenv { darwinMinVersion = "10.13"; darwinSdkVersion = "11.0"; }
else stdenv;
})
{ };
xcbuild = buildPackages.xcbuild.override {
productBuildVer = "20A2408";
};
Expand All @@ -176,21 +181,25 @@ let
inherit (darwin.apple_sdk_11_0.frameworks) WebKit;
};

wrapQtAppsHook = callPackage ({ makeBinaryWrapper }: makeSetupHook
{
name = "wrap-qt6-apps-hook";
propagatedBuildInputs = [ makeBinaryWrapper ];
} ./hooks/wrap-qt-apps-hook.sh) { };
wrapQtAppsHook = callPackage
({ makeBinaryWrapper }: makeSetupHook
{
name = "wrap-qt6-apps-hook";
propagatedBuildInputs = [ makeBinaryWrapper ];
} ./hooks/wrap-qt-apps-hook.sh)
{ };

qmake = callPackage ({ qtbase }: makeSetupHook
{
name = "qmake6-hook";
propagatedBuildInputs = [ qtbase.dev ];
substitutions = {
inherit debug;
fix_qmake_libtool = ./hooks/fix-qmake-libtool.sh;
};
} ./hooks/qmake-hook.sh) { };
qmake = callPackage
({ qtbase }: makeSetupHook
{
name = "qmake6-hook";
propagatedBuildInputs = [ qtbase.dev ];
substitutions = {
inherit debug;
fix_qmake_libtool = ./hooks/fix-qmake-libtool.sh;
};
} ./hooks/qmake-hook.sh)
{ };
} // lib.optionalAttrs config.allowAliases {
# Convert to a throw on 03-01-2023 and backport the change.
# Warnings show up in various cli tool outputs, throws do not.
Expand All @@ -203,12 +212,13 @@ let
f = addPackages;
};

bootstrapScope = baseScope.overrideScope(final: prev: {
bootstrapScope = baseScope.overrideScope (final: prev: {
qtbase = prev.qtbase.override { qttranslations = null; };
qtdeclarative = null;
});

finalScope = baseScope.overrideScope(final: prev: {
finalScope = baseScope.overrideScope (final: prev: {
qttranslations = bootstrapScope.qttranslations;
});
in finalScope
in
finalScope
40 changes: 28 additions & 12 deletions pkgs/development/libraries/qt-6/modules/qtbase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, patches ? [ ]
, version
, coreutils
, buildPackages
, bison
, flex
, gdb
Expand Down Expand Up @@ -79,6 +80,8 @@
, EventKit
, GSS
, MetalKit
# mingw
, pkgsBuildBuild
# optional dependencies
, cups
, libmysqlclient
Expand All @@ -96,6 +99,7 @@

let
debugSymbols = debug || developerBuild;
isCrossBuild = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
in
stdenv.mkDerivation rec {
pname = "qtbase";
Expand All @@ -110,7 +114,6 @@ stdenv.mkDerivation rec {
openssl
sqlite
zlib
unixODBC
# Text rendering
harfbuzz
icu
Expand All @@ -119,14 +122,16 @@ stdenv.mkDerivation rec {
libpng
pcre2
pcre
libproxy
zstd
double-conversion
libb2
md4c
double-conversion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double-conversion is now supported on windows since #290089

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

] ++ lib.optionals (!stdenv.hostPlatform.isMinGW) [
libproxy
dbus
glib
# unixODBC drivers
unixODBC
unixODBCDrivers.psql
unixODBCDrivers.sqlite
unixODBCDrivers.mariadb
Expand Down Expand Up @@ -174,21 +179,26 @@ stdenv.mkDerivation rec {
EventKit
GSS
MetalKit
] ++ lib.optional libGLSupported libGL;
] ++ lib.optionals libGLSupported [
libGL
] ++ lib.optionals stdenv.hostPlatform.isMinGW [
vulkan-headers
vulkan-loader
];
Comment on lines +184 to +187
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only for mingw? Shall we also add vulkan support to linux builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a mingw only thing. See

vulkan-headers
vulkan-loader
. Vulkan appears to be unsupported for Darwin. Did the conditional at the bottom here to avoid triggering a mass rebuild.


buildInputs = [
buildInputs = lib.optionals (lib.meta.availableOn stdenv.hostPlatform at-spi2-core) [
at-spi2-core
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform libinput) [
libinput
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
AppKit
CoreBluetooth
]
++ lib.optional withGtk3 gtk3
++ lib.optional developerBuild gdb
++ lib.optional (cups != null) cups
++ lib.optional (libmysqlclient != null) libmysqlclient
++ lib.optional (postgresql != null) postgresql;
++ lib.optional (cups != null && lib.meta.availableOn stdenv.hostPlatform cups) cups
++ lib.optional (libmysqlclient != null && !stdenv.hostPlatform.isMinGW) libmysqlclient
++ lib.optional (postgresql != null && lib.meta.availableOn stdenv.hostPlatform postgresql) postgresql;

nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which cmake xmlstarlet ninja ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ moveBuildTree ];
Expand All @@ -203,7 +213,7 @@ stdenv.mkDerivation rec {

# https://bugreports.qt.io/browse/QTBUG-97568
postPatch = ''
substituteInPlace src/corelib/CMakeLists.txt --replace-fail "/bin/ls" "${coreutils}/bin/ls"
substituteInPlace src/corelib/CMakeLists.txt --replace-fail "/bin/ls" "${buildPackages.coreutils}/bin/ls"
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace cmake/QtPublicAppleHelpers.cmake --replace-fail "/usr/bin/xcrun" "${xcbuild}/bin/xcrun"
'';
Expand Down Expand Up @@ -232,7 +242,11 @@ stdenv.mkDerivation rec {
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
# error: 'path' is unavailable: introduced in macOS 10.15
"-DQT_FEATURE_cxx17_filesystem=OFF"
] ++ lib.optional (qttranslations != null) "-DINSTALL_TRANSLATIONSDIR=${qttranslations}/translations";
] ++ lib.optionals isCrossBuild [
"-DQT_HOST_PATH=${pkgsBuildBuild.qt6.qtbase}"
"-DQt6HostInfo_DIR=${pkgsBuildBuild.qt6.qtbase}/lib/cmake/Qt6HostInfo"
Comment on lines +246 to +247
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these paths are explicitly set, maybe there's no need to put it in depsBuildBuild? (Also causes inf recursion.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. Logic updated to only include this when stdenv.hostPlatform != stdenv.buildPlatform. Fixed.

]
++ lib.optional (qttranslations != null && !isCrossBuild) "-DINSTALL_TRANSLATIONSDIR=${qttranslations}/translations";

env.NIX_LDFLAGS = toString (lib.optionals stdenv.hostPlatform.isDarwin [
# Undefined symbols for architecture arm64: "___gss_c_nt_hostbased_service_oid_desc"
Expand All @@ -253,13 +267,15 @@ stdenv.mkDerivation rec {

dontStrip = debugSymbols;

dontWrapQtApps = true;

setupHook = ../hooks/qtbase-setup-hook.sh;

meta = with lib; {
homepage = "https://www.qt.io/";
description = "A cross-platform application framework for C++";
license = with licenses; [ fdl13Plus gpl2Plus lgpl21Plus lgpl3Plus ];
maintainers = with maintainers; [ milahu nickcao LunNova ];
platforms = platforms.unix;
platforms = platforms.unix ++ platforms.windows;
};
}
Loading