Files
nixpkgs/pkgs/by-name/bp/bpftrace/package.nix
2026-09-11 00:54:34 +00:00

97 lines
1.8 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
llvmPackages,
elfutils,
bcc,
libbpf,
libbfd,
libopcodes,
glibc,
cereal,
asciidoctor,
cmake,
pkg-config,
flex,
bison,
util-linux,
xxd,
nixosTests,
}:
stdenv.mkDerivation rec {
pname = "bpftrace";
version = "0.27.0";
src = fetchFromGitHub {
owner = "bpftrace";
repo = "bpftrace";
rev = "v${version}";
hash = "sha256-wYDSx2WngWS4Ucj82hLO0G46tiXhqskhMjmv7NuUVfw=";
};
buildInputs = with llvmPackages; [
llvm
libclang
elfutils
bcc
libbpf
libbfd
libopcodes
cereal
asciidoctor
];
nativeBuildInputs = [
cmake
pkg-config
flex
bison
llvmPackages.llvm.dev
util-linux
xxd
];
cmakeFlags = [
"-DLIBBCC_INCLUDE_DIRS=${bcc}/include"
"-DUSE_SYSTEM_LIBBPF=ON"
"-DSYSTEM_INCLUDE_PATHS=${glibc.dev}/include"
];
# Pull BPF scripts into $PATH (next to their bcc program equivalents), but do
# not move them to keep `${pkgs.bpftrace}/share/bpftrace/tools/...` working.
postInstall = ''
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
'';
outputs = [
"out"
"man"
];
passthru.tests = {
inherit (nixosTests) bpf;
};
meta = {
description = "High-level tracing language for Linux eBPF";
homepage = "https://github.com/bpftrace/bpftrace";
changelog = "https://github.com/bpftrace/bpftrace/releases/tag/v${version}";
mainProgram = "bpftrace";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
rvl
thoughtpolice
martinetd
mfrw
illustris
];
platforms = lib.platforms.linux;
};
}