After #119942, mkDerivation supports recursive definition of package attributes with
foo = mkDerivation (final: { });
foo_v2 = foo.overrideAttrs (final: prev: { });
# instead of
foo = mkDerivation rec { };
foo_v2 = foo.overrideAttrs (prev: { });
The buildPythonPackage.overridePythonAttrs functionality originally introduced in #26155 should also support this style of overrides (to avoid the rec antipattern and make the overrides more composable).
pyfoo = buildPythonPackage (final: { });
pyfoo_v2 = pyfoo.overridePythonAttrs (final: prev: { });
# instead of
pyfoo = buildPythonPackage rec { };
pyfoo_v2 = pyfoo.overridePythonAttrs (prev: { });
Also, this probably belongs in #1819.