buildPython*: extend overrideStdenvCompat to fixed-point arguments
with `passthru.__stdenvPythonCompat` Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
This commit is contained in:
co-authored by
Matt Sturgeon
parent
5b114f0534
commit
de48b6a845
@@ -54,6 +54,7 @@ let
|
||||
lib.mirrorFunctionArgs f (
|
||||
args:
|
||||
let
|
||||
result = f args;
|
||||
getName = x: x.pname or (lib.getName (x.name or "<unnamed>"));
|
||||
applyMsgStdenvArg =
|
||||
name:
|
||||
@@ -62,12 +63,18 @@ let
|
||||
buildPythonPackage.override { stdenv = customStdenv; } { }
|
||||
'';
|
||||
in
|
||||
if !(lib.isFunction args) && (args ? stdenv) then
|
||||
if lib.isFunction args && result ? __stdenvPythonCompat then
|
||||
# Less reliable, as constructing with the wrong `stdenv` might lead to evaluation errors in the package definition.
|
||||
f'.override { stdenv = applyMsgStdenvArg (getName result) result.__stdenvPythonCompat; } (
|
||||
finalAttrs: removeAttrs (args finalAttrs) [ "stdenv" ]
|
||||
)
|
||||
else if (!lib.isFunction args) && (args ? stdenv) then
|
||||
# More reliable, but only works when args is not `(finalAttrs: { })`
|
||||
f'.override { stdenv = applyMsgStdenvArg (getName args) args.stdenv; } (
|
||||
removeAttrs args [ "stdenv" ]
|
||||
)
|
||||
else
|
||||
f args
|
||||
result
|
||||
)
|
||||
// {
|
||||
# Preserve the effect of overrideStdenvCompat when calling `buildPython*.override`.
|
||||
|
||||
Reference in New Issue
Block a user