Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 binutils, 5 fetchFromGitHub, 6 cmake, 7 ninja, 8 pkg-config, 9 wrapGAppsHook3, 10 boost186, 11 cereal, 12 cgal, 13 curl, 14 dbus, 15 eigen, 16 expat, 17 ffmpeg, 18 gcc-unwrapped, 19 glew, 20 glfw, 21 glib, 22 glib-networking, 23 gmp, 24 gst_all_1, 25 gtest, 26 gtk3, 27 hicolor-icon-theme, 28 ilmbase, 29 libpng, 30 mpfr, 31 nlopt, 32 opencascade-occt_7_6, 33 openvdb, 34 opencv, 35 pcre, 36 systemd, 37 tbb_2021, 38 webkitgtk_4_0, 39 wxGTK31, 40 xorg, 41 withSystemd ? stdenv.hostPlatform.isLinux, 42}: 43let 44 wxGTK' = 45 (wxGTK31.override { 46 withCurl = true; 47 withPrivateFonts = true; 48 withWebKit = true; 49 }).overrideAttrs 50 (old: { 51 configureFlags = old.configureFlags ++ [ 52 # Disable noisy debug dialogs 53 "--enable-debug=no" 54 ]; 55 }); 56in 57stdenv.mkDerivation rec { 58 pname = "bambu-studio"; 59 version = "01.10.02.76"; 60 61 src = fetchFromGitHub { 62 owner = "bambulab"; 63 repo = "BambuStudio"; 64 rev = "v${version}"; 65 hash = "sha256-LvAi3I5lnnumhOUagyej28uVy0Lgd3e19HNQXOUWSvQ="; 66 }; 67 68 nativeBuildInputs = [ 69 cmake 70 ninja 71 pkg-config 72 wrapGAppsHook3 73 ]; 74 75 buildInputs = [ 76 binutils 77 boost186 78 cereal 79 cgal 80 curl 81 dbus 82 eigen 83 expat 84 ffmpeg 85 gcc-unwrapped 86 glew 87 glfw 88 glib 89 glib-networking 90 gmp 91 gst_all_1.gstreamer 92 gst_all_1.gst-plugins-base 93 gst_all_1.gst-plugins-bad 94 gst_all_1.gst-plugins-good 95 gtk3 96 hicolor-icon-theme 97 ilmbase 98 libpng 99 mpfr 100 nlopt 101 opencascade-occt_7_6 102 openvdb 103 pcre 104 tbb_2021 105 webkitgtk_4_0 106 wxGTK' 107 xorg.libX11 108 opencv.cxxdev 109 ] 110 ++ lib.optionals withSystemd [ systemd ] 111 ++ checkInputs; 112 113 patches = [ 114 # Fix for webkitgtk linking 115 ./patches/0001-not-for-upstream-CMakeLists-Link-against-webkit2gtk-.patch 116 # Fix an issue with 117 ./patches/dont-link-opencv-world-bambu.patch 118 # Don't link osmesa 119 ./patches/no-osmesa.patch 120 # Fix the build with newer Boost versions. All but one commit is 121 # from <https://github.com/bambulab/BambuStudio/pull/3968>. 122 ./0001-Replace-deprecated-boost-filesystem-string_file.hpp-.patch 123 ./0002-Replace-deprecated-Boost-methods-options.patch 124 ./0003-Fix-additional-Boost-upgrade-issues.patch 125 ./0004-Remove-deprecated-Boost-filesystem-header.patch 126 ]; 127 128 doCheck = true; 129 checkInputs = [ gtest ]; 130 131 separateDebugInfo = true; 132 133 # The build system uses custom logic - defined in 134 # cmake/modules/FindNLopt.cmake in the package source - for finding the nlopt 135 # library, which doesn't pick up the package in the nix store. We 136 # additionally need to set the path via the NLOPT environment variable. 137 NLOPT = nlopt; 138 139 NIX_CFLAGS_COMPILE = toString [ 140 "-DBOOST_TIMER_ENABLE_DEPRECATED" 141 # Disable compiler warnings that clutter the build log. 142 # It seems to be a known issue for Eigen: 143 # http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1221 144 "-Wno-ignored-attributes" 145 "-I${opencv.out}/include/opencv4" 146 ]; 147 148 # prusa-slicer uses dlopen on `libudev.so` at runtime 149 NIX_LDFLAGS = lib.optionalString withSystemd "-ludev"; 150 151 # TODO: macOS 152 prePatch = '' 153 # Since version 2.5.0 of nlopt we need to link to libnlopt, as libnlopt_cxx 154 # now seems to be integrated into the main lib. 155 sed -i 's|nlopt_cxx|nlopt|g' cmake/modules/FindNLopt.cmake 156 ''; 157 158 cmakeFlags = [ 159 "-DSLIC3R_STATIC=0" 160 "-DSLIC3R_FHS=1" 161 "-DSLIC3R_GTK=3" 162 163 # Skips installing ffmpeg, since we BYO. 164 "-DFLATPAK=1" 165 166 # BambuStudio-specific 167 "-DBBL_RELEASE_TO_PUBLIC=1" 168 "-DBBL_INTERNAL_TESTING=0" 169 "-DDEP_WX_GTK3=ON" 170 "-DSLIC3R_BUILD_TESTS=0" 171 "-DCMAKE_CXX_FLAGS=-DBOOST_LOG_DYN_LINK" 172 ]; 173 174 preFixup = '' 175 gappsWrapperArgs+=( 176 --prefix LD_LIBRARY_PATH : "$out/lib" 177 178 # Fixes intermittent crash 179 # The upstream setup links in glew statically 180 --prefix LD_PRELOAD : "${glew.out}/lib/libGLEW.so" 181 ) 182 ''; 183 184 # needed to prevent collisions between the LICENSE.txt files of 185 # bambu-studio and orca-slicer. 186 postInstall = '' 187 mv $out/LICENSE.txt $out/share/BambuStudio/LICENSE.txt 188 mv $out/README.md $out/share/BambuStudio/README.md 189 ''; 190 191 meta = { 192 description = "PC Software for BambuLab's 3D printers"; 193 homepage = "https://github.com/bambulab/BambuStudio"; 194 changelog = "https://github.com/bambulab/BambuStudio/releases/tag/v${version}"; 195 license = lib.licenses.agpl3Plus; 196 maintainers = with lib.maintainers; [ 197 zhaofengli 198 dsluijk 199 ]; 200 mainProgram = "bambu-studio"; 201 platforms = lib.platforms.linux; 202 }; 203}