-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
86 lines (75 loc) · 2.92 KB
/
Copy pathflake.nix
File metadata and controls
86 lines (75 loc) · 2.92 KB
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
{
description = "stamp-suite — Simple Two-Way Active Measurement Protocol (STAMP)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Cargo features compiled into the nix-built binary and exercised
# by the check phase. Mirrors `cargo build/test --all-features`.
allFeatures = [ "ttl-nix" "ttl-pnet" "metrics" "snmp" ];
in
{
packages = {
default = pkgs.rustPlatform.buildRustPackage {
pname = "stamp-suite";
version = "0.9.0";
src = self;
# Regenerate after any Cargo.lock change: set to pkgs.lib.fakeHash,
# run `nix build .#default`, and copy the `got:` hash from the error.
cargoHash = "sha256-/HHpt2wz8PycXoQQkU6Gh+hT7DRuIlx1kKOIjwrZnGg=";
buildFeatures = allFeatures;
# Honour --all-features for the cargo test phase too so the
# metrics / snmp feature-gated tests run alongside the rest.
cargoTestFlags = [ "--all-features" ];
meta = with pkgs.lib; {
description = "Simple Two-Way Active Measurement Protocol (STAMP) implementation";
homepage = "https://github.com/asmie/stamp-suite";
license = licenses.mit;
mainProgram = "stamp-suite";
platforms = platforms.unix;
};
};
};
# `nix flake check` exercises the package build (which includes the
# cargo test phase) plus a clippy-with-warnings-as-errors gate that
# mirrors CI.
checks = {
build = self.packages.${system}.default;
clippy = pkgs.rustPlatform.buildRustPackage {
pname = "stamp-suite-clippy";
version = "0.9.0";
src = self;
# Regenerate after any Cargo.lock change: set to pkgs.lib.fakeHash,
# run `nix build .#default`, and copy the `got:` hash from the error.
cargoHash = "sha256-/HHpt2wz8PycXoQQkU6Gh+hT7DRuIlx1kKOIjwrZnGg=";
buildFeatures = allFeatures;
nativeBuildInputs = [ pkgs.clippy ];
buildPhase = ''
cargo clippy --all --all-features --tests -- -D warnings
'';
doCheck = false;
installPhase = "mkdir -p $out";
};
fmt = pkgs.runCommand "stamp-suite-fmt"
{ nativeBuildInputs = [ pkgs.rustfmt pkgs.cargo ]; } ''
cd ${self}
cargo fmt --all -- --check
touch $out
'';
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
cargo
rustc
rustfmt
clippy
rust-analyzer
];
};
}
);
}