vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / pkgs / os-specific / linux / bpftune / default.nix
blob830e214f6ba84ff0a1f51f3c7263f10a24c016e1
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , clang
5 , bpftools
6 , docutils
7 , libbpf
8 , libcap
9 , libnl
10 , nixosTests
13 stdenv.mkDerivation rec {
14   pname = "bpftune";
15   version = "0-unstable-2024-06-07";
17   src = fetchFromGitHub {
18     owner = "oracle";
19     repo = "bpftune";
20     rev = "04bab5dd306b55b3e4e13e261af2480b7ccff9fc";
21     hash = "sha256-kVjvupZ6HxJocwXWOrxUNqEGl0welJRlZwvOmMKqeBA=";
22   };
24   postPatch = ''
25     # otherwise shrink rpath would drop $out/lib from rpath
26     substituteInPlace src/Makefile \
27       --replace-fail /lib64   /lib \
28       --replace-fail /sbin    /bin \
29       --replace-fail ldconfig true
30     substituteInPlace src/bpftune.service \
31       --replace-fail /usr/sbin/bpftune "$out/bin/bpftune"
32     substituteInPlace include/bpftune/libbpftune.h \
33       --replace-fail /usr/lib64/bpftune/       "$out/lib/bpftune/" \
34       --replace-fail /usr/local/lib64/bpftune/ "$out/lib/bpftune/"
35     substituteInPlace src/libbpftune.c \
36       --replace-fail /lib/modules /run/booted-system/kernel-modules/lib/modules
37   '';
39   nativeBuildInputs = [
40     clang
41     bpftools
42     docutils # rst2man
43   ];
45   buildInputs = [
46     libbpf
47     libcap
48     libnl
49   ];
51   makeFlags = [
52     "prefix=${placeholder "out"}"
53     "confprefix=${placeholder "out"}/etc"
54     "BPFTUNE_VERSION=${version}"
55     "NL_INCLUDE=${lib.getDev libnl}/include/libnl3"
56     "BPF_INCLUDE=${lib.getDev libbpf}/include"
57   ];
59   hardeningDisable = [
60     "stackprotector"
61     "zerocallusedregs"
62   ];
64   passthru.tests = {
65     inherit (nixosTests) bpftune;
66   };
68   enableParallelBuilding = true;
70   meta = with lib; {
71     description = "BPF-based auto-tuning of Linux system parameters";
72     mainProgram = "bpftune";
73     homepage = "https://github.com/oracle-samples/bpftune";
74     license = licenses.gpl2Only;
75     maintainers = with maintainers; [ nickcao ];
76   };