Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 86 lines 1.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 flex, 6 bison, 7 bluez, 8 libnl, 9 libxcrypt, 10 pkg-config, 11 withBluez ? false, 12 withRemote ? false, 13 14 # for passthru.tests 15 ettercap, 16 nmap, 17 ostinato, 18 tcpreplay, 19 vde2, 20 wireshark, 21 python3, 22 haskellPackages, 23}: 24 25stdenv.mkDerivation rec { 26 pname = "libpcap"; 27 version = "1.10.5"; 28 29 src = fetchurl { 30 url = "https://www.tcpdump.org/release/${pname}-${version}.tar.gz"; 31 hash = "sha256-N87ZChmjAqfzLkWCJKAMNlwReQXCzTWsVEtogKgUiPA="; 32 }; 33 34 buildInputs = 35 lib.optionals stdenv.hostPlatform.isLinux [ libnl ] ++ lib.optionals withRemote [ libxcrypt ]; 36 37 nativeBuildInputs = [ 38 flex 39 bison 40 ] 41 ++ lib.optionals stdenv.hostPlatform.isLinux [ pkg-config ] 42 ++ lib.optionals withBluez [ bluez.dev ]; 43 44 # We need to force the autodetection because detection doesn't 45 # work in pure build environments. 46 configureFlags = [ 47 "--with-pcap=${if stdenv.hostPlatform.isLinux then "linux" else "bpf"}" 48 ] 49 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 50 "--disable-universal" 51 ] 52 ++ lib.optionals withRemote [ 53 "--enable-remote" 54 ] 55 ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "ac_cv_linux_vers=2" ]; 56 57 postInstall = '' 58 if [ "$dontDisableStatic" -ne "1" ]; then 59 rm -f $out/lib/libpcap.a 60 fi 61 ''; 62 63 enableParallelBuilding = true; 64 65 passthru.tests = { 66 inherit 67 ettercap 68 nmap 69 ostinato 70 tcpreplay 71 vde2 72 wireshark 73 ; 74 inherit (python3.pkgs) pcapy-ng scapy; 75 haskell-pcap = haskellPackages.pcap; 76 }; 77 78 meta = with lib; { 79 homepage = "https://www.tcpdump.org"; 80 description = "Packet Capture Library"; 81 mainProgram = "pcap-config"; 82 platforms = platforms.unix; 83 maintainers = with maintainers; [ fpletz ]; 84 license = licenses.bsd3; 85 }; 86}