···173173 separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.useLLVM or false);
174174 outputs' = outputs ++ lib.optional separateDebugInfo' "debug";
175175176176+ # Turn a derivation into its outPath without a string context attached.
177177+ # See the comment at the usage site.
178178+ unsafeDerivationToUntrackedOutpath = drv:
179179+ if lib.isDerivation drv
180180+ then builtins.unsafeDiscardStringContext drv.outPath
181181+ else drv;
182182+176183 noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated
177184 ++ depsHostHost ++ depsHostHostPropagated
178185 ++ buildInputs ++ propagatedBuildInputs
···446453 "/bin/sh"
447454 ];
448455 __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
456456+ } //
457457+ # If we use derivations directly here, they end up as build-time dependencies.
458458+ # This is especially problematic in the case of disallowed*, since the disallowed
459459+ # derivations will be built by nix as build-time dependencies, while those
460460+ # derivations might take a very long time to build, or might not even build
461461+ # successfully on the platform used.
462462+ # We can improve on this situation by instead passing only the outPath,
463463+ # without an attached string context, to nix. The out path will be a placeholder
464464+ # which will be replaced by the actual out path if the derivation in question
465465+ # is part of the final closure (and thus needs to be built). If it is not
466466+ # part of the final closure, then the placeholder will be passed along,
467467+ # but in that case we know for a fact that the derivation is not part of the closure.
468468+ # This means that passing the out path to nix does the right thing in either
469469+ # case, both for disallowed and allowed references/requisites, and we won't
470470+ # build the derivation if it wouldn't be part of the closure, saving time and resources.
471471+ # While the problem is less severe for allowed*, since we want the derivation
472472+ # to be built eventually, we would still like to get the error early and without
473473+ # having to wait while nix builds a derivation that might not be used.
474474+ # See also https://github.com/NixOS/nix/issues/4629
475475+ lib.optionalAttrs (attrs ? disallowedReferences) {
476476+ disallowedReferences =
477477+ map unsafeDerivationToUntrackedOutpath attrs.disallowedReferences;
478478+ } //
479479+ lib.optionalAttrs (attrs ? disallowedRequisites) {
480480+ disallowedRequisites =
481481+ map unsafeDerivationToUntrackedOutpath attrs.disallowedRequisites;
482482+ } //
483483+ lib.optionalAttrs (attrs ? allowedReferences) {
484484+ allowedReferences =
485485+ lib.mapNullable unsafeDerivationToUntrackedOutpath attrs.allowedReferences;
486486+ } //
487487+ lib.optionalAttrs (attrs ? allowedRequisites) {
488488+ allowedRequisites =
489489+ lib.mapNullable unsafeDerivationToUntrackedOutpath attrs.allowedRequisites;
449490 };
450491451492 validity = checkMeta { inherit meta attrs; };