at v206 162 lines 5.0 kB view raw
1{ stdenv, fetchurl, fetchFromGitHub, openssl, zlib, pcre, libxml2, libxslt, expat 2, gd, geoip, luajit 3, curl, apr, aprutil, apacheHttpd, yajl, libcap, modsecurity_standalone 4, rtmp ? false 5, fullWebDAV ? false 6, syslog ? false 7, moreheaders ? false 8, echo ? false 9, modsecurity ? false 10, ngx_lua ? modsecurity || false 11, set_misc ? false 12, fluent ? false 13, extraModules ? [] 14}: 15 16with stdenv.lib; 17 18let 19 version = "1.8.0"; 20 mainSrc = fetchurl { 21 url = "http://nginx.org/download/nginx-${version}.tar.gz"; 22 sha256 = "1mgkkmmwkhmpn68sdvbd73ssv6lpqhh864fsyvc1ij4hk4is3k13"; 23 }; 24 25 rtmp-ext = fetchFromGitHub { 26 owner = "arut"; 27 repo = "nginx-rtmp-module"; 28 rev = "v1.1.7"; 29 sha256 = "0i0fa1znkj7cipy5nlkw4k40klhp9jzk28wxy2vrvd2jvh91x3ma"; 30 }; 31 32 dav-ext = fetchFromGitHub { 33 owner = "arut"; 34 repo = "nginx-dav-ext-module"; 35 rev = "v0.0.3"; 36 sha256 = "1qck8jclxddncjad8yv911s9z7lrd58bp96jf13m0iqk54xghx91"; 37 }; 38 39 syslog-ext = fetchFromGitHub { 40 owner = "yaoweibin"; 41 repo = "nginx_syslog_patch"; 42 rev = "3ca5ba65541637f74467038aa032e2586321d0cb"; 43 sha256 = "0y8dxkx8m1jw4v5zsvw1gfah9vh3ryq0hfmrcbjzcmwp5b5lb1i8"; 44 }; 45 46 moreheaders-ext = fetchFromGitHub { 47 owner = "openresty"; 48 repo = "headers-more-nginx-module"; 49 rev = "v0.26"; 50 sha256 = "01wkqhk8mk8jgmzi7jbzmg5kamffx3lmhj5yfwryvnvs6xqs74wn"; 51 }; 52 53 modsecurity-ext = modsecurity_standalone.nginx; 54 55 echo-ext = fetchFromGitHub { 56 owner = "openresty"; 57 repo = "echo-nginx-module"; 58 rev = "v0.57"; 59 sha256 = "1q0f0zprcn0ypl2qh964cq186l3f40p0z7n7x22m8cxj367vf000"; 60 }; 61 62 lua-ext = fetchFromGitHub { 63 owner = "openresty"; 64 repo = "lua-nginx-module"; 65 rev = "v0.9.16"; 66 sha256 = "0dvdam228jhsrayb22ishljdkgib08bakh8ygn84sq0c2xbidzlp"; 67 }; 68 69 set-misc-ext = fetchFromGitHub { 70 owner = "openresty"; 71 repo = "set-misc-nginx-module"; 72 rev = "v0.28"; 73 sha256 = "1vixj60q0liri7k5ax85grj7q9vvgybkx421bwphbhai5xrjip96"; 74 }; 75 76 fluentd = fetchFromGitHub { 77 owner = "fluent"; 78 repo = "nginx-fluentd-module"; 79 rev = "8af234043059c857be27879bc547c141eafd5c13"; 80 sha256 = "1ycb5zd9sw60ra53jpak1m73zwrjikwhrrh9q6266h1mlyns7zxm"; 81 }; 82 83 develkit-ext = fetchFromGitHub { 84 owner = "simpl"; 85 repo = "ngx_devel_kit"; 86 rev = "v0.2.19"; 87 sha256 = "1cqcasp4lc6yq5pihfcdw4vp4wicngvdc3nqg3bg52r63c1qrz76"; 88 }; 89 90 91in 92 93stdenv.mkDerivation rec { 94 name = "nginx-${version}"; 95 src = mainSrc; 96 97 buildInputs = 98 [ openssl zlib pcre libxml2 libxslt gd geoip 99 ] ++ optional fullWebDAV expat 100 ++ optional ngx_lua luajit 101 ++ optionals modsecurity [ curl apr aprutil apacheHttpd yajl ]; 102 103 LUAJIT_LIB = if ngx_lua then "${luajit}/lib" else ""; 104 LUAJIT_INC = if ngx_lua then "${luajit}/include/luajit-2.0" else ""; 105 106 patches = if syslog then [ "${syslog-ext}/syslog-1.5.6.patch" ] else []; 107 108 configureFlags = [ 109 "--with-select_module" 110 "--with-poll_module" 111 "--with-threads" 112 "--with-http_ssl_module" 113 "--with-http_spdy_module" 114 "--with-http_realip_module" 115 "--with-http_addition_module" 116 "--with-http_xslt_module" 117 "--with-http_image_filter_module" 118 "--with-http_geoip_module" 119 "--with-http_sub_module" 120 "--with-http_dav_module" 121 "--with-http_flv_module" 122 "--with-http_mp4_module" 123 "--with-http_gunzip_module" 124 "--with-http_gzip_static_module" 125 "--with-http_auth_request_module" 126 "--with-http_random_index_module" 127 "--with-http_secure_link_module" 128 "--with-http_degradation_module" 129 "--with-http_stub_status_module" 130 "--with-ipv6" 131 # Install destination problems 132 # "--with-http_perl_module" 133 ] ++ optional rtmp "--add-module=${rtmp-ext}" 134 ++ optional fullWebDAV "--add-module=${dav-ext}" 135 ++ optional syslog "--add-module=${syslog-ext}" 136 ++ optional moreheaders "--add-module=${moreheaders-ext}" 137 ++ optional echo "--add-module=${echo-ext}" 138 ++ optional ngx_lua "--add-module=${develkit-ext} --add-module=${lua-ext}" 139 ++ optional set_misc "--add-module=${set-misc-ext}" 140 ++ optionals (elem stdenv.system (with platforms; linux ++ freebsd)) 141 [ "--with-file-aio" "--with-aio_module" ] 142 ++ optional fluent "--add-module=${fluentd}" 143 ++ optional modsecurity "--add-module=${modsecurity-ext}/nginx/modsecurity" 144 ++ (map (m: "--add-module=${m}") extraModules); 145 146 147 additionalFlags = optionalString stdenv.isDarwin "-Wno-error=deprecated-declarations -Wno-error=conditional-uninitialized"; 148 149 NIX_CFLAGS_COMPILE = optionalString modsecurity "-I${aprutil}/include/apr-1 -I${apacheHttpd}/include -I${apr}/include/apr-1 -I${yajl}/include"; 150 151 preConfigure = '' 152 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2}/include/libxml2 $additionalFlags" 153 ''; 154 155 meta = { 156 description = "A reverse proxy and lightweight webserver"; 157 homepage = http://nginx.org; 158 license = licenses.bsd2; 159 platforms = platforms.all; 160 maintainers = with maintainers; [ thoughtpolice raskin ]; 161 }; 162}