diff --git a/pkgs/os-specific/linux/bpftune/default.nix b/pkgs/os-specific/linux/bpftune/default.nix new file mode 100644 index 000000000000..09d5f4756191 --- /dev/null +++ b/pkgs/os-specific/linux/bpftune/default.nix @@ -0,0 +1,64 @@ +{ lib +, stdenv +, fetchFromGitHub +, clang +, bpftools +, docutils +, libbpf +, libcap +, libnl +}: + +stdenv.mkDerivation rec { + pname = "bpftune"; + version = "unstable-2023-05-30"; + + src = fetchFromGitHub { + owner = "oracle-samples"; + repo = "bpftune"; + rev = "bfec6668db29ec83afe2b030440f4d8f1476c1a6"; + hash = "sha256-is7y53c9pBSyywVW8hO0iHsVPQlsCb4LU/cJMGf9ua4="; + }; + + postPatch = '' + # otherwise shrink rpath would drop $out/lib from rpath + substituteInPlace src/Makefile \ + --replace /lib64 /lib \ + --replace /sbin /bin + substituteInPlace src/bpftune.service \ + --replace /usr/sbin/bpftune "$out/bin/bpftune" + substituteInPlace include/bpftune/libbpftune.h \ + --replace /usr/lib64/bpftune/ "$out/lib/bpftune/" \ + --replace /usr/local/lib64/bpftune/ "$out/lib/bpftune/" + ''; + + nativeBuildInputs = [ + clang + bpftools + docutils # rst2man + ]; + + buildInputs = [ + libbpf + libcap + libnl + ]; + + makeFlags = [ + "prefix=${placeholder "out"}" + "BPFTUNE_VERSION=${version}" + "BPF_INCLUDE=${lib.getDev libbpf}/include" + "NL_INCLUDE=${lib.getDev libnl}/include/libnl3" + ]; + + hardeningDisable = [ + "stackprotector" + ]; + + meta = with lib; { + description = "BPF-based auto-tuning of Linux system parameters"; + homepage = "https://github.com/oracle-samples/bpftune"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ nickcao ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6194bb7a42aa..41c5cf37130f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -27219,6 +27219,8 @@ with pkgs; bpf-linker = callPackage ../development/tools/bpf-linker { }; + bpftune = callPackage ../os-specific/linux/bpftune { }; + bpfmon = callPackage ../os-specific/linux/bpfmon { }; bridge-utils = callPackage ../os-specific/linux/bridge-utils { };