forked from elalish/manifold
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
149 lines (149 loc) · 4.54 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.gtest-src = {
url = "github:google/googletest/v1.14.0";
flake = false;
};
inputs.clipper2-src = {
url = "github:AngusJohnson/Clipper2";
flake = false;
};
outputs = { self, nixpkgs, flake-utils, gtest-src, clipper2-src }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
clipper2 = pkgs.clipper2.overrideAttrs (_: _: {
version = "14052024";
src = clipper2-src;
});
manifold =
{ parallel-backend ? "none"
, doCheck ? true
, build-tools ? [ ]
, ...
}: pkgs.stdenv.mkDerivation {
inherit doCheck;
pname = "manifold-${parallel-backend}";
version = "2.5.1";
src = self;
nativeBuildInputs = (with pkgs; [
cmake
ninja
(python3.withPackages
(ps: with ps; [ nanobind trimesh pytest ]))
gtest
pkg-config
]) ++ build-tools;
buildInputs = with pkgs; [
clipper2
assimp
];
cmakeFlags = [
"-DMANIFOLD_CBIND=ON"
"-DMANIFOLD_EXPORT=ON"
"-DBUILD_SHARED_LIBS=ON"
"-DMANIFOLD_PAR=${pkgs.lib.strings.toUpper parallel-backend}"
];
checkPhase = ''
cd test
./manifold_test
cd ../
'';
};
parallelBackends = [
{ parallel-backend = "none"; }
{
parallel-backend = "tbb";
build-tools = with pkgs; [ tbb pkg-config ];
}
];
in
{
packages = (builtins.listToAttrs
(map
(x: {
name = "manifold-" + x.parallel-backend;
value = manifold x;
})
parallelBackends)) // {
manifold-js = pkgs.buildEmscriptenPackage {
name = "manifold-js";
version = "2.5.1";
src = self;
nativeBuildInputs = (with pkgs; [ cmake python39 ]);
buildInputs = [ pkgs.nodejs ];
configurePhase = ''
cp -r ${clipper2-src} clipper2
chmod -R +w clipper2
mkdir -p .emscriptencache
export EM_CACHE=$(pwd)/.emscriptencache
mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=Release \
-DFETCHCONTENT_SOURCE_DIR_GOOGLETEST=${gtest-src} \
-DFETCHCONTENT_SOURCE_DIR_CLIPPER2=../clipper2 ..
'';
buildPhase = ''
emmake make -j''${NIX_BUILD_CORES}
'';
checkPhase = ''
cd test
node manifold_test.js
cd ../
'';
installPhase = ''
mkdir -p $out
cp {extras,wasm}/*.js $out/
cp {extras,wasm}/*.wasm $out/
'';
};
# but how should we make it work with other python versions?
manifold3d = with pkgs.python3Packages; buildPythonPackage {
pname = "manifold3d";
version = "2.5.1";
src = self;
propagatedBuildInputs = [
numpy
];
buildInputs = with pkgs; [
tbb
clipper2
];
nativeBuildInputs = with pkgs; [
cmake
ninja
setuptools
scikit-build-core
pyproject-metadata
pathspec
pkg-config
];
checkInputs = [
nanobind
trimesh
pytest
];
format = "pyproject";
dontUseCmakeConfigure = true;
doCheck = true;
checkPhase = ''
python3 bindings/python/examples/run_all.py
python3 -m pytest
'';
};
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
cmake
tbb
gtest
];
};
}
);
}