Files
Colin 8abcd1fb04 libpcap: allow building with RDMA protocol support
disabled by default for a couple reasons:
1. enabling would cause a mass-rebuild.
2. libpcap is an indirect input to rdma-core, hence a circular
   dependency. but rdma-core doesn't actually use libpcap: this loop
   will be removed by <https://github.com/NixOS/nixpkgs/pull/498294>.
2026-03-09 17:48:03 +00:00

112 lines
2.1 KiB
Nix

{
lib,
stdenv,
fetchurl,
flex,
bison,
bash,
bashNonInteractive,
bluez,
libnl,
libxcrypt,
pkg-config,
rdma-core,
withBluez ? false,
withRdma ? false,
withRemote ? false,
# for passthru.tests
ettercap,
nmap,
ostinato,
tcpreplay,
vde2,
wireshark,
python3,
haskellPackages,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libpcap";
version = "1.10.6";
__structuredAttrs = true;
src = fetchurl {
url = "https://www.tcpdump.org/release/libpcap-${finalAttrs.version}.tar.gz";
hash = "sha256-hy3REzf+GrAq2dT+4EfJ2iRNaVxt3zTi67cz79Ttiqk=";
};
outputs = [
"out"
"lib"
];
strictDeps = true;
buildInputs = [
bash
]
++ lib.optionals stdenv.hostPlatform.isLinux [ libnl ]
++ lib.optionals withRdma [ rdma-core ]
++ lib.optionals withRemote [ libxcrypt ]
++ lib.optionals withBluez [ bluez ];
nativeBuildInputs = [
flex
bison
]
++ lib.optionals stdenv.hostPlatform.isLinux [ pkg-config ];
# We need to force the autodetection because detection doesn't
# work in pure build environments.
configureFlags = [
"--with-pcap=${if stdenv.hostPlatform.isLinux then "linux" else "bpf"}"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
"--disable-universal"
]
++ lib.optionals withRdma [
"--enable-rdma"
]
++ lib.optionals withRemote [
"--enable-remote"
]
++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "ac_cv_linux_vers=2" ];
postInstall = ''
if [ "$dontDisableStatic" -ne "1" ]; then
rm -f $out/lib/libpcap.a
fi
'';
enableParallelBuilding = true;
outputChecks.lib.disallowedRequisites = [
bash
bashNonInteractive
];
passthru.tests = {
inherit
ettercap
nmap
ostinato
tcpreplay
vde2
wireshark
;
inherit (python3.pkgs) pcapy-ng scapy;
haskell-pcap = haskellPackages.pcap;
};
meta = {
homepage = "https://www.tcpdump.org";
description = "Packet Capture Library";
mainProgram = "pcap-config";
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ fpletz ];
license = lib.licenses.bsd3;
};
})