-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Improved makeOverridable #27319
Improved makeOverridable #27319
Conversation
@ElvishJerricco, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ttuegel, @peti and @edolstra to be potential reviewers. |
Instead of manually using `makeExtensible`, which broke `override`. Fixes NixOS#26561
b98fce8
to
c8f7cff
Compare
Consequently removing several ad-hoc definitions of the same concept.
7ea5137
to
8b76496
Compare
lib/fixed-points.nix
Outdated
# function in the resulting attribute set. But it's also useful for | ||
# having an internal structure that extensions can see, but the user | ||
# facing code cannot. | ||
makeExtensibleWithInterface = interface: fext: interface |
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.
@cstrahan I need to write something longer up another time, but I want to close my PR in lieu of this generalization.
@ElvishJerricco Looking good! Some of the complexity of the I think |
@Ericson2314 yea that sounds like a mostly better name, although |
@@ -7,26 +7,24 @@ | |||
, configurationNix ? import ./configuration-nix.nix | |||
}: | |||
|
|||
self: # Provided by `callPackageWithSelf` |
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.
This would be the final output, right?
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.
Yea. Since self
becomes the scope for all the packages' overrideScope
, it needs to support extend
, thus it needs to be the final output, not the internal one.
(extends packageSetConfig | ||
(extends compilerConfig | ||
(extends commonConfiguration | ||
(extends nixConfiguration haskellPackages))))) self |
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.
That seems like the wrong thing to put there though?
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.
I'll need to think about it.
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.
Are you talking about the self
? There's no reason it shouldn't be the final output, and I didn't want to have to pass around two different self
s
lib/customisation.nix
Outdated
# or extension is added. | ||
callPackageWithSelfWith = autoArgs: fn: args: | ||
let f = if builtins.isFunction fn then fn else import fn; | ||
in callPackageCommon (builtins.functionArgs f) autoArgs (iself: args: _: f args iself ) 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.
Right I think the last parameter should also be passed in----it is what mk-haskell-packages is supposed to feed into the (extend _ (extend _ ...))
chain.
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.
I don't know if that's true. It definitely needs the final output for the scope, which is sort of expected to be the same thing as the self
in the extensions chain.
Oh, I was unaware of this work :). I'll look when I'm back at my desk in a couple hours. |
Wait... Is that travis failure a memory leak in the Nix expressions?... Did I do that? |
3fd1ba9
to
9701165
Compare
Fixing the `overrideScope` in `haskellpackages`.
9701165
to
05f9db6
Compare
@ElvishJerricco So, I need a little bit more time to think this over. In the interim, I'd like to point out -- and get your thoughts on -- another solution I played with: #15095 (comment) There might be something there that you can draw inspiration from. |
Alright, I've looked through this pretty extensively, and it all looks good to me. I see from your example:
It's apparent that I don't want to bike-shed too much, but I do wonder if we can come up with more intuitive name. I've been pushing for a change in vernacular for a while now, where |
Another thing I'm excited about is being able to use |
@cstrahan Thanks =) I agree about the naming of |
As I mentioned before, if this does not belong in Nixpkgs, then this can go in an overlay [1], where you are free to do anything, and where this will not add burden to maintain Nixpkgs. [1] https://github.com/mozilla/nixpkgs-mozilla/blob/master/lib-overlay.nix |
I'm very reluctant to merge this because a) it makes a pretty non-trivial change to a core function; b) changes to |
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.
FWIW, I'll provide my (somewhat unhelpful) feedback, too. I haven't had the time to read, understand, and think about these modification in detail. I find it difficult to predict what kind of consequences these changes will have. In the past, we've merged changes to this code to fix problem A (and did), but then problem B emerged, and this chain of events has been going on like that for the last 2 years or so. It seems to me like someone will have to take a step back and think about overriding in Nix one more time, considering the big picture rather than trying to solve just one particular issue we recognize at this very moment. I might actually give it a shot, but it's not an easy problem as you all know.
Anyhow, I won't merge this PR because I don't have the problem that this code wants to solve. I realize some kind of problem exists, but I just don't have it in practice, so I'm not motivated to get into the details of this PR.
At the same time, if someone else desperately wants this merged, then I won't object either.
Can someone point out an actual problem with this code? Something that will break, something that will slow down, something that will make future code harder to reason about, anything? We have several people who have taken the time to understand this code who think it's a good solution to real-world problems, a few people who have reviewed it who aren't sure it's the best solution but haven't proposed another, and a few people who haven't reviewed it in detail but don't like it anyway. Why shouldn't we merge in this case? |
I should also point out that the code is structured so that each commit stands alone is readable. @ElvishJerricco has specifically done this to make this otherwise complex change decipherable. |
BTW, this is oversimplified but the ultimate theoretical justification for this change is the same as the justification for |
@shlevy Merge conflicts are fixed btw. |
@edolstra Please let me know if your objection is a hard "no" to this being merged, otherwise I'll merge soon. |
To touch on the performance concerns: if we don't have a readily available means of profiling built into Nix, that ought to be a priority for us, rather than punting on design improvements. |
This broke evaluation of |
}); | ||
}; | ||
|
||
in lib.makeExtensibleWithInterface (x: o: interface (addOverrideFuncs x o) o) (output: self: { |
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.
attribute 'makeExtensibleWithInterface' missing, at ~/nixpkgs/lib/customisation.nix:84:6
@shlevy looks good now |
Tarball is broken still, fixing... |
Done |
This PR breaks the evaluation of
and
git bisect says that e11dbc3 is the first commit to cause that failure. |
@ElvishJerricco @Ericson2314 Any idea here? |
Please revert. This makes an already bad idea (
WTF does that mean? What is Regarding performance metrics, we have those, and they show a significant spike starting today: https://hydra.nixos.org/job/nixpkgs/trunk/metrics#tabs-charts. E.g. The claim that reverts are cheap is false in my experience; once changes like these are in and other commits start building on them, it quickly becomes very hard to untangle them. |
Reverting |
Done |
Reverting NixOS#27319 This reverts commit 01a3f0b.
Reverting NixOS#27319 This reverts commit 9ce7175.
Reverting NixOS#27319 This reverts commit 751d397.
Fair. I understand that this change was complicated. But this still leaves us with issues like #26561. |
The existence of an Anyhow, technical discussion of this issue probably belongs into an RFC, not into a pull request -- unless someone feels like spending a lot of effort creating a PR that (a) works, (b) does not affect performance nor memory requirements, (c) is well documented, and (d) works out of the box without breaking evaluation of existing code. |
Motivation for this change: As explained in #26561, using
haskellPackages.extend
breakshaskellPackages.override
, meaning there is no way to override the arguments passed tohaskellPackages
, such asall-cabal-hashes
. This PR introduces a much more powerful notion of overriding intomakeOverridable
so that the solution to this problem can be enjoyed by everything.