Merge pull request #206811 from SuperSandro2000/openresty

This commit is contained in:
Sandro 2022-12-22 03:08:45 +01:00 committed by GitHub
commit 90cf235d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 14 deletions

View File

@ -18,9 +18,11 @@ outer@{ lib, stdenv, fetchurl, fetchpatch, openssl, zlib, pcre, libxml2, libxslt
, src ? null # defaults to upstream nginx ${version} , src ? null # defaults to upstream nginx ${version}
, sha256 ? null # when not specifying src , sha256 ? null # when not specifying src
, configureFlags ? [] , configureFlags ? []
, nativeBuildInputs ? []
, buildInputs ? [] , buildInputs ? []
, extraPatches ? [] , extraPatches ? []
, fixPatch ? p: p , fixPatch ? p: p
, postPatch ? ""
, preConfigure ? "" , preConfigure ? ""
, postInstall ? "" , postInstall ? ""
, meta ? null , meta ? null
@ -48,9 +50,7 @@ assert assertMsg (unique moduleNames == moduleNames)
"nginx: duplicate modules: ${concatStringsSep ", " moduleNames}. A common cause for this is that services.nginx.additionalModules adds a module which the nixos module itself already adds."; "nginx: duplicate modules: ${concatStringsSep ", " moduleNames}. A common cause for this is that services.nginx.additionalModules adds a module which the nixos module itself already adds.";
stdenv.mkDerivation { stdenv.mkDerivation {
inherit pname; inherit pname version nginxVersion;
inherit version;
inherit nginxVersion;
outputs = ["out" "doc"]; outputs = ["out" "doc"];
@ -59,6 +59,9 @@ stdenv.mkDerivation {
inherit sha256; inherit sha256;
}; };
nativeBuildInputs = [ removeReferencesTo ]
++ nativeBuildInputs;
buildInputs = [ openssl zlib pcre libxml2 libxslt gd geoip perl ] buildInputs = [ openssl zlib pcre libxml2 libxslt gd geoip perl ]
++ buildInputs ++ buildInputs
++ mapModules "inputs"; ++ mapModules "inputs";
@ -155,6 +158,8 @@ stdenv.mkDerivation {
] ++ mapModules "patches") ] ++ mapModules "patches")
++ extraPatches; ++ extraPatches;
inherit postPatch;
hardeningEnable = optional (!stdenv.isDarwin) "pie"; hardeningEnable = optional (!stdenv.isDarwin) "pie";
enableParallelBuilding = true; enableParallelBuilding = true;
@ -164,8 +169,6 @@ stdenv.mkDerivation {
cp -r ${nginx-doc}/* $doc cp -r ${nginx-doc}/* $doc
''; '';
nativeBuildInputs = [ removeReferencesTo ];
disallowedReferences = map (m: m.src) modules; disallowedReferences = map (m: m.src) modules;
postInstall = postInstall =

View File

@ -2,6 +2,7 @@
, runCommand , runCommand
, lib , lib
, fetchurl , fetchurl
, perl
, postgresql , postgresql
, nixosTests , nixosTests
, ... , ...
@ -9,17 +10,17 @@
callPackage ../nginx/generic.nix args rec { callPackage ../nginx/generic.nix args rec {
pname = "openresty"; pname = "openresty";
nginxVersion = "1.19.9"; nginxVersion = "1.21.4";
version = "${nginxVersion}.1"; version = "${nginxVersion}.1";
src = fetchurl { src = fetchurl {
url = "https://openresty.org/download/openresty-${version}.tar.gz"; url = "https://openresty.org/download/openresty-${version}.tar.gz";
sha256 = "1xn1d0x2y63z0mi0qq3js6lz6ziba92r7vyyfkj1qc738vjz8vsp"; sha256 = "sha256-DFCTtk94IehQZcmeXU5swxggz9fze5oN7IQgnYeir5k=";
}; };
# generic.nix applies fixPatch on top of every patch defined there. This # generic.nix applies fixPatch on top of every patch defined there.
# allows updating the patch destination, as openresty has nginx source code # This allows updating the patch destination, as openresty has
# in a different folder. # nginx source code in a different folder.
fixPatch = patch: fixPatch = patch:
let name = patch.name or (builtins.baseNameOf patch); in let name = patch.name or (builtins.baseNameOf patch); in
runCommand "openresty-${name}" { src = patch; } '' runCommand "openresty-${name}" { src = patch; } ''
@ -28,14 +29,16 @@ callPackage ../nginx/generic.nix args rec {
--replace "b/" "b/bundle/nginx-${nginxVersion}/" --replace "b/" "b/bundle/nginx-${nginxVersion}/"
''; '';
nativeBuildInputs = [ perl ];
buildInputs = [ postgresql ]; buildInputs = [ postgresql ];
configureFlags = [ "--with-http_postgres_module" ]; postPatch = ''
patchShebangs configure bundle/
preConfigure = ''
patchShebangs .
''; '';
configureFlags = [ "--with-http_postgres_module" ];
postInstall = '' postInstall = ''
ln -s $out/luajit/bin/luajit-2.1.0-beta3 $out/bin/luajit-openresty ln -s $out/luajit/bin/luajit-2.1.0-beta3 $out/bin/luajit-openresty
ln -s $out/nginx/sbin/nginx $out/bin/nginx ln -s $out/nginx/sbin/nginx $out/bin/nginx