-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrust.nix
More file actions
101 lines (89 loc) · 2.33 KB
/
Copy pathrust.nix
File metadata and controls
101 lines (89 loc) · 2.33 KB
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
{ inputs, ... }: {
perSystem =
{
pkgs,
lib,
self',
system,
...
}:
let
isLinux = pkgs.stdenv.isLinux;
isDarwin = pkgs.stdenv.isDarwin;
isAarch64 = pkgs.stdenv.hostPlatform.isAarch64;
isX86_64 = pkgs.stdenv.hostPlatform.isx86_64;
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (
p:
p.rust-bin.stable.latest.default.override {
extensions = [
"rust-analyzer"
"rust-src"
"rustfmt"
"clippy"
];
}
);
commonArgs = {
inherit (craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; }) version;
# This should be filtered, but there are a lot of useful extensions for tests
src = ./.;
strictDeps = true;
nativeBuildInputs =
with pkgs;
[
pkg-config
protobuf
rustPlatform.bindgenHook
]
++ lib.optionals isLinux [
linuxHeaders
];
buildInputs = lib.optionals isLinux [
pkgs.openblas
# TODO : mkl, armpl
];
env = {
PROTOC = "${pkgs.protobuf}/bin/protoc";
OPENBLAS_DIR = lib.optionalString isLinux "${pkgs.openblas}";
};
};
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.default
];
};
checks =
let
testFeatures = [
"blas"
"gpu"
"native-camera"
]
++ lib.optionals isDarwin [
"metal-backend"
]
++ lib.optionals (isLinux && isAarch64) [
"rknn"
];
mkTest = feature: {
name = "test-${feature}";
value = craneLib.cargoTest (
commonArgs
// {
pname = "yscv-${feature}";
cargoExtraArgs = "--workspace --features ${feature}";
cargoArtifacts = null;
}
);
};
in
builtins.listToAttrs (map mkTest testFeatures);
devShells.default = craneLib.devShell {
inherit (commonArgs) env;
packages = commonArgs.buildInputs ++ commonArgs.nativeBuildInputs;
};
};
}