nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 openssl,
6 zlib,
7 pcre,
8 libxcrypt,
9 libxml2,
10 libxslt,
11 replaceVars,
12 gd,
13 geoip,
14 gperftools,
15 jemalloc,
16 nixosTests,
17 withDebug ? false,
18 withMail ? false,
19 withStream ? false,
20 modules ? [ ],
21 ...
22}:
23
24let
25 inherit (lib) optional optionals optionalString;
26in
27stdenv.mkDerivation rec {
28 version = "3.1.0";
29 pname = "tengine";
30
31 src = fetchFromGitHub {
32 owner = "alibaba";
33 repo = pname;
34 rev = version;
35 hash = "sha256-cClSNBlresMHqJrqSFWvUo589TlwJ2tL5FWJG9QBuis=";
36 };
37
38 buildInputs = [
39 openssl
40 zlib
41 pcre
42 libxcrypt
43 libxml2
44 libxslt
45 gd
46 geoip
47 gperftools
48 jemalloc
49 ]
50 ++ lib.concatMap (mod: mod.inputs or [ ]) modules;
51
52 patches = [
53 ../nginx/nix-etag-1.15.4.patch
54 ./check-resolv-conf.patch
55 ../nginx/nix-skip-check-logs-path.patch
56 ];
57
58 postPatch = ''
59 substituteInPlace src/http/ngx_http_core_module.c \
60 --replace-fail '@nixStoreDir@' "$NIX_STORE" \
61 --replace-fail '@nixStoreDirLen@' "''${#NIX_STORE}"
62 '';
63
64 configureFlags = [
65 "--with-http_ssl_module"
66 "--with-http_v2_module"
67 "--with-http_realip_module"
68 "--with-http_addition_module"
69 "--with-http_xslt_module"
70 "--with-http_geoip_module"
71 "--with-http_sub_module"
72 "--with-http_dav_module"
73 "--with-http_flv_module"
74 "--with-http_mp4_module"
75 "--with-http_gunzip_module"
76 "--with-http_gzip_static_module"
77 "--with-http_auth_request_module"
78 "--with-http_random_index_module"
79 "--with-http_secure_link_module"
80 "--with-http_degradation_module"
81 "--with-http_stub_status_module"
82 "--with-threads"
83 "--with-pcre-jit"
84 "--with-http_slice_module"
85 "--with-select_module"
86 "--with-poll_module"
87 "--with-google_perftools_module"
88 "--with-jemalloc"
89 "--http-log-path=/var/log/nginx/access.log"
90 "--error-log-path=/var/log/nginx/error.log"
91 "--pid-path=/var/log/nginx/nginx.pid"
92 "--http-client-body-temp-path=/var/cache/nginx/client_body"
93 "--http-proxy-temp-path=/var/cache/nginx/proxy"
94 "--http-fastcgi-temp-path=/var/cache/nginx/fastcgi"
95 "--http-uwsgi-temp-path=/var/cache/nginx/uwsgi"
96 "--http-scgi-temp-path=/var/cache/nginx/scgi"
97 ]
98 ++ optionals withDebug [
99 "--with-debug"
100 ]
101 ++ optionals withMail [
102 "--with-mail"
103 "--with-mail_ssl_module"
104 ]
105 ++ optionals (!withMail) [
106 "--without-mail_pop3_module"
107 "--without-mail_imap_module"
108 "--without-mail_smtp_module"
109 ]
110 ++ optionals withStream [
111 "--with-stream"
112 "--with-stream_ssl_module"
113 "--with-stream_realip_module"
114 "--with-stream_geoip_module"
115 "--with-stream_ssl_preread_module"
116 "--with-stream_sni"
117 ]
118 ++ optionals (!withStream) [
119 "--without-stream_limit_conn_module"
120 "--without-stream_access_module"
121 "--without-stream_geo_module"
122 "--without-stream_map_module"
123 "--without-stream_split_clients_module"
124 "--without-stream_return_module"
125 "--without-stream_upstream_hash_module"
126 "--without-stream_upstream_least_conn_module"
127 "--without-stream_upstream_random_module"
128 "--without-stream_upstream_zone_module"
129 ]
130 ++ optional (gd != null) "--with-http_image_filter_module"
131 ++ optional (with stdenv.hostPlatform; isLinux || isFreeBSD) "--with-file-aio"
132 ++ map (mod: "--add-module=${mod.src}") modules;
133
134 env.NIX_CFLAGS_COMPILE =
135 "-I${libxml2.dev}/include/libxml2 -Wno-error=implicit-fallthrough"
136 + optionalString stdenv.hostPlatform.isDarwin " -Wno-error=deprecated-declarations";
137
138 preConfigure = (lib.concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules);
139
140 enableParallelBuilding = true;
141
142 postInstall = ''
143 mv $out/sbin $out/bin
144 '';
145
146 passthru = {
147 inherit modules;
148 tests = nixosTests.nginx-variants.tengine;
149 };
150
151 meta = {
152 description = "Web server based on Nginx and has many advanced features, originated by Taobao";
153 mainProgram = "nginx";
154 homepage = "https://tengine.taobao.org";
155 license = lib.licenses.bsd2;
156 platforms = lib.platforms.all;
157 maintainers = with lib.maintainers; [ izorkin ];
158 };
159}