git.iko.soy/typeable/nixpkgs
on master help sign in
bpftools: build bpf_asm, bpf_dbg

I needed some other bpf-related tools located in the kernel source tree, so I hijacked the bpftool package, renamed it to bpftools and added those programs.

commitc4bd0719e31e4e8d07aeecf4fcc578bd666fcb59 authorMilan Pässler <milan@petabyte.dev> dateMon 3 May 2021, 00:55 (6 years ago) parentc47fc06
4 files changed+40−31
pkgs/os-specific/linux/bpftool/default.nix−30 pkgs/os-specific/linux/bpftools/default.nix+38 pkgs/top-level/aliases.nix+1 pkgs/top-level/all-packages.nix+1−1
pkgs/os-specific/linux/bpftool/default.nixdeleted−30
@@ -1,30 +0,0 @@
1−{ lib, stdenv
2−, libopcodes, libbfd, libelf
3−, linuxPackages_latest, zlib
4−, python3
5−}:
6−
7−stdenv.mkDerivation {
8− pname = "bpftool";
9− inherit (linuxPackages_latest.kernel) version src;
10−
11− nativeBuildInputs = [ python3 ];
12− buildInputs = [ libopcodes libbfd libelf zlib ];
13−
14− preConfigure = ''
15− patchShebangs scripts/bpf_helpers_doc.py
16−
17− cd tools/bpf/bpftool
18− substituteInPlace ./Makefile \
19− --replace '/usr/local' "$out" \
20− --replace '/usr' "$out" \
21− --replace '/sbin' '/bin'
22− '';
23−
24− meta = with lib; {
25− description = "Debugging/program analysis tool for the eBPF subsystem";
26− license = [ licenses.gpl2 licenses.bsd2 ];
27− platforms = platforms.linux;
28− maintainers = with maintainers; [ thoughtpolice ];
29− };
30−}
pkgs/os-specific/linux/bpftools/default.nixnew file+38
@@ -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+}
pkgs/top-level/aliases.nix+1
@@ -70,6 +70,7 @@ mapAliases ({
7070 bazaarTools = throw "bazaar has been deprecated by breezy."; # added 2020-04-19
7171 beegfs = throw "beegfs has been removed."; # added 2019-11-24
7272 bluezFull = bluez; # Added 2019-12-03
73+ bpftool = bpftools; # Added 2021-05-03
7374 brackets = throw "brackets has been removed, it was unmaintained and had open vulnerabilities"; # added 2021-01-24
7475 bridge_utils = bridge-utils; # added 2015-02-20
7576 bro = zeek; # added 2019-09-29
pkgs/top-level/all-packages.nix+1−1
@@ -12536,7 +12536,7 @@ in
1253612536
1253712537 libbpf = callPackage ../os-specific/linux/libbpf { };
1253812538
12539− bpftool = callPackage ../os-specific/linux/bpftool { };
12539+ bpftools = callPackage ../os-specific/linux/bpftools { };
1254012540
1254112541 bpm-tools = callPackage ../tools/audio/bpm-tools { };
1254212542