@@ -1,58 +1,66 @@
1−{ stdenv, fetchurl, dpkg, bash, python27Packages }:
1+{ lib, fetchgit, curaengineLulzbot, cmake, jq, python3Packages, qtbase, qtquickcontrols2 }:
22
33let
4− py = python27Packages;
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+ curaengine = curaengineLulzbot;
12+ libarcus = python3Packages.libarcusLulzbot;
13+ uranium = python3Packages.uraniumLulzbot;
14+ libsavitar = python3Packages.libsavitarLulzbot;
515in
6−stdenv.mkDerivation rec {
16+python3Packages.buildPythonApplication rec {
717 name = "cura-lulzbot-${version}";
8− version = "15.02.1-1.03-5064";
9−
10− src =
11− if stdenv.hostPlatform.system == "x86_64-linux" then
12− fetchurl {
13− url = "https://download.alephobjects.com/ao/aodeb/dists/jessie/main/binary-amd64/cura_${version}_amd64.deb";
14− sha256 = "1gsfidg3gim5pjbl82vkh0cw4ya253m4p7nirm8nr6yjrsirkzxg";
15− }
16− else if stdenv.hostPlatform.system == "i686-linux" then
17− fetchurl {
18− url = "http://download.alephobjects.com/ao/aodeb/dists/jessie/main/binary-i386/cura_${version}_i386.deb";
19− sha256 = "0xd3df6bxq4rijgvsqvps454jkc1nzhxbdzzj6j2w317ppsbhyc1";
20− }
21− else throw "${name} is not supported on ${stdenv.hostPlatform.system}";
22−
23− python_deps = with py; [ pyopengl pyserial numpy wxPython30 power setuptools ];
24− pythonPath = python_deps;
25− propagatedBuildInputs = python_deps;
26− buildInputs = [ dpkg bash py.wrapPython ];
18+ version = "3.6.18";
2719
28− phases = [ "unpackPhase" "installPhase" ];
29− unpackPhase = "dpkg-deb -x ${src} ./";
20+ src = fetchgit {
21+ url = https://code.alephobjects.com/source/cura-lulzbot.git;
22+ rev = "71f1ac5a2b9f535175a3858a565930348358a9ca";
23+ sha256 = "0by06fpxvdgy858lwhsccbmvkdq67j2s1cz8v6jnrnjrsxk7vzka";
24+ };
3025
31− installPhase = ''
32− mkdir -p $out/bin
33− cp -r usr/share $out/share
34− find $out/share -type f -exec sed -i 's|/usr/share/cura|$out/share/cura|g' "{}" \;
26+ format = "other"; # using cmake to build
27+ buildInputs = [ qtbase qtquickcontrols2 ];
28+ # numpy-stl temporarily disabled due to https://code.alephobjects.com/T8415
29+ propagatedBuildInputs = with python3Packages; [ pyserial requests zeroconf ] ++ [ libsavitar uranium libarcus ]; # numpy-stl
30+ nativeBuildInputs = [ cmake python3Packages.wrapPython ];
3531
36− cat <<EOT > $out/bin/cura
37− #!${bash}/bin/bash
38− PYTHONPATH=$PYTHONPATH:$out/share/cura ${py.python}/bin/python $out/share/cura/cura.py "\$@"
39− EOT
32+ cmakeFlags = [
33+ "-DURANIUM_DIR=${uranium.src}"
34+ "-DCURA_VERSION=${version}"
35+ ];
4036
41− chmod 555 $out/bin/cura
37+ postPatch = ''
38+ sed -i 's,/python''${PYTHON_VERSION_MAJOR}/dist-packages,/python''${PYTHON_VERSION_MAJOR}.''${PYTHON_VERSION_MINOR}/site-packages,g' CMakeLists.txt
39+ sed -i 's, executable_name = .*, executable_name = "${curaengine}/bin/CuraEngine",' plugins/CuraEngineBackend/CuraEngineBackend.py
4240 '';
4341
44− meta = with stdenv.lib; {
45− description = "3D printing host software for the Lulzbot";
46−
47− longDescription = ''
48− Cura LulzBot Edition is a fork of the 3D printing/slicing
49− software from Ultimaker, with changes to support 3D printers
50− from Aleph Objects.
51− '';
42+ preFixup = ''
43+ substituteInPlace "$out/bin/cura-lulzbot" --replace 'import cura.CuraApplication' 'import Savitar; import cura.CuraApplication'
44+ ln -sT "${curaBinaryData}/cura/resources/firmware" "$out/share/cura/resources/firmware"
45+ ln -sT "${uranium}/share/uranium" "$out/share/uranium"
46+ ${jq}/bin/jq --arg out "$out" '.build=$out' >"$out/version.json" <<'EOF'
47+ ${builtins.toJSON {
48+ cura = version;
49+ cura_version = version;
50+ binarydata = curaBinaryDataVersion;
51+ engine = curaengine.version;
52+ libarcus = libarcus.version;
53+ libsavitar = libsavitar.version;
54+ uranium = uranium.version;
55+ }}
56+ EOF
57+ '';
5258
53− homepage = https://www.lulzbot.com/cura/;
54− license = licenses.agpl3;
59+ meta = with lib; {
60+ description = "3D printer / slicing GUI built on top of the Uranium framework";
61+ homepage = https://code.alephobjects.com/diffusion/CURA/;
62+ license = licenses.agpl3; # a partial relicense to LGPL has happened, but not certain that all AGPL bits are expunged
5563 platforms = platforms.linux;
56− maintainers = with maintainers; [ pjones ];
64+ maintainers = with maintainers; [ chaduffy ];
5765 };
5866}