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
haskell: preserve overrideScope on override #9336
Conversation
(triage) As far as I can tell, it's still relevant. @peti would you like to review this? |
I'm not sure what to do with this patch. It does a problem we have (albeit not an urgent one), so we want to merge, I suppose. On the other hand, the patch duplicates code that we probably don't want to duplicate. Instead, the proper implementation of |
4f71017
to
02bb266
Compare
I don't think that the duplicated code should be of much concern: it is only 3 lines that are duplicated (the |
@bennofs can you verify that master still needs this fix? |
@domenkozar yes still necessary:
|
@peti yes still:
How should that patch fix this? The issue is that |
Okay, thank you for the clarification. We currently have patches for 3
different issues that sound similar but are in fact different and it
seems like I've lost track of which is which.
|
@peti so any idea how we progress with this? it's currently one of the oldest PRs on the nixpkgs repo, and I don't think that more time will change the situation. So it seems we have three options:
|
@bennofs, I think option (2) is the best solution. The code duplication is unfortunate, but I don't see any reasonable way around it. Would you mind pushing an updated version of this patch that fixes the merge conflicts? I'll be happy to merge the PR then. |
f207ff3
to
84e7bb1
Compare
Merged to |
@peti I rebased to edit: oh I see you already noticed! 👍 |
Something isn't right: http://hydra.nixos.org/jobset/nixpkgs/haskell-updates. After b39964cec5d505c00196ff0983b9fe008aac8401 was added to the branch,
no longer works as before. |
@peti that is... weird. I will investigate. |
We want code such as `(pkg.override {}).overrideScope (self: super: {})` to work. This didn't work before, since `override` will call the original package again, and the attribute `overideScope`, which `callPackageWithScope` added, wasn't added again. The fix for this is to modify the package function itself to include the `callPackageWithScope` attribute, so it'll be re-added whenever the function is overriden for with arguments. There is a small problem here though: since callPackage uses some magic (`builtins.functionArgs`) to determine the auto-arguments of a function, we can't just write `callPackageWith scope drvScope`, since `builtins.functionArgs drvScope` will be `{}`. To fix this, we implement our own `callPackageWith`. Fixes #7953. Closes #9336.
84e7bb1
to
61acbb1
Compare
@peti fixed. stack compiles now. I added some docs that explain the the trickiness here. |
We want code such as
(pkg.override {}).overrideScope (self: super: {})
towork. This didn't work before, since
override
will call the original packageagain, and the attribute
overideScope
, whichcallPackageWithScope
added,wasn't added again. The fix for this is to modify the package function itself
to include the
callPackageWithScope
attribute, so it'll be re-added wheneverthe function is overriden for with arguments.
There is a small problem here though: since callPackage uses some magic
(
builtins.functionArgs
) to determine the auto-arguments of a function, wecan't just write
callPackageWith scope drvScope
, sincebuiltins.functionArgs drvScope
will be{}
. To fix this, we implement our owncallPackageWith
.fixes #7953
@peti can you test that this doesn't lead to unexpected side effects, I'm unsure about the performance implications of the change.