summary refs log tree commit diff
path: root/pkgs/development/libraries/qt-5
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/qt-5')
-rw-r--r--pkgs/development/libraries/qt-5/5.6/default.nix121
-rwxr-xr-xpkgs/development/libraries/qt-5/5.6/fetchsrcs.sh47
-rw-r--r--pkgs/development/libraries/qt-5/5.6/fix-qt-module-cmake-config.sh5
-rw-r--r--pkgs/development/libraries/qt-5/5.6/make-qt-wrapper.sh38
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qmake-hook.sh114
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch16
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/default.nix284
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch13
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch17
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gtkstyle.patch50
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch17
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch26
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch26
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch33
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch15
-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/series9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/setup-hook.sh52
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch40
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch42
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix14
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative/nix-profiles-import-paths.patch20
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdeclarative/series1
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtdoc.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtenginio.nix9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtimageformats.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtlocation.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix16
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch25
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtscript/default.nix10
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtsensors.nix9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch28
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix15
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtsvg.nix9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttools.nix16
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qttranslations.nix6
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtx11extras.nix9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix9
-rw-r--r--pkgs/development/libraries/qt-5/5.6/srcs.nix261
44 files changed, 1510 insertions, 0 deletions
diff --git a/pkgs/development/libraries/qt-5/5.6/default.nix b/pkgs/development/libraries/qt-5/5.6/default.nix
new file mode 100644
index 0000000000000..b74b2debf0e2b
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/default.nix
@@ -0,0 +1,121 @@
+/*
+
+# Minor Updates
+
+1. Edit ./fetchsrcs.sh to point to the updated URL.
+2. Run ./fetchsrcs.sh.
+3. Build and enjoy.
+
+# Major Updates
+
+1. Make a copy of this directory. (We like to keep the old version around
+   for a short time after major updates.)
+2. Delete the tmp/ subdirectory of the copy.
+3. Follow the minor update instructions above.
+4. Package any new Qt modules, if necessary.
+
+*/
+
+{ pkgs
+
+# options
+, developerBuild ? false
+, decryptSslTraffic ? false
+}:
+
+let inherit (pkgs) makeSetupHook makeWrapper stdenv; in
+
+with stdenv.lib;
+
+let
+
+  mirror = "http://download.qt.io";
+  srcs = import ./srcs.nix { inherit mirror; inherit (pkgs) fetchurl; };
+
+  qtSubmodule = args:
+    let
+      inherit (args) name;
+      version = args.version or srcs."${name}".version;
+      src = args.src or srcs."${name}".src;
+      inherit (pkgs.stdenv) mkDerivation;
+    in mkDerivation (args // {
+      name = "${name}-${version}";
+      inherit src;
+
+      propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or []);
+      nativeBuildInputs =
+        (args.nativeBuildInputs or [])
+        ++ [ pkgs.perl self.fixQtModuleCMakeConfig self.qmakeHook ];
+
+      NIX_QT_SUBMODULE = args.NIX_QT_SUBMODULE or true;
+
+      outputs = args.outputs or [ "dev" "out" ];
+      setOutputFlags = args.setOutputFlags or false;
+
+      enableParallelBuilding = args.enableParallelBuilding or true;
+
+      meta = self.qtbase.meta // (args.meta or {});
+    });
+
+  addPackages = self: with self;
+    let
+      callPackage = self.newScope { inherit qtSubmodule srcs; };
+    in {
+
+      qtbase = callPackage ./qtbase {
+        mesa = pkgs.mesa_noglu;
+        harfbuzz = pkgs.harfbuzz-icu;
+        cups = if stdenv.isLinux then pkgs.cups else null;
+        # GNOME dependencies are not used unless gtkStyle == true
+        inherit (pkgs.gnome) libgnomeui GConf gnome_vfs;
+        bison = pkgs.bison2; # error: too few arguments to function 'int yylex(...
+        inherit developerBuild decryptSslTraffic;
+      };
+
+      /* qt3d = not packaged */
+      /* qtactiveqt = not packaged */
+      /* qtandroidextras = not packaged */
+      /* qtcanvas3d = not packaged */
+      qtconnectivity = callPackage ./qtconnectivity.nix {};
+      qtdeclarative = callPackage ./qtdeclarative {};
+      qtdoc = callPackage ./qtdoc.nix {};
+      qtenginio = callPackage ./qtenginio.nix {};
+      qtgraphicaleffects = callPackage ./qtgraphicaleffects.nix {};
+      qtimageformats = callPackage ./qtimageformats.nix {};
+      qtlocation = callPackage ./qtlocation.nix {};
+      /* qtmacextras = not packaged */
+      qtmultimedia = callPackage ./qtmultimedia.nix {
+        inherit (pkgs.gst_all_1) gstreamer gst-plugins-base;
+      };
+      qtquickcontrols = callPackage ./qtquickcontrols.nix {};
+      qtscript = callPackage ./qtscript {};
+      qtsensors = callPackage ./qtsensors.nix {};
+      qtserialport = callPackage ./qtserialport {};
+      qtsvg = callPackage ./qtsvg.nix {};
+      qttools = callPackage ./qttools.nix {};
+      qttranslations = callPackage ./qttranslations.nix {};
+      /* qtwayland = not packaged */
+      /* qtwebchannel = not packaged */
+      /* qtwebengine = not packaged */
+      qtwebsockets = callPackage ./qtwebsockets.nix {};
+      /* qtwinextras = not packaged */
+      qtx11extras = callPackage ./qtx11extras.nix {};
+      qtxmlpatterns = callPackage ./qtxmlpatterns.nix {};
+
+      env = callPackage ../qt-env.nix {};
+      full = env "qt-${qtbase.version}" [
+        qtconnectivity qtdeclarative qtdoc qtenginio qtgraphicaleffects
+        qtimageformats qtlocation qtmultimedia qtquickcontrols qtscript
+        qtsensors qtserialport qtsvg qttools qttranslations qtwebsockets
+        qtx11extras qtxmlpatterns
+      ];
+
+      makeQtWrapper = makeSetupHook { deps = [ makeWrapper ]; } ./make-qt-wrapper.sh;
+      fixQtModuleCMakeConfig = makeSetupHook { } ./fix-qt-module-cmake-config.sh;
+      qmakeHook = makeSetupHook { substitutions = { qt_dev = qtbase.dev; lndir = pkgs.xorg.lndir; }; } ./qmake-hook.sh;
+
+    };
+
+   self = makeScope pkgs.newScope addPackages;
+
+in self
diff --git a/pkgs/development/libraries/qt-5/5.6/fetchsrcs.sh b/pkgs/development/libraries/qt-5/5.6/fetchsrcs.sh
new file mode 100755
index 0000000000000..c499c70ea2ca0
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/fetchsrcs.sh
@@ -0,0 +1,47 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -i bash -p coreutils findutils gnused nix wget
+
+set -x
+
+# The trailing slash at the end is necessary!
+RELEASE_URL="http://download.qt.io/official_releases/qt/5.6/5.6.0/submodules/"
+EXTRA_WGET_ARGS='-A *.tar.xz'
+
+mkdir tmp; cd tmp
+
+wget -nH -r -c --no-parent $RELEASE_URL $EXTRA_WGET_ARGS
+
+cat >../srcs.nix <<EOF
+# DO NOT EDIT! This file is generated automatically by manifest.sh
+{ fetchurl, mirror }:
+
+{
+EOF
+
+workdir=$(pwd)
+
+find . | while read src; do
+    if [[ -f "${src}" ]]; then
+        url="${src:2}"
+        # Sanitize file name
+        filename=$(basename "$src" | tr '@' '_')
+        nameversion="${filename%.tar.*}"
+        name=$(echo "$nameversion" | sed -e 's,-[[:digit:]].*,,' | sed -e 's,-opensource-src$,,')
+        version=$(echo "$nameversion" | sed -e 's,^\([[:alpha:]][[:alnum:]]*-\)\+,,')
+        sha256=$(nix-hash --type sha256 --base32 --flat "$src")
+        cat >>../srcs.nix <<EOF
+  $name = {
+    version = "$version";
+    src = fetchurl {
+      url = "\${mirror}/$url";
+      sha256 = "$sha256";
+      name = "$filename";
+    };
+  };
+EOF
+    fi
+done
+
+echo "}" >>../srcs.nix
+
+cd ..
diff --git a/pkgs/development/libraries/qt-5/5.6/fix-qt-module-cmake-config.sh b/pkgs/development/libraries/qt-5/5.6/fix-qt-module-cmake-config.sh
new file mode 100644
index 0000000000000..7ca3e33b613c2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/fix-qt-module-cmake-config.sh
@@ -0,0 +1,5 @@
+fixQtModuleCMakeConfig() {
+    local module="$1"
+    sed -e "/set(imported_location/ s@\\\${_qt5${module}_install_prefix}@${!outputLib}@" \
+        -i "${!outputDev}/lib/cmake/Qt5${module}/Qt5${module}Config.cmake"
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/make-qt-wrapper.sh b/pkgs/development/libraries/qt-5/5.6/make-qt-wrapper.sh
new file mode 100644
index 0000000000000..3b537430371a8
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/make-qt-wrapper.sh
@@ -0,0 +1,38 @@
+wrapQtProgram() {
+    local prog="$1"
+    shift
+    wrapProgram "$prog" \
+        --prefix QT_PLUGIN_PATH : "$QT_PLUGIN_PATH" \
+        --prefix QML_IMPORT_PATH : "$QML_IMPORT_PATH" \
+        --prefix QML2_IMPORT_PATH : "$QML2_IMPORT_PATH" \
+        --prefix XDG_CONFIG_DIRS : "$NIX_WRAP_XDG_CONFIG_DIRS" \
+        --prefix XDG_DATA_DIRS : "$NIX_WRAP_XDG_DATA_DIRS" \
+        "$@"
+}
+
+makeQtWrapper() {
+    local old="$1"
+    local new="$2"
+    shift
+    shift
+    makeWrapper "$old" "$new" \
+        --prefix QT_PLUGIN_PATH : "$QT_PLUGIN_PATH" \
+        --prefix QML_IMPORT_PATH : "$QML_IMPORT_PATH" \
+        --prefix QML2_IMPORT_PATH : "$QML2_IMPORT_PATH" \
+        --prefix XDG_CONFIG_DIRS : "$NIX_WRAP_XDG_CONFIG_DIRS" \
+        --prefix XDG_DATA_DIRS : "$NIX_WRAP_XDG_DATA_DIRS" \
+        "$@"
+}
+
+_makeQtWrapperSetup() {
+    # cannot use addToSearchPath because these directories may not exist yet
+    export QT_PLUGIN_PATH="$QT_PLUGIN_PATH${QT_PLUGIN_PATH:+:}${!outputLib}/lib/qt5/plugins"
+    export QML_IMPORT_PATH="$QML_IMPORT_PATH${QML_IMPORT_PATH:+:}${!outputLib}/lib/qt5/imports"
+    export QML2_IMPORT_PATH="$QML2_IMPORT_PATH${QML2_IMPORT_PATH:+:}${!outputLib}/lib/qt5/qml"
+    export XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS${XDG_CONFIG_DIRS:+:}${!outputLib}/etc/xdg"
+    export XDG_DATA_DIRS="$XDG_DATA_DIRS${XDG_DATA_DIRS:+:}${!outputLib}/share"
+    export NIX_WRAP_XDG_CONFIG_DIRS="$NIX_WRAP_XDG_CONFIG_DIRS${NIX_WRAP_XDG_CONFIG_DIRS:+:}${!outputLib}/etc/xdg"
+    export NIX_WRAP_XDG_DATA_DIRS="$NIX_WRAP_XDG_DATA_DIRS${NIX_WRAP_XDG_DATA_DIRS:+:}${!outputLib}/share"
+}
+
+prePhases+=(_makeQtWrapperSetup)
diff --git a/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh b/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh
new file mode 100644
index 0000000000000..425048a593575
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh
@@ -0,0 +1,114 @@
+if [[ -z "$QMAKE" ]]; then
+
+_qtLinkDependencyDir() {
+    @lndir@/bin/lndir -silent "$1/$2" "$qtOut/$2"
+    if [ -n "$NIX_QT_SUBMODULE" ]; then
+        find "$1/$2" -printf "$2/%P\n" >> "$out/nix-support/qt-inputs"
+    fi
+}
+
+_qtLinkModule() {
+    if [ -d "$1/mkspecs" ]; then
+        # $1 is a Qt module
+        _qtLinkDependencyDir "$1" mkspecs
+
+        for dir in bin include lib share; do
+            if [ -d "$1/$dir" ]; then
+                _qtLinkDependencyDir "$1" "$dir"
+            fi
+        done
+    fi
+}
+
+_qtRmModules() {
+    cat "$out/nix-support/qt-inputs" | while read file; do
+      if [ -h "$out/$file" ]; then
+        rm "$out/$file"
+      fi
+    done
+
+    cat "$out/nix-support/qt-inputs" | while read file; do
+      if [ -d "$out/$file" ]; then
+        rmdir --ignore-fail-on-non-empty -p "$out/$file"
+      fi
+    done
+
+    rm "$out/nix-support/qt-inputs"
+}
+
+_qtRmQmake() {
+    rm "$qtOut/bin/qmake" "$qtOut/bin/qt.conf"
+}
+
+_qtSetQmakePath() {
+    export PATH="$qtOut/bin${PATH:+:}$PATH"
+}
+
+_qtMultioutModuleDevs() {
+    # We cannot simply set these paths in configureFlags because libQtCore retains
+    # references to the paths it was built with.
+    moveToOutput "bin" "${!outputDev}"
+    moveToOutput "include" "${!outputDev}"
+
+    # The destination directory must exist or moveToOutput will do nothing
+    mkdir -p "${!outputDev}/share"
+    moveToOutput "share/doc" "${!outputDev}"
+
+    # Move libtool archives and qmake project files to $dev/lib
+    if [ "z${!outputLib}" != "z${!outputDev}" ]; then
+        pushd "${!outputLib}"
+        if [ -d "lib" ]; then
+            find lib -name '*.a' -o -name '*.la' -o -name '*.prl' -print0 | \
+                while read -r -d $'\0' file; do
+                    mkdir -p "${!outputDev}/$(dirname "$file")"
+                    mv "${!outputLib}/$file" "${!outputDev}/$file"
+                done
+        fi
+        popd
+    fi
+}
+
+qmakeConfigurePhase() {
+    runHook preConfigure
+
+    qmake PREFIX=$out $qmakeFlags
+
+    runHook postConfigure
+}
+
+qtOut=""
+if [[ -z "$NIX_QT_SUBMODULE" ]]; then
+    qtOut=`mktemp -d`
+else
+    qtOut=$out
+fi
+
+mkdir -p "$qtOut/bin" "$qtOut/mkspecs" "$qtOut/include" "$qtOut/nix-support" "$qtOut/lib" "$qtOut/share"
+
+cp "@qt_dev@/bin/qmake" "$qtOut/bin"
+cat >"$qtOut/bin/qt.conf" <<EOF
+[Paths]
+Prefix = $qtOut
+Plugins = lib/qt5/plugins
+Imports = lib/qt5/imports
+Qml2Imports = lib/qt5/qml
+Documentation = share/doc/qt5
+EOF
+
+export QMAKE="$qtOut/bin/qmake"
+
+envHooks+=(_qtLinkModule)
+# Set PATH to find qmake first in a preConfigure hook
+# It must run after all the envHooks!
+postHooks+=(_qtSetQmakePath)
+
+if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then
+    configurePhase=qmakeConfigurePhase
+fi
+
+if [ -n "$NIX_QT_SUBMODULE" ]; then
+    postInstallHooks+=(_qtRmQmake _qtRmModules)
+    preFixupHooks+=(_qtMultioutModuleDevs)
+fi
+
+fi
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch
new file mode 100644
index 0000000000000..3d65dcc902c3d
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/compose-search-path.patch
@@ -0,0 +1,16 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+@@ -251,10 +251,7 @@ void TableGenerator::initPossibleLocatio
+     // the QTCOMPOSE environment variable
+     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"));
+ }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch
new file mode 100644
index 0000000000000..2cb3f7dfa700e
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/decrypt-ssl-traffic.patch
@@ -0,0 +1,13 @@
+Index: qt-everywhere-opensource-src-5.5.1/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.5.1.orig/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ qt-everywhere-opensource-src-5.5.1/qtbase/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.6/qtbase/default.nix b/pkgs/development/libraries/qt-5/5.6/qtbase/default.nix
new file mode 100644
index 0000000000000..ce1ea89bb8284
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/default.nix
@@ -0,0 +1,284 @@
+{ stdenv, lib, fetchgit, copyPathsToStore, fixQtModuleCMakeConfig
+, srcs
+
+, xlibs, libX11, libxcb, libXcursor, libXext, libXrender, libXi
+, xcbutil, xcbutilimage, xcbutilkeysyms, xcbutilwm, libxkbcommon
+, fontconfig, freetype, harfbuzz
+, openssl, dbus, glib, udev, libxml2, libxslt, pcre16
+, zlib, libjpeg, libpng, libtiff, sqlite, icu
+
+, coreutils, bison, flex, gdb, gperf, lndir, ruby
+, patchelf, perl, pkgconfig, python
+
+# optional dependencies
+, cups ? null
+, mysql ? null, postgresql ? null
+
+# options
+, mesaSupported, mesa
+, buildExamples ? false
+, buildTests ? false
+, developerBuild ? false
+, gtkStyle ? true, libgnomeui, GConf, gnome_vfs, gtk
+, decryptSslTraffic ? false
+}:
+
+let
+  inherit (srcs.qt5) version;
+  system-x86_64 = lib.elem stdenv.system lib.platforms.x86_64;
+
+  # Search path for Gtk plugin
+  gtkLibPath = lib.makeLibraryPath [ gtk.out gnome_vfs.out libgnomeui.out GConf.out ];
+in
+
+stdenv.mkDerivation {
+
+  name = "qtbase-${version}";
+  inherit version;
+
+  srcs = with srcs; [ qt5.src qtbase.src ];
+
+  sourceRoot = "qt-everywhere-opensource-src-${version}";
+
+  outputs = [ "dev" "out" "gtk" ];
+
+  postUnpack = ''
+    mv qtbase-opensource-src-${version} $sourceRoot/qtbase
+  '';
+
+  patches =
+    copyPathsToStore (lib.readPathsFromFile ./. ./series)
+    ++ lib.optional decryptSslTraffic ./decrypt-ssl-traffic.patch
+    ++ lib.optional mesaSupported [ ./dlopen-gl.patch ./mkspecs-libgl.patch ];
+
+  postPatch =
+    ''
+      substituteInPlace configure --replace /bin/pwd pwd
+      substituteInPlace qtbase/configure --replace /bin/pwd pwd
+      substituteInPlace qtbase/src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
+      sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i config.tests/*/*.test -i qtbase/mkspecs/*/*.conf
+
+      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "qtbase/src/corelib/Qt5Config.cmake.in"
+      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "qtbase/src/corelib/Qt5CoreMacros.cmake"
+      sed -i 's/NO_DEFAULT_PATH//' "qtbase/src/gui/Qt5GuiConfigExtras.cmake.in"
+      sed -i 's/PATHS.*NO_DEFAULT_PATH//' "qtbase/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in"
+
+      substituteInPlace qtbase/src/network/kernel/qdnslookup_unix.cpp \
+        --replace "@glibc@" "${stdenv.cc.libc.out}"
+      substituteInPlace qtbase/src/network/kernel/qhostinfo_unix.cpp \
+        --replace "@glibc@" "${stdenv.cc.libc.out}"
+
+      substituteInPlace qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp \
+        --replace "@libXcursor@" "${libXcursor.out}"
+
+      substituteInPlace qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp \
+        --replace "@openssl@" "${openssl.out}"
+
+      substituteInPlace qtbase/src/dbus/qdbus_symbols.cpp \
+        --replace "@dbus_libs@" "${dbus.lib}"
+
+      substituteInPlace \
+        qtbase/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp \
+        --replace "@libX11@" "${libX11.out}"
+    ''
+    + lib.optionalString mesaSupported ''
+      substituteInPlace \
+        qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp \
+        --replace "@mesa_lib@" "${mesa.out}"
+      substituteInPlace qtbase/mkspecs/common/linux.conf \
+        --replace "@mesa_lib@" "${mesa.out}" \
+        --replace "@mesa_inc@" "${mesa.dev}"
+    '';
+
+
+  setOutputFlags = false;
+  preConfigure = ''
+    export LD_LIBRARY_PATH="$PWD/qtbase/lib:$PWD/qtbase/plugins/platforms:$LD_LIBRARY_PATH"
+    export MAKEFLAGS=-j$NIX_BUILD_CORES
+
+    configureFlags+="\
+        -plugindir $out/lib/qt5/plugins \
+        -importdir $out/lib/qt5/imports \
+        -qmldir $out/lib/qt5/qml \
+        -docdir $out/share/doc/qt5"
+  ''
+  # QMake expects to extract the list of available modules from .gitmodules
+  + ''
+    echo '[submodule "qtbase"]' >.gitmodules
+  '';
+
+  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
+    -c++11
+    ${lib.optionalString developerBuild "-developer-build"}
+    -largefile
+    -accessibility
+    -rpath
+    -optimized-qmake
+    -strip
+    -reduce-relocations
+    -system-proxies
+    -pkg-config
+
+    -gui
+    -widgets
+    -opengl desktop
+    -qml-debug
+    -nis
+    -iconv
+    -icu
+    -pch
+    -glib
+    -xcb
+    -qpa xcb
+    -${lib.optionalString (cups == null) "no-"}cups
+    -${lib.optionalString (!gtkStyle) "no-"}gtkstyle
+
+    -no-eglfs
+    -no-directfb
+    -no-linuxfb
+    -no-kms
+
+    ${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-libpng
+    -system-libjpeg
+    -system-harfbuzz
+    -system-xcb
+    -system-xkbcommon
+    -system-pcre
+    -openssl-linked
+    -dbus-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
+  '';
+
+  # 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 = [
+    dbus glib libxml2 libxslt openssl pcre16 sqlite udev zlib
+
+    # Image formats
+    libjpeg libpng libtiff
+
+    # Text rendering
+    fontconfig freetype harfbuzz icu
+
+    # X11 libs
+    xlibs.libXcomposite libX11 libxcb libXext libXrender libXi
+    xcbutil xcbutilimage xcbutilkeysyms xcbutilwm libxkbcommon
+  ]
+  ++ lib.optional mesaSupported mesa;
+
+  buildInputs =
+    [ bison flex gperf ruby ]
+    ++ lib.optional developerBuild gdb
+    ++ lib.optional (cups != null) cups
+    ++ lib.optional (mysql != null) mysql.lib
+    ++ lib.optional (postgresql != null) postgresql
+    ++ lib.optionals gtkStyle [gnome_vfs.out libgnomeui.out gtk GConf];
+
+  nativeBuildInputs = [ fixQtModuleCMakeConfig lndir patchelf perl pkgconfig python ];
+
+  # freetype-2.5.4 changed signedness of some struct fields
+  NIX_CFLAGS_COMPILE = "-Wno-error=sign-compare";
+
+  preFixup = ''
+    # We cannot simply set these paths in configureFlags because libQtCore retains
+    # references to the paths it was built with.
+    moveToOutput "bin" "$dev"
+    moveToOutput "include" "$dev"
+    moveToOutput "mkspecs" "$dev"
+
+    # The destination directory must exist or moveToOutput will do nothing
+    mkdir -p "$dev/share"
+    moveToOutput "share/doc" "$dev"
+
+    # Move libtool archives and qmake projects
+    if [ "z''${!outputLib}" != "z''${!outputDev}" ]; then
+        pushd "''${!outputLib}"
+        find lib -name '*.a' -o -name '*.la' -o -name '*.prl' | \
+            while read -r file; do
+                mkdir -p "''${!outputDev}/$(dirname "$file")"
+                mv "''${!outputLib}/$file" "''${!outputDev}/$file"
+            done
+        popd
+    fi
+
+    # Move the QGtkStyle plugin to the gtk output
+    mkdir -p "$gtk/lib/qt5/plugins/platformthemes"
+    mv "$out/lib/qt5/plugins/platformthemes/libqgtk2.so" "$gtk/lib/qt5/plugins/platformthemes"
+    rm "$out/lib/cmake/Qt5Gui/Qt5Gui_QGtk2ThemePlugin.cmake"
+
+    # Set RPATH for QGtkStyle plugin
+    qgtk2="$gtk/lib/qt5/plugins/platformthemes/libqgtk2.so"
+    qgtk2_RPATH="$(patchelf --print-rpath "$qgtk2")"
+    qgtk2_RPATH="$qgtk2_RPATH''${qgtk2_RPATH:+:}${gtkLibPath}"
+    patchelf "$qgtk2" \
+        --add-needed libgtk-x11-2.0.so \
+        --add-needed libgnomeui-2.so \
+        --add-needed libgnomevfs-2.so \
+        --add-needed libgconf-2.so \
+        --set-rpath "$qgtk2_RPATH"
+  '';
+
+  postFixup =
+    ''
+      # Don't retain build-time dependencies like gdb and ruby.
+      sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
+
+      fixQtModuleCMakeConfig "Concurrent"
+      fixQtModuleCMakeConfig "Core"
+      fixQtModuleCMakeConfig "DBus"
+      fixQtModuleCMakeConfig "Gui"
+      fixQtModuleCMakeConfig "Network"
+      fixQtModuleCMakeConfig "OpenGL"
+      fixQtModuleCMakeConfig "OpenGLExtensions"
+      fixQtModuleCMakeConfig "PrintSupport"
+      fixQtModuleCMakeConfig "Sql"
+      fixQtModuleCMakeConfig "Test"
+      fixQtModuleCMakeConfig "Widgets"
+      fixQtModuleCMakeConfig "Xml"
+    '';
+
+  setupHook = ./setup-hook.sh;
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = http://www.qt.io;
+    description = "A cross-platform application framework for C++";
+    license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
+    maintainers = with maintainers; [ bbenoist qknight ttuegel ];
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch
new file mode 100644
index 0000000000000..401cfd5c295eb
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-dbus.patch
@@ -0,0 +1,13 @@
+Index: qt-everywhere-opensource-src-5.5.1/qtbase/src/dbus/qdbus_symbols.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.5.1.orig/qtbase/src/dbus/qdbus_symbols.cpp
++++ qt-everywhere-opensource-src-5.5.1/qtbase/src/dbus/qdbus_symbols.cpp
+@@ -89,7 +89,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.6/qtbase/dlopen-gl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch
new file mode 100644
index 0000000000000..59f510ac54dab
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gl.patch
@@ -0,0 +1,17 @@
+Index: qt-everywhere-opensource-src-5.5.1/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.5.1.orig/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
++++ qt-everywhere-opensource-src-5.5.1/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+@@ -563,7 +563,12 @@ void (*QGLXContext::getProcAddress(const
+             {
+                 extern const QString qt_gl_library_name();
+ //                QLibrary lib(qt_gl_library_name());
++                // Check system library paths first
+                 QLibrary lib(QLatin1String("GL"));
++                if (!lib.load()) {
++                    // Fallback to Mesa driver
++                    lib.setFileName(QLatin1String("@mesa_lib@/lib/libGL"));
++                }
+                 glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+             }
+         }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gtkstyle.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gtkstyle.patch
new file mode 100644
index 0000000000000..ad1719c46e298
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-gtkstyle.patch
@@ -0,0 +1,50 @@
+Index: qt-everywhere-opensource-src-5.5.1/qtbase/src/widgets/styles/qgtk2painter.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.5.1.orig/qtbase/src/widgets/styles/qgtk2painter.cpp
++++ qt-everywhere-opensource-src-5.5.1/qtbase/src/widgets/styles/qgtk2painter.cpp
+@@ -96,7 +96,7 @@ static void initGtk()
+     static bool initialized = false;
+     if (!initialized) {
+         // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
+-        QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
++        QLibrary libgtk(QLS("@gtk@/lib/libgtk-x11-2.0"), 0, 0);
+ 
+         QGtk2PainterPrivate::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
+         QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
+Index: qt-everywhere-opensource-src-5.5.1/qtbase/src/widgets/styles/qgtkstyle_p.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.5.1.orig/qtbase/src/widgets/styles/qgtkstyle_p.cpp
++++ qt-everywhere-opensource-src-5.5.1/qtbase/src/widgets/styles/qgtkstyle_p.cpp
+@@ -327,7 +327,7 @@ void QGtkStylePrivate::gtkWidgetSetFocus
+ void QGtkStylePrivate::resolveGtk() const
+ {
+     // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
+-    QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
++    QLibrary libgtk(QLS("@gtk@/lib/libgtk-x11-2.0"), 0, 0);
+ 
+     gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
+     gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
+@@ -425,8 +425,8 @@ void QGtkStylePrivate::resolveGtk() cons
+     pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
+     pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
+ 
+-    gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
+-    gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
++    gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("@libgnomeui@/lib/libgnomeui-2"), 0, "gnome_icon_lookup_sync");
++    gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("@gnome_vfs@/lib/libgnomevfs-2"), 0, "gnome_vfs_init");
+ }
+ 
+ /* \internal
+@@ -594,9 +594,9 @@ void QGtkStylePrivate::cleanupGtkWidgets
+ static bool resolveGConf()
+ {
+     if (!QGtkStylePrivate::gconf_client_get_default) {
+-        QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
+-        QGtkStylePrivate::gconf_client_get_string =  (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
+-        QGtkStylePrivate::gconf_client_get_bool =  (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
++        QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("@gconf@/lib/libgconf-2"), 4, "gconf_client_get_default");
++        QGtkStylePrivate::gconf_client_get_string =  (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("@gconf@/lib/libgconf-2"), 4, "gconf_client_get_string");
++        QGtkStylePrivate::gconf_client_get_bool =  (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("@gconf@/lib/libgconf-2"), 4, "gconf_client_get_bool");
+     }
+     return (QGtkStylePrivate::gconf_client_get_default !=0);
+ }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch
new file mode 100644
index 0000000000000..d3b5b631be766
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-libXcursor.patch
@@ -0,0 +1,17 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp
+@@ -303,10 +303,10 @@ 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);
+         bool xcursorFound = xcursorLib.load();
+         if (!xcursorFound) { // try without the version number
+-            xcursorLib.setFileName(QLatin1String("Xcursor"));
++            xcursorLib.setFileName(QLatin1String("@libXcursor@/lib/Xcursor"));
+             xcursorFound = xcursorLib.load();
+         }
+         if (xcursorFound) {
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch
new file mode 100644
index 0000000000000..f51fa44faaf55
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-openssl.patch
@@ -0,0 +1,26 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -652,8 +652,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;
+@@ -670,8 +670,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.6/qtbase/dlopen-resolv.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch
new file mode 100644
index 0000000000000..3e9b9ca2b08a2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/dlopen-resolv.patch
@@ -0,0 +1,26 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/network/kernel/qdnslookup_unix.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/network/kernel/qdnslookup_unix.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/network/kernel/qdnslookup_unix.cpp
+@@ -79,7 +79,7 @@ static void resolveLibrary()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String("@glibc@/lib/resolv"));
+         if (!lib.load())
+             return;
+     }
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/network/kernel/qhostinfo_unix.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -95,7 +95,7 @@ static void resolveLibrary()
+     if (!lib.load())
+ #endif
+     {
+-        lib.setFileName(QLatin1String("resolv"));
++        lib.setFileName(QLatin1String("@glibc@/lib/libresolv"));
+         if (!lib.load())
+             return;
+     }
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch
new file mode 100644
index 0000000000000..a05d55c8640ad
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/libressl.patch
@@ -0,0 +1,33 @@
+From 81494e67eccba04fc3fe554d76a9ca6fe7f2250e Mon Sep 17 00:00:00 2001
+From: hasufell <hasufell@gentoo.org>
+Date: Sat, 10 Oct 2015 01:15:01 +0200
+Subject: [PATCH] Fix compilation with libressl
+
+By additionally checking for defined(SSL_CTRL_SET_CURVES), which
+is defined in openssl, but not in libressl.
+---
+ src/network/ssl/qsslcontext_openssl.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -340,7 +340,7 @@ init_context:
+ 
+     const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
+     if (!qcurves.isEmpty()) {
+-#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
++#if OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
+         // Set the curves to be used
+         if (q_SSLeay() >= 0x10002000L) {
+             // SSL_CTX_ctrl wants a non-const pointer as last argument,
+@@ -354,7 +354,7 @@ init_context:
+                 return sslContext;
+             }
+         } else
+-#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
++#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && defined(SSL_CTRL_SET_CURVES) && !defined(OPENSSL_NO_EC)
+         {
+             // specific curves requested, but not possible to set -> error
+             sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch
new file mode 100644
index 0000000000000..56ee0a411d4d8
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/mkspecs-libgl.patch
@@ -0,0 +1,15 @@
+Index: qt-everywhere-opensource-src-5.5.1/qtbase/mkspecs/common/linux.conf
+===================================================================
+--- qt-everywhere-opensource-src-5.5.1.orig/qtbase/mkspecs/common/linux.conf
++++ qt-everywhere-opensource-src-5.5.1/qtbase/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.6/qtbase/nix-profiles-library-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/nix-profiles-library-paths.patch
new file mode 100644
index 0000000000000..b2aad140ad0f2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/nix-profiles-library-paths.patch
@@ -0,0 +1,22 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/kernel/qcoreapplication.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/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
new file mode 100644
index 0000000000000..2196d83837527
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/series
@@ -0,0 +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
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/setup-hook.sh b/pkgs/development/libraries/qt-5/5.6/qtbase/setup-hook.sh
new file mode 100644
index 0000000000000..a9c4fbc855f77
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/setup-hook.sh
@@ -0,0 +1,52 @@
+addToSearchPathOnceWithCustomDelimiter() {
+    local delim="$1"
+    local search="$2"
+    local target="$3"
+    local dirs
+    local exported
+    IFS="$delim" read -a dirs <<< "${!search}"
+    local canonical
+    if canonical=$(readlink -e "$target"); then
+        for dir in ${dirs[@]}; do
+            if [ "z$dir" == "z$canonical" ]; then exported=1; fi
+        done
+        if [ -z $exported ]; then
+            eval "export ${search}=\"${!search}${!search:+$delim}$canonical\""
+        fi
+    fi
+}
+
+addToSearchPathOnce() {
+    addToSearchPathOnceWithCustomDelimiter ':' "$@"
+}
+
+propagateOnce() {
+    addToSearchPathOnceWithCustomDelimiter ' ' "$@"
+}
+
+_qtPropagateRuntimeDependencies() {
+    for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
+        if [ -d "$1/$dir" ]; then
+            propagateOnce propagatedBuildInputs "$1"
+            propagateOnce propagatedUserEnvPkgs "$1"
+            break
+        fi
+    done
+    addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins"
+    addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports"
+    addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml"
+}
+
+envHooks+=(_qtPropagateRuntimeDependencies)
+
+_qtMultioutDevs() {
+    # This is necessary whether the package is a Qt module or not
+    moveToOutput "mkspecs" "${!outputDev}"
+}
+
+preFixupHooks+=(_qtMultioutDevs)
+
+if [[ -z "$NIX_QT_PIC" ]]; then
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE${NIX_CFLAGS_COMPILE:+ }-fPIC"
+    export NIX_QT_PIC=1
+fi
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch
new file mode 100644
index 0000000000000..1c0541bdc2ad6
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/tzdir.patch
@@ -0,0 +1,40 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/tools/qtimezoneprivate_tz.cpp
+@@ -62,7 +62,10 @@ 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";
++    if (!QFile::exists(path))
++        path = QStringLiteral("/usr/share/zoneinfo/zone.tab");
+     if (!QFile::exists(path))
+         path = QStringLiteral("/usr/lib/zoneinfo/zone.tab");
+ 
+@@ -560,12 +563,18 @@ 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);
+         if (!tzif.open(QIODevice::ReadOnly)) {
+-            tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+-            if (!tzif.open(QIODevice::ReadOnly))
+-                return;
++            // Open named tz, try modern path first, if fails try legacy path
++            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++            if (!tzif.open(QIODevice::ReadOnly)) {
++                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++                if (!tzif.open(QIODevice::ReadOnly))
++                    return;
++            }
+         }
+     }
+ 
diff --git a/pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch b/pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch
new file mode 100644
index 0000000000000..ff4ad82ea8f8d
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtbase/xdg-config-dirs.patch
@@ -0,0 +1,42 @@
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/io/qsettings.cpp
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/corelib/io/qsettings.cpp
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/io/qsettings.cpp
+@@ -1155,6 +1155,24 @@ QConfFileSettingsPrivate::QConfFileSetti
+     if (!application.isEmpty())
+         confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
+     confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
++
++#if !defined(Q_OS_WIN)
++    // Add directories specified in $XDG_CONFIG_DIRS
++    const QString pathEnv = QString::fromLocal8Bit(getenv("XDG_CONFIG_DIRS"));
++    if (!pathEnv.isEmpty()) {
++        const QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
++        if (!pathEntries.isEmpty()) {
++            int j = 4; // This is the number of confFiles set above -- we need to start adding $XDG_CONFIG_DIRS after those.
++            for (int k = 0; k < pathEntries.size() && j < NumConfFiles - 1; ++k) {
++                const QString& path = pathEntries.at(k);
++                if (!application.isEmpty())
++                    confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + appFile, false));
++                confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + orgFile, false));
++            }
++        }
++    }
++#endif
++
+ #else
+     QString confName = getPath(format, QSettings::UserScope) + org;
+     if (!application.isEmpty())
+Index: qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/io/qsettings_p.h
+===================================================================
+--- qt-everywhere-opensource-src-5.6.0.orig/qtbase/src/corelib/io/qsettings_p.h
++++ qt-everywhere-opensource-src-5.6.0/qtbase/src/corelib/io/qsettings_p.h
+@@ -241,7 +241,7 @@ public:
+         F_Organization = 0x1,
+         F_User = 0x0,
+         F_System = 0x2,
+-        NumConfFiles = 4
++        NumConfFiles = 40 // HACK: increase NumConfFiles from 4 to 40 in order to accommodate more paths in $XDG_CONFIG_DIRS -- ellis
+ #else
+         SandboxConfFile = 0,
+         NumConfFiles = 1
diff --git a/pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix b/pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix
new file mode 100644
index 0000000000000..35538c7261f1d
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtconnectivity.nix
@@ -0,0 +1,10 @@
+{ qtSubmodule, qtbase, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtconnectivity";
+  qtInputs = [ qtbase qtdeclarative ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Bluetooth"
+    fixQtModuleCMakeConfig "Nfc"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix
new file mode 100644
index 0000000000000..407513f784989
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/default.nix
@@ -0,0 +1,14 @@
+{ qtSubmodule, lib, copyPathsToStore, python, qtbase, qtsvg, qtxmlpatterns }:
+
+qtSubmodule {
+  name = "qtdeclarative";
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  qtInputs = [ qtbase qtsvg qtxmlpatterns ];
+  nativeBuildInputs = [ python ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Qml"
+    fixQtModuleCMakeConfig "Quick"
+    fixQtModuleCMakeConfig "QuickTest"
+    fixQtModuleCMakeConfig "QuickWidgets"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/nix-profiles-import-paths.patch b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/nix-profiles-import-paths.patch
new file mode 100644
index 0000000000000..06b244b974ffe
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/nix-profiles-import-paths.patch
@@ -0,0 +1,20 @@
+Index: qtdeclarative-opensource-src-5.5.1/src/qml/qml/qqmlimport.cpp
+===================================================================
+--- qtdeclarative-opensource-src-5.5.1.orig/src/qml/qml/qqmlimport.cpp
++++ qtdeclarative-opensource-src-5.5.1/src/qml/qml/qqmlimport.cpp
+@@ -1549,6 +1549,15 @@ QQmlImportDatabase::QQmlImportDatabase(Q
+     QString installImportsPath =  QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+     addImportPath(installImportsPath);
+ 
++    // Add library paths derived from NIX_PROFILES.
++    const QByteArrayList profiles = qgetenv("NIX_PROFILES").split(' ');
++    const QString qmldir = QString::fromLatin1("/lib/qt5/qml");
++    Q_FOREACH (const QByteArray &profile, profiles) {
++        if (!profile.isEmpty()) {
++            addImportPath(QFile::decodeName(profile) + qmldir);
++        }
++    }
++
+     // env import paths
+     QByteArray envImportPath = qgetenv("QML2_IMPORT_PATH");
+     if (!envImportPath.isEmpty()) {
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdeclarative/series b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/series
new file mode 100644
index 0000000000000..7dbe197c56e01
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtdeclarative/series
@@ -0,0 +1 @@
+nix-profiles-import-paths.patch
diff --git a/pkgs/development/libraries/qt-5/5.6/qtdoc.nix b/pkgs/development/libraries/qt-5/5.6/qtdoc.nix
new file mode 100644
index 0000000000000..578ea6ba0b226
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtdoc.nix
@@ -0,0 +1,6 @@
+{ qtSubmodule, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtdoc";
+  qtInputs = [ qtdeclarative ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtenginio.nix b/pkgs/development/libraries/qt-5/5.6/qtenginio.nix
new file mode 100644
index 0000000000000..503a0f7ce4f55
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtenginio.nix
@@ -0,0 +1,9 @@
+{ qtSubmodule, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtenginio";
+  qtInputs = [ qtdeclarative ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Enginio"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix b/pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix
new file mode 100644
index 0000000000000..3273f12eb8302
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtgraphicaleffects.nix
@@ -0,0 +1,6 @@
+{ qtSubmodule, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtgraphicaleffects";
+  qtInputs = [ qtdeclarative ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtimageformats.nix b/pkgs/development/libraries/qt-5/5.6/qtimageformats.nix
new file mode 100644
index 0000000000000..03d0fffbe80e1
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtimageformats.nix
@@ -0,0 +1,6 @@
+{ qtSubmodule, qtbase }:
+
+qtSubmodule {
+  name = "qtimageformats";
+  qtInputs = [ qtbase ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtlocation.nix b/pkgs/development/libraries/qt-5/5.6/qtlocation.nix
new file mode 100644
index 0000000000000..0e2ad8bafb30d
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtlocation.nix
@@ -0,0 +1,10 @@
+{ qtSubmodule, qtbase, qtmultimedia }:
+
+qtSubmodule {
+  name = "qtlocation";
+  qtInputs = [ qtbase qtmultimedia ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Location"
+    fixQtModuleCMakeConfig "Positioning"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix b/pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix
new file mode 100644
index 0000000000000..9eb68ba6b5ba2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtmultimedia.nix
@@ -0,0 +1,16 @@
+{ qtSubmodule, qtbase, qtdeclarative, pkgconfig
+, alsaLib, gstreamer, gst-plugins-base, libpulseaudio
+}:
+
+qtSubmodule {
+  name = "qtmultimedia";
+  qtInputs = [ qtbase qtdeclarative ];
+  buildInputs = [
+    pkgconfig alsaLib gstreamer gst-plugins-base libpulseaudio
+  ];
+  qmakeFlags = [ "GST_VERSION=1.0" ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Multimedia"
+    fixQtModuleCMakeConfig "MultimediaWidgets"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix b/pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix
new file mode 100644
index 0000000000000..93a864621b824
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtquickcontrols.nix
@@ -0,0 +1,6 @@
+{ qtSubmodule, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtquickcontrols";
+  qtInputs = [ qtdeclarative ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch b/pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch
new file mode 100644
index 0000000000000..887e107b6c1b2
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtscript/0001-glib-2.32.patch
@@ -0,0 +1,25 @@
+From abd80356449bb36c8adcc5c9ca1df6b47715d265 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Sun, 23 Aug 2015 09:13:34 -0500
+Subject: [PATCH] glib-2.32
+
+---
+ src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
+index 1f6d25e..087c3fb 100644
+--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
++++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h
+@@ -81,7 +81,7 @@
+ #include <pthread.h>
+ #elif PLATFORM(GTK)
+ #include <wtf/gtk/GOwnPtr.h>
+-typedef struct _GMutex GMutex;
++typedef union _GMutex GMutex;
+ typedef struct _GCond GCond;
+ #endif
+ 
+-- 
+2.5.0
+
diff --git a/pkgs/development/libraries/qt-5/5.6/qtscript/default.nix b/pkgs/development/libraries/qt-5/5.6/qtscript/default.nix
new file mode 100644
index 0000000000000..b81a43aeadb04
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtscript/default.nix
@@ -0,0 +1,10 @@
+{ qtSubmodule, qtbase, qttools }:
+
+qtSubmodule {
+  name = "qtscript";
+  qtInputs = [ qtbase qttools ];
+  patches = [ ./0001-glib-2.32.patch ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Script"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtsensors.nix b/pkgs/development/libraries/qt-5/5.6/qtsensors.nix
new file mode 100644
index 0000000000000..5776f45a70689
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtsensors.nix
@@ -0,0 +1,9 @@
+{ qtSubmodule, qtbase, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtsensors";
+  qtInputs = [ qtbase qtdeclarative ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Sensors"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch b/pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch
new file mode 100644
index 0000000000000..3a813dc800745
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtserialport/0001-dlopen-serialport-udev.patch
@@ -0,0 +1,28 @@
+From d81c2c870b9bea8fb8e6b85baefb06542f568338 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Sun, 23 Aug 2015 09:16:02 -0500
+Subject: [PATCH] dlopen serialport udev
+
+---
+ src/serialport/qtudev_p.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
+index 6f2cabd..81b9849 100644
+--- a/src/serialport/qtudev_p.h
++++ b/src/serialport/qtudev_p.h
+@@ -105,9 +105,9 @@ inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolN
+ inline bool resolveSymbols(QLibrary *udevLibrary)
+ {
+     if (!udevLibrary->isLoaded()) {
+-        udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 1);
++        udevLibrary->setFileNameAndVersion(QStringLiteral("@libudev@/lib/libudev"), 1);
+         if (!udevLibrary->load()) {
+-            udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 0);
++            udevLibrary->setFileNameAndVersion(QStringLiteral("@libudev@/lib/libudev"), 0);
+             if (!udevLibrary->load()) {
+                 qWarning("Failed to load the library: %s, supported version(s): %i and %i", qPrintable(udevLibrary->fileName()), 1, 0);
+                 return false;
+-- 
+2.5.0
+
diff --git a/pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix b/pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix
new file mode 100644
index 0000000000000..3f409f9c0e084
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtserialport/default.nix
@@ -0,0 +1,15 @@
+{ qtSubmodule, qtbase, substituteAll, libudev }:
+
+qtSubmodule {
+  name = "qtserialport";
+  qtInputs = [ qtbase ];
+  patches = [
+    (substituteAll {
+      src = ./0001-dlopen-serialport-udev.patch;
+      libudev = libudev.out;
+    })
+  ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "SerialPort"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtsvg.nix b/pkgs/development/libraries/qt-5/5.6/qtsvg.nix
new file mode 100644
index 0000000000000..a460d6da4c2ad
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtsvg.nix
@@ -0,0 +1,9 @@
+{ qtSubmodule, qtbase }:
+
+qtSubmodule {
+  name = "qtsvg";
+  qtInputs = [ qtbase ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "Svg"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qttools.nix b/pkgs/development/libraries/qt-5/5.6/qttools.nix
new file mode 100644
index 0000000000000..1472691c52547
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qttools.nix
@@ -0,0 +1,16 @@
+{ qtSubmodule, qtbase }:
+
+qtSubmodule {
+  name = "qttools";
+  qtInputs = [ qtbase ];
+  postFixup = ''
+    moveToOutput "bin/qdbus" "$out"
+    moveToOutput "bin/qtpaths" "$out"
+
+    fixQtModuleCMakeConfig "Designer"
+    fixQtModuleCMakeConfig "Help"
+    fixQtModuleCMakeConfig "LinguistTools"
+    fixQtModuleCMakeConfig "UiPlugin"
+    fixQtModuleCMakeConfig "UiTools"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qttranslations.nix b/pkgs/development/libraries/qt-5/5.6/qttranslations.nix
new file mode 100644
index 0000000000000..50fc8cf6826a0
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qttranslations.nix
@@ -0,0 +1,6 @@
+{ qtSubmodule, qttools }:
+
+qtSubmodule {
+  name = "qttranslations";
+  qtInputs = [ qttools ];
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix b/pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix
new file mode 100644
index 0000000000000..c0d0f9e7d714e
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtwebsockets.nix
@@ -0,0 +1,9 @@
+{ qtSubmodule, qtbase, qtdeclarative }:
+
+qtSubmodule {
+  name = "qtwebsockets";
+  qtInputs = [ qtbase qtdeclarative ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "WebSockets"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtx11extras.nix b/pkgs/development/libraries/qt-5/5.6/qtx11extras.nix
new file mode 100644
index 0000000000000..db92f1353627d
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtx11extras.nix
@@ -0,0 +1,9 @@
+{ qtSubmodule, qtbase }:
+
+qtSubmodule {
+  name = "qtx11extras";
+  qtInputs = [ qtbase ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "X11Extras"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix b/pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix
new file mode 100644
index 0000000000000..3b22132e4c38e
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/qtxmlpatterns.nix
@@ -0,0 +1,9 @@
+{ qtSubmodule, qtbase }:
+
+qtSubmodule {
+  name = "qtxmlpatterns";
+  qtInputs = [ qtbase ];
+  postFixup = ''
+    fixQtModuleCMakeConfig "XmlPatterns"
+  '';
+}
diff --git a/pkgs/development/libraries/qt-5/5.6/srcs.nix b/pkgs/development/libraries/qt-5/5.6/srcs.nix
new file mode 100644
index 0000000000000..9ddbbbde078f0
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.6/srcs.nix
@@ -0,0 +1,261 @@
+# DO NOT EDIT! This file is generated automatically by manifest.sh
+{ fetchurl, mirror }:
+
+{
+  qttools = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qttools-opensource-src-5.6.0.tar.xz";
+      sha256 = "1791c9a1vxv0q2ywr00ya5rxaggidsq81s8h8fwmql75pdhlq90d";
+      name = "qttools-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtwebengine = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtwebengine-opensource-src-5.6.0.tar.xz";
+      sha256 = "00vaqx3mypqlnjkfwhx54r6ygfs07amkwc4rma0sg64zdjnvb8la";
+      name = "qtwebengine-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtserialbus = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtserialbus-opensource-src-5.6.0.tar.xz";
+      sha256 = "13hbmj9pilh5gkbbngfbp225qvc650pnzvpzawpnf69zwl757jlc";
+      name = "qtserialbus-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtwayland = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtwayland-opensource-src-5.6.0.tar.xz";
+      sha256 = "1k5zsgz54wlkxm3ici55lbbz286bk2791vri02bjgja5y9102pdm";
+      name = "qtwayland-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qt5 = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qt5-opensource-src-5.6.0.tar.xz";
+      sha256 = "195dl9pk9slbiy6mgwwpc70vaw62sdhxc3lxmlnyddk99widqa3k";
+      name = "qt5-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtimageformats = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtimageformats-opensource-src-5.6.0.tar.xz";
+      sha256 = "1nmsh682idxl0642q7376r9qfxkx0736q9pl4jx179c9lrsl519c";
+      name = "qtimageformats-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtactiveqt = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtactiveqt-opensource-src-5.6.0.tar.xz";
+      sha256 = "0xrjr9jwkxxcv46a8vj77px3v1p36nm6rpvyxma0wb4xhpippp3a";
+      name = "qtactiveqt-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtdoc = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtdoc-opensource-src-5.6.0.tar.xz";
+      sha256 = "1z69yl8nkvp21arjhzl34gr8gvxm5b03d58lwnddl4mkaxbi4vap";
+      name = "qtdoc-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtsensors = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtsensors-opensource-src-5.6.0.tar.xz";
+      sha256 = "0blwqmkh0hn1716d5fvy0vnh56y9iikl34ayz6ksl0ayxhpkk3si";
+      name = "qtsensors-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtwebchannel = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtwebchannel-opensource-src-5.6.0.tar.xz";
+      sha256 = "0ky1njksczyfb7y7p5kfgzbx9vgajzy51g2y3vrpfvl6bs9j8m62";
+      name = "qtwebchannel-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtmacextras = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtmacextras-opensource-src-5.6.0.tar.xz";
+      sha256 = "1jkmwppapvymdr1kwdrbjlxhcafcn4jb23ssnhrvvgcq3lnl5lhj";
+      name = "qtmacextras-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtwebsockets = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtwebsockets-opensource-src-5.6.0.tar.xz";
+      sha256 = "17vi3n27gx3f3c2lii3b70pzz6mpblam3236v6mj439xzrlvi2i6";
+      name = "qtwebsockets-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtconnectivity = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtconnectivity-opensource-src-5.6.0.tar.xz";
+      sha256 = "1ss0ibabiv7n5hakkxmkc4msrwgqcvfffdjajnv5jrq0030v0p0c";
+      name = "qtconnectivity-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtscript = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtscript-opensource-src-5.6.0.tar.xz";
+      sha256 = "0hjhkh4lia1i0iir1i8dr57gizi74h73j0phhir3q3wsglcpax5c";
+      name = "qtscript-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qttranslations = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qttranslations-opensource-src-5.6.0.tar.xz";
+      sha256 = "0jfdfj2z0nvf1xblmdxaphn0psjycrb5g3jxxcddkci214gka2cq";
+      name = "qttranslations-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtlocation = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtlocation-opensource-src-5.6.0.tar.xz";
+      sha256 = "1jakjrwic01b5vyij6hfzdfpipandpkj9li3d7wf9bzws0cia3in";
+      name = "qtlocation-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtserialport = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtserialport-opensource-src-5.6.0.tar.xz";
+      sha256 = "07rwhmh9y7b3ycvx4d4d1j32nahf8nhsb9qj99kxz5xrdfv7zvhn";
+      name = "qtserialport-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtsvg = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtsvg-opensource-src-5.6.0.tar.xz";
+      sha256 = "07v4bzxd31dhkhp52y4g2ii0sslmk48cqkkz32v41frqj4qrk1vr";
+      name = "qtsvg-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtwebview = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtwebview-opensource-src-5.6.0.tar.xz";
+      sha256 = "0mqbh125bq37xybwslhri4pl861r26cnraiz9ivh4881kqzab3x4";
+      name = "qtwebview-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtcanvas3d = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtcanvas3d-opensource-src-5.6.0.tar.xz";
+      sha256 = "1kwykm1ffgpjgb3ggd4h2d2x3yhp9jsc0gnwlks620bahagdbbb6";
+      name = "qtcanvas3d-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtwinextras = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtwinextras-opensource-src-5.6.0.tar.xz";
+      sha256 = "14xvm081wjyild2wi7pcilqxdkhc8b0lf9yn7yf7zp576i9ir5aq";
+      name = "qtwinextras-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtgraphicaleffects = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtgraphicaleffects-opensource-src-5.6.0.tar.xz";
+      sha256 = "1s0n8hrmrfs53cmm7i45p8zavvmsl0aisd5sgj93p8c5rzyi3s81";
+      name = "qtgraphicaleffects-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtxmlpatterns = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtxmlpatterns-opensource-src-5.6.0.tar.xz";
+      sha256 = "1m0rr0m9zg2d6rdban2p5qyx8rdnjnjsfk3bm72bh47hscxipvds";
+      name = "qtxmlpatterns-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtquickcontrols2 = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtquickcontrols2-opensource-src-5.6.0.tar.xz";
+      sha256 = "1q7yp7l32jd3p28587ldxzkj58z1aad9gcs80w6vqc9952i6xv2r";
+      name = "qtquickcontrols2-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtbase = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtbase-opensource-src-5.6.0.tar.xz";
+      sha256 = "0ynnvcs5idivzldsq5ciqg9myg82b3l3906l4vjv54lyamf8mykf";
+      name = "qtbase-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qt3d = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qt3d-opensource-src-5.6.0.tar.xz";
+      sha256 = "17a37xhav5mxspx2c9wsgvcilv7ys40q6minmlqd1gnfmsfphqdr";
+      name = "qt3d-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtenginio = {
+    version = "1.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtenginio-opensource-src-1.6.0.tar.xz";
+      sha256 = "033z2jncci64s7s9ml5rsfsnrkdmhx1g5dfvr61imv63pzxxqzb2";
+      name = "qtenginio-opensource-src-1.6.0.tar.xz";
+    };
+  };
+  qtx11extras = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtx11extras-opensource-src-5.6.0.tar.xz";
+      sha256 = "099lc7kxcxgp5s01ddnd6n955fc8866caark43xfs2dw0a6pdva7";
+      name = "qtx11extras-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtdeclarative = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtdeclarative-opensource-src-5.6.0.tar.xz";
+      sha256 = "0k70zlyx1nh35caiav4s3jvg5l029pvilm6sarxmfj73y19z0mcc";
+      name = "qtdeclarative-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtmultimedia = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtmultimedia-opensource-src-5.6.0.tar.xz";
+      sha256 = "11h66xcr3y3w8hhvx801r66yirvf1kppasjlhm25qvr6rpb9jgqh";
+      name = "qtmultimedia-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtquickcontrols = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtquickcontrols-opensource-src-5.6.0.tar.xz";
+      sha256 = "12vqkxpz5y2bbh083lpsxcianykl8x7am49pmc4x221a5xwrc27c";
+      name = "qtquickcontrols-opensource-src-5.6.0.tar.xz";
+    };
+  };
+  qtandroidextras = {
+    version = "5.6.0";
+    src = fetchurl {
+      url = "${mirror}/official_releases/qt/5.6/5.6.0/submodules/qtandroidextras-opensource-src-5.6.0.tar.xz";
+      sha256 = "1qhrn8vhfn0z73bc2ls1b4zfvr7r5gn7b5xdmjp26hi338j55vp0";
+      name = "qtandroidextras-opensource-src-5.6.0.tar.xz";
+    };
+  };
+}