-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
170 lines (152 loc) · 5.24 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
description = "WIP: Flake to built and run CadQuery in JupyterLab on M1 Mac";
# inputs.nixpkgs.url = "github:nixos/nixpkgs/release-22.11";
# Required for apple_sdk 12.0
# inputs.nixpkgs.url = "github:nixos/nixpkgs/master";
inputs.nixpkgs.url = "github:nixos/nixpkgs";
outputs = {
self,
nixpkgs,
}: let
system = "aarch64-darwin";
in {
packages.${system} = let
pkgs = import nixpkgs {inherit system;};
stdenv = pkgs.darwin.apple_sdk.clang14Stdenv;
inherit (pkgs) lib;
in {
default = self.outputs.packages.${system}.ocp;
clang-python = with pkgs.python3Packages;
buildPythonPackage rec {
inherit stdenv;
inherit (stdenv.cc.cc) version;
pname = "clang";
src = "${stdenv.cc.cc.src}/clang/bindings/python";
propagatedBuildInputs = [setuptools];
# CLANG_LIBRARY_PATH = lib.makeLibraryPath [libclang.lib];
format = "pyproject";
postUnpack = let
pyproject_toml = pkgs.writeText "pyproject.toml" ''
[build-system]
requires = [ "setuptools>=42", "wheel" ]
build-backend = "setuptools.build_meta"
[project]
name = "clang"
version = "${version}"
'';
in ''
cp '${pyproject_toml}' $sourceRoot/pyproject.toml
'';
# unpackPhase = let
# pyproject_toml = pkgs.writeText "pyproject.toml" ''
# [build-system]
# requires = [ "setuptools>=42", "wheel" ]
# build-backend = "setuptools.build_meta"
# [project]
# name = "clang"
# version = "${version}"
# '';
# in ''
# export sourceRoot=$PWD/source
# mkdir $sourceRoot
# tar xf ${stdenv.cc.cc.src}
# cp -rv --no-preserve=mode clang-${stdenv.cc.version}.src/bindings/python/* $sourceRoot/
# cp '${pyproject_toml}' $sourceRoot/pyproject.toml
# '';
};
pywrap = with pkgs.python3Packages;
buildPythonPackage {
inherit stdenv;
pname = "pywrap";
version = "07f85fc";
src = pkgs.fetchFromGitHub {
owner = "CadQuery";
repo = "pywrap";
rev = "07f85fc";
sha256 = "ktyIDnmF+gGLtBquGJ4wgxU2bjPe85Yv6na99ZIUC7k=";
};
propagatedBuildInputs = [
click
jinja2
joblib
logzero
pandas
path
pybind11
pyparsing
schema
toml
toposort
tqdm
self.packages.${system}.clang-python
];
meta = {
homepage = "https://github.com/CadQuery/pywrap";
description = "PyWrap is a C++ binding generator using pybind11, libclang and jinja.";
license = lib.licenses.asl20;
maintainers = with maintainers; [];
};
};
ocp = let
pythonWithPywrap = pkgs.python3.withPackages (ps:
with ps; [
joblib
setuptools
pybind11
self.packages.${system}.pywrap
]);
in
stdenv.mkDerivation {
pname = "OCP";
version = "7.5.3.0";
src = pkgs.fetchFromGitHub {
owner = "CadQuery";
repo = "OCP";
rev = "7.5.3.0";
sha256 = "jaZVsbMWSuLNnLlRzDp4ZEKqZLXC8OAp+i8/jKbMRJg=";
};
buildInputs = with pkgs; [
llvmPackages_14.libclang
llvmPackages_14.libcxxClang
# boost
cmake
darwin.apple_sdk.frameworks.OpenGL
opencascade-occt
# (opencascade-occt.override {vtk = vtk_9;})
pythonWithPywrap
pkg-config
rapidjson
vtk_9
];
# type_traits: -i "$(nix path-info github:nixos/nixpkgs#llvmPackages_14.libcxx.dev)/include/c++/v1" \
# -l "$(nix path-info github:nixos/nixpkgs#llvmPackages_14.libcxxStdenv.cc.cc.lib)/lib/libclang.dylib" \
configurePhase = ''
pywrap \
-i "$(nix path-info github:nixos/nixpkgs#llvmPackages_14.libcxx.dev)/include/c++/v1" \
-l "$(nix path-info github:nixos/nixpkgs#llvmPackages_14.libcxxStdenv.cc.cc.lib)/lib/libclang.dylib" \
all ocp.toml
'';
buildPhase = ''
cmake -S OCP -B build
cmake --build build
'';
# BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${llvmPackages.libclang.lib}/lib/clang/${lib.getVersion clang}/include";
# cmakeFlags = [
# "-DPYTHON_EXECUTABLE=${python}/bin/python"
# ];
# "-DOCE_INSTALL_PREFIX=${placeholder "out"}"
# "-DOCE_WITH_FREEIMAGE=ON"
# "-DOCE_WITH_VTK=ON"
# "-DOCE_WITH_GL2PS=ON"
# "-DOCE_MULTITHREAD_LIBRARY=TBB"
# ];
meta = {
homepage = "https://github.com/CadQuery/OCP";
description = "Python wrapper for OCCT generated using pywrap.";
license = lib.licenses.asl20;
maintainers = with pkgs.maintainers; [];
};
};
};
};
}