nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 242 lines 6.4 kB view raw
1{ 2 stdenv, 3 lib, 4 binutils, 5 fetchFromGitHub, 6 cmake, 7 pkg-config, 8 wrapGAppsHook3, 9 boost186, 10 cereal, 11 cgal, 12 curl, 13 dbus, 14 eigen, 15 expat, 16 glew, 17 glib, 18 glib-networking, 19 gmp, 20 gtk3, 21 hicolor-icon-theme, 22 ilmbase, 23 libpng, 24 mpfr, 25 nanosvg, 26 nlopt, 27 opencascade-occt_7_6_1, 28 openvdb, 29 qhull, 30 tbb_2021, 31 wxGTK32, 32 xorg, 33 libbgcode, 34 heatshrink, 35 catch2_3, 36 webkitgtk_4_1, 37 ctestCheckHook, 38 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, 39 systemd, 40 udevCheckHook, 41 z3, 42 wxGTK-override ? null, 43 opencascade-override ? null, 44}: 45let 46 nanosvg-fltk = nanosvg.overrideAttrs (old: { 47 pname = "nanosvg-fltk"; 48 version = "unstable-2022-12-22"; 49 50 src = fetchFromGitHub { 51 owner = "fltk"; 52 repo = "nanosvg"; 53 rev = "abcd277ea45e9098bed752cf9c6875b533c0892f"; 54 hash = "sha256-WNdAYu66ggpSYJ8Kt57yEA4mSTv+Rvzj9Rm1q765HpY="; 55 }; 56 }); 57 openvdb_tbb_2021_8 = openvdb.override { tbb = tbb_2021; }; 58 wxGTK-override' = if wxGTK-override == null then wxGTK32 else wxGTK-override; 59 opencascade-override' = 60 if opencascade-override == null then opencascade-occt_7_6_1 else opencascade-override; 61in 62stdenv.mkDerivation (finalAttrs: { 63 pname = "prusa-slicer"; 64 version = "2.9.2"; 65 66 src = fetchFromGitHub { 67 owner = "prusa3d"; 68 repo = "PrusaSlicer"; 69 hash = "sha256-j/fdEgcFq0nWBLpyapwZIbBIXCnqEWV6Tk+6sTHk/Bc="; 70 rev = "version_${finalAttrs.version}"; 71 }; 72 73 # only applies to prusa slicer because super-slicer overrides *all* patches 74 patches = [ 75 # https://github.com/NixOS/nixpkgs/issues/415703 76 # https://gitlab.archlinux.org/archlinux/packaging/packages/prusa-slicer/-/merge_requests/5 77 ./allow_wayland.patch 78 ]; 79 80 # (not applicable to super-slicer fork) 81 postPatch = lib.optionalString (finalAttrs.pname == "prusa-slicer") ( 82 # Patch required for GCC 14, but breaks on clang 83 lib.optionalString stdenv.cc.isGNU '' 84 substituteInPlace src/slic3r-arrange/include/arrange/DataStoreTraits.hpp \ 85 --replace-fail \ 86 "WritableDataStoreTraits<ArrItem>::template set" \ 87 "WritableDataStoreTraits<ArrItem>::set" 88 '' 89 # Make Gcode viewer open newer bgcode files. 90 + '' 91 substituteInPlace src/platform/unix/PrusaGcodeviewer.desktop \ 92 --replace-fail 'MimeType=text/x.gcode;' 'MimeType=application/x-bgcode;text/x.gcode;' 93 '' 94 ); 95 96 nativeBuildInputs = [ 97 cmake 98 pkg-config 99 wrapGAppsHook3 100 wxGTK-override' 101 udevCheckHook 102 ]; 103 104 buildInputs = [ 105 binutils 106 boost186 # does not build with 1.87, see https://github.com/prusa3d/PrusaSlicer/issues/13799 107 cereal 108 cgal 109 curl 110 dbus 111 eigen 112 expat 113 glew 114 glib 115 glib-networking 116 gmp 117 gtk3 118 hicolor-icon-theme 119 ilmbase 120 libpng 121 mpfr 122 nanosvg-fltk 123 nlopt 124 opencascade-override' 125 openvdb_tbb_2021_8 126 qhull 127 tbb_2021 128 wxGTK-override' 129 xorg.libX11 130 libbgcode 131 heatshrink 132 catch2_3 133 webkitgtk_4_1 134 z3 135 ] 136 ++ lib.optionals withSystemd [ 137 systemd 138 ]; 139 140 strictDeps = true; 141 142 separateDebugInfo = true; 143 144 doInstallCheck = true; 145 146 # The build system uses custom logic - defined in 147 # cmake/modules/FindNLopt.cmake in the package source - for finding the nlopt 148 # library, which doesn't pick up the package in the nix store. We 149 # additionally need to set the path via the NLOPT environment variable. 150 NLOPT = nlopt; 151 152 # prusa-slicer uses dlopen on `libudev.so` at runtime 153 NIX_LDFLAGS = lib.optionalString withSystemd "-ludev"; 154 155 prePatch = '' 156 # Since version 2.5.0 of nlopt we need to link to libnlopt, as libnlopt_cxx 157 # now seems to be integrated into the main lib. 158 sed -i 's|nlopt_cxx|nlopt|g' cmake/modules/FindNLopt.cmake 159 160 # Disable slic3r_jobs_tests.cpp as the test fails sometimes 161 sed -i 's|slic3r_jobs_tests.cpp||g' tests/slic3rutils/CMakeLists.txt 162 163 # prusa-slicer expects the OCCTWrapper shared library in the same folder as 164 # the executable when loading STEP files. We force the loader to find it in 165 # the usual locations (i.e. LD_LIBRARY_PATH) instead. See the manpage 166 # dlopen(3) for context. 167 if [ -f "src/libslic3r/Format/STEP.cpp" ]; then 168 substituteInPlace src/libslic3r/Format/STEP.cpp \ 169 --replace-fail 'libpath /= "OCCTWrapper.so";' 'libpath = "OCCTWrapper.so";' 170 fi 171 # https://github.com/prusa3d/PrusaSlicer/issues/9581 172 if [ -f "cmake/modules/FindEXPAT.cmake" ]; then 173 rm cmake/modules/FindEXPAT.cmake 174 fi 175 176 # Fix resources folder location on macOS 177 substituteInPlace src/${ 178 if finalAttrs.pname == "prusa-slicer" then "CLI/Setup.cpp" else "PrusaSlicer.cpp" 179 } \ 180 --replace-fail "#ifdef __APPLE__" "#if 0" 181 ''; 182 183 cmakeFlags = [ 184 "-DSLIC3R_STATIC=0" 185 "-DSLIC3R_FHS=1" 186 "-DSLIC3R_GTK=3" 187 "-DCMAKE_CXX_FLAGS=-DBOOST_LOG_DYN_LINK" 188 ]; 189 190 postInstall = '' 191 ln -s "$out/bin/prusa-slicer" "$out/bin/prusa-gcodeviewer" 192 193 mkdir -p "$out/lib" 194 mv -v $out/bin/*.* $out/lib/ 195 196 mkdir -p "$out/share/pixmaps/" 197 ln -s "$out/share/PrusaSlicer/icons/PrusaSlicer.png" "$out/share/pixmaps/PrusaSlicer.png" 198 ln -s "$out/share/PrusaSlicer/icons/PrusaSlicer-gcodeviewer_192px.png" "$out/share/pixmaps/PrusaSlicer-gcodeviewer.png" 199 200 mkdir -p "$out"/share/mime/packages 201 cat << EOF > "$out"/share/mime/packages/prusa-gcode-viewer.xml 202 <?xml version="1.0" encoding="UTF-8"?> 203 <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> 204 <mime-type type="application/x-bgcode"> 205 <comment xml:lang="en">Binary G-code file</comment> 206 <glob pattern="*.bgcode"/> 207 </mime-type> 208 </mime-info> 209 EOF 210 ''; 211 212 preFixup = '' 213 gappsWrapperArgs+=( 214 --prefix LD_LIBRARY_PATH : "$out/lib" 215 ) 216 ''; 217 218 doCheck = true; 219 nativeCheckInputs = [ ctestCheckHook ]; 220 checkFlags = [ 221 "--force-new-ctest-process" 222 "-E" 223 "libslic3r_tests|sla_print_tests" 224 ]; 225 226 meta = 227 with lib; 228 { 229 description = "G-code generator for 3D printer"; 230 homepage = "https://github.com/prusa3d/PrusaSlicer"; 231 license = licenses.agpl3Plus; 232 maintainers = with maintainers; [ 233 tweber 234 tmarkus 235 fliegendewurst 236 ]; 237 platforms = platforms.unix; 238 } 239 // lib.optionalAttrs (stdenv.hostPlatform.isDarwin) { 240 mainProgram = "PrusaSlicer"; 241 }; 242})