Skip to content
Open
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
192 changes: 128 additions & 64 deletions pkgs/development/libraries/qt-5/modules/qtbase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
perl,
pkg-config,
python3,
copyPathToStore,
makeSetupHook,
which,
# darwin support
xcbuild,
Expand Down Expand Up @@ -84,6 +86,23 @@ let
"linux-generic-g++"
else
throw "Please add a qtPlatformCross entry for ${plat.config}";
qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins";
qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml";
qtDocPrefix = "share/doc/qt-${qtCompatVersion}";
fix_qt_builtin_paths = copyPathToStore ../hooks/fix-qt-builtin-paths.sh;
fix_qt_module_paths = copyPathToStore ../hooks/fix-qt-module-paths.sh;

devTools = [
"bin/fixqt4headers.pl"
"bin/moc"
"bin/qdbuscpp2xml"
"bin/qdbusxml2cpp"
"bin/qlalr"
"bin/qmake"
"bin/rcc"
"bin/syncqt.pl"
"bin/uic"
];
in

stdenv.mkDerivation (
Expand All @@ -92,7 +111,6 @@ stdenv.mkDerivation (
{
pname = "qtbase";
inherit qtCompatVersion src version;
debug = debugSymbols;

propagatedBuildInputs = [
libxml2
Expand Down Expand Up @@ -136,7 +154,9 @@ stdenv.mkDerivation (
libxcb-render-util
libxcb-wm
]
++ lib.optional libGLSupported libGL
++ lib.optionals libGLSupported [
libGL
]
Comment on lines +157 to +159
Copy link
Contributor

Choose a reason for hiding this comment

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

This kind of diff hunk is good I think, but I find it tangent to the main point of this PR. Could you please avoid these lib.{optional -> optionals} changes and focus on the actual changes of the PR? Or alternatively, separate it to a different commit?

);

buildInputs = [
Expand All @@ -146,10 +166,18 @@ stdenv.mkDerivation (
++ lib.optionals (!stdenv.hostPlatform.isDarwin) (
lib.optional withLibinput libinput ++ lib.optional withGtk3 gtk3
)
++ lib.optional developerBuild gdb
++ lib.optional (cups != null) cups
++ lib.optional mysqlSupport libmysqlclient
++ lib.optional (libpq != null) libpq;
++ lib.optionals developerBuild [
gdb
]
++ lib.optionals (cups != null) [
cups
]
++ lib.optionals mysqlSupport [
libmysqlclient
]
++ lib.optionals (libpq != null) [
libpq
];

nativeBuildInputs = [
bison
Expand All @@ -160,8 +188,12 @@ stdenv.mkDerivation (
pkg-config
which
]
++ lib.optionals mysqlSupport [ libmysqlclient ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
++ lib.optionals mysqlSupport [
libmysqlclient
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
xcbuild
];

}
// lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
Expand Down Expand Up @@ -192,25 +224,23 @@ stdenv.mkDerivation (

inherit patches;

fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
fix_qt_module_paths = ../hooks/fix-qt-module-paths.sh;
preHook = ''
. "$fix_qt_builtin_paths"
. "$fix_qt_module_paths"
. ${fix_qt_builtin_paths}
. ${fix_qt_module_paths}
. ${../hooks/move-qt-dev-tools.sh}
. ${../hooks/fix-qmake-libtool.sh}
'';

postPatch = ''
for prf in qml_plugin.prf qt_plugin.prf qt_docs.prf qml_module.prf create_cmake.prf; do
substituteInPlace "mkspecs/features/$prf" \
--subst-var qtPluginPrefix \
--subst-var qtQmlPrefix \
--subst-var qtDocPrefix
--subst-var-by qtPluginPrefix ${qtPluginPrefix} \
--subst-var-by qtQmlPrefix ${qtQmlPrefix} \
--subst-var-by qtDocPrefix ${qtDocPrefix}
done

substituteInPlace configure --replace /bin/pwd pwd
substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
substituteInPlace configure --replace-fail /bin/pwd pwd
substituteInPlace src/corelib/global/global.pri --replace-fail /bin/ls ${coreutils}/bin/ls
Copy link
Contributor

Choose a reason for hiding this comment

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

This change too is blessed, but should be a different commit.

sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i mkspecs/*/*.conf

sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5Config.cmake.in
Expand Down Expand Up @@ -260,20 +290,16 @@ stdenv.mkDerivation (
''
);

qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins";
qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml";
qtDocPrefix = "share/doc/qt-${qtCompatVersion}";

setOutputFlags = false;
preConfigure = ''
export LD_LIBRARY_PATH="$PWD/lib:$PWD/plugins/platforms''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"

NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"${qtPluginPrefix}\""

# paralellize compilation of qtmake, which happens within ./configure
export MAKEFLAGS+=" -j$NIX_BUILD_CORES"

./bin/syncqt.pl -version $version
./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
Expand All @@ -295,9 +321,9 @@ stdenv.mkDerivation (
NIX_OUTPUT_BIN = $bin
NIX_OUTPUT_DEV = $dev
NIX_OUTPUT_OUT = $out
NIX_OUTPUT_DOC = $dev/$qtDocPrefix
NIX_OUTPUT_QML = $bin/$qtQmlPrefix
NIX_OUTPUT_PLUGIN = $bin/$qtPluginPrefix
NIX_OUTPUT_DOC = $dev/${qtDocPrefix}
NIX_OUTPUT_QML = $bin/${qtQmlPrefix}
NIX_OUTPUT_PLUGIN = $bin/${qtPluginPrefix}
EOF
}

Expand All @@ -321,13 +347,19 @@ stdenv.mkDerivation (
''-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.hostPlatform.isLinux "-DUSE_X11"
++ lib.optionals libGLSupported [
''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"''
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"-DUSE_X11"
]
++ 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.optionals decryptSslTraffic [
"-DQT_DECRYPT_SSL_TRAFFIC"
]
);
}
// lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
Expand All @@ -336,25 +368,28 @@ stdenv.mkDerivation (
"-Wno-free-nonheap-object"
"-w"
];
}
// lib.optionalAttrs (libpq != null) {
# PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
# if dependency paths contain the string "pq", which can occur in the hash.
# To prevent these failures, we need to override PostgreSQL detection.
PSQL_LIBS = "-L${libpq}/lib -lpq";
};

prefixKey = "-prefix ";

# PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
# if dependency paths contain the string "pq", which can occur in the hash.
# To prevent these failures, we need to override PostgreSQL detection.
PSQL_LIBS = lib.optionalString (libpq != null) "-L${libpq}/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)"
"-qmldir $(out)/$(qtQmlPrefix)"
"-docdir $(out)/$(qtDocPrefix)"
"-plugindir"
"${placeholder "out"}/${qtPluginPrefix}"
"-qmldir"
"${placeholder "out"}/${qtQmlPrefix}"
"-docdir"
"${placeholder "out"}/${qtDocPrefix}"

"-verbose"
"-confirm-license"
Expand All @@ -371,7 +406,8 @@ stdenv.mkDerivation (

"-gui"
"-widgets"
"-opengl desktop"
"-opengl"
"desktop"
"-icu"
"-L"
"${icu.out}/lib"
Expand All @@ -380,10 +416,14 @@ stdenv.mkDerivation (
"-pch"
]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-device ${qtPlatformCross stdenv.hostPlatform}"
"-device-option CROSS_COMPILE=${stdenv.cc.targetPrefix}"
"-device"
"${qtPlatformCross stdenv.hostPlatform}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
"${qtPlatformCross stdenv.hostPlatform}"
(qtPlatformCross stdenv.hostPlatform)

"-device-option"
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
]
++ lib.optionals debugSymbols [
"-debug"
]
++ lib.optional debugSymbols "-debug"
++ lib.optionals developerBuild [
"-developer-build"
"-no-warnings-are-errors"
Expand Down Expand Up @@ -438,10 +478,14 @@ stdenv.mkDerivation (
"-${if libpq != null then "plugin" else "no"}-sql-psql"
"-system-libpng"

"-make libs"
"-make tools"
"-${lib.optionalString (!buildExamples) "no"}make examples"
"-${lib.optionalString (!buildTests) "no"}make tests"
"-make"
"libs"
"-make"
"tools"
"-${lib.optionalString (!buildExamples) "no"}make"
"examples"
"-${lib.optionalString (!buildTests) "no"}make"
"tests"
]
++ (
if stdenv.hostPlatform.isDarwin then
Expand All @@ -456,7 +500,8 @@ stdenv.mkDerivation (
]
++ [
"-xcb"
"-qpa xcb"
"-qpa"
"xcb"
"-L"
"${libx11.out}/lib"
"-I"
Expand All @@ -474,8 +519,12 @@ stdenv.mkDerivation (
"-dbus-linked"
"-glib"
]
++ lib.optional withGtk3 "-gtk"
++ lib.optional withLibinput "-libinput"
++ lib.optionals withGtk3 [
"-gtk"
]
++ lib.optionals withLibinput [
"-libinput"
]
++ [
"-inotify"
]
Expand All @@ -491,7 +540,7 @@ stdenv.mkDerivation (
"-I"
"${libmysqlclient}/include"
]
++ lib.optional (qttranslations != null) [
++ lib.optionals (qttranslations != null) [
"-translationdir"
"${qttranslations}/translations"
]
Expand All @@ -502,25 +551,15 @@ stdenv.mkDerivation (
moveToOutput "mkspecs" "$dev"
'';

devTools = [
"bin/fixqt4headers.pl"
"bin/moc"
"bin/qdbuscpp2xml"
"bin/qdbusxml2cpp"
"bin/qlalr"
"bin/qmake"
"bin/rcc"
"bin/syncqt.pl"
"bin/uic"
];

postFixup = ''
# Don't retain build-time dependencies like gdb.
sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri

Copy link
Contributor

Choose a reason for hiding this comment

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

Another unrelated change.

fixQtModulePaths "''${!outputDev}/mkspecs/modules"
fixQtBuiltinPaths "''${!outputDev}" '*.pr?'

# Move development tools to $dev
devTools="${lib.concatStringsSep " " devTools}"
moveQtDevTools
moveToOutput bin "$dev"

Expand All @@ -531,9 +570,34 @@ stdenv.mkDerivation (

dontStrip = debugSymbols;

setupHook = ../hooks/qtbase-setup-hook.sh;
setupHook =
let
hook = makeSetupHook {
name = "qtbase5-setup-hook";
substitutions = {
inherit
qtPluginPrefix
qtQmlPrefix
qtDocPrefix
fix_qt_builtin_paths
fix_qt_module_paths
;
debug = debugSymbols;
};
} ../hooks/qtbase-setup-hook.sh;
in
"${hook}/nix-support/setup-hook";
Comment on lines +573 to +589
Copy link
Contributor

Choose a reason for hiding this comment

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

How come it worked before without these substitutions?


passthru = {
inherit
qtPluginPrefix
qtQmlPrefix
qtDocPrefix
;
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
};

passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
__structuredAttrs = true;

meta = {
homepage = "https://www.qt.io/";
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/libraries/qt-5/qtModule.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ mkDerivation (
done
fi

${lib.optionalString (lib.hasAttr "devTools" args) ''devTools="${lib.concatStringsSep " " args.devTools}"''}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain how come this is needed all of a sudden?

moveQtDevTools

${args.postFixup or ""}
Expand Down
Loading