22 , systemdSupport ? stdenv.hostPlatform.isLinux
74 # optional dependencies
82 , libGLSupported ? stdenv.hostPlatform.isLinux
84 , qttranslations ? null
88 isCrossBuild = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
90 stdenv.mkDerivation rec {
95 propagatedBuildInputs = [
113 ] ++ lib.optionals (!stdenv.hostPlatform.isMinGW) [
120 unixODBCDrivers.sqlite
121 unixODBCDrivers.mariadb
122 ] ++ lib.optionals systemdSupport [
124 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
157 ] ++ lib.optionals libGLSupported [
159 ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
162 ] ++ lib.optional (cups != null && lib.meta.availableOn stdenv.hostPlatform cups) cups;
164 buildInputs = lib.optionals (lib.meta.availableOn stdenv.hostPlatform at-spi2-core) [
166 ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform 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 ];
183 enableParallelBuilding = true;
187 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
188 # TODO: Verify that this catches all the occurrences?
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
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"}'
204 substituteInPlace mkspecs/common/macx.conf \
205 --replace-fail 'CONFIG += ' 'CONFIG += no_default_rpath '
208 fix_qt_builtin_paths = ../hooks/fix-qt-builtin-paths.sh;
209 fix_qt_module_paths = ../hooks/fix-qt-module-paths.sh;
211 . "$fix_qt_builtin_paths"
212 . "$fix_qt_module_paths"
215 qtPluginPrefix = "lib/qt-6/plugins";
216 qtQmlPrefix = "lib/qt-6/qml";
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"
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;
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
254 dontWrapQtApps = true;
256 setupHook = ../hooks/qtbase-setup-hook.sh;
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;