about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/qt-5
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/qt-5')
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/default.nix380
-rwxr-xr-xnixpkgs/pkgs/development/libraries/qt-5/5.15/fetch.sh17
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/modules40
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0001-qtbase-mkspecs-mac.patch485
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0003-qtbase-mkspecs.patch490
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0004-qtbase-replace-libdir.patch68
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0005-qtbase-cmake.patch194
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0006-qtbase-gtk3.patch48
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0007-qtbase-xcursor.patch29
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0008-qtbase-tzdir.patch64
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0009-qtbase-qtpluginpath.patch33
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0010-qtbase-assert.patch32
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0011-fix-header_module.patch22
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0012-qtbase-tbd-frameworks.patch15
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0014-aarch64-darwin.patch275
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative-default-disable-qmlcache.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative.patch114
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtscript.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtserialport.patch22
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qttools.patch15
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-checks.patch29
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-no-platform-check.patch12
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-link-pulseaudio.patch8
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-mac-dont-set-dsymutil-path.patch12
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-qos-classes.patch11
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-readline.patch30
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-icu68.patch170
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit.patch12
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs-generated.json202
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs.nix94
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/README.md81
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qmake-libtool.sh25
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh64
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh36
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh34
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh54
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh112
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh1
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh107
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/mkDerivation.nix15
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qt3d.nix9
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtbase.nix424
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtcharts.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix13
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtdatavis3d.nix9
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtdoc.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtgamepad.nix10
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtimageformats.nix20
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtlocation.nix13
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtlottie.nix9
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtmacextras.nix10
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix24
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtnetworkauth.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtpim.nix27
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtpositioning.nix14
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtremoteobjects.nix8
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtscript.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtscxml.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtsensors.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialbus.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialport.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtspeech.nix9
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtsvg.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtsystems.nix54
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qttools.nix42
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qttranslations.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland-app_id.patch36
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland.nix15
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix12
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebengine.nix327
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebglplugin.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebkit.nix63
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebview.nix12
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtx11extras.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix7
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/qt-env.nix21
-rw-r--r--nixpkgs/pkgs/development/libraries/qt-5/qtModule.nix94
83 files changed, 4898 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/default.nix b/nixpkgs/pkgs/development/libraries/qt-5/5.15/default.nix
new file mode 100644
index 000000000000..a2b38046c5a8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/default.nix
@@ -0,0 +1,380 @@
+/*
+
+# Updates
+
+Run `./fetch.sh` to update package sources from Git.
+Check for any minor version changes.
+
+*/
+
+{ makeScopeWithSplicing', generateSplicesForMkScope
+, lib, stdenv, fetchurl, fetchgit, fetchpatch, fetchFromGitHub, makeSetupHook, makeWrapper
+, bison, cups ? null, harfbuzz, libGL, perl, python3
+, gstreamer, gst-plugins-base, gtk3, dconf
+, llvmPackages_15, overrideSDK, overrideLibcxx
+, darwin
+
+  # options
+, developerBuild ? false
+, decryptSslTraffic ? false
+, debug ? false
+, config
+}:
+
+let
+
+  srcs = import ./srcs.nix { inherit lib fetchgit fetchFromGitHub; };
+
+  qtCompatVersion = srcs.qtbase.version;
+
+  patches = {
+    qtbase = lib.optionals stdenv.isDarwin [
+      ./qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
+
+      # Patch framework detection to support X.framework/X.tbd,
+      # extending the current support for X.framework/X.
+      ./qtbase.patch.d/0012-qtbase-tbd-frameworks.patch
+
+      ./qtbase.patch.d/0014-aarch64-darwin.patch
+    ] ++ [
+      ./qtbase.patch.d/0003-qtbase-mkspecs.patch
+      ./qtbase.patch.d/0004-qtbase-replace-libdir.patch
+      ./qtbase.patch.d/0005-qtbase-cmake.patch
+      ./qtbase.patch.d/0006-qtbase-gtk3.patch
+      ./qtbase.patch.d/0007-qtbase-xcursor.patch
+      ./qtbase.patch.d/0008-qtbase-tzdir.patch
+      ./qtbase.patch.d/0009-qtbase-qtpluginpath.patch
+      ./qtbase.patch.d/0010-qtbase-assert.patch
+      ./qtbase.patch.d/0011-fix-header_module.patch
+    ];
+    qtdeclarative = [
+      ./qtdeclarative.patch
+      # prevent headaches from stale qmlcache data
+      ./qtdeclarative-default-disable-qmlcache.patch
+    ];
+    qtlocation = lib.optionals stdenv.cc.isClang [
+      # Fix build with Clang 16
+      (fetchpatch {
+        url = "https://github.com/boostorg/numeric_conversion/commit/50a1eae942effb0a9b90724323ef8f2a67e7984a.patch";
+        stripLen = 1;
+        extraPrefix = "src/3rdparty/mapbox-gl-native/deps/boost/1.65.1/";
+        hash = "sha256-UEvIXzn387f9BAeBdhheStD/4M7en+rmqX8C6gstl6k=";
+      })
+    ];
+    qtmultimedia = lib.optionals stdenv.isDarwin [
+      # build patch for qtmultimedia with xcode 15
+      (fetchpatch {
+        url = "https://raw.githubusercontent.com/Homebrew/formula-patches/3f509180/qt5/qt5-qtmultimedia-xcode15.patch";
+        stripLen = 1;
+        hash = "sha256-HrEqfmm8WbapWgLM0L4AKW8168pwT2zYI8HOJruEPSs=";
+      })
+    ];
+    qtpim = [
+      ## Upstream patches after the Qt6 transition that apply without problems & fix bugs
+
+      # Fixes QList -> QSet conversion
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/f337e281e28904741a3b1ac23d15c3a83ef2bbc9.patch";
+        hash = "sha256-zlxD45JnbhIgdJxMmGxGMUBcQPcgzpu3s4bLX939jL0=";
+      })
+      # Fixes invalid syntax from a previous bad patch in tests
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/2aefdd8bd28a4decf9ef8381f5b255f39f1ee90c.patch";
+        hash = "sha256-mg93QF3hi50igw1/Ok7fEs9iCaN6co1+p2/5fQtxTmc=";
+      })
+      # Unit test account for QList index change
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/79b41af6a4117f5efb0298289e20c30b4d0b0b2e.patch";
+        hash = "sha256-u+cLl4lu6r2+j5GAiasqbB6/OZPz5A6GpSB33vd/VBg=";
+      })
+      # Remove invalid method overload which confuses the QML engine
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/5679a6141c76ae7d64c3acc8a87b1adb048289e0.patch";
+        hash = "sha256-z8f8kLhC9CqBOfGPL8W9KJq7MwALAAicXfRkHiQEVJ4=";
+      })
+      # Specify enum flag type properly in unit test
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/a43cc24e57db8d3c3939fa540d67da3294dcfc5c.patch";
+        hash = "sha256-SsYkxX6prxi8VRZr4az+wqawcRN8tR3UuIFswJL+3T4=";
+      })
+      # Update qHash methods to return size_t instead of uint
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/9c698155d82fc2b68a87c59d0443c33f9085b117.patch";
+        hash = "sha256-rb8D8taaglhQikYSAPrtLvazgIw8Nga/a9+J21k8gIo=";
+      })
+      # Mark virtual methods with override keyword
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/f34cf2ff2b0f428d5b8a70763b29088075ebbd1c.patch";
+        hash = "sha256-tNPOEVpx1eqHx5T23ueW32KxMQ/SB+TBCJ4PZ6SA3LI=";
+      })
+      # Fix calendardemo example
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/a66590d473753bc49105d3132fb9e4150c92a14a.patch";
+        hash = "sha256-RPRtGQ24NQYewnv6+IqYITpwD/XxuK68a1iKgFmKm3c=";
+      })
+      # Make the tests pass on big endian systems
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/7802f038ed1391078e27fa3f37d785a69314537b.patch";
+        hash = "sha256-hogUXyPXjGE0q53PWOjiQbQ2YzOsvrJ7mo9djGIbjVQ=";
+      })
+      # Fix some deprecated QChar constructor issues in unit tests
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/114615812dcf9398c957b0833e860befe15f840f.patch";
+        hash = "sha256-yZ1qs8y5DSq8FDXRPyuSPRIzjEUTWAhpVide/b+xaLQ=";
+      })
+      # Accessors should be const
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/a2bf7cdf05c264b5dd2560f799760b5508f154e4.patch";
+        hash = "sha256-+YfPrKyOKnPkqFokwW/aDsEivg4TzdJwQpDdAtM+rQE=";
+      })
+      # Enforce detail access constraints in contact operations by default
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/8765a35233aa21a932ee92bbbb92a5f8edd4dc68.patch";
+        hash = "sha256-vp/enerVecEXz4zyxQ66DG+fVVWxI4bYnLj92qaaqNk=";
+      })
+      # Fixes broken file generation, which breaks reverse dependencies that try to find one of its modules
+      (fetchpatch {
+        url = "https://github.com/qt/qtpim/commit/4b2bdce30bd0629c9dc0567af6eeaa1d038f3152.patch";
+        hash = "sha256-2dXhkZyxPvY2KQq2veerAlpXkpU5/FeArWRlm1aOcEY=";
+      })
+
+      ## Patches that haven't been upstreamed
+
+      # Fix tst_QContactManager::compareVariant_data test
+      (fetchpatch {
+        url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/1001_fix-qtdatetime-null-comparison.patch";
+        hash = "sha256-k/rO9QjwSlRChwFTZLkxDjZWqFkua4FNbaNf1bJKLxc=";
+      })
+      # Avoid crash while parsing vCards from different threads
+      (fetchpatch {
+        url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/1002_Avoid-crash-while-parsing-vcards-from-different-threads.patch";
+        hash = "sha256-zhayAoWgcmKosEGVBy2k6a2e6BxyVwfGX18tBbzqEk8=";
+      })
+      # Adapt to JSON parser behavior change in Qt 5.15
+      (fetchpatch {
+        url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/1003_adapt_to_json_parser_change.patch";
+        hash = "sha256-qAIa48hmDd8vMH/ywqW+22vISKai76XnjgFuB+tQbIU=";
+      })
+      # Fix version being 0.0.0
+      (fetchpatch {
+        url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/2000_revert_module_version.patch";
+        hash = "sha256-6wg/eVu9J83yvIO428U1FX3otz58tAy6pCvp7fqOBKU=";
+      })
+    ];
+    qtscript = [ ./qtscript.patch ];
+    qtserialport = [ ./qtserialport.patch ];
+    qtsystems = [
+      # Enable building with udisks support
+      (fetchpatch {
+        url = "https://salsa.debian.org/qt-kde-team/qt/qtsystems/-/raw/a23fd92222c33479d7f3b59e48116def6b46894c/debian/patches/2001_build_with_udisk.patch";
+        hash = "sha256-B/z/+tai01RU/bAJSCp5a0/dGI8g36nwso8MiJv27YM=";
+      })
+    ];
+    qtwebengine = [
+      (fetchpatch {
+        url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a6f16c6daea3b5a1f7bc9f175d1645922c131563/qt5/qt5-webengine-python3.patch";
+        hash = "sha256-rUSDwTucXVP3Obdck7LRTeKZ+JYQSNhQ7+W31uHZ9yM=";
+      })
+      (fetchpatch {
+        url = "https://raw.githubusercontent.com/Homebrew/formula-patches/7ae178a617d1e0eceb742557e63721af949bd28a/qt5/qt5-webengine-chromium-python3.patch";
+        stripLen = 1;
+        extraPrefix = "src/3rdparty/";
+        hash = "sha256-MZGYeMdGzwypfKoSUaa56K3inbcGRx7he/+AFyk5ekA=";
+      })
+      (fetchpatch {
+        url = "https://raw.githubusercontent.com/Homebrew/formula-patches/7ae178a617d1e0eceb742557e63721af949bd28a/qt5/qt5-webengine-gcc12.patch";
+        stripLen = 1;
+        extraPrefix = "src/3rdparty/";
+        hash = "sha256-s4GsGMJTBNWw2gTJuIEP3tqT82AmTsR2mbj59m2p6rM=";
+      })
+      ./qtwebengine-link-pulseaudio.patch
+    ] ++ lib.optionals stdenv.isDarwin [
+      ./qtwebengine-darwin-no-platform-check.patch
+      ./qtwebengine-mac-dont-set-dsymutil-path.patch
+      ./qtwebengine-darwin-checks.patch
+    ];
+    qtwebkit = [
+      (fetchpatch {
+        name = "qtwebkit-bison-3.7-build.patch";
+        url = "https://github.com/qtwebkit/qtwebkit/commit/d92b11fea65364fefa700249bd3340e0cd4c5b31.patch";
+        sha256 = "0h8ymfnwgkjkwaankr3iifiscsvngqpwb91yygndx344qdiw9y0n";
+      })
+      (fetchpatch {
+        name = "qtwebkit-glib-2.68.patch";
+        url = "https://github.com/qtwebkit/qtwebkit/pull/1058/commits/5b698ba3faffd4e198a45be9fe74f53307395e4b.patch";
+        sha256 = "0a3xv0h4lv8wggckgy8cg8xnpkg7n9h45312pdjdnnwy87xvzss0";
+      })
+      (fetchpatch {
+        name = "qtwebkit-darwin-handle.patch";
+        url = "https://github.com/qtwebkit/qtwebkit/commit/5c272a21e621a66862821d3ae680f27edcc64c19.patch";
+        sha256 = "9hjqLyABz372QDgoq7nXXXQ/3OXBGcYN1/92ekcC3WE=";
+      })
+      ./qtwebkit.patch
+      ./qtwebkit-icu68.patch
+    ] ++ lib.optionals stdenv.isDarwin [
+      ./qtwebkit-darwin-no-readline.patch
+      ./qtwebkit-darwin-no-qos-classes.patch
+    ];
+    qttools = [ ./qttools.patch ];
+  };
+
+  addPackages = self:
+    let
+      qtModule = callPackage ../qtModule.nix {
+        inherit patches;
+        # Use a variant of mkDerivation that does not include wrapQtApplications
+        # to avoid cyclic dependencies between Qt modules.
+        mkDerivation =
+          (callPackage ../mkDerivation.nix { wrapQtAppsHook = null; }) stdenv.mkDerivation;
+      };
+
+      callPackage = self.newScope { inherit qtCompatVersion qtModule srcs stdenv; };
+    in {
+
+      inherit callPackage qtCompatVersion qtModule srcs;
+
+      mkDerivationWith = callPackage ../mkDerivation.nix { };
+
+      mkDerivation = callPackage ({ mkDerivationWith }: mkDerivationWith stdenv.mkDerivation) { };
+
+      qtbase = callPackage ../modules/qtbase.nix {
+        inherit (srcs.qtbase) src version;
+        patches = patches.qtbase;
+        inherit bison cups harfbuzz libGL;
+        withGtk3 = !stdenv.isDarwin; inherit dconf gtk3;
+        inherit developerBuild decryptSslTraffic;
+        inherit (darwin.apple_sdk_11_0.frameworks) AGL AppKit ApplicationServices AVFoundation Carbon Cocoa CoreAudio CoreBluetooth
+          CoreLocation CoreServices DiskArbitration Foundation OpenGL MetalKit IOKit;
+        libobjc = darwin.apple_sdk_11_0.objc4;
+        xcbuild = darwin.apple_sdk_11_0.xcodebuild;
+      };
+
+      qt3d = callPackage ../modules/qt3d.nix {};
+      qtcharts = callPackage ../modules/qtcharts.nix {};
+      qtconnectivity = callPackage ../modules/qtconnectivity.nix {
+        inherit (darwin.apple_sdk_11_0.frameworks) IOBluetooth;
+      };
+      qtdatavis3d = callPackage ../modules/qtdatavis3d.nix {};
+      qtdeclarative = callPackage ../modules/qtdeclarative.nix {};
+      qtdoc = callPackage ../modules/qtdoc.nix {};
+      qtgamepad = callPackage ../modules/qtgamepad.nix {
+        inherit (darwin.apple_sdk_11_0.frameworks) GameController;
+      };
+      qtgraphicaleffects = callPackage ../modules/qtgraphicaleffects.nix {};
+      qtimageformats = callPackage ../modules/qtimageformats.nix {};
+      qtlocation = callPackage ../modules/qtlocation.nix {};
+      qtlottie = callPackage ../modules/qtlottie.nix {};
+      qtmacextras = callPackage ../modules/qtmacextras.nix {};
+      qtmultimedia = callPackage ../modules/qtmultimedia.nix {
+        inherit gstreamer gst-plugins-base;
+      };
+      qtnetworkauth = callPackage ../modules/qtnetworkauth.nix {};
+      qtpim = callPackage ../modules/qtpim.nix {};
+      qtpositioning = callPackage ../modules/qtpositioning.nix {};
+      qtquick1 = null;
+      qtquickcontrols = callPackage ../modules/qtquickcontrols.nix {};
+      qtquickcontrols2 = callPackage ../modules/qtquickcontrols2.nix {};
+      qtremoteobjects = callPackage ../modules/qtremoteobjects.nix {};
+      qtscript = callPackage ../modules/qtscript.nix {};
+      qtsensors = callPackage ../modules/qtsensors.nix {};
+      qtserialbus = callPackage ../modules/qtserialbus.nix {};
+      qtserialport = callPackage ../modules/qtserialport.nix {};
+      qtspeech = callPackage ../modules/qtspeech.nix {};
+      qtsvg = callPackage ../modules/qtsvg.nix {};
+      qtsystems = callPackage ../modules/qtsystems.nix {};
+      qtscxml = callPackage ../modules/qtscxml.nix {};
+      qttools = callPackage ../modules/qttools.nix {};
+      qttranslations = callPackage ../modules/qttranslations.nix {};
+      qtvirtualkeyboard = callPackage ../modules/qtvirtualkeyboard.nix {};
+      qtwayland = callPackage ../modules/qtwayland.nix {};
+      qtwebchannel = callPackage ../modules/qtwebchannel.nix {};
+      qtwebengine = callPackage ../modules/qtwebengine.nix {
+        # The version of Chromium used by Qt WebEngine 5.15.x does not build with clang 16 due
+        # to the following errors:
+        # * -Wenum-constexpr-conversion: This is a downgradable error in clang 16, but it is planned
+        #   to be made into a hard error in a future version of clang. Patches are not available for
+        #   the version of v8 used by Chromium in Qt WebEngine, and fixing the code is non-trivial.
+        # * -Wincompatible-function-pointer-types: This is also a downgradable error generated
+        #   starting with clang 16. Patches are available upstream that can be backported.
+        # Because the first error is non-trivial to fix and suppressing it risks future breakage,
+        # clang is pinned to clang 15. That also makes fixing the second set of errors unnecessary.
+        stdenv =
+          let stdenv' = if stdenv.cc.isClang then overrideLibcxx llvmPackages_15.stdenv else stdenv;
+          in if stdenv'.isDarwin then overrideSDK stdenv' "11.0" else stdenv';
+        inherit (srcs.qtwebengine) version;
+        python = python3;
+        postPatch = ''
+          # update catapult for python3 compatibility
+          rm -r src/3rdparty/chromium/third_party/catapult
+          cp -r ${srcs.catapult} src/3rdparty/chromium/third_party/catapult
+        '';
+        inherit (darwin) cctools xnu;
+        inherit (darwin.apple_sdk_11_0) libpm libunwind;
+        inherit (darwin.apple_sdk_11_0.libs) sandbox;
+        inherit (darwin.apple_sdk_11_0.frameworks) ApplicationServices AVFoundation Foundation ForceFeedback GameController AppKit
+          ImageCaptureCore CoreBluetooth IOBluetooth CoreWLAN Quartz Cocoa LocalAuthentication
+          MediaPlayer MediaAccessibility SecurityInterface Vision CoreML OpenDirectory Accelerate;
+        libobjc = darwin.apple_sdk_11_0.objc4;
+      };
+      qtwebglplugin = callPackage ../modules/qtwebglplugin.nix {};
+      qtwebkit = callPackage ../modules/qtwebkit.nix {
+        inherit (darwin) ICU;
+        inherit (darwin.apple_sdk_11_0.frameworks) OpenGL;
+      };
+      qtwebsockets = callPackage ../modules/qtwebsockets.nix {};
+      qtwebview = callPackage ../modules/qtwebview.nix {
+        inherit (darwin.apple_sdk_11_0.frameworks) CoreFoundation WebKit;
+      };
+      qtx11extras = callPackage ../modules/qtx11extras.nix {};
+      qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};
+
+      env = callPackage ../qt-env.nix {};
+      full = callPackage ({ env, qtbase }: env "qt-full-${qtbase.version}") { }
+      # `with self` is ok to use here because having these spliced is unnecessary
+      (with self; [
+        qt3d qtcharts qtconnectivity qtdeclarative qtdoc qtgraphicaleffects
+        qtimageformats qtlocation qtmultimedia qtquickcontrols qtquickcontrols2
+        qtscript qtsensors qtserialport qtsvg qttools qttranslations
+        qtvirtualkeyboard qtwebchannel qtwebengine qtwebsockets
+        qtwebview qtx11extras qtxmlpatterns qtlottie qtdatavis3d
+      ] ++ lib.optional (!stdenv.isDarwin) qtwayland
+        ++ lib.optional (stdenv.isDarwin) qtmacextras);
+
+      qmake = callPackage ({ qtbase }: makeSetupHook {
+        name = "qmake-hook";
+        ${if stdenv.buildPlatform == stdenv.hostPlatform
+          then "propagatedBuildInputs"
+          else "depsTargetTargetPropagated"} = [ qtbase.dev ];
+        substitutions = {
+          inherit debug;
+          fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh;
+        };
+      } ../hooks/qmake-hook.sh) { };
+
+      wrapQtAppsHook = callPackage ({ makeBinaryWrapper, qtbase, qtwayland }: makeSetupHook {
+        name = "wrap-qt5-apps-hook";
+        propagatedBuildInputs = [ qtbase.dev makeBinaryWrapper ]
+          ++ lib.optional stdenv.isLinux qtwayland.dev;
+      } ../hooks/wrap-qt-apps-hook.sh) { };
+    };
+
+  baseScope = makeScopeWithSplicing' {
+    otherSplices = generateSplicesForMkScope "qt5";
+    f = addPackages;
+  };
+
+  bootstrapScope = baseScope.overrideScope(final: prev: {
+    qtbase = prev.qtbase.override { qttranslations = null; };
+    qtdeclarative = null;
+  });
+
+  finalScope = baseScope.overrideScope(final: prev: {
+    # qttranslations causes eval-time infinite recursion when
+    # cross-compiling; disabled for now.
+    qttranslations =
+      if stdenv.buildPlatform == stdenv.hostPlatform
+      then bootstrapScope.qttranslations
+      else null;
+    qutebrowser = final.callPackage ../../../../applications/networking/browsers/qutebrowser { };
+  });
+in finalScope
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/fetch.sh b/nixpkgs/pkgs/development/libraries/qt-5/5.15/fetch.sh
new file mode 100755
index 000000000000..7225b432c574
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/fetch.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p nix-prefetch-scripts jq
+
+set -eox pipefail
+
+here="$(dirname "${BASH_SOURCE[0]}")"
+modules="${here}/modules"
+srcs="${here}/srcs-generated.json"
+
+while read -r module; do
+    if [[ -z "$module" ]]; then continue; fi
+    url="https://invent.kde.org/qt/qt/${module}.git"
+    nix-prefetch-git --url $url --rev refs/heads/kde/5.15 --fetch-submodules \
+        | jq "{key: \"${module}\", value: {url,rev,sha256}}"
+done < "$modules" | jq -s 'from_entries' > "${srcs}.tmp"
+
+mv "${srcs}.tmp" "$srcs"
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/modules b/nixpkgs/pkgs/development/libraries/qt-5/5.15/modules
new file mode 100644
index 000000000000..ccc7dbcb8151
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/modules
@@ -0,0 +1,40 @@
+qt3d
+qtactiveqt
+qtandroidextras
+qtbase
+qtcharts
+qtconnectivity
+qtdatavis3d
+qtdeclarative
+qtdoc
+qtgamepad
+qtgraphicaleffects
+qtimageformats
+qtlocation
+qtlottie
+qtmacextras
+qtmultimedia
+qtnetworkauth
+qtpurchasing
+qtquick3d
+qtquickcontrols
+qtquickcontrols2
+qtquicktimeline
+qtremoteobjects
+qtscxml
+qtsensors
+qtserialbus
+qtserialport
+qtspeech
+qtsvg
+qttools
+qttranslations
+qtvirtualkeyboard
+qtwayland
+qtwebchannel
+qtwebglplugin
+qtwebsockets
+qtwebview
+qtwinextras
+qtx11extras
+qtxmlpatterns
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0001-qtbase-mkspecs-mac.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
new file mode 100644
index 000000000000..9d2a47c7c348
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
@@ -0,0 +1,485 @@
+From 5ec1d1009d9943f20e82ffc087deabb31d447e75 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Milan=20P=C3=A4ssler?= <me@pbb.lc>
+Date: Fri, 3 Apr 2020 21:07:58 +0200
+Subject: [PATCH 01/11] qtbase-mkspecs-mac
+
+---
+ mkspecs/common/mac.conf               |   2 +-
+ mkspecs/features/mac/default_post.prf | 206 --------------------------
+ mkspecs/features/mac/default_pre.prf  |  58 --------
+ mkspecs/features/mac/sdk.mk           |  25 ----
+ mkspecs/features/mac/sdk.prf          |  61 --------
+ 5 files changed, 1 insertion(+), 351 deletions(-)
+ delete mode 100644 mkspecs/features/mac/sdk.mk
+ delete mode 100644 mkspecs/features/mac/sdk.prf
+
+diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
+index 61bea952b2..9909dae726 100644
+--- a/mkspecs/common/mac.conf
++++ b/mkspecs/common/mac.conf
+@@ -23,7 +23,7 @@ QMAKE_INCDIR_OPENGL     = \
+ 
+ QMAKE_FIX_RPATH         = install_name_tool -id
+ 
+-QMAKE_LFLAGS_RPATH      = -Wl,-rpath,
++QMAKE_LFLAGS_RPATH      =
+ QMAKE_LFLAGS_GCSECTIONS = -Wl,-dead_strip
+ 
+ QMAKE_LFLAGS_REL_RPATH  =
+diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
+index abc6d82ade..59b94fe5b6 100644
+--- a/mkspecs/features/mac/default_post.prf
++++ b/mkspecs/features/mac/default_post.prf
+@@ -1,9 +1,5 @@
+ load(default_post)
+ 
+-# Recompute SDK version in case the user set it explicitly
+-sdk_version = $$QMAKE_MAC_SDK_VERSION
+-QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
+-
+ contains(TEMPLATE, .*app) {
+     !macx-xcode:if(isEmpty(BUILDS)|build_pass) {
+         # Detect changes to the platform SDK
+@@ -16,36 +12,6 @@ contains(TEMPLATE, .*app) {
+         QMAKE_EXTRA_INCLUDES += $$shell_quote($$PWD/sdk.mk)
+     }
+ 
+-    # Detect incompatible SDK versions
+-
+-    isEmpty(QT_MAC_SDK_VERSION_MIN): \
+-        QT_MAC_SDK_VERSION_MIN = $$QT_MAC_SDK_VERSION
+-
+-    !versionAtLeast(QMAKE_MAC_SDK_VERSION, $$QT_MAC_SDK_VERSION_MIN): \
+-        warning("Qt requires at least version $$QT_MAC_SDK_VERSION_MIN of the platform SDK," \
+-              "you're building against version $${QMAKE_MAC_SDK_VERSION}. Please upgrade.")
+-
+-    !isEmpty(QT_MAC_SDK_VERSION_MAX) {
+-        # For Qt developers only
+-        !isEmpty($$list($$(QT_MAC_SDK_NO_VERSION_CHECK))): \
+-            CONFIG += sdk_no_version_check
+-
+-        QMAKE_MAC_SDK_MAJOR_VERSION = $$replace(QMAKE_MAC_SDK_VERSION, "(\\d+)(\\.\\d+)(\\.\\d+)?", \\1)
+-
+-        !sdk_no_version_check:!versionAtMost(QMAKE_MAC_SDK_MAJOR_VERSION, $$QT_MAC_SDK_VERSION_MAX) {
+-            warning("Qt has only been tested with version $$QT_MAC_SDK_VERSION_MAX"\
+-                    "of the platform SDK, you're using $${QMAKE_MAC_SDK_MAJOR_VERSION}.")
+-            warning("This is an unsupported configuration. You may experience build issues," \
+-                    "and by using")
+-            warning("the $$QMAKE_MAC_SDK_VERSION SDK you are opting in to new features" \
+-                    "that Qt has not been prepared for.")
+-
+-            warning("Please downgrade the SDK you use to build your app to version" \
+-                    "$$QT_MAC_SDK_VERSION_MAX, or configure")
+-            warning("with CONFIG+=sdk_no_version_check when running qmake" \
+-                    "to silence this warning.")
+-        }
+-    }
+ }
+ 
+ !no_objective_c:CONFIG += objective_c
+@@ -73,230 +39,6 @@ qt {
+     }
+ }
+ 
+-# Add the same default rpaths as Xcode does for new projects.
+-# This is especially important for iOS/tvOS/watchOS where no other option is possible.
+-!no_default_rpath {
+-    uikit: QMAKE_RPATHDIR += @executable_path/Frameworks
+-    else: QMAKE_RPATHDIR += @executable_path/../Frameworks
+-    equals(TEMPLATE, lib):!plugin:lib_bundle: QMAKE_RPATHDIR += @loader_path/Frameworks
+-}
+-
+-# Don't pass -headerpad_max_install_names when using Bitcode.
+-# In that case the linker emits a warning stating that the flag is ignored when
+-# used with bitcode, for reasons that cannot be determined (rdar://problem/20748962).
+-# Using this flag is also unnecessary in practice on UIKit platforms since they
+-# are sandboxed, and only UIKit platforms support bitcode to begin with.
+-!bitcode: QMAKE_LFLAGS += $$QMAKE_LFLAGS_HEADERPAD
+-
+-app_extension_api_only {
+-    QMAKE_CFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_CXXFLAGS            += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_CXXFLAGS_PRECOMPILE += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-    QMAKE_LFLAGS              += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
+-}
+-
+-macos {
+-    !isEmpty(QMAKE_APPLE_DEVICE_ARCHS) {
+-        # If the user has requested a specific set of architectures,
+-        # build all of those by default, but limited to only those.
+-        CONFIG -= only_active_arch
+-    } else {
+-        # Otherwise allow building all of the architectures available
+-        # in Qt, but only build the active arch (unless the user has
+-        # manually overridden this via CONFIG -= only_active_arch).
+-        QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCHS
+-    }
+-}
+-
+-macx-xcode {
+-    qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO
+-    !isEmpty(QMAKE_PKGINFO_TYPEINFO): \
+-        qmake_pkginfo_typeinfo.value = $$QMAKE_PKGINFO_TYPEINFO
+-    else: \
+-        qmake_pkginfo_typeinfo.value = "????"
+-    QMAKE_MAC_XCODE_SETTINGS += qmake_pkginfo_typeinfo
+-
+-    bundle_version = $$VERSION
+-    isEmpty(bundle_version): bundle_version = 1.0.0
+-
+-    l = $$split(bundle_version, '.') 0 0  # make sure there are at least three
+-    VER_MAJ = $$member(l, 0, 0)
+-    VER_MIN = $$member(l, 1, 1)
+-    VER_PAT = $$member(l, 2, 2)
+-    unset(l)
+-
+-    qmake_full_version.name = QMAKE_FULL_VERSION
+-    qmake_full_version.value = $${VER_MAJ}.$${VER_MIN}.$${VER_PAT}
+-    QMAKE_MAC_XCODE_SETTINGS += qmake_full_version
+-
+-    qmake_short_version.name = QMAKE_SHORT_VERSION
+-    qmake_short_version.value = $${VER_MAJ}.$${VER_MIN}
+-    QMAKE_MAC_XCODE_SETTINGS += qmake_short_version
+-
+-    !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
+-        debug_information_format.name = DEBUG_INFORMATION_FORMAT
+-        debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
+-        debug_information_format.build = debug
+-        QMAKE_MAC_XCODE_SETTINGS += debug_information_format
+-    }
+-
+-    QMAKE_XCODE_ARCHS =
+-
+-    arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
+-    arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
+-    QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
+-    QMAKE_MAC_XCODE_SETTINGS += arch_device
+-
+-    simulator {
+-        arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
+-        arch_simulator.value = $$QMAKE_APPLE_SIMULATOR_ARCHS
+-        QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_SIMULATOR_ARCHS
+-        QMAKE_MAC_XCODE_SETTINGS += arch_simulator
+-    }
+-
+-    only_active_arch.name = ONLY_ACTIVE_ARCH
+-    only_active_arch.value = YES
+-    only_active_arch.build = debug
+-    QMAKE_MAC_XCODE_SETTINGS += only_active_arch
+-} else {
+-    device|!simulator: VALID_DEVICE_ARCHS = $$QMAKE_APPLE_DEVICE_ARCHS
+-    simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS
+-    VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS
+-
+-    single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
+-
+-    macos {
+-        only_active_arch: DEFAULT_ARCHS = $$system("uname -m")
+-        else: DEFAULT_ARCHS = $$VALID_ARCHS
+-    }
+-
+-    ARCHS = $(filter $(EXPORT_VALID_ARCHS), \
+-        $(if $(ARCHS), $(ARCHS), \
+-            $(if $(EXPORT_DEFAULT_ARCHS), $(EXPORT_DEFAULT_ARCHS), \
+-        $(EXPORT_VALID_ARCHS))))
+-    ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ARCHS), $(EXPORT_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch))
+-
+-    QMAKE_EXTRA_VARIABLES += VALID_ARCHS DEFAULT_ARCHS ARCHS ARCH_ARGS
+-
+-    arch_flags = $(EXPORT_ARCH_ARGS)
+-
+-    QMAKE_CFLAGS += $$arch_flags
+-    QMAKE_CXXFLAGS += $$arch_flags
+-    QMAKE_LFLAGS += $$arch_flags
+-
+-    QMAKE_PCH_ARCHS = $$VALID_ARCHS
+-
+-    macos: deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET
+-    ios: deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
+-    tvos: deployment_target = $$QMAKE_TVOS_DEPLOYMENT_TARGET
+-    watchos: deployment_target = $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
+-
+-    # If we're doing a simulator and device build, device and simulator
+-    # architectures use different paths and flags for the sysroot and
+-    # deployment target switch, so we must multiplex them across multiple
+-    # architectures using -Xarch. Otherwise we fall back to the simple path.
+-    # This is not strictly necessary, but results in cleaner command lines
+-    # and makes it easier for people to override EXPORT_VALID_ARCHS to limit
+-    # individual rules to a different set of architecture(s) from the overall
+-    # build (such as machtest in QtCore).
+-    simulator:device {
+-        QMAKE_XARCH_CFLAGS =
+-        QMAKE_XARCH_LFLAGS =
+-        QMAKE_EXTRA_VARIABLES += QMAKE_XARCH_CFLAGS QMAKE_XARCH_LFLAGS
+-
+-        for (arch, VALID_ARCHS) {
+-            contains(VALID_SIMULATOR_ARCHS, $$arch) {
+-                sdk = $$simulator.sdk
+-                version_identifier = $$simulator.deployment_identifier
+-            } else {
+-                sdk = $$device.sdk
+-                version_identifier = $$device.deployment_identifier
+-            }
+-
+-            version_min_flags = \
+-                -Xarch_$${arch} \
+-                -m$${version_identifier}-version-min=$$deployment_target
+-            QMAKE_XARCH_CFLAGS_$${arch} = $$version_min_flags \
+-                -Xarch_$${arch} \
+-                -isysroot$$xcodeSDKInfo(Path, $$sdk)
+-            QMAKE_XARCH_LFLAGS_$${arch} = $$version_min_flags \
+-                -Xarch_$${arch} \
+-                -isysroot$$xcodeSDKInfo(Path, $$sdk)
+-
+-            QMAKE_XARCH_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS_$${arch})
+-            QMAKE_XARCH_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS_$${arch})
+-
+-            QMAKE_EXTRA_VARIABLES += \
+-                QMAKE_XARCH_CFLAGS_$${arch} \
+-                QMAKE_XARCH_LFLAGS_$${arch}
+-        }
+-
+-        QMAKE_CFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+-        QMAKE_CXXFLAGS += $(EXPORT_QMAKE_XARCH_CFLAGS)
+-        QMAKE_LFLAGS += $(EXPORT_QMAKE_XARCH_LFLAGS)
+-    } else {
+-        simulator {
+-            version_identifier = $$simulator.deployment_identifier
+-            sysroot_path  = $$xcodeSDKInfo(Path, $$simulator.sdk)
+-        } else {
+-            version_identifier = $$device.deployment_identifier
+-            sysroot_path  = $$xcodeSDKInfo(Path, $$device.sdk)
+-        }
+-        version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
+-        QMAKE_CFLAGS += -isysroot $$sysroot_path $$version_min_flag
+-        QMAKE_CXXFLAGS += -isysroot $$sysroot_path $$version_min_flag
+-        QMAKE_LFLAGS += -isysroot $$sysroot_path $$version_min_flag
+-    }
+-
+-    # Enable precompiled headers for multiple architectures
+-    QMAKE_CFLAGS_USE_PRECOMPILE =
+-    for (arch, VALID_ARCHS) {
+-        icc_pch_style: \
+-            use_flag = "-pch-use "
+-        else: \
+-            use_flag = -include
+-
+-        # Only use Xarch with multi-arch, as the option confuses ccache
+-        count(VALID_ARCHS, 1, greaterThan): \
+-            QMAKE_CFLAGS_USE_PRECOMPILE += \
+-                -Xarch_$${arch}
+-
+-        QMAKE_CFLAGS_USE_PRECOMPILE += \
+-            $${use_flag}${QMAKE_PCH_OUTPUT_$${arch}}
+-    }
+-    icc_pch_style {
+-        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE -include ${QMAKE_PCH_INPUT}
+-        QMAKE_CFLAGS_USE_PRECOMPILE =
+-    } else {
+-        QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-        QMAKE_OBJCFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-        QMAKE_OBJCXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+-    }
+-
+-    QMAKE_PCH_OUTPUT_EXT = _${QMAKE_PCH_ARCH}$${QMAKE_PCH_OUTPUT_EXT}
+-}
+-
+-!equals(sdk_version, $$QMAKE_MAC_SDK_VERSION) {
+-    # Explicit SDK version has been set, respect that
+-    QMAKE_LFLAGS += -Wl,-sdk_version -Wl,$$sdk_version
+-}
+-
+-cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
+-!isEmpty(QMAKE_XCODE_VERSION): \
+-    cache(QMAKE_XCODE_VERSION, stash)
+-
+-QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
+-
+-xcode_product_bundle_identifier_setting.name = PRODUCT_BUNDLE_IDENTIFIER
+-xcode_product_bundle_identifier_setting.value = $$QMAKE_TARGET_BUNDLE_PREFIX
+-isEmpty(xcode_product_bundle_identifier_setting.value): \
+-    xcode_product_bundle_identifier_setting.value = "com.yourcompany"
+-xcode_product_bundle_target = $$QMAKE_BUNDLE
+-isEmpty(xcode_product_bundle_target): \
+-    xcode_product_bundle_target = ${PRODUCT_NAME:rfc1034identifier}
+-xcode_product_bundle_identifier_setting.value = "$${xcode_product_bundle_identifier_setting.value}.$${xcode_product_bundle_target}"
+-QMAKE_MAC_XCODE_SETTINGS += xcode_product_bundle_identifier_setting
+-
+ !macx-xcode {
+     generate_xcode_project.commands = @$(QMAKE) -spec macx-xcode \"$(EXPORT__PRO_FILE_)\" $$QMAKE_ARGS
+     generate_xcode_project.target = xcodeproj
+diff --git a/mkspecs/features/mac/default_pre.prf b/mkspecs/features/mac/default_pre.prf
+index 2c91ba6679..a6ab233825 100644
+--- a/mkspecs/features/mac/default_pre.prf
++++ b/mkspecs/features/mac/default_pre.prf
+@@ -21,61 +21,3 @@ macos {
+ }
+ 
+ load(default_pre)
+-
+-isEmpty(QMAKE_XCODE_DEVELOPER_PATH) {
+-    # Get path of Xcode's Developer directory
+-    QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null")
+-    isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \
+-        error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.")
+-
+-    # Make sure Xcode path is valid
+-    !exists($$QMAKE_XCODE_DEVELOPER_PATH): \
+-        error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
+-}
+-
+-isEmpty(QMAKE_XCODEBUILD_PATH): \
+-    QMAKE_XCODEBUILD_PATH = $$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")
+-
+-!isEmpty(QMAKE_XCODEBUILD_PATH) {
+-    # Make sure Xcode is set up properly
+-    !system("/usr/bin/xcrun xcodebuild -license check 2>/dev/null"): \
+-        error("Xcode not set up properly. You need to confirm the license agreement by running 'sudo xcrun xcodebuild -license accept'.")
+-
+-    isEmpty(QMAKE_XCODE_VERSION) {
+-        # Extract Xcode version using xcodebuild
+-        xcode_version = $$system("/usr/bin/xcrun xcodebuild -version")
+-        QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
+-        isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
+-        unset(xcode_version)
+-    }
+-}
+-
+-isEmpty(QMAKE_TARGET_BUNDLE_PREFIX) {
+-    QMAKE_XCODE_PREFERENCES_FILE = $$(HOME)/Library/Preferences/com.apple.dt.Xcode.plist
+-    exists($$QMAKE_XCODE_PREFERENCES_FILE): \
+-        QMAKE_TARGET_BUNDLE_PREFIX = $$system("/usr/libexec/PlistBuddy -c 'print IDETemplateOptions:bundleIdentifierPrefix' $$QMAKE_XCODE_PREFERENCES_FILE 2>/dev/null")
+-
+-    !isEmpty(_QMAKE_CACHE_):!isEmpty(QMAKE_TARGET_BUNDLE_PREFIX): \
+-        cache(QMAKE_TARGET_BUNDLE_PREFIX)
+-}
+-
+-QMAKE_ASSET_CATALOGS_APP_ICON = AppIcon
+-
+-# Make the default debug info format for static debug builds
+-# DWARF instead of DWARF with dSYM. This cuts down build times
+-# for application debug builds significantly, as Xcode doesn't
+-# have to pull out all the DWARF info from the Qt static libs
+-# and put it into a dSYM file. We don't need that dSYM file in
+-# the first place, since the information is available in the
+-# object files inside the archives (static libraries).
+-macx-xcode:qtConfig(static): \
+-    QMAKE_XCODE_DEBUG_INFORMATION_FORMAT = dwarf
+-
+-# This variable is used by the xcode_dynamic_library_suffix
+-# feature, which allows Xcode to choose the Qt libraries to link to
+-# at build time, depending on the current Xcode SDK and configuration.
+-QMAKE_XCODE_LIBRARY_SUFFIX_SETTING = QT_LIBRARY_SUFFIX
+-
+-xcode_copy_phase_strip_setting.name = COPY_PHASE_STRIP
+-xcode_copy_phase_strip_setting.value = NO
+-QMAKE_MAC_XCODE_SETTINGS += xcode_copy_phase_strip_setting
+diff --git a/mkspecs/features/mac/sdk.mk b/mkspecs/features/mac/sdk.mk
+--- a/mkspecs/features/mac/sdk.mk
++++ b/mkspecs/features/mac/sdk.mk
+@@ -1,27 +0,0 @@
+-
+-ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+-    CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+-    ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+-        # We don't want to complain about out of date SDK unless the target needs to be remade.
+-        # This covers use-cases such as running 'make check' after moving the build to a
+-        # computer without Xcode or with a different Xcode version.
+-        TARGET_UP_TO_DATE := $(shell QT_MAC_SDK_NO_VERSION_CHECK=1 $(MAKE) --question $(QMAKE_TARGET) && echo 1 || echo 0)
+-        ifeq ($(TARGET_UP_TO_DATE),0)
+-            ifneq ($(findstring missing DEVELOPER_DIR path,$(CURRENT_MAC_SDK_VERSION)),)
+-                $(info The developer dir $(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) is no longer valid.)
+-            else ifneq ($(findstring SDK "$(EXPORT_QMAKE_MAC_SDK)" cannot be located,$(CURRENT_MAC_SDK_VERSION)),)
+-                $(info The developer dir $(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) no longer contains the $(EXPORT_QMAKE_MAC_SDK_VERSION) platform SDK.)
+-            else ifneq ($(CURRENT_MAC_SDK_VERSION),)
+-                $(info The $(EXPORT_QMAKE_MAC_SDK) platform SDK has been changed from version $(EXPORT_QMAKE_MAC_SDK_VERSION) to version $(CURRENT_MAC_SDK_VERSION).)
+-            else
+-                $(info Unknown error resolving current platform SDK version.)
+-            endif
+-            $(info This requires a fresh build of your project. Please wipe the build directory)
+-            ifneq ($(EXPORT__QMAKE_STASH_),)
+-                $(info including the qmake cache in $(EXPORT__QMAKE_STASH_))
+-            endif
+-            $(error ^)
+-        endif
+-    endif
+-endif
+diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf
+deleted file mode 100644
+index 3a9c2778bb..0000000000
+--- a/mkspecs/features/mac/sdk.prf
++++ /dev/null
+@@ -1,61 +0,0 @@
+-
+-isEmpty(QMAKE_MAC_SDK): \
+-    error("QMAKE_MAC_SDK must be set when using CONFIG += sdk.")
+-
+-contains(QMAKE_MAC_SDK, .*/.*): \
+-    error("QMAKE_MAC_SDK can only contain short-form SDK names (eg. macosx, iphoneos)")
+-
+-defineReplace(xcodeSDKInfo) {
+-    info = $$1
+-    equals(info, "Path"): \
+-        infoarg = --show-sdk-path
+-    equals(info, "PlatformPath"): \
+-        infoarg = --show-sdk-platform-path
+-    equals(info, "SDKVersion"): \
+-        infoarg = --show-sdk-version
+-    sdk = $$2
+-    isEmpty(sdk): \
+-        sdk = $$QMAKE_MAC_SDK
+-
+-    isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}) {
+-        QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcrun --sdk $$sdk $$infoarg 2>/dev/null")
+-        # --show-sdk-platform-path won't work for Command Line Tools; this is fine
+-        # only used by the XCTest backend to testlib
+-        isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}):if(!isEmpty(QMAKE_XCODEBUILD_PATH)|!equals(infoarg, "--show-sdk-platform-path")): \
+-            error("Could not resolve SDK $$info for \'$$sdk\' using $$infoarg")
+-        cache(QMAKE_MAC_SDK.$${sdk}.$${info}, set stash, QMAKE_MAC_SDK.$${sdk}.$${info})
+-    }
+-
+-    return($$eval(QMAKE_MAC_SDK.$${sdk}.$${info}))
+-}
+-
+-QMAKE_MAC_SDK_PATH = $$xcodeSDKInfo(Path)
+-QMAKE_MAC_SDK_PLATFORM_PATH = $$xcodeSDKInfo(PlatformPath)
+-QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
+-
+-isEmpty(QMAKE_EXPORT_INCDIR_OPENGL) {
+-    QMAKE_EXPORT_INCDIR_OPENGL = $$QMAKE_INCDIR_OPENGL
+-    sysrootified =
+-    for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
+-    QMAKE_INCDIR_OPENGL = $$sysrootified
+-}
+-
+-QMAKESPEC_NAME = $$basename(QMAKESPEC)
+-
+-# Resolve SDK version of various tools
+-for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_ACTOOL QMAKE_LINK_C QMAKE_LINK_C_SHLIB)) {
+-    tool_variable = QMAKE_MAC_SDK.$${QMAKESPEC_NAME}.$${QMAKE_MAC_SDK}.$${tool}
+-    !isEmpty($$tool_variable) {
+-        $$tool = $$eval($$tool_variable)
+-        next()
+-    }
+-
+-    value = $$eval($$tool)
+-    isEmpty(value): next()
+-
+-    sysrooted = $$system("/usr/bin/xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value) 2>/dev/null")
+-    isEmpty(sysrooted): next()
+-
+-    $$tool = $$sysrooted $$member(value, 1, -1)
+-    cache($$tool_variable, set stash, $$tool)
+-}
+diff --git a/mkspecs/features/mac/toolchain.prf b/mkspecs/features/mac/toolchain.prf
+deleted file mode 100644
+index df191eb13c..0000000000
+--- a/mkspecs/features/mac/toolchain.prf
++++ /dev/null
+@@ -1,5 +0,0 @@
+-# Ensure that we process sdk.prf first, as it will update QMAKE_CXX,
+-# which the default path determination uses.
+-sdk: load(sdk)
+-
+-load(toolchain)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0003-qtbase-mkspecs.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0003-qtbase-mkspecs.patch
new file mode 100644
index 000000000000..1c9012c0f2e8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0003-qtbase-mkspecs.patch
@@ -0,0 +1,490 @@
+From 03a5a7eab673d18d00c9b5eb8c7d5b790079e8ff Mon Sep 17 00:00:00 2001
+From: OPNA2608 <christoph.neidahl@gmail.com>
+Date: Mon, 12 Apr 2021 20:20:46 +0200
+Subject: [PATCH 03/11] qtbase-mkspecs
+
+---
+ mkspecs/features/create_cmake.prf             | 51 +++---------
+ .../data/cmake/Qt5BasicConfig.cmake.in        | 80 +------------------
+ mkspecs/features/qml_module.prf               |  2 +-
+ mkspecs/features/qml_plugin.prf               |  2 +-
+ mkspecs/features/qt_app.prf                   |  2 +-
+ mkspecs/features/qt_build_paths.prf           |  4 +-
+ mkspecs/features/qt_docs.prf                  | 10 +--
+ mkspecs/features/qt_example_installs.prf      |  2 +-
+ mkspecs/features/qt_functions.prf             | 27 ++++---
+ mkspecs/features/qt_installs.prf              | 22 ++---
+ mkspecs/features/qt_plugin.prf                |  2 +-
+ 11 files changed, 52 insertions(+), 152 deletions(-)
+
+diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
+index 24ed125f12..f0666a1986 100644
+--- a/mkspecs/features/create_cmake.prf
++++ b/mkspecs/features/create_cmake.prf
+@@ -21,7 +21,7 @@ load(cmake_functions)
+ # at cmake time whether package has been found via a symlink, and correct
+ # that to an absolute path. This is only done for installations to
+ # the /usr or / prefix.
+-CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$[QT_INSTALL_LIBS])
++CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$NIX_OUTPUT_OUT/lib/)
+ contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND = $$CMAKE_INSTALL_LIBS_DIR
+ 
+ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
+@@ -77,45 +77,20 @@ split_incpath {
+         $$cmake_extra_source_includes.output
+ }
+ 
+-CMAKE_INCLUDE_DIR = $$cmakeRelativePath($$[QT_INSTALL_HEADERS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") {
+-    CMAKE_INCLUDE_DIR = $$[QT_INSTALL_HEADERS]/
+-    CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_INCLUDE_DIR = $$NIX_OUTPUT_DEV/include/
++CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
+-    CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/
+-    CMAKE_LIB_DIR_IS_ABSOLUTE = True
+-} else {
+-    CMAKE_RELATIVE_INSTALL_LIBS_DIR = $$cmakeRelativePath($$[QT_INSTALL_PREFIX], $$[QT_INSTALL_LIBS])
+-    # We need to go up another two levels because the CMake files are
+-    # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
+-    CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}../../"
+-}
++CMAKE_BIN_DIR = $$NIX_OUTPUT_BIN/bin/
++CMAKE_BIN_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_BIN_DIR, "^\\.\\./.*") {
+-    CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
+-    CMAKE_BIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_LIB_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_LIB_DIR_IS_ABSOLUTE = True
+ 
+-CMAKE_PLUGIN_DIR = $$cmakeRelativePath($$[QT_INSTALL_PLUGINS], $$[QT_INSTALL_PREFIX])
+-contains(CMAKE_PLUGIN_DIR, "^\\.\\./.*") {
+-    CMAKE_PLUGIN_DIR = $$[QT_INSTALL_PLUGINS]/
+-    CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+-}
++CMAKE_PLUGIN_DIR = $$NIX_OUTPUT_PLUGIN/
++CMAKE_PLUGIN_DIR_IS_ABSOLUTE = True
+ 
+-win32:!static:!staticlib {
+-    CMAKE_DLL_DIR = $$cmakeRelativePath($$[QT_INSTALL_BINS], $$[QT_INSTALL_PREFIX])
+-    contains(CMAKE_DLL_DIR, "^\\.\\./.*") {
+-        CMAKE_DLL_DIR = $$[QT_INSTALL_BINS]/
+-        CMAKE_DLL_DIR_IS_ABSOLUTE = True
+-    }
+-} else {
+-    CMAKE_DLL_DIR = $$CMAKE_LIB_DIR
+-    CMAKE_DLL_DIR_IS_ABSOLUTE = $$CMAKE_LIB_DIR_IS_ABSOLUTE
+-}
++CMAKE_DLL_DIR = $$NIX_OUTPUT_OUT/lib/
++CMAKE_DLL_DIR_IS_ABSOLUTE = True
+ 
+ static|staticlib:CMAKE_STATIC_TYPE = true
+ 
+@@ -258,7 +233,7 @@ contains(CONFIG, plugin) {
+ 
+     cmake_qt5_plugin_file.files = $$cmake_target_file.output
+     static|staticlib: cmake_qt5_plugin_file.files += $$cmake_qt5_plugin_import_file.output
+-    cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++    cmake_qt5_plugin_file.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+     INSTALLS += cmake_qt5_plugin_file
+ 
+     return()
+@@ -400,7 +375,7 @@ exists($$cmake_macros_file.input) {
+     cmake_qt5_module_files.files += $$cmake_macros_file.output
+ }
+ 
+-cmake_qt5_module_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
++cmake_qt5_module_files.path = $$NIX_OUTPUT_OUT/lib/cmake/Qt5$${CMAKE_MODULE_NAME}
+ 
+ # We are generating cmake files. Most developers of Qt are not aware of cmake,
+ # so we require automatic tests to be available. The only module which should
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index db18dbece6..8246f37931 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -2,30 +2,6 @@ if (CMAKE_VERSION VERSION_LESS 3.1.0)
+     message(FATAL_ERROR \"Qt 5 $${CMAKE_MODULE_NAME} module requires at least CMake version 3.1.0\")
+ 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}.VERSION)")
+@@ -145,11 +121,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATI
+       IsDebugAndRelease)
+     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}\")
+-!!ELSE
+     set(imported_location \"$${CMAKE_DLL_DIR}${LIB_LOCATION}\")
+-!!ENDIF
+     _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+     set(_deps
+         ${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}
+@@ -209,11 +181,7 @@ macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration LIB_LOCATI
+ !!ENDIF
+ 
+ !!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
+@@ -229,24 +197,13 @@ 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}$${CMAKE_QT_STEM}.framework\"
+-      \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_QT_STEM}.framework/Headers\"
++      \"$${CMAKE_LIB_DIR}$${CMAKE_QT_STEM}.framework\"
++      \"$${CMAKE_LIB_DIR}$${CMAKE_QT_STEM}.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}$${CMAKE_QT_STEM}.framework/Versions/$$section(VERSION, ., 0, 0)/Headers/$$VERSION/\"
+-        \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_QT_STEM}.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}\")
+-!!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}\"
++      \"$${CMAKE_LIB_DIR}$${CMAKE_QT_STEM}.framework/Versions/$$section(VERSION, .,0, 0)/Headers/$$VERSION/\"
++      \"$${CMAKE_LIB_DIR}$${CMAKE_QT_STEM}.framework/Versions/$$section(VERSION, .,0, 0)/Headers/$$VERSION/$${MODULE_INCNAME}\"
+     )
+ !!ELSE
+     set(Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS \"\")
+@@ -262,7 +219,6 @@ 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
+@@ -491,25 +447,13 @@ 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}\" \"\" $${CMAKE_DEBUG_AND_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_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}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(DEBUG \"$${CMAKE_LIB_FILE_LOCATION_DEBUG}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_DEBUG}\" $${CMAKE_DEBUG_AND_RELEASE})
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -528,25 +472,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+ !!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}\" \"\" $${CMAKE_DEBUG_AND_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}\"
+-!!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}\" )
+-!!ELSE
+         \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" )
+-!!ENDIF
+         _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_LIB_FILE_LOCATION_RELEASE}\" \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" $${CMAKE_DEBUG_AND_RELEASE})
+ !!ENDIF // CMAKE_STATIC_WINDOWS_BUILD
+     endif()
+@@ -573,11 +505,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+           IsDebugAndRelease)
+         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
+         _qt5_$${CMAKE_MODULE_NAME}_check_file_exists(${imported_location})
+         set_target_properties(Qt5::${Plugin} PROPERTIES
+             \"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
+diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf
+index 3d6cd9b3db..ca8b0b2701 100644
+--- a/mkspecs/features/qml_module.prf
++++ b/mkspecs/features/qml_module.prf
+@@ -51,7 +51,7 @@ builtin_resources {
+ # Install rules
+ qmldir.base = $$qmldir_path
+ qmldir.files = $$qmldir_file
+-qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH
++qmldir.path = $$NIX_OUTPUT_QML/$$TARGETPATH
+ 
+ qmlfiles.base = $$_PRO_FILE_PWD_
+ qmlfiles.files = $$fq_aux_qml_files
+diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf
+index 1b67435787..24a1f78c17 100644
+--- a/mkspecs/features/qml_plugin.prf
++++ b/mkspecs/features/qml_plugin.prf
+@@ -50,7 +50,7 @@ load(qt_build_paths)
+ 
+ DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH
+ 
+-target.path = $$[QT_INSTALL_QML]/$$TARGETPATH
++target.path = $$NIX_OUTPUT_QML/$$TARGETPATH
+ INSTALLS += target
+ 
+ # Some final setup
+diff --git a/mkspecs/features/qt_app.prf b/mkspecs/features/qt_app.prf
+index 8354f30eea..62028fef8e 100644
+--- a/mkspecs/features/qt_app.prf
++++ b/mkspecs/features/qt_app.prf
+@@ -30,7 +30,7 @@ host_build:force_bootstrap {
+     target.path = $$[QT_HOST_BINS]
+ } else {
+     !build_pass:qtConfig(debug_and_release): CONFIG += release
+-    target.path = $$[QT_INSTALL_BINS]
++    target.path = $$NIX_OUTPUT_BIN/bin
+     CONFIG += relative_qt_rpath  # Qt's tools and apps should be relocatable
+ }
+ INSTALLS += target
+diff --git a/mkspecs/features/qt_build_paths.prf b/mkspecs/features/qt_build_paths.prf
+index 3bb3823a8e..655b7b7db8 100644
+--- a/mkspecs/features/qt_build_paths.prf
++++ b/mkspecs/features/qt_build_paths.prf
+@@ -24,6 +24,6 @@ exists($$MODULE_BASE_INDIR/.git): \
+ !force_independent {
+     # If the module is not built independently, everything ends up in qtbase.
+     # This is the case in non-prefix builds, except for selected modules.
+-    MODULE_BASE_OUTDIR = $$[QT_HOST_PREFIX]
+-    MODULE_QMAKE_OUTDIR = $$[QT_HOST_PREFIX]
++    MODULE_BASE_OUTDIR = $$NIX_OUTPUT_OUT
++    MODULE_QMAKE_OUTDIR = $$NIX_OUTPUT_OUT
+ }
+diff --git a/mkspecs/features/qt_docs.prf b/mkspecs/features/qt_docs.prf
+index 095bf15dac..4cc977bea5 100644
+--- a/mkspecs/features/qt_docs.prf
++++ b/mkspecs/features/qt_docs.prf
+@@ -65,7 +65,7 @@ QMAKE_DOCS_OUTPUTDIR = $$QMAKE_DOCS_BASE_OUTDIR/$$QMAKE_DOCS_TARGETDIR
+ 
+ QDOC += -outputdir $$shell_quote($$QMAKE_DOCS_OUTPUTDIR)
+ !build_online_docs: \
+-    QDOC += -installdir $$shell_quote($$[QT_INSTALL_DOCS])
++    QDOC += -installdir $$shell_quote($$NIX_OUTPUT_DOC)
+ PREP_DOC_INDEXES =
+ DOC_INDEXES =
+ !isEmpty(QTREPOS) {
+@@ -84,8 +84,8 @@ DOC_INDEXES =
+         DOC_INDEXES += -indexdir $$shell_quote($$qrep/doc)
+ } else {
+     prepare_docs: \
+-        PREP_DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
+-    DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS/get])
++        PREP_DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
++    DOC_INDEXES += -indexdir $$shell_quote($$NIX_OUTPUT_DOC)
+ }
+ 
+ qtattributionsscanner.target = qtattributionsscanner
+@@ -108,12 +108,12 @@ prepare_docs {
+     qch_docs.commands = $$QHELPGENERATOR $$shell_quote($$QMAKE_DOCS_OUTPUTDIR/$${QMAKE_DOCS_TARGET}.qhp) -o $$shell_quote($$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch)
+ 
+     inst_html_docs.files = $$QMAKE_DOCS_OUTPUTDIR
+-    inst_html_docs.path = $$[QT_INSTALL_DOCS]
++    inst_html_docs.path = $$NIX_OUTPUT_DOC
+     inst_html_docs.CONFIG += no_check_exist directory no_default_install no_build
+     INSTALLS += inst_html_docs
+ 
+     inst_qch_docs.files = $$QMAKE_DOCS_BASE_OUTDIR/$${QMAKE_DOCS_TARGET}.qch
+-    inst_qch_docs.path = $$[QT_INSTALL_DOCS]
++    inst_qch_docs.path = $$NIX_OUTPUT_DOC
+     inst_qch_docs.CONFIG += no_check_exist no_default_install no_build
+     INSTALLS += inst_qch_docs
+ 
+diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf
+index 15b373ba40..5c373fe1d5 100644
+--- a/mkspecs/features/qt_example_installs.prf
++++ b/mkspecs/features/qt_example_installs.prf
+@@ -91,7 +91,7 @@ sourcefiles += \
+     $$SOURCES $$HEADERS $$FORMS $$RESOURCES $$TRANSLATIONS \
+     $$DBUS_ADAPTORS $$DBUS_INTERFACES
+ addInstallFiles(sources.files, $$sourcefiles)
+-sources.path = $$[QT_INSTALL_EXAMPLES]/$$probase
++sources.path = $$NIX_OUTPUT_DEV/share/examples/$$probase
+ INSTALLS += sources
+ 
+ check_examples {
+diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
+index 7777e615bd..b0c6880a74 100644
+--- a/mkspecs/features/qt_functions.prf
++++ b/mkspecs/features/qt_functions.prf
+@@ -87,19 +87,22 @@ defineTest(qtHaveModule) {
+ defineTest(qtPrepareTool) {
+     cmd = $$eval(QT_TOOL.$${2}.binary)
+     isEmpty(cmd) {
+-        cmd = $$[QT_HOST_BINS]/$$2
+-        exists($${cmd}.pl) {
+-            $${1}_EXE = $${cmd}.pl
+-            cmd = perl -w $$system_path($${cmd}.pl)
+-        } else: contains(QMAKE_HOST.os, Windows) {
+-            $${1}_EXE = $${cmd}.exe
+-            cmd = $$system_path($${cmd}.exe)
+-        } else:contains(QMAKE_HOST.os, Darwin) {
+-            BUNDLENAME = $${cmd}.app/Contents/MacOS/$$2
+-            exists($$BUNDLENAME) {
+-                cmd = $$BUNDLENAME
++        cmd = $$system("command -v $${2}")
++        isEmpty(cmd) {
++            cmd = $$system("command -v $${2}.pl")
++            !isEmpty(cmd) {
++                $${1}_EXE = $$cmd
++                cmd = perl -w $$system_path($${cmd})
++            } else: contains(QMAKE_HOST.os, Windows) {
++                cmd = $$system("command -v $${2}.exe")
++                $${1}_EXE = $$cmd
++            } else: contains(QMAKE_HOST.os, Darwin) {
++                cmd = $$system("command -v $${2}.app")
++                !isEmpty(cmd) {
++                    cmd = $${cmd}/Contents/MacOS/$${2}
++                    $${1}_EXE = $$cmd
++                }
+             }
+-            $${1}_EXE = $$cmd
+         } else {
+             $${1}_EXE = $$cmd
+         }
+diff --git a/mkspecs/features/qt_installs.prf b/mkspecs/features/qt_installs.prf
+index 1ebca17366..a8f958eae8 100644
+--- a/mkspecs/features/qt_installs.prf
++++ b/mkspecs/features/qt_installs.prf
+@@ -12,16 +12,10 @@
+ #library
+ !qt_no_install_library {
+     win32 {
+-       host_build: \
+-           dlltarget.path = $$[QT_HOST_BINS]
+-       else: \
+-           dlltarget.path = $$[QT_INSTALL_BINS]
++       dlltarget.path = $$NIX_OUTPUT_BIN/bin
+        INSTALLS += dlltarget
+     }
+-    host_build: \
+-        target.path = $$[QT_HOST_LIBS]
+-    else: \
+-        target.path = $$[QT_INSTALL_LIBS]
++    target.path = $$NIX_OUTPUT_OUT/lib
+     !static: target.CONFIG = no_dll
+     INSTALLS += target
+ }
+@@ -29,35 +23,35 @@
+ #headers
+ qt_install_headers {
+     gen_headers.files = $$SYNCQT.GENERATED_HEADER_FILES
+-    gen_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    gen_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += gen_headers
+ 
+     targ_headers.files = $$SYNCQT.HEADER_FILES $$SYNCQT.INJECTED_HEADER_FILES
+-    targ_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME
++    targ_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME
+     INSTALLS += targ_headers
+ 
+     private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES $$SYNCQT.INJECTED_PRIVATE_HEADER_FILES
+-    private_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
++    private_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/private
+     generated_privates: \
+         private_headers.CONFIG += no_check_exist
+     INSTALLS += private_headers
+ 
+     qpa_headers.files = $$SYNCQT.QPA_HEADER_FILES
+-    qpa_headers.path = $$[QT_INSTALL_HEADERS]/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
++    qpa_headers.path = $$NIX_OUTPUT_DEV/include/$$MODULE_INCNAME/$$VERSION/$$MODULE_INCNAME/qpa
+     INSTALLS += qpa_headers
+ }
+ 
+ #module
+ qt_install_module {
+     !isEmpty(MODULE_PRI) {
+-        pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        pritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         pritarget.files = $$MODULE_PRI
+         INSTALLS += pritarget
+     } else: isEmpty(MODULE_PRIVATE_PRI) {
+         warning("Project $$basename(_PRO_FILE_) is a module, but has not defined MODULE_PRI, which is required for Qt to expose the module to other projects.")
+     }
+     !isEmpty(MODULE_PRIVATE_PRI) {
+-        privpritarget.path = $$[QT_HOST_DATA]/mkspecs/modules
++        privpritarget.path = $$NIX_OUTPUT_DEV/mkspecs/modules
+         privpritarget.files = $$MODULE_PRIVATE_PRI
+         INSTALLS += privpritarget
+     }
+diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf
+index 573d717eea..024c624cb6 100644
+--- a/mkspecs/features/qt_plugin.prf
++++ b/mkspecs/features/qt_plugin.prf
+@@ -88,7 +88,7 @@ CONFIG(static, static|shared)|prefix_build {
+     }
+ }
+ 
+-target.path = $$[QT_INSTALL_PLUGINS]/$$PLUGIN_TYPE
++target.path = $$NIX_OUTPUT_PLUGIN/$$PLUGIN_TYPE
+ INSTALLS += target
+ 
+ qt_libinfix_plugins: TARGET = $$TARGET$$QT_LIBINFIX
+-- 
+2.29.3
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0004-qtbase-replace-libdir.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0004-qtbase-replace-libdir.patch
new file mode 100644
index 000000000000..bbfc93897873
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0004-qtbase-replace-libdir.patch
@@ -0,0 +1,68 @@
+From 30d3906ff5e8671e9c97c5336c6c549656c0e293 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Milan=20P=C3=A4ssler?= <me@pbb.lc>
+Date: Sat, 4 Apr 2020 00:27:41 +0200
+Subject: [PATCH 04/11] qtbase-replace-libdir
+
+---
+ mkspecs/features/qt_common.prf | 20 ++------------------
+ mkspecs/features/qt_module.prf |  5 +----
+ 2 files changed, 3 insertions(+), 22 deletions(-)
+
+diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
+index 8df94aa4ee..414029f31c 100644
+--- a/mkspecs/features/qt_common.prf
++++ b/mkspecs/features/qt_common.prf
+@@ -31,32 +31,16 @@ contains(TEMPLATE, .*lib)|contains(TEMPLATE, aux) {
+         rplbase = $$dirname(_QMAKE_SUPER_CACHE_)/[^/][^/]*
+     else: \
+         rplbase = $$MODULE_BASE_OUTDIR
+-    host_build {
+-        qqt_libdir = \$\$\$\$[QT_HOST_LIBS]
+-        qt_libdir = $$[QT_HOST_LIBS]
+-    } else {
+-        qqt_libdir = \$\$\$\$[QT_INSTALL_LIBS]
+-        qt_libdir = $$[QT_INSTALL_LIBS]
+-    }
++    qt_libdir = $$NIX_OUTPUT_OUT/lib
+     contains(QMAKE_DEFAULT_LIBDIRS, $$qt_libdir) {
+-        lib_replace0.match = $$rplbase/lib/
+-        lib_replace0.replace = $$qqt_libdir/
+-        lib_replace0.CONFIG = path
+-        QMAKE_PRL_INSTALL_REPLACE += lib_replace0
+         lib_replace.match = "[^ ']*$$rplbase/lib"
+         lib_replace.replace =
+     } else {
+         lib_replace.match = $$rplbase/lib
+-        lib_replace.replace = $$qqt_libdir
++        lib_replace.replace = $$qt_libdir
+     }
+     lib_replace.CONFIG = path
+     QMAKE_PRL_INSTALL_REPLACE += lib_replace
+-    !equals(qt_libdir, $$rplbase/lib) {
+-        qtlibdir_replace.match = $$qt_libdir
+-        qtlibdir_replace.replace = $$qqt_libdir
+-        qtlibdir_replace.CONFIG = path
+-        QMAKE_PRL_INSTALL_REPLACE += qtlibdir_replace
+-    }
+ }
+ contains(TEMPLATE, .*lib)|darwin {
+     if(!host_build|!cross_compile):qtConfig(reduce_exports): CONFIG += hide_symbols
+diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
+index 828a9621b9..b9e5d35026 100644
+--- a/mkspecs/features/qt_module.prf
++++ b/mkspecs/features/qt_module.prf
+@@ -305,10 +305,7 @@ load(qt_targets)
+ }
+ !lib_bundle:unix {
+     CONFIG += create_libtool
+-    host_build: \
+-        QMAKE_LIBTOOL_LIBDIR = $$[QT_HOST_LIBS]
+-    else: \
+-        QMAKE_LIBTOOL_LIBDIR = "=$$[QT_INSTALL_LIBS/raw]"
++    QMAKE_LIBTOOL_LIBDIR = $$NIX_OUTPUT_OUT/lib
+     !isEmpty(lib_replace0.match) {
+         ltlib_replace0.match = $$lib_replace0.match
+         ltlib_replace0.replace = $$QMAKE_LIBTOOL_LIBDIR/
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0005-qtbase-cmake.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0005-qtbase-cmake.patch
new file mode 100644
index 000000000000..19646df1666f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0005-qtbase-cmake.patch
@@ -0,0 +1,194 @@
+From 7871fbcefc7596a458cec005edafd9d4962baea3 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@mailbox.org>
+Date: Tue, 17 Sep 2019 05:34:28 -0500
+Subject: [PATCH 05/11] qtbase-cmake
+
+---
+ mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in  |  2 +-
+ mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in |  4 ++--
+ src/corelib/Qt5CoreConfigExtras.cmake.in             | 10 +++++-----
+ src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in    |  2 +-
+ .../Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in  |  2 +-
+ src/dbus/Qt5DBusConfigExtras.cmake.in                | 12 ++----------
+ src/gui/Qt5GuiConfigExtras.cmake.in                  |  6 +++---
+ src/widgets/Qt5WidgetsConfigExtras.cmake.in          |  2 +-
+ 8 files changed, 16 insertions(+), 24 deletions(-)
+
+diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+index b6c3ab8609..edb6a89316 100644
+--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+@@ -513,7 +513,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
+           IsDebugAndRelease)
+         set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
+ 
+-        set(imported_location \"$${CMAKE_PLUGIN_DIR}${PLUGIN_LOCATION}\")
++        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}
+diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+index b550a52c60..dbd3243885 100644
+--- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
++++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+@@ -53,10 +53,10 @@ set_property(TARGET Qt5::$$CMAKE_PLUGIN_NAME PROPERTY INTERFACE_SOURCES
+ !!ENDIF
+ 
+ !!IF !isEmpty(CMAKE_RELEASE_TYPE)
+-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\" $${CMAKE_DEBUG_AND_RELEASE})
++_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_DIR}$${CMAKE_PLUGIN_LOCATION_RELEASE}\" $${CMAKE_DEBUG_AND_RELEASE})
+ !!ENDIF
+ !!IF !isEmpty(CMAKE_DEBUG_TYPE)
+-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\" $${CMAKE_DEBUG_AND_RELEASE})
++_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_DIR}$${CMAKE_PLUGIN_LOCATION_DEBUG}\" $${CMAKE_DEBUG_AND_RELEASE})
+ !!ENDIF
+ 
+ list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
+diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
+index 4c1c3a612b..bb8ab08143 100644
+--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
+@@ -6,7 +6,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_OUTPUT_DEV/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -21,7 +21,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_OUTPUT_DEV/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -38,7 +38,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_OUTPUT_DEV/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+@@ -121,7 +121,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_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
+ !!ENDIF
+@@ -135,7 +135,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_OUTPUT_DEV/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
+index c357237d0e..6f0c75de3c 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDir.cmake.in
++++ b/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_OUTPUT_DEV/$${CMAKE_HOST_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in b/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
+index 706304cf34..546420f6ad 100644
+--- a/src/corelib/Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
++++ b/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_OUTPUT_DEV/$${CMAKE_INSTALL_DATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+ !!ELSE
+ set(_qt5_corelib_extra_includes \"$${CMAKE_INSTALL_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+ !!ENDIF
+diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
+index a814678f7b..b13b964ec8 100644
+--- a/src/dbus/Qt5DBusConfigExtras.cmake.in
++++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
+@@ -2,11 +2,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\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbuscpp2xml PROPERTIES
+@@ -17,11 +13,7 @@ endif()
+ 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\")
+-!!ELSE
+-    set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+-!!ENDIF
++    set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
+     _qt5_DBus_check_file_exists(${imported_location})
+ 
+     set_target_properties(Qt5::qdbusxml2cpp PROPERTIES
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 84dbbfebd4..8ad0720c5c 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/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_OUTPUT_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_properties TargetName Configuration LIB_LOCATIO
+     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_OUTPUT_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_OUTPUT_OUT/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ELSE
+     set(imported_implib \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\")
+ !!ENDIF
+diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+index 83d8004a08..ca0b8e4bfb 100644
+--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
++++ b/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_OUTPUT_DEV/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ELSE
+     set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
+ !!ENDIF
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0006-qtbase-gtk3.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0006-qtbase-gtk3.patch
new file mode 100644
index 000000000000..48f4c9b3f99e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0006-qtbase-gtk3.patch
@@ -0,0 +1,48 @@
+From 7a9f4f875053aed8ab387161eea623bf8325cfa8 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@mailbox.org>
+Date: Tue, 17 Sep 2019 05:35:33 -0500
+Subject: [PATCH 06/11] qtbase-gtk3
+
+---
+ src/plugins/platformthemes/gtk3/main.cpp | 17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/src/plugins/platformthemes/gtk3/main.cpp b/src/plugins/platformthemes/gtk3/main.cpp
+index 860fc3a26e..8cd4663d49 100644
+--- a/src/plugins/platformthemes/gtk3/main.cpp
++++ b/src/plugins/platformthemes/gtk3/main.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include <qpa/qplatformthemeplugin.h>
+ #include "qgtk3theme.h"
++#include <QFile>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -54,8 +55,22 @@ public:
+ QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList &params)
+ {
+     Q_UNUSED(params);
+-    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive))
++    if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) {
++
++#ifdef NIXPKGS_QGTK3_XDG_DATA_DIRS
++        QStringList XDG_DATA_DIRS = QFile::decodeName(qgetenv("XDG_DATA_DIRS")).split(':');
++        XDG_DATA_DIRS << QLatin1String(NIXPKGS_QGTK3_XDG_DATA_DIRS);
++        qputenv("XDG_DATA_DIRS", QFile::encodeName(XDG_DATA_DIRS.join(':')));
++#endif
++
++#ifdef NIXPKGS_QGTK3_GIO_EXTRA_MODULES
++        QStringList GIO_EXTRA_MODULES = QFile::decodeName(qgetenv("GIO_EXTRA_MODULES")).split(':');
++        GIO_EXTRA_MODULES << QLatin1String(NIXPKGS_QGTK3_GIO_EXTRA_MODULES);
++        qputenv("GIO_EXTRA_MODULES", QFile::encodeName(GIO_EXTRA_MODULES.join(':')));
++#endif
++
+         return new QGtk3Theme;
++    }
+ 
+     return nullptr;
+ }
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0007-qtbase-xcursor.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0007-qtbase-xcursor.patch
new file mode 100644
index 000000000000..617b0684df65
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0007-qtbase-xcursor.patch
@@ -0,0 +1,29 @@
+From 707098eada20ba074e642a73248de74407bc261c Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@mailbox.org>
+Date: Tue, 17 Sep 2019 05:35:58 -0500
+Subject: [PATCH 07/11] qtbase-xcursor
+
+---
+ src/plugins/platforms/xcb/qxcbcursor.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
+index 42c7a52bd4..ba670ddb44 100644
+--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
++++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
+@@ -317,10 +317,10 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
+ #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
+     static bool function_ptrs_not_initialized = true;
+     if (function_ptrs_not_initialized) {
+-        QLibrary xcursorLib(QLatin1String("Xcursor"), 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(NIXPKGS_LIBXCURSOR));
+             xcursorFound = xcursorLib.load();
+         }
+         if (xcursorFound) {
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0008-qtbase-tzdir.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0008-qtbase-tzdir.patch
new file mode 100644
index 000000000000..319de315bfb7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0008-qtbase-tzdir.patch
@@ -0,0 +1,64 @@
+From da003b582ee8823b29b1ff5c0aca8e06e7741b94 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@mailbox.org>
+Date: Tue, 17 Sep 2019 05:36:25 -0500
+Subject: [PATCH 08/11] qtbase-tzdir
+
+---
+ src/corelib/time/qtimezoneprivate_tz.cpp | 31 +++++++++++++++---------
+ 1 file changed, 19 insertions(+), 12 deletions(-)
+
+diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
+index 01f9a6cce0..910338205a 100644
+--- a/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -77,7 +77,11 @@ typedef QHash<QByteArray, QTzTimeZone> QTzTimeZoneHash;
+ // 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");
++    // 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");
+ 
+@@ -672,20 +676,23 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::findEntry(const QByteArray &ianaId)
+         if (!tzif.open(QIODevice::ReadOnly))
+             return ret;
+     } 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, 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));
++            tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+             if (!tzif.open(QIODevice::ReadOnly)) {
+-                // ianaId may be a POSIX rule, taken from $TZ or /etc/TZ
+-                const QByteArray zoneInfo = ianaId.split(',').at(0);
+-                const char *begin = zoneInfo.constBegin();
+-                if (PosixZone::parse(begin, zoneInfo.constEnd()).hasValidOffset()
+-                    && (begin == zoneInfo.constEnd()
+-                        || PosixZone::parse(begin, zoneInfo.constEnd()).hasValidOffset())) {
+-                    ret.m_posixRule = ianaId;
++                tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
++                if (!tzif.open(QIODevice::ReadOnly)) {
++                    // ianaId may be a POSIX rule, taken from $TZ or /etc/TZ
++                    const QByteArray zoneInfo = ianaId.split(',').at(0);
++                    const char *begin = zoneInfo.constBegin();
++                    if (PosixZone::parse(begin, zoneInfo.constEnd()).hasValidOffset()
++                        && (begin == zoneInfo.constEnd()
++                            || PosixZone::parse(begin, zoneInfo.constEnd()).hasValidOffset())) {
++                        ret.m_posixRule = ianaId;
++                    }
++                    return ret;
+                 }
+-                return ret;
+             }
+         }
+     }
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0009-qtbase-qtpluginpath.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0009-qtbase-qtpluginpath.patch
new file mode 100644
index 000000000000..28013ec10482
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0009-qtbase-qtpluginpath.patch
@@ -0,0 +1,33 @@
+From 9fc6efaf774a8716932c98c0b0ea6408ed2614c2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Milan=20P=C3=A4ssler?= <me@pbb.lc>
+Date: Sun, 10 May 2020 12:47:28 +0200
+Subject: [PATCH 09/11] qtbase-qtpluginpath
+
+---
+ src/corelib/kernel/qcoreapplication.cpp | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
+index 5fdcc9b914..1a126ef359 100644
+--- a/src/corelib/kernel/qcoreapplication.cpp
++++ b/src/corelib/kernel/qcoreapplication.cpp
+@@ -2691,6 +2691,16 @@ QStringList QCoreApplication::libraryPathsLocked()
+         QStringList *app_libpaths = new QStringList;
+         coreappdata()->app_libpaths.reset(app_libpaths);
+ 
++        // Add library paths derived from PATH
++        const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++        const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
++        for (const QString &path: paths) {
++            if (!path.isEmpty()) {
++                app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
++            }
++        }
++
++
+         auto setPathsFromEnv = [&](QString libPathEnv) {
+             if (!libPathEnv.isEmpty()) {
+                 QStringList paths = libPathEnv.split(QDir::listSeparator(), Qt::SkipEmptyParts);
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0010-qtbase-assert.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0010-qtbase-assert.patch
new file mode 100644
index 000000000000..c5b099c4ca35
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0010-qtbase-assert.patch
@@ -0,0 +1,32 @@
+From 015845b3c320d02691f28373097d1e6dbbac79f7 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@mailbox.org>
+Date: Tue, 17 Sep 2019 05:37:04 -0500
+Subject: [PATCH 10/11] qtbase-assert
+
+---
+ src/testlib/qtestassert.h | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/testlib/qtestassert.h b/src/testlib/qtestassert.h
+index 6498ea84ef..d821ced7fc 100644
+--- a/src/testlib/qtestassert.h
++++ b/src/testlib/qtestassert.h
+@@ -44,10 +44,13 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-
++#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
++#define QTEST_ASSERT(cond) do { } while ((false) && (cond))
++#define QTEST_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
++#else
+ #define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (false)
+-
+ #define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (false)
++#endif
+ 
+ QT_END_NAMESPACE
+ 
+-- 
+2.25.4
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0011-fix-header_module.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0011-fix-header_module.patch
new file mode 100644
index 000000000000..bdb6a3616567
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0011-fix-header_module.patch
@@ -0,0 +1,22 @@
+From 2bce8511877db1db532e1437e7140b1d55633f86 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Mon, 30 Sep 2019 20:15:40 -0500
+Subject: [PATCH 11/11] fix header_module
+
+---
+ mkspecs/features/qt_module.prf | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
+index 0b2a30d159..37271e09d9 100644
+--- a/mkspecs/features/qt_module.prf
++++ b/mkspecs/features/qt_module.prf
+@@ -84,7 +84,7 @@ header_module {
+         qt_no_install_library
+ 
+     # Allow creation of .prl, .la and .pc files.
+-    target.path = $$[QT_INSTALL_LIBS]
++    target.path = $$NIX_OUTPUT_OUT/lib
+     target.CONFIG += dummy_install
+     INSTALLS    += target
+ } else {
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0012-qtbase-tbd-frameworks.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0012-qtbase-tbd-frameworks.patch
new file mode 100644
index 000000000000..8a5939978a6b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0012-qtbase-tbd-frameworks.patch
@@ -0,0 +1,15 @@
+diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
+index 84dbbfebd4..615bfed124 100644
+--- a/src/gui/Qt5GuiConfigExtras.cmake.in
++++ b/src/gui/Qt5GuiConfigExtras.cmake.in
+@@ -119,6 +119,10 @@ macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
+             if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
+                 set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
+             endif()
++            set(Qt5Gui_${_cmake_lib_name}_LIBRARY "${Qt5Gui_${_cmake_lib_name}_LIBRARY}/${_lib}.tbd")
++            if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
++                set(Qt5Gui_${_cmake_lib_name}_LIBRARY)
++            endif()
+ !!ENDIF
+             if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY)
+                 # The above find_library call doesn\'t work for finding
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0014-aarch64-darwin.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0014-aarch64-darwin.patch
new file mode 100644
index 000000000000..f0809f8f9a3f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0014-aarch64-darwin.patch
@@ -0,0 +1,275 @@
+From abc52460201bc5c7603505bb187138b0c59291aa Mon Sep 17 00:00:00 2001
+From: Mushroom <mushroom@watchingyour.tv>
+Date: Sun, 20 Dec 2020 00:11:41 +0000
+Subject: [PATCH] [QtBase] Split macOS platforms by architecture
+
+Currently macOS only has one platform, which forces the default arch to
+x86_64. This patch splits the platforms by architecture, and defaults to
+the same as the host.
+
+This stops M1-based macs from compiling x64 binaries by default,
+instead making them compile native binaries.
+
+[ChangeLog][QtBase][Platform Specific Changes][OS X] Split macOS
+platforms so it doesn't default to the x64 architecture every time
+
+Change-Id: I34891b107bb24f68371df1c8f087eb0ad5b5dd95
+---
+ configure                                     |  9 +++-
+ .../clang-macx-desktop.conf}                  |  8 ++--
+ mkspecs/common/macx.conf                      |  1 -
+ .../Info.plist.app                            |  0
+ .../Info.plist.dSYM.in                        |  0
+ .../Info.plist.disable_highdpi                |  0
+ .../Info.plist.lib                            |  0
+ mkspecs/macx-clang-arm64/qmake.conf           |  7 ++++
+ .../qplatformdefs.h                           |  0
+ mkspecs/macx-clang-x64/Info.plist.app         | 24 +++++++++++
+ mkspecs/macx-clang-x64/Info.plist.dSYM.in     | 18 ++++++++
+ .../macx-clang-x64/Info.plist.disable_highdpi |  8 ++++
+ mkspecs/macx-clang-x64/Info.plist.lib         | 20 +++++++++
+ mkspecs/macx-clang-x64/qmake.conf             |  7 ++++
+ mkspecs/macx-clang-x64/qplatformdefs.h        | 41 +++++++++++++++++++
+ 15 files changed, 137 insertions(+), 6 deletions(-)
+ rename mkspecs/{macx-clang/qmake.conf => common/clang-macx-desktop.conf} (83%)
+ rename mkspecs/{macx-clang => macx-clang-arm64}/Info.plist.app (100%)
+ rename mkspecs/{macx-clang => macx-clang-arm64}/Info.plist.dSYM.in (100%)
+ rename mkspecs/{macx-clang => macx-clang-arm64}/Info.plist.disable_highdpi (100%)
+ rename mkspecs/{macx-clang => macx-clang-arm64}/Info.plist.lib (100%)
+ create mode 100644 mkspecs/macx-clang-arm64/qmake.conf
+ rename mkspecs/{macx-clang => macx-clang-arm64}/qplatformdefs.h (100%)
+ create mode 100644 mkspecs/macx-clang-x64/Info.plist.app
+ create mode 100644 mkspecs/macx-clang-x64/Info.plist.dSYM.in
+ create mode 100644 mkspecs/macx-clang-x64/Info.plist.disable_highdpi
+ create mode 100644 mkspecs/macx-clang-x64/Info.plist.lib
+ create mode 100644 mkspecs/macx-clang-x64/qmake.conf
+ create mode 100644 mkspecs/macx-clang-x64/qplatformdefs.h
+
+diff --git a/configure b/configure
+index b6c9b462f24..a86f2ceaa5b 100755
+--- a/configure
++++ b/configure
+@@ -556,7 +556,14 @@ PLATFORM_NOTES=
+ if [ -z "$PLATFORM" ]; then
+     case "$UNAME_SYSTEM:$UNAME_RELEASE" in
+      Darwin:*)
+-        PLATFORM=macx-clang
++        case "$UNAME_MACHINE" in
++            arm64)
++                PLATFORM=macx-clang-arm64
++                ;;
++            *)
++                PLATFORM=macx-clang-x64
++                ;;
++        esac
+         ;;
+      AIX:*)
+         #PLATFORM=aix-g++
+diff --git a/mkspecs/macx-clang/qmake.conf b/mkspecs/common/clang-macx-desktop.conf
+similarity index 83%
+rename from mkspecs/macx-clang/qmake.conf
+rename to mkspecs/common/clang-macx-desktop.conf
+index 0cf1f31b60d..042319a2aa3 100644
+--- a/mkspecs/macx-clang/qmake.conf
++++ b/mkspecs/common/clang-macx-desktop.conf
+@@ -24,9 +24,9 @@ QMAKE_LIBS_X11 = -lX11 -lXext -lm
+ QMAKE_LIBDIR_X11 = /opt/X11/lib
+ QMAKE_INCDIR_X11 = /opt/X11/include
+ 
+-include(../common/macx.conf)
+-include(../common/gcc-base-mac.conf)
+-include(../common/clang.conf)
+-include(../common/clang-mac.conf)
++include(macx.conf)
++include(gcc-base-mac.conf)
++include(clang.conf)
++include(clang-mac.conf)
+ 
+ load(qt_config)
+diff --git a/mkspecs/macx-clang/Info.plist.app b/mkspecs/macx-clang-arm64/Info.plist.app
+similarity index 100%
+rename from mkspecs/macx-clang/Info.plist.app
+rename to mkspecs/macx-clang-arm64/Info.plist.app
+diff --git a/mkspecs/macx-clang/Info.plist.dSYM.in b/mkspecs/macx-clang-arm64/Info.plist.dSYM.in
+similarity index 100%
+rename from mkspecs/macx-clang/Info.plist.dSYM.in
+rename to mkspecs/macx-clang-arm64/Info.plist.dSYM.in
+diff --git a/mkspecs/macx-clang/Info.plist.disable_highdpi b/mkspecs/macx-clang-arm64/Info.plist.disable_highdpi
+similarity index 100%
+rename from mkspecs/macx-clang/Info.plist.disable_highdpi
+rename to mkspecs/macx-clang-arm64/Info.plist.disable_highdpi
+diff --git a/mkspecs/macx-clang/Info.plist.lib b/mkspecs/macx-clang-arm64/Info.plist.lib
+similarity index 100%
+rename from mkspecs/macx-clang/Info.plist.lib
+rename to mkspecs/macx-clang-arm64/Info.plist.lib
+diff --git a/mkspecs/macx-clang-arm64/qmake.conf b/mkspecs/macx-clang-arm64/qmake.conf
+new file mode 100644
+index 00000000000..0cc2361e696
+--- /dev/null
++++ b/mkspecs/macx-clang-arm64/qmake.conf
+@@ -0,0 +1,7 @@
++#
++# qmake configuration for Clang on OS X (arm64)
++#
++
++QMAKE_APPLE_DEVICE_ARCHS=arm64
++
++include(../common/clang-macx-desktop.conf)
+diff --git a/mkspecs/macx-clang/qplatformdefs.h b/mkspecs/macx-clang-arm64/qplatformdefs.h
+similarity index 100%
+rename from mkspecs/macx-clang/qplatformdefs.h
+rename to mkspecs/macx-clang-arm64/qplatformdefs.h
+diff --git a/mkspecs/macx-clang-x64/Info.plist.app b/mkspecs/macx-clang-x64/Info.plist.app
+new file mode 100644
+index 00000000000..fa592af0897
+--- /dev/null
++++ b/mkspecs/macx-clang-x64/Info.plist.app
+@@ -0,0 +1,24 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
++<plist version="1.0">
++<dict>
++	<key>CFBundleExecutable</key>
++	<string>${EXECUTABLE_NAME}</string>
++	<key>CFBundleIconFile</key>
++	<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
++	<key>CFBundleIdentifier</key>
++	<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
++	<key>CFBundlePackageType</key>
++	<string>APPL</string>
++	<key>CFBundleSignature</key>
++	<string>${QMAKE_PKGINFO_TYPEINFO}</string>
++	<key>LSMinimumSystemVersion</key>
++	<string>${MACOSX_DEPLOYMENT_TARGET}</string>
++	<key>NOTE</key>
++	<string>This file was generated by Qt/QMake.</string>
++	<key>NSPrincipalClass</key>
++	<string>NSApplication</string>
++	<key>NSSupportsAutomaticGraphicsSwitching</key>
++	<true/>
++</dict>
++</plist>
+diff --git a/mkspecs/macx-clang-x64/Info.plist.dSYM.in b/mkspecs/macx-clang-x64/Info.plist.dSYM.in
+new file mode 100644
+index 00000000000..a8c8d0d4fb5
+--- /dev/null
++++ b/mkspecs/macx-clang-x64/Info.plist.dSYM.in
+@@ -0,0 +1,18 @@
++<?xml version=\"1.0\" encoding=\"UTF-8\"?>
++<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
++<plist version=\"1.0\">
++	<dict>
++		<key>CFBundleIdentifier</key>
++		<string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
++		<key>CFBundlePackageType</key>
++		<string>dSYM</string>
++		<key>CFBundleSignature</key>
++		<string>????</string>
++!!IF !isEmpty(VERSION)
++		<key>CFBundleShortVersionString</key>
++		<string>$${VER_MAJ}.$${VER_MIN}</string>
++		<key>CFBundleVersion</key>
++		<string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
++!!ENDIF
++	</dict>
++</plist>
+diff --git a/mkspecs/macx-clang-x64/Info.plist.disable_highdpi b/mkspecs/macx-clang-x64/Info.plist.disable_highdpi
+new file mode 100644
+index 00000000000..a9b89888ad4
+--- /dev/null
++++ b/mkspecs/macx-clang-x64/Info.plist.disable_highdpi
+@@ -0,0 +1,8 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
++<plist version="1.0">
++<dict>
++	<key>NSHighResolutionCapable</key>
++	<string>NO</string>
++</dict>
++</plist>
+diff --git a/mkspecs/macx-clang-x64/Info.plist.lib b/mkspecs/macx-clang-x64/Info.plist.lib
+new file mode 100644
+index 00000000000..34752ec40d9
+--- /dev/null
++++ b/mkspecs/macx-clang-x64/Info.plist.lib
+@@ -0,0 +1,20 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
++<plist version="1.0">
++<dict>
++	<key>CFBundleExecutable</key>
++	<string>${EXECUTABLE_NAME}</string>
++	<key>CFBundleIdentifier</key>
++	<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
++	<key>CFBundlePackageType</key>
++	<string>FMWK</string>
++	<key>CFBundleShortVersionString</key>
++	<string>${QMAKE_SHORT_VERSION}</string>
++	<key>CFBundleSignature</key>
++	<string>${QMAKE_PKGINFO_TYPEINFO}</string>
++	<key>CFBundleVersion</key>
++	<string>${QMAKE_FULL_VERSION}</string>
++	<key>NOTE</key>
++	<string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
++</dict>
++</plist>
+diff --git a/mkspecs/macx-clang-x64/qmake.conf b/mkspecs/macx-clang-x64/qmake.conf
+new file mode 100644
+index 00000000000..1ac373b53b4
+--- /dev/null
++++ b/mkspecs/macx-clang-x64/qmake.conf
+@@ -0,0 +1,7 @@
++#
++# qmake configuration for Clang on OS X (arm64)
++#
++
++QMAKE_APPLE_DEVICE_ARCHS=x86_64
++
++include(../common/clang-macx-desktop.conf)
+diff --git a/mkspecs/macx-clang-x64/qplatformdefs.h b/mkspecs/macx-clang-x64/qplatformdefs.h
+new file mode 100644
+index 00000000000..063491dd900
+--- /dev/null
++++ b/mkspecs/macx-clang-x64/qplatformdefs.h
+@@ -0,0 +1,41 @@
++/****************************************************************************
++**
++** Copyright (C) 2016 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the qmake spec of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 3 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL3 included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 3 requirements
++** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 2.0 or (at your option) the GNU General
++** Public license version 3 or any later version approved by the KDE Free
++** Qt Foundation. The licenses are as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
++** included in the packaging of this file. Please review the following
++** information to ensure the GNU General Public License requirements will
++** be met: https://www.gnu.org/licenses/gpl-2.0.html and
++** https://www.gnu.org/licenses/gpl-3.0.html.
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include "../common/mac/qplatformdefs.h"
++
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative-default-disable-qmlcache.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative-default-disable-qmlcache.patch
new file mode 100644
index 000000000000..03668d960c78
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative-default-disable-qmlcache.patch
@@ -0,0 +1,13 @@
+diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
+index 1d66e75..827567a 100644
+--- a/src/qml/qml/qqmltypeloader.cpp
++++ b/src/qml/qml/qqmltypeloader.cpp
+@@ -727,7 +727,7 @@ bool QQmlTypeLoader::Blob::isDebugging() const
+ 
+ bool QQmlTypeLoader::Blob::diskCacheEnabled() const
+ {
+-    return (!disableDiskCache() && !isDebugging()) || forceDiskCache();
++    return forceDiskCache();
+ }
+ 
+ bool QQmlTypeLoader::Blob::qmldirDataAvailable(const QQmlRefPointer<QQmlQmldirData> &data, QList<QQmlError> *errors)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative.patch
new file mode 100644
index 000000000000..d9c721e6946c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative.patch
@@ -0,0 +1,114 @@
+diff --git a/src/particles/particles.pro b/src/particles/particles.pro
+index aaaa83419a..58aee00036 100644
+--- a/src/particles/particles.pro
++++ b/src/particles/particles.pro
+@@ -20,6 +20,6 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick/Particles.2
+ QML_IMPORT_NAME = QtQuick.Particles
+ IMPORT_VERSION = 2.$$QT_MINOR_VERSION
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+ 
+ load(qt_module)
+diff --git a/src/qml/qml.pro b/src/qml/qml.pro
+index e39a8319b6..90c0331278 100644
+--- a/src/qml/qml.pro
++++ b/src/qml/qml.pro
+@@ -72,6 +72,6 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml
+ QML_IMPORT_NAME = QtQml
+ IMPORT_VERSION = 2.$$QT_MINOR_VERSION
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+ 
+ load(qt_module)
+diff --git a/src/qmlmodels/qmlmodels.pro b/src/qmlmodels/qmlmodels.pro
+index 4ac093556d..112e2c2be0 100644
+--- a/src/qmlmodels/qmlmodels.pro
++++ b/src/qmlmodels/qmlmodels.pro
+@@ -68,6 +68,6 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml/Models.2
+ QML_IMPORT_NAME = QtQml.Models
+ IMPORT_VERSION = 2.$$QT_MINOR_VERSION
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+ 
+ load(qt_module)
+diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro
+index c2e8068fc6..79dba368f7 100644
+--- a/src/qmltest/qmltest.pro
++++ b/src/qmltest/qmltest.pro
+@@ -34,7 +34,7 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/Qt/test/qtestroot
+ QML_IMPORT_NAME = Qt.test.qtestroot
+ QML_IMPORT_VERSION = 1.0
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+ 
+ # Install qmldir
+ qmldir.files = $$PWD/qmldir
+diff --git a/src/qmlworkerscript/qmlworkerscript.pro b/src/qmlworkerscript/qmlworkerscript.pro
+index 84466062e1..79885455cc 100644
+--- a/src/qmlworkerscript/qmlworkerscript.pro
++++ b/src/qmlworkerscript/qmlworkerscript.pro
+@@ -23,6 +23,6 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml/WorkerScript.2
+ QML_IMPORT_NAME = QtQml.WorkerScript
+ IMPORT_VERSION = 2.$$QT_MINOR_VERSION
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+ 
+ load(qt_module)
+diff --git a/src/quick/quick.pro b/src/quick/quick.pro
+index f2d49cf939..c401b04c4e 100644
+--- a/src/quick/quick.pro
++++ b/src/quick/quick.pro
+@@ -52,4 +52,4 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick.2
+ QML_IMPORT_NAME = QtQuick
+ IMPORT_VERSION = 2.$$QT_MINOR_VERSION
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+diff --git a/src/quickshapes/quickshapes.pro b/src/quickshapes/quickshapes.pro
+index 4dbd3e5e46..0c6b186fc8 100644
+--- a/src/quickshapes/quickshapes.pro
++++ b/src/quickshapes/quickshapes.pro
+@@ -36,4 +36,4 @@ QMLTYPES_FILENAME = plugins.qmltypes
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick/Shapes
+ QML_IMPORT_NAME = QtQuick.Shapes
+ IMPORT_VERSION = 1.$$QT_MINOR_VERSION
+-CONFIG += qmltypes install_qmltypes install_metatypes
++CONFIG += qmltypes install_qmltypes
+diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
+index 005db4248..685c5b1b2 100644
+--- a/src/qml/qml/qqmlimport.cpp
++++ b/src/qml/qml/qqmlimport.cpp
+@@ -1760,6 +1760,15 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
+     QString installImportsPath =  QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
+     addImportPath(installImportsPath);
+ 
++    // Add import paths derived from PATH
++    const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
++    const QString qmldir = QStringLiteral("../" NIXPKGS_QML2_IMPORT_PREFIX);
++    for (const QString &path: paths) {
++        if (!path.isEmpty()) {
++            addImportPath(QDir::cleanPath(path + QDir::separator() + qmldir));
++        }
++    }
++
+     // env import paths
+     if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) {
+         const QString envImportPath = qEnvironmentVariable("QML2_IMPORT_PATH");
+diff --git a/tools/qmlcachegen/qmlcache.prf b/tools/qmlcachegen/qmlcache.prf
+index 537eaf62ea..e21de58f64 100644
+--- a/tools/qmlcachegen/qmlcache.prf
++++ b/tools/qmlcachegen/qmlcache.prf
+@@ -26,7 +26,7 @@ defineReplace(qmlCacheOutputFileName) {
+ }
+ 
+ qmlcacheinst.base = $$QMLCACHE_DESTDIR
+-qmlcacheinst.path = $$[QT_INSTALL_QML]/$$TARGETPATH
++qmlcacheinst.path = $$NIX_OUTPUT_QML/$$TARGETPATH
+ qmlcacheinst.CONFIG = no_check_exist
+ 
+ qmlcachegen.input = CACHEGEN_FILES
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtscript.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtscript.patch
new file mode 100644
index 000000000000..5508dec1280e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtscript.patch
@@ -0,0 +1,13 @@
+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
+ 
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtserialport.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtserialport.patch
new file mode 100644
index 000000000000..f25524e80bcf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtserialport.patch
@@ -0,0 +1,22 @@
+diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
+index af2dab2..8e17f64 100644
+--- a/src/serialport/qtudev_p.h
++++ b/src/serialport/qtudev_p.h
+@@ -111,9 +111,17 @@ inline QFunctionPointer resolveSymbol(QLibrary *udevLibrary, const char *symbolN
+ inline bool resolveSymbols(QLibrary *udevLibrary)
+ {
+     if (!udevLibrary->isLoaded()) {
++#ifdef NIXPKGS_LIBUDEV
++        udevLibrary->setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 1);
++#else
+         udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 1);
++#endif
+         if (!udevLibrary->load()) {
++#ifdef NIXPKGS_LIBUDEV
++            udevLibrary->setFileNameAndVersion(QLatin1String(NIXPKGS_LIBUDEV), 0);
++#else
+             udevLibrary->setFileNameAndVersion(QStringLiteral("udev"), 0);
++#endif
+             if (!udevLibrary->load()) {
+                 qWarning("Failed to load the library: %s, supported version(s): %i and %i", qPrintable(udevLibrary->fileName()), 1, 0);
+                 return false;
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qttools.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qttools.patch
new file mode 100644
index 000000000000..8ae12198ca25
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qttools.patch
@@ -0,0 +1,15 @@
+--- a/src/macdeployqt/shared/shared.cpp
++++ b/src/macdeployqt/shared/shared.cpp
+@@ -1241,6 +1241,12 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
+     if (!QFile(qmlImportScannerPath).exists())
+         qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
+ 
++#ifdef NIXPKGS_QMLIMPORTSCANNER
++    // Fallback: Nixpkgs hardcoded path
++    if (!QFile(qmlImportScannerPath).exists())
++        qmlImportScannerPath = NIXPKGS_QMLIMPORTSCANNER;
++#endif
++
+     // Verify that we found a qmlimportscanner binary
+     if (!QFile(qmlImportScannerPath).exists()) {
+         LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-checks.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-checks.patch
new file mode 100644
index 000000000000..213fb624dab1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-checks.patch
@@ -0,0 +1,29 @@
+diff --git a/configure.pri b/configure.pri
+index 3a33bdc82..c1460b8b5 100644
+--- a/configure.pri
++++ b/configure.pri
+@@ -442,24 +442,6 @@ defineTest(qtwebengine_isWindowsPlatformSupported) {
+ }
+ 
+ defineTest(qtwebengine_isMacOsPlatformSupported) {
+-    !qtwebengine_isMinXcodeVersion(10, 0, 0) {
+-        qtwebengine_platformError("requires at least version 10.0.0, but using Xcode version $${QMAKE_XCODE_VERSION}.")
+-        return(false)
+-    }
+-    !clang|intel_icc {
+-        qtwebengine_platformError("requires Clang.")
+-        return(false)
+-    }
+-    # We require macOS 10.13 (darwin version 17.0.0) or newer.
+-    darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0)
+-    lessThan(darwin_major_version, 17) {
+-        qtwebengine_platformError("requires macOS version 10.13 or newer.")
+-        return(false)
+-    }
+-    !qtwebengine_isMinOSXSDKVersion(10, 13): {
+-        qtwebengine_platformError("requires a macOS SDK version of 10.13 or newer. Current version is $${WEBENGINE_OSX_SDK_PRODUCT_VERSION}.")
+-        return(false)
+-    }
+     CONFIG(debug, debug|release):isUniversal(){
+         qtwebengine_platformError("Universal builds can not be done with debug configuration due to large binary size.")
+         return(false)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-no-platform-check.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-no-platform-check.patch
new file mode 100644
index 000000000000..86663ee80b57
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-darwin-no-platform-check.patch
@@ -0,0 +1,12 @@
+diff a/src/buildtools/config/mac_osx.pri b/src/buildtools/config/mac_osx.pri
+--- a/src/buildtools/config/mac_osx.pri
++++ b/src/buildtools/config/mac_osx.pri
+@@ -5,8 +5,6 @@ load(functions)
+ # otherwise query for it.
+ QMAKE_MAC_SDK_VERSION = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.SDKVersion)
+ isEmpty(QMAKE_MAC_SDK_VERSION) {
+-     QMAKE_MAC_SDK_VERSION = $$system("/usr/bin/xcodebuild -sdk $${QMAKE_MAC_SDK} -version SDKVersion 2>/dev/null")
+-     isEmpty(QMAKE_MAC_SDK_VERSION): error("Could not resolve SDK version for \'$${QMAKE_MAC_SDK}\'")
+ }
+ 
+ # chromium/build/mac/find_sdk.py expects the SDK version (mac_sdk_min) in Major.Minor format.
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-link-pulseaudio.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-link-pulseaudio.patch
new file mode 100644
index 000000000000..052ec89dbc17
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-link-pulseaudio.patch
@@ -0,0 +1,8 @@
+--- a/src/core/config/common.pri
++++ b/src/core/config/common.pri
+@@ -47,3 +47,5 @@
+
+ !qtConfig(webengine-nodejs10): gn_args += use_rollup=false
+ gn_args += enable_ipc_logging=false
++
++gn_args += link_pulseaudio=true
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-mac-dont-set-dsymutil-path.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-mac-dont-set-dsymutil-path.patch
new file mode 100644
index 000000000000..dcdf5f57ffdc
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebengine-mac-dont-set-dsymutil-path.patch
@@ -0,0 +1,12 @@
+diff a/src/3rdparty/chromium/build/toolchain/mac/BUILD.gn b/src/3rdparty/chromium/build/toolchain/mac/BUILD.gn
+--- a/src/3rdparty/chromium/build/toolchain/mac/BUILD.gn
++++ b/src/3rdparty/chromium/build/toolchain/mac/BUILD.gn
+@@ -184,8 +184,6 @@ template("mac_toolchain") {
+     # If dSYMs are enabled, this flag will be added to the link tools.
+     if (_enable_dsyms) {
+       dsym_switch = " -Wcrl,dsym,{{root_out_dir}} "
+-      dsym_switch += "-Wcrl,dsymutilpath," +
+-                     "${prefix}dsymutil" + " "
+ 
+       dsym_output_dir =
+           "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.dSYM"
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-qos-classes.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-qos-classes.patch
new file mode 100644
index 000000000000..a7087f517623
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-qos-classes.patch
@@ -0,0 +1,11 @@
+diff --git a/Source/cmake/OptionsQt.cmake b/Source/cmake/OptionsQt.cmake
+--- a/Source/cmake/OptionsQt.cmake
++++ b/Source/cmake/OptionsQt.cmake
+@@ -683,7 +683,6 @@ if (WIN32 AND COMPILER_IS_GCC_OR_CLANG)
+ endif ()
+ 
+ if (APPLE)
+-    SET_AND_EXPOSE_TO_BUILD(HAVE_QOS_CLASSES 1)
+ endif ()
+ 
+ if (ENABLE_MATHML)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-readline.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-readline.patch
new file mode 100644
index 000000000000..4871032f6f2c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-darwin-no-readline.patch
@@ -0,0 +1,30 @@
+diff --git a/Source/JavaScriptCore/shell/CMakeLists.txt b/Source/JavaScriptCore/shell/CMakeLists.txt
+--- a/Source/JavaScriptCore/shell/CMakeLists.txt
++++ b/Source/JavaScriptCore/shell/CMakeLists.txt
+@@ -9,7 +9,6 @@ set(JSC_LIBRARIES
+ )
+ 
+ if (WTF_OS_MAC_OS_X)
+-    list(APPEND JSC_LIBRARIES edit)
+ endif ()
+ 
+ if ("${JavaScriptCore_LIBRARY_TYPE}" MATCHES "STATIC")
+diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
+--- a/Source/WTF/wtf/Platform.h
++++ b/Source/WTF/wtf/Platform.h
+@@ -563,7 +563,6 @@
+ #if PLATFORM(IOS)
+ 
+ #define HAVE_NETWORK_EXTENSION 1
+-#define HAVE_READLINE 1
+ #if USE(APPLE_INTERNAL_SDK)
+ #define USE_CFNETWORK 1
+ #endif
+@@ -650,7 +649,6 @@
+ #define HAVE_MADV_DONTNEED 1
+ #define HAVE_MERGESORT 1
+ #define HAVE_PTHREAD_SETNAME_NP 1
+-#define HAVE_READLINE 1
+ #define HAVE_SYS_TIMEB_H 1
+ 
+ #if !PLATFORM(GTK) && !PLATFORM(QT)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-icu68.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-icu68.patch
new file mode 100644
index 000000000000..73463d7567a3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit-icu68.patch
@@ -0,0 +1,170 @@
+Regressed by https://github.com/unicode-org/icu/commit/c3fe7e09d844
+
+In file included from Source/WebCore/platform/text/TextAllInOne.cpp:31:
+Source/WebCore/platform/text/TextCodecICU.cpp:311:42: error: use of undeclared identifier 'TRUE'
+        ucnv_setFallback(m_converterICU, TRUE);
+                                         ^
+In file included from Source/WebCore/platform/text/TextAllInOne.cpp:40:
+In file included from Source/WebCore/platform/text/icu/UTextProvider.cpp:27:
+Source/WebCore/platform/text/icu/UTextProvider.h:83:28: error: use of undeclared identifier 'TRUE'
+            isAccessible = TRUE;
+                           ^
+Source/WebCore/platform/text/icu/UTextProvider.h:88:28: error: use of undeclared identifier 'FALSE'
+            isAccessible = FALSE;
+                           ^
+Source/WebCore/platform/text/icu/UTextProvider.h:97:28: error: use of undeclared identifier 'TRUE'
+            isAccessible = TRUE;
+                           ^
+Source/WebCore/platform/text/icu/UTextProvider.h:102:28: error: use of undeclared identifier 'FALSE'
+            isAccessible = FALSE;
+                           ^
+In file included from Source/WebCore/platform/text/TextAllInOne.cpp:41:
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:103:20: error: use of undeclared identifier 'TRUE'
+            return TRUE;
+                   ^
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:108:20: error: use of undeclared identifier 'FALSE'
+            return FALSE;
+                   ^
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:114:20: error: use of undeclared identifier 'TRUE'
+            return TRUE;
+                   ^
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:119:20: error: use of undeclared identifier 'FALSE'
+            return FALSE;
+                   ^
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:147:12: error: use of undeclared identifier 'TRUE'
+    return TRUE;
+           ^
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:339:16: error: use of undeclared identifier 'FALSE'
+        return FALSE;
+               ^
+Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp:359:12: error: use of undeclared identifier 'TRUE'
+    return TRUE;
+           ^
+In file included from Source/WebCore/platform/text/TextAllInOne.cpp:42:
+Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp:128:16: error: use of undeclared identifier 'FALSE'
+        return FALSE;
+               ^
+Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp:148:12: error: use of undeclared identifier 'TRUE'
+    return TRUE;
+           ^
+
+--- a/Source/WebCore/platform/text/TextCodecICU.cpp
++++ b/Source/WebCore/platform/text/TextCodecICU.cpp
+@@ -308,7 +308,7 @@ void TextCodecICU::createICUConverter() const
+     m_converterICU = ucnv_open(m_canonicalConverterName, &err);
+     ASSERT(U_SUCCESS(err));
+     if (m_converterICU)
+-        ucnv_setFallback(m_converterICU, TRUE);
++        ucnv_setFallback(m_converterICU, true);
+ }
+ 
+ int TextCodecICU::decodeToBuffer(UChar* target, UChar* targetLimit, const char*& source, const char* sourceLimit, int32_t* offsets, bool flush, UErrorCode& err)
+--- a/Source/WebCore/platform/text/icu/UTextProvider.h
++++ b/Source/WebCore/platform/text/icu/UTextProvider.h
+@@ -80,12 +80,12 @@ inline bool uTextAccessInChunkOrOutOfRange(UText* text
+             // Ensure chunk offset is well formed if computed offset exceeds int32_t range.
+             ASSERT(offset < std::numeric_limits<int32_t>::max());
+             text->chunkOffset = offset < std::numeric_limits<int32_t>::max() ? static_cast<int32_t>(offset) : 0;
+-            isAccessible = TRUE;
++            isAccessible = true;
+             return true;
+         }
+         if (nativeIndex >= nativeLength && text->chunkNativeLimit == nativeLength) {
+             text->chunkOffset = text->chunkLength;
+-            isAccessible = FALSE;
++            isAccessible = false;
+             return true;
+         }
+     } else {
+@@ -94,12 +94,12 @@ inline bool uTextAccessInChunkOrOutOfRange(UText* text
+             // Ensure chunk offset is well formed if computed offset exceeds int32_t range.
+             ASSERT(offset < std::numeric_limits<int32_t>::max());
+             text->chunkOffset = offset < std::numeric_limits<int32_t>::max() ? static_cast<int32_t>(offset) : 0;
+-            isAccessible = TRUE;
++            isAccessible = true;
+             return true;
+         }
+         if (nativeIndex <= 0 && !text->chunkNativeStart) {
+             text->chunkOffset = 0;
+-            isAccessible = FALSE;
++            isAccessible = false;
+             return true;
+         }
+     }
+--- a/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp
++++ b/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp
+@@ -100,23 +100,23 @@ static UBool uTextLatin1Access(UText* uText, int64_t i
+         if (index < uText->chunkNativeLimit && index >= uText->chunkNativeStart) {
+             // Already inside the buffer. Set the new offset.
+             uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart);
+-            return TRUE;
++            return true;
+         }
+         if (index >= length && uText->chunkNativeLimit == length) {
+             // Off the end of the buffer, but we can't get it.
+             uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart);
+-            return FALSE;
++            return false;
+         }
+     } else {
+         if (index <= uText->chunkNativeLimit && index > uText->chunkNativeStart) {
+             // Already inside the buffer. Set the new offset.
+             uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart);
+-            return TRUE;
++            return true;
+         }
+         if (!index && !uText->chunkNativeStart) {
+             // Already at the beginning; can't go any farther.
+             uText->chunkOffset = 0;
+-            return FALSE;
++            return false;
+         }
+     }
+     
+@@ -144,7 +144,7 @@ static UBool uTextLatin1Access(UText* uText, int64_t i
+ 
+     uText->nativeIndexingLimit = uText->chunkLength;
+ 
+-    return TRUE;
++    return true;
+ }
+ 
+ static int32_t uTextLatin1Extract(UText* uText, int64_t start, int64_t limit, UChar* dest, int32_t destCapacity, UErrorCode* status)
+@@ -336,7 +336,7 @@ static int64_t uTextLatin1ContextAwareNativeLength(UTe
+ static UBool uTextLatin1ContextAwareAccess(UText* text, int64_t nativeIndex, UBool forward)
+ {
+     if (!text->context)
+-        return FALSE;
++        return false;
+     int64_t nativeLength = uTextLatin1ContextAwareNativeLength(text);
+     UBool isAccessible;
+     if (uTextAccessInChunkOrOutOfRange(text, nativeIndex, nativeLength, forward, isAccessible))
+@@ -356,7 +356,7 @@ static UBool uTextLatin1ContextAwareAccess(UText* text
+         ASSERT(newContext == UTextProviderContext::PriorContext);
+         textLatin1ContextAwareSwitchToPriorContext(text, nativeIndex, nativeLength, forward);
+     }
+-    return TRUE;
++    return true;
+ }
+ 
+ static int32_t uTextLatin1ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode)
+--- a/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp
++++ b/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp
+@@ -125,7 +125,7 @@ static inline int64_t uTextUTF16ContextAwareNativeLeng
+ static UBool uTextUTF16ContextAwareAccess(UText* text, int64_t nativeIndex, UBool forward)
+ {
+     if (!text->context)
+-        return FALSE;
++        return false;
+     int64_t nativeLength = uTextUTF16ContextAwareNativeLength(text);
+     UBool isAccessible;
+     if (uTextAccessInChunkOrOutOfRange(text, nativeIndex, nativeLength, forward, isAccessible))
+@@ -145,7 +145,7 @@ static UBool uTextUTF16ContextAwareAccess(UText* text,
+         ASSERT(newContext == UTextProviderContext::PriorContext);
+         textUTF16ContextAwareSwitchToPriorContext(text, nativeIndex, nativeLength, forward);
+     }
+-    return TRUE;
++    return true;
+ }
+ 
+ static int32_t uTextUTF16ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit.patch b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit.patch
new file mode 100644
index 000000000000..b94a4b76cbab
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtwebkit.patch
@@ -0,0 +1,12 @@
+diff --git a/Source/WebKit2/PlatformQt.cmake b/Source/WebKit2/PlatformQt.cmake
+--- a/Source/WebKit2/PlatformQt.cmake
++++ b/Source/WebKit2/PlatformQt.cmake
+@@ -261,6 +261,7 @@
+ list(APPEND WebKit2_SYSTEM_INCLUDE_DIRECTORIES
+     ${GLIB_INCLUDE_DIRS}
+     ${GSTREAMER_INCLUDE_DIRS}
++    ${GSTREAMER_PBUTILS_INCLUDE_DIRS}
+     ${Qt5Quick_INCLUDE_DIRS}
+     ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
+     ${SQLITE_INCLUDE_DIR}
+
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs-generated.json b/nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs-generated.json
new file mode 100644
index 000000000000..817129349718
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs-generated.json
@@ -0,0 +1,202 @@
+{
+  "qt3d": {
+    "url": "https://invent.kde.org/qt/qt/qt3d.git",
+    "rev": "c1f8fa2578d99e07f5e581f26bd532695b9534f9",
+    "sha256": "19wsf9capc8i5157hfp8g735scpcms329ylp0fg86j9qalg7ccwg"
+  },
+  "qtactiveqt": {
+    "url": "https://invent.kde.org/qt/qt/qtactiveqt.git",
+    "rev": "2ed4be9e852d2533b982493a26bf061b245dc106",
+    "sha256": "0v6fwykibl4d20sdh10inaavpzwp5ijpyw8k31078shw3hsgkqxf"
+  },
+  "qtandroidextras": {
+    "url": "https://invent.kde.org/qt/qt/qtandroidextras.git",
+    "rev": "3d30862e761afd5fe8451857bb531b6fb8f63dc3",
+    "sha256": "0sq4dgk88n96wja1wp6j5swxhz8wksf1v4sibywvg7v431nfy82p"
+  },
+  "qtbase": {
+    "url": "https://invent.kde.org/qt/qt/qtbase.git",
+    "rev": "ea7a183732c17005f08ca14fd70cdd305c90396d",
+    "sha256": "0lblir4zcnxc2ix9frcsygkhfs5qx7xibpflapmi6d978jjfxjmx"
+  },
+  "qtcharts": {
+    "url": "https://invent.kde.org/qt/qt/qtcharts.git",
+    "rev": "e17308d5ce83a8b66aeeaaaf16ce16d4ee6b2826",
+    "sha256": "1igna3qdwpaf67lhj0m743cj127hyg73ynjhadhjk3gz34h12r09"
+  },
+  "qtconnectivity": {
+    "url": "https://invent.kde.org/qt/qt/qtconnectivity.git",
+    "rev": "e33b82889625b6a72e0be91c5023a30d53136a80",
+    "sha256": "17yxmj1xd2q0a2in6aygp88bsg1vivklmzjwi97llbmvcxxvzhfn"
+  },
+  "qtdatavis3d": {
+    "url": "https://invent.kde.org/qt/qt/qtdatavis3d.git",
+    "rev": "d7af24d26b9fbb83bf57b2b7245d280eb78e8b22",
+    "sha256": "1h85cn4qabva8fcr69b35cmy9c7vbk2fz8licw5ca42bq141k4kw"
+  },
+  "qtdeclarative": {
+    "url": "https://invent.kde.org/qt/qt/qtdeclarative.git",
+    "rev": "1b0e366092bcfae0392592c3b7891f0e47af1018",
+    "sha256": "0fif6gbin3clvy7rfvrs5qdjqvi3ql9yciiwdbm7z0by2kzz1qsg"
+  },
+  "qtdoc": {
+    "url": "https://invent.kde.org/qt/qt/qtdoc.git",
+    "rev": "c8af0c56f1765302f8bdf874dfacb11c4e0bf4e3",
+    "sha256": "161wm1pq732nnbx8jbmiv1g1ziqzjwy48dpasy3zgj4i83qyvdas"
+  },
+  "qtgamepad": {
+    "url": "https://invent.kde.org/qt/qt/qtgamepad.git",
+    "rev": "4b52913503e3713200265cd6bc19b301792dbf96",
+    "sha256": "1n5pafxarhb4rsvr18al4hyc6xmm5nhjkknrnhdldy9vz7w50bgs"
+  },
+  "qtgraphicaleffects": {
+    "url": "https://invent.kde.org/qt/qt/qtgraphicaleffects.git",
+    "rev": "cce7d784237cd2dd4af1abe2757d048e34e02685",
+    "sha256": "1yvxpkfxd44z9z44mfv77lfsbgjlmxz1rilblpp8h276zc5w6l5z"
+  },
+  "qtimageformats": {
+    "url": "https://invent.kde.org/qt/qt/qtimageformats.git",
+    "rev": "b22bf4d0d77c7dafe8b4622f8bb45ac0b9cc9bdd",
+    "sha256": "0gz1par4gkcwwbxh0g1n1lrzyjjmi53gqfmbb222gkf5k8kf0r2i"
+  },
+  "qtlocation": {
+    "url": "https://invent.kde.org/qt/qt/qtlocation.git",
+    "rev": "48a17e88fc1df5b6ae82a9787466226c830bcbf2",
+    "sha256": "0gn4zsf01xr0g8divixk2zpq97dnqs1cdc3q577ijczd2rcs6z4f"
+  },
+  "qtlottie": {
+    "url": "https://invent.kde.org/qt/qt/qtlottie.git",
+    "rev": "909b79f4810b8ac62baa3544837793cfb132593b",
+    "sha256": "1bh5418nshzlgc3xf8yg1c0n70xcazr3ya9fdfn1xs3yhxdxcd8h"
+  },
+  "qtmacextras": {
+    "url": "https://invent.kde.org/qt/qt/qtmacextras.git",
+    "rev": "cc717d0093d796e6bafb65892e6825f146c1d3cd",
+    "sha256": "1cdal8yfjwgl30fh2s5s45hy1mw70n8bfdsbx8q6j4g062dr16zd"
+  },
+  "qtmultimedia": {
+    "url": "https://invent.kde.org/qt/qt/qtmultimedia.git",
+    "rev": "f587b18db4abd68cb6d4d77fbcec1b94c38d2a51",
+    "sha256": "16b3yaq7i0cs9sw8q5f98g9kzphy3kwy0nw6hzznnzpkmg0pgkv1"
+  },
+  "qtnetworkauth": {
+    "url": "https://invent.kde.org/qt/qt/qtnetworkauth.git",
+    "rev": "1e3f2196bd45a5ee272b08b1d82cef29aaa89b61",
+    "sha256": "1jshzvsa2nnckakiybh6q7f0wdl5p04b6mymxvjzzphr0q32qn75"
+  },
+  "qtpurchasing": {
+    "url": "https://invent.kde.org/qt/qt/qtpurchasing.git",
+    "rev": "736144c5827385000e391e9a55a0f0162b7e8112",
+    "sha256": "1djvj4glxc360my597g81aqjmrhk46447x5s2jj81yiflppvkbny"
+  },
+  "qtquick3d": {
+    "url": "https://invent.kde.org/qt/qt/qtquick3d.git",
+    "rev": "f3c3c2041f4800a7fc1904771f5c6af036167dc9",
+    "sha256": "1xsxhx20spj50jmsqd5f2qa7kmr9rn08c22zkckhrgic73188dpg"
+  },
+  "qtquickcontrols": {
+    "url": "https://invent.kde.org/qt/qt/qtquickcontrols.git",
+    "rev": "dcc90558d9c0cba41eec7df290943994289b0e87",
+    "sha256": "0xccglsr1c519lyfg58hj6aa34zfyxc4zff360kd84yxmp8r4y9i"
+  },
+  "qtquickcontrols2": {
+    "url": "https://invent.kde.org/qt/qt/qtquickcontrols2.git",
+    "rev": "a2d56960dd76c94a5115b5415be5ee174d377718",
+    "sha256": "03wikwwf329wzml59hw0mqqzqjqfp95k8bvifi21zgrnjfl8rsrr"
+  },
+  "qtquicktimeline": {
+    "url": "https://invent.kde.org/qt/qt/qtquicktimeline.git",
+    "rev": "b1b4b882dabaa036c3fb73c4a879ba8efbb02ded",
+    "sha256": "07zaziin88y5cq9xy4dsfw2y7njs92qq00mg42350g1s6zqrlbv2"
+  },
+  "qtremoteobjects": {
+    "url": "https://invent.kde.org/qt/qt/qtremoteobjects.git",
+    "rev": "bdc316aca82769b43cb7821c10d80a1ca02b846e",
+    "sha256": "136izb42sdy42lr5amh343f97s59fwf3mv44dg5n8jwg0mg7s67b"
+  },
+  "qtscxml": {
+    "url": "https://invent.kde.org/qt/qt/qtscxml.git",
+    "rev": "e8727aabe55526956295407d27317ec15e12b283",
+    "sha256": "1gyas1prkvnmxlvb90s9qzpy1frk8c4b7n0wnjn0vkfp0cmv3w52"
+  },
+  "qtsensors": {
+    "url": "https://invent.kde.org/qt/qt/qtsensors.git",
+    "rev": "a41492b23cde20d1e00427d31e4637d06aea3638",
+    "sha256": "1p9w444bzgixw6a8qarznnr15ayn22k2limsi5mzqanf3j3bd3ml"
+  },
+  "qtserialbus": {
+    "url": "https://invent.kde.org/qt/qt/qtserialbus.git",
+    "rev": "c41785c9f36560722b917d373ee97eed8cc4089a",
+    "sha256": "05nvzh9lbkbsghpdb3q26nbxgdq5007xak8zxwd3cz9mhqy8xnyc"
+  },
+  "qtserialport": {
+    "url": "https://invent.kde.org/qt/qt/qtserialport.git",
+    "rev": "3380465d5d4977326616c5e57789a81681be650e",
+    "sha256": "06dzraplqhidkngl3sjb3sppqpvc8v8ahrjz06dnsh1dwj8hizh7"
+  },
+  "qtspeech": {
+    "url": "https://invent.kde.org/qt/qt/qtspeech.git",
+    "rev": "3b163bfd46d96bc9ee848dcee49e9cabe6699287",
+    "sha256": "03d4qvxfzwcfgbjdrpq0hvnhbz8bj6diphwiywdp16kvfmp13g9f"
+  },
+  "qtsvg": {
+    "url": "https://invent.kde.org/qt/qt/qtsvg.git",
+    "rev": "7d6e373c7db9c05ef586db0eb50c87cd894229ad",
+    "sha256": "1aw9xxfjhm14raj7nivrr1ljnqcmibbbjyrx4bawp58mqbq4as4x"
+  },
+  "qttools": {
+    "url": "https://invent.kde.org/qt/qt/qttools.git",
+    "rev": "38ae810be3fb4984f75b55a16d3413e35d701af1",
+    "sha256": "0hc65pidlp6lnb3srr2hg3dnas3hdj9cxkp7azcndj3wi36mclwf"
+  },
+  "qttranslations": {
+    "url": "https://invent.kde.org/qt/qt/qttranslations.git",
+    "rev": "56065158ffc4cd0fd78f9edf4b21b77b969f8dbb",
+    "sha256": "1lyh8hryi6hgw50gz9l6qxjfb72k4a7cg10vw18iffi7yv262g0z"
+  },
+  "qtvirtualkeyboard": {
+    "url": "https://invent.kde.org/qt/qt/qtvirtualkeyboard.git",
+    "rev": "817378aa10176fd26eed36542bc657e48d9dd42e",
+    "sha256": "0ihgm8y19zlkp3677rp9hnzm56y74djsnpr78yk0mrbcbxv1hpwb"
+  },
+  "qtwayland": {
+    "url": "https://invent.kde.org/qt/qt/qtwayland.git",
+    "rev": "4de268cbaf6ff3b633429577f06d3d746a3b202a",
+    "sha256": "1ris6yxd4igrjvjv7bnxkdr402lk1k0djalkbk5s4z8l4qpavn3y"
+  },
+  "qtwebchannel": {
+    "url": "https://invent.kde.org/qt/qt/qtwebchannel.git",
+    "rev": "f84887c1aee4ab04af375e639ae965c9ea2186a5",
+    "sha256": "0pn4ly4lyf0db9pfb80q45zssifjg3466hnw7ryxnm4331izvbja"
+  },
+  "qtwebglplugin": {
+    "url": "https://invent.kde.org/qt/qt/qtwebglplugin.git",
+    "rev": "ddcff45e8f2ca9f229017b3ded62327d2fb50af2",
+    "sha256": "1ybc94jidzqhrkm0v2daqq0nm34ydqpcgd8q4qhz9abi0ccj17s4"
+  },
+  "qtwebsockets": {
+    "url": "https://invent.kde.org/qt/qt/qtwebsockets.git",
+    "rev": "d41bb9f4f7ab9d5ff184ef94cf2f6ff7cf01de00",
+    "sha256": "0pc14sd1dzrw599kdjg1309l9hf9ylp0pnyv7i6s2pyfqqq0x85r"
+  },
+  "qtwebview": {
+    "url": "https://invent.kde.org/qt/qt/qtwebview.git",
+    "rev": "f078642eb9a440f6aa88f2beaf10f445de1e29bb",
+    "sha256": "0qak3y3qaxs6lf34y8rcp922sqd08nvag0lvl7znxm8d5b7qmnn6"
+  },
+  "qtwinextras": {
+    "url": "https://invent.kde.org/qt/qt/qtwinextras.git",
+    "rev": "1bf19cc6a7972d8543485786418b6631459d3469",
+    "sha256": "09a6xacb0zsp44w5zz15lkh6sypy7y1xg7m1fkxj2n26wbdc2p52"
+  },
+  "qtx11extras": {
+    "url": "https://invent.kde.org/qt/qt/qtx11extras.git",
+    "rev": "5fb2e067a38d3583684310130f5d8aad064f512f",
+    "sha256": "1whfsdmyihnzzy3ijh5wcbsw9ppg3s5nx2insw5yrx36iz0y054d"
+  },
+  "qtxmlpatterns": {
+    "url": "https://invent.kde.org/qt/qt/qtxmlpatterns.git",
+    "rev": "5a1948ddc05bf44017ac12bd5c2b9bc79fbcb9a2",
+    "sha256": "0613zb8lzd1i2g5kbn7h39warx7hn1z5qi28zk8l88ivpn84dx4q"
+  }
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs.nix b/nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs.nix
new file mode 100644
index 000000000000..130fcd332ba4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/5.15/srcs.nix
@@ -0,0 +1,94 @@
+{ lib, fetchgit, fetchFromGitHub }:
+
+let
+  version = "5.15.11";
+
+  mk = name: args:
+    {
+      inherit version;
+      src = fetchgit {
+        inherit (args) url rev sha256;
+        fetchLFS = false;
+        fetchSubmodules = true;
+        deepClone = false;
+        leaveDotGit = false;
+      };
+    };
+in
+lib.mapAttrs mk (lib.importJSON ./srcs-generated.json)
+// {
+  # qtpim has no official releases
+  qtpim = {
+    version = "unstable-2020-11-02";
+    src = fetchFromGitHub {
+      owner = "qt";
+      repo = "qtpim";
+      # Last commit before Qt5 support was broken
+      rev = "f9a8f0fc914c040d48bbd0ef52d7a68eea175a98";
+      hash = "sha256-/1g+vvHjuRLB1vsm41MrHbBZ+88Udca0iEcbz0Q1BNQ=";
+    };
+  };
+
+  # Has no kde/5.15 branch
+  qtpositioning = rec {
+    version = "5.15.2";
+    src = fetchFromGitHub {
+      owner = "qt";
+      repo = "qtpositioning";
+      rev = "v${version}";
+      hash = "sha256-L/P+yAQItm3taPpCNoOOm7PNdOFZiIwJJYflk6JDWvU=";
+    };
+  };
+
+  # qtwebkit does not have an official release tarball on the qt mirror and is
+  # mostly maintained by the community.
+  qtwebkit = rec {
+    src = fetchFromGitHub {
+      owner = "qt";
+      repo = "qtwebkit";
+      rev = "v${version}";
+      sha256 = "0x8rng96h19xirn7qkz3lydal6v4vn00bcl0s3brz36dfs0z8wpg";
+    };
+    version = "5.212.0-alpha4";
+  };
+
+  # qtsystems has no official releases
+  qtsystems = {
+    version = "unstable-2019-01-03";
+    src = fetchFromGitHub {
+      owner = "qt";
+      repo = "qtsystems";
+      rev = "e3332ee38d27a134cef6621fdaf36687af1b6f4a";
+      hash = "sha256-P8MJgWiDDBCYo+icbNva0LODy0W+bmQTS87ggacuMP0=";
+    };
+  };
+
+  catapult = fetchgit {
+    url = "https://chromium.googlesource.com/catapult";
+    rev = "5eedfe23148a234211ba477f76fc2ea2e8529189";
+    hash = "sha256-LPfBCEB5tJOljXpptsNk0sHGtJf/wIRL7fccN79Nh6o=";
+  };
+
+  qtscript = rec {
+    version = "5.15.15";
+
+    src = fetchFromGitHub {
+      owner = "qt";
+      repo = "qtscript";
+      rev = "v${version}-lts";
+      hash = "sha256-o2YG1m3LuG9Kq9Bqi1wRa6ceHsivK+hJR7w08NE/kBo=";
+    };
+  };
+
+  qtwebengine = rec {
+    version = "5.15.15";
+
+    src = fetchFromGitHub {
+      owner = "qt";
+      repo = "qtwebengine";
+      rev = "v${version}-lts";
+      hash = "sha256-AmW3u8D9Y8lXZu0aiuxYXNPzZ5GCXeBQGfAcgFuXAh4=";
+      fetchSubmodules = true;
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/README.md b/nixpkgs/pkgs/development/libraries/qt-5/README.md
new file mode 100644
index 000000000000..b2ef74d0aef1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/README.md
@@ -0,0 +1,81 @@
+# Qt 5 Maintainer's Notes
+
+## Minor Updates
+
+Let `$major` be the major version number, e.g. `5.9`.
+
+1. Change the version number in the `$major/fetch.sh`.
+2. Run `./maintainers/scripts/fetch-kde-qt.sh pkgs/development/libraries/qt-5/$major`
+   from the top of the Nixpkgs tree.
+
+See below if it is necessary to update any patches.
+
+## Major Updates
+
+Let `$major` be the new major version number, e.g. `5.10`.
+
+1. Copy the subdirectory from the previous major version to `$major`.
+2. Change the version number in `$major/fetch.sh`.
+3. Run `./maintainers/scripts/fetch-kde-qt.sh pkgs/development/libraries/qt-5/$major`
+   from the top of the Nixpkgs tree.
+4. Add a top-level attribute in `pkgs/top-level/all-packages.nix` for the new
+   major version.
+5. Change the `qt5` top-level attribute to point to the new major version.
+6. If the previous major version is _not_ a long-term support release,
+   remove it from Nixpkgs.
+
+See below if it is necessary to update any patches.
+
+## Patches
+
+Nixpkgs maintains several patches for Qt which cannot be submitted upstream. To
+facilitate maintenance, a fork of the upstream repository is created for each patched module:
+
+- [qtbase](https://github.com/ttuegel/qtbase)
+- [qtwebkit](https://github.com/ttuegel/qtwebkit)
+- [qttools](https://github.com/ttuegel/qttools)
+- [qtscript](https://github.com/ttuegel/qtscript)
+- [qtserialport](https://github.com/ttuegel/qtserialport)
+- [qtdeclarative](https://github.com/ttuegel/qtdeclarative)
+- [qtwebengine](https://github.com/ttuegel/qtwebengine)
+
+In each repository, the patches are contained in a branch named `nixpkgs/$major`
+for each major version. Please make a pull request to add or update any patch
+which will be maintained in Nixpkgs.
+
+The forked repository for each module is used to create a single patch in
+Nixpkgs. To recreate the patch for module `$module` (e.g. `qtbase`) at version
+`$version` (e.g. `5.9.1`) in the branch `$major` (e.g. `5.9`),
+
+1. Clone the fork for `$module` from the list above.
+2. Checkout the active branch, `git checkout nixpkgs/$major`.
+3. Compare the patched branch to the release tag,
+   `git diff v$version > $module.patch`.
+4. Copy `$module.patch` into the Nixpkgs tree.
+
+### Minor Version Updates
+
+To update module `$module` to version `$version` from an older version in the
+same branch `$major`,
+
+1. Clone the fork for `$module` from the list above.
+2. Checkout the active branch, `git checkout nixpkgs/$major`.
+3. Merge the new version into the active branch,
+   `git merge --no-ff v$version`.
+4. Fix any conflicts.
+5. Open a pull request for the changes.
+6. Follow the instructions above to recreate the module patch in Nixpkgs.
+
+### Major Version Updates
+
+To update module `$module` from `$oldversion` in branch `$oldmajor` to version
+`$version` in branch `$major`,
+
+1. Clone the fork for `$module` from the list above.
+2. Checkout a new branch for the new major version,
+   `git checkout -b nixpkgs/$major nixpkgs/$oldmajor`.
+3. Rebase the patches from `$oldversion` onto the new branch,
+   `git rebase v$oldversion --onto v$version`.
+4. Fix any conflicts.
+5. Open a pull request for the changes.
+6. Follow the instructions above to recreate the module patch in Nixpkgs.
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qmake-libtool.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qmake-libtool.sh
new file mode 100644
index 000000000000..6aaeda052d70
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qmake-libtool.sh
@@ -0,0 +1,25 @@
+# Fix libtool libraries generated by qmake.
+# qmake started inserting filenames of shared objects instead of the appropriate
+# linker flags. fixQmakeLibtool searches for broken libtool libraries and
+# replaces the filenames with the linker flags that should have been there.
+fixQmakeLibtool() {
+    if [ -d "$1" ]; then
+        find "$1" -name '*.la' | while read la; do
+            set +e
+            framework_libs=$(grep '^dependency_libs' "$la" | grep -Eo -- '-framework +\w+' | tr '\n' ' ')
+            set -e
+            sed -i "$la" \
+                -e '/^dependency_libs/ s,\(/[^ ]\+\)/lib\([^/ ]\+\)\.so,-L\1 -l\2,g' \
+                -e '/^dependency_libs/ s,-framework \+\w\+,,g'
+            if [ ! -z "$framework_libs" ]; then
+                if grep '^inherited_linker_flags=' $la >/dev/null; then
+                    sed -i "$la" -e "s/^\(inherited_linker_flags='[^']*\)/\1 $framework_libs/"
+                else
+                    echo "inherited_linker_flags='$framework_libs'" >> "$la"
+                fi
+            fi
+        done
+    fi
+}
+
+fixupOutputHooks+=('fixQmakeLibtool $prefix')
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh
new file mode 100644
index 000000000000..0f17856b4c7d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-builtin-paths.sh
@@ -0,0 +1,64 @@
+# fixQtBuiltinPaths
+#
+# Usage: fixQtBuiltinPaths _dir_ _pattern_
+#
+# Fix Qt builtin paths in files matching _pattern_ under _dir_.
+#
+fixQtBuiltinPaths() {
+    local dir="$1"
+    local pattern="$2"
+    local bin="${!outputBin}"
+    local dev="${!outputDev}"
+    local doc="${!outputDoc}"
+    local lib="${!outputLib}"
+
+    if [ -d "$dir" ]; then
+        find "$dir" -name "$pattern" | while read pr_; do
+            if grep -q '\$\$\[QT_' "${pr_:?}"; then
+                echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${pr_:?}'..."
+                sed -i "${pr_:?}" \
+                    -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|"'$$'"NIX_OUTPUT_DEV/bin|g" \
+                    -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$dev/mkspecs|g" \
+                    -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|"'$$'"NIX_OUTPUT_DEV|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$bin/bin|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$bin|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$doc/share/doc|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$doc/examples|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$dev/include|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$bin/$qtPluginPrefix|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|"'$$'"NIX_OUTPUT_LIB|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$dev/tests|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
+                    -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$bin/$qtQmlPrefix|g"
+            fi
+        done
+    elif [ -e "$dir" ]; then
+        if grep -q '\$\$\[QT_' "${dir:?}"; then
+            echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${dir:?}'..."
+            sed -i "${dir:?}" \
+                -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|"'$$'"NIX_OUTPUT_DEV/bin|g" \
+                -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$dev/mkspecs|g" \
+                -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|"'$$'"NIX_OUTPUT_DEV|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$bin/bin|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$bin|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$doc/share/doc|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$doc/examples|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$dev/include|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$bin/$qtPluginPrefix|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|"'$$'"NIX_OUTPUT_LIB|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$dev/tests|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
+                -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$bin/$qtQmlPrefix|g"
+        fi
+    else
+        echo "fixQtBuiltinPaths: Warning: \`$dir' does not exist"
+    fi
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh
new file mode 100644
index 000000000000..33682f6f3c69
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh
@@ -0,0 +1,36 @@
+# fixQtModulePaths
+#
+# Usage: fixQtModulePaths _dir_
+#
+# Find Qt module definitions in directory _dir_ and patch the module paths.
+#
+fixQtModulePaths () {
+    local dir="$1"
+    local bin="${!outputBin}"
+    local dev="${!outputDev}"
+    local lib="${!outputLib}"
+
+    if [ -d "$dir" ]; then
+        find "$dir" -name 'qt_*.pri' | while read pr; do
+            if grep -q '\$\$QT_MODULE_' "${pr:?}"; then
+                echo "fixQtModulePaths: Fixing module paths in \`${pr:?}'..."
+                sed -i "${pr:?}" \
+                    -e "s|\\\$\\\$QT_MODULE_LIB_BASE|$lib/lib|g" \
+                    -e "s|\\\$\\\$QT_MODULE_HOST_LIB_BASE|$lib/lib|g" \
+                    -e "s|\\\$\\\$QT_MODULE_INCLUDE_BASE|$dev/include|g" \
+                    -e "s|\\\$\\\$QT_MODULE_BIN_BASE|$dev/bin|g"
+            fi
+        done
+    elif [ -e "$dir" ]; then
+        echo "fixQtModulePaths: Warning: \`$dir' is not a directory"
+    else
+        echo "fixQtModulePaths: Warning: \`$dir' does not exist"
+    fi
+
+    if [ "z$bin" != "z$dev" ]; then
+        if [ -d "$bin/bin" ]; then
+            mkdir -p "$dev/bin"
+            lndir -silent "$bin/bin" "$dev/bin"
+        fi
+    fi
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh
new file mode 100644
index 000000000000..85489c85105b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/move-qt-dev-tools.sh
@@ -0,0 +1,34 @@
+updateToolPath() {
+    local tool="$1"
+    local target="$2"
+    local original="${!outputBin}/$tool"
+    local actual="${!outputDev}/$tool"
+    if grep -q "$original" "$target"; then
+        echo "updateToolPath: Updating \`$original' in \`$target\'..."
+        sed -i "$target" -e "s|$original|$actual|"
+    fi
+}
+
+moveQtDevTools() {
+    if [ -n "$devTools" ]; then
+        for tool in $devTools; do
+            moveToOutput "$tool" "${!outputDev}"
+        done
+
+        if [ -d "${!outputDev}/mkspecs" ]; then
+            find "${!outputDev}/mkspecs" -name '*.pr?' | while read pr_; do
+                for tool in $devTools; do
+                    updateToolPath "$tool" "$pr_"
+                done
+            done
+        fi
+
+        if [ -d "${!outputDev}/lib/cmake" ]; then
+            find "${!outputDev}/lib/cmake" -name '*.cmake' | while read cmake; do
+                for tool in $devTools; do
+                    updateToolPath "$tool" "$cmake"
+                done
+            done
+        fi
+    fi
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
new file mode 100644
index 000000000000..56607df6b4b9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh
@@ -0,0 +1,54 @@
+. @fix_qmake_libtool@
+
+qmakeFlags=( ${qmakeFlags-} )
+
+qmakePrePhase() {
+    qmakeFlags_orig=( "${qmakeFlags[@]}" )
+
+    # These flags must be added _before_ the flags specified in the derivation.
+    qmakeFlags=( \
+        "PREFIX=$out" \
+        "NIX_OUTPUT_OUT=$out" \
+        "NIX_OUTPUT_DEV=${!outputDev}" \
+        "NIX_OUTPUT_BIN=${!outputBin}" \
+        "NIX_OUTPUT_DOC=${!outputDev}/${qtDocPrefix:?}" \
+        "NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?}" \
+        "NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?}" \
+    )
+
+    if [ -n "@debug@" ]; then
+        qmakeFlags+=( "CONFIG+=debug" )
+    else
+        qmakeFlags+=( "CONFIG+=release" )
+    fi
+
+    # do the stripping ourselves (needed for separateDebugInfo)
+    qmakeFlags+=( "CONFIG+=nostrip" )
+
+    qmakeFlags+=( "${qmakeFlags_orig[@]}" )
+}
+prePhases+=" qmakePrePhase"
+
+qmakeConfigurePhase() {
+    runHook preConfigure
+
+    echo "QMAKEPATH=$QMAKEPATH"
+    echo qmake "${qmakeFlags[@]}"
+    qmake "${qmakeFlags[@]}"
+
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echo "qmake: enabled parallel building"
+    fi
+
+    if ! [[ -v enableParallelInstalling ]]; then
+        enableParallelInstalling=1
+        echo "qmake: enabled parallel installing"
+    fi
+
+    runHook postConfigure
+}
+
+if [ -z "${dontUseQmakeConfigure-}" -a -z "${configurePhase-}" ]; then
+    configurePhase=qmakeConfigurePhase
+fi
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
new file mode 100644
index 000000000000..1b57d676e1fc
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
@@ -0,0 +1,112 @@
+if [[ -n "${__nix_qtbase-}" ]]; then
+    # Throw an error if a different version of Qt was already set up.
+    if [[ "$__nix_qtbase" != "@dev@" ]]; then
+        echo >&2 "Error: detected mismatched Qt dependencies:"
+        echo >&2 "    @dev@"
+        echo >&2 "    $__nix_qtbase"
+        exit 1
+    fi
+else # Only set up Qt once.
+__nix_qtbase="@dev@"
+
+qtPluginPrefix=@qtPluginPrefix@
+qtQmlPrefix=@qtQmlPrefix@
+qtDocPrefix=@qtDocPrefix@
+
+. @fix_qt_builtin_paths@
+. @fix_qt_module_paths@
+
+# Disable debug symbols if qtbase was built without debugging.
+# This stops -dev paths from leaking into other outputs.
+if [ -z "@debug@" ]; then
+    NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
+fi
+
+# Integration with CMake:
+# Set the CMake build type corresponding to how qtbase was built.
+if [ -n "@debug@" ]; then
+    cmakeBuildType="Debug"
+else
+    cmakeBuildType="Release"
+fi
+
+providesQtRuntime() {
+    [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
+}
+
+# Build tools are often confused if QMAKE is unset.
+QMAKE=@dev@/bin/qmake
+export QMAKE
+
+QMAKEPATH=
+export QMAKEPATH
+
+QMAKEMODULES=
+export QMAKEMODULES
+
+declare -Ag qmakePathSeen=()
+qmakePathHook() {
+    # Skip this path if we have seen it before.
+    # MUST use 'if' because 'qmakePathSeen[$]' may be unset.
+    if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
+    qmakePathSeen[$1]=1
+    if [ -d "$1/mkspecs" ]
+    then
+        QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
+        QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
+    fi
+}
+envBuildHostHooks+=(qmakePathHook)
+
+# Propagate any runtime dependency of the building package.
+# Each dependency is propagated to the user environment and as a build
+# input so that it will be re-propagated to the user environment by any
+# package depending on the building package. (This is necessary in case
+# the building package does not provide runtime dependencies itself and so
+# would not be propagated to the user environment.)
+declare -Ag qtEnvHostTargetSeen=()
+qtEnvHostTargetHook() {
+    # Skip this path if we have seen it before.
+    # MUST use 'if' because 'qmakePathSeen[$]' may be unset.
+    if [ -n "${qtEnvHostTargetSeen[$1]-}" ]; then return; fi
+    qtEnvHostTargetSeen[$1]=1
+    if providesQtRuntime "$1" && [ "z${!outputBin}" != "z${!outputDev}" ]
+    then
+        propagatedBuildInputs+=" $1"
+    fi
+}
+envHostTargetHooks+=(qtEnvHostTargetHook)
+
+postPatchMkspecs() {
+    # Prevent this hook from running multiple times
+    dontPatchMkspecs=1
+
+    local bin="${!outputBin}"
+    local dev="${!outputDev}"
+    local doc="${!outputDoc}"
+    local lib="${!outputLib}"
+
+    moveToOutput "mkspecs" "$dev"
+
+    if [ -d "$dev/mkspecs/modules" ]; then
+        fixQtModulePaths "$dev/mkspecs/modules"
+    fi
+
+    if [ -d "$dev/mkspecs" ]; then
+        fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
+    fi
+}
+if [ -z "${dontPatchMkspecs-}" ]; then
+    postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
+fi
+
+qtPreHook() {
+    # Check that wrapQtAppsHook is used, or it is explicitly disabled.
+    if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
+        echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set."
+        exit 1
+    fi
+}
+prePhases+=" qtPreHook"
+
+fi
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh
new file mode 100644
index 000000000000..c320a7974471
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh
@@ -0,0 +1 @@
+qmakeFlags+=( "QMAKE_LRELEASE=@dev@/bin/lrelease" )
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh b/nixpkgs/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh
new file mode 100644
index 000000000000..2127be5e0a2a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh
@@ -0,0 +1,107 @@
+if [[ -z "${__nix_wrapQtAppsHook-}" ]]; then
+__nix_wrapQtAppsHook=1  # Don't run this hook more than once.
+
+# Inherit arguments given in mkDerivation
+qtWrapperArgs=( ${qtWrapperArgs-} )
+
+qtHostPathSeen=()
+
+qtUnseenHostPath() {
+    for pkg in "${qtHostPathSeen[@]}"
+    do
+        if [ "${pkg:?}" == "$1" ]
+        then
+            return 1
+        fi
+    done
+
+    qtHostPathSeen+=("$1")
+    return 0
+}
+
+qtHostPathHook() {
+    qtUnseenHostPath "$1" || return 0
+
+    local pluginDir="$1/${qtPluginPrefix:?}"
+    if [ -d "$pluginDir" ]
+    then
+        qtWrapperArgs+=(--prefix QT_PLUGIN_PATH : "$pluginDir")
+    fi
+
+    local qmlDir="$1/${qtQmlPrefix:?}"
+    if [ -d "$qmlDir" ]
+    then
+        qtWrapperArgs+=(--prefix QML2_IMPORT_PATH : "$qmlDir")
+    fi
+}
+addEnvHooks "$targetOffset" qtHostPathHook
+
+makeQtWrapper() {
+    local original="$1"
+    local wrapper="$2"
+    shift 2
+    makeWrapper "$original" "$wrapper" "${qtWrapperArgs[@]}" "$@"
+}
+
+wrapQtApp() {
+    local program="$1"
+    shift 1
+    wrapProgram "$program" "${qtWrapperArgs[@]}" "$@"
+}
+
+qtOwnPathsHook() {
+    local xdgDataDir="${!outputBin}/share"
+    if [ -d "$xdgDataDir" ]
+    then
+        qtWrapperArgs+=(--prefix XDG_DATA_DIRS : "$xdgDataDir")
+    fi
+
+    local xdgConfigDir="${!outputBin}/etc/xdg"
+    if [ -d "$xdgConfigDir" ]
+    then
+        qtWrapperArgs+=(--prefix XDG_CONFIG_DIRS : "$xdgConfigDir")
+    fi
+
+    qtHostPathHook "${!outputBin}"
+}
+
+preFixupPhases+=" qtOwnPathsHook"
+
+# Note: $qtWrapperArgs still gets defined even if ${dontWrapQtApps-} is set.
+wrapQtAppsHook() {
+    # skip this hook when requested
+    [ -z "${dontWrapQtApps-}" ] || return 0
+
+    # guard against running multiple times (e.g. due to propagation)
+    [ -z "$wrapQtAppsHookHasRun" ] || return 0
+    wrapQtAppsHookHasRun=1
+
+    local targetDirs=( "$prefix/bin" "$prefix/sbin" "$prefix/libexec" "$prefix/Applications" "$prefix/"*.app )
+    echo "wrapping Qt applications in ${targetDirs[@]}"
+
+    for targetDir in "${targetDirs[@]}"
+    do
+        [ -d "$targetDir" ] || continue
+
+        find "$targetDir" ! -type d -executable -print0 | while IFS= read -r -d '' file
+        do
+            isELF "$file" || isMachO "$file" || continue
+
+            if [ -f "$file" ]
+            then
+                echo "wrapping $file"
+                wrapQtApp "$file"
+            elif [ -h "$file" ]
+            then
+                target="$(readlink -e "$file")"
+                echo "wrapping $file -> $target"
+                rm "$file"
+                makeQtWrapper "$target" "$file"
+            fi
+        done
+    done
+}
+
+fixupOutputHooks+=(wrapQtAppsHook)
+
+fi
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/mkDerivation.nix b/nixpkgs/pkgs/development/libraries/qt-5/mkDerivation.nix
new file mode 100644
index 000000000000..a90e229e688d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/mkDerivation.nix
@@ -0,0 +1,15 @@
+{ wrapQtAppsHook }:
+
+mkDerivation:
+
+args:
+
+let
+  args_ = {
+
+    nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ wrapQtAppsHook ];
+
+  };
+in
+
+mkDerivation (args // args_)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qt3d.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qt3d.nix
new file mode 100644
index 000000000000..f394ff6627e0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qt3d.nix
@@ -0,0 +1,9 @@
+{ lib, stdenv, qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qt3d";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+  # error: use of undeclared identifier 'stat64'
+  env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) "-Dstat64=stat";
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtbase.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtbase.nix
new file mode 100644
index 000000000000..67e9bd5440d1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtbase.nix
@@ -0,0 +1,424 @@
+{ stdenv, lib
+, src, patches, version, qtCompatVersion
+
+, coreutils, bison, flex, gdb, gperf, lndir, perl, pkg-config, python3
+, which
+  # darwin support
+, libiconv, libobjc, xcbuild, AGL, AppKit, ApplicationServices, AVFoundation, Carbon, Cocoa, CoreAudio, CoreBluetooth
+, CoreLocation, CoreServices, DiskArbitration, Foundation, OpenGL, MetalKit, IOKit
+
+, dbus, fontconfig, freetype, glib, harfbuzz, icu, libdrm, libX11, libXcomposite
+, libXcursor, libXext, libXi, libXrender, libinput, libjpeg, libpng , libxcb
+, libxkbcommon, libxml2, libxslt, openssl, pcre2, sqlite, udev, xcbutil
+, xcbutilimage, xcbutilkeysyms, xcbutilrenderutil, xcbutilwm , zlib, at-spi2-core
+
+  # optional dependencies
+, cups ? null, postgresql ? null
+, withGtk3 ? false, dconf, gtk3
+, qttranslations ? null
+
+  # options
+, libGLSupported ? !stdenv.isDarwin
+, libGL
+  # qmake detection for libmysqlclient does not seem to work when cross compiling
+, mysqlSupport ? stdenv.hostPlatform == stdenv.buildPlatform
+, libmysqlclient
+, buildExamples ? false
+, buildTests ? false
+, debug ? false
+, developerBuild ? false
+, decryptSslTraffic ? false
+, testers
+, buildPackages
+}:
+
+let
+  debugSymbols = debug || developerBuild;
+  qtPlatformCross = plat: with plat;
+    if isLinux
+    then "linux-generic-g++"
+    else throw "Please add a qtPlatformCross entry for ${plat.config}";
+in
+
+stdenv.mkDerivation (finalAttrs: ({
+  pname = "qtbase";
+  inherit qtCompatVersion src version;
+  debug = debugSymbols;
+
+  propagatedBuildInputs = [
+    libxml2 libxslt openssl sqlite zlib
+
+    # Text rendering
+    harfbuzz icu
+
+    # Image formats
+    libjpeg libpng
+    pcre2
+  ] ++ (
+    if stdenv.isDarwin then [
+      # TODO: move to buildInputs, this should not be propagated.
+      AGL AppKit ApplicationServices AVFoundation Carbon Cocoa CoreAudio CoreBluetooth
+      CoreLocation CoreServices DiskArbitration Foundation OpenGL
+      libobjc libiconv MetalKit IOKit
+    ] else [
+      dbus glib udev
+
+      # Text rendering
+      fontconfig freetype
+
+      libdrm
+
+      # X11 libs
+      libX11 libXcomposite libXext libXi libXrender libxcb libxkbcommon xcbutil
+      xcbutilimage xcbutilkeysyms xcbutilrenderutil xcbutilwm
+    ] ++ lib.optional libGLSupported libGL
+  );
+
+  buildInputs = [ python3 at-spi2-core ]
+    ++ lib.optionals (!stdenv.isDarwin)
+    (
+      [ libinput ]
+      ++ lib.optional withGtk3 gtk3
+    )
+    ++ lib.optional developerBuild gdb
+    ++ lib.optional (cups != null) cups
+    ++ lib.optional (mysqlSupport) libmysqlclient
+    ++ lib.optional (postgresql != null) postgresql;
+
+  nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which ]
+    ++ lib.optionals stdenv.isDarwin [ xcbuild ];
+
+  } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+    # `qtbase` expects to find `cc` (with no prefix) in the
+    # `$PATH`, so the following is needed even if
+    # `stdenv.buildPlatform.canExecute stdenv.hostPlatform`
+    depsBuildBuild = [ buildPackages.stdenv.cc ];
+  } // {
+
+  propagatedNativeBuildInputs = [ lndir ];
+
+  # libQt5Core links calls CoreFoundation APIs that call into the system ICU. Binaries linked
+  # against it will crash during build unless they can access `/usr/share/icu/icudtXXl.dat`.
+  propagatedSandboxProfile = lib.optionalString stdenv.isDarwin ''
+    (allow file-read* (subpath "/usr/share/icu"))
+  '';
+
+  enableParallelBuilding = true;
+
+  outputs = [ "bin" "dev" "out" ];
+
+  inherit patches;
+
+  fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
+  fix_qt_module_paths = ../hooks/fix-qt-module-paths.sh;
+  preHook = ''
+    . "$fix_qt_builtin_paths"
+    . "$fix_qt_module_paths"
+    . ${../hooks/move-qt-dev-tools.sh}
+    . ${../hooks/fix-qmake-libtool.sh}
+  '';
+
+  postPatch = ''
+    for prf in qml_plugin.prf qt_plugin.prf qt_docs.prf qml_module.prf create_cmake.prf; do
+        substituteInPlace "mkspecs/features/$prf" \
+            --subst-var qtPluginPrefix \
+            --subst-var qtQmlPrefix \
+            --subst-var qtDocPrefix
+    done
+
+    substituteInPlace configure --replace /bin/pwd pwd
+    substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls
+    sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i mkspecs/*/*.conf
+
+    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
+
+    # https://bugs.gentoo.org/803470
+    sed -i 's/-lpthread/-pthread/' mkspecs/common/linux.conf src/corelib/configure.json
+
+    patchShebangs ./bin
+  '' + (
+    if stdenv.isDarwin then ''
+        sed -i \
+            -e 's|/usr/bin/xcode-select|xcode-select|' \
+            -e 's|/usr/bin/xcrun|xcrun|' \
+            -e 's|/usr/bin/xcodebuild|xcodebuild|' \
+            -e 's|QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`|QMAKE_CXX="clang++"\nQMAKE_CONF_COMPILER="clang++"|' \
+            ./configure
+            substituteInPlace ./mkspecs/common/mac.conf \
+                --replace "/System/Library/Frameworks/OpenGL.framework/" "${OpenGL}/Library/Frameworks/OpenGL.framework/" \
+                --replace "/System/Library/Frameworks/AGL.framework/" "${AGL}/Library/Frameworks/AGL.framework/"
+    '' else lib.optionalString libGLSupported ''
+      sed -i mkspecs/common/linux.conf \
+          -e "/^QMAKE_INCDIR_OPENGL/ s|$|${libGL.dev or libGL}/include|" \
+          -e "/^QMAKE_LIBDIR_OPENGL/ s|$|${libGL.out}/lib|"
+    '' + lib.optionalString (stdenv.hostPlatform.isx86_32 && stdenv.cc.isGNU) ''
+      sed -i mkspecs/common/gcc-base-unix.conf \
+          -e "/^QMAKE_LFLAGS_SHLIB/ s/-shared/-shared -static-libgcc/"
+    ''
+  );
+
+  qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins";
+  qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml";
+  qtDocPrefix = "share/doc/qt-${qtCompatVersion}";
+
+  setOutputFlags = false;
+  preConfigure = ''
+    export LD_LIBRARY_PATH="$PWD/lib:$PWD/plugins/platforms''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
+
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
+
+    # paralellize compilation of qtmake, which happens within ./configure
+    export MAKEFLAGS+=" -j$NIX_BUILD_CORES"
+
+    ./bin/syncqt.pl -version $version
+  '' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+    # QT's configure script will refuse to use pkg-config unless these two environment variables are set
+    export PKG_CONFIG_SYSROOT_DIR=/
+    export PKG_CONFIG_LIBDIR=${lib.getLib pkg-config}/lib
+    echo "QMAKE_LFLAGS=''${LDFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf
+    echo "QMAKE_CFLAGS=''${CFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf
+    echo "QMAKE_CXXFLAGS=''${CXXFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf
+  '';
+
+  postConfigure = ''
+    qmakeCacheInjectNixOutputs() {
+        local cache="$1/.qmake.stash"
+        echo "qmakeCacheInjectNixOutputs: $cache"
+        if ! [ -f "$cache" ]; then
+            echo >&2 "qmakeCacheInjectNixOutputs: WARNING: $cache does not exist"
+        fi
+        cat >>"$cache" <<EOF
+    NIX_OUTPUT_BIN = $bin
+    NIX_OUTPUT_DEV = $dev
+    NIX_OUTPUT_OUT = $out
+    NIX_OUTPUT_DOC = $dev/$qtDocPrefix
+    NIX_OUTPUT_QML = $bin/$qtQmlPrefix
+    NIX_OUTPUT_PLUGIN = $bin/$qtPluginPrefix
+    EOF
+    }
+
+    find . -name '.qmake.conf' | while read conf; do
+        qmakeCacheInjectNixOutputs "$(dirname $conf)"
+    done
+  '';
+
+  env = {
+    NIX_CFLAGS_COMPILE = toString ([
+      "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields
+    ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
+      "-Wno-warn=free-nonheap-object"
+      "-Wno-free-nonheap-object"
+      "-w"
+    ] ++ [
+      ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"''
+      ''-DLIBRESOLV_SO="${stdenv.cc.libc.out}/lib/libresolv"''
+      ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"''
+    ] ++ lib.optional libGLSupported ''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"''
+    ++ lib.optional stdenv.isLinux "-DUSE_X11"
+    ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-darwin") [
+      # ignore "is only available on macOS 10.12.2 or newer" in obj-c code
+      "-Wno-error=unguarded-availability"
+    ]
+    ++ lib.optionals withGtk3 [
+      ''-DNIXPKGS_QGTK3_XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}"''
+      ''-DNIXPKGS_QGTK3_GIO_EXTRA_MODULES="${dconf.lib}/lib/gio/modules"''
+    ] ++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC");
+  } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+    NIX_CFLAGS_COMPILE_FOR_BUILD = toString ([
+      "-Wno-warn=free-nonheap-object"
+      "-Wno-free-nonheap-object"
+      "-w"
+    ]);
+  };
+
+  prefixKey = "-prefix ";
+
+  # PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
+  # if dependency paths contain the string "pq", which can occur in the hash.
+  # To prevent these failures, we need to override PostgreSQL detection.
+  PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq";
+
+  } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+  configurePlatforms = [ ];
+  } // {
+  # TODO Remove obsolete and useless flags once the build will be totally mastered
+  configureFlags = [
+    "-plugindir $(out)/$(qtPluginPrefix)"
+    "-qmldir $(out)/$(qtQmlPrefix)"
+    "-docdir $(out)/$(qtDocPrefix)"
+
+    "-verbose"
+    "-confirm-license"
+    "-opensource"
+
+    "-release"
+    "-shared"
+    "-accessibility"
+    "-optimized-qmake"
+    # for separateDebugInfo
+    "-no-strip"
+    "-system-proxies"
+    "-pkg-config"
+
+    "-gui"
+    "-widgets"
+    "-opengl desktop"
+    "-icu"
+    "-L" "${icu.out}/lib"
+    "-I" "${icu.dev}/include"
+    "-pch"
+  ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "-device ${qtPlatformCross stdenv.hostPlatform}"
+    "-device-option CROSS_COMPILE=${stdenv.cc.targetPrefix}"
+  ]
+  ++ lib.optional debugSymbols "-debug"
+  ++ lib.optionals developerBuild [
+    "-developer-build"
+    "-no-warnings-are-errors"
+  ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
+    "-no-warnings-are-errors"
+  ] ++ (if (!stdenv.hostPlatform.isx86_64) then [
+    "-no-sse2"
+  ] else [
+    "-sse2"
+    "${lib.optionalString (!stdenv.hostPlatform.sse3Support)   "-no"}-sse3"
+    "${lib.optionalString (!stdenv.hostPlatform.ssse3Support)  "-no"}-ssse3"
+    "${lib.optionalString (!stdenv.hostPlatform.sse4_1Support) "-no"}-sse4.1"
+    "${lib.optionalString (!stdenv.hostPlatform.sse4_2Support) "-no"}-sse4.2"
+    "${lib.optionalString (!stdenv.hostPlatform.avxSupport)    "-no"}-avx"
+    "${lib.optionalString (!stdenv.hostPlatform.avx2Support)   "-no"}-avx2"
+    ]
+  ) ++ [
+    "-no-mips_dsp"
+    "-no-mips_dspr2"
+  ] ++ [
+    "-system-zlib"
+    "-L" "${zlib.out}/lib"
+    "-I" "${zlib.dev}/include"
+    "-system-libjpeg"
+    "-L" "${libjpeg.out}/lib"
+    "-I" "${libjpeg.dev}/include"
+    "-system-harfbuzz"
+    "-L" "${harfbuzz.out}/lib"
+    "-I" "${harfbuzz.dev}/include"
+    "-system-pcre"
+    "-openssl-linked"
+    "-L" "${lib.getLib openssl}/lib"
+    "-I" "${openssl.dev}/include"
+    "-system-sqlite"
+    ''-${if mysqlSupport then "plugin" else "no"}-sql-mysql''
+    ''-${if postgresql != null then "plugin" else "no"}-sql-psql''
+
+    "-make libs"
+    "-make tools"
+    ''-${lib.optionalString (!buildExamples) "no"}make examples''
+    ''-${lib.optionalString (!buildTests) "no"}make tests''
+  ]
+    ++ (
+      if stdenv.isDarwin then [
+      "-no-fontconfig"
+      "-qt-freetype"
+      "-qt-libpng"
+      "-no-framework"
+    ] else [
+      "-rpath"
+    ] ++ [
+      "-xcb"
+      "-qpa xcb"
+      "-L" "${libX11.out}/lib"
+      "-I" "${libX11.out}/include"
+      "-L" "${libXext.out}/lib"
+      "-I" "${libXext.out}/include"
+      "-L" "${libXrender.out}/lib"
+      "-I" "${libXrender.out}/include"
+
+      "-libinput"
+
+      ''-${lib.optionalString (cups == null) "no-"}cups''
+      "-dbus-linked"
+      "-glib"
+    ] ++ [
+      "-system-libpng"
+    ] ++ lib.optional withGtk3 "-gtk"
+      ++ [
+        "-inotify"
+    ] ++ lib.optionals (cups != null) [
+      "-L" "${cups.lib}/lib"
+      "-I" "${cups.dev}/include"
+    ] ++ lib.optionals (mysqlSupport) [
+      "-L" "${libmysqlclient}/lib"
+      "-I" "${libmysqlclient}/include"
+    ] ++ lib.optional (qttranslations != null) [
+      "-translationdir" "${qttranslations}/translations"
+    ]
+  );
+
+  # Move selected outputs.
+  postInstall = ''
+    moveToOutput "mkspecs" "$dev"
+  '';
+
+  devTools = [
+    "bin/fixqt4headers.pl"
+    "bin/moc"
+    "bin/qdbuscpp2xml"
+    "bin/qdbusxml2cpp"
+    "bin/qlalr"
+    "bin/qmake"
+    "bin/rcc"
+    "bin/syncqt.pl"
+    "bin/uic"
+  ];
+
+  postFixup = ''
+    # Don't retain build-time dependencies like gdb.
+    sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
+    fixQtModulePaths "''${!outputDev}/mkspecs/modules"
+    fixQtBuiltinPaths "''${!outputDev}" '*.pr?'
+
+    # Move development tools to $dev
+    moveQtDevTools
+    moveToOutput bin "$dev"
+
+    # fixup .pc file (where to find 'moc' etc.)
+    sed -i "$dev/lib/pkgconfig/Qt5Core.pc" \
+      -e "/^host_bins=/ c host_bins=$dev/bin"
+  '';
+
+  dontStrip = debugSymbols;
+
+  setupHook = ../hooks/qtbase-setup-hook.sh;
+
+  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
+
+  meta = with lib; {
+    homepage = "https://www.qt.io/";
+    description = "A cross-platform application framework for C++";
+    license = with licenses; [ fdl13Plus gpl2Plus lgpl21Plus lgpl3Plus ];
+    maintainers = with maintainers; [ qknight ttuegel periklis bkchr ];
+    pkgConfigModules = [
+      "Qt5Concurrent"
+      "Qt5Core"
+      "Qt5DBus"
+      "Qt5Gui"
+      "Qt5Network"
+      "Qt5OpenGL"
+      "Qt5OpenGLExtensions"
+      "Qt5PrintSupport"
+      #"Qt5Qml"
+      #"Qt5QmlModels"
+      #"Qt5Quick"
+      #"Qt5QuickTest"
+      #"Qt5QuickWidgets"
+      "Qt5Sql"
+      "Qt5Test"
+      "Qt5Widgets"
+      "Qt5Xml"
+    ];
+    platforms = platforms.unix;
+  };
+
+}))
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtcharts.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtcharts.nix
new file mode 100644
index 000000000000..75766649a404
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtcharts.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtcharts";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
new file mode 100644
index 000000000000..81efb4bee04b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
@@ -0,0 +1,13 @@
+{ qtModule, lib, stdenv, qtbase, qtdeclarative, bluez, IOBluetooth }:
+
+qtModule {
+  pname = "qtconnectivity";
+  buildInputs = lib.optional stdenv.isLinux bluez;
+  propagatedBuildInputs = [
+    qtbase
+    qtdeclarative
+  ] ++ lib.optionals stdenv.isDarwin [
+    IOBluetooth
+  ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdatavis3d.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdatavis3d.nix
new file mode 100644
index 000000000000..d79320ea139f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdatavis3d.nix
@@ -0,0 +1,9 @@
+{ lib, stdenv, qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtdatavis3d";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+  # error: use of undeclared identifier 'stat64'
+  env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) "-Dstat64=stat";
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix
new file mode 100644
index 000000000000..f4249b7f9505
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix
@@ -0,0 +1,26 @@
+{ lib
+, stdenv
+, qtModule, python3, qtbase, qtsvg }:
+
+qtModule {
+  pname = "qtdeclarative";
+  propagatedBuildInputs = [ qtbase qtsvg ];
+  nativeBuildInputs = [ python3 ];
+  outputs = [ "out" "dev" "bin" ];
+  preConfigure = ''
+    NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\""
+  '';
+  configureFlags = [ "-qml-debug" ];
+  devTools = [
+    "bin/qml"
+    "bin/qmlcachegen"
+    "bin/qmleasing"
+    "bin/qmlimportscanner"
+    "bin/qmllint"
+    "bin/qmlmin"
+    "bin/qmlplugindump"
+    "bin/qmlprofiler"
+    "bin/qmlscene"
+    "bin/qmltestrunner"
+  ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdoc.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdoc.nix
new file mode 100644
index 000000000000..93620e42667e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtdoc.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtdeclarative }:
+
+qtModule {
+  pname = "qtdoc";
+  propagatedBuildInputs = [ qtdeclarative ];
+  outputs = [ "out" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtgamepad.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtgamepad.nix
new file mode 100644
index 000000000000..398572673171
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtgamepad.nix
@@ -0,0 +1,10 @@
+{ lib, stdenv, qtModule, qtbase, qtdeclarative, GameController, pkg-config }:
+
+qtModule {
+  pname = "qtgamepad";
+  propagatedBuildInputs = [ qtbase qtdeclarative ]
+    ++ lib.optional stdenv.isDarwin GameController;
+  buildInputs = [ ];
+  nativeBuildInputs = [ pkg-config ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix
new file mode 100644
index 000000000000..2fe865492e36
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtdeclarative }:
+
+qtModule {
+  pname = "qtgraphicaleffects";
+  propagatedBuildInputs = [ qtdeclarative ];
+  outputs = [ "out" "dev" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtimageformats.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtimageformats.nix
new file mode 100644
index 000000000000..4775bb0b0383
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtimageformats.nix
@@ -0,0 +1,20 @@
+{ lib
+, stdenv
+, qtModule
+, qtbase
+, libwebp
+, jasper
+, libmng
+, libtiff
+}:
+
+qtModule {
+  pname = "qtimageformats";
+  propagatedBuildInputs = [
+    qtbase libwebp
+  ] ++ lib.optionals (!jasper.meta.broken) [
+    jasper
+  ] ++ [
+    libmng libtiff
+  ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtlocation.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtlocation.nix
new file mode 100644
index 000000000000..a9897648d8e6
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtlocation.nix
@@ -0,0 +1,13 @@
+{ lib, stdenv, qtModule, qtbase, qtmultimedia }:
+
+qtModule {
+  pname = "qtlocation";
+  propagatedBuildInputs = [ qtbase qtmultimedia ];
+  outputs = [ "bin" "out" "dev" ];
+  qmakeFlags = lib.optionals stdenv.isDarwin [
+     # boost uses std::auto_ptr which has been disabled in clang with libcxx
+     # This flag re-enables this feature
+     # https://libcxx.llvm.org/docs/UsingLibcxx.html#c-17-specific-configuration-macros
+     "QMAKE_CXXFLAGS+=-D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR"
+  ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtlottie.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtlottie.nix
new file mode 100644
index 000000000000..4231fcb26b1c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtlottie.nix
@@ -0,0 +1,9 @@
+{ qtModule
+, qtbase
+, qtdeclarative
+}:
+
+qtModule {
+  pname = "qtlottie";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtmacextras.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
new file mode 100644
index 000000000000..da0f5f760bf7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtmacextras.nix
@@ -0,0 +1,10 @@
+{ lib, qtModule, qtbase }:
+
+qtModule {
+  pname = "qtmacextras";
+  propagatedBuildInputs = [ qtbase ];
+  meta = with lib; {
+    maintainers = with maintainers; [ periklis ];
+    platforms = platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix
new file mode 100644
index 000000000000..d5dc16c52823
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix
@@ -0,0 +1,24 @@
+{ qtModule
+, lib
+, stdenv
+, qtbase
+, qtdeclarative
+, pkg-config
+, alsa-lib
+, gstreamer
+, gst-plugins-base
+, libpulseaudio
+, wayland
+}:
+
+qtModule {
+  pname = "qtmultimedia";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ gstreamer gst-plugins-base ]
+    # https://github.com/NixOS/nixpkgs/pull/169336 regarding libpulseaudio
+    ++ lib.optionals stdenv.isLinux [ libpulseaudio alsa-lib wayland ];
+  outputs = [ "bin" "dev" "out" ];
+  qmakeFlags = [ "GST_VERSION=1.0" ];
+  NIX_LDFLAGS = lib.optionalString (stdenv.isDarwin) "-lobjc";
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtnetworkauth.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtnetworkauth.nix
new file mode 100644
index 000000000000..bec5f354a23a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtnetworkauth.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase }:
+
+qtModule {
+  pname = "qtnetworkauth";
+  propagatedBuildInputs = [ qtbase ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtpim.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtpim.nix
new file mode 100644
index 000000000000..01692d9f2ec3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtpim.nix
@@ -0,0 +1,27 @@
+{ qtModule
+, lib
+, qtbase
+, qtdeclarative
+}:
+
+qtModule {
+  pname = "qtpim";
+
+  outputs = [
+    "out"
+    "dev"
+  ];
+
+  propagatedBuildInputs = [
+    qtbase
+    qtdeclarative
+  ];
+
+  qmakeFlags = [
+    "CONFIG+=git_build"
+  ];
+
+  meta = {
+    maintainers = with lib.maintainers; [ OPNA2608 ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtpositioning.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtpositioning.nix
new file mode 100644
index 000000000000..20f059976323
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtpositioning.nix
@@ -0,0 +1,14 @@
+{ qtModule
+, qtbase
+, qtdeclarative
+, qtserialport
+, pkg-config
+, openssl
+}:
+
+qtModule {
+  pname = "qtpositioning";
+  propagatedBuildInputs = [ qtbase qtdeclarative qtserialport ];
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ openssl ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix
new file mode 100644
index 000000000000..3b78a2a6c87e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtdeclarative }:
+
+qtModule {
+  pname = "qtquickcontrols";
+  propagatedBuildInputs = [ qtdeclarative ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix
new file mode 100644
index 000000000000..59070629ddc7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtdeclarative }:
+
+qtModule {
+  pname = "qtquickcontrols2";
+  propagatedBuildInputs = [ qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtremoteobjects.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtremoteobjects.nix
new file mode 100644
index 000000000000..fde78848c854
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtremoteobjects.nix
@@ -0,0 +1,8 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtremoteobjects";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  # cycle is detected in build when adding "dev" "bin" too
+  outputs = [ "out" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtscript.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtscript.nix
new file mode 100644
index 000000000000..07993b72a6d3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtscript.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase, qttools }:
+
+qtModule {
+  pname = "qtscript";
+  propagatedBuildInputs = [ qtbase qttools ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtscxml.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtscxml.nix
new file mode 100644
index 000000000000..3314934db2ff
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtscxml.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtscxml";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsensors.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsensors.nix
new file mode 100644
index 000000000000..fdea92035b90
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsensors.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtsensors";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialbus.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialbus.nix
new file mode 100644
index 000000000000..3a7285d0a8b0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialbus.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase, qtserialport }:
+
+qtModule {
+  pname = "qtserialbus";
+  propagatedBuildInputs = [ qtbase qtserialport ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialport.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialport.nix
new file mode 100644
index 000000000000..7907f91b986b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtserialport.nix
@@ -0,0 +1,7 @@
+{ qtModule, stdenv, lib, qtbase, systemd }:
+
+qtModule {
+  pname = "qtserialport";
+  propagatedBuildInputs = [ qtbase ];
+  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isLinux "-DNIXPKGS_LIBUDEV=\"${lib.getLib systemd}/lib/libudev\"";
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtspeech.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtspeech.nix
new file mode 100644
index 000000000000..94e66cf40044
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtspeech.nix
@@ -0,0 +1,9 @@
+{ lib, qtModule, stdenv, speechd, pkg-config }:
+
+qtModule {
+  pname = "qtspeech";
+  propagatedBuildInputs = [ ];
+  buildInputs = lib.optionals stdenv.isLinux [ speechd ];
+  nativeBuildInputs = [ pkg-config ];
+  outputs = [ "out" "dev" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsvg.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsvg.nix
new file mode 100644
index 000000000000..418c69fb2ebf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsvg.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase }:
+
+qtModule {
+  pname = "qtsvg";
+  propagatedBuildInputs = [ qtbase ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsystems.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsystems.nix
new file mode 100644
index 000000000000..921172c2856b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtsystems.nix
@@ -0,0 +1,54 @@
+{ qtModule
+, stdenv
+, lib
+, bluez
+, libevdev
+, libX11
+, pkg-config
+, qtbase
+, udev
+, wrapQtAppsHook
+}:
+
+qtModule {
+  pname = "qtsystems";
+
+  outputs = [
+    "out"
+    "dev"
+  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
+    "bin"
+  ];
+
+  propagatedBuildInputs = [
+    qtbase
+  ];
+
+  nativeBuildInputs = [
+    pkg-config
+    wrapQtAppsHook
+  ];
+
+  buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
+    bluez
+    libevdev
+    libX11
+    udev
+  ];
+
+  qmakeFlags = [
+    "CONFIG+=git_build"
+  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
+    "CONFIG+=ofono"
+    "CONFIG+=udisks"
+    "CONFIG+=upower"
+  ];
+
+  postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
+    wrapQtApp $bin/bin/servicefw
+  '';
+
+  meta = {
+    maintainers = with lib.maintainers; [ OPNA2608 ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qttools.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qttools.nix
new file mode 100644
index 000000000000..37e4348ed2c2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qttools.nix
@@ -0,0 +1,42 @@
+{ qtModule, stdenv, lib, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qttools";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+
+  # fixQtBuiltinPaths overwrites a builtin path we should keep
+  postPatch = ''
+    sed -i "src/linguist/linguist.pro" \
+        -e '/^cmake_linguist_config_version_file.input =/ s|$$\[QT_HOST_DATA.*\]|${lib.getDev qtbase}|'
+    sed -i "src/qtattributionsscanner/qtattributionsscanner.pro" \
+        -e '/^cmake_qattributionsscanner_config_version_file.input =/ s|$$\[QT_HOST_DATA.*\]|${lib.getDev qtbase}|'
+  '';
+
+  devTools = [
+    "bin/qcollectiongenerator"
+    "bin/linguist"
+    "bin/assistant"
+    "bin/qdoc"
+    "bin/lconvert"
+    "bin/designer"
+    "bin/qtattributionsscanner"
+    "bin/lrelease"
+    "bin/lrelease-pro"
+    "bin/pixeltool"
+    "bin/lupdate"
+    "bin/lupdate-pro"
+    "bin/qtdiag"
+    "bin/qhelpgenerator"
+    "bin/qtplugininfo"
+    "bin/qthelpconverter"
+    "bin/lprodump"
+    "bin/qdistancefieldgenerator"
+  ] ++ lib.optionals stdenv.isDarwin [
+    "bin/macdeployqt"
+  ];
+
+  env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && qtdeclarative != null) ''-DNIXPKGS_QMLIMPORTSCANNER="${qtdeclarative.dev}/bin/qmlimportscanner"'';
+
+  setupHook = ../hooks/qttools-setup-hook.sh;
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qttranslations.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qttranslations.nix
new file mode 100644
index 000000000000..bcd52cdc4a8f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qttranslations.nix
@@ -0,0 +1,7 @@
+{ qtModule, qttools }:
+
+qtModule {
+  pname = "qttranslations";
+  nativeBuildInputs = [ qttools ];
+  outputs = [ "out" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix
new file mode 100644
index 000000000000..0bfc242d15b8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtvirtualkeyboard.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase, qtdeclarative, qtsvg, hunspell  }:
+
+qtModule {
+  pname = "qtvirtualkeyboard";
+  propagatedBuildInputs = [ qtbase qtdeclarative qtsvg hunspell ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland-app_id.patch b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland-app_id.patch
new file mode 100644
index 000000000000..24d081aa602b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland-app_id.patch
@@ -0,0 +1,36 @@
+Ensure that the correct `app_id` for Wayland is set. The upstream implementation
+uses `QFileInfo::baseName()`[1] which strips everything away after the first dot.
+This means that `.foo-wrapped` has an empty `app_id` because `baseName` returns
+an empty string in this case.
+
+The patch basically checks whether the program has the form `.foo-wrapped` (i.e. got
+wrapped by `makeWrapper`) and if that's the case, `foo` will be the correct `app_id`.
+
+[1] https://doc.qt.io/qt-5/qfileinfo.html#baseName
+
+diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
+index ba881cb..b3fd031 100644
+--- a/src/client/qwaylandwindow.cpp
++++ b/src/client/qwaylandwindow.cpp
+@@ -167,7 +167,20 @@ void QWaylandWindow::initWindow()
+                                                                                  Qt::SkipEmptyParts);
+ 
+                 if (domainName.isEmpty()) {
+-                    mShellSurface->setAppId(fi.baseName());
++                    auto baseName = fi.baseName();
++                    if (baseName.isEmpty()) {
++                        auto fileName = fi.fileName();
++                        if (fileName.endsWith("-wrapped") && fileName.startsWith(".")) {
++                            do {
++                                auto len = fileName.length();
++                                fileName = fileName.right(len - 1);
++                                fileName = fileName.left(len - 9);
++                            } while (fileName.endsWith("-wrapped") && fileName.startsWith("."));
++                            mShellSurface->setAppId(fileName);
++                        }
++                    } else {
++                        mShellSurface->setAppId(baseName);
++                    }
+                 } else {
+                     QString appId;
+                     for (int i = 0; i < domainName.count(); ++i)
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland.nix
new file mode 100644
index 000000000000..347a5cf64342
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwayland.nix
@@ -0,0 +1,15 @@
+{ qtModule, qtbase, qtquickcontrols, wayland, wayland-scanner, pkg-config }:
+
+qtModule {
+  pname = "qtwayland";
+  propagatedBuildInputs = [ qtbase qtquickcontrols ];
+  buildInputs = [ wayland ];
+  nativeBuildInputs = [ pkg-config wayland-scanner ];
+  outputs = [ "out" "dev" "bin" ];
+  patches = [
+    # NixOS-specific, ensure that app_id is correctly determined for
+    # wrapped executables from `wrapQtAppsHook` (see comment in patch for further
+    # context).
+    ./qtwayland-app_id.patch
+  ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix
new file mode 100644
index 000000000000..e7d6be534409
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix
@@ -0,0 +1,12 @@
+{ lib
+, stdenv
+, qtModule
+, qtbase
+, qtdeclarative
+}:
+
+qtModule {
+  pname = "qtwebchannel";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" ] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
new file mode 100644
index 000000000000..3503067aca75
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebengine.nix
@@ -0,0 +1,327 @@
+{ qtModule
+, qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel
+
+, bison, flex, git, gperf, ninja, pkg-config, python, which, python3
+, nodejs, qtbase, perl
+, buildPackages
+, pkgsBuildTarget
+, pkgsBuildBuild
+
+, xorg, libXcursor, libXScrnSaver, libXrandr, libXtst
+, fontconfig, freetype, harfbuzz, icu, dbus, libdrm
+, zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus
+, jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent
+, alsa-lib
+, pulseaudio
+, libcap
+, pciutils
+, systemd
+, enableProprietaryCodecs ? true
+, gn
+, cctools, libobjc, libpm, libunwind, sandbox, xnu
+, ApplicationServices, AVFoundation, Foundation, ForceFeedback, GameController, AppKit
+, ImageCaptureCore, CoreBluetooth, IOBluetooth, CoreWLAN, Quartz, Cocoa, LocalAuthentication
+, MediaPlayer, MediaAccessibility, SecurityInterface, Vision, CoreML, OpenDirectory, Accelerate
+, cups, openbsm, runCommand, xcbuild, writeScriptBin
+, ffmpeg_4 ? null
+, lib, stdenv, fetchpatch
+, version ? null
+, qtCompatVersion
+, pipewireSupport ? stdenv.isLinux
+, pipewire_0_2
+, postPatch ? ""
+, nspr
+, lndir
+, dbusSupport ? !stdenv.isDarwin, expat
+}:
+
+let
+  # qtwebengine expects to find an executable in $PATH which runs on
+  # the build platform yet knows about the host `.pc` files.  Most
+  # configury allows setting $PKG_CONFIG to point to an
+  # arbitrarily-named script which serves this purpose; however QT
+  # insists that it is named `pkg-config` with no target prefix.  So
+  # we re-wrap the host platform's pkg-config.
+  pkg-config-wrapped-without-prefix = stdenv.mkDerivation {
+    name = "pkg-config-wrapper-without-target-prefix";
+    dontUnpack = true;
+    dontBuild = true;
+    installPhase = ''
+      mkdir -p $out/bin
+      ln -s '${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' $out/bin/pkg-config
+    '';
+  };
+
+  qtPlatformCross = plat: with plat;
+    if isLinux
+    then "linux-generic-g++"
+    else throw "Please add a qtPlatformCross entry for ${plat.config}";
+
+in
+
+qtModule ({
+  pname = "qtwebengine";
+  nativeBuildInputs = [
+    bison flex git gperf ninja pkg-config python which gn nodejs
+  ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
+    perl
+    lndir (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtbase)
+    pkgsBuildBuild.pkg-config
+    (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols)
+    pkg-config-wrapped-without-prefix
+  ] ++ lib.optional stdenv.isDarwin xcbuild;
+  doCheck = true;
+  outputs = [ "bin" "dev" "out" ];
+
+  enableParallelBuilding = true;
+
+  # Don’t use the gn setup hook
+  dontUseGnConfigure = true;
+
+  # ninja builds some components with -Wno-format,
+  # which cannot be set at the same time as -Wformat-security
+  hardeningDisable = [ "format" ];
+
+  postPatch = ''
+    # Patch Chromium build tools
+    (
+      cd src/3rdparty/chromium;
+
+      # Manually fix unsupported shebangs
+      substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
+        --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" || true
+
+      # TODO: be more precise
+      patchShebangs .
+
+      # Fix compatibility with python3.11
+      substituteInPlace tools/metrics/ukm/ukm_model.py \
+        --replace "r'^(?i)(|true|false)$'" "r'(?i)^(|true|false)$'"
+      substituteInPlace tools/grit/grit/util.py \
+        --replace "mode = 'rU'" "mode = 'r'"
+    )
+  ''
+  # Prevent Chromium build script from making the path to `clang` relative to
+  # the build directory.  `clang_base_path` is the value of `QMAKE_CLANG_DIR`
+  # from `src/core/config/mac_osx.pri`.
+  + lib.optionalString stdenv.isDarwin ''
+    substituteInPlace ./src/3rdparty/chromium/build/toolchain/mac/BUILD.gn \
+      --replace 'prefix = rebase_path("$clang_base_path/bin/", root_build_dir)' 'prefix = "$clang_base_path/bin/"'
+  ''
+  # Patch library paths in Qt sources
+  + ''
+    sed -i \
+      -e "s,QLibraryInfo::location(QLibraryInfo::DataPath),QLatin1String(\"$out\"),g" \
+      -e "s,QLibraryInfo::location(QLibraryInfo::TranslationsPath),QLatin1String(\"$out/translations\"),g" \
+      -e "s,QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath),QLatin1String(\"$out/libexec\"),g" \
+      src/core/web_engine_library_info.cpp
+  ''
+  # Patch library paths in Chromium sources
+  + lib.optionalString (!stdenv.isDarwin) ''
+    sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
+      src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
+
+    sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
+      src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
+  '' + lib.optionalString stdenv.isDarwin (''
+    substituteInPlace src/buildtools/config/mac_osx.pri \
+      --replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'
+
+    # Following is required to prevent a build error:
+    # ninja: error: '/nix/store/z8z04p0ph48w22rqzx7ql67gy8cyvidi-SDKs/MacOSX10.12.sdk/usr/include/mach/exc.defs', needed by 'gen/third_party/crashpad/crashpad/util/mach/excUser.c', missing and no known rule to make it
+    substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
+      --replace '$sysroot/usr' "${xnu}"
+
+    # Apple has some secret stuff they don't share with OpenBSM
+    substituteInPlace src/3rdparty/chromium/base/mac/mach_port_rendezvous.cc \
+      --replace "audit_token_to_pid(request.trailer.msgh_audit)" "request.trailer.msgh_audit.val[5]"
+    substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/mach/mach_message.cc \
+      --replace "audit_token_to_pid(audit_trailer->msgh_audit)" "audit_trailer->msgh_audit.val[5]"
+
+    # ld: warning: directory not found for option '-L/nix/store/...-xcodebuild-0.1.2-pre/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib'
+    # ld: fatal warning(s) induced error (-fatal_warnings)
+    substituteInPlace src/3rdparty/chromium/build/config/compiler/BUILD.gn \
+      --replace "-Wl,-fatal_warnings" ""
+  '') + postPatch;
+
+  env = {
+    NIX_CFLAGS_COMPILE =
+      toString (
+        lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
+          "-w "
+        ] ++ lib.optionals stdenv.cc.isGNU [
+          # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit
+          "-Wno-class-memaccess"
+        ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [
+          # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
+          # TODO: investigate and fix properly
+          "-march=westmere"
+        ] ++ lib.optionals stdenv.cc.isClang [
+          "-Wno-elaborated-enum-base"
+        ]);
+  } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+    NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch";
+    "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch";
+  };
+
+  preConfigure = ''
+    export NINJAFLAGS=-j$NIX_BUILD_CORES
+
+    if [ -d "$PWD/tools/qmake" ]; then
+        QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH"
+    fi
+  '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
+    export QMAKE_CC=$CC
+    export QMAKE_CXX=$CXX
+    export QMAKE_LINK=$CXX
+    export QMAKE_AR=$AR
+  '';
+
+  qmakeFlags = [ "--" "-system-ffmpeg" ]
+    ++ lib.optional (pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform) "-webengine-webrtc-pipewire"
+    ++ lib.optional enableProprietaryCodecs "-proprietary-codecs";
+
+  propagatedBuildInputs = [
+    qtdeclarative qtquickcontrols qtlocation qtwebchannel
+
+    # Image formats
+    libjpeg libpng libtiff libwebp
+
+    # Video formats
+    srtp libvpx
+
+    # Audio formats
+    libopus
+
+    # Text rendering
+    harfbuzz icu
+
+    libevent
+    ffmpeg_4
+  ] ++ lib.optionals (!stdenv.isDarwin) [
+    dbus zlib minizip snappy nss protobuf jsoncpp
+
+    # Audio formats
+    alsa-lib
+    pulseaudio
+
+    # Text rendering
+    fontconfig freetype
+
+    libcap
+    pciutils
+
+    # X11 libs
+    xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst
+    xorg.libXcomposite xorg.libXdamage libdrm xorg.libxkbfile
+
+  ] ++ lib.optionals pipewireSupport [
+    # Pipewire
+    pipewire_0_2
+  ]
+
+  # FIXME These dependencies shouldn't be needed but can't find a way
+  # around it. Chromium pulls this in while bootstrapping GN.
+  ++ lib.optionals stdenv.isDarwin [
+    libobjc
+    cctools
+
+    # frameworks
+    ApplicationServices
+    AVFoundation
+    Foundation
+    ForceFeedback
+    GameController
+    AppKit
+    ImageCaptureCore
+    CoreBluetooth
+    IOBluetooth
+    CoreWLAN
+    Quartz
+    Cocoa
+    LocalAuthentication
+    MediaPlayer
+    MediaAccessibility
+    SecurityInterface
+    Vision
+    CoreML
+    OpenDirectory
+    Accelerate
+
+    openbsm
+    libunwind
+  ];
+
+  buildInputs = lib.optionals stdenv.isDarwin [
+    cups
+    libpm
+    sandbox
+
+    # `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py`
+    # to get some information about the host platform.
+    (writeScriptBin "sw_vers" ''
+      #!${stdenv.shell}
+
+      while [ $# -gt 0 ]; do
+        case "$1" in
+          -buildVersion) echo "17E199";;
+        *) break ;;
+
+        esac
+        shift
+      done
+    '')
+  ];
+
+  dontUseNinjaBuild = true;
+  dontUseNinjaInstall = true;
+
+  postInstall = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
+    mkdir -p $out/libexec
+  '' + lib.optionalString stdenv.isLinux ''
+    cat > $out/libexec/qt.conf <<EOF
+    [Paths]
+    Prefix = ..
+    EOF
+
+  '' + ''
+    # Fix for out-of-sync QtWebEngine and Qt releases (since 5.15.3)
+    sed 's/${lib.head (lib.splitString "-" version)} /${qtCompatVersion} /' -i "$out"/lib/cmake/*/*Config.cmake
+  '';
+
+  requiredSystemFeatures = [ "big-parallel" ];
+
+  meta = with lib; {
+    description = "A web engine based on the Chromium web browser";
+    maintainers = with maintainers; [ matthewbauer ];
+
+    # qtwebengine-5.15.8: "QtWebEngine can only be built for x86,
+    # x86-64, ARM, Aarch64, and MIPSel architectures."
+    platforms = with lib.systems.inspect.patterns;
+      let inherit (lib.systems.inspect) patternLogicalAnd;
+      in concatMap (patternLogicalAnd isUnix) (lib.concatMap lib.toList [
+        isx86_32
+        isx86_64
+        isAarch32
+        isAarch64
+        (patternLogicalAnd isMips isLittleEndian)
+      ]);
+
+    # This build takes a long time; particularly on slow architectures
+    timeout = 24 * 3600;
+  };
+
+} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+  configurePlatforms = [ ];
+  # to get progress output in `nix-build` and `nix build -L`
+  preBuild = ''
+    export TERM=dumb
+  '';
+  depsBuildBuild = [
+    pkgsBuildBuild.stdenv
+    zlib
+    nss
+    nspr
+  ];
+
+})
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebglplugin.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebglplugin.nix
new file mode 100644
index 000000000000..b2d93300a664
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebglplugin.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase, qtwebsockets }:
+
+qtModule {
+  pname = "qtwebglplugin";
+  propagatedBuildInputs = [ qtbase qtwebsockets ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebkit.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
new file mode 100644
index 000000000000..9c5d347d110b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebkit.nix
@@ -0,0 +1,63 @@
+{ qtModule, stdenv, lib, fetchurl
+, qtbase, qtdeclarative, qtlocation, qtmultimedia, qtsensors, qtwebchannel
+, fontconfig, libwebp, libxml2, libxslt
+, sqlite, systemd, glib, gst_all_1, cmake
+, bison, flex, gdb, gperf, perl, pkg-config, python38, ruby
+, ICU, OpenGL
+}:
+
+let
+  hyphen = stdenv.mkDerivation rec {
+    pname = "hyphen";
+    version = "2.8.8";
+    src = fetchurl {
+      url = "http://dev-www.libreoffice.org/src/5ade6ae2a99bc1e9e57031ca88d36dad-hyphen-${version}.tar.gz";
+      sha256 = "304636d4eccd81a14b6914d07b84c79ebb815288c76fe027b9ebff6ff24d5705";
+    };
+    postPatch = ''
+      patchShebangs tests
+    '';
+    buildInputs = [ perl ];
+  };
+in
+qtModule {
+  pname = "qtwebkit";
+  propagatedBuildInputs = [ qtbase qtdeclarative qtlocation qtsensors qtwebchannel ]
+    ++ lib.optional stdenv.isDarwin qtmultimedia;
+  buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base hyphen ]
+    ++ lib.optionals stdenv.isDarwin [ ICU OpenGL ];
+  nativeBuildInputs = [ bison flex gdb gperf perl pkg-config python38 ruby cmake ];
+
+  cmakeFlags = [ "-DPORT=Qt" ]
+    ++ lib.optionals stdenv.isDarwin [
+      "-DQt5Multimedia_DIR=${lib.getDev qtmultimedia}/lib/cmake/Qt5Multimedia"
+      "-DQt5MultimediaWidgets_DIR=${lib.getDev qtmultimedia}/lib/cmake/Qt5MultimediaWidgets"
+      "-DMACOS_FORCE_SYSTEM_XML_LIBRARIES=OFF"
+    ];
+
+  env.NIX_CFLAGS_COMPILE = toString ([
+    # with gcc7 this warning blows the log over Hydra's limit
+    "-Wno-expansion-to-defined"
+  ]
+  # with gcc8, -Wclass-memaccess became part of -Wall and this too exceeds the logging limit
+  ++ lib.optional stdenv.cc.isGNU "-Wno-class-memaccess"
+  # with clang this warning blows the log over Hydra's limit
+  ++ lib.optional stdenv.isDarwin "-Wno-inconsistent-missing-override"
+  ++ lib.optional (!stdenv.isDarwin) ''-DNIXPKGS_LIBUDEV="${lib.getLib systemd}/lib/libudev"'');
+
+  doCheck = false; # fails 13 out of 13 tests (ctest)
+
+  # remove forbidden references to $TMPDIR
+  preFixup = lib.optionalString stdenv.isLinux ''
+    patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$out"/libexec/*
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    maintainers = with lib.maintainers; [ abbradar periklis ];
+    knownVulnerabilities = [
+      "QtWebkit upstream is unmaintained and receives no security updates, see https://blogs.gnome.org/mcatanzaro/2022/11/04/stop-using-qtwebkit/"
+    ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix
new file mode 100644
index 000000000000..a355662aed6c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebsockets.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtwebsockets";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  outputs = [ "out" "dev" "bin" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebview.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebview.nix
new file mode 100644
index 000000000000..fd8755390973
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtwebview.nix
@@ -0,0 +1,12 @@
+{ lib, stdenv, qtModule, qtdeclarative, qtwebengine, CoreFoundation, WebKit }:
+
+qtModule {
+  pname = "qtwebview";
+  propagatedBuildInputs = [ qtdeclarative qtwebengine ];
+  buildInputs = lib.optionals stdenv.isDarwin [
+    CoreFoundation
+    WebKit
+  ];
+  outputs = [ "out" "dev" "bin" ];
+  NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreFoundation -framework WebKit";
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtx11extras.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtx11extras.nix
new file mode 100644
index 000000000000..8d5aa2fd235f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtx11extras.nix
@@ -0,0 +1,6 @@
+{ qtModule, qtbase }:
+
+qtModule {
+  pname = "qtx11extras";
+  propagatedBuildInputs = [ qtbase ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix
new file mode 100644
index 000000000000..ae4ea52dcd8a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/modules/qtxmlpatterns.nix
@@ -0,0 +1,7 @@
+{ qtModule, qtbase, qtdeclarative }:
+
+qtModule {
+  pname = "qtxmlpatterns";
+  propagatedBuildInputs = [ qtbase qtdeclarative ];
+  devTools = [ "bin/xmlpatterns" "bin/xmlpatternsvalidator" ];
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/qt-env.nix b/nixpkgs/pkgs/development/libraries/qt-5/qt-env.nix
new file mode 100644
index 000000000000..b4a201c08cc4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/qt-env.nix
@@ -0,0 +1,21 @@
+{ buildEnv, qtbase }: name: paths:
+
+buildEnv {
+  inherit name;
+  paths = [ qtbase ] ++ paths;
+
+  pathsToLink = [ "/bin" "/mkspecs" "/include" "/lib" "/share" ];
+  extraOutputsToInstall = [ "out" "dev" ];
+
+  postBuild = ''
+    rm "$out/bin/qmake"
+    cp "${qtbase.dev}/bin/qmake" "$out/bin"
+    cat >"$out/bin/qt.conf" <<EOF
+    [Paths]
+    Prefix = $out
+    Plugins = ${qtbase.qtPluginPrefix}
+    Qml2Imports = ${qtbase.qtQmlPrefix}
+    Documentation = ${qtbase.qtDocPrefix}
+    EOF
+  '';
+}
diff --git a/nixpkgs/pkgs/development/libraries/qt-5/qtModule.nix b/nixpkgs/pkgs/development/libraries/qt-5/qtModule.nix
new file mode 100644
index 000000000000..54d24e46092f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/qt-5/qtModule.nix
@@ -0,0 +1,94 @@
+{ lib
+, stdenv
+, buildPackages
+, mkDerivation
+, perl
+, qmake
+, patches
+, srcs
+, pkgsHostTarget
+}:
+
+let inherit (lib) licenses maintainers platforms; in
+
+args:
+
+let
+  inherit (args) pname;
+  version = args.version or srcs.${pname}.version;
+  src = args.src or srcs.${pname}.src;
+in
+
+mkDerivation (args // {
+  inherit pname version src;
+  patches = (args.patches or []) ++ (patches.${pname} or []);
+
+  nativeBuildInputs =
+    (args.nativeBuildInputs or []) ++ [
+      perl qmake
+    ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
+      pkgsHostTarget.qt5.qtbase.dev
+    ];
+  propagatedBuildInputs =
+    (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or []) ++
+    (args.propagatedBuildInputs or []);
+} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
+  depsBuildBuild = [ buildPackages.stdenv.cc ] ++ (args.depsBuildBuild or []);
+} // {
+
+  outputs = args.outputs or [ "out" "dev" ];
+  setOutputFlags = args.setOutputFlags or false;
+
+  preHook = ''
+    . ${./hooks/move-qt-dev-tools.sh}
+    . ${./hooks/fix-qt-builtin-paths.sh}
+  '';
+
+  preConfigure = ''
+    ${args.preConfigure or ""}
+
+    fixQtBuiltinPaths . '*.pr?'
+  '' + lib.optionalString (builtins.compareVersions "5.15.0" version <= 0)
+  # Note: We use ${version%%-*} to remove any tag from the end of the version
+  # string. Version tags are added by Nixpkgs maintainers and not reflected in
+  # the source version.
+  ''
+    if [[ -z "$dontCheckQtModuleVersion" ]] \
+        && grep -q '^MODULE_VERSION' .qmake.conf 2>/dev/null \
+        && ! grep -q -F "''${version%%-*}" .qmake.conf 2>/dev/null
+    then
+      echo >&2 "error: could not find version ''${version%%-*} in .qmake.conf"
+      echo >&2 "hint: check .qmake.conf and update the package version in Nixpkgs"
+      exit 1
+    fi
+
+    if [[ -z "$dontSyncQt" && -f sync.profile ]]; then
+      syncqt.pl -version "''${version%%-*}"
+    fi
+  '';
+
+  dontWrapQtApps = args.dontWrapQtApps or true;
+
+  postFixup = ''
+    if [ -d "''${!outputDev}/lib/pkgconfig" ]; then
+        find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do
+            sed -i "$pc" \
+                -e "/^prefix=/ c prefix=''${!outputLib}" \
+                -e "/^exec_prefix=/ c exec_prefix=''${!outputBin}" \
+                -e "/^includedir=/ c includedir=''${!outputDev}/include"
+        done
+    fi
+
+    moveQtDevTools
+
+    ${args.postFixup or ""}
+  '';
+
+  meta = {
+    homepage = "https://www.qt.io";
+    description = "A cross-platform application framework for C++";
+    license = with licenses; [ fdl13Plus gpl2Plus lgpl21Plus lgpl3Plus ];
+    maintainers = with maintainers; [ qknight ttuegel periklis bkchr ];
+    platforms = platforms.unix;
+  } // (args.meta or {});
+})