Merge pull request #108888 from ttuegel/feature--staging--qt-no-mkDerivation
Qt: Do not require mkDerivation
This commit is contained in:
@@ -145,7 +145,7 @@ let
|
||||
patches = patches.qtbase;
|
||||
inherit bison cups harfbuzz libGL;
|
||||
withGtk3 = true; inherit dconf gtk3;
|
||||
inherit developerBuild decryptSslTraffic;
|
||||
inherit debug developerBuild decryptSslTraffic;
|
||||
};
|
||||
|
||||
qtcharts = callPackage ../modules/qtcharts.nix {};
|
||||
@@ -197,6 +197,7 @@ let
|
||||
qmake = makeSetupHook {
|
||||
deps = [ self.qtbase.dev ];
|
||||
substitutions = {
|
||||
inherit debug;
|
||||
fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh;
|
||||
};
|
||||
} ../hooks/qmake-hook.sh;
|
||||
|
||||
@@ -149,7 +149,7 @@ let
|
||||
patches = patches.qtbase;
|
||||
inherit bison cups harfbuzz libGL;
|
||||
withGtk3 = true; inherit dconf gtk3;
|
||||
inherit developerBuild decryptSslTraffic;
|
||||
inherit debug developerBuild decryptSslTraffic;
|
||||
};
|
||||
|
||||
qtcharts = callPackage ../modules/qtcharts.nix {};
|
||||
@@ -199,6 +199,7 @@ let
|
||||
qmake = makeSetupHook {
|
||||
deps = [ self.qtbase.dev ];
|
||||
substitutions = {
|
||||
inherit debug;
|
||||
fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh;
|
||||
};
|
||||
} ../hooks/qmake-hook.sh;
|
||||
|
||||
@@ -179,6 +179,7 @@ let
|
||||
qmake = makeSetupHook {
|
||||
deps = [ self.qtbase.dev ];
|
||||
substitutions = {
|
||||
inherit debug;
|
||||
fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh;
|
||||
};
|
||||
} ../hooks/qmake-hook.sh;
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
qmakeFlags=( ${qmakeFlags-} )
|
||||
|
||||
qmakePrePhase() {
|
||||
qmakeFlags_orig=( "${qmakeFlags[@]}" )
|
||||
|
||||
# These flags must be added _before_ the flags specified in the derivation.
|
||||
qmakeFlags=( \
|
||||
"PREFIX=$out" \
|
||||
"NIX_OUTPUT_OUT=$out" \
|
||||
@@ -11,8 +14,15 @@ qmakePrePhase() {
|
||||
"NIX_OUTPUT_DOC=${!outputDev}/${qtDocPrefix:?}" \
|
||||
"NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?}" \
|
||||
"NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?}" \
|
||||
"${qmakeFlags[@]}" \
|
||||
)
|
||||
|
||||
if [ -n "@debug@" ]; then
|
||||
qmakeFlags+=( "CONFIG+=debug" )
|
||||
else
|
||||
qmakeFlags+=( "CONFIG+=release" )
|
||||
fi
|
||||
|
||||
qmakeFlags+=( "${qmakeFlags_orig[@]}" )
|
||||
}
|
||||
prePhases+=" qmakePrePhase"
|
||||
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
if [[ -n "${__nix_qtbase-}" ]]; 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:"
|
||||
echo >&2 " @dev@"
|
||||
echo >&2 " $__nix_qtbase"
|
||||
exit 1
|
||||
fi
|
||||
else # Only set up Qt once.
|
||||
__nix_qtbase="@dev@"
|
||||
|
||||
qtPluginPrefix=@qtPluginPrefix@
|
||||
qtQmlPrefix=@qtQmlPrefix@
|
||||
qtDocPrefix=@qtDocPrefix@
|
||||
@@ -5,6 +16,20 @@ qtDocPrefix=@qtDocPrefix@
|
||||
. @fix_qt_builtin_paths@
|
||||
. @fix_qt_module_paths@
|
||||
|
||||
# Disable debug symbols if qtbase was built without debugging.
|
||||
# This stops -dev paths from leaking into other outputs.
|
||||
if [ -z "@debug@" ]; then
|
||||
NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
|
||||
fi
|
||||
|
||||
# Integration with CMake:
|
||||
# Set the CMake build type corresponding to how qtbase was built.
|
||||
if [ -n "@debug@" ]; then
|
||||
cmakeBuildType="Debug"
|
||||
else
|
||||
cmakeBuildType="Release"
|
||||
fi
|
||||
|
||||
providesQtRuntime() {
|
||||
[ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
|
||||
}
|
||||
@@ -19,7 +44,12 @@ export QMAKEPATH
|
||||
QMAKEMODULES=
|
||||
export QMAKEMODULES
|
||||
|
||||
declare -Ag qmakePathSeen=()
|
||||
qmakePathHook() {
|
||||
# Skip this path if we have seen it before.
|
||||
# MUST use 'if' because 'qmakePathSeen[$]' may be unset.
|
||||
if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
|
||||
qmakePathSeen[$1]=1
|
||||
if [ -d "$1/mkspecs" ]
|
||||
then
|
||||
QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
|
||||
@@ -34,7 +64,12 @@ envBuildHostHooks+=(qmakePathHook)
|
||||
# package depending on the building package. (This is necessary in case
|
||||
# the building package does not provide runtime dependencies itself and so
|
||||
# would not be propagated to the user environment.)
|
||||
declare -Ag qtEnvHostTargetSeen=()
|
||||
qtEnvHostTargetHook() {
|
||||
# Skip this path if we have seen it before.
|
||||
# MUST use 'if' because 'qmakePathSeen[$]' may be unset.
|
||||
if [ -n "${qtEnvHostTargetSeen[$1]-}" ]; then return; fi
|
||||
qtEnvHostTargetSeen[$1]=1
|
||||
if providesQtRuntime "$1" && [ "z${!outputBin}" != "z${!outputDev}" ]
|
||||
then
|
||||
propagatedBuildInputs+=" $1"
|
||||
@@ -64,3 +99,14 @@ postPatchMkspecs() {
|
||||
if [ -z "${dontPatchMkspecs-}" ]; then
|
||||
postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
|
||||
fi
|
||||
|
||||
qtPreHook() {
|
||||
# Check that wrapQtAppsHook is used, or it is explicitly disabled.
|
||||
if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
|
||||
echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
prePhases+=" qtPreHook"
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
if [[ -z "${__nix_wrapQtAppsHook-}" ]]; then
|
||||
__nix_wrapQtAppsHook=1 # Don't run this hook more than once.
|
||||
|
||||
# Inherit arguments given in mkDerivation
|
||||
qtWrapperArgs=( ${qtWrapperArgs-} )
|
||||
|
||||
@@ -100,3 +103,5 @@ wrapQtAppsHook() {
|
||||
}
|
||||
|
||||
fixupOutputHooks+=(wrapQtAppsHook)
|
||||
|
||||
fi
|
||||
|
||||
@@ -9,21 +9,6 @@ args:
|
||||
let
|
||||
args_ = {
|
||||
|
||||
qmakeFlags = [ ("CONFIG+=" + (if debug then "debug" else "release")) ]
|
||||
++ (args.qmakeFlags or []);
|
||||
|
||||
NIX_CFLAGS_COMPILE = toString (
|
||||
optional (!debug) "-DQT_NO_DEBUG"
|
||||
++ lib.toList (args.NIX_CFLAGS_COMPILE or []));
|
||||
|
||||
cmakeFlags =
|
||||
(args.cmakeFlags or [])
|
||||
++ [
|
||||
("-DCMAKE_BUILD_TYPE=" + (if debug then "Debug" else "Release"))
|
||||
];
|
||||
|
||||
enableParallelBuilding = args.enableParallelBuilding or true;
|
||||
|
||||
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ wrapQtAppsHook ];
|
||||
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
libGL,
|
||||
buildExamples ? false,
|
||||
buildTests ? false,
|
||||
debug ? false,
|
||||
developerBuild ? false,
|
||||
decryptSslTraffic ? false
|
||||
}:
|
||||
@@ -33,12 +34,14 @@ let
|
||||
compareVersion = v: builtins.compareVersions version v;
|
||||
qmakeCacheName =
|
||||
if compareVersion "5.12.4" < 0 then ".qmake.cache" else ".qmake.stash";
|
||||
debugSymbols = debug || developerBuild;
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
|
||||
name = "qtbase-${version}";
|
||||
inherit qtCompatVersion src version;
|
||||
debug = debugSymbols;
|
||||
|
||||
propagatedBuildInputs =
|
||||
[
|
||||
@@ -241,6 +244,7 @@ stdenv.mkDerivation {
|
||||
"-I" "${icu.dev}/include"
|
||||
"-pch"
|
||||
]
|
||||
++ lib.optional debugSymbols "-debug"
|
||||
++ lib.optionals (compareVersion "5.11.0" < 0)
|
||||
[
|
||||
"-qml-debug"
|
||||
@@ -397,6 +401,8 @@ stdenv.mkDerivation {
|
||||
-e "/^host_bins=/ c host_bins=$dev/bin"
|
||||
'';
|
||||
|
||||
dontStrip = debugSymbols;
|
||||
|
||||
setupHook = ../hooks/qtbase-setup-hook.sh;
|
||||
|
||||
meta = with lib; {
|
||||
|
||||
@@ -34,6 +34,8 @@ mkDerivation (args // {
|
||||
fixQtBuiltinPaths . '*.pr?'
|
||||
'';
|
||||
|
||||
dontWrapQtApps = args.dontWrapQtApps or true;
|
||||
|
||||
postFixup = ''
|
||||
if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
|
||||
find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
|
||||
|
||||
Reference in New Issue
Block a user