nixpkgs/pkgs/tools/networking/xdp-tools/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 lines
1.8 KiB
Nix
Raw Normal View History

2022-08-07 16:18:27 +02:00
{ lib
, stdenv
, fetchFromGitHub
2022-09-04 20:20:33 +02:00
, fetchpatch
2022-08-07 16:18:27 +02:00
, libbpf
, elfutils
, zlib
, libpcap
, bpftools
2022-09-04 20:20:33 +02:00
, llvmPackages
, pkg-config
2022-08-07 16:18:27 +02:00
, m4
, emacs-nox
, wireshark-cli
2022-09-04 20:20:33 +02:00
, nukeReferences
2022-08-07 16:18:27 +02:00
}:
stdenv.mkDerivation rec {
pname = "xdp-tools";
version = "1.3.1";
2022-08-07 16:18:27 +02:00
src = fetchFromGitHub {
owner = "xdp-project";
repo = "xdp-tools";
rev = "v${version}";
sha256 = "ctggXzc3qA+m2/nJ9lmR/pERj0YyPko3MTttm8e85cU=";
2022-08-07 16:18:27 +02:00
};
patches = [
# Fix function detection for btf__type_cnt()
(fetchpatch {
url = "https://github.com/xdp-project/xdp-tools/commit/a7df567634af77381832a2212c5f5099b07734f3.patch";
sha256 = "n6qG/bojSGUowrAaJWxecYpWdv9OceHkoaGlhbl81hA=";
})
];
2022-09-04 20:20:33 +02:00
outputs = [ "out" "lib" ];
2022-08-07 16:18:27 +02:00
buildInputs = [
libbpf
elfutils
libpcap
zlib
];
depsBuildBuild = [
emacs-nox # to generate man pages from .org
];
2022-08-07 16:18:27 +02:00
nativeBuildInputs = [
bpftools
2022-09-04 20:20:33 +02:00
llvmPackages.clang
llvmPackages.llvm
pkg-config
2022-08-07 16:18:27 +02:00
m4
2022-09-04 20:20:33 +02:00
nukeReferences
];
nativeCheckInputs = [
2022-09-04 20:20:33 +02:00
wireshark-cli # for tshark
2022-08-07 16:18:27 +02:00
];
2022-09-04 20:20:33 +02:00
# When building BPF, the default CC wrapper is interfering a bit too much.
2022-08-07 16:18:27 +02:00
BPF_CFLAGS = "-fno-stack-protector -Wno-error=unused-command-line-argument";
2022-09-04 20:20:33 +02:00
2022-08-07 16:18:27 +02:00
PRODUCTION = 1;
DYNAMIC_LIBXDP = 1;
FORCE_SYSTEM_LIBBPF = 1;
FORCE_EMACS = 1;
2022-09-04 20:20:33 +02:00
makeFlags = [ "PREFIX=$(out)" "LIBDIR=$(lib)/lib" ];
2022-08-07 16:18:27 +02:00
2022-09-04 20:20:33 +02:00
postInstall = ''
# Note that even the static libxdp would refer to BPF_OBJECT_DIR ?=$(LIBDIR)/bpf
rm "$lib"/lib/*.a
# Drop unfortunate references to glibc.dev/include at least from $lib
nuke-refs "$lib"/lib/bpf/*.o
2022-08-07 16:18:27 +02:00
'';
meta = with lib; {
homepage = "https://github.com/xdp-project/xdp-tools";
description = "Library and utilities for use with XDP";
license = with licenses; [ gpl2 lgpl21 bsd2 ];
2022-11-17 23:39:09 +01:00
maintainers = with maintainers; [ tirex vcunat vifino ];
2022-08-07 16:18:27 +02:00
platforms = platforms.linux;
};
}