-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
115 lines (100 loc) · 2.35 KB
/
default.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
{
lib,
stdenv,
craneLib,
nixFilter,
maturin,
rustPlatform,
libiconv,
python3,
}:
let
src = craneLib.cleanCargoSource (craneLib.path ./.);
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
# python package build will recompile PyO3 when built with maturin
# as there are different build features are used for the extension module
# and the standalone dylib which is used for tests and benchmarks
doNotLinkInheritedArtifacts = true;
buildInputs =
[
python3
]
++ lib.optionals stdenv.isDarwin [
# Additional darwin specific inputs can be set here
libiconv
];
};
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual crate itself, reusing the dependency
# artifacts from above.
libunblob-native = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
}
);
self = python3.pkgs.buildPythonPackage {
inherit (libunblob-native) pname version;
format = "pyproject";
src = nixFilter {
root = ./.;
include = [
"Cargo.toml"
"Cargo.lock"
"pyproject.toml"
"python"
"benches"
"src"
"README.md"
"LICENSE"
];
};
buildInputs = commonArgs.buildInputs ++ [ maturin ];
strictDeps = true;
doCheck = false;
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = (
with rustPlatform;
[
cargoSetupHook
maturinBuildHook
]
);
passthru = {
inherit
cargoArtifacts
craneLib
commonArgs
libunblob-native
;
tests = {
pytest =
with python3.pkgs;
buildPythonPackage {
inherit (libunblob-native) pname version;
format = "other";
src = nixFilter {
root = ./.;
include = [
"pyproject.toml"
"tests"
];
};
dontBuild = true;
dontInstall = true;
nativeCheckInputs = [
self
pytestCheckHook
];
};
};
};
};
in
self