2021-12-13 10:04:58 +01:00
|
|
|
{ fetchFromGitHub
|
2022-06-09 23:37:56 +02:00
|
|
|
, elfutils
|
2021-12-13 10:04:58 +01:00
|
|
|
, pkg-config
|
|
|
|
, stdenv
|
|
|
|
, zlib
|
|
|
|
, lib
|
2023-05-06 18:45:28 +02:00
|
|
|
|
|
|
|
# for passthru.tests
|
|
|
|
, knot-dns
|
2021-12-26 00:21:59 +01:00
|
|
|
, nixosTests
|
2023-05-06 18:45:28 +02:00
|
|
|
, systemd
|
|
|
|
, tracee
|
2019-05-21 20:06:36 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "libbpf";
|
2024-07-11 22:54:41 +02:00
|
|
|
version = "1.4.5";
|
2019-05-21 20:06:36 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-12-13 10:04:58 +01:00
|
|
|
owner = "libbpf";
|
|
|
|
repo = "libbpf";
|
|
|
|
rev = "v${version}";
|
2024-07-11 22:54:41 +02:00
|
|
|
hash = "sha256-GQbx3LaGrFTwEtUsP7V/Y1Keoa4dSmDxhmSTsML+tVk=";
|
2019-05-21 20:06:36 +02:00
|
|
|
};
|
|
|
|
|
2021-01-19 07:50:56 +01:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2022-06-09 23:37:56 +02:00
|
|
|
buildInputs = [ elfutils zlib ];
|
2019-05-21 20:06:36 +02:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
2022-01-10 20:45:19 +01:00
|
|
|
makeFlags = [ "PREFIX=$(out)" "-C src" ];
|
2019-05-21 20:06:36 +02:00
|
|
|
|
2021-12-13 10:04:58 +01:00
|
|
|
passthru.tests = {
|
2023-05-06 18:45:28 +02:00
|
|
|
inherit knot-dns tracee;
|
2021-12-13 10:04:58 +01:00
|
|
|
bpf = nixosTests.bpf;
|
2023-05-06 18:45:28 +02:00
|
|
|
systemd = systemd.override { withLibBPF = true; };
|
2021-12-13 10:04:58 +01:00
|
|
|
};
|
|
|
|
|
2021-12-04 12:25:09 +01:00
|
|
|
postInstall = ''
|
|
|
|
# install linux's libbpf-compatible linux/btf.h
|
2022-02-11 08:54:53 +01:00
|
|
|
install -Dm444 include/uapi/linux/*.h -t $out/include/linux
|
2021-12-04 12:25:09 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-19 07:50:56 +01:00
|
|
|
# FIXME: Multi-output requires some fixes to the way the pkg-config file is
|
2019-05-21 20:06:36 +02:00
|
|
|
# constructed (it gets put in $out instead of $dev for some reason, with
|
|
|
|
# improper paths embedded). Don't enable it for now.
|
|
|
|
|
|
|
|
# outputs = [ "out" "dev" ];
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2024-04-04 21:42:18 +02:00
|
|
|
description = "Library for loading eBPF programs and reading and manipulating eBPF objects from user-space";
|
2021-12-13 10:04:58 +01:00
|
|
|
homepage = "https://github.com/libbpf/libbpf";
|
|
|
|
license = with licenses; [ lgpl21 /* or */ bsd2 ];
|
2021-12-04 12:25:09 +01:00
|
|
|
maintainers = with maintainers; [ thoughtpolice vcunat saschagrunert martinetd ];
|
2021-12-13 10:04:58 +01:00
|
|
|
platforms = platforms.linux;
|
2019-05-21 20:06:36 +02:00
|
|
|
};
|
|
|
|
}
|