From f25d8cd3288c2aa807284e6d8f5eb6f4b22ae76c Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 27 Aug 2025 23:31:26 +0300 Subject: [PATCH] nginx: Apply patch to fix endianess detection Fixes corrupted date and a corrupte HTTP header field `/nn1R7cu0=3l` ``` date: 52anAoe1x3Wt3H4l1u0sc3.632 GMT curl: (92) Invalid HTTP header field was received: frame type: 1, stream: 1, name: [/nn1R7cu0=3l], value: [bytes] ``` The patch is 4+ years old yet no one has had this problem? Fixes https://www.github.com/NixOS/nixpkgs/issues/437626 --- pkgs/servers/http/nginx/generic.nix | 64 +++++++++++++++++------------ 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix index 34356f77fab4..ac58212aed82 100644 --- a/pkgs/servers/http/nginx/generic.nix +++ b/pkgs/servers/http/nginx/generic.nix @@ -175,32 +175,37 @@ stdenv.mkDerivation { ++ configureFlags ++ map (mod: "--add-module=${mod.src}") modules; - env.NIX_CFLAGS_COMPILE = toString ( - [ - "-I${libxml2.dev}/include/libxml2" - "-Wno-error=implicit-fallthrough" - ( - # zlig-ng patch needs this - if stdenv.cc.isGNU then - "-Wno-error=discarded-qualifiers" - else - "-Wno-error=incompatible-pointer-types-discards-qualifiers" - ) - ] - ++ lib.optionals (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") [ - # fix build vts module on gcc11 - "-Wno-error=stringop-overread" - ] - ++ lib.optionals stdenv.cc.isClang [ - "-Wno-error=deprecated-declarations" - "-Wno-error=gnu-folding-constant" - "-Wno-error=unused-but-set-variable" - ] - ++ lib.optionals stdenv.hostPlatform.isMusl [ - # fix sys/cdefs.h is deprecated - "-Wno-error=cpp" - ] - ); + env = { + NIX_CFLAGS_COMPILE = toString ( + [ + "-I${libxml2.dev}/include/libxml2" + "-Wno-error=implicit-fallthrough" + ( + # zlig-ng patch needs this + if stdenv.cc.isGNU then + "-Wno-error=discarded-qualifiers" + else + "-Wno-error=incompatible-pointer-types-discards-qualifiers" + ) + ] + ++ lib.optionals (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "11") [ + # fix build vts module on gcc11 + "-Wno-error=stringop-overread" + ] + ++ lib.optionals stdenv.cc.isClang [ + "-Wno-error=deprecated-declarations" + "-Wno-error=gnu-folding-constant" + "-Wno-error=unused-but-set-variable" + ] + ++ lib.optionals stdenv.hostPlatform.isMusl [ + # fix sys/cdefs.h is deprecated + "-Wno-error=cpp" + ] + ); + } + // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + CONFIG_BIG_ENDIAN = if stdenv.hostPlatform.isBigEndian then "y" else "n"; + }; configurePlatforms = [ ]; @@ -218,6 +223,9 @@ stdenv.mkDerivation { ./nix-etag-1.15.4.patch ./nix-skip-check-logs-path.patch ] + # Upstream may be against cross-compilation patches. + # https://trac.nginx.org/nginx/ticket/2240 https://trac.nginx.org/nginx/ticket/1928#comment:6 + # That dev quit the project in 2024 so the stance could be different now. ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ (fetchpatch { url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/102-sizeof_test_fix.patch"; @@ -231,6 +239,10 @@ stdenv.mkDerivation { url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/103-sys_nerr.patch"; sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd"; }) + (fetchpatch { + url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/104-endianness_fix.patch"; + sha256 = "sha256-M7V3ZJfKImur2OoqXcoL+CbgFj/huWnfZ4xMCmvkqfc="; + }) ] ++ mapModules "patches" )