Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cura 5.2.1 #208124

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Cura 5.2.1 #208124

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions pkgs/applications/misc/cura/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,47 @@

mkDerivation rec {
pname = "cura";
version = "4.13.1";
version = "5.2.1";

src = fetchFromGitHub {
owner = "Ultimaker";
repo = "Cura";
rev = version;
sha256 = "sha256-R88SdAxx3tkQCDInrFTKad1tPSDTSYaVAPUVmdk94Xk=";
sha256 = "01qjxjdzp4n8rs5phwi3kdkf222w4qwcfnb7mvfawyd2yakqim6h";
};

materials = fetchFromGitHub {
owner = "Ultimaker";
repo = "fdm_materials";
rev = "4.13.2";
sha256 = "sha256-7y4OcbeQHv+loJ4cMgPU0e818Zsv90EwARdztNWS8zM=";
rev = "5.2.0";
sha256 = "0xn6mdn3kwabssad8rpmnmx3kgzh9ldy0kgb6qr2bcd6cklg4anp";
};

buildInputs = [ qtbase qtquickcontrols2 qtgraphicaleffects ];
propagatedBuildInputs = with python3.pkgs; [
libsavitar numpy-stl pyserial requests uranium zeroconf pynest2d
sentry-sdk trimesh keyring
keyring
# libsavitar # TODO? Alpine apparently currently ignores it, see: https://git.alpinelinux.org/aports/tree/testing/cura/APKBUILD?id=2474a2fc7f819a7c8a31ccc561b95955dec5101f
numpy-stl
pynest2d
pyqt6
pyserial
requests
sentry-sdk
trimesh
uranium
zeroconf
] ++ plugins;
nativeBuildInputs = [ cmake python3.pkgs.wrapPython ];

cmakeFlags = [
"-DURANIUM_DIR=${python3.pkgs.uranium.src}"
"-DCURA_VERSION=${version}"
# The upstream code checks for an exact python version and errors out
# if we don't have that and do not pass `Python_VERSION` explicitly.
"-DPython_VERSION=${python3.pythonVersion}"
# Set install location to not be the global Python install dir
# (which is read-only in the nix store); see:
"-DPython_SITELIB_LOCAL=${placeholder "out"}/${python3.sitePackages}"
];

makeWrapperArgs = [
Expand All @@ -52,7 +67,11 @@ mkDerivation rec {

postFixup = ''
wrapPythonPrograms
wrapQtApp $out/bin/cura

# find $out/bin
Copy link
Member

@LunNova LunNova Dec 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover debug code?

Missed that this isn't ready for review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've only done the Cura dependencies, not Cura itself.

# exit 1

wrapQtApp $out/bin/cura_app.py
'';

meta = with lib; {
Expand Down
26 changes: 26 additions & 0 deletions pkgs/applications/misc/curaengine/cmake/FindStb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Finds the Stb utility library on your computer.
#
# This script exports the following parameters for use if you find the Stb
# package:
# - Stb_FOUND: Whether Stb has been found on your computer.
# - Stb_INCLUDE_DIRS: The directory where the header files of Stb are located.

find_package(PkgConfig QUIET)
pkg_check_modules(PC_Stb QUIET Stb)

find_path(Stb_INCLUDE_DIRS stb_image_resize.h #Search for something that is a little less prone to false positives than just stb.h.
HINTS ${PC_Stb_INCLUDEDIR} ${PC_Stb_INCLUDE_DIRS}
PATHS "$ENV{PROGRAMFILES}" "$ENV{PROGRAMW6432}" "/usr/include"
PATH_SUFFIXES include/stb stb include
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Stb DEFAULT_MSG Stb_INCLUDE_DIRS)

mark_as_advanced(Stb_INCLUDE_DIRS)

if(Stb_FOUND)
message(STATUS "Found Stb installation at: ${Stb_INCLUDE_DIRS}")
add_library(Stb::Stb INTERFACE IMPORTED)
set_target_properties(Stb::Stb PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Stb_INCLUDE_DIRS})
endif()
101 changes: 95 additions & 6 deletions pkgs/applications/misc/curaengine/default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,109 @@
{ lib, stdenv, fetchFromGitHub, cmake, libarcus, stb, protobuf }:
{ stdenv
, lib
, fetchFromGitHub
, fetchurl
, fetchpatch
, runCommand
, cmake

# Dependencies
, boost
, clipper
, libarcus
, protobuf
, range-v3
, rapidjson
, stb
, spdlog
}:
let
# curaengine maintained its own `Findstb.cmake` in the past,
# but it was remove as part of their switch to `conan` in
# https://github.com/Ultimaker/CuraEngine/commit/9f46b87fc9c85bfa46a678927f076644f6102e94
# We revive it here from the parent commit since it's unclear
# how nixpkgs's cmake should find it otherwise.
FindStbCmake = ./cmake/FindStb.cmake;

# Make a directory that contains all of the extra `.cmake` files,
# so we can provide it with `-DCMAKE_MODULE_PATH`.
# Note that CMake is case sensitive on non-Windows for these file names!
ExtraFindCmakeDir = runCommand "curaengine-cmake-dir" {} ''
mkdir -p $out
ln -s ${FindStbCmake} $out/FindStb.cmake
'';

in
stdenv.mkDerivation rec {
pname = "curaengine";
version = "4.13.1";
version = "5.2.1";

src = fetchFromGitHub {
owner = "Ultimaker";
repo = "CuraEngine";
rev = version;
sha256 = "sha256-dx0Q6cuA66lG4nwR7quW5Tvs9sdxjdV4gtpxXirI4nY=";
sha256 = "03267hm5vjd6fs2ggdn8rc92xrx0ilfkpvmdf2lf0f0w6p3s534w";
};

nativeBuildInputs = [ cmake ];
buildInputs = [ libarcus stb protobuf ];
patches = [
# Imported from Alpine:
(fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/community/curaengine/cmake-helpers.patch?id=0c8c8327f0fd55c277778637f444a22961af3fcf";
name = "curaengine-cmake-helpers.patch";
sha256 = "1zn4yipcl6jxzs0bjclss64wcyq71h8sgik2bbb94jl4pnammvmm";
})
# Imported from Alpine:
(fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/community/curaengine/cmake.patch?id=0c8c8327f0fd55c277778637f444a22961af3fcf";
name = "curaengine-cmake.patch";
sha256 = "1g1f54h9z50c9246nz1vfnz4wkds3j87xbv6rlmm4wbcbcg107ij";
})
];

# The `cmake.patch` does
# -find_package(stb REQUIRED)
# We insert it back here (as a new line after RapidJSON), but with capital `S`:
# find_package(Stb REQUIRED)
# so that our `FindStb.cmake` from above (passed via `DCMAKE_MODULE_PATH`)
# will pick up the `find_package()` and find it.
#
# The `cmake.patch` also does
# - stb::stb
# so we insert it back here (again with uppercase `S`) after `Boost:boost`.
postPatch = ''
sed -i \
-e "s,find_package(RapidJSON REQUIRED),find_package(RapidJSON REQUIRED)\nfind_package(Stb REQUIRED)," \
-e "s,Boost::boost$,Boost::boost\nStb::Stb," \
CMakeLists.txt
'';

nativeBuildInputs = [
cmake
boost
range-v3
rapidjson
stb
];
buildInputs = [
clipper
libarcus
protobuf
spdlog # Apparently available in both compiled-library and header-only version; assuming the former for now (which as per its README speeds up compiles), so not putting it into `nativeBuildInputs`.
];

# The `cmake-helpers.patch` added above adds `FindClipper.cmake` which calls
# CMake's `FIND_PATH()` but only on *environment* variables (`$ENV{CLIPPER_PATH}`),
# not CMake variables, so we cannot set this one with `cmakeFlags = [ "-D..." ]`
# and instead set it here as an environment variable.
CLIPPER_PATH = lib.getLib clipper;

cmakeFlags = [
"-DCURA_ENGINE_VERSION=${version}"

# See comments on `ExtraFindCmakeDir` above.
"-DCMAKE_MODULE_PATH=${ExtraFindCmakeDir}"

cmakeFlags = [ "-DCURA_ENGINE_VERSION=${version}" ];
# "-DCMAKE_VERBOSE_MAKEFILE=1" # enable for easier debugging of build failures
];

meta = with lib; {
description = "A powerful, fast and robust engine for processing 3D models into 3D printing instruction";
Expand Down
29 changes: 18 additions & 11 deletions pkgs/development/python-modules/libarcus/default.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
{ lib, buildPythonPackage, python, fetchFromGitHub
, fetchpatch
, cmake, sip_4, protobuf, pythonOlder }:
, cmake, sip, protobuf, pythonOlder }:

buildPythonPackage rec {
pname = "libarcus";
version = "4.12.0";
version = "5.2.0";
format = "other";

src = fetchFromGitHub {
owner = "Ultimaker";
repo = "libArcus";
rev = version;
sha256 = "sha256-X33ptwYj9YkVWqUDPP+Ic+hoIb+rwsLdQXvHLA9z+3w=";
sha256 = "1rcymbgk3fijmsa1vdicgrcp45igvrsh30rld989mmqd04chmr4x";
};

patches = [
# Fix build against protobuf 3.18+
# https://github.com/Ultimaker/libArcus/issues/121
# Imported from Alpine:
(fetchpatch {
url = "https://raw.githubusercontent.com/coryan/vcpkg/f69b85aa403b04e7d442c90db3418d484e44024f/ports/arcus/0001-fix-protobuf-deprecated.patch";
sha256 = "0bqj7pxzpwsamknd6gadj419x6mwx8wnlfzg4zqn6cax3cmasjb2";
url = "https://git.alpinelinux.org/aports/plain/community/libarcus/cmake-build.patch?id=ad078141cb02378fe42aedea4271f4beb2fd2f01";
name = "libarcus-cmake-build.patch";
sha256 = "0v0cxhaazq29psq9idcv16ngvp30j3h5xghx8vb9n79zl1a9b82n";
})
# Imported from Alpine:
(fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/community/libarcus/ArcusConfig.patch?id=2a3bb5dbbb9f049578f7d2ca55f22dc7db635bfd";
name = "libarcus-ArcusConfig.patch";
sha256 = "1yq4a3r6q3bq22adsmzh9048q6db9qrwp1cl51xp1x7j9b9cxgda";
})
];

disabled = pythonOlder "3.4";

propagatedBuildInputs = [ sip_4 ];
propagatedBuildInputs = [ sip ];
nativeBuildInputs = [ cmake ];
buildInputs = [ protobuf ];

postPatch = ''
sed -i 's#''${Python3_SITEARCH}#${placeholder "out"}/${python.sitePackages}#' cmake/SIPMacros.cmake
'';
cmakeFlags = [
# The `libarcus-cmake-build.patch` above adds a line with `set_target_properties()` that requires this.
"-DARCUS_VERSION=${version}"
];

meta = with lib; {
description = "Communication library between internal components for Ultimaker software";
Expand Down
22 changes: 14 additions & 8 deletions pkgs/development/python-modules/libsavitar/default.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
{ lib, buildPythonPackage, python, pythonOlder, fetchFromGitHub, cmake, sip_4 }:
{ lib, buildPythonPackage, python, pythonOlder, fetchFromGitHub, cmake, sip }:

buildPythonPackage rec {
pname = "libsavitar";
version = "4.12.0";
version = "5.0.0";
format = "other";

src = fetchFromGitHub {
owner = "Ultimaker";
repo = "libSavitar";
rev = version;
sha256 = "sha256-MAA1WtGED6lvU6N4BE6wwY1aYaFrCq/gkmQFz3VWqNA=";
sha256 = "05c0y2wmn094vnd3aymnwishf74l7pyal0fnwf4lhs6i2y59km38";
};

postPatch = ''
sed -i 's#''${Python3_SITEARCH}#${placeholder "out"}/${python.sitePackages}#' cmake/SIPMacros.cmake
'';

nativeBuildInputs = [ cmake ];

propagatedBuildInputs = [ sip_4 ];
propagatedBuildInputs = [ sip ];

cmakeFlags = [
# The upstream code checks for an exact python version and errors out
# if we don't have that and do not pass `Python_VERSION` explicitly:
# https://github.com/Ultimaker/libSavitar/commit/a7ee88779574769e8c4cd82281f96d53fc4f742a#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR27
"-DPython_VERSION=${python.pythonVersion}"
# Set install location to not be the global Python install dir
# (which is read-only in the nix store); see:
"-DPython_SITELIB_LOCAL=${placeholder "out"}/${python.sitePackages}"
];

disabled = pythonOlder "3.4.0";

Expand Down
63 changes: 54 additions & 9 deletions pkgs/development/python-modules/uranium/default.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,76 @@
{ lib, buildPythonPackage, fetchFromGitHub, python, cmake
, fetchpatch
, pyqt5, numpy, scipy, shapely, libarcus, cryptography, doxygen, gettext, pythonOlder }:

buildPythonPackage rec {
version = "4.12.0";
version = "5.2.0";
pname = "uranium";
format = "other";

src = fetchFromGitHub {
owner = "Ultimaker";
repo = "Uranium";
rev = version;
sha256 = "sha256-SE9xqrloPXIRTJiiqUdRKFmb4c0OjmJK5CMn6VXMFmk=";
sha256 = "07npd2067zz968snw8gjazaibmqp5vjspd6k4nysglpsnfd9bfsj";
};

patches = [
# Imported from Alpine:
(fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/testing/uranium/cmake-helpers.patch?id=7972f49701755aacaace54a72605176cba896999";
name = "uranium-cmake-helpers.patch";
sha256 = "0ivawvf4kyhwspz1jyvy7xb3s6lfhzg3dynnh82ax95nj6rzmi6p";
})
# Imported from Alpine:
(fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/testing/uranium/cmake.patch?id=7972f49701755aacaace54a72605176cba896999";
name = "uranium-cmake.patch";
sha256 = "145wgq32hh1gjcnnhnfcm8mzg3fgcv36zxmdjsg25sssbsc73vbk";
})
];

disabled = pythonOlder "3.5.0";

buildInputs = [ python gettext ];
propagatedBuildInputs = [ pyqt5 numpy scipy shapely libarcus cryptography ];
nativeBuildInputs = [ cmake doxygen ];

postPatch = ''
sed -i 's,/python''${PYTHON_VERSION_MAJOR}/dist-packages,/python''${PYTHON_VERSION_MAJOR}.''${PYTHON_VERSION_MINOR}/site-packages,g' CMakeLists.txt
sed -i \
-e "s,Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)).*,Resources.addSearchPath(\"$out/share/uranium/resources\")," \
-e "s,self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)).*,self._plugin_registry.addPluginLocation(\"$out/lib/uranium/plugins\")," \
UM/Application.py
'';
postPatch = lib.concatStrings [
# See comment on setting of `-DPython_SITELIB_LOCAL` below.
''
sed -i \
-e "s,Python_SITELIB,Python_SITELIB_LOCAL," \
CMakeLists.txt
''
# `uranium`'s relative search paths need to be fixed because these
# python files are installed in `$PREFIX/lib/python3.10/site-packages/UM/`
# but the dirs they seek are in `$PREFIX/share/` and `$PREFIX/lib/uranium/`.
''
sed -i \
-e "s,Resources.addSearchPath(str(Path(__file__).parent.parent.joinpath("resources"))),Resources.addSearchPath(\"$out/share/uranium/resources\")," \
-e "s,self._plugin_registry.addPluginLocation(str(Path(__file__).parent.parent.joinpath("plugins"))),self._plugin_registry.addPluginLocation(\"$out/lib/uranium/plugins\")," \
UM/Application.py
''
];

cmakeFlags = [
# Set install location to not be the global Python install dir
# (which is read-only in the nix store); see:
# Note the `cmake.patch` above changes the variable that needs to be set
# from `Python_SITELIB_LOCAL` to `Python_SITELIB`,
# and our `postPatch` above undoes that, because otherwise we get error:
# CMake Error at cmake_install.cmake:53 (file):
# file INSTALL cannot make directory
# "/nix/store/al6g1zbk8li6p8mcyp0h60d08jaahf8c-python3-3.10.9/lib/python3.10/site-packages/UM":
# Permission denied.
"-DPython_SITELIB_LOCAL=${placeholder "out"}/${python.sitePackages}"

# Fixes cmake warning `GETTEXT_MSGINIT_EXECUTABLE is undefined!`
"-DGETTEXT_MSGINIT_EXECUTABLE=msginit"

# Fixes cmake warning about its absence.
"-DCURA_BINARY_DATA_DIRECTORY=${placeholder "out"}/share/cuda"
];

meta = with lib; {
description = "A Python framework for building Desktop applications";
Expand Down