2020-05-15 21:57:56 +00:00
|
|
|
{ lib
|
2023-08-10 07:59:29 +00:00
|
|
|
, stdenv
|
2020-05-15 21:57:56 +00:00
|
|
|
, wrapQtAppsHook
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, ninja
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-05-15 21:57:56 +00:00
|
|
|
, eigen
|
|
|
|
, zlib
|
|
|
|
, libpng
|
|
|
|
, boost
|
2023-08-10 07:59:29 +00:00
|
|
|
, guile
|
2023-11-16 04:20:00 +00:00
|
|
|
, python
|
2023-08-10 07:59:29 +00:00
|
|
|
, qtbase
|
|
|
|
, darwin
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "libfive";
|
|
|
|
version = "unstable-2023-06-07";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2020-05-15 21:57:56 +00:00
|
|
|
owner = "libfive";
|
|
|
|
repo = "libfive";
|
2023-08-10 07:59:29 +00:00
|
|
|
rev = "c85ffe1ba1570c2551434c5bad731884aaf80598";
|
|
|
|
hash = "sha256-OITy3fJx+Z6856V3D/KpSQRJztvOdJdqUv1c65wNgCc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-05-15 21:57:56 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
nativeBuildInputs = [ wrapQtAppsHook cmake ninja pkg-config python.pkgs.pythonImportsCheckHook ];
|
|
|
|
buildInputs = [ eigen zlib libpng boost guile python qtbase ]
|
2023-08-10 07:59:29 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk_11_0.frameworks.Cocoa ];
|
2022-10-30 15:09:59 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
substituteInPlace studio/src/guile/interpreter.cpp \
|
2023-08-10 07:59:29 +00:00
|
|
|
--replace '"libfive/bind/guile"' \
|
|
|
|
'"libfive/bind/guile:${placeholder "out"}/${guile.siteCcacheDir}"' \
|
|
|
|
--replace '(app_resource_dir + ":" + finder_build_dir).toLocal8Bit()' \
|
|
|
|
'"libfive/bind/guile:${placeholder "out"}/${guile.siteCcacheDir}"'
|
2022-10-30 15:09:59 +00:00
|
|
|
|
|
|
|
substituteInPlace libfive/bind/guile/CMakeLists.txt \
|
|
|
|
--replace "LIBFIVE_FRAMEWORK_DIR=$<TARGET_FILE_DIR:libfive>" \
|
|
|
|
"LIBFIVE_FRAMEWORK_DIR=$out/lib" \
|
|
|
|
--replace "LIBFIVE_STDLIB_DIR=$<TARGET_FILE_DIR:libfive-stdlib>" \
|
|
|
|
"LIBFIVE_STDLIB_DIR=$out/lib"
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
substituteInPlace libfive/bind/python/CMakeLists.txt \
|
|
|
|
--replace ' ''${PYTHON_SITE_PACKAGES_DIR}' \
|
|
|
|
" $out/${python.sitePackages}" \
|
|
|
|
|
|
|
|
substituteInPlace libfive/bind/python/libfive/ffi.py \
|
|
|
|
--replace "os.path.join('libfive', folder)" \
|
|
|
|
"os.path.join('$out/${python.sitePackages}/libfive', folder)" \
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
export XDG_CACHE_HOME=$(mktemp -d)/.cache
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = [
|
2023-08-10 07:59:29 +00:00
|
|
|
"-DGUILE_CCACHE_DIR=${placeholder "out"}/${guile.siteCcacheDir}"
|
|
|
|
] ++ lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11") [
|
|
|
|
# warning: 'aligned_alloc' is only available on macOS 10.15 or newer
|
|
|
|
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"
|
2022-10-30 15:09:59 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
env = lib.optionalAttrs stdenv.cc.isClang {
|
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-error=enum-constexpr-conversion";
|
|
|
|
};
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
2021-05-20 23:08:51 +00:00
|
|
|
# No rules to install the mac app, so do it manually.
|
|
|
|
mkdir -p $out/Applications
|
|
|
|
cp -r studio/Studio.app $out/Applications/Studio.app
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
install_name_tool -add_rpath $out/lib $out/Applications/Studio.app/Contents/MacOS/Studio
|
|
|
|
|
|
|
|
makeWrapper $out/Applications/Studio.app/Contents/MacOS/Studio $out/bin/Studio
|
|
|
|
'' + ''
|
2021-05-20 23:08:51 +00:00
|
|
|
# Link "Studio" binary to "libfive-studio" to be more obvious:
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s "$out/bin/Studio" "$out/bin/libfive-studio"
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
# Create links since libfive looks for the library in a specific path.
|
|
|
|
mkdir -p "$out/${python.sitePackages}/libfive/src"
|
|
|
|
ln -s "$out"/lib/libfive.* "$out/${python.sitePackages}/libfive/src/"
|
|
|
|
mkdir -p "$out/${python.sitePackages}/libfive/stdlib"
|
|
|
|
ln -s "$out"/lib/libfive-stdlib.* "$out/${python.sitePackages}/libfive/stdlib/"
|
|
|
|
|
|
|
|
# Create links so Studio can find the bindings.
|
|
|
|
mkdir -p "$out/libfive/bind"
|
|
|
|
ln -s "$out/${python.sitePackages}" "$out/libfive/bind/python"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"libfive"
|
|
|
|
"libfive.runner"
|
|
|
|
"libfive.shape"
|
|
|
|
"libfive.stdlib"
|
|
|
|
];
|
|
|
|
|
2020-05-15 21:57:56 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Infrastructure for solid modeling with F-Reps in C, C++, and Guile";
|
|
|
|
homepage = "https://libfive.com/";
|
2023-11-16 04:20:00 +00:00
|
|
|
maintainers = with maintainers; [ hodapp kovirobi wulfsta ];
|
2020-05-15 21:57:56 +00:00
|
|
|
license = with licenses; [ mpl20 gpl2Plus ];
|
2023-08-10 07:59:29 +00:00
|
|
|
platforms = with platforms; all;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|