diff options
Diffstat (limited to 'pkgs/by-name/bp')
-rw-r--r-- | pkgs/by-name/bp/bpftop/package.nix | 40 | ||||
-rw-r--r-- | pkgs/by-name/bp/bpftrace/package.nix | 86 |
2 files changed, 109 insertions, 17 deletions
diff --git a/pkgs/by-name/bp/bpftop/package.nix b/pkgs/by-name/bp/bpftop/package.nix index 9dc4f4df19711..4f912c09e6595 100644 --- a/pkgs/by-name/bp/bpftop/package.nix +++ b/pkgs/by-name/bp/bpftop/package.nix @@ -1,24 +1,27 @@ -{ lib -, rustPlatform -, fetchFromGitHub -, pkg-config -, elfutils -, zlib -, libbpf +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + elfutils, + zlib, + libbpf, + clangStdenv, }: - -rustPlatform.buildRustPackage rec { +let pname = "bpftop"; - version = "0.4.2"; - + version = "0.5.2"; +in +rustPlatform.buildRustPackage.override { stdenv = clangStdenv; } { + inherit pname version; src = fetchFromGitHub { owner = "Netflix"; repo = "bpftop"; - rev = "v${version}"; - hash = "sha256-zYCv3L+xDFAJ4Wo9xwfHJrqPQUv5KiFDbhCdC1Z6qNo="; + rev = "refs/tags/v${version}"; + hash = "sha256-WH/oCnkBcvoouBbkAcyawfAuNR3VsTl5+ZATLpi9d4w="; }; - cargoHash = "sha256-6uPfMxjSrSGrAgJcvzTY/i1ckoW/wIi7D5noOafCvZE="; + cargoHash = "sha256-H9HapuIyJJOSQIR9IvFZaQ+Nz9M0MH12JwbY8r2l+JY="; buildInputs = [ elfutils @@ -26,16 +29,19 @@ rustPlatform.buildRustPackage rec { zlib ]; - nativeBuildInputs = [ - pkg-config + nativeBuildInputs = [ pkg-config ]; + + hardeningDisable = [ + "zerocallusedregs" ]; meta = { - description = "A dynamic real-time view of running eBPF programs"; + description = "Dynamic real-time view of running eBPF programs"; homepage = "https://github.com/Netflix/bpftop"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ _0x4A6F + luftmensch-luftmensch mfrw ]; mainProgram = "bpftop"; diff --git a/pkgs/by-name/bp/bpftrace/package.nix b/pkgs/by-name/bp/bpftrace/package.nix new file mode 100644 index 0000000000000..f1dc1bb4fd7dc --- /dev/null +++ b/pkgs/by-name/bp/bpftrace/package.nix @@ -0,0 +1,86 @@ +{ lib, stdenv, fetchFromGitHub +, llvmPackages, elfutils, bcc +, libbpf, libbfd, libopcodes, glibc +, cereal, asciidoctor +, cmake, pkg-config, flex, bison +, util-linux +, fetchpatch +, nixosTests +}: + +stdenv.mkDerivation rec { + pname = "bpftrace"; + version = "0.21.2"; + + src = fetchFromGitHub { + owner = "iovisor"; + repo = "bpftrace"; + rev = "v${version}"; + hash = "sha256-/2m+5iFE7R+ZEc/VcgWAhkLD/jEK88roUUOUyYODi0U="; + }; + + + buildInputs = with llvmPackages; [ + llvm libclang + elfutils bcc + libbpf libbfd libopcodes + cereal asciidoctor + ]; + + nativeBuildInputs = [ + cmake pkg-config flex bison + llvmPackages.llvm.dev + util-linux + ]; + + # 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" + "-DINSTALL_TOOL_DOCS=OFF" + "-DSYSTEM_INCLUDE_PATHS=${glibc.dev}/include" + ]; + + patches = [ + (fetchpatch { + name = "runqlat-bt-no-includes.patch"; + url = "https://github.com/bpftrace/bpftrace/pull/3262.patch"; + hash = "sha256-9yqaZeG1Uf2cC9Aa40c2QUTQRl8n2NO1nq278hf9P4M="; + }) + (fetchpatch { + name = "kheaders-not-found-message-only-on-error.patch"; + url = "https://github.com/bpftrace/bpftrace/pull/3265.patch"; + hash = "sha256-8AICMzwq5Evy9+hmZhFjccw/HmgZ9t+YIoHApjLv6Uc="; + excludes = [ "CHANGELOG.md" ]; + }) + ]; + + # 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 = { + bpf = nixosTests.bpf; + }; + + meta = with lib; { + description = "High-level tracing language for Linux eBPF"; + homepage = "https://github.com/iovisor/bpftrace"; + changelog = "https://github.com/iovisor/bpftrace/releases/tag/v${version}"; + mainProgram = "bpftrace"; + license = licenses.asl20; + maintainers = with maintainers; [ rvl thoughtpolice martinetd mfrw ]; + platforms = platforms.linux; + }; +} |