@@ -0,0 +1,38 @@
1+{ lib, stdenv
2+, libopcodes, libbfd, libelf, readline
3+, linuxPackages_latest, zlib
4+, python3, bison, flex
5+}:
6+
7+stdenv.mkDerivation {
8+ pname = "bpftools";
9+ inherit (linuxPackages_latest.kernel) version src;
10+
11+ nativeBuildInputs = [ python3 bison flex ];
12+ buildInputs = [ libopcodes libbfd libelf zlib readline ];
13+
14+ preConfigure = ''
15+ patchShebangs scripts/bpf_helpers_doc.py
16+
17+ cd tools/bpf
18+ substituteInPlace ./bpftool/Makefile \
19+ --replace '/usr/local' "$out" \
20+ --replace '/usr' "$out" \
21+ --replace '/sbin' '/bin'
22+ '';
23+
24+ buildFlags = [ "bpftool" "bpf_asm" "bpf_dbg" ];
25+
26+ installPhase = ''
27+ make -C bpftool install
28+ install -Dm755 -t $out/bin bpf_asm
29+ install -Dm755 -t $out/bin bpf_dbg
30+ '';
31+
32+ meta = with lib; {
33+ description = "Debugging/program analysis tools for the eBPF subsystem";
34+ license = [ licenses.gpl2 licenses.bsd2 ];
35+ platforms = platforms.linux;
36+ maintainers = with maintainers; [ thoughtpolice ];
37+ };
38+}