forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / qt-6 / modules / qtbase.nix
blob9df79ccc89be892fe56d7572dfcf3d0826728f03
1 { stdenv
2 , lib
3 , src
4 , patches ? [ ]
5 , version
6 , bison
7 , flex
8 , gperf
9 , lndir
10 , perl
11 , pkg-config
12 , which
13 , cmake
14 , ninja
15 , xmlstarlet
16 , libproxy
17 , xorg
18 , zstd
19 , double-conversion
20 , util-linux
21 , systemd
22 , systemdSupport ? stdenv.hostPlatform.isLinux
23 , libb2
24 , md4c
25 , mtdev
26 , lksctp-tools
27 , libselinux
28 , libsepol
29 , vulkan-headers
30 , vulkan-loader
31 , libthai
32 , libdrm
33 , libdatrie
34 , lttng-ust
35 , libepoxy
36 , dbus
37 , fontconfig
38 , freetype
39 , glib
40 , harfbuzz
41 , icu
42 , libX11
43 , libXcomposite
44 , libXext
45 , libXi
46 , libXrender
47 , libinput
48 , libjpeg
49 , libpng
50 , libxcb
51 , libxkbcommon
52 , libxml2
53 , libxslt
54 , openssl
55 , pcre
56 , pcre2
57 , sqlite
58 , udev
59 , xcbutil
60 , xcbutilimage
61 , xcbutilkeysyms
62 , xcbutilrenderutil
63 , xcbutilwm
64 , zlib
65 , at-spi2-core
66 , unixODBC
67 , unixODBCDrivers
68   # darwin
69 , moveBuildTree
70 , darwinVersionInputs
71 , xcbuild
72   # mingw
73 , pkgsBuildBuild
74   # optional dependencies
75 , cups
76 , libmysqlclient
77 , postgresql
78 , withGtk3 ? false
79 , dconf
80 , gtk3
81   # options
82 , libGLSupported ? stdenv.hostPlatform.isLinux
83 , libGL
84 , qttranslations ? null
87 let
88   isCrossBuild = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
90 stdenv.mkDerivation rec {
91   pname = "qtbase";
93   inherit src version;
95   propagatedBuildInputs = [
96     libxml2
97     libxslt
98     openssl
99     sqlite
100     zlib
101     # Text rendering
102     harfbuzz
103     icu
104     # Image formats
105     libjpeg
106     libpng
107     pcre2
108     pcre
109     zstd
110     libb2
111     md4c
112     double-conversion
113   ] ++ lib.optionals (!stdenv.hostPlatform.isMinGW) [
114     libproxy
115     dbus
116     glib
117     # unixODBC drivers
118     unixODBC
119     unixODBCDrivers.psql
120     unixODBCDrivers.sqlite
121     unixODBCDrivers.mariadb
122   ] ++ lib.optionals systemdSupport [
123     systemd
124   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
125     util-linux
126     mtdev
127     lksctp-tools
128     libselinux
129     libsepol
130     lttng-ust
131     vulkan-headers
132     vulkan-loader
133     libthai
134     libdrm
135     libdatrie
136     udev
137     # Text rendering
138     fontconfig
139     freetype
140     # X11 libs
141     libX11
142     libXcomposite
143     libXext
144     libXi
145     libXrender
146     libxcb
147     libxkbcommon
148     xcbutil
149     xcbutilimage
150     xcbutilkeysyms
151     xcbutilrenderutil
152     xcbutilwm
153     xorg.libXdmcp
154     xorg.libXtst
155     xorg.xcbutilcursor
156     libepoxy
157   ] ++ lib.optionals libGLSupported [
158     libGL
159   ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
160     vulkan-headers
161     vulkan-loader
162   ] ++ lib.optional (cups != null && lib.meta.availableOn stdenv.hostPlatform cups) cups;
164   buildInputs = lib.optionals (lib.meta.availableOn stdenv.hostPlatform at-spi2-core) [
165     at-spi2-core
166   ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform libinput) [
167     libinput
168   ] ++ lib.optionals stdenv.hostPlatform.isDarwin darwinVersionInputs
169   ++ lib.optional withGtk3 gtk3
170   ++ lib.optional (libmysqlclient != null && !stdenv.hostPlatform.isMinGW) libmysqlclient
171   ++ lib.optional (postgresql != null && lib.meta.availableOn stdenv.hostPlatform postgresql) postgresql;
173   nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which cmake xmlstarlet ninja ]
174     ++ lib.optionals stdenv.hostPlatform.isDarwin [ moveBuildTree ];
176   propagatedNativeBuildInputs = [ lndir ]
177     # I’m not sure if this is necessary, but the macOS mkspecs stuff
178     # tries to call `xcrun xcodebuild`, so better safe than sorry.
179     ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
181   strictDeps = true;
183   enableParallelBuilding = true;
185   inherit patches;
187   postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
188     # TODO: Verify that this catches all the occurrences?
189     for file in \
190       cmake/QtPublicAppleHelpers.cmake \
191       mkspecs/features/mac/asset_catalogs.prf \
192       mkspecs/features/mac/default_pre.prf \
193       mkspecs/features/mac/sdk.mk \
194       mkspecs/features/mac/sdk.prf \
195       mkspecs/features/permissions.prf \
196       src/corelib/Qt6CoreMacros.cmake
197     do
198       substituteInPlace "$file" \
199         --replace-quiet /usr/bin/xcrun '${lib.getExe' xcbuild "xcrun"}' \
200         --replace-quiet /usr/bin/xcode-select '${lib.getExe' xcbuild "xcode-select"}' \
201         --replace-quiet /usr/libexec/PlistBuddy '${lib.getExe' xcbuild "PlistBuddy"}'
202     done
204     substituteInPlace mkspecs/common/macx.conf \
205       --replace-fail 'CONFIG += ' 'CONFIG += no_default_rpath '
206   '';
208   fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
209   fix_qt_module_paths = ../hooks/fix-qt-module-paths.sh;
210   preHook = ''
211     . "$fix_qt_builtin_paths"
212     . "$fix_qt_module_paths"
213   '';
215   qtPluginPrefix = "lib/qt-6/plugins";
216   qtQmlPrefix = "lib/qt-6/qml";
218   cmakeFlags = [
219     "-DQT_EMBED_TOOLCHAIN_COMPILER=OFF"
220     "-DINSTALL_PLUGINSDIR=${qtPluginPrefix}"
221     "-DINSTALL_QMLDIR=${qtQmlPrefix}"
222     "-DQT_FEATURE_libproxy=ON"
223     "-DQT_FEATURE_system_sqlite=ON"
224     "-DQT_FEATURE_openssl_linked=ON"
225   ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
226     "-DQT_FEATURE_sctp=ON"
227     "-DQT_FEATURE_journald=${if systemdSupport then "ON" else "OFF"}"
228     "-DQT_FEATURE_vulkan=ON"
229   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
230     "-DQT_FEATURE_rpath=OFF"
231   ] ++ lib.optionals isCrossBuild [
232     "-DQT_HOST_PATH=${pkgsBuildBuild.qt6.qtbase}"
233     "-DQt6HostInfo_DIR=${pkgsBuildBuild.qt6.qtbase}/lib/cmake/Qt6HostInfo"
234   ]
235   ++ lib.optional (qttranslations != null && !isCrossBuild) "-DINSTALL_TRANSLATIONSDIR=${qttranslations}/translations";
237   env.NIX_CFLAGS_COMPILE = "-DNIXPKGS_QT_PLUGIN_PREFIX=\"${qtPluginPrefix}\"";
239   outputs = [ "out" "dev" ];
240   separateDebugInfo = true;
242   moveToDev = false;
244   postFixup = ''
245     moveToOutput      "mkspecs/modules" "$dev"
246     fixQtModulePaths  "$dev/mkspecs/modules"
247     fixQtBuiltinPaths "$out" '*.pr?'
248   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
250     # FIXME: not sure why this isn't added automatically?
251     patchelf --add-rpath "${libmysqlclient}/lib/mariadb" $out/${qtPluginPrefix}/sqldrivers/libqsqlmysql.so
252   '';
254   dontWrapQtApps = true;
256   setupHook = ../hooks/qtbase-setup-hook.sh;
258   meta = with lib; {
259     homepage = "https://www.qt.io/";
260     description = "Cross-platform application framework for C++";
261     license = with licenses; [ fdl13Plus gpl2Plus lgpl21Plus lgpl3Plus ];
262     maintainers = with maintainers; [ milahu nickcao LunNova ];
263     platforms = platforms.unix ++ platforms.windows;
264   };