-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
114 lines (95 loc) · 3.47 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
{
description = "kupli";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
# Currently only needed for shell.nix (integration with VSCode).
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
flake-utils.url = "github:numtide/flake-utils";
# Nix language server used for VSCode.
nil.url = "github:oxalica/nil";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, advisory-db, crane, flake-utils, nil, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
craneLib = crane.lib.${system};
src = craneLib.cleanCargoSource (craneLib.path ./.);
commonArgs = {
inherit src;
strictDeps = true;
buildInputs = with pkgs; [ openssl ];
nativeBuildInputs = with pkgs; [ pkg-config ];
CARGO_BUILD_RUSTFLAGS = "--cfg uuid_unstable";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
kupli-crate = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
in
{
devShells.default = craneLib.devShell {
checks = self.checks.${system};
inputsFrom = [ kupli-crate ];
packages = with pkgs; [
git
(rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
})
# Both of these used for VSCode.
nixpkgs-fmt
nil.packages.${system}.default
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
checks = {
# Build the crate as part of `nix flake check` for convenience.
inherit kupli-crate;
# 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.
kupli-crate-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
kupli-crate-doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
});
kupli-crate-fmt = craneLib.cargoFmt {
inherit src;
};
kupli-crate-audit = craneLib.cargoAudit {
inherit src advisory-db;
};
kupli-crate-deny = craneLib.cargoDeny {
inherit src;
};
kupli-crate-nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
});
};
packages.default = kupli-crate;
apps.default = flake-utils.lib.mkApp {
drv = kupli-crate;
};
}
);
}