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-10-09 19:29:22 +00:00
|
|
|
version = "0.19.1";
|
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}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-JyMogqyntSm2IDXzsOIjcUkf2YwG2oXKpqPpdx/eMNI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-10-09 19:29:22 +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 = ''
|
2023-10-09 19:29:22 +00:00
|
|
|
ln -sr $out/share/bpftrace/tools/*.bt $out/bin/
|
|
|
|
# do not use /usr/bin/env for shipped tools
|
|
|
|
# If someone can get patchShebangs to work here please fix.
|
|
|
|
sed -i -e "1s:#!/usr/bin/env bpftrace:#!$out/bin/bpftrace:" $out/share/bpftrace/tools/*.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";
|
2023-10-09 19:29:22 +00:00
|
|
|
changelog = "https://github.com/iovisor/bpftrace/releases/tag/v${version}";
|
|
|
|
mainProgram = "bpftrace";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ rvl thoughtpolice martinetd mfrw ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|