From f4005df861a412e491b564032ed62a0e36af34ed Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 6 Jul 2026 12:00:48 -0400 Subject: [PATCH] nix: restore atf cross overlay dropped in #3810 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 2026-07-03 nightly failed in release-node-sdk/bindings/build-macos (darwin-arm64): atf-aarch64-apple-darwin aborts with "cannot run test program while cross compiling", cascading through libiconv → apple-sdk-14.4 → bindings-node-js-napi. No node/bindings npm nightly has published since 20260630 (and the shared last-nightly watermark from the iOS tag keeps subsequent runs skipping). The overlay was removed in #3810 on the expectation that NixOS/nixpkgs#510292 (merged, present in the pinned nixos-unstable rev) covers it. It does not for this build: the upstream seeds are gated on !buildPlatform.canExecute hostPlatform, and our cross is aarch64-darwin → aarch64-apple-darwin — same arch and kernel, so canExecute is true and the seeds never apply, while autoconf still decides cross_compiling=yes from the triple mismatch. Restore the structurally-gated (buildPlatform != hostPlatform) overlay until the upstream gate matches; double-applying the seeds is harmless. Co-Authored-By: Claude Fable 5 --- nix/lib/patches.nix | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/nix/lib/patches.nix b/nix/lib/patches.nix index d35aa96006..daf9011ba9 100644 --- a/nix/lib/patches.nix +++ b/nix/lib/patches.nix @@ -8,6 +8,56 @@ }; } ) + # atf 0.23's configure.ac uses AC_RUN_IFELSE for three probes that + # cannot execute a compiled test binary during cross-compilation, + # aborting with: + # "configure: error: cannot run test program while cross compiling" + # + # This breaks the aarch64-apple-darwin cross-build chain: + # atf → libiconv → apple-sdk-14.4 → bindings-node-js-napi-* + # See https://github.com/xmtp/libxmtp/issues/3470 + # and https://github.com/xmtp/libxmtp/issues/3476. + # + # Upstreamed as https://github.com/NixOS/nixpkgs/pull/510292 (merged, + # present in the current pin) — but the upstream seeds are gated on + # `!buildPlatform.canExecute hostPlatform`, and our nightly cross is + # aarch64-darwin → aarch64-apple-darwin: same arch and kernel, so + # canExecute is TRUE and the seeds never apply, while autoconf still + # decides cross_compiling=yes from the triple mismatch and aborts + # (broke the 2026-07-03 nightly after #3810 dropped this overlay). + # Keep this structurally-gated copy until the upstream gate is + # `buildPlatform != hostPlatform`; double-applying the seeds when + # both gates fire is harmless (same cache values). + # + # The three AC_RUN_IFELSE cache variables and their justifications: + # + # kyua_cv_getopt_plus (m4/module-application.m4) + # Tests whether getopt(3) accepts a leading '+' for POSIX + # behavior. All target platforms (Darwin, glibc, musl) honour '+'. + # + # kyua_cv_attribute_noreturn (m4/module-defs.m4) + # Tests whether __attribute__((__noreturn__)) is supported by + # checking GCC version >= 2.5. All modern GCC/Clang satisfy this. + # + # kyua_cv_getcwd_works (m4/module-fs.m4) + # Tests whether getcwd(NULL, 0) dynamically allocates. Both + # Darwin and Linux (glibc and musl) support this. + # + # Pre-seeding all three is safe for every target in this flake. + # Gated on cross-compilation so native builds keep pulling from + # cache.nixos.org unchanged. + ( + final: prev: + prev.lib.optionalAttrs (prev.stdenv.buildPlatform != prev.stdenv.hostPlatform) { + atf = prev.atf.overrideAttrs (old: { + configureFlags = (old.configureFlags or [ ]) ++ [ + "kyua_cv_getopt_plus=yes" + "kyua_cv_attribute_noreturn=yes" + "kyua_cv_getcwd_works=yes" + ]; + }); + } + ) # tcl 8.6.16 (pinned via nixpkgs 09061f74...) has multiple # cross-compile bugs when targeting *-unknown-linux-musl, and the # Hydra build farm only caches the x86_64-linux build host (not