From 53957a1eb39b2bd438b7e1111c2644d65e3cdfae Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Mon, 9 Feb 2026 12:18:01 +0530 Subject: [PATCH] fix: make Android SDK env vars conditional on abidir ANDROID_SDK_ROOT, ANDROID_NDK_HOME, and androidManifest are only needed for Android builds (when abidir is set). Making them unconditional causes evaluation failures on aarch64-darwin since the Android SDK overlay doesn't support that platform. Co-Authored-By: Claude Opus 4.6 --- nix/default.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index d77862e8f..5dd8d0315 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -45,9 +45,6 @@ in stdenv.mkDerivation { pkgs.darwin.cctools gcc # Necessary for libbacktrace ]; - # Environment variables required for Android builds - ANDROID_SDK_ROOT="${pkgs.androidPkgs.sdk}"; - ANDROID_NDK_HOME="${pkgs.androidPkgs.ndk}"; NIMFLAGS = "-d:disableMarchNative -d:git_revision_override=${revision}"; XDG_CACHE_HOME = "/tmp"; @@ -61,6 +58,15 @@ in stdenv.mkDerivation { configurePhase = '' patchShebangs . vendor/nimbus-build-system > /dev/null + + # build_nim.sh guards "rm -rf dist/checksums" with NIX_BUILD_TOP != "/build", + # but on macOS the nix sandbox uses /private/tmp/... so the check fails and + # dist/checksums (provided via preBuild) gets deleted. Fix the check to skip + # the removal whenever NIX_BUILD_TOP is set (i.e. any nix build). + substituteInPlace vendor/nimbus-build-system/scripts/build_nim.sh \ + --replace 'if [[ "''${NIX_BUILD_TOP}" != "/build" ]]; then' \ + 'if [[ -z "''${NIX_BUILD_TOP}" ]]; then' + make nimbus-build-system-paths make nimbus-build-system-nimble-dir ''; @@ -104,4 +110,7 @@ in stdenv.mkDerivation { license = licenses.mit; platforms = stableSystems; }; -} +} // lib.optionalAttrs (abidir != null) { + ANDROID_SDK_ROOT = "${pkgs.androidPkgs.sdk}"; + ANDROID_NDK_HOME = "${pkgs.androidPkgs.ndk}"; +})