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