at master 77 lines 1.7 kB view raw
1{ 2 fetchFromGitHub, 3 elfutils, 4 pkg-config, 5 stdenv, 6 zlib, 7 lib, 8 9 # for passthru.tests 10 knot-dns, 11 nixosTests, 12 systemd, 13 tracee, 14}: 15 16stdenv.mkDerivation rec { 17 pname = "libbpf"; 18 version = "1.6.2"; 19 20 src = fetchFromGitHub { 21 owner = "libbpf"; 22 repo = "libbpf"; 23 rev = "v${version}"; 24 hash = "sha256-igjjwirg3O5mC3DzGCAO9OgrH2drnE/gV6NH7ZLNnFE="; 25 }; 26 27 patches = [ 28 # Fix redefinition when using linux/netlink.h from libbpf with musl 29 # https://github.com/libbpf/libbpf/pull/919 30 ./sync-uapi-move-constants-from-linux-kernel-h-to-linux-const-h.patch 31 ]; 32 33 nativeBuildInputs = [ pkg-config ]; 34 buildInputs = [ 35 elfutils 36 zlib 37 ]; 38 39 enableParallelBuilding = true; 40 makeFlags = [ 41 "PREFIX=$(out)" 42 "-C src" 43 ]; 44 45 passthru.tests = { 46 inherit knot-dns tracee; 47 bpf = nixosTests.bpf; 48 systemd = systemd.override { withLibBPF = true; }; 49 }; 50 51 postInstall = '' 52 # install linux's libbpf-compatible linux/btf.h 53 install -Dm444 include/uapi/linux/*.h -t $out/include/linux 54 ''; 55 56 # FIXME: Multi-output requires some fixes to the way the pkg-config file is 57 # constructed (it gets put in $out instead of $dev for some reason, with 58 # improper paths embedded). Don't enable it for now. 59 60 # outputs = [ "out" "dev" ]; 61 62 meta = with lib; { 63 description = "Library for loading eBPF programs and reading and manipulating eBPF objects from user-space"; 64 homepage = "https://github.com/libbpf/libbpf"; 65 license = with licenses; [ 66 lgpl21 # or 67 bsd2 68 ]; 69 maintainers = with maintainers; [ 70 thoughtpolice 71 vcunat 72 saschagrunert 73 martinetd 74 ]; 75 platforms = platforms.linux; 76 }; 77}