nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 makeWrapper,
6 bison,
7 flex,
8 geoip,
9 geolite-legacy,
10 libcli,
11 libnet,
12 libnetfilter_conntrack,
13 libnl,
14 libpcap,
15 libsodium,
16 liburcu,
17 ncurses,
18 pkg-config,
19 zlib,
20}:
21
22stdenv.mkDerivation rec {
23 pname = "netsniff-ng";
24 version = "0.6.9";
25
26 src = fetchFromGitHub {
27 repo = "netsniff-ng";
28 owner = "netsniff-ng";
29 rev = "v${version}";
30 hash = "sha256-P1xZqhZ/HJV3fAvh4xhhApZ0+FLDFqvYrZlbvb+FV7I=";
31 };
32
33 nativeBuildInputs = [
34 bison
35 flex
36 makeWrapper
37 pkg-config
38 ];
39
40 buildInputs = [
41 geoip
42 geolite-legacy
43 libcli
44 libnet
45 libnl
46 libnetfilter_conntrack
47 libpcap
48 libsodium
49 liburcu
50 ncurses
51 zlib
52 ];
53
54 # ./configure is not autoGNU but some home-brewn magic
55 configurePhase = ''
56 runHook preConfigure
57
58 patchShebangs configure
59 substituteInPlace configure --replace "which" "command -v"
60 NACL_INC_DIR=${libsodium.dev}/include/sodium NACL_LIB=sodium ./configure
61
62 runHook postConfigure
63 '';
64
65 enableParallelBuilding = true;
66
67 # All files installed to /etc are just static data that can go in the store
68 makeFlags = [
69 "PREFIX=$(out)"
70 "ETCDIR=$(out)/etc"
71 ];
72
73 postInstall = ''
74 # trafgen and bpfc can call out to cpp to process config files.
75 wrapProgram "$out/sbin/trafgen" --prefix PATH ":" "${stdenv.cc}/bin"
76 wrapProgram "$out/sbin/bpfc" --prefix PATH ":" "${stdenv.cc}/bin"
77
78 ln -sv ${geolite-legacy}/share/GeoIP/GeoIP.dat $out/etc/netsniff-ng/country4.dat
79 ln -sv ${geolite-legacy}/share/GeoIP/GeoIPv6.dat $out/etc/netsniff-ng/country6.dat
80 ln -sv ${geolite-legacy}/share/GeoIP/GeoIPCity.dat $out/etc/netsniff-ng/city4.dat
81 ln -sv ${geolite-legacy}/share/GeoIP/GeoIPCityv6.dat $out/etc/netsniff-ng/city6.dat
82 ln -sv ${geolite-legacy}/share/GeoIP/GeoIPASNum.dat $out/etc/netsniff-ng/asname4.dat
83 ln -sv ${geolite-legacy}/share/GeoIP/GeoIPASNumv6.dat $out/etc/netsniff-ng/asname6.dat
84 rm -v $out/etc/netsniff-ng/geoip.conf # updating databases after installation is impossible
85 '';
86
87 meta = with lib; {
88 description = "Swiss army knife for daily Linux network plumbing";
89 longDescription = ''
90 netsniff-ng is a free Linux networking toolkit. Its gain of performance
91 is reached by zero-copy mechanisms, so that on packet reception and
92 transmission the kernel does not need to copy packets from kernel space
93 to user space and vice versa. The toolkit can be used for network
94 development and analysis, debugging, auditing or network reconnaissance.
95 '';
96 homepage = "http://netsniff-ng.org/";
97 license = with licenses; [ gpl2Only ];
98 platforms = platforms.linux;
99 };
100}