-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
79 lines (71 loc) · 2.14 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
{
description = " A Rust library to quickly get the size and line size of your CPU caches";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-compat.follows = "flake-compat";
inputs.utils.follows = "utils";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
rust = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "utils";
};
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, gitignore, rust, utils, ... }: utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ gitignore.overlay rust.overlay ]; };
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideScope' (_: _: {
cargo = toolchain;
clippy = toolchain;
rustc = toolchain;
rustfmt = toolchain;
});
src = pkgs.gitignoreSource ./.;
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
};
fmt = craneLib.cargoFmt { inherit cargoArtifacts src; };
clippy = craneLib.cargoClippy {
inherit src;
cargoArtifacts = fmt;
cargoClippyExtraArgs = "-- --deny warnings";
};
crate = craneLib.buildPackage {
inherit src;
cargoArtifacts = clippy;
};
in
{
checks = { inherit fmt clippy; };
packages.default = crate;
devShells.default = with pkgs; mkShell {
name = "cache-size";
nativeBuildInputs = [
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
cargo-edit
cargo-udeps
cargo-watch
rust-analyzer
nixpkgs-fmt
rnix-lsp
pre-commit
];
shellHook = ''
pre-commit install --install-hooks
'';
};
});
}