2022-12-17 10:02:37 +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
|
2022-07-18 16:21:45 +00:00
|
|
|
, 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";
|
2023-02-09 11:40:11 +00:00
|
|
|
version = "0.17.0";
|
2022-06-16 17:23:12 +00:00
|
|
|
|
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}";
|
2023-02-09 11:40:11 +00:00
|
|
|
sha256 = "sha256-PBqq3u8zym+RY6xudJ66ItzDZEJBNvJDtve1GtxcOdQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = with llvmPackages;
|
2021-05-20 23:08:51 +00:00
|
|
|
[ llvm libclang
|
2022-07-18 16:21:45 +00:00
|
|
|
elfutils 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"
|
2022-12-17 10:02:37 +00:00
|
|
|
"-DINSTALL_TOOL_DOCS=off"
|
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
|
|
|
};
|
|
|
|
}
|