about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@secure.mailbox.org>2017-04-30 07:33:50 -0500
committerGitHub <noreply@github.com>2017-04-30 07:33:50 -0500
commit4e0d21edd189a1d925355aa1af6c96023b8535df (patch)
tree3eeeea88c1fc77acbc3c013b86b8010faf12ff6d /pkgs
parent5e3de3938e995beaa7f4c6c05a908254b390fdc0 (diff)
parent6fa2979ebcaa98be0d978474cfbaa68d8d19a896 (diff)
downloadnixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.tar
nixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.tar.gz
nixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.tar.bz2
nixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.tar.lz
nixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.tar.xz
nixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.tar.zst
nixlib-4e0d21edd189a1d925355aa1af6c96023b8535df.zip
Merge pull request #25285 from ttuegel/qt--fix-plugin-paths
Qt: purify plugin paths, unify Linux and Darwin builders
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/display-managers/sddm/default.nix6
-rw-r--r--pkgs/build-support/kde/wrapper.nix6
-rw-r--r--pkgs/desktops/plasma-5/default.nix2
-rw-r--r--pkgs/desktops/plasma-5/kwin/default.nix8
-rw-r--r--pkgs/desktops/plasma-5/libkscreen.nix15
-rw-r--r--pkgs/desktops/plasma-5/libkscreen/default.nix19
-rw-r--r--pkgs/desktops/plasma-5/libkscreen/libkscreen-backends-path.patch27
-rw-r--r--pkgs/desktops/plasma-5/libkscreen/series1
-rw-r--r--pkgs/development/libraries/kde-frameworks/default.nix2
-rw-r--r--pkgs/development/libraries/kde-frameworks/kinit/default.nix10
-rw-r--r--pkgs/development/libraries/kde-frameworks/kinit/kdeinit-extra_libs.patch49
-rw-r--r--pkgs/development/libraries/kde-frameworks/kinit/kinit-libpath.patch13
-rw-r--r--pkgs/development/libraries/kde-frameworks/kinit/series1
-rw-r--r--pkgs/development/libraries/kde-frameworks/kwindowsystem/default.nix (renamed from pkgs/development/libraries/kde-frameworks/kwindowsystem.nix)6
-rw-r--r--pkgs/development/libraries/kde-frameworks/kwindowsystem/platform-plugins-path.patch22
-rw-r--r--pkgs/development/libraries/kde-frameworks/kwindowsystem/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/nix-profiles-library-paths.patch22
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths-darwin.patch384
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths.patch180
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/compose-search-path.patch14
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/decrypt-ssl-traffic.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/default.nix356
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-dbus.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-gl.patch16
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-libXcursor.patch15
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-openssl.patch26
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-resolv.patch18
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/libressl.patch10
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/mkspecs-libgl.patch15
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/nix-profiles-library-paths.patch22
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/qnativesocketengine-type-pun.patch14
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/qpa-plugin-path.patch15
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/series8
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/tzdir.patch21
-rw-r--r--pkgs/development/libraries/qt-5/5.8/qtbase/xdg-config-dirs.patch14
-rw-r--r--pkgs/development/libraries/qt-5/make-qt-wrapper.sh12
-rw-r--r--pkgs/top-level/all-packages.nix47
38 files changed, 552 insertions, 872 deletions
diff --git a/pkgs/applications/display-managers/sddm/default.nix b/pkgs/applications/display-managers/sddm/default.nix
index f675febafb56..d1f487b37acf 100644
--- a/pkgs/applications/display-managers/sddm/default.nix
+++ b/pkgs/applications/display-managers/sddm/default.nix
@@ -25,6 +25,12 @@ let
       })
     ];
 
+    postPatch =
+      # Module Qt5::Test must be included in `find_package` before it is used.
+      ''
+        sed -i CMakeLists.txt -e '/find_package(Qt5/ s|)| Test)|'
+      '';
+
     nativeBuildInputs = [ cmake extra-cmake-modules pkgconfig qttools ];
 
     buildInputs = [
diff --git a/pkgs/build-support/kde/wrapper.nix b/pkgs/build-support/kde/wrapper.nix
index 228eb696bd9a..4442b111d790 100644
--- a/pkgs/build-support/kde/wrapper.nix
+++ b/pkgs/build-support/kde/wrapper.nix
@@ -48,9 +48,9 @@ stdenv.mkDerivation {
                     --suffix PATH : "$env/bin" \
                     --prefix XDG_CONFIG_DIRS : "$env/etc/xdg" \
                     --prefix XDG_DATA_DIRS : "$env/share:${gtk3}/share/gsettings-schemas/${gtk3.name}" \
-                    --set QML_IMPORT_PATH "$env/lib/qt5/imports" \
-                    --set QML2_IMPORT_PATH "$env/lib/qt5/qml" \
-                    --set QT_PLUGIN_PATH "$env/lib/qt5/plugins" \
+                    --prefix QML_IMPORT_PATH : "$env/lib/qt5/imports" \
+                    --prefix QML2_IMPORT_PATH : "$env/lib/qt5/qml" \
+                    --prefix QT_PLUGIN_PATH : "$env/lib/qt5/plugins" \
                     --prefix GIO_EXTRA_MODULES : "${dconf.lib}/lib/gio/modules"
                 good="1"
                 break
diff --git a/pkgs/desktops/plasma-5/default.nix b/pkgs/desktops/plasma-5/default.nix
index 0cb25a315d6e..1a8f1ed064b0 100644
--- a/pkgs/desktops/plasma-5/default.nix
+++ b/pkgs/desktops/plasma-5/default.nix
@@ -62,7 +62,7 @@ let
       kwayland-integration = callPackage ./kwayland-integration.nix {};
       kwin = callPackage ./kwin {};
       kwrited = callPackage ./kwrited.nix {};
-      libkscreen = callPackage ./libkscreen.nix {};
+      libkscreen = callPackage ./libkscreen {};
       libksysguard = callPackage ./libksysguard {};
       milou = callPackage ./milou.nix {};
       oxygen = callPackage ./oxygen.nix {};
diff --git a/pkgs/desktops/plasma-5/kwin/default.nix b/pkgs/desktops/plasma-5/kwin/default.nix
index 01f90664276e..a14b6433a76e 100644
--- a/pkgs/desktops/plasma-5/kwin/default.nix
+++ b/pkgs/desktops/plasma-5/kwin/default.nix
@@ -30,4 +30,12 @@ plasmaPackage {
         --subst-var-by xwayland ${lib.getBin xwayland}/bin/Xwayland
   '';
   cmakeFlags = [ "-DCMAKE_SKIP_BUILD_RPATH=OFF" ];
+  postInstall = ''
+    # Some package(s) refer to these service types by the wrong name.
+    # I would prefer to patch those packages, but I cannot find them!
+    ln -s $out/share/kservicetypes5/kwineffect.desktop \
+          $out/share/kservicetypes5/kwin-effect.desktop
+    ln -s $out/share/kservicetypes5/kwinscript.desktop \
+          $out/share/kservicetypes5/kwin-script.desktop
+  '';
 }
diff --git a/pkgs/desktops/plasma-5/libkscreen.nix b/pkgs/desktops/plasma-5/libkscreen.nix
deleted file mode 100644
index 4e04fd5ed1d9..000000000000
--- a/pkgs/desktops/plasma-5/libkscreen.nix
+++ /dev/null
@@ -1,15 +0,0 @@
-{ plasmaPackage
-, extra-cmake-modules
-, kwayland, libXrandr
-, qtx11extras
-}:
-
-plasmaPackage {
-  name = "libkscreen";
-  nativeBuildInputs = [
-    extra-cmake-modules
-  ];
-  propagatedBuildInputs = [
-    kwayland libXrandr qtx11extras
-  ];
-}
diff --git a/pkgs/desktops/plasma-5/libkscreen/default.nix b/pkgs/desktops/plasma-5/libkscreen/default.nix
new file mode 100644
index 000000000000..afb2c20e90cc
--- /dev/null
+++ b/pkgs/desktops/plasma-5/libkscreen/default.nix
@@ -0,0 +1,19 @@
+{ plasmaPackage, lib, copyPathsToStore
+, extra-cmake-modules
+, kwayland, libXrandr
+, qtx11extras
+}:
+
+plasmaPackage {
+  name = "libkscreen";
+  nativeBuildInputs = [
+    extra-cmake-modules
+  ];
+  propagatedBuildInputs = [
+    kwayland libXrandr qtx11extras
+  ];
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  preConfigure = ''
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_LIBKSCREEN_BACKENDS=\"''${!outputLib}/lib/qt5/plugins/kf5/kscreen\""
+  '';
+}
diff --git a/pkgs/desktops/plasma-5/libkscreen/libkscreen-backends-path.patch b/pkgs/desktops/plasma-5/libkscreen/libkscreen-backends-path.patch
new file mode 100644
index 000000000000..9d3cf49b9cd1
--- /dev/null
+++ b/pkgs/desktops/plasma-5/libkscreen/libkscreen-backends-path.patch
@@ -0,0 +1,27 @@
+Index: libkscreen-5.9.4/src/backendmanager.cpp
+===================================================================
+--- libkscreen-5.9.4.orig/src/backendmanager.cpp
++++ libkscreen-5.9.4/src/backendmanager.cpp
+@@ -178,17 +178,11 @@ QFileInfo BackendManager::preferredBacke
+ QFileInfoList BackendManager::listBackends()
+ {
+     // Compile a list of installed backends first
+-    const QString backendFilter = QStringLiteral("KSC_*");
+-    const QStringList paths = QCoreApplication::libraryPaths();
+-    QFileInfoList finfos;
+-    for (const QString &path : paths) {
+-        const QDir dir(path + QLatin1String("/kf5/kscreen/"),
+-                       backendFilter,
+-                       QDir::SortFlags(QDir::QDir::Name),
+-                       QDir::NoDotAndDotDot | QDir::Files);
+-        finfos.append(dir.entryInfoList());
+-    }
+-    return finfos;
++    const QDir dir(QStringLiteral(NIXPKGS_LIBKSCREEN_BACKENDS),
++                   QStringLiteral("KSC_*"),
++                   QDir::SortFlags(QDir::QDir::Name),
++                   QDir::NoDotAndDotDot | QDir::Files);
++    return dir.entryInfoList();
+ }
+ 
+ KScreen::AbstractBackend *BackendManager::loadBackendPlugin(QPluginLoader *loader, const QString &name,
diff --git a/pkgs/desktops/plasma-5/libkscreen/series b/pkgs/desktops/plasma-5/libkscreen/series
new file mode 100644
index 000000000000..86bf4ab10602
--- /dev/null
+++ b/pkgs/desktops/plasma-5/libkscreen/series
@@ -0,0 +1 @@
+libkscreen-backends-path.patch
diff --git a/pkgs/development/libraries/kde-frameworks/default.nix b/pkgs/development/libraries/kde-frameworks/default.nix
index 2906dc788865..221fba628ba9 100644
--- a/pkgs/development/libraries/kde-frameworks/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/default.nix
@@ -96,7 +96,7 @@ let
       kwallet = callPackage ./kwallet.nix {};
       kwayland = callPackage ./kwayland.nix {};
       kwidgetsaddons = callPackage ./kwidgetsaddons.nix {};
-      kwindowsystem = callPackage ./kwindowsystem.nix {};
+      kwindowsystem = callPackage ./kwindowsystem {};
       kxmlgui = callPackage ./kxmlgui.nix {};
       kxmlrpcclient = callPackage ./kxmlrpcclient.nix {};
       modemmanager-qt = callPackage ./modemmanager-qt.nix {};
diff --git a/pkgs/development/libraries/kde-frameworks/kinit/default.nix b/pkgs/development/libraries/kde-frameworks/kinit/default.nix
index b965f761e922..f5cfa166e911 100644
--- a/pkgs/development/libraries/kde-frameworks/kinit/default.nix
+++ b/pkgs/development/libraries/kde-frameworks/kinit/default.nix
@@ -1,9 +1,12 @@
 {
   kdeFramework, lib, copyPathsToStore,
   extra-cmake-modules, kdoctools,
-  kconfig, kcrash, ki18n, kio, kservice, kwindowsystem
+  kconfig, kcrash, ki18n, kio, kparts, kservice, kwindowsystem, plasma-framework
 }:
 
+let
+  inherit (lib) getLib;
+in
 kdeFramework {
   name = "kinit";
   meta = { maintainers = [ lib.maintainers.ttuegel ]; };
@@ -12,4 +15,9 @@ kdeFramework {
     kconfig kcrash ki18n kio kservice kwindowsystem
   ];
   patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  NIX_CFLAGS_COMPILE = [
+    ''-DNIXPKGS_KF5_KIOCORE="${getLib kio}/lib/libKF5KIOCore.so.5"''
+    ''-DNIXPKGS_KF5_PARTS="${getLib kparts}/lib/libKF5Parts.so.5"''
+    ''-DNIXPKGS_KF5_PLASMA="${getLib plasma-framework}/lib/libKF5Plasma.so.5"''
+  ];
 }
diff --git a/pkgs/development/libraries/kde-frameworks/kinit/kdeinit-extra_libs.patch b/pkgs/development/libraries/kde-frameworks/kinit/kdeinit-extra_libs.patch
new file mode 100644
index 000000000000..75e632d41292
--- /dev/null
+++ b/pkgs/development/libraries/kde-frameworks/kinit/kdeinit-extra_libs.patch
@@ -0,0 +1,49 @@
+Index: kinit-5.32.0/src/kdeinit/kinit.cpp
+===================================================================
+--- kinit-5.32.0.orig/src/kdeinit/kinit.cpp
++++ kinit-5.32.0/src/kdeinit/kinit.cpp
+@@ -96,11 +96,9 @@ static const char *extra_libs[] = {
+     "libKF5Parts.5.dylib",
+     "libKF5Plasma.5.dylib"
+ #else
+-    "libKF5KIOCore.so.5",
+-    "libKF5Parts.so.5",
+-//#ifdef __KDE_HAVE_GCC_VISIBILITY // Removed for KF5, we'll see.
+-    "libKF5Plasma.so.5"
+-//#endif
++    NIXPKGS_KF5_KIOCORE,
++    NIXPKGS_KF5_PARTS,
++    NIXPKGS_KF5_PLASMA
+ #endif
+ };
+ #endif
+@@ -1533,20 +1531,6 @@ static int initXconnection()
+ }
+ #endif
+ 
+-#ifndef Q_OS_OSX
+-// Find a shared lib in the lib dir, e.g. libkio.so.
+-// Completely unrelated to plugins.
+-static QString findSharedLib(const QString &lib)
+-{
+-    QString path = QFile::decodeName(CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/") + lib;
+-    if (QFile::exists(path)) {
+-        return path;
+-    }
+-    // We could also look in LD_LIBRARY_PATH, but really, who installs the main libs in different prefixes?
+-    return QString();
+-}
+-#endif
+-
+ extern "C" {
+ 
+     static void secondary_child_handler(int)
+@@ -1692,7 +1676,7 @@ int main(int argc, char **argv)
+     if (!d.suicide && qEnvironmentVariableIsEmpty("KDE_IS_PRELINKED")) {
+         const int extrasCount = sizeof(extra_libs) / sizeof(extra_libs[0]);
+         for (int i = 0; i < extrasCount; i++) {
+-            const QString extra = findSharedLib(QString::fromLatin1(extra_libs[i]));
++            const QString extra = QString::fromLatin1(extra_libs[i]);
+             if (!extra.isEmpty()) {
+                 QLibrary l(extra);
+                 l.setLoadHints(QLibrary::ExportExternalSymbolsHint);
diff --git a/pkgs/development/libraries/kde-frameworks/kinit/kinit-libpath.patch b/pkgs/development/libraries/kde-frameworks/kinit/kinit-libpath.patch
index a5c76fca2481..b949723fb543 100644
--- a/pkgs/development/libraries/kde-frameworks/kinit/kinit-libpath.patch
+++ b/pkgs/development/libraries/kde-frameworks/kinit/kinit-libpath.patch
@@ -1,8 +1,8 @@
-Index: kinit-5.24.0/src/kdeinit/kinit.cpp
+Index: kinit-5.32.0/src/kdeinit/kinit.cpp
 ===================================================================
---- kinit-5.24.0.orig/src/kdeinit/kinit.cpp
-+++ kinit-5.24.0/src/kdeinit/kinit.cpp
-@@ -672,19 +672,16 @@ static pid_t launch(int argc, const char
+--- kinit-5.32.0.orig/src/kdeinit/kinit.cpp
++++ kinit-5.32.0/src/kdeinit/kinit.cpp
+@@ -623,19 +623,15 @@ static pid_t launch(int argc, const char
  
          if (!libpath.isEmpty()) {
              if (libpath_relative) {
@@ -23,10 +23,9 @@ Index: kinit-5.24.0/src/kdeinit/kinit.cpp
 +                QByteArrayList profiles = qgetenv("NIX_PROFILES").split(' ');
 +                // Reverse the profile list.
 +                std::reverse(profiles.begin(), profiles.end());
-+                const QString libdir = QString::fromLatin1("/lib/");
-+                Q_FOREACH (const QByteArray &profile, profiles) {
++                for (const QByteArray &profile: profiles) {
 +                    if (!profile.isEmpty()) {
-+                        l.setFileName(QFile::decodeName(profile) + libdir + libpath);
++                        l.setFileName(QFile::decodeName(profile) + QStringLiteral("/lib/") + libpath);
 +                        if (l.load()) break;
 +                    }
                  }
diff --git a/pkgs/development/libraries/kde-frameworks/kinit/series b/pkgs/development/libraries/kde-frameworks/kinit/series
index 576b8a935bf1..9195a4e8e6b0 100644
--- a/pkgs/development/libraries/kde-frameworks/kinit/series
+++ b/pkgs/development/libraries/kde-frameworks/kinit/series
@@ -1,2 +1,3 @@
 kinit-libpath.patch
 start_kdeinit-path.patch
+kdeinit-extra_libs.patch
diff --git a/pkgs/development/libraries/kde-frameworks/kwindowsystem.nix b/pkgs/development/libraries/kde-frameworks/kwindowsystem/default.nix
index 4bfd813ff932..8a91bdbac528 100644
--- a/pkgs/development/libraries/kde-frameworks/kwindowsystem.nix
+++ b/pkgs/development/libraries/kde-frameworks/kwindowsystem/default.nix
@@ -1,5 +1,5 @@
 {
-  kdeFramework, lib,
+  kdeFramework, lib, copyPathsToStore,
   extra-cmake-modules,
   qtbase, qttools, qtx11extras
 }:
@@ -12,4 +12,8 @@ kdeFramework {
   };
   nativeBuildInputs = [ extra-cmake-modules qttools ];
   propagatedBuildInputs = [ qtx11extras ];
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  preConfigure = ''
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PATH=\"$out/lib/qt5/plugins\""
+  '';
 }
diff --git a/pkgs/development/libraries/kde-frameworks/kwindowsystem/platform-plugins-path.patch b/pkgs/development/libraries/kde-frameworks/kwindowsystem/platform-plugins-path.patch
new file mode 100644
index 000000000000..ed24897d342a
--- /dev/null
+++ b/pkgs/development/libraries/kde-frameworks/kwindowsystem/platform-plugins-path.patch
@@ -0,0 +1,22 @@
+Index: kwindowsystem-5.32.0/src/pluginwrapper.cpp
+===================================================================
+--- kwindowsystem-5.32.0.orig/src/pluginwrapper.cpp
++++ kwindowsystem-5.32.0/src/pluginwrapper.cpp
+@@ -37,14 +37,9 @@ Q_GLOBAL_STATIC(KWindowSystemPluginWrapp
+ static QStringList pluginCandidates()
+ {
+     QStringList ret;
+-    foreach (const QString &path, QCoreApplication::libraryPaths()) {
+-        QDir pluginDir(path + QLatin1Literal("/kf5/org.kde.kwindowsystem.platforms"));
+-        if (!pluginDir.exists()) {
+-            continue;
+-        }
+-        foreach (const QString &entry, pluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) {
+-            ret << pluginDir.absoluteFilePath(entry);
+-        }
++    QDir pluginDir(QStringLiteral(NIXPKGS_QT_PLUGIN_PATH) + QLatin1Literal("/kf5/org.kde.kwindowsystem.platforms"));
++    foreach (const QString &entry, pluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) {
++        ret << pluginDir.absoluteFilePath(entry);
+     }
+     return ret;
+ }
diff --git a/pkgs/development/libraries/kde-frameworks/kwindowsystem/series b/pkgs/development/libraries/kde-frameworks/kwindowsystem/series
new file mode 100644
index 000000000000..2cd02056ff81
--- /dev/null
+++ b/pkgs/development/libraries/kde-frameworks/kwindowsystem/series
@@ -0,0 +1 @@
+platform-plugins-path.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/nix-profiles-library-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/nix-profiles-library-paths.patch
deleted file mode 100644
index d454a74109ae..000000000000
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/nix-profiles-library-paths.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Index: qtbase-opensource-src-5.6.0/src/corelib/kernel/qcoreapplication.cpp
-===================================================================
---- qtbase-opensource-src-5.6.0.orig/src/corelib/kernel/qcoreapplication.cpp
-+++ qtbase-opensource-src-5.6.0/src/corelib/kernel/qcoreapplication.cpp
-@@ -2533,7 +2533,17 @@ QStringList QCoreApplication::libraryPat
-         QStringList *app_libpaths = new QStringList;
-         coreappdata()->app_libpaths.reset(app_libpaths);
- 
-+        // Add library paths derived from NIX_PROFILES.
-+        const QByteArrayList profiles = qgetenv("NIX_PROFILES").split(' ');
-+        const QString plugindir = QString::fromLatin1("/lib/qt5/plugins");
-+        Q_FOREACH (const QByteArray &profile, profiles) {
-+            if (!profile.isEmpty()) {
-+                app_libpaths->append(QFile::decodeName(profile) + plugindir);
-+            }
-+        }
-+
-         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
-+        qunsetenv("QT_PLUGIN_PATH"); // do not propagate to child processes
-         if (!libPathEnv.isEmpty()) {
-             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
-             for (QStringList::const_iterator it = paths.constBegin(); it != paths.constEnd(); ++it) {
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/series b/pkgs/development/libraries/qt-5/5.6/qtbase/series
index 2196d8383752..9ef8c998c661 100644
--- a/pkgs/development/libraries/qt-5/5.6/qtbase/series
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/series
@@ -4,6 +4,5 @@ dlopen-libXcursor.patch
 dlopen-openssl.patch
 dlopen-dbus.patch
 xdg-config-dirs.patch
-nix-profiles-library-paths.patch
 compose-search-path.patch
 libressl.patch
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths-darwin.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths-darwin.patch
deleted file mode 100644
index da7f36542ef9..000000000000
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths-darwin.patch
+++ /dev/null
@@ -1,384 +0,0 @@
-Index: qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-+++ qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-@@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
- endif()
- !!ENDIF
-
--!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
--!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ELSE
--get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
--# Use original install prefix when loaded through a
--# cross-prefix symbolic link such as /lib -> /usr/lib.
--get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
--get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5$${CMAKE_MODULE_NAME}\" REALPATH)
--if(_realCurr STREQUAL _realOrig)
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
--else()
--    get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--endif()
--unset(_realOrig)
--unset(_realCurr)
--unset(_IMPORT_PREFIX)
--!!ENDIF
--!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--get_filename_component(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
--!!ELSE
--set(_qt5$${CMAKE_MODULE_NAME}_install_prefix \"$$[QT_INSTALL_PREFIX]\")
--!!ENDIF
--
- !!IF !equals(TEMPLATE, aux)
- # For backwards compatibility only. Use Qt5$${CMAKE_MODULE_NAME}_VERSION instead.
- set(Qt5$${CMAKE_MODULE_NAME}_VERSION_STRING "$$eval(QT.$${MODULE}.MAJOR_VERSION).$$eval(QT.$${MODULE}.MINOR_VERSION).$$eval(QT.$${MODULE}.PATCH_VERSION)")
-@@ -59,7 +35,10 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-     set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
-
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    if(NOT EXISTS \"${imported_location}\")
-+        set(imported_location \"@NIX_DEV@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    endif()
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
-@@ -74,45 +53,17 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
-         \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
-     )
-
--!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ELSE
--    set(imported_implib \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
--!!ENDIF
--    _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_implib})
--    if(NOT \"${IMPLIB_LOCATION}\" STREQUAL \"\")
--        set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES
--        \"IMPORTED_IMPLIB_${Configuration}\" ${imported_implib}
--        )
--    endif()
--!!ENDIF
- endmacro()
- !!ENDIF
-
- if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
-
- !!IF !no_module_headers
--!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
--      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
--    )
--!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
--    )
--!!ELSE
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
--!!ENDIF
--!!ELSE
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
-+    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"@NIX_OUT@/lib\" \"@NIX_OUT@/lib/$${MODULE_INCNAME}.framework/Headers\")
- !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION\"
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}/$$VERSION/$${MODULE_INCNAME}\"
-+        \"\"
-     )
- !!ELSE
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
-@@ -128,7 +80,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
- !!ENDIF
- !!ENDIF
--!!ENDIF
-+
- !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
-     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
- !!ENDIF
-@@ -253,28 +205,19 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
- !!IF isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
- !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_DEBUG_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -282,36 +225,23 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!ENDIF // CMAKE_RELEASE_TYPE
-
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--    _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE
-     _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
- !!IF isEmpty(CMAKE_RELEASE_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
-     if (EXISTS
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
-+        \"@NIX_OUT@/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ELSE
-         \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
- !!ENDIF
-       AND EXISTS
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
-+        \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ELSE
-         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
- !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_RELEASE_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -328,11 +258,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
-         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
-
--!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
--        set(imported_location \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ELSE
--        set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
--!!ENDIF
-+        set(imported_location \"${PLUGIN_LOCATION}\")
-         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
-         set_target_properties(Qt5::${Plugin} PROPERTIES
-             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
-Index: qtbase-opensource-src-5.8.0/src/gui/Qt5GuiConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/gui/Qt5GuiConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.8.0/src/gui/Qt5GuiConfigExtras.cmake.in
-@@ -2,7 +2,7 @@
- !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
-
- !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
--set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR/QtANGLE\")
-+set(Qt5Gui_EGL_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ELSE
- set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR/QtANGLE\")
- !!ENDIF
-@@ -17,13 +17,13 @@ macro(_populate_qt5gui_gl_target_propert
-     set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
-
- !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Gui_install_prefix}/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
-+    set(imported_location \"@NIX_OUT@/$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
- !!ENDIF
-
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_implib \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
-+    set(imported_implib \"@NIX_DEV@/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ELSE
-     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.8.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.8.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
-     add_executable(Qt5::uic IMPORTED)
-
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/corelib/Qt5CoreConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
-     add_executable(Qt5::qmake IMPORTED)
-
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::moc)
-     add_executable(Qt5::moc IMPORTED)
-
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -35,7 +35,7 @@ if (NOT TARGET Qt5::rcc)
-     add_executable(Qt5::rcc IMPORTED)
-
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -131,7 +131,7 @@ if (NOT TARGET Qt5::WinMain)
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
- !!ENDIF
-@@ -145,7 +145,7 @@ if (NOT TARGET Qt5::WinMain)
-     set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
-
- !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ELSE
-     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-+++ qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-@@ -1,6 +1,6 @@
-
- !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-+++ qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-@@ -1,6 +1,6 @@
-
- !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
--set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
-+set(_qt5_corelib_extra_includes \"@NIX_DEV@/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
- !!ELSE
- set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
- !!ENDIF
-Index: qtbase-opensource-src-5.8.0/src/dbus/Qt5DBusConfigExtras.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/src/dbus/Qt5DBusConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.8.0/src/dbus/Qt5DBusConfigExtras.cmake.in
-@@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qdbuscpp2xml)
-     add_executable(Qt5::qdbuscpp2xml IMPORTED)
-
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-@@ -18,7 +18,7 @@ if (NOT TARGET Qt5::qdbusxml2cpp)
-     add_executable(Qt5::qdbusxml2cpp IMPORTED)
-
- !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
--    set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
-+    set(imported_location \"@NIX_DEV@/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ELSE
-     set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
- !!ENDIF
-Index: qtbase-opensource-src-5.8.0/mkspecs/features/create_cmake.prf
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/mkspecs/features/create_cmake.prf
-+++ qtbase-opensource-src-5.8.0/mkspecs/features/create_cmake.prf
-@@ -136,28 +136,28 @@ contains(CONFIG, plugin) {
-
-     win32 {
-         isEmpty(CMAKE_STATIC_TYPE) {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.dll
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.dll
-         } else:mingw {
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}/$$PLUGIN_TYPE/lib$${TARGET}.a
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}d.a
-         } else {                         # MSVC static
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}.lib
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/$${TARGET}d.lib
-         }
-     } else {
-         mac {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
-             else: CMAKE_PlUGIN_EXT = .a
-
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         } else {
-             isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
-             else: CMAKE_PlUGIN_EXT = .a
-
--            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
--            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-+            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
-         }
-     }
-     cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
-Index: qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-===================================================================
---- qtbase-opensource-src-5.8.0.orig/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-+++ qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-@@ -2,10 +2,10 @@
- add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
-
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
- !!ENDIF
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
- !!ENDIF
-
- list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths.patch
index 0d5c2d510929..c43653558e32 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/cmake-paths.patch
@@ -1,7 +1,7 @@
-Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+Index: qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
-+++ qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
 @@ -9,30 +9,6 @@ if (CMAKE_VERSION VERSION_LESS 3.0.0)
  endif()
  !!ENDIF
@@ -45,7 +45,7 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cm
  !!ELSE
      set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
  !!ENDIF
-@@ -74,45 +53,18 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
+@@ -74,19 +53,6 @@ macro(_populate_$${CMAKE_MODULE_NAME}_ta
          \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
      )
  
@@ -65,23 +65,26 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cm
  endmacro()
  !!ENDIF
  
- if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
- 
+@@ -95,24 +61,24 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
  !!IF !no_module_headers
--!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
--    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
+ !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
+     set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS
 -      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
 -      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
--    )
--!!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
++      \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework\"
++      \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Headers\"
+     )
+ !!IF isEmpty(CMAKE_NO_PRIVATE_INCLUDES)
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS
 -        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
 -        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
--    )
--!!ELSE
--    set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
--!!ENDIF
--!!ELSE
++        \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
++        \"@NIX_OUT@/$${CMAKE_LIB_DIR}Qt$${CMAKE_MODULE_NAME}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+     )
+ !!ELSE
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+ !!ENDIF
+ !!ELSE
  !!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE)
 -    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
 +    set(_Qt5$${CMAKE_MODULE_NAME}_OWN_INCLUDE_DIRS \"@NIX_DEV@/$$CMAKE_INCLUDE_DIR\" \"@NIX_DEV@/$${CMAKE_INCLUDE_DIR}$${MODULE_INCNAME}\")
@@ -94,27 +97,17 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cm
      )
  !!ELSE
      set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
-@@ -128,7 +80,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
-     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
- !!ENDIF
- !!ENDIF
--!!ENDIF
-+
- !!IF !isEmpty(CMAKE_ADD_SOURCE_INCLUDE_DIRS)
-     include(\"${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake\" OPTIONAL)
- !!ENDIF
-@@ -253,28 +205,19 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- 
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+@@ -255,7 +221,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
  !!IF isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
 -    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
++    if (EXISTS \"@NIX_OUT@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+ !!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+@@ -263,13 +229,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
      if (EXISTS
  !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
 -        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_DEBUG}\"
@@ -129,31 +122,17 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cm
  !!ELSE
          \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
  !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_DEBUG_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -282,36 +225,23 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
- !!ENDIF // CMAKE_RELEASE_TYPE
- 
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--    _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" \"\" )
--!!ELSE
-     _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
- 
- !!IF !isEmpty(CMAKE_FIND_OTHER_LIBRARY_BUILD)
+@@ -292,7 +258,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
  !!IF isEmpty(CMAKE_RELEASE_TYPE)
--!!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
--!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+ !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD)
+ !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
 -    if (EXISTS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
--    if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
--        _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" )
--!!ELSE // CMAKE_STATIC_WINDOWS_BUILD
++    if (EXISTS \"@NIX_DEV@/$${CMAKE_LIB_DIR}$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ELSE // CMAKE_LIB_DIR_IS_ABSOLUTE
+     if (EXISTS \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+ !!ENDIF // CMAKE_LIB_DIR_IS_ABSOLUTE
+@@ -300,13 +266,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
+ !!ELSE // CMAKE_STATIC_WINDOWS_BUILD
      if (EXISTS
  !!IF isEmpty(CMAKE_DLL_DIR_IS_ABSOLUTE)
 -        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_DLL_DIR}$${CMAKE_LIB_FILE_LOCATION_RELEASE}\"
@@ -168,12 +147,7 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cm
  !!ELSE
          \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
  !!ENDIF
-         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
--!!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
-     endif()
- !!ENDIF // CMAKE_RELEASE_TYPE
- !!ENDIF // CMAKE_FIND_OTHER_LIBRARY_BUILD
-@@ -328,11 +258,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
+@@ -328,11 +294,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME
      macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
          set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
  
@@ -186,10 +160,10 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5BasicConfig.cm
          _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
          set_target_properties(Qt5::${Plugin} PROPERTIES
              \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
-Index: qtbase-opensource-src-5.7.0/src/gui/Qt5GuiConfigExtras.cmake.in
+Index: qtbase-opensource-src-5.8.0/src/gui/Qt5GuiConfigExtras.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/gui/Qt5GuiConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.7.0/src/gui/Qt5GuiConfigExtras.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/src/gui/Qt5GuiConfigExtras.cmake.in
++++ qtbase-opensource-src-5.8.0/src/gui/Qt5GuiConfigExtras.cmake.in
 @@ -2,7 +2,7 @@
  !!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE)
  
@@ -215,10 +189,10 @@ Index: qtbase-opensource-src-5.7.0/src/gui/Qt5GuiConfigExtras.cmake.in
  !!ELSE
      set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
  !!ENDIF
-Index: qtbase-opensource-src-5.7.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+Index: qtbase-opensource-src-5.8.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/widgets/Qt5WidgetsConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.7.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/src/widgets/Qt5WidgetsConfigExtras.cmake.in
++++ qtbase-opensource-src-5.8.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
 @@ -3,7 +3,7 @@ if (NOT TARGET Qt5::uic)
      add_executable(Qt5::uic IMPORTED)
  
@@ -228,10 +202,10 @@ Index: qtbase-opensource-src-5.7.0/src/widgets/Qt5WidgetsConfigExtras.cmake.in
  !!ELSE
      set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
  !!ENDIF
-Index: qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtras.cmake.in
+Index: qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtras.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/Qt5CoreConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtras.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtras.cmake.in
 @@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qmake)
      add_executable(Qt5::qmake IMPORTED)
  
@@ -277,10 +251,10 @@ Index: qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtras.cmake.in
  !!ELSE
      set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
  !!ENDIF
-Index: qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+Index: qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
-+++ qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
++++ qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
 @@ -1,6 +1,6 @@
  
  !!IF isEmpty(CMAKE_INSTALL_DATA_DIR_IS_ABSOLUTE)
@@ -289,10 +263,10 @@ Index: qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtrasMkspecDirForIn
  !!ELSE
  set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
  !!ENDIF
-Index: qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+Index: qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
-+++ qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
++++ qtbase-opensource-src-5.8.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
 @@ -1,6 +1,6 @@
  
  !!IF isEmpty(CMAKE_HOST_DATA_DIR_IS_ABSOLUTE)
@@ -301,10 +275,10 @@ Index: qtbase-opensource-src-5.7.0/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmak
  !!ELSE
  set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
  !!ENDIF
-Index: qtbase-opensource-src-5.7.0/src/dbus/Qt5DBusConfigExtras.cmake.in
+Index: qtbase-opensource-src-5.8.0/src/dbus/Qt5DBusConfigExtras.cmake.in
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/dbus/Qt5DBusConfigExtras.cmake.in
-+++ qtbase-opensource-src-5.7.0/src/dbus/Qt5DBusConfigExtras.cmake.in
+--- qtbase-opensource-src-5.8.0.orig/src/dbus/Qt5DBusConfigExtras.cmake.in
++++ qtbase-opensource-src-5.8.0/src/dbus/Qt5DBusConfigExtras.cmake.in
 @@ -3,7 +3,7 @@ if (NOT TARGET Qt5::qdbuscpp2xml)
      add_executable(Qt5::qdbuscpp2xml IMPORTED)
  
@@ -323,10 +297,27 @@ Index: qtbase-opensource-src-5.7.0/src/dbus/Qt5DBusConfigExtras.cmake.in
  !!ELSE
      set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
  !!ENDIF
-Index: qtbase-opensource-src-5.7.0/mkspecs/features/create_cmake.prf
+Index: qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+===================================================================
+--- qtbase-opensource-src-5.8.0.orig/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
++++ qtbase-opensource-src-5.8.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+@@ -2,10 +2,10 @@
+ add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
+ 
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
++_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
+ !!ENDIF
+ !!IF !isEmpty(CMAKE_DEBUG_TYPE)
+-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
++_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
+ !!ENDIF
+ 
+ list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
+Index: qtbase-opensource-src-5.8.0/mkspecs/features/create_cmake.prf
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/mkspecs/features/create_cmake.prf
-+++ qtbase-opensource-src-5.7.0/mkspecs/features/create_cmake.prf
+--- qtbase-opensource-src-5.8.0.orig/mkspecs/features/create_cmake.prf
++++ qtbase-opensource-src-5.8.0/mkspecs/features/create_cmake.prf
 @@ -136,28 +136,28 @@ contains(CONFIG, plugin) {
  
      win32 {
@@ -338,7 +329,7 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/create_cmake.prf
          } else:mingw {
 -            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
 -            CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
-+            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}/$$PLUGIN_TYPE/lib$${TARGET}.a
++            CMAKE_PLUGIN_LOCATION_RELEASE = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}.a
 +            CMAKE_PLUGIN_LOCATION_DEBUG = $${CMAKE_PLUGIN_DIR}$$PLUGIN_TYPE/lib$${TARGET}d.a
          } else {                         # MSVC static
 -            CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
@@ -366,20 +357,3 @@ Index: qtbase-opensource-src-5.7.0/mkspecs/features/create_cmake.prf
          }
      }
      cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
-Index: qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-===================================================================
---- qtbase-opensource-src-5.7.0.orig/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-+++ qtbase-opensource-src-5.7.0/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
-@@ -2,10 +2,10 @@
- add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
- 
- !!IF !isEmpty(CMAKE_RELEASE_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
- !!ENDIF
- !!IF !isEmpty(CMAKE_DEBUG_TYPE)
--_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
-+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"@NIX_OUT@/$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
- !!ENDIF
- 
- list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/compose-search-path.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/compose-search-path.patch
index a0e344a7bc68..d0bea4afaa32 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/compose-search-path.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/compose-search-path.patch
@@ -1,16 +1,18 @@
-Index: qtbase-opensource-src-5.7.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+Index: qtbase-opensource-src-5.8.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-+++ qtbase-opensource-src-5.7.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
-@@ -257,10 +257,7 @@ void TableGenerator::initPossibleLocatio
-     // the QTCOMPOSE environment variable
+--- qtbase-opensource-src-5.8.0.orig/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
++++ qtbase-opensource-src-5.8.0/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+@@ -258,12 +258,9 @@ void TableGenerator::initPossibleLocatio
+     m_possibleLocations.reserve(7);
      if (qEnvironmentVariableIsSet("QTCOMPOSE"))
          m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
 -    m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
 -    m_possibleLocations.append(QStringLiteral("/usr/local/share/X11/locale"));
 -    m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale"));
 -    m_possibleLocations.append(QStringLiteral("/usr/local/lib/X11/locale"));
-+    m_possibleLocations.append(QStringLiteral("${libX11}/share/X11/locale"));
      m_possibleLocations.append(QStringLiteral(X11_PREFIX "/share/X11/locale"));
      m_possibleLocations.append(QStringLiteral(X11_PREFIX "/lib/X11/locale"));
++    m_possibleLocations.append(QStringLiteral(NIXPKGS_QTCOMPOSE));
  }
+ 
+ QString TableGenerator::findComposeFile()
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/decrypt-ssl-traffic.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/decrypt-ssl-traffic.patch
deleted file mode 100644
index 495db07cfbb5..000000000000
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/decrypt-ssl-traffic.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: qtbase-opensource-src-5.5.1/src/network/ssl/qsslsocket_openssl.cpp
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/src/network/ssl/qsslsocket_openssl.cpp
-+++ qtbase-opensource-src-5.5.1/src/network/ssl/qsslsocket_openssl.cpp
-@@ -48,7 +48,7 @@
- ****************************************************************************/
- 
- //#define QSSLSOCKET_DEBUG
--//#define QT_DECRYPT_SSL_TRAFFIC
-+#define QT_DECRYPT_SSL_TRAFFIC
- 
- #include "qssl_p.h"
- #include "qsslsocket_openssl_p.h"
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/default.nix b/pkgs/development/libraries/qt-5/5.8/qtbase/default.nix
index be35032785d9..e11d9dd1f29b 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/default.nix
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/default.nix
@@ -34,13 +34,52 @@ stdenv.mkDerivation {
   name = "qtbase-${version}";
   inherit src version;
 
+  propagatedBuildInputs =
+    [
+      libxml2 libxslt openssl pcre16 sqlite zlib
+
+      # Text rendering
+      harfbuzz icu
+
+      # Image formats
+      libjpeg libpng libtiff
+    ]
+
+    ++ lib.optional mesaSupported mesa
+
+    ++ lib.optionals (!stdenv.isDarwin) [
+      dbus glib udev
+
+      # Text rendering
+      fontconfig freetype
+
+      # X11 libs
+      libX11 libXcomposite libXext libXi libXrender libxcb libxkbcommon xcbutil
+      xcbutilimage xcbutilkeysyms xcbutilrenderutil xcbutilwm
+    ]
+
+    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
+      AGL AppKit ApplicationServices Carbon Cocoa
+      CoreAudio CoreBluetooth CoreLocation CoreServices
+      DiskArbitration Foundation OpenGL
+      darwin.cf-private darwin.apple_sdk.sdk darwin.libobjc libiconv
+    ]);
+
+  buildInputs = [ ]
+    ++ lib.optionals (!stdenv.isDarwin) [ gtk3 libinput ]
+    ++ lib.optional developerBuild gdb
+    ++ lib.optional (cups != null) cups
+    ++ lib.optional (mysql != null) mysql.lib
+    ++ lib.optional (postgresql != null) postgresql;
+
+  nativeBuildInputs =
+    [ bison flex gperf lndir perl pkgconfig python2 ]
+    ++ lib.optional (!stdenv.isDarwin) patchelf;
+
   outputs = [ "out" "dev" ];
 
   patches =
-    copyPathsToStore (lib.readPathsFromFile ./. ./series)
-    ++ [(if stdenv.isDarwin then ./cmake-paths-darwin.patch else ./cmake-paths.patch)]
-    ++ lib.optional decryptSslTraffic ./decrypt-ssl-traffic.patch
-    ++ lib.optionals mesaSupported [ ./dlopen-gl.patch ./mkspecs-libgl.patch ];
+    copyPathsToStore (lib.readPathsFromFile ./. ./series);
 
   postPatch =
     ''
@@ -48,37 +87,19 @@ stdenv.mkDerivation {
       substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
       sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i config.tests/*/*.test -i mkspecs/*/*.conf
 
-      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "src/corelib/Qt5Config.cmake.in"
-      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "src/corelib/Qt5CoreMacros.cmake"
-      sed -i 's/NO_DEFAULT_PATH//' "src/gui/Qt5GuiConfigExtras.cmake.in"
-      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in"
-
-      substituteInPlace src/network/kernel/qdnslookup_unix.cpp \
-        --replace "@glibc@" "${stdenv.cc.libc.out}"
-      substituteInPlace src/network/kernel/qhostinfo_unix.cpp \
-        --replace "@glibc@" "${stdenv.cc.libc.out}"
-
-      substituteInPlace src/network/ssl/qsslsocket_openssl_symbols.cpp \
-        --replace "@openssl@" "${openssl.out}"
-    '' + lib.optionalString stdenv.isLinux ''
-      substituteInPlace src/plugins/platforms/xcb/qxcbcursor.cpp \
-        --replace "@libXcursor@" "${libXcursor.out}"
-
-      substituteInPlace src/dbus/qdbus_symbols.cpp \
-        --replace "@dbus_libs@" "${dbus.lib}"
-
-      substituteInPlace \
-        src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp \
-        --replace "@libX11@" "${libX11.out}"
+      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5Config.cmake.in
+      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' src/corelib/Qt5CoreMacros.cmake
+      sed -i 's/NO_DEFAULT_PATH//' src/gui/Qt5GuiConfigExtras.cmake.in
+      sed -i '/PATHS.*NO_DEFAULT_PATH/ d' mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
     ''
+
     + lib.optionalString mesaSupported ''
-      substituteInPlace \
-        src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp \
-        --replace "@mesa_lib@" "${mesa.out}"
-      substituteInPlace mkspecs/common/linux.conf \
-        --replace "@mesa_lib@" "${mesa.out}" \
-        --replace "@mesa_inc@" "${mesa.dev or mesa}"
-    ''+ lib.optionalString stdenv.isDarwin ''
+      sed -i mkspecs/common/linux.conf \
+          -e "/^QMAKE_INCDIR_OPENGL/ s|$|${mesa.dev or mesa}/include|" \
+          -e "/^QMAKE_LIBDIR_OPENGL/ s|$|${mesa.out}/lib|"
+    ''
+
+    + lib.optionalString stdenv.isDarwin ''
       sed -i \
           -e 's|! /usr/bin/xcode-select --print-path >/dev/null 2>&1;|false;|' \
           -e 's|! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1;|false;|' \
@@ -106,132 +127,132 @@ stdenv.mkDerivation {
         -importdir $out/lib/qt5/imports \
         -qmldir $out/lib/qt5/qml \
         -docdir $out/share/doc/qt5"
-  '';
 
-  prefixKey = "-prefix ";
-
-  # -no-eglfs, -no-directfb, -no-linuxfb and -no-kms because of the current minimalist mesa
-  # TODO Remove obsolete and useless flags once the build will be totally mastered
-  configureFlags = ''
-    -verbose
-    -confirm-license
-    -opensource
-
-    -release
-    -shared
-    ${lib.optionalString developerBuild "-developer-build"}
-    -accessibility
-    -optimized-qmake
-    -strip
-    -no-reduce-relocations
-    -system-proxies
-    -pkg-config
-
-    -gui
-    -widgets
-    -opengl desktop
-    -qml-debug
-    -icu
-    -pch
-
-    ${lib.optionalString (!system-x86_64) "-no-sse2"}
-    -no-sse3
-    -no-ssse3
-    -no-sse4.1
-    -no-sse4.2
-    -no-avx
-    -no-avx2
-    -no-mips_dsp
-    -no-mips_dspr2
-
-    -system-zlib
-    -system-libjpeg
-    -system-harfbuzz
-    -system-pcre
-    -openssl-linked
-
-    -system-sqlite
-    -${if mysql != null then "plugin" else "no"}-sql-mysql
-    -${if postgresql != null then "plugin" else "no"}-sql-psql
-
-    -make libs
-    -make tools
-    -${lib.optionalString (buildExamples == false) "no"}make examples
-    -${lib.optionalString (buildTests == false) "no"}make tests
-    -v
-  '' + lib.optionalString (!stdenv.isDarwin) ''
-    -rpath
-    -glib
-    -xcb
-    -qpa xcb
-
-    -${lib.optionalString (cups == null) "no-"}cups
-
-    -no-eglfs
-    -no-directfb
-    -no-linuxfb
-    -no-kms
-
-    -libinput
-    -gtk
-    -system-libpng
-    -system-xcb
-    -system-xkbcommon
-    -dbus-linked
-  '' + lib.optionalString stdenv.isDarwin ''
-    -platform macx-clang
-    -no-use-gold-linker
-    -no-fontconfig
-    -qt-freetype
-    -qt-libpng
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QPA_PLATFORM_PLUGIN_PATH=\"''${!outputLib}/lib/qt5/plugins\""
   '';
 
-  # 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 (postgresql != null) "-L${postgresql.lib}/lib -lpq";
 
-  propagatedBuildInputs = [
-    libxml2 libxslt openssl pcre16 sqlite zlib
+  NIX_CFLAGS_COMPILE =
+    [
+      "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields
+      ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"''
+      ''-DNIXPKGS_LIBRESOLV="${stdenv.cc.libc.out}/lib/libresolv"''
+      ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"''
+    ]
 
-    # Text rendering
-    harfbuzz icu
+    ++ lib.optional mesaSupported
+       ''-DNIXPKGS_MESA_GL="${mesa.out}/lib/libGL"''
 
-    # Image formats
-    libjpeg libpng libtiff
-  ]
-  ++ lib.optional mesaSupported mesa
-  ++ lib.optionals (!stdenv.isDarwin) [
-    dbus glib udev
+    ++ lib.optionals stdenv.isDarwin
+    [
+      "-D__MAC_OS_X_VERSION_MAX_ALLOWED=1090"
+      "-D__AVAILABILITY_INTERNAL__MAC_10_10=__attribute__((availability(macosx,introduced=10.10)))"
+      # Note that nixpkgs's objc4 is from macOS 10.11 while the SDK is
+      # 10.9 which necessitates the above macro definition that mentions
+      # 10.10
+    ]
 
-    # Text rendering
-    fontconfig freetype
+    ++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC";
 
-    # X11 libs
-    libX11 libXcomposite libXext libXi libXrender libxcb libxkbcommon xcbutil
-    xcbutilimage xcbutilkeysyms xcbutilrenderutil xcbutilwm
-  ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
-    AGL AppKit ApplicationServices Carbon Cocoa
-    CoreAudio CoreBluetooth CoreLocation CoreServices
-    DiskArbitration Foundation OpenGL
-    darwin.cf-private darwin.libobjc libiconv
-  ]);
+  prefixKey = "-prefix ";
 
-  buildInputs = [ ]
-    ++ lib.optionals (!stdenv.isDarwin) [ gtk3 libinput ]
-    ++ lib.optional developerBuild gdb
-    ++ lib.optional (cups != null) cups
-    ++ lib.optional (mysql != null) mysql.lib
-    ++ lib.optional (postgresql != null) postgresql;
+  # 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 (postgresql != null) "-L${postgresql.lib}/lib -lpq";
 
-  nativeBuildInputs = [ bison flex gperf lndir perl pkgconfig python2 ] ++ lib.optional (!stdenv.isDarwin) patchelf;
+  # -no-eglfs, -no-directfb, -no-linuxfb and -no-kms because of the current minimalist mesa
+  # TODO Remove obsolete and useless flags once the build will be totally mastered
+  configureFlags =
+    [
+      "-verbose"
+      "-confirm-license"
+      "-opensource"
+
+      "-release"
+      "-shared"
+      "-accessibility"
+      "-optimized-qmake"
+      "-strip"
+      "-system-proxies"
+      "-pkg-config"
+    ]
+    ++ lib.optionals developerBuild [
+      "-developer-build"
+      "-no-warnings-are-errors"
+    ]
+    ++ [
+      "-gui"
+      "-widgets"
+      "-opengl desktop"
+      "-qml-debug"
+      "-icu"
+      "-pch"
+    ]
+
+    ++ [
+      ''${lib.optionalString (!system-x86_64) "-no"}-sse2''
+      "-no-sse3"
+      "-no-ssse3"
+      "-no-sse4.1"
+      "-no-sse4.2"
+      "-no-avx"
+      "-no-avx2"
+      "-no-mips_dsp"
+      "-no-mips_dspr2"
+    ]
+
+    ++ [
+      "-system-zlib"
+      "-system-libjpeg"
+      "-system-harfbuzz"
+      "-system-pcre"
+      "-openssl-linked"
+      "-system-sqlite"
+      ''-${if mysql != null then "plugin" else "no"}-sql-mysql''
+      ''-${if postgresql != null then "plugin" else "no"}-sql-psql''
+
+      "-make libs"
+      "-make tools"
+      ''-${lib.optionalString (buildExamples == false) "no"}make examples''
+      ''-${lib.optionalString (buildTests == false) "no"}make tests''
+      "-v"
+    ]
+
+    ++ lib.optionals (!stdenv.isDarwin) [
+      "-rpath"
+
+      "-system-xcb"
+      "-xcb"
+      "-qpa xcb"
+
+      "-system-xkbcommon"
+      "-libinput"
+      "-xkbcommon-evdev"
+
+      "-no-eglfs"
+      "-no-gbm"
+      "-no-kms"
+      "-no-linuxfb"
+
+      ''-${lib.optionalString (cups == null) "no-"}cups''
+      "-dbus-linked"
+      "-glib"
+      "-gtk"
+      "-inotify"
+      "-system-libjpeg"
+      "-system-libpng"
+    ]
+
+    ++ lib.optionals stdenv.isDarwin [
+      "-platform macx-clang"
+      "-no-use-gold-linker"
+      "-no-fontconfig"
+      "-qt-freetype"
+      "-qt-libpng"
+    ];
 
-  # freetype-2.5.4 changed signedness of some struct fields
-  NIX_CFLAGS_COMPILE = "-Wno-error=sign-compare"
-    + lib.optionalString stdenv.isDarwin " -D__MAC_OS_X_VERSION_MAX_ALLOWED=1090 -D__AVAILABILITY_INTERNAL__MAC_10_10=__attribute__((availability(macosx,introduced=10.10)))";
-  # Note that nixpkgs's objc4 is from macOS 10.11 while the SDK is
-  # 10.9 which necessitates the above macro definition that mentions
-  # 10.10
+  enableParallelBuilding = true;
 
   postInstall = ''
     find "$out" -name "*.cmake" | while read file; do
@@ -257,28 +278,43 @@ stdenv.mkDerivation {
     ''
       # Don't retain build-time dependencies like gdb.
       sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
+    ''
 
-      # Move libtool archives and qmake projects
+    # Move libtool archives into $dev
+    + ''
       if [ "z''${!outputLib}" != "z''${!outputDev}" ]; then
           pushd "''${!outputLib}"
-          find lib -name '*.a' -o -name '*.la'${if stdenv.isDarwin then "" else "-o -name '*.prl'"} | \
-              while read -r file; do
-                  mkdir -p "''${!outputDev}/$(dirname "$file")"
-                  mv "''${!outputLib}/$file" "''${!outputDev}/$file"
-              done
+          find lib -name '*.a' -o -name '*.la' | while read -r file; do
+              mkdir -p "''${!outputDev}/$(dirname "$file")"
+              mv "''${!outputLib}/$file" "''${!outputDev}/$file"
+          done
           popd
       fi
     ''
+
+    # Move qmake project files into $dev.
+    # Don't move .prl files on darwin because they end up in
+    # "dev/lib/Foo.framework/Foo.prl" which interferes with subsequent
+    # use of lndir in the qtbase setup-hook. On Linux, the .prl files
+    # are in lib, and so do not cause a subsequent recreation of deep
+    # framework directory trees.
+    + lib.optionalString (!stdenv.isDarwin) ''
+      if [ "z''${!outputLib}" != "z''${!outputDev}" ]; then
+          pushd "''${!outputLib}"
+          find lib -name '*.prl' | while read -r file; do
+              mkdir -p "''${!outputDev}/$(dirname "$file")"
+              mv "''${!outputLib}/$file" "''${!outputDev}/$file"
+          done
+          popd
+      fi
+    ''
+
     # fixup .pc file (where to find 'moc' etc.)
     + lib.optionalString (!stdenv.isDarwin) ''
       sed -i "$dev/lib/pkgconfig/Qt5Core.pc" \
           -e "/^host_bins=/ c host_bins=$dev/bin"
     ''
-    # Don' move .prl files on darwin because they end up in
-    # "dev/lib/Foo.framework/Foo.prl" which interferes with subsequent
-    # use of lndir in the qtbase setup-hook. On Linux, the .prl files
-    # are in lib, and so do not cause a subsequent recreation of deep
-    # framework directory trees.
+
     + lib.optionalString stdenv.isDarwin ''
       fixDarwinDylibNames_rpath() {
         local flags=()
@@ -300,8 +336,6 @@ stdenv.mkDerivation {
               then ../../qtbase-setup-hook-darwin.sh
               else ../../qtbase-setup-hook.sh;
 
-  enableParallelBuilding = true;
-
   meta = with lib; {
     homepage = http://www.qt.io;
     description = "A cross-platform application framework for C++";
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-dbus.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-dbus.patch
deleted file mode 100644
index 10b0b6701ddc..000000000000
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-dbus.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: qtbase-opensource-src-5.7.0/src/dbus/qdbus_symbols.cpp
-===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/dbus/qdbus_symbols.cpp
-+++ qtbase-opensource-src-5.7.0/src/dbus/qdbus_symbols.cpp
-@@ -97,7 +97,7 @@ bool qdbus_loadLibDBus()
- #ifdef Q_OS_WIN
-         QLatin1String("dbus-1"),
- #endif
--        QLatin1String("libdbus-1")
-+        QLatin1String("@dbus_libs@/lib/libdbus-1")
-     };
- 
-     lib->unload();
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-gl.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-gl.patch
index ea3073ced50a..c835f2bfe441 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-gl.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-gl.patch
@@ -1,17 +1,19 @@
-Index: qtbase-opensource-src-5.5.1/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+Index: qtbase-opensource-src-5.8.0/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
 ===================================================================
---- qtbase-opensource-src-5.5.1.orig/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-+++ qtbase-opensource-src-5.5.1/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
-@@ -563,7 +563,12 @@ void (*QGLXContext::getProcAddress(const
-             {
+--- qtbase-opensource-src-5.8.0.orig/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
++++ qtbase-opensource-src-5.8.0/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+@@ -576,7 +576,14 @@ QFunctionPointer QGLXContext::getProcAdd
+ #ifndef QT_NO_LIBRARY
                  extern const QString qt_gl_library_name();
  //                QLibrary lib(qt_gl_library_name());
 +                // Check system library paths first
                  QLibrary lib(QLatin1String("GL"));
++#ifdef NIXPKGS_MESA_GL
 +                if (!lib.load()) {
 +                    // Fallback to Mesa driver
-+                    lib.setFileName(QLatin1String("@mesa_lib@/lib/libGL"));
++                    lib.setFileName(QLatin1String(NIXPKGS_MESA_GL));
 +                }
++#endif // NIXPKGS_MESA_GL
                  glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ #endif
              }
-         }
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-libXcursor.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-libXcursor.patch
index 02b7efb73d22..d0e82cf122ac 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-libXcursor.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-libXcursor.patch
@@ -1,17 +1,20 @@
-Index: qtbase-opensource-src-5.7.0/src/plugins/platforms/xcb/qxcbcursor.cpp
+Index: qtbase-opensource-src-5.8.0/src/plugins/platforms/xcb/qxcbcursor.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/plugins/platforms/xcb/qxcbcursor.cpp
-+++ qtbase-opensource-src-5.7.0/src/plugins/platforms/xcb/qxcbcursor.cpp
-@@ -309,10 +309,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *c
+--- qtbase-opensource-src-5.8.0.orig/src/plugins/platforms/xcb/qxcbcursor.cpp
++++ qtbase-opensource-src-5.8.0/src/plugins/platforms/xcb/qxcbcursor.cpp
+@@ -309,13 +309,13 @@ QXcbCursor::QXcbCursor(QXcbConnection *c
  #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
      static bool function_ptrs_not_initialized = true;
      if (function_ptrs_not_initialized) {
 -        QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
-+        QLibrary xcursorLib(QLatin1String("@libXcursor@/lib/libXcursor"), 1);
++        QLibrary xcursorLib(QLatin1String(NIXPKGS_LIBXCURSOR), 1);
          bool xcursorFound = xcursorLib.load();
          if (!xcursorFound) { // try without the version number
 -            xcursorLib.setFileName(QLatin1String("Xcursor"));
-+            xcursorLib.setFileName(QLatin1String("@libXcursor@/lib/Xcursor"));
++            xcursorLib.setFileName(QLatin1String(NIXPKGS_LIBXCURSOR));
              xcursorFound = xcursorLib.load();
          }
          if (xcursorFound) {
+             ptrXcursorLibraryLoadCursor =
+                 (PtrXcursorLibraryLoadCursor) xcursorLib.resolve("XcursorLibraryLoadCursor");
+             ptrXcursorLibraryGetTheme =
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-openssl.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-openssl.patch
deleted file mode 100644
index 9891bfeac5bf..000000000000
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-openssl.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Index: qtbase-opensource-src-5.7.0/src/network/ssl/qsslsocket_openssl_symbols.cpp
-===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/network/ssl/qsslsocket_openssl_symbols.cpp
-+++ qtbase-opensource-src-5.7.0/src/network/ssl/qsslsocket_openssl_symbols.cpp
-@@ -658,8 +658,8 @@ static QPair<QLibrary*, QLibrary*> loadO
- #endif
- #if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
-     // first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
--    libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));
--    libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));
-+    libssl->setFileNameAndVersion(QLatin1String("@openssl@/lib/libssl"), QLatin1String(SHLIB_VERSION_NUMBER));
-+    libcrypto->setFileNameAndVersion(QLatin1String("@openssl@/lib/libcrypto"), QLatin1String(SHLIB_VERSION_NUMBER));
-     if (libcrypto->load() && libssl->load()) {
-         // libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
-         return pair;
-@@ -676,8 +676,8 @@ static QPair<QLibrary*, QLibrary*> loadO
-     //  OS X's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third
-     //    attempt, _after_ <bundle>/Contents/Frameworks has been searched.
-     //  iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place.
--    libssl->setFileNameAndVersion(QLatin1String("ssl"), -1);
--    libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);
-+    libssl->setFileNameAndVersion(QLatin1String("@openssl@/lib/libssl"), -1);
-+    libcrypto->setFileNameAndVersion(QLatin1String("@openssl@/lib/libcrypto"), -1);
-     if (libcrypto->load() && libssl->load()) {
-         // libssl.so.0 and libcrypto.so.0 found
-         return pair;
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-resolv.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-resolv.patch
index 98a3610f5fbd..ef7cd4a910a2 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-resolv.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/dlopen-resolv.patch
@@ -1,26 +1,26 @@
-Index: qtbase-opensource-src-5.7.0/src/network/kernel/qdnslookup_unix.cpp
+Index: qtbase-opensource-src-5.8.0/src/network/kernel/qdnslookup_unix.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/network/kernel/qdnslookup_unix.cpp
-+++ qtbase-opensource-src-5.7.0/src/network/kernel/qdnslookup_unix.cpp
-@@ -85,7 +85,7 @@ static bool resolveLibraryInternal()
+--- qtbase-opensource-src-5.8.0.orig/src/network/kernel/qdnslookup_unix.cpp
++++ qtbase-opensource-src-5.8.0/src/network/kernel/qdnslookup_unix.cpp
+@@ -90,7 +90,7 @@ static bool resolveLibraryInternal()
      if (!lib.load())
  #endif
      {
 -        lib.setFileName(QLatin1String("resolv"));
-+        lib.setFileName(QLatin1String("@glibc@/lib/resolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
          if (!lib.load())
              return false;
      }
-Index: qtbase-opensource-src-5.7.0/src/network/kernel/qhostinfo_unix.cpp
+Index: qtbase-opensource-src-5.8.0/src/network/kernel/qhostinfo_unix.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/network/kernel/qhostinfo_unix.cpp
-+++ qtbase-opensource-src-5.7.0/src/network/kernel/qhostinfo_unix.cpp
+--- qtbase-opensource-src-5.8.0.orig/src/network/kernel/qhostinfo_unix.cpp
++++ qtbase-opensource-src-5.8.0/src/network/kernel/qhostinfo_unix.cpp
 @@ -100,7 +100,7 @@ static bool resolveLibraryInternal()
      if (!lib.load())
  #endif
      {
 -        lib.setFileName(QLatin1String("resolv"));
-+        lib.setFileName(QLatin1String("@glibc@/lib/libresolv"));
++        lib.setFileName(QLatin1String(NIXPKGS_LIBRESOLV));
          if (!lib.load())
              return false;
      }
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/libressl.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/libressl.patch
index 4390db977a71..e9c60e7ab076 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/libressl.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/libressl.patch
@@ -9,11 +9,11 @@ is defined in openssl, but not in libressl.
  src/network/ssl/qsslcontext_openssl.cpp | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
-Index: qtbase-opensource-src-5.7.0/src/network/ssl/qsslcontext_openssl.cpp
+Index: qtbase-opensource-src-5.8.0/src/network/ssl/qsslcontext_openssl.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/network/ssl/qsslcontext_openssl.cpp
-+++ qtbase-opensource-src-5.7.0/src/network/ssl/qsslcontext_openssl.cpp
-@@ -347,7 +347,7 @@ init_context:
+--- qtbase-opensource-src-5.8.0.orig/src/network/ssl/qsslcontext_openssl.cpp
++++ qtbase-opensource-src-5.8.0/src/network/ssl/qsslcontext_openssl.cpp
+@@ -351,7 +351,7 @@ init_context:
  
      const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
      if (!qcurves.isEmpty()) {
@@ -22,7 +22,7 @@ Index: qtbase-opensource-src-5.7.0/src/network/ssl/qsslcontext_openssl.cpp
          // Set the curves to be used
          if (q_SSLeay() >= 0x10002000L) {
              // SSL_CTX_ctrl wants a non-const pointer as last argument,
-@@ -360,7 +360,7 @@ init_context:
+@@ -364,7 +364,7 @@ init_context:
                  sslContext->errorCode = QSslError::UnspecifiedError;
              }
          } else
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/mkspecs-libgl.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/mkspecs-libgl.patch
deleted file mode 100644
index fda3d3e36533..000000000000
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/mkspecs-libgl.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-Index: qtbase-opensource-src-5.5.1/mkspecs/common/linux.conf
-===================================================================
---- qtbase-opensource-src-5.5.1.orig/mkspecs/common/linux.conf
-+++ qtbase-opensource-src-5.5.1/mkspecs/common/linux.conf
-@@ -12,8 +12,8 @@ QMAKE_INCDIR            =
- QMAKE_LIBDIR            =
- QMAKE_INCDIR_X11        =
- QMAKE_LIBDIR_X11        =
--QMAKE_INCDIR_OPENGL     =
--QMAKE_LIBDIR_OPENGL     =
-+QMAKE_INCDIR_OPENGL     = @mesa_inc@/include
-+QMAKE_LIBDIR_OPENGL     = @mesa_lib@/lib
- QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL
- QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL
- QMAKE_INCDIR_EGL        =
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/nix-profiles-library-paths.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/nix-profiles-library-paths.patch
deleted file mode 100644
index ebaf3651a6d0..000000000000
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/nix-profiles-library-paths.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Index: qtbase-opensource-src-5.7.0/src/corelib/kernel/qcoreapplication.cpp
-===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/kernel/qcoreapplication.cpp
-+++ qtbase-opensource-src-5.7.0/src/corelib/kernel/qcoreapplication.cpp
-@@ -2487,7 +2487,17 @@ QStringList QCoreApplication::libraryPat
-         QStringList *app_libpaths = new QStringList;
-         coreappdata()->app_libpaths.reset(app_libpaths);
- 
-+        // Add library paths derived from NIX_PROFILES.
-+        const QByteArrayList profiles = qgetenv("NIX_PROFILES").split(' ');
-+        const QString plugindir = QString::fromLatin1("/lib/qt5/plugins");
-+        for (const QByteArray &profile: profiles) {
-+            if (!profile.isEmpty()) {
-+                app_libpaths->append(QFile::decodeName(profile) + plugindir);
-+            }
-+        }
-+
-         const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
-+        qunsetenv("QT_PLUGIN_PATH"); // do not propagate to child processes
-         if (!libPathEnv.isEmpty()) {
-             QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
-             for (QStringList::const_iterator it = paths.constBegin(); it != paths.constEnd(); ++it) {
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/qnativesocketengine-type-pun.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/qnativesocketengine-type-pun.patch
new file mode 100644
index 000000000000..ad40dfab2f7b
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/qnativesocketengine-type-pun.patch
@@ -0,0 +1,14 @@
+Index: qtbase-opensource-src-5.8.0/src/network/socket/qnativesocketengine_unix.cpp
+===================================================================
+--- qtbase-opensource-src-5.8.0.orig/src/network/socket/qnativesocketengine_unix.cpp
++++ qtbase-opensource-src-5.8.0/src/network/socket/qnativesocketengine_unix.cpp
+@@ -979,7 +979,8 @@ qint64 QNativeSocketEnginePrivate::nativ
+             if (cmsgptr->cmsg_len == CMSG_LEN(sizeof(int))
+                     && ((cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_HOPLIMIT)
+                         || (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_TTL))) {
+-                header->hopLimit = *reinterpret_cast<int *>(CMSG_DATA(cmsgptr));
++                int *ttl = reinterpret_cast<int *>(CMSG_DATA(cmsgptr));
++                header->hopLimit = *ttl;
+             }
+ 
+ #ifndef QT_NO_SCTP
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/qpa-plugin-path.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/qpa-plugin-path.patch
new file mode 100644
index 000000000000..6d40ed19c00a
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/qpa-plugin-path.patch
@@ -0,0 +1,15 @@
+Index: qtbase-opensource-src-5.8.0/src/gui/kernel/qguiapplication.cpp
+===================================================================
+--- qtbase-opensource-src-5.8.0.orig/src/gui/kernel/qguiapplication.cpp
++++ qtbase-opensource-src-5.8.0/src/gui/kernel/qguiapplication.cpp
+@@ -1217,6 +1217,10 @@ void QGuiApplicationPrivate::createPlatf
+ 
+     // Load the platform integration
+     QString platformPluginPath = QString::fromLocal8Bit(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
++    if (!platformPluginPath.isEmpty()) {
++        platformPluginPath.append(QStringLiteral(":"));
++    }
++    platformPluginPath.append(QStringLiteral(NIXPKGS_QPA_PLATFORM_PLUGIN_PATH));
+ 
+ 
+     QByteArray platformName;
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/series b/pkgs/development/libraries/qt-5/5.8/qtbase/series
index 2196d8383752..0378ca1f5035 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/series
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/series
@@ -1,9 +1,9 @@
 dlopen-resolv.patch
 tzdir.patch
 dlopen-libXcursor.patch
-dlopen-openssl.patch
-dlopen-dbus.patch
 xdg-config-dirs.patch
-nix-profiles-library-paths.patch
-compose-search-path.patch
 libressl.patch
+qpa-plugin-path.patch
+dlopen-gl.patch
+compose-search-path.patch
+cmake-paths.patch
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/tzdir.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/tzdir.patch
index f4056dd9cc97..b8c05815a784 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/tzdir.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/tzdir.patch
@@ -1,29 +1,28 @@
-Index: qtbase-opensource-src-5.7.0/src/corelib/tools/qtimezoneprivate_tz.cpp
+Index: qtbase-opensource-src-5.8.0/src/corelib/tools/qtimezoneprivate_tz.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/tools/qtimezoneprivate_tz.cpp
-+++ qtbase-opensource-src-5.7.0/src/corelib/tools/qtimezoneprivate_tz.cpp
-@@ -68,7 +68,10 @@ typedef QHash<QByteArray, QTzTimeZone> Q
+--- qtbase-opensource-src-5.8.0.orig/src/corelib/tools/qtimezoneprivate_tz.cpp
++++ qtbase-opensource-src-5.8.0/src/corelib/tools/qtimezoneprivate_tz.cpp
+@@ -70,7 +70,11 @@ typedef QHash<QByteArray, QTzTimeZone> Q
  // Parse zone.tab table, assume lists all installed zones, if not will need to read directories
  static QTzTimeZoneHash loadTzTimeZones()
  {
 -    QString path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
-+    QString path = qgetenv("TZDIR");
-+    path += "/zone.tab";
++    // Try TZDIR first, in case we're running on NixOS.
++    QString path = QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/zone.tab");
++    // Fallback to traditional paths in case we are not on NixOS.
 +    if (!QFile::exists(path))
 +        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
      if (!QFile::exists(path))
          path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
  
-@@ -566,12 +569,18 @@ void QTzTimeZonePrivate::init(const QByt
+@@ -642,12 +646,16 @@ void QTzTimeZonePrivate::init(const QByt
          if (!tzif.open(QIODevice::ReadOnly))
              return;
      } else {
 -        // Open named tz, try modern path first, if fails try legacy path
 -        tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
-+        // Try TZDIR first
-+        QString zoneinfoDir = qgetenv("TZDIR");
-+        zoneinfoDir += "/" + QString::fromLocal8Bit(ianaId);
-+        tzif.setFileName(zoneinfoDir);
++        // Try TZDIR first, in case we're running on NixOS
++        tzif.setFileName(QFile::decodeName(qgetenv("TZDIR")) + QStringLiteral("/") + QString::fromLocal8Bit(ianaId));
          if (!tzif.open(QIODevice::ReadOnly)) {
 -            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
 -            if (!tzif.open(QIODevice::ReadOnly))
diff --git a/pkgs/development/libraries/qt-5/5.8/qtbase/xdg-config-dirs.patch b/pkgs/development/libraries/qt-5/5.8/qtbase/xdg-config-dirs.patch
index 1f2f316c5b26..b5c21f064a42 100644
--- a/pkgs/development/libraries/qt-5/5.8/qtbase/xdg-config-dirs.patch
+++ b/pkgs/development/libraries/qt-5/5.8/qtbase/xdg-config-dirs.patch
@@ -1,8 +1,8 @@
-Index: qtbase-opensource-src-5.7.0/src/corelib/io/qsettings.cpp
+Index: qtbase-opensource-src-5.8.0/src/corelib/io/qsettings.cpp
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/io/qsettings.cpp
-+++ qtbase-opensource-src-5.7.0/src/corelib/io/qsettings.cpp
-@@ -1161,6 +1161,23 @@ QConfFileSettingsPrivate::QConfFileSetti
+--- qtbase-opensource-src-5.8.0.orig/src/corelib/io/qsettings.cpp
++++ qtbase-opensource-src-5.8.0/src/corelib/io/qsettings.cpp
+@@ -1134,6 +1134,23 @@ QConfFileSettingsPrivate::QConfFileSetti
          confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
      confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
  
@@ -26,10 +26,10 @@ Index: qtbase-opensource-src-5.7.0/src/corelib/io/qsettings.cpp
      for (i = 0; i < NumConfFiles; ++i) {
          if (confFiles[i]) {
              spec = i;
-Index: qtbase-opensource-src-5.7.0/src/corelib/io/qsettings_p.h
+Index: qtbase-opensource-src-5.8.0/src/corelib/io/qsettings_p.h
 ===================================================================
---- qtbase-opensource-src-5.7.0.orig/src/corelib/io/qsettings_p.h
-+++ qtbase-opensource-src-5.7.0/src/corelib/io/qsettings_p.h
+--- qtbase-opensource-src-5.8.0.orig/src/corelib/io/qsettings_p.h
++++ qtbase-opensource-src-5.8.0/src/corelib/io/qsettings_p.h
 @@ -246,7 +246,7 @@ public:
          F_Organization = 0x1,
          F_User = 0x0,
diff --git a/pkgs/development/libraries/qt-5/make-qt-wrapper.sh b/pkgs/development/libraries/qt-5/make-qt-wrapper.sh
index 8f42682fa23e..4a5651f74c9b 100644
--- a/pkgs/development/libraries/qt-5/make-qt-wrapper.sh
+++ b/pkgs/development/libraries/qt-5/make-qt-wrapper.sh
@@ -2,9 +2,9 @@ wrapQtProgram() {
     local prog="$1"
     shift
     wrapProgram "$prog" \
-        --set QT_PLUGIN_PATH "$QT_PLUGIN_PATH" \
-        --set QML_IMPORT_PATH "$QML_IMPORT_PATH" \
-        --set QML2_IMPORT_PATH "$QML2_IMPORT_PATH" \
+        --prefix QT_PLUGIN_PATH : "$QT_PLUGIN_PATH" \
+        --prefix QML_IMPORT_PATH : "$QML_IMPORT_PATH" \
+        --prefix QML2_IMPORT_PATH : "$QML2_IMPORT_PATH" \
         --prefix XDG_DATA_DIRS : "$RUNTIME_XDG_DATA_DIRS" \
         --prefix XDG_CONFIG_DIRS : "$RUNTIME_XDG_CONFIG_DIRS" \
         --prefix GIO_EXTRA_MODULES : "$GIO_EXTRA_MODULES" \
@@ -17,9 +17,9 @@ makeQtWrapper() {
     shift
     shift
     makeWrapper "$old" "$new" \
-        --set QT_PLUGIN_PATH "$QT_PLUGIN_PATH" \
-        --set QML_IMPORT_PATH "$QML_IMPORT_PATH" \
-        --set QML2_IMPORT_PATH "$QML2_IMPORT_PATH" \
+        --prefix QT_PLUGIN_PATH : "$QT_PLUGIN_PATH" \
+        --prefix QML_IMPORT_PATH : "$QML_IMPORT_PATH" \
+        --prefix QML2_IMPORT_PATH : "$QML2_IMPORT_PATH" \
         --prefix XDG_DATA_DIRS : "$RUNTIME_XDG_DATA_DIRS" \
         --prefix XDG_CONFIG_DIRS : "$RUNTIME_XDG_CONFIG_DIRS" \
         --prefix GIO_EXTRA_MODULES : "$GIO_EXTRA_MODULES" \
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 157c9ba336ce..1085346a664f 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -273,7 +273,8 @@ with pkgs;
       inherit kernel rootModules allowMissing;
     };
 
-  kdeDerivation = import ../build-support/kde/derivation.nix { inherit stdenv lib; };
+  kdeDerivation = makeOverridable (import ../build-support/kde/derivation.nix)
+    { inherit stdenv lib; };
 
   kdeWrapper = callPackage ../build-support/kde/wrapper.nix {
     inherit (gnome3) dconf;
@@ -9540,30 +9541,32 @@ with pkgs;
     developerBuild = true;
   });
 
-  qt56 = recurseIntoAttrs (import ../development/libraries/qt-5/5.6 {
-    inherit newScope;
-    inherit stdenv fetchurl makeSetupHook makeWrapper;
-    bison = bison2; # error: too few arguments to function 'int yylex(...
-    inherit cups;
-    harfbuzz = harfbuzz-icu;
-    mesa = mesa_noglu;
-    inherit perl;
-    inherit (gst_all_1) gstreamer gst-plugins-base;
-  });
+  qt56 = recurseIntoAttrs (makeOverridable
+    (import ../development/libraries/qt-5/5.6) {
+      inherit newScope;
+      inherit stdenv fetchurl makeSetupHook makeWrapper;
+      bison = bison2; # error: too few arguments to function 'int yylex(...
+      inherit cups;
+      harfbuzz = harfbuzz-icu;
+      mesa = mesa_noglu;
+      inherit perl;
+      inherit (gst_all_1) gstreamer gst-plugins-base;
+    });
 
   libsForQt56 = recurseIntoAttrs (lib.makeScope qt56.newScope mkLibsForQt5);
 
-  qt58 = recurseIntoAttrs (import ../development/libraries/qt-5/5.8 {
-    inherit newScope;
-    inherit stdenv fetchurl makeSetupHook makeWrapper;
-    bison = bison2; # error: too few arguments to function 'int yylex(...
-    inherit cups;
-    harfbuzz = harfbuzz-icu;
-    mesa = mesa_noglu;
-    inherit perl;
-    inherit (gst_all_1) gstreamer gst-plugins-base;
-    inherit (gnome3) gtk3 dconf;
-  });
+  qt58 = recurseIntoAttrs (makeOverridable
+    (import ../development/libraries/qt-5/5.8) {
+      inherit newScope;
+      inherit stdenv fetchurl makeSetupHook makeWrapper;
+      bison = bison2; # error: too few arguments to function 'int yylex(...
+      inherit cups;
+      harfbuzz = harfbuzz-icu;
+      mesa = mesa_noglu;
+      inherit perl;
+      inherit (gst_all_1) gstreamer gst-plugins-base;
+      inherit (gnome3) gtk3 dconf;
+    });
 
   libsForQt58 = recurseIntoAttrs (lib.makeScope qt58.newScope mkLibsForQt5);