-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
90 lines (79 loc) · 2.96 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
# Copyright (c) 2022 Espresso Systems (espressosys.com)
# This file is part of the Jellyfish library.
# You should have received a copy of the MIT License
# along with the Jellyfish library. If not, see <https://mit-license.org/>.
{
description = "VeriZexe dev env";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils"; # for dedup
# allow shell.nix alongside flake.nix
inputs.flake-compat.url = "github:edolstra/flake-compat";
inputs.flake-compat.flake = false;
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-utils, flake-compat, rust-overlay, pre-commit-hooks, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith
(toolchain: toolchain.minimal.override { extensions = [ "rustfmt" ]; });
stableToolchain = pkgs.rust-bin.stable.latest.minimal.override {
extensions = [ "clippy" "llvm-tools-preview" "rust-src" ];
};
in with pkgs;
{
check = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
check-format = {
enable = true;
files = "\\.rs$";
entry = "cargo fmt -- --check";
};
doctest = {
enable = true;
entry = "cargo test --doc";
files = "\\.rs$";
pass_filenames = false;
};
cargo-clippy = {
enable = true;
description = "Lint Rust code.";
entry = "cargo-clippy --workspace -- -D warnings";
files = "\\.rs$";
pass_filenames = false;
};
cargo-sort = {
enable = true;
description = "Ensure Cargo.toml are sorted";
entry = "cargo sort -w";
pass_filenames = false;
};
};
};
};
devShell = mkShell {
buildInputs = [
argbash
openssl
pkgconfig
git
stableToolchain
nightlyToolchain
cargo-sort
] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
shellHook = ''
export RUST_BACKTRACE=full
export PATH="$PATH:$(pwd)/target/debug:$(pwd)/target/release"
# Ensure `cargo fmt` uses `rustfmt` from nightly.
export RUSTFMT="${nightlyToolchain}/bin/rustfmt"
''
# install pre-commit hooks
+ self.check.${system}.pre-commit-check.shellHook;
};
}
);
}