at 23.11-beta 122 lines 2.9 kB view raw
1{ audit 2, bash 3, bison 4, cmake 5, elfutils 6, fetchFromGitHub 7, flex 8, iperf 9, lib 10, libbpf 11, llvmPackages 12, luajit 13, makeWrapper 14, netperf 15, nixosTests 16, python3 17, stdenv 18, zip 19}: 20 21python3.pkgs.buildPythonApplication rec { 22 pname = "bcc"; 23 version = "0.28.0"; 24 25 disabled = !stdenv.isLinux; 26 27 src = fetchFromGitHub { 28 owner = "iovisor"; 29 repo = "bcc"; 30 rev = "v${version}"; 31 sha256 = "sha256-+ecSaVroDC2bWbio4JsuwEvHQdCMpxLt7hIkeREMJs8="; 32 }; 33 format = "other"; 34 35 buildInputs = with llvmPackages; [ 36 llvm llvm.dev libclang 37 elfutils luajit netperf iperf 38 flex bash libbpf 39 ]; 40 41 patches = [ 42 # This is needed until we fix 43 # https://github.com/NixOS/nixpkgs/issues/40427 44 ./fix-deadlock-detector-import.patch 45 ]; 46 47 propagatedBuildInputs = [ python3.pkgs.netaddr ]; 48 nativeBuildInputs = [ 49 bison 50 cmake 51 flex 52 llvmPackages.llvm.dev 53 makeWrapper 54 python3.pkgs.setuptools 55 zip 56 ]; 57 58 cmakeFlags = [ 59 "-DBCC_KERNEL_MODULES_DIR=/run/booted-system/kernel-modules/lib/modules" 60 "-DREVISION=${version}" 61 "-DENABLE_USDT=ON" 62 "-DENABLE_CPP_API=ON" 63 "-DCMAKE_USE_LIBBPF_PACKAGE=ON" 64 "-DENABLE_LIBDEBUGINFOD=OFF" 65 ]; 66 67 # to replace this executable path: 68 # https://github.com/iovisor/bcc/blob/master/src/python/bcc/syscall.py#L384 69 ausyscall = "${audit}/bin/ausyscall"; 70 71 postPatch = '' 72 substituteAll ${./libbcc-path.patch} ./libbcc-path.patch 73 patch -p1 < libbcc-path.patch 74 75 substituteAll ${./absolute-ausyscall.patch} ./absolute-ausyscall.patch 76 patch -p1 < absolute-ausyscall.patch 77 78 # https://github.com/iovisor/bcc/issues/3996 79 substituteInPlace src/cc/libbcc.pc.in \ 80 --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ 81 ''; 82 83 preInstall = '' 84 # required for setuptool during install 85 export PYTHONPATH=$out/${python3.sitePackages}:$PYTHONPATH 86 ''; 87 postInstall = '' 88 mkdir -p $out/bin $out/share 89 rm -r $out/share/bcc/tools/old 90 mv $out/share/bcc/tools/doc $out/share 91 mv $out/share/bcc/man $out/share/ 92 93 find $out/share/bcc/tools -type f -executable -print0 | \ 94 while IFS= read -r -d ''$'\0' f; do 95 bin=$out/bin/$(basename $f) 96 if [ ! -e $bin ]; then 97 ln -s $f $bin 98 fi 99 substituteInPlace "$f" \ 100 --replace '$(dirname $0)/lib' "$out/share/bcc/tools/lib" 101 done 102 103 sed -i -e "s!lib=.*!lib=$out/bin!" $out/bin/{java,ruby,node,python}gc 104 ''; 105 106 postFixup = '' 107 wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath" 108 ''; 109 110 outputs = [ "out" "man" ]; 111 112 passthru.tests = { 113 bpf = nixosTests.bpf; 114 }; 115 116 meta = with lib; { 117 description = "Dynamic Tracing Tools for Linux"; 118 homepage = "https://iovisor.github.io/bcc/"; 119 license = licenses.asl20; 120 maintainers = with maintainers; [ ragge mic92 thoughtpolice martinetd ]; 121 }; 122}