makeOverridablePythonPackage: simplify implementation

Attach overridePythonAttrs by attribute set update
instead of `stdenv.mkDerivation`'s `passthru`.

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
This commit is contained in:
Yueh-Shun Li
2025-10-23 18:36:31 +08:00
parent 1653d671aa
commit e8302431ef

View File

@@ -19,22 +19,13 @@ let
lib.mirrorFunctionArgs f (
origArgs:
let
args = lib.fix (
lib.extends (_: previousAttrs: {
passthru = (previousAttrs.passthru or { }) // {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
};
}) (_: origArgs)
);
result = f args;
overrideWith = newArgs: args // (if pkgs.lib.isFunction newArgs then newArgs args else newArgs);
result = f origArgs;
overrideWith = newArgs: origArgs // lib.toFunction newArgs origArgs;
in
if builtins.isAttrs result then
if lib.isAttrs result then
result
else if builtins.isFunction result then
{
// {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
__functor = self: result;
}
else
result