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