2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub
|
2021-02-05 17:12:51 +00:00
|
|
|
, cmake, pkg-config, flex, bison
|
2020-09-25 04:45:31 +00:00
|
|
|
, llvmPackages, kernel, elfutils
|
|
|
|
, libelf, libbfd, libbpf, libopcodes, bcc
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "bpftrace";
|
2021-04-05 15:23:46 +00:00
|
|
|
version = "0.12.0";
|
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}";
|
|
|
|
sha256 = "0njbixkrpdl9gjnkzg0ybmqsva0ydfda5vms66v8ij7xida2qy07";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = with llvmPackages;
|
|
|
|
[ llvm clang-unwrapped
|
|
|
|
kernel elfutils libelf bcc
|
2020-09-25 04:45:31 +00:00
|
|
|
libbpf libbfd libopcodes
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config flex bison ]
|
2020-04-24 23:36:52 +00:00
|
|
|
# libelf is incompatible with elfutils-libelf
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# patch the source, *then* substitute on @NIX_KERNEL_SRC@ in the result. we could
|
|
|
|
# also in theory make this an environment variable around bpftrace, but this works
|
|
|
|
# nicely without wrappers.
|
|
|
|
patchPhase = ''
|
|
|
|
patch -p1 < ${./fix-kernel-include-dir.patch}
|
|
|
|
substituteInPlace ./src/utils.cpp \
|
|
|
|
--subst-var-by NIX_KERNEL_SRC '${kernel.dev}/lib/modules/${kernel.modDirVersion}'
|
|
|
|
'';
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
postInstall = ''
|
|
|
|
rm -rf $out/share/bpftrace/tools/doc
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
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;
|
|
|
|
maintainers = with maintainers; [ rvl thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|