nixpkgs/pkgs/os-specific/linux/bpftrace/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

62 lines
1.8 KiB
Nix

{ lib, stdenv, fetchFromGitHub
, cmake, pkgconfig, flex, bison
, llvmPackages, kernel, elfutils
, libelf, libbfd, libbpf, libopcodes, bcc
}:
stdenv.mkDerivation rec {
pname = "bpftrace";
version = "0.11.4";
src = fetchFromGitHub {
owner = "iovisor";
repo = "bpftrace";
rev = "refs/tags/v${version}";
sha256 = "0y4qgm2cpccrsm20rnh92hqplddqsc5q5zhw9nqn2igm3h9i0z7h";
};
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 lib; {
description = "High-level tracing language for Linux eBPF";
homepage = "https://github.com/iovisor/bpftrace";
license = licenses.asl20;
maintainers = with maintainers; [ rvl thoughtpolice ];
};
}