@@ -0,0 +1,125 @@
1+{ stdenv
2+, lib
3+, fetchurl
4+, pkgconfig
5+, makeWrapper
6+, file
7+, geoip
8+, hyperscan
9+, jansson
10+, libcap_ng
11+, libevent
12+, libnet
13+, libnetfilter_log
14+, libnetfilter_queue
15+, libnfnetlink
16+, libpcap
17+, libyaml
18+, luajit
19+, nspr
20+, nss
21+, pcre
22+, python
23+, zlib
24+, redisSupport ? true, redis, hiredis
25+, rustSupport ? true, rustc, cargo
26+}: let
27+ libmagic = file;
28+ hyperscanSupport = stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux";
29+in
30+stdenv.mkDerivation rec {
31+ pname = "suricata";
32+ version = "4.1.4";
33+
34+ src = fetchurl {
35+ url = "https://www.openinfosecfoundation.org/download/${pname}-${version}.tar.gz";
36+ sha256 = "02901wjf90171rhkymcgp0h48hkn3wv8iwrhz4d8ppraz68hv99d";
37+ };
38+
39+ nativeBuildInputs = [
40+ makeWrapper
41+ pkgconfig
42+ ];
43+
44+ buildInputs = [
45+ geoip
46+ jansson
47+ libcap_ng
48+ libevent
49+ libmagic
50+ libnet
51+ libnetfilter_log
52+ libnetfilter_queue
53+ libnfnetlink
54+ libpcap
55+ libyaml
56+ luajit
57+ nspr
58+ nss
59+ pcre
60+ python
61+ zlib
62+ ]
63+ ++ lib.optional hyperscanSupport [ hyperscan ]
64+ ++ lib.optional redisSupport [ redis hiredis ]
65+ ++ lib.optional rustSupport [ rustc cargo ]
66+ ;
67+
68+ enableParallelBuilding = true;
69+
70+ configureFlags = [
71+ "--disable-gccmarch-native"
72+ "--enable-afl"
73+ "--enable-af-packet"
74+ "--enable-gccprotect"
75+ "--enable-geoip"
76+ "--enable-luajit"
77+ "--enable-nflog"
78+ "--enable-nfqueue"
79+ "--enable-pie"
80+ "--disable-prelude"
81+ "--enable-python"
82+ "--enable-unix-socket"
83+ "--localstatedir=/var"
84+ "--sysconfdir=/etc"
85+ "--with-libnet-includes=${libnet}/include"
86+ "--with-libnet-libraries=${libnet}/lib"
87+ ]
88+ ++ lib.optional hyperscanSupport [
89+ "--with-libhs-includes=${hyperscan}/include"
90+ "--with-libhs-libraries=${hyperscan}/lib"
91+ ]
92+ ++ lib.optional redisSupport [ "--enable-hiredis" ]
93+ ++ lib.optional rustSupport [
94+ "--enable-rust"
95+ "--enable-rust-experimental"
96+ ];
97+
98+ installFlags = [
99+ "e_localstatedir=\${TMPDIR}"
100+ "e_logdir=\${TMPDIR}"
101+ "e_logcertsdir=\${TMPDIR}"
102+ "e_logfilesdir=\${TMPDIR}"
103+ "e_rundir=\${TMPDIR}"
104+ "e_sysconfdir=\${out}/etc/suricata"
105+ "e_sysconfrulesdir=\${out}/etc/suricata/rules"
106+ "localstatedir=\${TMPDIR}"
107+ "runstatedir=\${TMPDIR}"
108+ "sysconfdir=\${out}/etc"
109+ ];
110+
111+ installTargets = "install install-conf";
112+
113+ postInstall = ''
114+ wrapProgram "$out/bin/suricatasc" \
115+ --prefix PYTHONPATH : $PYTHONPATH:$(toPythonPath "$out")
116+ '';
117+
118+ meta = with stdenv.lib; {
119+ description = "A free and open source, mature, fast and robust network threat detection engine";
120+ homepage = "https://suricata-ids.org";
121+ license = licenses.gpl2;
122+ platforms = platforms.linux;
123+ maintainers = with maintainers; [ magenbluten ];
124+ };
125+}