srcOnly: add warning for usage with non-stdenv derivations

This commit is contained in:
sternenseemann
2025-08-06 16:53:17 +02:00
parent 8d0b9ddcc5
commit 2e6f99eddd
+5 -2
View File
@@ -69,12 +69,15 @@ if lib.isDerivation attrs && attrs ? overrideAttrs then
attrs.overrideAttrs (_finalAttrs: prevAttrs: argsToOverride prevAttrs)
else
let
# TODO(@sternenseemann): remove drvAttrs special casing
# If we don't have overrideAttrs, it is extremely unlikely that we are seeing
# a derivation constructed by stdenv.mkDerivation. Since srcOnly assumes
# that we are using stdenv's setup.sh, it therefore doesn't make sense to
# have derivation specific logic in this branch.
args = attrs.drvAttrs or attrs;
# TODO(@sternenseemann): remove drvAttrs special casing in NixOS 26.05
args =
lib.warnIf (lib.isDerivation attrs)
"srcOnly: derivations not created by a variant of stdenv.mkDerivation are not supported. Code relying on behaviour of srcOnly with non-stdenv derivations may break in the future."
attrs.drvAttrs or attrs;
stdenv = args.stdenv or (lib.warn "srcOnly: stdenv not provided, using stdenvNoCC" stdenvNoCC);
drv = stdenv.mkDerivation (args // argsToOverride args);
in