From 6809a773a36d3c6c27a08d1114fa8947b0feeb9c Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Wed, 15 Apr 2026 08:45:30 -0400 Subject: [PATCH] atf: fix cross build on Darwin Three issues prevented correct cross-compilation of atf on Darwin: 1. ATF_SHELL was not set, so configure's AC_PATH_PROGS found the build-platform bash in PATH. On Darwin, atf uses darwin.bootstrapStdenv whose initialPath includes the native bash; set ATF_SHELL to darwin.bootstrapStdenv.shell to pin it explicitly. Using the shell string from bootstrapStdenv avoids introducing a new derivation argument, which would force evaluation of pkgsStatic.bashNonInteractive and recreate the infinite recursion that the existing darwin.bootstrapStdenv override prevents. 2. configure's AC_RUN_IFELSE checks (kyua_cv_getopt_plus, kyua_cv_attribute_noreturn, kyua_cv_getcwd_works) try to execute compiled test programs on the build host, which fails when cross- compiling. Pre-set these cache variables so configure skips the run tests. 3. atf-sh and atf-check shebangs referenced the build-platform bash. Add patchShebangs --host to postInstall to rewrite them to the host-platform bash. Fixes #413910 --- pkgs/by-name/at/atf/package.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/by-name/at/atf/package.nix b/pkgs/by-name/at/atf/package.nix index 326419c5f72a..4a9a0e178292 100644 --- a/pkgs/by-name/at/atf/package.nix +++ b/pkgs/by-name/at/atf/package.nix @@ -45,6 +45,18 @@ stdenv'.mkDerivation (finalAttrs: { nativeBuildInputs = [ autoreconfHook ]; + configureFlags = + lib.optionals stdenv.hostPlatform.isDarwin [ + "ATF_SHELL=${darwin.bootstrapStdenv.shell}" + ] + # When cross-compiling, autoconf cannot run test programs on the build host. + # Pre-set cache variables so configure skips those AC_RUN_IFELSE checks. + ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + "kyua_cv_getopt_plus=yes" + "kyua_cv_attribute_noreturn=yes" + "kyua_cv_getcwd_works=yes" + ]; + enableParallelBuilding = true; makeFlags = [