diff options
author | Emily <vcs@emily.moe> | 2020-02-04 22:06:02 +0000 |
---|---|---|
committer | Austin Seipp <aseipp@pobox.com> | 2020-02-04 19:30:40 -0600 |
commit | 6d046e1079601c38540d5eb67ce913632898605b (patch) | |
tree | e3a0a28976e8089499850323f7fc8cbe6bd79400 /pkgs/servers/http/nginx | |
parent | db3182a65d0c95afa197cb61c5be80e1c9a8278f (diff) | |
download | nixlib-6d046e1079601c38540d5eb67ce913632898605b.tar nixlib-6d046e1079601c38540d5eb67ce913632898605b.tar.gz nixlib-6d046e1079601c38540d5eb67ce913632898605b.tar.bz2 nixlib-6d046e1079601c38540d5eb67ce913632898605b.tar.lz nixlib-6d046e1079601c38540d5eb67ce913632898605b.tar.xz nixlib-6d046e1079601c38540d5eb67ce913632898605b.tar.zst nixlib-6d046e1079601c38540d5eb67ce913632898605b.zip |
openresty: rebase on top of nginx package
The primary motivation of this change was to allow third-party modules to be used with OpenResty, but it also results in a significant reduction of code duplication.
Diffstat (limited to 'pkgs/servers/http/nginx')
-rw-r--r-- | pkgs/servers/http/nginx/generic.nix | 74 | ||||
-rw-r--r-- | pkgs/servers/http/nginx/mainline.nix | 4 | ||||
-rw-r--r-- | pkgs/servers/http/nginx/stable.nix | 4 |
3 files changed, 50 insertions, 32 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; diff --git a/pkgs/servers/http/nginx/mainline.nix b/pkgs/servers/http/nginx/mainline.nix index e300c5b7a95d..8626dd4a7626 100644 --- a/pkgs/servers/http/nginx/mainline.nix +++ b/pkgs/servers/http/nginx/mainline.nix @@ -1,6 +1,6 @@ { callPackage, ... }@args: -callPackage ./generic.nix (args // { +callPackage ./generic.nix args { version = "1.17.8"; sha256 = "0nwn4md8sxhks2j77qq1nvk5pfz3yykfhh2b507b6l2idp7kxllp"; -}) +} diff --git a/pkgs/servers/http/nginx/stable.nix b/pkgs/servers/http/nginx/stable.nix index 31aeaa6f0843..001ea60839a2 100644 --- a/pkgs/servers/http/nginx/stable.nix +++ b/pkgs/servers/http/nginx/stable.nix @@ -1,6 +1,6 @@ { callPackage, ... } @ args: -callPackage ./generic.nix (args // { +callPackage ./generic.nix args { version = "1.16.1"; sha256 = "0az3vf463b538ajvaq94hsz9ipmjgnamfj1jy0v5flfks5njl77i"; -}) +} |