@ -5,7 +5,20 @@
, withStream ? true
, withMail ? false
, modules ? [ ]
, version , sha256 , . . .
, . . .
} :
{ pname ? " n g i n x "
, 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 v ersion then mod . ${ attrPath } or [ ]
else throw " M o d u l e a t ${ toString mod . src } d o e s n o t s u p p o r t n g i n x v e r s i o n ${ v ersion} ! " ) ;
if supports nginxV ersion then mod . ${ attrPath } or [ ]
else throw " M o d u l e a t ${ toString mod . src } d o e s n o t s u p p o r t n g i n x v e r s i o n ${ nginxV ersion} ! " ) ;
in
stdenv . mkDerivation {
pname = " n g i n x " ;
inherit pname ;
inherit version ;
inherit nginxVersion ;
src = fetchurl {
src = if src != null then src else fetchurl {
url = " h t t p s : / / n g i n x . o r g / d o w n l o a d / n g i n x - ${ version } . t a r . g z " ;
inherit sha256 ;
} ;
buildInputs = [ openssl zlib pcre libxml2 libxslt gd geoip perl ]
++ buildInputs
++ mapModules " i n p u t s " ;
configureFlags = [
@ -71,6 +86,7 @@ stdenv.mkDerivation {
]
++ optional ( gd != null ) " - - w i t h - h t t p _ i m a g e _ f i l t e r _ m o d u l e "
++ optional ( with stdenv . hostPlatform ; isLinux || isFreeBSD ) " - - w i t h - f i l e - a i o "
++ configureFlags
++ map ( mod : " - - a d d - m o d u l e = ${ 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 = " $ N I X _ S T O R E " nixStoreDirLen = " ' ' ${ #NIX_STORE}"
'' ;
} ) ++ stdenv . lib . optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
( fetchpatch {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / o p e n w r t / p a c k a g e s / m a s t e r / n e t / n g i n x / p a t c h e s / 1 0 2 - s i z e o f _ t e s t _ f i x . p a t c h " ;
sha256 = " 0 i 2 k 3 0 a c 8 d 7 i n j 9 l 6 b l 0 6 8 4 k j g l a m 2 f 6 8 z 8 l f 3 x g g c c 2 i 5 w z h h 8 a " ;
} )
( fetchpatch {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / o p e n w r t / p a c k a g e s / m a s t e r / n e t / n g i n x / p a t c h e s / 1 0 1 - f e a t u r e _ t e s t _ f i x . p a t c h " ;
sha256 = " 0 v 6 8 9 0 a 8 5 a q m w 6 0 p g j 3 m m 7 g 8 n k a p h g q 6 5 d j 4 v 9 c 6 h 5 8 w d s r c 6 f 0 y " ;
} )
( fetchpatch {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / o p e n w r t / p a c k a g e s / m a s t e r / n e t / n g i n x / p a t c h e s / 1 0 3 - s y s _ n e r r . p a t c h " ;
sha256 = " 0 s 4 9 7 x 6 m k z 9 4 7 a w 2 9 w d y 0 7 3 k 8 d y j q 8 j 9 9 l a x 1 a 1 m z p i k z r 4 r x l m d " ;
} )
] ++ mapModules " p a t c h e s " ;
preConfigure = preConfigure
+ concatMapStringsSep " \n " ( mod : mod . preConfigure or " " ) modules ;
patches = map fixPatch
( singleton ( substituteAll {
src = ./nix-etag-1.15.4.patch ;
preInstall = ''
export nixStoreDir = " $ N I X _ S T O R E " nixStoreDirLen = " ' ' ${ #NIX_STORE}"
'' ;
} ) ++ optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
( fetchpatch {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / o p e n w r t / p a c k a g e s / m a s t e r / n e t / n g i n x / p a t c h e s / 1 0 2 - s i z e o f _ t e s t _ f i x . p a t c h " ;
sha256 = " 0 i 2 k 3 0 a c 8 d 7 i n j 9 l 6 b l 0 6 8 4 k j g l a m 2 f 6 8 z 8 l f 3 x g g c c 2 i 5 w z h h 8 a " ;
} )
( fetchpatch {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / o p e n w r t / p a c k a g e s / m a s t e r / n e t / n g i n x / p a t c h e s / 1 0 1 - f e a t u r e _ t e s t _ f i x . p a t c h " ;
sha256 = " 0 v 6 8 9 0 a 8 5 a q m w 6 0 p g j 3 m m 7 g 8 n k a p h g q 6 5 d j 4 v 9 c 6 h 5 8 w d s r c 6 f 0 y " ;
} )
( fetchpatch {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / o p e n w r t / p a c k a g e s / m a s t e r / n e t / n g i n x / p a t c h e s / 1 0 3 - s y s _ n e r r . p a t c h " ;
sha256 = " 0 s 4 9 7 x 6 m k z 9 4 7 a w 2 9 w d y 0 7 3 k 8 d y j q 8 j 9 9 l a x 1 a 1 m z p i k z r 4 r x l m d " ;
} )
] ++ mapModules " p a t c h e s " ) ;
hardeningEnable = optional ( ! stdenv . isDarwin ) " p i e " ;
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 r e v e r s e p r o x y a n d l i g h t w e i g h t w e b s e r v e r " ;
homepage = http://nginx.org ;
license = licenses . bsd2 ;