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.
This commit is contained in:
@@ -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);
|
||||
preConfigure = 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";
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{ callPackage, ... }@args:
|
||||
|
||||
callPackage ./generic.nix (args // {
|
||||
callPackage ./generic.nix args {
|
||||
version = "1.17.8";
|
||||
sha256 = "0nwn4md8sxhks2j77qq1nvk5pfz3yykfhh2b507b6l2idp7kxllp";
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{ callPackage, ... } @ args:
|
||||
|
||||
callPackage ./generic.nix (args // {
|
||||
callPackage ./generic.nix args {
|
||||
version = "1.16.1";
|
||||
sha256 = "0az3vf463b538ajvaq94hsz9ipmjgnamfj1jy0v5flfks5njl77i";
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user