3
0
Fork 0
forked from mirrors/nixpkgs

nginx/etag-patch: Use Nix store dir from build env

So far, the Nix store directory was hardcoded and if someone uses a
different Nix store directory the patch won't work. Of course, this is
pretty uncommon, but by not only substituting the store directory but
also the length of it we also save a few calls to ngx_strlen(), which
should save us a few cycles.

Signed-off-by: aszlig <aszlig@nix.build>
This commit is contained in:
aszlig 2019-04-18 10:07:55 +02:00
parent d533285224
commit 1f24685d93
No known key found for this signature in database
GPG key ID: 684089CE67EBB691
2 changed files with 9 additions and 6 deletions

View file

@ -1,5 +1,5 @@
{ stdenv, fetchurl, fetchpatch, openssl, zlib, pcre, libxml2, libxslt { stdenv, fetchurl, fetchpatch, openssl, zlib, pcre, libxml2, libxslt
, gd, geoip , substituteAll, gd, geoip
, withDebug ? false , withDebug ? false
, withStream ? true , withStream ? true
, withMail ? false , withMail ? false
@ -75,9 +75,12 @@ stdenv.mkDerivation {
preConfigure = (concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules); preConfigure = (concatMapStringsSep "\n" (mod: mod.preConfigure or "") modules);
patches = [ patches = stdenv.lib.singleton (substituteAll {
./nix-etag-1.15.4.patch src = ./nix-etag-1.15.4.patch;
] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ preInstall = ''
export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}"
'';
}) ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
(fetchpatch { (fetchpatch {
url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/102-sizeof_test_fix.patch"; url = "https://raw.githubusercontent.com/openwrt/packages/master/net/nginx/patches/102-sizeof_test_fix.patch";
sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a"; sha256 = "0i2k30ac8d7inj9l6bl0684kjglam2f68z8lf3xggcc2i5wzhh8a";

View file

@ -36,8 +36,8 @@ index c57ec00c..b7992de2 100644
- r->headers_out.last_modified_time, - r->headers_out.last_modified_time,
- r->headers_out.content_length_n) - r->headers_out.content_length_n)
- - etag->value.data; - - etag->value.data;
+ #define NIX_STORE_DIR "/nix/store" + #define NIX_STORE_DIR "@nixStoreDir@"
+ #define NIX_STORE_LEN ngx_strlen(NIX_STORE_DIR) + #define NIX_STORE_LEN @nixStoreDirLen@
+ +
+ if (r->headers_out.last_modified_time == 1 + if (r->headers_out.last_modified_time == 1
+ && !ngx_strncmp(real, NIX_STORE_DIR, NIX_STORE_LEN) + && !ngx_strncmp(real, NIX_STORE_DIR, NIX_STORE_LEN)