about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--maintainers/maintainer-list.nix6
-rw-r--r--pkgs/tools/networking/xdp-tools/default.nix80
-rw-r--r--pkgs/top-level/all-packages.nix4
3 files changed, 90 insertions, 0 deletions
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 79dacff88b1c8..409405868e1d0 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -13420,6 +13420,12 @@
     githubId = 1292007;
     name = "Sébastien Maccagnoni";
   };
+  tirex = {
+    email = "szymon@kliniewski.pl";
+    name = "Szymon Kliniewski";
+    github = "NoneTirex";
+    githubId = 26038207;
+  };
   titanous = {
     email = "jonathan@titanous.com";
     github = "titanous";
diff --git a/pkgs/tools/networking/xdp-tools/default.nix b/pkgs/tools/networking/xdp-tools/default.nix
new file mode 100644
index 0000000000000..4861347e38fe7
--- /dev/null
+++ b/pkgs/tools/networking/xdp-tools/default.nix
@@ -0,0 +1,80 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchpatch
+, libbpf
+, elfutils
+, zlib
+, libpcap
+, llvmPackages
+, pkg-config
+, m4
+, emacs-nox
+, wireshark-cli
+, nukeReferences
+}:
+stdenv.mkDerivation rec {
+  pname = "xdp-tools";
+  version = "1.2.6";
+
+  src = fetchFromGitHub {
+    owner = "xdp-project";
+    repo = "xdp-tools";
+    rev = "v${version}";
+    sha256 = "xKxR20Jz+pGKzazFoZe0i0pv7AuaxdL8Yt3IE4JAje8=";
+  };
+
+  outputs = [ "out" "lib" ];
+
+  patches = [
+    (fetchpatch {
+      # Compat with libbpf 1.0: https://github.com/xdp-project/xdp-tools/pull/221
+      url = "https://github.com/xdp-project/xdp-tools/commit/f8592d0609807f5b2b73d27eb3bd623da4bd1997.diff";
+      sha256 = "+NpR0d5YE1TMFeyidBuXCDkcBTa2W0094nqYiEWKpY4=";
+    })
+  ];
+
+  buildInputs = [
+    libbpf
+    elfutils
+    libpcap
+    zlib
+  ];
+
+  nativeBuildInputs = [
+    llvmPackages.clang
+    llvmPackages.llvm
+    pkg-config
+    m4
+    emacs-nox # to generate man pages from .org
+    nukeReferences
+  ];
+  checkInputs = [
+    wireshark-cli # for tshark
+  ];
+
+  # When building BPF, the default CC wrapper is interfering a bit too much.
+  BPF_CFLAGS = "-fno-stack-protector -Wno-error=unused-command-line-argument";
+
+  PRODUCTION = 1;
+  DYNAMIC_LIBXDP = 1;
+  FORCE_SYSTEM_LIBBPF = 1;
+  FORCE_EMACS = 1;
+
+  makeFlags = [ "PREFIX=$(out)" "LIBDIR=$(lib)/lib" ];
+
+  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
+  '';
+
+  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 ];
+    maintainers = with maintainers; [ tirex vcunat ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 32580f54e941d..1cd3ea826e869 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -12378,6 +12378,10 @@ with pkgs;
 
   xdg-launch = callPackage ../applications/misc/xdg-launch { };
 
+  xdp-tools = callPackage ../tools/networking/xdp-tools {
+    llvmPackages = llvmPackages_14;
+  };
+
   xkbvalidate = callPackage ../tools/X11/xkbvalidate { };
 
   xkeysnail = callPackage ../tools/X11/xkeysnail { };