forked from boncheolgu/tflite-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
77 lines (69 loc) · 2.09 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
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
};
outputs = { self, nixpkgs, utils, crane }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
renamed_tflite = pkgs.clangStdenv.mkDerivation {
name = "renamed_tflite";
src = pkgs.tensorflow-lite;
buildPhase = ''
mkdir $out/
mkdir $out/lib/
# Copy everything
cp -r $src/* $out/
# Rename specific files in lib/
if [ -d $out/lib ]; then
# Rename libtensorflowlite_c.so to libtensorflow-lite_c.so
if [ -f $out/lib/libtensorflowlite_c.so ]; then
cp $out/lib/libtensorflowlite_c.so $out/lib/libtensorflow-lite_c.so
fi
# Rename libtensorflowlite.so to libtensorflow-lite.so
if [ -f $out/lib/libtensorflowlite.so ]; then
cp $out/lib/libtensorflowlite.so $out/lib/libtensorflow-lite.so
fi
fi
'';
};
in
{
packages.default = (crane.mkLib pkgs).buildPackage {
src = ./.;
doCheck = true;
TFLITE_X86_64_LIB_DIR = "${renamed_tflite}/lib";
TFLITE_LIB_DIR = "${renamed_tflite}/lib";
buildInputs = with pkgs; [
renamed_tflite
vtk
];
nativeBuildInputs = with pkgs; [
clang
pkg-config
perl
rustPlatform.bindgenHook
cmake
libclang
];
};
devShell = pkgs.mkShell {
TFLITE_X86_64_LIB_DIR = "${renamed_tflite}/lib";
TFLITE_LIB_DIR = "${renamed_tflite}/lib";
buildInputs = with pkgs;[
clang
];
nativeBuildInputs = with pkgs; [
rustc
cargo
renamed_tflite
pkg-config
clang
libclang
rustPlatform.bindgenHook
];
};
});
}