-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildPython*: allow providing a finalAttrs function #370232
Conversation
@@ -40,21 +40,27 @@ let | |||
result | |||
); | |||
|
|||
allowFinalAttrs = f: lib.mirrorFunctionArgs f (args: f (lib.fix (lib.toFunction args))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a lib function that does that?
If the process could be standardized that could be done to all builders and we could do a rec witch hunt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I just think that it should be in lib on the final form. It'll likely be reused by other builder implementations.
This implementation fixes the fixed point arguments taken by One significant drawback is the lack of Update: As @TomaSajt suggests, it's not even something like |
As @ShamrockLee said, this is just a shorthad for |
330be27
to
a69b5ca
Compare
I tried to avoid awful diffs, but... here we go. Rewritten everything to pass down finalAttrs to |
a69b5ca
to
d236251
Compare
460100d
to
94e35e4
Compare
Rewritten almost everything to use overlays for handling args. The only issue I have right now is that I cannot call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just not use lib.extends, but a custom function I have been calling "transforms". It takes in a transformation instead of an overlay.
If that transformation just does prevAttrs //
at the beginning, it would act exactly like an overlay.
However, since we now explicitly // the prevAttrs
you could remove some unneeded names from prevAttrs
before //-ing it.
here's the definition of transforms btw:
transforms =
transformation: rattrs:
final: transformation final (rattrs final)
And here's lib.extends to compare to
extends =
overlay: rattrs:
final: rattrs final // overlay final (rattrs final)
(Note the extra rattrs final //
) (rattrs final
is prev
)
2326338
to
fadc6d9
Compare
fadc6d9
to
ff0bf8a
Compare
ff0bf8a
to
d09b941
Compare
BTW, @TomaSajt, you should totally add |
As @ShamrockLee mentioned previously it's very important to acknowledge is the following:
Note: |
So that you know, #267296 fixes the issue. Such issues are a good example of how custom overriders are hard to maintain and are not a good pattern. |
This function is similar to the |
origAttrs: | ||
let | ||
unfixed = (lib.toFunction origAttrs) { }; | ||
stdenv = unfixed.stdenv or python.stdenv; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdenv = unfixed.stdenv or python.stdenv; | |
stdenv = origAttrs.stdenv or python.stdenv; |
if origAttrs
is { stdenv = ...; }
, unfixed
will be a callable equivalent to finalAttrs: { stdenv = "..."; }
. When origAttrs
is a function, it is impossible to specify stdenv
as its arguments and get it out before fixing the arguments.
buildPythonPackage.override { stdenv = ...; }
is the only possible and reasonable way to specify custom stdenv
. That's what #271762 is for.
Closing in favor of #271387 |
This adds support for
finalAttrs
function in python packages:just like
This implementation is alternative to #271387. The difference is that I don't depend on a stale PR, but #271387 should replace my code.
For now, I only updated a package that I maintain for testing. For treewide, #293452 would be a better place.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.