-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflake.nix
97 lines (89 loc) · 2.52 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
{
description = "kube_quantity - Rust Kubernetes Quantity Parser Library";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
crane,
advisory-db,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
formatter = pkgs.nixfmt-rfc-style;
craneLib = crane.mkLib pkgs;
markdownFilter = path: _type: builtins.match ".*md$" path != null;
markdownOrCargo = path: type: (markdownFilter path type) || (craneLib.filterCargoSources path type);
# Common arguments for all crane builds
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = markdownOrCargo;
name = "source"; # Be reproducible, regardless of the directory name
};
strictDeps = true;
cargoExtraArgs = "--features __check";
};
# Build just the cargo dependencies
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
{
inherit formatter;
checks = {
# Check code format
cargo-fmt = craneLib.cargoFmt (builtins.removeAttrs commonArgs [ "cargoExtraArgs" ]);
# Run clippy (with the dependencies already built)
cargo-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
# Run tests
cargo-test = craneLib.cargoTest (
commonArgs
// {
inherit cargoArtifacts;
}
);
# Doc tests
cargo-doc = craneLib.cargoDoc (
commonArgs
// {
inherit cargoArtifacts;
}
);
# Audit dependencies
cargo-audit = craneLib.cargoAudit {
inherit advisory-db;
inherit (commonArgs) src;
};
};
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
formatter
cargo
cargo-release
clippy
rustc
zizmor
actionlint
];
};
};
}
);
}