@@ -175,32 +175,37 @@ stdenv.mkDerivation {
175175 ++ configureFlags
176176 ++ map ( mod : "--add-module=${ mod . src } " ) modules ;
177177
178- env . NIX_CFLAGS_COMPILE = toString (
179- [
180- "-I${ libxml2 . dev } /include/libxml2"
181- "-Wno-error=implicit-fallthrough"
182- (
183- # zlig-ng patch needs this
184- if stdenv . cc . isGNU then
185- "-Wno-error=discarded-qualifiers"
186- else
187- "-Wno-error=incompatible-pointer-types-discards-qualifiers"
188- )
189- ]
190- ++ lib . optionals ( stdenv . cc . isGNU && lib . versionAtLeast stdenv . cc . version "11" ) [
191- # fix build vts module on gcc11
192- "-Wno-error=stringop-overread"
193- ]
194- ++ lib . optionals stdenv . cc . isClang [
195- "-Wno-error=deprecated-declarations"
196- "-Wno-error=gnu-folding-constant"
197- "-Wno-error=unused-but-set-variable"
198- ]
199- ++ lib . optionals stdenv . hostPlatform . isMusl [
200- # fix sys/cdefs.h is deprecated
201- "-Wno-error=cpp"
202- ]
203- ) ;
178+ env = {
179+ NIX_CFLAGS_COMPILE = toString (
180+ [
181+ "-I${ libxml2 . dev } /include/libxml2"
182+ "-Wno-error=implicit-fallthrough"
183+ (
184+ # zlig-ng patch needs this
185+ if stdenv . cc . isGNU then
186+ "-Wno-error=discarded-qualifiers"
187+ else
188+ "-Wno-error=incompatible-pointer-types-discards-qualifiers"
189+ )
190+ ]
191+ ++ lib . optionals ( stdenv . cc . isGNU && lib . versionAtLeast stdenv . cc . version "11" ) [
192+ # fix build vts module on gcc11
193+ "-Wno-error=stringop-overread"
194+ ]
195+ ++ lib . optionals stdenv . cc . isClang [
196+ "-Wno-error=deprecated-declarations"
197+ "-Wno-error=gnu-folding-constant"
198+ "-Wno-error=unused-but-set-variable"
199+ ]
200+ ++ lib . optionals stdenv . hostPlatform . isMusl [
201+ # fix sys/cdefs.h is deprecated
202+ "-Wno-error=cpp"
203+ ]
204+ ) ;
205+ }
206+ // lib . optionalAttrs ( stdenv . buildPlatform != stdenv . hostPlatform ) {
207+ CONFIG_BIG_ENDIAN = if stdenv . hostPlatform . isBigEndian then "y" else "n" ;
208+ } ;
204209
205210 configurePlatforms = [ ] ;
206211
@@ -218,6 +223,9 @@ stdenv.mkDerivation {
218223 ./nix-etag-1.15.4.patch
219224 ./nix-skip-check-logs-path.patch
220225 ]
226+ # Upstream may be against cross-compilation patches.
227+ # https://trac.nginx.org/nginx/ticket/2240 https://trac.nginx.org/nginx/ticket/1928#comment:6
228+ # That dev quit the project in 2024 so the stance could be different now.
221229 ++ lib . optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
222230 ( fetchpatch {
223231 url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/102-sizeof_test_fix.patch" ;
@@ -231,6 +239,10 @@ stdenv.mkDerivation {
231239 url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/103-sys_nerr.patch" ;
232240 sha256 = "0s497x6mkz947aw29wdy073k8dyjq8j99lax1a1mzpikzr4rxlmd" ;
233241 } )
242+ ( fetchpatch {
243+ url = "https://raw.githubusercontent.com/openwrt/packages/c057dfb09c7027287c7862afab965a4cd95293a3/net/nginx/patches/104-endianness_fix.patch" ;
244+ sha256 = "sha256-M7V3ZJfKImur2OoqXcoL+CbgFj/huWnfZ4xMCmvkqfc=" ;
245+ } )
234246 ]
235247 ++ mapModules "patches"
236248 )
0 commit comments