jnv: 0.4.2 -> 0.5.0 (#371655)
[NixPkgs.git] / pkgs / development / libraries / libfive / default.nix
bloba6d7304524dbae015b6ba39e89042f5c9e6d244b
2   lib,
3   stdenv,
4   wrapQtAppsHook,
5   fetchFromGitHub,
6   unstableGitUpdater,
7   cmake,
8   ninja,
9   pkg-config,
10   eigen,
11   zlib,
12   libpng,
13   boost,
14   guile,
15   python,
16   qtbase,
17   darwin,
20 stdenv.mkDerivation {
21   pname = "libfive";
22   version = "0-unstable-2024-10-10";
24   src = fetchFromGitHub {
25     owner = "libfive";
26     repo = "libfive";
27     rev = "71899313d36ce14de6646ef760fa6bbc5c0cc067";
28     hash = "sha256-bA+4wGAygdbHcOMGFwNyzn2daQ8E7NeOTUF2Tr3RQww=";
29   };
31   nativeBuildInputs = [
32     wrapQtAppsHook
33     cmake
34     ninja
35     pkg-config
36     python.pkgs.pythonImportsCheckHook
37   ];
38   buildInputs = [
39     eigen
40     zlib
41     libpng
42     boost
43     guile
44     python
45     qtbase
46   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk_11_0.frameworks.Cocoa ];
48   preConfigure = ''
49     substituteInPlace studio/src/guile/interpreter.cpp \
50       --replace '"libfive/bind/guile"' \
51                 '"libfive/bind/guile:${placeholder "out"}/${guile.siteCcacheDir}"' \
52       --replace '(app_resource_dir + ":" + finder_build_dir).toLocal8Bit()' \
53                 '"libfive/bind/guile:${placeholder "out"}/${guile.siteCcacheDir}"'
55     substituteInPlace libfive/bind/guile/CMakeLists.txt \
56       --replace "LIBFIVE_FRAMEWORK_DIR=$<TARGET_FILE_DIR:libfive>" \
57                 "LIBFIVE_FRAMEWORK_DIR=$out/lib" \
58       --replace "LIBFIVE_STDLIB_DIR=$<TARGET_FILE_DIR:libfive-stdlib>" \
59                 "LIBFIVE_STDLIB_DIR=$out/lib"
61     substituteInPlace libfive/bind/python/CMakeLists.txt \
62       --replace ' ''${PYTHON_SITE_PACKAGES_DIR}' \
63                 " $out/${python.sitePackages}" \
65     substituteInPlace libfive/bind/python/libfive/ffi.py \
66       --replace "os.path.join('libfive', folder)" \
67                 "os.path.join('$out/${python.sitePackages}/libfive', folder)" \
69     export XDG_CACHE_HOME=$(mktemp -d)/.cache
70   '';
72   cmakeFlags = [
73     "-DGUILE_CCACHE_DIR=${placeholder "out"}/${guile.siteCcacheDir}"
74   ];
76   env = lib.optionalAttrs stdenv.cc.isClang {
77     NIX_CFLAGS_COMPILE = "-Wno-error=enum-constexpr-conversion";
78   };
80   postInstall =
81     lib.optionalString stdenv.hostPlatform.isDarwin ''
82       # No rules to install the mac app, so do it manually.
83       mkdir -p $out/Applications
84       cp -r studio/Studio.app $out/Applications/Studio.app
86       install_name_tool -add_rpath $out/lib $out/Applications/Studio.app/Contents/MacOS/Studio
88       makeWrapper $out/Applications/Studio.app/Contents/MacOS/Studio $out/bin/Studio
89     ''
90     + ''
91       # Link "Studio" binary to "libfive-studio" to be more obvious:
92       ln -s "$out/bin/Studio" "$out/bin/libfive-studio"
94       # Create links since libfive looks for the library in a specific path.
95       mkdir -p "$out/${python.sitePackages}/libfive/src"
96       ln -s "$out"/lib/libfive.* "$out/${python.sitePackages}/libfive/src/"
97       mkdir -p "$out/${python.sitePackages}/libfive/stdlib"
98       ln -s "$out"/lib/libfive-stdlib.* "$out/${python.sitePackages}/libfive/stdlib/"
100       # Create links so Studio can find the bindings.
101       mkdir -p "$out/libfive/bind"
102       ln -s "$out/${python.sitePackages}" "$out/libfive/bind/python"
103     '';
105   pythonImportsCheck = [
106     "libfive"
107     "libfive.runner"
108     "libfive.shape"
109     "libfive.stdlib"
110   ];
112   passthru.updateScript = unstableGitUpdater {
113     tagFormat = "";
114   };
116   meta = with lib; {
117     description = "Infrastructure for solid modeling with F-Reps in C, C++, and Guile";
118     homepage = "https://libfive.com/";
119     maintainers = with maintainers; [
120       hodapp
121       kovirobi
122       wulfsta
123     ];
124     license = with licenses; [
125       mpl20
126       gpl2Plus
127     ];
128     platforms = with platforms; all;
129   };