-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
139 lines (120 loc) · 3.6 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
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";
};
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
crane,
treefmt-nix,
...
}:
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;
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.nixfmt-rfc-style.enable = true;
programs.deadnix.enable = true;
programs.statix.enable = true;
};
in {
devShells.default = pkgs.mkShell {
inputsFrom = [];
packages = with pkgs;
[
rustToolchain
cargo-edit
cargo-watch
rust-analyzer
bacon
nixd
nixfmt-rfc-style
nil
statix
deadnix
nix-index
nix-info
treefmt
alejandra
nix-tree
manix
]
++ buildInputs;
shellHook = ''
export RUST_BACKTRACE=1
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"
echo "Using Rust nightly: $(rustc --version)"
root=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
export PATH=$PATH:$root/target/debug:$root/target/release
'';
};
formatter = treefmtEval.config.build.wrapper;
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";
# cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
fmt = craneLib.cargoFmt {
src = ./.;
};
};
}
);
}