Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / qt-5 / 5.15 / default.nix
bloba2b38046c5a8335e427c4047f0498838be38944a
1 /*
3 # Updates
5 Run `./fetch.sh` to update package sources from Git.
6 Check for any minor version changes.
8 */
10 { makeScopeWithSplicing', generateSplicesForMkScope
11 , lib, stdenv, fetchurl, fetchgit, fetchpatch, fetchFromGitHub, makeSetupHook, makeWrapper
12 , bison, cups ? null, harfbuzz, libGL, perl, python3
13 , gstreamer, gst-plugins-base, gtk3, dconf
14 , llvmPackages_15, overrideSDK, overrideLibcxx
15 , darwin
17   # options
18 , developerBuild ? false
19 , decryptSslTraffic ? false
20 , debug ? false
21 , config
24 let
26   srcs = import ./srcs.nix { inherit lib fetchgit fetchFromGitHub; };
28   qtCompatVersion = srcs.qtbase.version;
30   patches = {
31     qtbase = lib.optionals stdenv.isDarwin [
32       ./qtbase.patch.d/0001-qtbase-mkspecs-mac.patch
34       # Patch framework detection to support X.framework/X.tbd,
35       # extending the current support for X.framework/X.
36       ./qtbase.patch.d/0012-qtbase-tbd-frameworks.patch
38       ./qtbase.patch.d/0014-aarch64-darwin.patch
39     ] ++ [
40       ./qtbase.patch.d/0003-qtbase-mkspecs.patch
41       ./qtbase.patch.d/0004-qtbase-replace-libdir.patch
42       ./qtbase.patch.d/0005-qtbase-cmake.patch
43       ./qtbase.patch.d/0006-qtbase-gtk3.patch
44       ./qtbase.patch.d/0007-qtbase-xcursor.patch
45       ./qtbase.patch.d/0008-qtbase-tzdir.patch
46       ./qtbase.patch.d/0009-qtbase-qtpluginpath.patch
47       ./qtbase.patch.d/0010-qtbase-assert.patch
48       ./qtbase.patch.d/0011-fix-header_module.patch
49     ];
50     qtdeclarative = [
51       ./qtdeclarative.patch
52       # prevent headaches from stale qmlcache data
53       ./qtdeclarative-default-disable-qmlcache.patch
54     ];
55     qtlocation = lib.optionals stdenv.cc.isClang [
56       # Fix build with Clang 16
57       (fetchpatch {
58         url = "https://github.com/boostorg/numeric_conversion/commit/50a1eae942effb0a9b90724323ef8f2a67e7984a.patch";
59         stripLen = 1;
60         extraPrefix = "src/3rdparty/mapbox-gl-native/deps/boost/1.65.1/";
61         hash = "sha256-UEvIXzn387f9BAeBdhheStD/4M7en+rmqX8C6gstl6k=";
62       })
63     ];
64     qtmultimedia = lib.optionals stdenv.isDarwin [
65       # build patch for qtmultimedia with xcode 15
66       (fetchpatch {
67         url = "https://raw.githubusercontent.com/Homebrew/formula-patches/3f509180/qt5/qt5-qtmultimedia-xcode15.patch";
68         stripLen = 1;
69         hash = "sha256-HrEqfmm8WbapWgLM0L4AKW8168pwT2zYI8HOJruEPSs=";
70       })
71     ];
72     qtpim = [
73       ## Upstream patches after the Qt6 transition that apply without problems & fix bugs
75       # Fixes QList -> QSet conversion
76       (fetchpatch {
77         url = "https://github.com/qt/qtpim/commit/f337e281e28904741a3b1ac23d15c3a83ef2bbc9.patch";
78         hash = "sha256-zlxD45JnbhIgdJxMmGxGMUBcQPcgzpu3s4bLX939jL0=";
79       })
80       # Fixes invalid syntax from a previous bad patch in tests
81       (fetchpatch {
82         url = "https://github.com/qt/qtpim/commit/2aefdd8bd28a4decf9ef8381f5b255f39f1ee90c.patch";
83         hash = "sha256-mg93QF3hi50igw1/Ok7fEs9iCaN6co1+p2/5fQtxTmc=";
84       })
85       # Unit test account for QList index change
86       (fetchpatch {
87         url = "https://github.com/qt/qtpim/commit/79b41af6a4117f5efb0298289e20c30b4d0b0b2e.patch";
88         hash = "sha256-u+cLl4lu6r2+j5GAiasqbB6/OZPz5A6GpSB33vd/VBg=";
89       })
90       # Remove invalid method overload which confuses the QML engine
91       (fetchpatch {
92         url = "https://github.com/qt/qtpim/commit/5679a6141c76ae7d64c3acc8a87b1adb048289e0.patch";
93         hash = "sha256-z8f8kLhC9CqBOfGPL8W9KJq7MwALAAicXfRkHiQEVJ4=";
94       })
95       # Specify enum flag type properly in unit test
96       (fetchpatch {
97         url = "https://github.com/qt/qtpim/commit/a43cc24e57db8d3c3939fa540d67da3294dcfc5c.patch";
98         hash = "sha256-SsYkxX6prxi8VRZr4az+wqawcRN8tR3UuIFswJL+3T4=";
99       })
100       # Update qHash methods to return size_t instead of uint
101       (fetchpatch {
102         url = "https://github.com/qt/qtpim/commit/9c698155d82fc2b68a87c59d0443c33f9085b117.patch";
103         hash = "sha256-rb8D8taaglhQikYSAPrtLvazgIw8Nga/a9+J21k8gIo=";
104       })
105       # Mark virtual methods with override keyword
106       (fetchpatch {
107         url = "https://github.com/qt/qtpim/commit/f34cf2ff2b0f428d5b8a70763b29088075ebbd1c.patch";
108         hash = "sha256-tNPOEVpx1eqHx5T23ueW32KxMQ/SB+TBCJ4PZ6SA3LI=";
109       })
110       # Fix calendardemo example
111       (fetchpatch {
112         url = "https://github.com/qt/qtpim/commit/a66590d473753bc49105d3132fb9e4150c92a14a.patch";
113         hash = "sha256-RPRtGQ24NQYewnv6+IqYITpwD/XxuK68a1iKgFmKm3c=";
114       })
115       # Make the tests pass on big endian systems
116       (fetchpatch {
117         url = "https://github.com/qt/qtpim/commit/7802f038ed1391078e27fa3f37d785a69314537b.patch";
118         hash = "sha256-hogUXyPXjGE0q53PWOjiQbQ2YzOsvrJ7mo9djGIbjVQ=";
119       })
120       # Fix some deprecated QChar constructor issues in unit tests
121       (fetchpatch {
122         url = "https://github.com/qt/qtpim/commit/114615812dcf9398c957b0833e860befe15f840f.patch";
123         hash = "sha256-yZ1qs8y5DSq8FDXRPyuSPRIzjEUTWAhpVide/b+xaLQ=";
124       })
125       # Accessors should be const
126       (fetchpatch {
127         url = "https://github.com/qt/qtpim/commit/a2bf7cdf05c264b5dd2560f799760b5508f154e4.patch";
128         hash = "sha256-+YfPrKyOKnPkqFokwW/aDsEivg4TzdJwQpDdAtM+rQE=";
129       })
130       # Enforce detail access constraints in contact operations by default
131       (fetchpatch {
132         url = "https://github.com/qt/qtpim/commit/8765a35233aa21a932ee92bbbb92a5f8edd4dc68.patch";
133         hash = "sha256-vp/enerVecEXz4zyxQ66DG+fVVWxI4bYnLj92qaaqNk=";
134       })
135       # Fixes broken file generation, which breaks reverse dependencies that try to find one of its modules
136       (fetchpatch {
137         url = "https://github.com/qt/qtpim/commit/4b2bdce30bd0629c9dc0567af6eeaa1d038f3152.patch";
138         hash = "sha256-2dXhkZyxPvY2KQq2veerAlpXkpU5/FeArWRlm1aOcEY=";
139       })
141       ## Patches that haven't been upstreamed
143       # Fix tst_QContactManager::compareVariant_data test
144       (fetchpatch {
145         url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/1001_fix-qtdatetime-null-comparison.patch";
146         hash = "sha256-k/rO9QjwSlRChwFTZLkxDjZWqFkua4FNbaNf1bJKLxc=";
147       })
148       # Avoid crash while parsing vCards from different threads
149       (fetchpatch {
150         url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/1002_Avoid-crash-while-parsing-vcards-from-different-threads.patch";
151         hash = "sha256-zhayAoWgcmKosEGVBy2k6a2e6BxyVwfGX18tBbzqEk8=";
152       })
153       # Adapt to JSON parser behavior change in Qt 5.15
154       (fetchpatch {
155         url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/1003_adapt_to_json_parser_change.patch";
156         hash = "sha256-qAIa48hmDd8vMH/ywqW+22vISKai76XnjgFuB+tQbIU=";
157       })
158       # Fix version being 0.0.0
159       (fetchpatch {
160         url = "https://salsa.debian.org/qt-kde-team/qt/qtpim/-/raw/360682f88457b5ae7c92f32f574e51ccc5edbea0/debian/patches/2000_revert_module_version.patch";
161         hash = "sha256-6wg/eVu9J83yvIO428U1FX3otz58tAy6pCvp7fqOBKU=";
162       })
163     ];
164     qtscript = [ ./qtscript.patch ];
165     qtserialport = [ ./qtserialport.patch ];
166     qtsystems = [
167       # Enable building with udisks support
168       (fetchpatch {
169         url = "https://salsa.debian.org/qt-kde-team/qt/qtsystems/-/raw/a23fd92222c33479d7f3b59e48116def6b46894c/debian/patches/2001_build_with_udisk.patch";
170         hash = "sha256-B/z/+tai01RU/bAJSCp5a0/dGI8g36nwso8MiJv27YM=";
171       })
172     ];
173     qtwebengine = [
174       (fetchpatch {
175         url = "https://raw.githubusercontent.com/Homebrew/formula-patches/a6f16c6daea3b5a1f7bc9f175d1645922c131563/qt5/qt5-webengine-python3.patch";
176         hash = "sha256-rUSDwTucXVP3Obdck7LRTeKZ+JYQSNhQ7+W31uHZ9yM=";
177       })
178       (fetchpatch {
179         url = "https://raw.githubusercontent.com/Homebrew/formula-patches/7ae178a617d1e0eceb742557e63721af949bd28a/qt5/qt5-webengine-chromium-python3.patch";
180         stripLen = 1;
181         extraPrefix = "src/3rdparty/";
182         hash = "sha256-MZGYeMdGzwypfKoSUaa56K3inbcGRx7he/+AFyk5ekA=";
183       })
184       (fetchpatch {
185         url = "https://raw.githubusercontent.com/Homebrew/formula-patches/7ae178a617d1e0eceb742557e63721af949bd28a/qt5/qt5-webengine-gcc12.patch";
186         stripLen = 1;
187         extraPrefix = "src/3rdparty/";
188         hash = "sha256-s4GsGMJTBNWw2gTJuIEP3tqT82AmTsR2mbj59m2p6rM=";
189       })
190       ./qtwebengine-link-pulseaudio.patch
191     ] ++ lib.optionals stdenv.isDarwin [
192       ./qtwebengine-darwin-no-platform-check.patch
193       ./qtwebengine-mac-dont-set-dsymutil-path.patch
194       ./qtwebengine-darwin-checks.patch
195     ];
196     qtwebkit = [
197       (fetchpatch {
198         name = "qtwebkit-bison-3.7-build.patch";
199         url = "https://github.com/qtwebkit/qtwebkit/commit/d92b11fea65364fefa700249bd3340e0cd4c5b31.patch";
200         sha256 = "0h8ymfnwgkjkwaankr3iifiscsvngqpwb91yygndx344qdiw9y0n";
201       })
202       (fetchpatch {
203         name = "qtwebkit-glib-2.68.patch";
204         url = "https://github.com/qtwebkit/qtwebkit/pull/1058/commits/5b698ba3faffd4e198a45be9fe74f53307395e4b.patch";
205         sha256 = "0a3xv0h4lv8wggckgy8cg8xnpkg7n9h45312pdjdnnwy87xvzss0";
206       })
207       (fetchpatch {
208         name = "qtwebkit-darwin-handle.patch";
209         url = "https://github.com/qtwebkit/qtwebkit/commit/5c272a21e621a66862821d3ae680f27edcc64c19.patch";
210         sha256 = "9hjqLyABz372QDgoq7nXXXQ/3OXBGcYN1/92ekcC3WE=";
211       })
212       ./qtwebkit.patch
213       ./qtwebkit-icu68.patch
214     ] ++ lib.optionals stdenv.isDarwin [
215       ./qtwebkit-darwin-no-readline.patch
216       ./qtwebkit-darwin-no-qos-classes.patch
217     ];
218     qttools = [ ./qttools.patch ];
219   };
221   addPackages = self:
222     let
223       qtModule = callPackage ../qtModule.nix {
224         inherit patches;
225         # Use a variant of mkDerivation that does not include wrapQtApplications
226         # to avoid cyclic dependencies between Qt modules.
227         mkDerivation =
228           (callPackage ../mkDerivation.nix { wrapQtAppsHook = null; }) stdenv.mkDerivation;
229       };
231       callPackage = self.newScope { inherit qtCompatVersion qtModule srcs stdenv; };
232     in {
234       inherit callPackage qtCompatVersion qtModule srcs;
236       mkDerivationWith = callPackage ../mkDerivation.nix { };
238       mkDerivation = callPackage ({ mkDerivationWith }: mkDerivationWith stdenv.mkDerivation) { };
240       qtbase = callPackage ../modules/qtbase.nix {
241         inherit (srcs.qtbase) src version;
242         patches = patches.qtbase;
243         inherit bison cups harfbuzz libGL;
244         withGtk3 = !stdenv.isDarwin; inherit dconf gtk3;
245         inherit developerBuild decryptSslTraffic;
246         inherit (darwin.apple_sdk_11_0.frameworks) AGL AppKit ApplicationServices AVFoundation Carbon Cocoa CoreAudio CoreBluetooth
247           CoreLocation CoreServices DiskArbitration Foundation OpenGL MetalKit IOKit;
248         libobjc = darwin.apple_sdk_11_0.objc4;
249         xcbuild = darwin.apple_sdk_11_0.xcodebuild;
250       };
252       qt3d = callPackage ../modules/qt3d.nix {};
253       qtcharts = callPackage ../modules/qtcharts.nix {};
254       qtconnectivity = callPackage ../modules/qtconnectivity.nix {
255         inherit (darwin.apple_sdk_11_0.frameworks) IOBluetooth;
256       };
257       qtdatavis3d = callPackage ../modules/qtdatavis3d.nix {};
258       qtdeclarative = callPackage ../modules/qtdeclarative.nix {};
259       qtdoc = callPackage ../modules/qtdoc.nix {};
260       qtgamepad = callPackage ../modules/qtgamepad.nix {
261         inherit (darwin.apple_sdk_11_0.frameworks) GameController;
262       };
263       qtgraphicaleffects = callPackage ../modules/qtgraphicaleffects.nix {};
264       qtimageformats = callPackage ../modules/qtimageformats.nix {};
265       qtlocation = callPackage ../modules/qtlocation.nix {};
266       qtlottie = callPackage ../modules/qtlottie.nix {};
267       qtmacextras = callPackage ../modules/qtmacextras.nix {};
268       qtmultimedia = callPackage ../modules/qtmultimedia.nix {
269         inherit gstreamer gst-plugins-base;
270       };
271       qtnetworkauth = callPackage ../modules/qtnetworkauth.nix {};
272       qtpim = callPackage ../modules/qtpim.nix {};
273       qtpositioning = callPackage ../modules/qtpositioning.nix {};
274       qtquick1 = null;
275       qtquickcontrols = callPackage ../modules/qtquickcontrols.nix {};
276       qtquickcontrols2 = callPackage ../modules/qtquickcontrols2.nix {};
277       qtremoteobjects = callPackage ../modules/qtremoteobjects.nix {};
278       qtscript = callPackage ../modules/qtscript.nix {};
279       qtsensors = callPackage ../modules/qtsensors.nix {};
280       qtserialbus = callPackage ../modules/qtserialbus.nix {};
281       qtserialport = callPackage ../modules/qtserialport.nix {};
282       qtspeech = callPackage ../modules/qtspeech.nix {};
283       qtsvg = callPackage ../modules/qtsvg.nix {};
284       qtsystems = callPackage ../modules/qtsystems.nix {};
285       qtscxml = callPackage ../modules/qtscxml.nix {};
286       qttools = callPackage ../modules/qttools.nix {};
287       qttranslations = callPackage ../modules/qttranslations.nix {};
288       qtvirtualkeyboard = callPackage ../modules/qtvirtualkeyboard.nix {};
289       qtwayland = callPackage ../modules/qtwayland.nix {};
290       qtwebchannel = callPackage ../modules/qtwebchannel.nix {};
291       qtwebengine = callPackage ../modules/qtwebengine.nix {
292         # The version of Chromium used by Qt WebEngine 5.15.x does not build with clang 16 due
293         # to the following errors:
294         # * -Wenum-constexpr-conversion: This is a downgradable error in clang 16, but it is planned
295         #   to be made into a hard error in a future version of clang. Patches are not available for
296         #   the version of v8 used by Chromium in Qt WebEngine, and fixing the code is non-trivial.
297         # * -Wincompatible-function-pointer-types: This is also a downgradable error generated
298         #   starting with clang 16. Patches are available upstream that can be backported.
299         # Because the first error is non-trivial to fix and suppressing it risks future breakage,
300         # clang is pinned to clang 15. That also makes fixing the second set of errors unnecessary.
301         stdenv =
302           let stdenv' = if stdenv.cc.isClang then overrideLibcxx llvmPackages_15.stdenv else stdenv;
303           in if stdenv'.isDarwin then overrideSDK stdenv' "11.0" else stdenv';
304         inherit (srcs.qtwebengine) version;
305         python = python3;
306         postPatch = ''
307           # update catapult for python3 compatibility
308           rm -r src/3rdparty/chromium/third_party/catapult
309           cp -r ${srcs.catapult} src/3rdparty/chromium/third_party/catapult
310         '';
311         inherit (darwin) cctools xnu;
312         inherit (darwin.apple_sdk_11_0) libpm libunwind;
313         inherit (darwin.apple_sdk_11_0.libs) sandbox;
314         inherit (darwin.apple_sdk_11_0.frameworks) ApplicationServices AVFoundation Foundation ForceFeedback GameController AppKit
315           ImageCaptureCore CoreBluetooth IOBluetooth CoreWLAN Quartz Cocoa LocalAuthentication
316           MediaPlayer MediaAccessibility SecurityInterface Vision CoreML OpenDirectory Accelerate;
317         libobjc = darwin.apple_sdk_11_0.objc4;
318       };
319       qtwebglplugin = callPackage ../modules/qtwebglplugin.nix {};
320       qtwebkit = callPackage ../modules/qtwebkit.nix {
321         inherit (darwin) ICU;
322         inherit (darwin.apple_sdk_11_0.frameworks) OpenGL;
323       };
324       qtwebsockets = callPackage ../modules/qtwebsockets.nix {};
325       qtwebview = callPackage ../modules/qtwebview.nix {
326         inherit (darwin.apple_sdk_11_0.frameworks) CoreFoundation WebKit;
327       };
328       qtx11extras = callPackage ../modules/qtx11extras.nix {};
329       qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};
331       env = callPackage ../qt-env.nix {};
332       full = callPackage ({ env, qtbase }: env "qt-full-${qtbase.version}") { }
333       # `with self` is ok to use here because having these spliced is unnecessary
334       (with self; [
335         qt3d qtcharts qtconnectivity qtdeclarative qtdoc qtgraphicaleffects
336         qtimageformats qtlocation qtmultimedia qtquickcontrols qtquickcontrols2
337         qtscript qtsensors qtserialport qtsvg qttools qttranslations
338         qtvirtualkeyboard qtwebchannel qtwebengine qtwebsockets
339         qtwebview qtx11extras qtxmlpatterns qtlottie qtdatavis3d
340       ] ++ lib.optional (!stdenv.isDarwin) qtwayland
341         ++ lib.optional (stdenv.isDarwin) qtmacextras);
343       qmake = callPackage ({ qtbase }: makeSetupHook {
344         name = "qmake-hook";
345         ${if stdenv.buildPlatform == stdenv.hostPlatform
346           then "propagatedBuildInputs"
347           else "depsTargetTargetPropagated"} = [ qtbase.dev ];
348         substitutions = {
349           inherit debug;
350           fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh;
351         };
352       } ../hooks/qmake-hook.sh) { };
354       wrapQtAppsHook = callPackage ({ makeBinaryWrapper, qtbase, qtwayland }: makeSetupHook {
355         name = "wrap-qt5-apps-hook";
356         propagatedBuildInputs = [ qtbase.dev makeBinaryWrapper ]
357           ++ lib.optional stdenv.isLinux qtwayland.dev;
358       } ../hooks/wrap-qt-apps-hook.sh) { };
359     };
361   baseScope = makeScopeWithSplicing' {
362     otherSplices = generateSplicesForMkScope "qt5";
363     f = addPackages;
364   };
366   bootstrapScope = baseScope.overrideScope(final: prev: {
367     qtbase = prev.qtbase.override { qttranslations = null; };
368     qtdeclarative = null;
369   });
371   finalScope = baseScope.overrideScope(final: prev: {
372     # qttranslations causes eval-time infinite recursion when
373     # cross-compiling; disabled for now.
374     qttranslations =
375       if stdenv.buildPlatform == stdenv.hostPlatform
376       then bootstrapScope.qttranslations
377       else null;
378     qutebrowser = final.callPackage ../../../../applications/networking/browsers/qutebrowser { };
379   });
380 in finalScope