nixpkgs/pkgs/os-specific/linux/bpftrace/default.nix
Austin Seipp 6fb7b16046
linuxPackages.bpftrace: 0.9.4 -> 0.11.0
This fixes the `bcc` include directory (which was improperly set, and
warned about at build-time, but masked by some backwards compat code,
apparently) and also includes some missing libraries in `buildInputs`

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2020-08-31 17:47:30 -05:00

64 lines
1.9 KiB
Nix

{ stdenv, fetchFromGitHub
, cmake, pkgconfig, flex, bison
, llvmPackages, kernel, elfutils
, libelf, libbfd, libbpf, libopcodes, bcc
}:
stdenv.mkDerivation rec {
pname = "bpftrace";
version = "0.11.0";
src = fetchFromGitHub {
owner = "iovisor";
repo = "bpftrace";
rev = "refs/tags/v${version}";
sha256 = "02f2r731yj3fdc8341id1ksk4dma9rwm2765n2xgx2ldrrz5823y";
};
enableParallelBuilding = true;
buildInputs = with llvmPackages;
[ llvm clang-unwrapped
kernel elfutils libelf bcc
libbpf libbfd libopcodes
];
nativeBuildInputs = [ cmake pkgconfig flex bison ]
# libelf is incompatible with elfutils-libelf
++ stdenv.lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
# 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"
"-DLIBBCC_INCLUDE_DIRS=${bcc}/include"
];
# 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" ];
meta = with stdenv.lib; {
description = "High-level tracing language for Linux eBPF";
homepage = "https://github.com/iovisor/bpftrace";
license = licenses.asl20;
maintainers = with maintainers; [ rvl thoughtpolice ];
};
}