-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
59 lines (53 loc) · 1.65 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
{
description = "Lets you run other commands in different directories.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
};
outputs = {
self,
nixpkgs,
crane,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource (craneLib.path ./.);
commonArgs = {
inherit src;
strictDeps = true;
buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
cdo = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
});
in {
formatter = pkgs.alejandra;
packages.default = cdo;
checks = {
inherit cdo;
clippy = craneLib.cargoClippy (commonArgs // {inherit cargoArtifacts;});
test = craneLib.cargoTest (commonArgs // {inherit cargoArtifacts;});
rustfmt = craneLib.cargoFmt {inherit src;};
alejandra =
pkgs.runCommand "alejandra" {
buildInputs = [pkgs.alejandra];
} ''
alejandra -c ${./.}
mkdir $out
'';
};
devShells.default = craneLib.devShell {
checks = self.checks.${system};
# Ensure `rust-analyzer` has access to the rust source code.
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
});
}