@@ -0,0 +1,78 @@
1+{ lib, callPackage, fetchgit, cmake, jq, python3Packages, qtbase, qtquickcontrols2 }:
2+
3+let
4+ # admittedly, we're using (printer firmware) blobs when we could compile them ourselves.
5+ curaBinaryDataVersion = "3.6.18"; # Marlin v2.0.0.144. Keep this accurate wrt. the below.
6+ curaBinaryData = fetchgit {
7+ url = https://code.alephobjects.com/diffusion/CBD/cura-binary-data.git;
8+ rev = "cdc046494bbfe1f65bfb34659a257eef9a0100a0";
9+ sha256 = "0v0s036gxdjiglas2yzw95alv60sw3pq5k1zrrhmw9mxr4irrblb";
10+ };
11+
12+ libarcusLulzbot = callPackage ./libarcus.nix {
13+ inherit (python3Packages) buildPythonPackage sip pythonOlder;
14+ };
15+ libsavitarLulzbot = callPackage ./libsavitar.nix {
16+ inherit (python3Packages) buildPythonPackage sip pythonOlder;
17+ };
18+
19+ inherit (python3Packages) buildPythonPackage pyqt5 numpy scipy shapely pythonOlder;
20+ curaengine = callPackage ./curaengine.nix {
21+ inherit libarcusLulzbot;
22+ };
23+ uraniumLulzbot = callPackage ./uranium.nix {
24+ inherit callPackage libarcusLulzbot;
25+ inherit (python3Packages) buildPythonPackage pyqt5 numpy scipy shapely pythonOlder;
26+ };
27+in
28+python3Packages.buildPythonApplication rec {
29+ name = "cura-lulzbot-${version}";
30+ version = "3.6.18";
31+
32+ src = fetchgit {
33+ url = https://code.alephobjects.com/source/cura-lulzbot.git;
34+ rev = "71f1ac5a2b9f535175a3858a565930348358a9ca";
35+ sha256 = "0by06fpxvdgy858lwhsccbmvkdq67j2s1cz8v6jnrnjrsxk7vzka";
36+ };
37+
38+ format = "other"; # using cmake to build
39+ buildInputs = [ qtbase qtquickcontrols2 ];
40+ # numpy-stl temporarily disabled due to https://code.alephobjects.com/T8415
41+ propagatedBuildInputs = with python3Packages; [ pyserial requests zeroconf ] ++ [ libsavitarLulzbot uraniumLulzbot libarcusLulzbot ]; # numpy-stl
42+ nativeBuildInputs = [ cmake python3Packages.wrapPython ];
43+
44+ cmakeFlags = [
45+ "-DURANIUM_DIR=${uraniumLulzbot.src}"
46+ "-DCURA_VERSION=${version}"
47+ ];
48+
49+ postPatch = ''
50+ sed -i 's,/python''${PYTHON_VERSION_MAJOR}/dist-packages,/python''${PYTHON_VERSION_MAJOR}.''${PYTHON_VERSION_MINOR}/site-packages,g' CMakeLists.txt
51+ sed -i 's, executable_name = .*, executable_name = "${curaengine}/bin/CuraEngine",' plugins/CuraEngineBackend/CuraEngineBackend.py
52+ '';
53+
54+ preFixup = ''
55+ substituteInPlace "$out/bin/cura-lulzbot" --replace 'import cura.CuraApplication' 'import Savitar; import cura.CuraApplication'
56+ ln -sT "${curaBinaryData}/cura/resources/firmware" "$out/share/cura/resources/firmware"
57+ ln -sT "${uraniumLulzbot}/share/uranium" "$out/share/uranium"
58+ ${jq}/bin/jq --arg out "$out" '.build=$out' >"$out/version.json" <<'EOF'
59+ ${builtins.toJSON {
60+ cura = version;
61+ cura_version = version;
62+ binarydata = curaBinaryDataVersion;
63+ engine = curaengine.version;
64+ libarcus = libarcusLulzbot.version;
65+ libsavitar = libsavitarLulzbot.version;
66+ uranium = uraniumLulzbot.version;
67+ }}
68+ EOF
69+ '';
70+
71+ meta = with lib; {
72+ description = "3D printer / slicing GUI built on top of the Uranium framework";
73+ homepage = https://code.alephobjects.com/diffusion/CURA/;
74+ license = licenses.agpl3; # a partial relicense to LGPL has happened, but not certain that all AGPL bits are expunged
75+ platforms = platforms.linux;
76+ maintainers = with maintainers; [ chaduffy ];
77+ };
78+}