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