From 9e49230e6dcc8315535b4e2c5ade12e87f6d9ab9 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Mon, 27 Apr 2026 14:09:19 -0400 Subject: [PATCH] stdenv.mkDerivation: check if host suffix is necessary Rather than precomputing what the stdenv host suffix should be, we check the condition first. This is even better than turning the concats into multiple comparisons (although I'm going to do that as well), since if hostPlatform == buildPlatform, we never have to evaluate any further. --- pkgs/stdenv/generic/make-derivation.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index d4493b9aaf4f..101d25e5bfaf 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -229,9 +229,8 @@ let canExecuteHostOnBuild = buildPlatform.canExecute hostPlatform; defaultHardeningFlags = (if stdenvHasCC then stdenv.cc else { }).defaultHardeningFlags or knownHardeningFlags; - stdenvHostSuffix = optionalString ( - hostPlatform != buildPlatform && stdenvHasCC - ) "-${hostPlatform.config}"; + hostSuffixNecessary = hostPlatform != buildPlatform && stdenvHasCC; + stdenvHostSuffix = "-${hostPlatform.config}"; stdenvStaticMarker = optionalString isStatic "-static"; userHook = config.stdenv.userHook or null; @@ -529,8 +528,10 @@ let # just used for their side-affects. Those might as well since the # hash can't be the same. See #32986. hostSuffix = optionalString ( - !(attrs ? outputHash) - || + hostSuffixNecessary && + ( + !(attrs ? outputHash) + || ( depsBuildTarget ++ depsBuildTargetPropagated @@ -541,6 +542,7 @@ let ++ depsTargetTarget ++ depsTargetTargetPropagated ) == [ ] + ) ) stdenvHostSuffix; # Disambiguate statically built packages. This was originally