Make overridePackages extend rather than replace existing overrides#19496
Make overridePackages extend rather than replace existing overrides#19496cstrahan merged 2 commits intoNixOS:masterfrom
overridePackages extend rather than replace existing overrides#19496Conversation
|
@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nbp, @cstrahan and @edolstra to be potential reviewers. |
|
I never realized |
pkgs/top-level/default.nix
Outdated
There was a problem hiding this comment.
Not sure about space usage/complexity, but using foldl or foldl' would let this this from top to bottom, which seems easier to read.
There was a problem hiding this comment.
Good point. There could be some constant factor cost in the extra flip needed for extends, but nothing to worry about without benchmarks.
07caf58 to
1db9a37
Compare
1db9a37 to
3ca3b14
Compare
| # nix-repl> obj | ||
| # { __unfix__ = «lambda»; bar = "bar"; extend = «lambda»; foo = "foo + "; foobar = "foo + bar"; } | ||
| makeExtensible = rattrs: | ||
| makeExtensible = makeExtensibleWithCustomName "extend"; |
There was a problem hiding this comment.
Hah, I recently thought about doing just this, as I figured someone might need a different name, perhaps for backwards compatibility somewhere or avoiding name clashes.
|
I've wanted this ever since I discovered @roconnor's dynamic-binding/object system[1][2], as seen in the wonderful The current solution isn't ideal, and the behavior clearly isn't what we'd like (as is evident in #18483). I believe this approach would be an improvement from both a UI and semantic point of view. 👍 [1] http://r6.ca/blog/20140422T142911Z.html |
|
Glad you all like it! What further review/testing/etc is needed before somebody feels comfortable merging this? 😄 |
|
The only hesitance I have is that (if I'm reading this right) it'll break existing uses of Would it be possible to, perhaps with more verbose code, provide a backwards compatible interface, and warn the user to supply the Alternatively, maybe the error that people would see with the present code would be sufficient to clue them in. I feel like I might be over stepping my privileges in making that judgement call, though. |
|
One option might be: expose the "extender" function as |
|
See https://github.com/NixOS/nixpkgs/pull/19496/files#diff-017a38a631b06991d33857f7681874b3L71 config's The only compatibility hazard is relying on |
|
@cstrahan I agree it would be nice to standardize on |
|
@Ericson2314 Ah, I didn't catch the distinction between In that case, I think this is probably fine as is. I'll put it through its paces tonight and merge. |
|
@cstrahan yeah, typing that last comment I realized just how confusing those identifiers are. All the more reason for standardizing on |
|
Hey, sorry -- oversubscribed myself. I'll give this a quick sanity check right now and merge. Pinkie-promise. |
|
Since this commit I get when using the following expression and a |
|
Checking the manual I saw the following has to be used. What I wrote in my previous comment used to work but not anymore. Maybe its worth sending out an e-mail. |
|
@FRidh Sorry this was not an intended breaking change. I'll look into it. |
…function As [reported][1] by @FRidh, `pkgs.overridePackages` no longer works because that function is added to the attribute set *after* fixing. Precisely, that means the `include pkgs` in `allpackages.nix` doesn't pick it up with the rest of the final fixed package set. This changes changes `makeExtensibleWithCustomName`, and by extension plain `makeExtensible` so that the refixer function is added as a final extension before fixing. [1]: NixOS#19496 (comment)
It makes the function more useful as one can always re-import nixpkgs to start afresh.
CC @cstrahan (your new abstraction!) @nbp (held off on doing this because breaking change IIRC) @Mathnerd314 (wanted this)