1{
2 lib,
3 stdenv,
4 cmake,
5 cups,
6 ninja,
7 python,
8 pythonImportsCheckHook,
9 moveBuildTree,
10 shiboken6,
11 llvmPackages,
12 symlinkJoin,
13}:
14let
15 packages = with python.pkgs.qt6; [
16 # required
17 python.pkgs.ninja
18 python.pkgs.packaging
19 python.pkgs.setuptools
20 qtbase
21
22 # optional
23 qt3d
24 qtcharts
25 qtconnectivity
26 qtdatavis3d
27 qtdeclarative
28 qthttpserver
29 qtmultimedia
30 qtnetworkauth
31 qtquick3d
32 qtremoteobjects
33 qtscxml
34 qtsensors
35 qtspeech
36 qtsvg
37 qtwebchannel
38 qtwebsockets
39 qtwebview
40 qtpositioning
41 qtlocation
42 qtshadertools
43 qtserialport
44 qtserialbus
45 qtgraphs
46 qttools
47 ];
48 qt_linked = symlinkJoin {
49 name = "qt_linked";
50 paths = packages;
51 };
52in
53
54stdenv.mkDerivation (finalAttrs: {
55 pname = "pyside6";
56
57 inherit (shiboken6) version src;
58
59 sourceRoot = "pyside-setup-everywhere-src-${finalAttrs.version}/sources/pyside6";
60
61 # Qt Designer plugin moved to a separate output to reduce closure size
62 # for downstream things
63 outputs = [
64 "out"
65 "devtools"
66 ];
67
68 # cmake/Macros/PySideModules.cmake supposes that all Qt frameworks on macOS
69 # reside in the same directory as QtCore.framework, which is not true for Nix.
70 # We therefore symLink all required and optional Qt modules in one directory tree ("qt_linked").
71 postPatch = ''
72 # Don't ignore optional Qt modules
73 substituteInPlace cmake/PySideHelpers.cmake \
74 --replace-fail \
75 'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \
76 'set (found_basepath 0)'
77 ''
78 + lib.optionalString stdenv.hostPlatform.isDarwin ''
79 substituteInPlace cmake/PySideHelpers.cmake \
80 --replace-fail \
81 "Designer" ""
82 '';
83
84 # "Couldn't find libclang.dylib You will likely need to add it manually to PATH to ensure the build succeeds."
85 env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
86 LLVM_INSTALL_DIR = "${lib.getLib llvmPackages.libclang}/lib";
87 };
88
89 nativeBuildInputs = [
90 cmake
91 ninja
92 python
93 pythonImportsCheckHook
94 ]
95 ++ lib.optionals stdenv.hostPlatform.isDarwin [ moveBuildTree ];
96
97 buildInputs = (
98 if stdenv.hostPlatform.isLinux then
99 # qtwebengine fails under darwin
100 # see https://github.com/NixOS/nixpkgs/pull/312987
101 packages ++ [ python.pkgs.qt6.qtwebengine ]
102 else
103 python.pkgs.qt6.darwinVersionInputs
104 ++ [
105 qt_linked
106 cups
107 ]
108 );
109
110 propagatedBuildInputs = [ shiboken6 ];
111
112 cmakeFlags = [ "-DBUILD_TESTS=OFF" ];
113
114 dontWrapQtApps = true;
115
116 postInstall = ''
117 cd ../../..
118 ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=pyside6
119 cp -r PySide6.egg-info $out/${python.sitePackages}/
120
121 mkdir -p "$devtools"
122 moveToOutput "${python.pkgs.qt6.qtbase.qtPluginPrefix}/designer" "$devtools"
123 '';
124
125 pythonImportsCheck = [ "PySide6" ];
126
127 meta = {
128 description = "Python bindings for Qt";
129 license = with lib.licenses; [
130 lgpl3Only
131 gpl2Only
132 gpl3Only
133 ];
134 homepage = "https://wiki.qt.io/Qt_for_Python";
135 changelog = "https://code.qt.io/cgit/pyside/pyside-setup.git/tree/doc/changelogs/changes-${finalAttrs.version}?h=v${finalAttrs.version}";
136 maintainers = with lib.maintainers; [ ];
137 platforms = lib.platforms.all;
138 };
139})