1 { lib, stdenv, fetchFromGitHub, openssl, zlib, pcre, libxcrypt, libxml2, libxslt
2 , substituteAll, gd, geoip, gperftools, jemalloc, nixosTests
11 inherit (lib) optional optionals optionalString;
13 stdenv.mkDerivation rec {
17 src = fetchFromGitHub {
21 hash = "sha256-cClSNBlresMHqJrqSFWvUo589TlwJ2tL5FWJG9QBuis=";
25 [ openssl zlib pcre libxcrypt libxml2 libxslt gd geoip gperftools jemalloc ]
26 ++ lib.concatMap (mod: mod.inputs or []) modules;
28 patches = lib.singleton (substituteAll {
29 src = ../nginx/nix-etag-1.15.4.patch;
31 export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}"
34 ./check-resolv-conf.patch
35 ../nginx/nix-skip-check-logs-path.patch
39 "--with-http_ssl_module"
40 "--with-http_v2_module"
41 "--with-http_realip_module"
42 "--with-http_addition_module"
43 "--with-http_xslt_module"
44 "--with-http_geoip_module"
45 "--with-http_sub_module"
46 "--with-http_dav_module"
47 "--with-http_flv_module"
48 "--with-http_mp4_module"
49 "--with-http_gunzip_module"
50 "--with-http_gzip_static_module"
51 "--with-http_auth_request_module"
52 "--with-http_random_index_module"
53 "--with-http_secure_link_module"
54 "--with-http_degradation_module"
55 "--with-http_stub_status_module"
58 "--with-http_slice_module"
59 "--with-select_module"
61 "--with-google_perftools_module"
63 "--http-log-path=/var/log/nginx/access.log"
64 "--error-log-path=/var/log/nginx/error.log"
65 "--pid-path=/var/log/nginx/nginx.pid"
66 "--http-client-body-temp-path=/var/cache/nginx/client_body"
67 "--http-proxy-temp-path=/var/cache/nginx/proxy"
68 "--http-fastcgi-temp-path=/var/cache/nginx/fastcgi"
69 "--http-uwsgi-temp-path=/var/cache/nginx/uwsgi"
70 "--http-scgi-temp-path=/var/cache/nginx/scgi"
71 ] ++ optionals withDebug [
73 ] ++ optionals withMail [
75 "--with-mail_ssl_module"
76 ] ++ optionals (!withMail) [
77 "--without-mail_pop3_module"
78 "--without-mail_imap_module"
79 "--without-mail_smtp_module"
80 ] ++ optionals withStream [
82 "--with-stream_ssl_module"
83 "--with-stream_realip_module"
84 "--with-stream_geoip_module"
85 "--with-stream_ssl_preread_module"
87 ] ++ optionals (!withStream) [
88 "--without-stream_limit_conn_module"
89 "--without-stream_access_module"
90 "--without-stream_geo_module"
91 "--without-stream_map_module"
92 "--without-stream_split_clients_module"
93 "--without-stream_return_module"
94 "--without-stream_upstream_hash_module"
95 "--without-stream_upstream_least_conn_module"
96 "--without-stream_upstream_random_module"
97 "--without-stream_upstream_zone_module"
98 ] ++ optional (gd != null) "--with-http_image_filter_module"
99 ++ optional (with stdenv.hostPlatform; isLinux || isFreeBSD) "--with-file-aio"
100 ++ map (mod: "--add-module=${mod.src}") modules;
102 env.NIX_CFLAGS_COMPILE = "-I${libxml2.dev}/include/libxml2 -Wno-error=implicit-fallthrough"
103 + optionalString stdenv.hostPlatform.isDarwin " -Wno-error=deprecated-declarations";
105 preConfigure = (lib.concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules);
107 hardeningEnable = optional (!stdenv.hostPlatform.isDarwin) "pie";
109 enableParallelBuilding = true;
112 mv $out/sbin $out/bin
117 tests = nixosTests.nginx-variants.tengine;
121 description = "Web server based on Nginx and has many advanced features, originated by Taobao";
122 mainProgram = "nginx";
123 homepage = "https://tengine.taobao.org";
124 license = licenses.bsd2;
125 platforms = platforms.all;
126 maintainers = with maintainers; [ izorkin ];