-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
99 lines (86 loc) · 3.84 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-unstable";
devshell = {
url = "github:numtide/devshell";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, devshell, flake-utils, rust-overlay, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ devshell.overlay (import rust-overlay) ];
pkgs = import nixpkgs { inherit overlays system; };
rust = pkgs.rust-bin.nightly.latest;
in rec {
packages = {
default = pkgs.rustPlatform.buildRustPackage {
pname = "proost";
version = "0.1.0";
nativeBuildInputs = [ rust.minimal ];
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
meta = with pkgs.lib; {
description = "A simple proof assistant written in Rust";
homepage = "https://gitlab.crans.org/loutr/proost";
license = licenses.gpl3;
};
};
docker-ci = let
rust-ci = rust.minimal.override { extensions = [ "clippy" "rustfmt" ]; };
in pkgs.dockerTools.buildImage {
name = "proost-ci";
config.Entrypoint = [ "${pkgs.dockerTools.binSh}/bin/sh" "-c" ];
copyToRoot = pkgs.buildEnv {
name = "proost-dependencies";
paths = (with pkgs; [ cargo-deny coreutils gcc gnugrep gnused grcov lcov libxslt openssh rsync ])
++ (with pkgs.dockerTools; [ binSh caCertificates fakeNss ]) ++ [ rust-ci ];
pathsToLink = [ "/bin" "/etc" ];
};
runAsRoot = "mkdir /tmp";
};
};
devShell = let
rust-dev = rust.default.override { extensions = [ "rust-src" "rust-analyzer" ]; };
in pkgs.devshell.mkShell {
name = "proost";
commands = [{
name = "coverage";
command = let
excl_enum_struct = "^([[:space:]]*)(pub |pub(([[:alpha:]]|[[:space:]]|[:])+) )?(enum|struct) ";
excl_enum_fn_struct = "^([[:space:]]*)(pub |pub(([[:alpha:]]|[[:space:]]|[:])+) )?(enum|fn|struct) ";
excl_line = "//!|#\\[|use|unreachable!|^\\}$|${excl_enum_struct}";
excl_start = "${excl_enum_struct}";
excl_stop = "^\\}$";
excl_br_line = "#\\[|assert(_eq)?!|(error|warn|info|debug|trace)!|^[[:space:]]*\\}(,)?$|${excl_enum_fn_struct}";
excl_br_start = "#\\[no_coverage\\]|^mod tests \\{|${excl_enum_struct}";
excl_br_stop = "^\\}$";
env = "CARGO_INCREMENTAL=0"
+ " RUSTFLAGS=\"-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort\""
+ " RUSTDOCFLAGS=\"-Cpanic=abort\"";
in ''
${env} cargo test
grcov . -s . -b ./target/debug/ --branch --llvm --ignore '*cargo*' --ignore-not-existing \
--excl-line "${excl_line}" --excl-start "${excl_start}" --excl-stop "${excl_stop}" \
--excl-br-line "${excl_br_line}" --excl-br-start "${excl_br_start}" --excl-br-stop "${excl_br_stop}" \
-o ./target/coverage.lcov --log /dev/null || true
find target \( -name "*.gcda" -or -name "*.gcno" \) -delete
genhtml --branch --no-function-coverage --precision 2 target/coverage.lcov -o coverage
'';
help = "Launch tests and generate HTML coverage website";
}];
packages = with pkgs; [ cargo-deny grcov lcov rust-dev ];
};
});
}