diff options
Diffstat (limited to 'pkgs/servers/http/nginx/generic.nix')
-rw-r--r-- | pkgs/servers/http/nginx/generic.nix | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix index 990d7c5cf134..31a501332fff 100644 --- a/pkgs/servers/http/nginx/generic.nix +++ b/pkgs/servers/http/nginx/generic.nix @@ -5,7 +5,20 @@ , withStream ? true , withMail ? false , modules ? [] -, version, sha256, ... +, ... +}: + +{ pname ? "nginx" +, version +, nginxVersion ? version +, src ? null # defaults to upstream nginx ${version} +, sha256 ? null # when not specifying src +, configureFlags ? [] +, buildInputs ? [] +, fixPatch ? p: p +, preConfigure ? "" +, postInstall ? null +, meta ? null }: with stdenv.lib; @@ -16,21 +29,23 @@ let (mod: let supports = mod.supports or (_: true); in - if supports version then mod.${attrPath} or [] - else throw "Module at ${toString mod.src} does not support nginx version ${version}!"); + if supports nginxVersion then mod.${attrPath} or [] + else throw "Module at ${toString mod.src} does not support nginx version ${nginxVersion}!"); in stdenv.mkDerivation { - pname = "nginx"; + inherit pname; inherit version; + inherit nginxVersion; - src = fetchurl { + src = if src != null then src else fetchurl { url = "https://nginx.org/download/nginx-${version}.tar.gz"; inherit sha256; }; buildInputs = [ openssl zlib pcre libxml2 libxslt gd geoip perl ] + ++ buildInputs ++ mapModules "inputs"; configureFlags = [ @@ -71,6 +86,7 @@ stdenv.mkDerivation { ] ++ optional (gd != null) "--with-http_image_filter_module" ++ optional (with stdenv.hostPlatform; isLinux || isFreeBSD) "--with-file-aio" + ++ configureFlags ++ map (mod: "--add-module=${mod.src}") modules; NIX_CFLAGS_COMPILE = toString ([ @@ -80,33 +96,35 @@ stdenv.mkDerivation { configurePlatforms = []; - preConfigure = (concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules); - - patches = stdenv.lib.singleton (substituteAll { - src = ./nix-etag-1.15.4.patch; - preInstall = '' - export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}" - ''; - }) ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - (fetchpatch { - url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/102-sizeof_test_fix.patch"; - sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a"; - }) - (fetchpatch { - url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/101-feature_test_fix.patch"; - sha256 = "0v6890a85aqmw60pgj3mm7g8nkaphgq65dj4v9c6h58wdsrc6f0y"; - }) - (fetchpatch { - url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/103-sys_nerr.patch"; - sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd"; - }) - ] ++ mapModules "patches"; + preConfigure = preConfigure + + concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules; + + patches = map fixPatch + (singleton (substituteAll { + src = ./nix-etag-1.15.4.patch; + preInstall = '' + export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}" + ''; + }) ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/102-sizeof_test_fix.patch"; + sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/101-feature_test_fix.patch"; + sha256 = "0v6890a85aqmw60pgj3mm7g8nkaphgq65dj4v9c6h58wdsrc6f0y"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/103-sys_nerr.patch"; + sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd"; + }) + ] ++ mapModules "patches"); hardeningEnable = optional (!stdenv.isDarwin) "pie"; enableParallelBuilding = true; - postInstall = '' + postInstall = if postInstall != null then postInstall else '' mv $out/sbin $out/bin ''; @@ -115,7 +133,7 @@ stdenv.mkDerivation { tests.nginx = nixosTests.nginx; }; - meta = { + meta = if meta != null then meta else { description = "A reverse proxy and lightweight webserver"; homepage = http://nginx.org; license = licenses.bsd2; |