From e0d03c43bf2deb01b27a61154560df8576f305eb Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 30 May 2016 16:29:41 -0500 Subject: [PATCH 1/3] qt56: make symlink farm for CMake builds like QMake --- .../libraries/qt-5/5.6/default.nix | 4 +- .../libraries/qt-5/5.6/qmake-hook.sh | 101 ++---------------- .../libraries/qt-5/5.6/qtbase/default.nix | 4 +- .../libraries/qt-5/5.6/qtbase/setup-hook.sh | 79 ++++++++++++++ .../libraries/qt-5/5.6/setup-hook.sh | 7 ++ 5 files changed, 98 insertions(+), 97 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.6/setup-hook.sh diff --git a/pkgs/development/libraries/qt-5/5.6/default.nix b/pkgs/development/libraries/qt-5/5.6/default.nix index 4aada4224dac..0d095517c568 100644 --- a/pkgs/development/libraries/qt-5/5.6/default.nix +++ b/pkgs/development/libraries/qt-5/5.6/default.nix @@ -52,6 +52,8 @@ let outputs = args.outputs or [ "dev" "out" ]; setOutputFlags = args.setOutputFlags or false; + setupHook = ./setup-hook.sh; + enableParallelBuilding = args.enableParallelBuilding or true; meta = self.qtbase.meta // (args.meta or {}); @@ -111,7 +113,7 @@ let ]; makeQtWrapper = makeSetupHook { deps = [ makeWrapper ]; } ./make-qt-wrapper.sh; - qmakeHook = makeSetupHook { substitutions = { qt_dev = qtbase.dev; lndir = pkgs.xorg.lndir; }; } ./qmake-hook.sh; + qmakeHook = makeSetupHook { deps = [ self.qtbase ]; } ./qmake-hook.sh; }; diff --git a/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh b/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh index 9fd4735209ce..696b4ea8dad3 100644 --- a/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh +++ b/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh @@ -1,48 +1,14 @@ -if [[ -z "$QMAKE" ]]; then +qmakeConfigurePhase() { + runHook preConfigure -_qtLinkDependencyDir() { - @lndir@/bin/lndir -silent "$1/$2" "$qtOut/$2" - if [ -n "$NIX_QT_SUBMODULE" ]; then - find "$1/$2" -printf "$2/%P\n" >> "$out/nix-support/qt-inputs" - fi + qmake PREFIX=$out $qmakeFlags + + runHook postConfigure } -_qtLinkModule() { - if [ -d "$1/mkspecs" ]; then - # $1 is a Qt module - _qtLinkDependencyDir "$1" mkspecs - - for dir in bin include lib share; do - if [ -d "$1/$dir" ]; then - _qtLinkDependencyDir "$1" "$dir" - fi - done - fi -} - -_qtRmModules() { - cat "$out/nix-support/qt-inputs" | while read file; do - if [ -h "$out/$file" ]; then - rm "$out/$file" - fi - done - - cat "$out/nix-support/qt-inputs" | while read file; do - if [ -d "$out/$file" ]; then - rmdir --ignore-fail-on-non-empty -p "$out/$file" - fi - done - - rm "$out/nix-support/qt-inputs" -} - -_qtRmQmake() { - rm "$qtOut/bin/qmake" "$qtOut/bin/qt.conf" -} - -_qtSetQmakePath() { - export PATH="$qtOut/bin${PATH:+:}$PATH" -} +if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then + configurePhase=qmakeConfigurePhase +fi _qtModuleMultioutDevsPre() { # We cannot simply set these paths in configureFlags because libQtCore retains @@ -65,63 +31,12 @@ _qtModuleMultioutDevsPost() { mkdir -p "${!outputDev}/$(dirname "$file")" mv "${!outputLib}/$file" "${!outputDev}/$file" done - - # Ensure that CMake can find the shared libraries - mkdir -p "${!outputDev}/lib" - @lndir@/bin/lndir -silent "${!outputLib}/lib" "${!outputDev}/lib" fi popd fi } -_qtRmQtOut() { - rm -fr "$qtOut" -} - -qmakeConfigurePhase() { - runHook preConfigure - - qmake PREFIX=$out $qmakeFlags - - runHook postConfigure -} - -qtOut="" -if [[ -z "$NIX_QT_SUBMODULE" ]]; then - qtOut=`mktemp -d` -else - qtOut=$out -fi - -mkdir -p "$qtOut/bin" "$qtOut/mkspecs" "$qtOut/include" "$qtOut/nix-support" "$qtOut/lib" "$qtOut/share" - -cp "@qt_dev@/bin/qmake" "$qtOut/bin" -cat >"$qtOut/bin/qt.conf" <> "$NIX_QT5_TMP/nix-support/qt-inputs" + done + + postHooks+=(_qtSetCMakePrefix) + + cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin" + echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs" + + cat >"$NIX_QT5_TMP/bin/qt.conf" <> "$NIX_QT5_TMP/nix-support/qt-inputs" + + export QMAKE="$NIX_QT5_TMP/bin/qmake" + + # Set PATH to find qmake first in a preConfigure hook + # It must run after all the envHooks! + postHooks+=(_qtSetQmakePath) +fi + +qt5LinkModuleDir() { + if [ -d "$1/$2" ]; then + @lndir@/bin/lndir -silent "$1/$2" "$NIX_QT5_TMP/$2" + find "$1/$2" -printf "$2/%P\n" >> "$NIX_QT5_TMP/nix-support/qt-inputs" + fi +} + +qt5LinkModuleDir @out@ "lib" + +qt5LinkModuleDir @dev@ "bin" +qt5LinkModuleDir @dev@ "include" +qt5LinkModuleDir @dev@ "lib" +qt5LinkModuleDir @dev@ "mkspecs" +qt5LinkModuleDir @dev@ "share" diff --git a/pkgs/development/libraries/qt-5/5.6/setup-hook.sh b/pkgs/development/libraries/qt-5/5.6/setup-hook.sh new file mode 100644 index 000000000000..212ac903eeeb --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.6/setup-hook.sh @@ -0,0 +1,7 @@ +qt5LinkModuleDir @out@ "lib" + +qt5LinkModuleDir @dev@ "bin" +qt5LinkModuleDir @dev@ "include" +qt5LinkModuleDir @dev@ "lib" +qt5LinkModuleDir @dev@ "mkspecs" +qt5LinkModuleDir @dev@ "share" From 7299f68a05c08714d4a32ee759ed264b4b459f6f Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 30 May 2016 16:30:06 -0500 Subject: [PATCH 2/3] qbittorrent: don't use qmakeHook Qt now configures QMake for all builds so there is no need to invoke `qmakeHook` just to get a working `qmake`. --- pkgs/applications/networking/p2p/qbittorrent/default.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/networking/p2p/qbittorrent/default.nix b/pkgs/applications/networking/p2p/qbittorrent/default.nix index 77624c0d9383..78f2c79923a4 100644 --- a/pkgs/applications/networking/p2p/qbittorrent/default.nix +++ b/pkgs/applications/networking/p2p/qbittorrent/default.nix @@ -17,15 +17,13 @@ stdenv.mkDerivation rec { sha256 = "1f4impsjck8anl39pwypsck7j6xw0dl18qd0b4xi23r45jvx9l60"; }; - nativeBuildInputs = [ pkgconfig which qmakeHook ]; + nativeBuildInputs = [ pkgconfig which ]; buildInputs = [ boost libtorrentRasterbar qt5.qtbase qt5.qttools ] ++ optional guiSupport dbus_libs; - dontUseQmakeConfigure = true; - preConfigure = '' - export QT_QMAKE="$qtOut/bin" + export QT_QMAKE=$(dirname "$QMAKE") ''; configureFlags = [ From a1facf33625de78723352ee36f9d18dfab9f5993 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 30 May 2016 16:30:58 -0500 Subject: [PATCH 3/3] qtox: run pre- and post-install hooks Fixes #15744. --- .../networking/instant-messengers/qtox/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/applications/networking/instant-messengers/qtox/default.nix b/pkgs/applications/networking/instant-messengers/qtox/default.nix index d244c4d11c41..50017de132c9 100644 --- a/pkgs/applications/networking/instant-messengers/qtox/default.nix +++ b/pkgs/applications/networking/instant-messengers/qtox/default.nix @@ -43,9 +43,13 @@ stdenv.mkDerivation rec { ''; installPhase = '' + runHook preInstall + mkdir -p $out/bin cp qtox $out/bin wrapQtProgram $out/bin/qtox + + runHook postInstall ''; enableParallelBuilding = true;