1{
2 mkDerivation,
3 lib,
4 fetchFromGitHub,
5 cmake,
6 python3,
7 qtbase,
8 qtquickcontrols2,
9 qtgraphicaleffects,
10 curaengine,
11 plugins ? [ ],
12}:
13
14mkDerivation rec {
15 pname = "cura";
16 version = "4.13.1";
17
18 src = fetchFromGitHub {
19 owner = "Ultimaker";
20 repo = "Cura";
21 rev = version;
22 sha256 = "sha256-R88SdAxx3tkQCDInrFTKad1tPSDTSYaVAPUVmdk94Xk=";
23 };
24
25 materials = fetchFromGitHub {
26 owner = "Ultimaker";
27 repo = "fdm_materials";
28 rev = "4.13.2";
29 sha256 = "sha256-7y4OcbeQHv+loJ4cMgPU0e818Zsv90EwARdztNWS8zM=";
30 };
31
32 buildInputs = [
33 qtbase
34 qtquickcontrols2
35 qtgraphicaleffects
36 ];
37 propagatedBuildInputs =
38 with python3.pkgs;
39 [
40 libsavitar
41 numpy-stl
42 pyserial
43 requests
44 uranium
45 zeroconf
46 pynest2d
47 sentry-sdk
48 trimesh
49 keyring
50 ]
51 ++ plugins;
52 nativeBuildInputs = [
53 cmake
54 python3.pkgs.wrapPython
55 ];
56
57 cmakeFlags = [
58 "-DURANIUM_DIR=${python3.pkgs.uranium.src}"
59 "-DCURA_VERSION=${version}"
60 ];
61
62 makeWrapperArgs = [
63 # hacky workaround for https://github.com/NixOS/nixpkgs/issues/59901
64 "--set OMP_NUM_THREADS 1"
65 ];
66
67 postPatch = ''
68 sed -i 's,/python''${PYTHON_VERSION_MAJOR}/dist-packages,/python''${PYTHON_VERSION_MAJOR}.''${PYTHON_VERSION_MINOR}/site-packages,g' CMakeLists.txt
69 sed -i 's, executable_name = .*, executable_name = "${curaengine}/bin/CuraEngine",' plugins/CuraEngineBackend/CuraEngineBackend.py
70 '';
71
72 postInstall = ''
73 mkdir -p $out/share/cura/resources/materials
74 cp ${materials}/*.fdm_material $out/share/cura/resources/materials/
75 mkdir -p $out/lib/cura/plugins
76 for plugin in ${toString plugins}; do
77 ln -s $plugin/lib/cura/plugins/* $out/lib/cura/plugins
78 done
79 '';
80
81 postFixup = ''
82 wrapPythonPrograms
83 wrapQtApp $out/bin/cura
84 '';
85
86 meta = with lib; {
87 description = "3D printer / slicing GUI built on top of the Uranium framework";
88 mainProgram = "cura";
89 homepage = "https://github.com/Ultimaker/Cura";
90 license = licenses.lgpl3Plus;
91 platforms = platforms.linux;
92 maintainers = [ ];
93 };
94}