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