buildPython*: unconditionally add .override #455362
buildPython*: unconditionally add .override #455362MattSturgeon merged 1 commit intoNixOS:masterfrom
Conversation
MattSturgeon
left a comment
There was a problem hiding this comment.
With these changes, override is being added to the result, not the function.
I don't think this particularly changes how lazily f is evaluated; rather it just moves the override attribute to the wrong place.
8113fb0 to
c8d84a7
Compare
c8d84a7 to
af0cbe4
Compare
Indeed, resolved. |
There was a problem hiding this comment.
This is a much better approach. Avoiding (f ? override) does indeed make f lazier.
If
!(f ? override)accessing.overrideof the returned function will[...]
We shouldn't need to worry about that edge-case, because makeOverridablePythonPackage is a private function that is always applied with a callPackage result, so ? override will always be true.
With this in mind, the commit message could be shortened and put less emphasis on "we can't do (f?override)" and more emphasis on "we don't actually need to do it anyway"?
(I edited the PR description to match your revised approach)
SGTM overall, thanks!
To be able to splice, we can't fail to eval before returning an attribute set. By checking for f ? override, we need to force f which isn't always possible, whereas mirrorFunctionArgs serves as an indirection which wraps the inner thunks in an attribute set that can always be returned. Fortunately, there should be no case when f evaluates successfully and does not have the override attribute, so we can just remove the condition. This fixes evaluation of buildPython* based packages in certain splicing situations by being lazier. An example of this is pkgsCross.ghcjs.buildPackages.nixpkgs-openjdk-updater on staging right now (ff5098e).
af0cbe4 to
0443b98
Compare
Done. |
MattSturgeon
left a comment
There was a problem hiding this comment.
An example of this is
pkgsCross.ghcjs.buildPackages.nixpkgs-openjdk-updateron staging right now (ff5098e).
Is this still accurate? #366593 (comment) seems to contradict.
Either way, this is just nitpicking the commit wording; the change itself is good regardless of whether it addresses a currently-present issue.
LGTM, thanks!
|
c4e3b67 adds an earlier Thanks both for your thorough investigation, analysis, fixes, improvements, etc! I'll merge this now, as it is an objectively good patch. Even if c4e3b67 means we won't see any changes in practice with modern nix implementations, it's still good to remove unnecessary potential strictness from the code. |
|
Successfully created backport PR for |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-25.11
git worktree add -d .worktree/backport-455362-to-release-25.11 origin/release-25.11
cd .worktree/backport-455362-to-release-25.11
git switch --create backport-455362-to-release-25.11
git cherry-pick -x 0443b98ab3aa88d5eb7ff231781d679be89868e8 |
|
Ah! It's already inside |
Preserve laziness of
buildPython*build-helper functions, by addingoverrideunconditionally instead of viaoptionalAttrs (f ? override).Checking if
fcontainsoverridecauses it to be strictly evaluated. The check is also uneccessary because we knowmakeOverridablePythonPackageis always supplied acallPackage-result (eithercallPackage ./mk-python-derivation.nix { }or the python2 equivalent), sooverrideshould always be present inf.This should resolve issues like
pkgsCross.ghcjs.buildPackages.nixpkgs-openjdk-updateron staging right now (ff5098e).Original description
This change fixes two kinds of issues:
Fixes evaluation if
resultis neither a function nor an attribute set (which the code at least allowed before buildPython*: bring back buildPython*.override #366593).Fix evaluation of buildPython* based packages in certain splicing situations by being lazier. An example of this is pkgsCross.ghcjs.buildPackages.nixpkgs-openjdk-updater on staging right now (ff5098e). Apparently, a change that is not part of master, caused this to manifest on staging.
By moving the addition of the set with .override inwards, we are able generating the outer __spliced set without forcing result, so we can actually access splices that don't throw.
cc @wolfgangwalther @alexfmpe