2023-05-24 13:37:59 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch
|
|
|
|
, llvmPackages, elfutils, bcc
|
|
|
|
, libbpf, libbfd, libopcodes
|
2021-12-06 16:07:01 +00:00
|
|
|
, cereal, asciidoctor
|
2023-05-24 13:37:59 +00:00
|
|
|
, cmake, pkg-config, flex, bison
|
2022-06-16 17:23:12 +00:00
|
|
|
, util-linux
|
2023-05-24 13:37:59 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "bpftrace";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "0.18.0";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-05-24 13:37:59 +00:00
|
|
|
owner = "iovisor";
|
|
|
|
repo = "bpftrace";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-+SBLcMyOf1gZN8dG5xkNLsqIcK1eVlswjY1GRXepFVg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
patches = [
|
|
|
|
# fails to build - https://github.com/iovisor/bpftrace/issues/2598
|
|
|
|
(fetchpatch {
|
|
|
|
name = "link-binaries-against-zlib";
|
|
|
|
url = "https://github.com/iovisor/bpftrace/commit/a60b171eb288250c3f1d6f065b05d8a87aff3cdd.patch";
|
|
|
|
hash = "sha256-b/0pKDjolo2RQ/UGjEfmWdG0tnIiFX8PJHhRCXvzyxA=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = with llvmPackages; [
|
|
|
|
llvm libclang
|
|
|
|
elfutils bcc
|
|
|
|
libbpf libbfd libopcodes
|
|
|
|
cereal asciidoctor
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +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
|
|
|
|
#
|
2023-05-24 13:37:59 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_TESTING=FALSE"
|
|
|
|
"-DLIBBCC_INCLUDE_DIRS=${bcc}/include"
|
|
|
|
"-DINSTALL_TOOL_DOCS=OFF"
|
|
|
|
"-DUSE_SYSTEM_BPF_BCC=ON"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
# Pull BPF scripts into $PATH (next to their bcc program equivalents), but do
|
|
|
|
# not move them to keep `${pkgs.bpftrace}/share/bpftrace/tools/...` working.
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
2022-06-26 10:26:21 +00:00
|
|
|
ln -s $out/share/bpftrace/tools/*.bt $out/bin/
|
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
|
|
|
};
|
|
|
|
}
|