From 5326cab419ec91a3954ba1f4db38e2648af74ffd Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 19 Jul 2019 15:19:03 +0800 Subject: [PATCH] use recommended nginx patch --- nixbld-etc-nixos/configuration.nix | 25 +++---- nixbld-etc-nixos/nix-etag-1.15.4.patch | 92 -------------------------- 2 files changed, 13 insertions(+), 104 deletions(-) delete mode 100644 nixbld-etc-nixos/nix-etag-1.15.4.patch diff --git a/nixbld-etc-nixos/configuration.nix b/nixbld-etc-nixos/configuration.nix index 96c7dc8..ed2153c 100644 --- a/nixbld-etc-nixos/configuration.nix +++ b/nixbld-etc-nixos/configuration.nix @@ -215,18 +215,6 @@ ACTION=="add", SUBSYSTEM=="tty", \ }; nixpkgs.config.packageOverrides = super: let self = super.pkgs; in { - # nginx etag patch merged in Nixpkgs 19.09, remove after upgrading - # https://github.com/NixOS/nixpkgs/pull/60578 - nginx = super.nginx.overrideAttrs(oa: { - patches = oa.patches ++ [ - (super.substituteAll { - src = ./nix-etag-1.15.4.patch; - preInstall = '' - export nixStoreDir="$NIX_STORE" nixStoreDirLen="''${#NIX_STORE}" - ''; - }) - ]; - }); hydra = super.hydra.overrideAttrs(oa: { patches = oa.patches ++ [ ./hydra-conda.patch ./hydra-retry.patch ]; hydraPath = oa.hydraPath + ":" + super.lib.makeBinPath [ super.jq ]; @@ -390,6 +378,19 @@ ACTION=="add", SUBSYSTEM=="tty", \ }; }; }; + # not needed after 19.09 - https://github.com/NixOS/nixpkgs/pull/60578 + services.nginx.package = pkgs.nginx.overrideAttrs (drv: { + patches = (drv.patches or []) ++ pkgs.lib.singleton (pkgs.fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/master/" + + "pkgs/servers/http/nginx/nix-etag-1.15.4.patch"; + sha256 = "0i2lfz66204kcm1qdqws07cbq5nh1grxcz1ycp6qhmypl3da8hq4"; + postFetch = '' + substituteInPlace "$out" \ + --subst-var-by nixStoreDir "$NIX_STORE" \ + --subst-var-by nixStoreDirLen "''${#NIX_STORE}" + ''; + }); + }); services.uwsgi = { enable = true; plugins = [ "python3" ]; diff --git a/nixbld-etc-nixos/nix-etag-1.15.4.patch b/nixbld-etc-nixos/nix-etag-1.15.4.patch deleted file mode 100644 index 9dec715..0000000 --- a/nixbld-etc-nixos/nix-etag-1.15.4.patch +++ /dev/null @@ -1,92 +0,0 @@ -From f6a978f024d01202f954483423af1b2d5d5159a6 Mon Sep 17 00:00:00 2001 -From: Yegor Timoshenko -Date: Fri, 28 Sep 2018 03:27:04 +0000 -Subject: [PATCH] If root is in Nix store, set ETag to its path hash - ---- - src/http/ngx_http_core_module.c | 56 +++++++++++++++++++++++++++++---- - 1 file changed, 50 insertions(+), 6 deletions(-) - -diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c -index c57ec00c..b7992de2 100644 ---- a/src/http/ngx_http_core_module.c -+++ b/src/http/ngx_http_core_module.c -@@ -1583,6 +1583,7 @@ ngx_http_set_etag(ngx_http_request_t *r) - { - ngx_table_elt_t *etag; - ngx_http_core_loc_conf_t *clcf; -+ u_char *real, *ptr1, *ptr2; - - clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - -@@ -1598,16 +1599,61 @@ ngx_http_set_etag(ngx_http_request_t *r) - etag->hash = 1; - ngx_str_set(&etag->key, "ETag"); - -- etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); -- if (etag->value.data == NULL) { -+ real = ngx_realpath(clcf->root.data, NULL); -+ -+ if (real == NULL) { - etag->hash = 0; - return NGX_ERROR; - } - -- etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"", -- r->headers_out.last_modified_time, -- r->headers_out.content_length_n) -- - etag->value.data; -+ #define NIX_STORE_DIR "@nixStoreDir@" -+ #define NIX_STORE_LEN @nixStoreDirLen@ -+ -+ if (r->headers_out.last_modified_time == 1 -+ && !ngx_strncmp(real, NIX_STORE_DIR, NIX_STORE_LEN) -+ && real[NIX_STORE_LEN] == '/' -+ && real[NIX_STORE_LEN + 1] != '\0') -+ { -+ ptr1 = real + NIX_STORE_LEN; -+ *ptr1 = '"'; -+ -+ ptr2 = (u_char *) ngx_strchr(ptr1, '-'); -+ -+ if (ptr2 == NULL) { -+ ngx_free(real); -+ etag->hash = 0; -+ return NGX_ERROR; -+ } -+ -+ *ptr2++ = '"'; -+ *ptr2 = '\0'; -+ -+ etag->value.len = ngx_strlen(ptr1); -+ etag->value.data = ngx_pnalloc(r->pool, etag->value.len); -+ -+ if (etag->value.data == NULL) { -+ ngx_free(real); -+ etag->hash = 0; -+ return NGX_ERROR; -+ } -+ -+ ngx_memcpy(etag->value.data, ptr1, etag->value.len); -+ } else { -+ etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); -+ -+ if (etag->value.data == NULL) { -+ ngx_free(real); -+ etag->hash = 0; -+ return NGX_ERROR; -+ } -+ -+ etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"", -+ r->headers_out.last_modified_time, -+ r->headers_out.content_length_n) -+ - etag->value.data; -+ } -+ -+ ngx_free(real); - - r->headers_out.etag = etag; - --- -2.19.0 -