Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 24.05-beta 108 lines 3.7 kB view raw
1{ lib 2, stdenv 3, wrapQtAppsHook 4, fetchFromGitHub 5, unstableGitUpdater 6, cmake 7, ninja 8, pkg-config 9, eigen 10, zlib 11, libpng 12, boost 13, guile 14, python 15, qtbase 16, darwin 17}: 18 19stdenv.mkDerivation { 20 pname = "libfive"; 21 version = "0-unstable-2024-03-28"; 22 23 src = fetchFromGitHub { 24 owner = "libfive"; 25 repo = "libfive"; 26 rev = "4c59b11667bbe8be9802f59697fa64bbfe1ea82d"; 27 hash = "sha256-scYSprozfC537vAXhMfWswyS3xivpoURWPhplH7yHIg="; 28 }; 29 30 nativeBuildInputs = [ wrapQtAppsHook cmake ninja pkg-config python.pkgs.pythonImportsCheckHook ]; 31 buildInputs = [ eigen zlib libpng boost guile python qtbase ] 32 ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk_11_0.frameworks.Cocoa ]; 33 34 preConfigure = '' 35 substituteInPlace studio/src/guile/interpreter.cpp \ 36 --replace '"libfive/bind/guile"' \ 37 '"libfive/bind/guile:${placeholder "out"}/${guile.siteCcacheDir}"' \ 38 --replace '(app_resource_dir + ":" + finder_build_dir).toLocal8Bit()' \ 39 '"libfive/bind/guile:${placeholder "out"}/${guile.siteCcacheDir}"' 40 41 substituteInPlace libfive/bind/guile/CMakeLists.txt \ 42 --replace "LIBFIVE_FRAMEWORK_DIR=$<TARGET_FILE_DIR:libfive>" \ 43 "LIBFIVE_FRAMEWORK_DIR=$out/lib" \ 44 --replace "LIBFIVE_STDLIB_DIR=$<TARGET_FILE_DIR:libfive-stdlib>" \ 45 "LIBFIVE_STDLIB_DIR=$out/lib" 46 47 substituteInPlace libfive/bind/python/CMakeLists.txt \ 48 --replace ' ''${PYTHON_SITE_PACKAGES_DIR}' \ 49 " $out/${python.sitePackages}" \ 50 51 substituteInPlace libfive/bind/python/libfive/ffi.py \ 52 --replace "os.path.join('libfive', folder)" \ 53 "os.path.join('$out/${python.sitePackages}/libfive', folder)" \ 54 55 export XDG_CACHE_HOME=$(mktemp -d)/.cache 56 ''; 57 58 cmakeFlags = [ 59 "-DGUILE_CCACHE_DIR=${placeholder "out"}/${guile.siteCcacheDir}" 60 ] ++ lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11") [ 61 # warning: 'aligned_alloc' is only available on macOS 10.15 or newer 62 "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15" 63 ]; 64 65 env = lib.optionalAttrs stdenv.cc.isClang { 66 NIX_CFLAGS_COMPILE = "-Wno-error=enum-constexpr-conversion"; 67 }; 68 69 postInstall = lib.optionalString stdenv.isDarwin '' 70 # No rules to install the mac app, so do it manually. 71 mkdir -p $out/Applications 72 cp -r studio/Studio.app $out/Applications/Studio.app 73 74 install_name_tool -add_rpath $out/lib $out/Applications/Studio.app/Contents/MacOS/Studio 75 76 makeWrapper $out/Applications/Studio.app/Contents/MacOS/Studio $out/bin/Studio 77 '' + '' 78 # Link "Studio" binary to "libfive-studio" to be more obvious: 79 ln -s "$out/bin/Studio" "$out/bin/libfive-studio" 80 81 # Create links since libfive looks for the library in a specific path. 82 mkdir -p "$out/${python.sitePackages}/libfive/src" 83 ln -s "$out"/lib/libfive.* "$out/${python.sitePackages}/libfive/src/" 84 mkdir -p "$out/${python.sitePackages}/libfive/stdlib" 85 ln -s "$out"/lib/libfive-stdlib.* "$out/${python.sitePackages}/libfive/stdlib/" 86 87 # Create links so Studio can find the bindings. 88 mkdir -p "$out/libfive/bind" 89 ln -s "$out/${python.sitePackages}" "$out/libfive/bind/python" 90 ''; 91 92 pythonImportsCheck = [ 93 "libfive" 94 "libfive.runner" 95 "libfive.shape" 96 "libfive.stdlib" 97 ]; 98 99 passthru.updateScript = unstableGitUpdater { }; 100 101 meta = with lib; { 102 description = "Infrastructure for solid modeling with F-Reps in C, C++, and Guile"; 103 homepage = "https://libfive.com/"; 104 maintainers = with maintainers; [ hodapp kovirobi wulfsta ]; 105 license = with licenses; [ mpl20 gpl2Plus ]; 106 platforms = with platforms; all; 107 }; 108}