From 5953ae56d8550d2a5433aa54b62ec9fa3595915e Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 21 May 2025 16:53:08 -0600 Subject: [PATCH] Don't trigger the evaluation of apple-sdk in Linux stdenv During the Apple SDK revamp of #346043, cc-wrapper and bintools-wrapper were modified to automatically add a fallback SDK if $DEVELOPER_DIR is not set [^1]. However, because of the order of the && operands, apple-sdk is always evaluated even when it's not needed. Flip the && operands so we only trigger the evaluation when targeting Darwin. [^1]: 51755b0c00881bfe1602db0eb689efd2c66bcc20 --- pkgs/build-support/bintools-wrapper/default.nix | 2 +- pkgs/build-support/cc-wrapper/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 195a7091242a..4618b1cbba52 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -492,7 +492,7 @@ stdenvNoCC.mkDerivation { darwinMinVersionVariable ; } - // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) { + // lib.optionalAttrs (stdenvNoCC.targetPlatform.isDarwin && apple-sdk != null) { # Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`. fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk; }; diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index f12fe4d18bec..b9df3fc1b2b0 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -889,7 +889,7 @@ stdenvNoCC.mkDerivation { # These will become empty strings when not targeting Darwin. inherit (targetPlatform) darwinMinVersion darwinMinVersionVariable; } - // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) { + // lib.optionalAttrs (stdenvNoCC.targetPlatform.isDarwin && apple-sdk != null) { # Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`. fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk; };