-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
114 lines (97 loc) · 2.82 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
{
description = "🧬 Terminal utility to track intake of caffeine (or other stimulants), vitamins, supplements, nootropics and chemical compounds in general.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
};
devenv.url = "github:cachix/devenv";
};
outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
crane,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.nightly.latest.default.override {
extensions = [
"rust-src"
"llvm-tools-preview"
"miri"
];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
buildInputs = with pkgs;
[
openssl
pkg-config
]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
commonArgs = {
src = craneLib.cleanCargoSource (craneLib.path ./.);
buildInputs = buildInputs;
nativeBuildInputs = with pkgs; [ pkg-config ];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in {
devShells.default = pkgs.mkShell {
packages = with pkgs;
[
rustToolchain
cargo-edit
cargo-watch
rust-analyzer
bacon
]
++ buildInputs;
shellHook = ''
export RUST_BACKTRACE=1
echo "Using Rust nightly: $(rustc --version)"
'';
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
};
packages = {
default = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
pname = "neuronek";
version = "0.0.1-alpha.3";
doCheck = false;
preBuild = ''
export CARGO_INCREMENTAL=0
'';
postInstall = ''
${pkgs.file}/bin/file $out/bin/*
'';
});
check = craneLib.cargoNextest (commonArgs
// {
inherit cargoArtifacts;
cargoNextestExtraArgs = "--workspace";
});
};
checks = {
clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
fmt = craneLib.cargoFmt {
src = ./.;
};
};
}
);
}