1{ stdenv, lib, fetchFromGitHub, pkg-config, autoreconfHook
2, curl, apacheHttpd, pcre, apr, aprutil, libxml2
3, luaSupport ? false, lua5, perl
4}:
5
6let luaValue = if luaSupport then lua5 else "no";
7 optional = lib.optional;
8in
9
10stdenv.mkDerivation rec {
11 pname = "modsecurity";
12 version = "2.9.7";
13
14 src = fetchFromGitHub {
15 owner = "SpiderLabs";
16 repo = pname;
17 rev = "v${version}";
18 sha256 = "sha256-hJ8wYeC83dl85bkUXGZKHpHzw9QRgtusj1/+Coxsx0k=";
19 };
20
21 nativeBuildInputs = [ pkg-config autoreconfHook ];
22 buildInputs = [ curl apacheHttpd pcre apr aprutil libxml2 ] ++
23 optional luaSupport lua5;
24
25 configureFlags = [
26 "--enable-standalone-module"
27 "--enable-static"
28 "--with-curl=${curl.dev}"
29 "--with-apxs=${apacheHttpd.dev}/bin/apxs"
30 "--with-pcre=${pcre.dev}"
31 "--with-apr=${apr.dev}"
32 "--with-apu=${aprutil.dev}/bin/apu-1-config"
33 "--with-libxml=${libxml2.dev}"
34 "--with-lua=${luaValue}"
35 ];
36
37 outputs = ["out" "nginx"];
38 # by default modsecurity's install script copies compiled output to httpd's modules folder
39 # this patch removes those lines
40 patches = [ ./Makefile.am.patch ];
41
42 doCheck = true;
43 nativeCheckInputs = [ perl ];
44
45 postInstall = ''
46 mkdir -p $nginx
47 cp -R * $nginx
48 '';
49
50 meta = with lib; {
51 description = "Open source, cross-platform web application firewall (WAF)";
52 license = licenses.asl20;
53 homepage = "https://www.modsecurity.org/";
54 maintainers = with maintainers; [offline];
55 platforms = lib.platforms.linux ++ lib.platforms.darwin;
56 };
57}