2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub
|
2021-02-05 17:12:51 +00:00
|
|
|
, cmake, pkg-config, flex, bison
|
2021-12-06 16:07:01 +00:00
|
|
|
, llvmPackages, elfutils
|
2020-09-25 04:45:31 +00:00
|
|
|
, libelf, libbfd, libbpf, libopcodes, bcc
|
2021-12-06 16:07:01 +00:00
|
|
|
, cereal, asciidoctor
|
|
|
|
, nixosTests
|
2022-06-16 17:23:12 +00:00
|
|
|
, util-linux
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "bpftrace";
|
2022-07-14 12:49:19 +00:00
|
|
|
version = "0.15.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# Cherry-picked from merged PR, remove this hook on next update
|
|
|
|
# https://github.com/iovisor/bpftrace/pull/2242
|
|
|
|
# Cannot `fetchpatch` such pure renaming diff since
|
|
|
|
# https://github.com/iovisor/bpftrace/commit/2df807dbae4037aa8bf0afc03f52fb3f6321c62a.patch
|
|
|
|
# does not contain any diff in unified format but just this instead:
|
|
|
|
# ...
|
|
|
|
# man/man8/{bashreadline.8 => bashreadline.bt.8} | 0
|
|
|
|
# ...
|
|
|
|
# 35 files changed, 0 insertions(+), 0 deletions(-)
|
|
|
|
# rename man/man8/{bashreadline.8 => bashreadline.bt.8} (100%)
|
|
|
|
# ...
|
|
|
|
# on witch `fetchpatch` fails with
|
|
|
|
# error: Normalized patch '/build/patch' is empty (while the fetched file was not)!
|
|
|
|
# Did you maybe fetch a HTML representation of a patch instead of a raw patch?
|
|
|
|
postUnpack = ''
|
|
|
|
rename .8 .bt.8 "$sourceRoot"/man/man8/*.8
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "iovisor";
|
|
|
|
repo = "bpftrace";
|
2021-04-05 15:23:46 +00:00
|
|
|
rev = "v${version}";
|
2022-07-14 12:49:19 +00:00
|
|
|
sha256 = "sha256-9adZAKSn00W2yNwVDbVB1/O5Y+10c4EkVJGCHyd4Tgg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = with llvmPackages;
|
2021-05-20 23:08:51 +00:00
|
|
|
[ llvm libclang
|
2021-12-06 16:07:01 +00:00
|
|
|
elfutils libelf bcc
|
2020-09-25 04:45:31 +00:00
|
|
|
libbpf libbfd libopcodes
|
2021-12-06 16:07:01 +00:00
|
|
|
cereal asciidoctor
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config flex bison llvmPackages.llvm.dev util-linux ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# tests aren't built, due to gtest shenanigans. see:
|
|
|
|
#
|
|
|
|
# https://github.com/iovisor/bpftrace/issues/161#issuecomment-453606728
|
|
|
|
# https://github.com/iovisor/bpftrace/pull/363
|
|
|
|
#
|
|
|
|
cmakeFlags =
|
|
|
|
[ "-DBUILD_TESTING=FALSE"
|
2020-09-25 04:45:31 +00:00
|
|
|
"-DLIBBCC_INCLUDE_DIRS=${bcc}/include"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# nuke the example/reference output .txt files, for the included tools,
|
|
|
|
# stuffed inside $out. we don't need them at all.
|
2022-06-26 10:26:21 +00:00
|
|
|
# (see "Allow skipping examples" for a potential option
|
|
|
|
# https://github.com/iovisor/bpftrace/pull/2256)
|
|
|
|
#
|
|
|
|
# Pull BPF scripts into $PATH (next to their bcc program equivalents), but do
|
|
|
|
# not move them to keep `${pkgs.bpftrace}/share/bpftrace/tools/...` working.
|
|
|
|
# (remove `chmod` once a new release "Add executable permission to tools"
|
|
|
|
# https://github.com/iovisor/bpftrace/commit/77e524e6d276216ed6a6e1984cf204418db07c78)
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
rm -rf $out/share/bpftrace/tools/doc
|
2022-06-26 10:26:21 +00:00
|
|
|
|
|
|
|
ln -s $out/share/bpftrace/tools/*.bt $out/bin/
|
|
|
|
chmod +x $out/bin/*.bt
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
passthru.tests = {
|
|
|
|
bpf = nixosTests.bpf;
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "High-level tracing language for Linux eBPF";
|
|
|
|
homepage = "https://github.com/iovisor/bpftrace";
|
|
|
|
license = licenses.asl20;
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with maintainers; [ rvl thoughtpolice martinetd ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|