forked from ugandalf/capnp-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
109 lines (90 loc) · 3.18 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
nixpkgs-21.url = "github:NixOS/nixpkgs/nixos-21.11";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = inputs@{ self, flake-utils, nixpkgs, rust-overlay, nixpkgs-21, crane
, advisory-db, ... }:
flake-utils.lib.eachSystem [ flake-utils.lib.system.x86_64-linux ] (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rust-custom-toolchain = (pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rustfmt"
"llvm-tools-preview"
"rust-analyzer-preview"
];
});
in rec {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
openssl
pkg-config
];
nativeBuildInputs = with pkgs; [
# get current rust toolchain defaults (this includes clippy and rustfmt)
rust-custom-toolchain
cargo-edit
capnproto
cmake
];
# fetch with cli instead of native
CARGO_NET_GIT_FETCH_WITH_CLI = "true";
RUST_BACKTRACE = 1;
};
default = {};
checks = let
craneLib =
(inputs.crane.mkLib pkgs).overrideToolchain rust-custom-toolchain;
src = ./.;
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
buildInputs = with pkgs; [ openssl pkg-config ];
};
build-tests = craneLib.buildPackage {
inherit cargoArtifacts src;
buildInputs = with pkgs; [ openssl pkg-config capnproto ];
};
in {
inherit build-tests;
# Run clippy (and deny all warnings) on the crate source,
# again, resuing the dependency artifacts from above.
#
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
my-crate-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
cargoClippyExtraArgs = "-- --deny warnings";
buildInputs = with pkgs; [ openssl pkg-config capnproto ];
};
# Check formatting
my-crate-fmt = craneLib.cargoFmt { inherit src; };
# Audit dependencies
my-crate-audit = craneLib.cargoAudit {
inherit src;
advisory-db = inputs.advisory-db;
cargoAuditExtraArgs = "--ignore RUSTSEC-2020-0071";
};
# Run tests with cargo-nextest
my-crate-nextest = craneLib.cargoNextest {
inherit cargoArtifacts src;
partitions = 1;
partitionType = "count";
buildInputs = with pkgs; [ openssl pkg-config capnproto ];
};
};
});
}