1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
{
audit,
bash,
bison,
cmake,
elfutils,
fetchFromGitHub,
flex,
iperf,
lib,
libbpf,
llvmPackages,
luajit,
makeWrapper,
netperf,
nixosTests,
python3Packages,
readline,
replaceVars,
zip,
}:
python3Packages.buildPythonApplication rec {
pname = "bcc";
version = "0.37.0";
pyproject = false;
src = fetchFromGitHub {
owner = "iovisor";
repo = "bcc";
tag = "v${version}";
hash = "sha256-OfQWqZ7yyN+rs6PJP5QUIn07QdxOiBoUEetGQPp6KJo=";
};
patches = [
# This is needed until we fix
# https://github.com/NixOS/nixpkgs/issues/40427
./fix-deadlock-detector-import.patch
# Quick & dirty fix for bashreadline
# https://github.com/NixOS/nixpkgs/issues/328743
./bashreadline.py-remove-dependency-on-elftools.patch
(replaceVars ./absolute-ausyscall.patch {
ausyscall = lib.getExe' audit "ausyscall";
})
];
build-system = [ python3Packages.setuptools ];
dependencies = [ python3Packages.netaddr ];
nativeBuildInputs = [
bison
cmake
flex
llvmPackages.llvm
makeWrapper
zip
];
buildInputs = [
llvmPackages.llvm
llvmPackages.libclang
elfutils
luajit
netperf
iperf
flex
bash
libbpf
];
cmakeFlags = [
(lib.cmakeFeature "BCC_KERNEL_MODULES_DIR" "/run/booted-system/kernel-modules/lib/modules")
(lib.cmakeFeature "REVISION" version)
(lib.cmakeBool "ENABLE_USDT" true)
(lib.cmakeBool "ENABLE_CPP_API" true)
(lib.cmakeBool "CMAKE_USE_LIBBPF_PACKAGE" true)
(lib.cmakeBool "ENABLE_LIBDEBUGINFOD" false)
];
postPatch = ''
substituteInPlace src/python/bcc/libbcc.py \
--replace-fail "libbcc.so.0" "$out/lib/libbcc.so.0"
# https://github.com/iovisor/bcc/issues/3996
substituteInPlace src/cc/libbcc.pc.in \
--replace-fail '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@
substituteInPlace tools/bashreadline.py \
--replace-fail '/bin/bash' '${readline}/lib/libreadline.so'
'';
postInstall = ''
mkdir -p $out/bin $out/share
rm -r $out/share/bcc/tools/old
mv $out/share/bcc/tools/doc $out/share
mv $out/share/bcc/man $out/share/
find $out/share/bcc/tools -type f -executable -print0 | \
while IFS= read -r -d ''$'\0' f; do
bin=$out/bin/$(basename $f)
if [ ! -e $bin ]; then
ln -s $f $bin
fi
substituteInPlace "$f" \
--replace-quiet '$(dirname $0)/lib' "$out/share/bcc/tools/lib"
done
'';
pythonImportsCheck = [ "bcc" ];
postFixup = ''
wrapPythonProgramsIn "$out/share/bcc/tools" "$out ''${pythonPath[*]}"
'';
outputs = [
"out"
"man"
];
passthru.tests = {
bpf = nixosTests.bpf;
};
meta = {
description = "Dynamic Tracing Tools for Linux";
homepage = "https://iovisor.github.io/bcc/";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
ragge
mic92
thoughtpolice
martinetd
ryan4yin
];
platforms = lib.platforms.linux;
};
}
|