makeOverridablePythonPackage: take care of overrideAttrs

Make it possible to mix overridePythonAttrs and overrideAttrs, i.e.
((<pkg>.overrideAttrs (_: { foo = "a"; })).overridePythonAttrs (_: { })).foo now works

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
This commit is contained in:
Yueh-Shun Li
2025-12-10 19:22:04 +08:00
co-authored by Matt Sturgeon
parent e8302431ef
commit ca6c090082
2 changed files with 44 additions and 0 deletions
@@ -14,6 +14,9 @@ let
# Derivations built with `buildPythonPackage` can already be overridden with `override`, `overrideAttrs`, and `overrideDerivation`.
# This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`.
#
# Overridings specified through `overridePythonAttrs` will always be applied
# before those specified by `overrideAttrs`, even if invoked after them.
makeOverridablePythonPackage =
f:
lib.mirrorFunctionArgs f (
@@ -26,6 +29,8 @@ let
result
// {
overridePythonAttrs = newArgs: makeOverridablePythonPackage f (overrideWith newArgs);
overrideAttrs =
newArgs: makeOverridablePythonPackage (args: (f args).overrideAttrs newArgs) origArgs;
}
else
result