default.nix (3747B)
1 # There is stuff in the nixpkgs nginx that's quite difficult to 2 # disable if you want the smallest possible nginx for a single use, so 3 # herewith a derivation that allows fine-grained control of all the 4 # --with and --without options. The patches are from nixpkgs (or from 5 # openwrt via nixpkgs, it looks like) and at least one of them is 6 # essential for making the package cross-compilable 7 8 { 9 stdenv, 10 openssl, 11 fetchzip, 12 fetchpatch, 13 pcre, 14 zlib, 15 lib, 16 options ? [ ], 17 }: 18 let 19 # nginx configure script does not accept a with-foo_module flag for 20 # a foo_module that's already included, nor a without-foo_module 21 # for a module that isn't. Ho hum 22 # grep -E 'without.+\)' auto/options | sed -e 's/).*$//g' -e 's/.*--without-//g' 23 defaultEnabled = [ 24 "select_module" 25 "poll_module" 26 "quic_bpf_module" 27 "http" 28 "http-cache" 29 "http_charset_module" 30 "http_gzip_module" 31 "http_ssi_module" 32 "http_userid_module" 33 "http_access_module" 34 "http_auth_basic_module" 35 "http_mirror_module" 36 "http_autoindex_module" 37 "http_status_module" 38 "http_geo_module" 39 "http_map_module" 40 "http_split_clients_module" 41 "http_referer_module" 42 "http_rewrite_module" 43 "http_proxy_module" 44 "http_fastcgi_module" 45 "http_uwsgi_module" 46 "http_scgi_module" 47 "http_grpc_module" 48 "http_memcached_module" 49 "http_limit_conn_module" 50 "http_limit_req_module" 51 "http_empty_gif_module" 52 "http_browser_module" 53 "http_upstream_hash_module" 54 "http_upstream_ip_hash_module" 55 "http_upstream_least_conn_module" 56 "http_upstream_random_module" 57 "http_upstream_keepalive_module" 58 "http_upstream_zone_module" 59 "mail_pop3_module" 60 "mail_imap_module" 61 "mail_smtp_module" 62 "stream_limit_conn_module" 63 "stream_access_module" 64 "stream_geo_module" 65 "stream_map_module" 66 "stream_split_clients_module" 67 "stream_return_module" 68 "stream_pass_module" 69 "stream_set_module" 70 "stream_upstream_hash_module" 71 "stream_upstream_least_conn_module" 72 "stream_upstream_random_module" 73 "stream_upstream_zone_module" 74 "pcre" 75 "pcre2" 76 ]; 77 # for each in defaultEnabled that are not in withFlags, 78 # add a --without option 79 # for each in withFlags that are not in defaultEnabled, 80 # add a --with option 81 withouts = lib.subtractLists options defaultEnabled; 82 withs = lib.subtractLists defaultEnabled options; 83 84 in 85 stdenv.mkDerivation { 86 pname = "nginx-small"; 87 version = ""; 88 buildInputs = [ 89 openssl 90 pcre 91 zlib 92 ]; 93 configureFlags = 94 (map (f: "--with-${f}") withs) 95 ++ (map (f: "--without-${f}") withouts) 96 ++ lib.optional (pcre == null) "--without-http_rewrite_module" 97 ++ lib.optional (zlib == null) "--without-http_gzip_module"; 98 99 env.NIX_CFLAGS_COMPILE = "-Wno-error=cpp"; # musl 100 101 configurePlatforms = [ ]; 102 patches = [ 103 (fetchpatch { 104 url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/102-sizeof_test_fix.patch"; 105 sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a"; 106 }) 107 (fetchpatch { 108 url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/101-feature_test_fix.patch"; 109 sha256 = "0v6890a85aqmw60pgj3mm7g8nkaphgq65dj4v9c6h58wdsrc6f0y"; 110 }) 111 (fetchpatch { 112 url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/103-sys_nerr.patch"; 113 sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd"; 114 }) 115 ]; 116 117 src = fetchzip { 118 url = "https://nginx.org/download/nginx-1.26.2.tar.gz"; 119 hash = "sha256-CQbvqISgca+LBpmTUuF8IuJZC9GNn8kT0hQwzfz+wH8="; 120 }; 121 }