Skip to content

Commit 61a8c62

Browse files
danieldkDaniël de Kok
authored andcommitted
Add default.nix to build and test the crate
1 parent 0ef4cad commit 61a8c62

File tree

5 files changed

+3214
-36
lines changed

5 files changed

+3214
-36
lines changed

default.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
callPackage
3+
, stdenv
4+
5+
, defaultCrateOverrides
6+
, nix-gitignore
7+
8+
, darwin
9+
, python3Packages
10+
, pkgconfig
11+
12+
, releaseBuild ? true
13+
}:
14+
15+
let
16+
rustNightly = callPackage ./nix/rust-nightly.nix {};
17+
in ((callPackage ./nix/finalfusion-python.nix {}).finalfusion_python {}).override {
18+
release = releaseBuild;
19+
rust = rustNightly;
20+
21+
crateOverrides = defaultCrateOverrides // {
22+
finalfusion-python = attr: rec {
23+
pname = "finalfusion-python";
24+
name = "${pname}-${attr.version}";
25+
26+
src = nix-gitignore.gitignoreSource [ ".git/" "*.nix" "/nix" ] ./.;
27+
28+
buildInputs = stdenv.lib.optional stdenv.isDarwin darwin.Security;
29+
30+
installCheckInputs = [ python3Packages.pytest ];
31+
32+
propagatedBuildInputs = [ python3Packages.numpy ];
33+
34+
doInstallCheck = true;
35+
36+
installPhase = let
37+
sitePackages = python3Packages.python.sitePackages;
38+
sharedLibrary = stdenv.hostPlatform.extensions.sharedLibrary;
39+
in ''
40+
mkdir -p "$out/${sitePackages}"
41+
cp target/lib/libfinalfusion-*${sharedLibrary} \
42+
"$out/${sitePackages}/finalfusion.so"
43+
export PYTHONPATH="$out/${sitePackages}:$PYTHONPATH"
44+
'';
45+
46+
installCheckPhase = ''
47+
cargo fmt --all -- --check
48+
pytest
49+
'';
50+
51+
meta = with stdenv.lib; {
52+
description = "Python module for finalfusion embeddings";
53+
license = licenses.asl20;
54+
platforms = platforms.all;
55+
};
56+
};
57+
58+
pyo3 = attr: {
59+
buildInputs = [ python3Packages.python ];
60+
};
61+
};
62+
}

0 commit comments

Comments
 (0)