1{ fetchFromGitHub
2, elfutils
3, pkg-config
4, stdenv
5, zlib
6, lib
7
8# for passthru.tests
9, knot-dns
10, nixosTests
11, systemd
12, tracee
13}:
14
15stdenv.mkDerivation rec {
16 pname = "libbpf";
17 version = "1.4.5";
18
19 src = fetchFromGitHub {
20 owner = "libbpf";
21 repo = "libbpf";
22 rev = "v${version}";
23 hash = "sha256-GQbx3LaGrFTwEtUsP7V/Y1Keoa4dSmDxhmSTsML+tVk=";
24 };
25
26 nativeBuildInputs = [ pkg-config ];
27 buildInputs = [ elfutils zlib ];
28
29 enableParallelBuilding = true;
30 makeFlags = [ "PREFIX=$(out)" "-C src" ];
31
32 passthru.tests = {
33 inherit knot-dns tracee;
34 bpf = nixosTests.bpf;
35 systemd = systemd.override { withLibBPF = true; };
36 };
37
38 postInstall = ''
39 # install linux's libbpf-compatible linux/btf.h
40 install -Dm444 include/uapi/linux/*.h -t $out/include/linux
41 '';
42
43 # FIXME: Multi-output requires some fixes to the way the pkg-config file is
44 # constructed (it gets put in $out instead of $dev for some reason, with
45 # improper paths embedded). Don't enable it for now.
46
47 # outputs = [ "out" "dev" ];
48
49 meta = with lib; {
50 description = "Library for loading eBPF programs and reading and manipulating eBPF objects from user-space";
51 homepage = "https://github.com/libbpf/libbpf";
52 license = with licenses; [ lgpl21 /* or */ bsd2 ];
53 maintainers = with maintainers; [ thoughtpolice vcunat saschagrunert martinetd ];
54 platforms = platforms.linux;
55 };
56}