at 24.05-pre 77 lines 1.8 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, clang 5, bpftools 6, docutils 7, libbpf 8, libcap 9, libnl 10, nixosTests 11}: 12 13stdenv.mkDerivation rec { 14 pname = "bpftune"; 15 version = "unstable-2023-09-11"; 16 17 src = fetchFromGitHub { 18 owner = "oracle"; 19 repo = "bpftune"; 20 rev = "22926812a555eac910eac0699100bac0f8776f1b"; 21 hash = "sha256-BflJc5lYWYFIo9LzKfb34F4V1qOI8ywVjnzOLz605DI="; 22 }; 23 24 postPatch = '' 25 # otherwise shrink rpath would drop $out/lib from rpath 26 substituteInPlace src/Makefile \ 27 --replace /lib64 /lib \ 28 --replace /sbin /bin \ 29 --replace ldconfig true 30 substituteInPlace src/bpftune.service \ 31 --replace /usr/sbin/bpftune "$out/bin/bpftune" 32 substituteInPlace include/bpftune/libbpftune.h \ 33 --replace /usr/lib64/bpftune/ "$out/lib/bpftune/" \ 34 --replace /usr/local/lib64/bpftune/ "$out/lib/bpftune/" 35 substituteInPlace src/libbpftune.c \ 36 --replace /lib/modules /run/booted-system/kernel-modules/lib/modules 37 38 substituteInPlace src/Makefile sample_tuner/Makefile \ 39 --replace 'BPF_INCLUDE := /usr/include' 'BPF_INCLUDE := ${lib.getDev libbpf}/include' \ 40 ''; 41 42 nativeBuildInputs = [ 43 clang 44 bpftools 45 docutils # rst2man 46 ]; 47 48 buildInputs = [ 49 libbpf 50 libcap 51 libnl 52 ]; 53 54 makeFlags = [ 55 "prefix=${placeholder "out"}" 56 "confprefix=${placeholder "out"}/etc" 57 "BPFTUNE_VERSION=${version}" 58 "NL_INCLUDE=${lib.getDev libnl}/include/libnl3" 59 ]; 60 61 hardeningDisable = [ 62 "stackprotector" 63 ]; 64 65 passthru.tests = { 66 inherit (nixosTests) bpftune; 67 }; 68 69 enableParallelBuilding = true; 70 71 meta = with lib; { 72 description = "BPF-based auto-tuning of Linux system parameters"; 73 homepage = "https://github.com/oracle-samples/bpftune"; 74 license = licenses.gpl2Only; 75 maintainers = with maintainers; [ nickcao ]; 76 }; 77}