+65
-59
pkgs/by-name/pr/prometheus-ebpf-exporter/package.nix
+65
-59
pkgs/by-name/pr/prometheus-ebpf-exporter/package.nix
···
1
1
{
2
2
lib,
3
+
clangStdenv,
3
4
buildGoModule,
4
5
fetchFromGitHub,
5
6
nixosTests,
6
-
pkgs,
7
+
versionCheckHook,
8
+
nix-update-script,
7
9
libbpf,
8
10
libelf,
9
11
libsystemtap,
10
12
libz,
11
13
}:
12
14
13
-
let
14
-
version = "2.4.2";
15
-
tag = "v${version}";
16
-
in
17
-
buildGoModule.override
18
-
{
19
-
stdenv = pkgs.clangStdenv;
20
-
}
21
-
{
22
-
name = "ebpf_exporter";
15
+
# BPF programs must be compiled with Clang
16
+
buildGoModule.override { stdenv = clangStdenv; } (finalAttrs: {
17
+
pname = "prometheus-ebpf-exporter";
18
+
version = "2.5.1";
23
19
24
-
src = fetchFromGitHub {
25
-
inherit tag;
26
-
owner = "cloudflare";
27
-
repo = "ebpf_exporter";
28
-
hash = "sha256-gXzaMx9Z6LzrlDaQnagQIi183uKhJvdYiolYb8P+MIs=";
29
-
};
20
+
src = fetchFromGitHub {
21
+
owner = "cloudflare";
22
+
repo = "ebpf_exporter";
23
+
tag = "v${finalAttrs.version}";
24
+
hash = "sha256-zIevVZ4ldPj/4OvQFo+Nv/g//xNZEppO9ccB6y65rZA=";
25
+
};
30
26
31
-
vendorHash = "sha256-GhQvPp8baw2l91OUOg+/lrG27P/D4Uzng8XevJf8Pj4=";
27
+
vendorHash = "sha256-ZwKXIIoV4yEyjSpGjVDr91/CQmVuF9zc0IHkJYraE9o=";
32
28
33
-
postPatch = ''
34
-
substituteInPlace examples/Makefile \
35
-
--replace-fail "-Wall -Werror" ""
36
-
'';
29
+
postPatch = ''
30
+
substituteInPlace examples/Makefile \
31
+
--replace-fail "-Wall -Werror" ""
32
+
'';
37
33
38
-
buildInputs = [
39
-
libbpf
40
-
libelf
41
-
libsystemtap
42
-
libz
43
-
];
34
+
buildInputs = [
35
+
libbpf
36
+
libelf
37
+
libsystemtap
38
+
libz
39
+
];
44
40
45
-
CGO_LDFLAGS = "-l bpf";
41
+
CGO_LDFLAGS = "-l bpf";
46
42
47
-
hardeningDisable = [ "zerocallusedregs" ];
43
+
hardeningDisable = [ "zerocallusedregs" ];
48
44
49
-
# Tests fail on trying to access cgroups.
50
-
doCheck = false;
45
+
ldflags = [
46
+
"-s"
47
+
"-w"
48
+
"-X github.com/prometheus/common/version.Version=${finalAttrs.version}"
49
+
"-X github.com/prometheus/common/version.Revision=${finalAttrs.src.tag}"
50
+
"-X github.com/prometheus/common/version.Branch=${finalAttrs.src.tag}"
51
+
"-X github.com/prometheus/common/version.BuildUser=nix@nixpkgs"
52
+
"-X github.com/prometheus/common/version.BuildDate=unknown"
53
+
];
51
54
52
-
ldflags = [
53
-
"-s"
54
-
"-w"
55
-
"-X github.com/prometheus/common/version.Version=${version}"
56
-
"-X github.com/prometheus/common/version.Revision=${tag}"
57
-
"-X github.com/prometheus/common/version.Branch=unknown"
58
-
"-X github.com/prometheus/common/version.BuildUser=nix@nixpkgs"
59
-
"-X github.com/prometheus/common/version.BuildDate=unknown"
60
-
];
55
+
postBuild = ''
56
+
BUILD_LIBBPF=0 make examples
57
+
'';
61
58
62
-
postBuild = ''
63
-
BUILD_LIBBPF=0 make examples
64
-
'';
59
+
postInstall = ''
60
+
mkdir -p $out/examples
61
+
mv examples/*.o examples/*.yaml $out/examples
62
+
'';
65
63
66
-
postInstall = ''
67
-
mkdir -p $out/examples
68
-
mv examples/*.o examples/*.yaml $out/examples
69
-
'';
64
+
# Tests fail on trying to access cgroups.
65
+
doCheck = false;
70
66
71
-
passthru.tests = { inherit (nixosTests.prometheus-exporters) ebpf; };
67
+
doInstallCheck = true;
68
+
nativeInstallCheckInputs = [ versionCheckHook ];
69
+
versionCheckProgramArg = "--version";
72
70
73
-
meta = {
74
-
description = "Prometheus exporter for custom eBPF metrics";
75
-
mainProgram = "ebpf_exporter";
76
-
homepage = "https://github.com/cloudflare/ebpf_exporter";
77
-
changelog = "https://github.com/cloudflare/ebpf_exporter/releases/tag/v${tag}";
78
-
license = lib.licenses.mit;
79
-
maintainers = with lib.maintainers; [ jpds ];
80
-
platforms = lib.platforms.linux;
81
-
};
82
-
}
71
+
passthru = {
72
+
updateScript = nix-update-script { };
73
+
tests = { inherit (nixosTests.prometheus-exporters) ebpf; };
74
+
};
75
+
76
+
meta = {
77
+
description = "Prometheus exporter for custom eBPF metrics";
78
+
mainProgram = "ebpf_exporter";
79
+
homepage = "https://github.com/cloudflare/ebpf_exporter";
80
+
changelog = "https://github.com/cloudflare/ebpf_exporter/releases/tag/${finalAttrs.src.tag}";
81
+
license = lib.licenses.mit;
82
+
maintainers = with lib.maintainers; [
83
+
jpds
84
+
stepbrobd
85
+
];
86
+
platforms = lib.platforms.linux;
87
+
};
88
+
})