about summary refs log tree commit diff
path: root/pkgs/os-specific
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2023-07-18 12:43:02 +0200
committerGitHub <noreply@github.com>2023-07-18 12:43:02 +0200
commit065fd18e5cb2c569132499da2e60e41e0f046b7a (patch)
treeec7c07993c18bdd46a353f44c7f97e911c75aac5 /pkgs/os-specific
parentf3e2dc94764ea027b2b2d230382664b2aa768890 (diff)
parent3f751bfdf6d1086317d175b628a17690605cccd1 (diff)
Merge pull request #240452 from NickCao/bpftune
Diffstat (limited to 'pkgs/os-specific')
-rw-r--r--pkgs/os-specific/linux/bpftune/default.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/bpftune/default.nix b/pkgs/os-specific/linux/bpftune/default.nix
new file mode 100644
index 0000000000000..da1bd1b384bbf
--- /dev/null
+++ b/pkgs/os-specific/linux/bpftune/default.nix
@@ -0,0 +1,73 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, clang
+, bpftools
+, docutils
+, libbpf
+, libcap
+, libnl
+, nixosTests
+}:
+
+stdenv.mkDerivation rec {
+  pname = "bpftune";
+  version = "unstable-2023-07-14";
+
+  src = fetchFromGitHub {
+    owner = "oracle-samples";
+    repo = "bpftune";
+    rev = "66620152bf8c37ab592e9273fe87e567126801c2";
+    hash = "sha256-U0O+F1DBF1xiaUKklwpZORBwF1T9wHM0SPQKUNaxKZk=";
+  };
+
+  postPatch = ''
+    # otherwise shrink rpath would drop $out/lib from rpath
+    substituteInPlace src/Makefile \
+      --replace /lib64   /lib \
+      --replace /sbin    /bin \
+      --replace ldconfig true
+    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"}"
+    "confprefix=${placeholder "out"}/etc"
+    "BPFTUNE_VERSION=${version}"
+    "BPF_INCLUDE=${lib.getDev libbpf}/include"
+    "NL_INCLUDE=${lib.getDev libnl}/include/libnl3"
+  ];
+
+  hardeningDisable = [
+    "stackprotector"
+  ];
+
+  passthru.tests = {
+    inherit (nixosTests) bpftune;
+  };
+
+  enableParallelBuilding = true;
+
+  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 ];
+  };
+}