Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 fetchFromGitHub,
4 fetchpatch,
5 rustPlatform,
6 clang,
7 pkg-config,
8 elfutils,
9 rustfmt,
10 zlib,
11}:
12
13rustPlatform.buildRustPackage rec {
14 pname = "below";
15 version = "0.9.0";
16
17 src = fetchFromGitHub {
18 owner = "facebookincubator";
19 repo = "below";
20 tag = "v${version}";
21 hash = "sha256-tPweJFqhZMOL+M08bDjW6HPmtuhr9IXJNP0c938O7Cg=";
22 };
23
24 cargoPatches = [
25 (fetchpatch {
26 name = "update-Cargo.lock.patch";
27 url = "https://github.com/facebookincubator/below/commit/f46f9936ac29fa23f5cb02cafe93ae724649bafc.patch";
28 hash = "sha256-J+M8FIuo8ToT3+9eZi5qfwfAW98XcNRqTIJd6O8z1Ig=";
29 })
30 ];
31
32 cargoHash = "sha256-JrSSIwREHSg5YJivSdBIPjOkOtdw8qGCsa4yE7rJz/E=";
33
34 prePatch = ''
35 sed -i "s,ExecStart=.*/bin,ExecStart=$out/bin," etc/below.service
36 '';
37 postInstall = ''
38 install -d $out/lib/systemd/system
39 install -t $out/lib/systemd/system etc/below.service
40 '';
41
42 # bpf code compilation
43 hardeningDisable = [
44 "stackprotector"
45 "zerocallusedregs"
46 ];
47
48 nativeBuildInputs = [
49 clang
50 pkg-config
51 rustfmt
52 ];
53 buildInputs = [
54 elfutils
55 zlib
56 ];
57
58 # needs /sys/fs/cgroup
59 doCheck = false;
60
61 meta = {
62 platforms = lib.platforms.linux;
63 maintainers = with lib.maintainers; [ globin ];
64 description = "Time traveling resource monitor for modern Linux systems";
65 license = lib.licenses.asl20;
66 homepage = "https://github.com/facebookincubator/below";
67 mainProgram = "below";
68 };
69}