-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
95 lines (78 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = {
self,
nixpkgs,
crane,
flake-utils,
advisory-db,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib;
craneLib = crane.lib.${system};
src = craneLib.cleanCargoSource (craneLib.path ./.);
commonArgs = {
inherit src;
buildInputs = with pkgs;
[
pkg-config
]
++ lib.optionals pkgs.stdenv.isDarwin [];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
anyrun-stdin = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
});
in {
checks = {
inherit anyrun-stdin;
anyrun-stdin-clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
anyrun-stdin-doc = craneLib.cargoDoc (commonArgs
// {
inherit cargoArtifacts;
});
anyrun-stdin-fmt = craneLib.cargoFmt {
inherit src;
};
anyrun-stdin-audit = craneLib.cargoAudit {
inherit src advisory-db;
};
};
packages.default = anyrun-stdin;
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks.${system};
nativeBuildInputs = with pkgs; [
cargo # rust package manager
clippy # opinionated rust formatter
deadnix # clean up unused nix code
gcc # GNU Compiler Collection
lldb # software debugger
rustc # rust compiler
rustfmt # rust formatter
rust-analyzer # rust analyzer
statix # lints and suggestions
];
};
});
}