1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchzip, 6 pkg-config, 7 dbus, 8 lndir, 9 dbus-python, 10 sip, 11 pyqt6-sip, 12 pyqt-builder, 13 qt6Packages, 14 pythonOlder, 15 mesa, 16 withMultimedia ? true, 17 withWebSockets ? true, 18 withLocation ? true, 19 # Not currently part of PyQt6 20 #, withConnectivity ? true 21 withPrintSupport ? true, 22 cups, 23}: 24 25buildPythonPackage rec { 26 pname = "pyqt6"; 27 version = "6.9.0"; 28 pyproject = true; 29 30 disabled = pythonOlder "3.9"; 31 32 # It looks like a stable release, but is it? Who knows. 33 # It's not on PyPI proper yet, at least, and the current 34 # actually-released version does not build with Qt 6.9, 35 # so we kinda have to use it. 36 # "ffs smdh fam" - K900 37 src = fetchzip { 38 url = "https://web.archive.org/web/20250406083944/https://www.riverbankcomputing.com/pypi/packages/PyQt6/pyqt6-6.9.0.tar.gz"; 39 hash = "sha256-UZSbz6MqdNtl2r4N8uvgNjQ+28KCzNFb5yFqPcooT5E="; 40 }; 41 42 patches = [ 43 # Fix some wrong assumptions by ./project.py 44 # TODO: figure out how to send this upstream 45 ./pyqt6-fix-dbus-mainloop-support.patch 46 # confirm license when installing via pyqt6_sip 47 ./pyqt5-confirm-license.patch 48 ]; 49 50 build-system = [ 51 sip 52 pyqt-builder 53 ]; 54 55 dependencies = [ 56 pyqt6-sip 57 dbus-python 58 ]; 59 60 # be more verbose 61 # and normalize version 62 postPatch = '' 63 cat >> pyproject.toml <<EOF 64 [tool.sip.project] 65 verbose = true 66 EOF 67 68 substituteInPlace pyproject.toml \ 69 --replace-fail 'version = "${version}"' 'version = "${lib.versions.pad 3 version}"' 70 ''; 71 72 enableParallelBuilding = true; 73 # HACK: paralellize compilation of make calls within pyqt's setup.py 74 # pkgs/stdenv/generic/setup.sh doesn't set this for us because 75 # make gets called by python code and not its build phase 76 # format=pyproject means the pip-build-hook hook gets used to build this project 77 # pkgs/development/interpreters/python/hooks/pip-build-hook.sh 78 # does not use the enableParallelBuilding flag 79 postUnpack = '' 80 export MAKEFLAGS+="''${enableParallelBuilding:+-j$NIX_BUILD_CORES}" 81 ''; 82 83 outputs = [ 84 "out" 85 "dev" 86 ]; 87 88 dontWrapQtApps = true; 89 90 nativeBuildInputs = 91 with qt6Packages; 92 [ 93 pkg-config 94 lndir 95 qtbase 96 qtsvg 97 qtdeclarative 98 qtwebchannel 99 qmake 100 qtquick3d 101 qtquicktimeline 102 ] 103 # ++ lib.optional withConnectivity qtconnectivity 104 ++ lib.optional withMultimedia qtmultimedia 105 ++ lib.optional withWebSockets qtwebsockets 106 ++ lib.optional withLocation qtlocation; 107 108 buildInputs = 109 with qt6Packages; 110 [ 111 dbus 112 qtbase 113 qtsvg 114 qtdeclarative 115 qtquick3d 116 qtquicktimeline 117 ] 118 # ++ lib.optional withConnectivity qtconnectivity 119 ++ lib.optional withWebSockets qtwebsockets 120 ++ lib.optional withLocation qtlocation; 121 122 propagatedBuildInputs = 123 # ld: library not found for -lcups 124 lib.optionals (withPrintSupport && stdenv.hostPlatform.isDarwin) [ cups ]; 125 126 passthru = { 127 inherit sip pyqt6-sip; 128 multimediaEnabled = withMultimedia; 129 WebSocketsEnabled = withWebSockets; 130 }; 131 132 dontConfigure = true; 133 134 # Checked using pythonImportsCheck, has no tests 135 136 pythonImportsCheck = 137 [ 138 "PyQt6" 139 "PyQt6.QtCore" 140 "PyQt6.QtQml" 141 "PyQt6.QtWidgets" 142 "PyQt6.QtGui" 143 "PyQt6.QtQuick" 144 ] 145 ++ lib.optional withWebSockets "PyQt6.QtWebSockets" 146 ++ lib.optional withMultimedia "PyQt6.QtMultimedia" 147 # ++ lib.optional withConnectivity "PyQt6.QtConnectivity" 148 ++ lib.optional withLocation "PyQt6.QtPositioning"; 149 150 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-address-of-temporary"; 151 152 meta = with lib; { 153 description = "Python bindings for Qt6"; 154 homepage = "https://riverbankcomputing.com/"; 155 license = licenses.gpl3Only; 156 inherit (mesa.meta) platforms; 157 maintainers = with maintainers; [ LunNova ]; 158 }; 159}