From 8b7ae03a9562bee540544d0bc5b5ec1f963c76c9 Mon Sep 17 00:00:00 2001 From: liberodark Date: Tue, 31 Dec 2024 18:28:26 +0100 Subject: [PATCH] orca-slicer: fix gcc14 --- pkgs/by-name/or/orca-slicer/package.nix | 228 +++++++++++++++++++----- 1 file changed, 181 insertions(+), 47 deletions(-) diff --git a/pkgs/by-name/or/orca-slicer/package.nix b/pkgs/by-name/or/orca-slicer/package.nix index d6d8c4a93847d9..1f7705ef80511e 100644 --- a/pkgs/by-name/or/orca-slicer/package.nix +++ b/pkgs/by-name/or/orca-slicer/package.nix @@ -1,52 +1,186 @@ { + stdenv, lib, + binutils, fetchFromGitHub, - bambu-studio, + cmake, + pkg-config, + wrapGAppsHook3, + boost180, + cereal, + cgal, + curl, + dbus, + eigen, + expat, + ffmpeg, + gcc-unwrapped, + glew, + glfw, + glib, + glib-networking, + gmp, + gst_all_1, + gtest, + gtk3, + hicolor-icon-theme, + ilmbase, + libpng, + mesa, + mpfr, + nlopt, + opencascade-occt_7_6, + openvdb, + opencv, + pcre, + systemd, + tbb_2021_11, + webkitgtk_4_0, + wxGTK31, + xorg, + withSystemd ? stdenv.hostPlatform.isLinux, }: -bambu-studio.overrideAttrs ( - finalAttrs: previousAttrs: { - version = "2.2.0"; - pname = "orca-slicer"; - - src = fetchFromGitHub { - owner = "SoftFever"; - repo = "OrcaSlicer"; - rev = "v${finalAttrs.version}"; - hash = "sha256-h+cHWhrp894KEbb3ic2N4fNTn13WlOSYoMsaof0RvRI="; - }; - - patches = [ - # Fix for webkitgtk linking - ./patches/0001-not-for-upstream-CMakeLists-Link-against-webkit2gtk-.patch - ./patches/dont-link-opencv-world-orca.patch - ]; +let + wxGTK' = + (wxGTK31.override { + withCurl = true; + withPrivateFonts = true; + withWebKit = true; + }).overrideAttrs + (old: { + configureFlags = old.configureFlags ++ [ + # Disable noisy debug dialogs + "--enable-debug=no" + ]; + }); +in +stdenv.mkDerivation rec { + pname = "orca-slicer"; + version = "v2.2.0"; + + src = fetchFromGitHub { + owner = "SoftFever"; + repo = "OrcaSlicer"; + tag = version; + hash = "sha256-h+cHWhrp894KEbb3ic2N4fNTn13WlOSYoMsaof0RvRI="; + }; + + nativeBuildInputs = [ + cmake + pkg-config + wrapGAppsHook3 + ]; + + buildInputs = + [ + binutils + boost180 + cereal + cgal + curl + dbus + eigen + expat + ffmpeg + gcc-unwrapped + glew + glfw + glib + glib-networking + gmp + gst_all_1.gstreamer + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-bad + gst_all_1.gst-plugins-good + gtk3 + hicolor-icon-theme + ilmbase + libpng + mesa + mpfr + nlopt + opencascade-occt_7_6 + openvdb + pcre + tbb_2021_11 + webkitgtk_4_0 + wxGTK' + xorg.libX11 + opencv + ] + ++ lib.optionals withSystemd [ systemd ] + ++ checkInputs; + + patches = [ + # Fix for webkitgtk linking + ./patches/0001-not-for-upstream-CMakeLists-Link-against-webkit2gtk-.patch + ./patches/dont-link-opencv-world-orca.patch + ]; + + doCheck = true; + checkInputs = [ gtest ]; + + separateDebugInfo = true; - preFixup = '' - gappsWrapperArgs+=( - # Fixes blackscreen dialogs - --set WEBKIT_DISABLE_COMPOSITING_MODE 1 - ) - ''; - - cmakeFlags = lib.remove "-DFLATPAK=1" previousAttrs.cmakeFlags or [ ]; - - # needed to prevent collisions between the LICENSE.txt files of - # bambu-studio and orca-slicer. - postInstall = '' - mv $out/LICENSE.txt $out/share/OrcaSlicer/LICENSE.txt - ''; - - meta = with lib; { - description = "G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.)"; - homepage = "https://github.com/SoftFever/OrcaSlicer"; - license = licenses.agpl3Only; - maintainers = with maintainers; [ - zhaofengli - ovlach - pinpox - ]; - mainProgram = "orca-slicer"; - platforms = platforms.linux; - }; - } -) + NLOPT = nlopt; + + NIX_CFLAGS_COMPILE = toString [ + "-Wno-ignored-attributes" + "-I${opencv.out}/include/opencv4" + "-Wno-error=template-id-cdtor" + "-Wno-error=incompatible-pointer-types" + "-Wno-template-id-cdtor" + "-Wno-uninitialized" + "-Wno-unused-result" + "-Wno-deprecated-declarations" + "-DBOOST_ALLOW_DEPRECATED_HEADERS" + "-DBOOST_MATH_DISABLE_STD_FPCLASSIFY" + "-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS" + "-DBOOST_MATH_DISABLE_FLOAT128" + "-DBOOST_MATH_NO_QUAD_SUPPORT" + "-DBOOST_MATH_MAX_FLOAT128_DIGITS=0" + "-DBOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT" + "-DBOOST_MATH_DISABLE_FLOAT128_BUILTIN_FPCLASSIFY" + ]; + + NIX_LDFLAGS = lib.optionalString withSystemd "-ludev"; + + prePatch = '' + sed -i 's|nlopt_cxx|nlopt|g' cmake/modules/FindNLopt.cmake + ''; + + cmakeFlags = [ + "-DSLIC3R_STATIC=0" + "-DSLIC3R_FHS=1" + "-DSLIC3R_GTK=3" + "-DBBL_RELEASE_TO_PUBLIC=1" + "-DBBL_INTERNAL_TESTING=0" + "-DDEP_WX_GTK3=ON" + "-DSLIC3R_BUILD_TESTS=0" + "-DCMAKE_CXX_FLAGS=-DBOOST_LOG_DYN_LINK" + "-DCMAKE_CXX_FLAGS=-DGL_SILENCE_DEPRECATION" + "-DCMAKE_EXE_LINKER_FLAGS=-Wl,--no-as-needed" + ]; + + preFixup = '' + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "$out/lib" + --prefix LD_PRELOAD : "${glew.out}/lib/libGLEW.so" + --set WEBKIT_DISABLE_COMPOSITING_MODE 1 + ) + ''; + + meta = with lib; { + description = "G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.)"; + homepage = "https://github.com/SoftFever/OrcaSlicer"; + license = licenses.agpl3Only; + maintainers = with maintainers; [ + zhaofengli + ovlach + pinpox + liberodark + ]; + mainProgram = "orca-slicer"; + platforms = platforms.linux; + }; +}