-
Notifications
You must be signed in to change notification settings - Fork 697
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
Global source-repository-packages #9314
Comments
I think this is somewhat related to #5444. My impression is that a lot of the issues that people run into there could be fixed/alleviated by this proposal. |
I think this is one of the haskell.nix issues related to this: input-output-hk/haskell.nix#1367 |
I don't know enough about this to comment, but I wonder if there are any hidden pitfalls with allowing that. But if there are, perhaps that would lead to a beneficial revision of the assumption and a rewrite. If the proposal is accepted, who is going to implement that? |
Thanks for thinking about this. I think you mention separate problems that are unreleated to the local/global distinction.
A global cache of source-repository-packages could be implemented without any change in how source-repository-package are considered by the solver. It does require designing how to get it to work well though. Projects enjoy a The cabal store already has this issue so perhaps a common solution is needed.
The problem with getting cabal to work well inside nix is mostly due to the fact inside the nix build sandbox you cannot do arbitrary IO; and that it is hard to get cabal to not do IO. Nix could prefect the repositories for example but there is no simple way to get cabal to use the prefetched repositories rather than doing the checkout itself.
I don't understand how this situation can arise. A tighly coupled sibiling package ... but living in a separate repository? |
I'd be happy to give it a go. Though I can't make any promises about when I'll have capacity |
Yes this is a great point. I agree that caching and solving are distinct concerns. Though I think the difficulties that haskell.nix runs into suggests that some changes would need to made to the solver for cabal-install to accept source-repository-packages that aren't built in place. I agree that implementing this feature would make cabal store bloat worse, but that's orthogonal to this.
Just to be clear I'm not suggesting we should be calling
Perhaps I shouldn't have mentioned this. I was trying to come up with a scenario where someone truly wanted a local |
Putting this another way.
(2) is a lot of work but nothing else about cabal-install's behaviour will change other than where the source code is coming from. I would like to avoid having to set up my own hackage-server but still be able to override source code without changing behaviour. |
[without that package being considered local to the project] Apologies if I sound repetitive. In this use case, I don't see the importance of the package not being considered local (beside caching, which has we discussed above is an idepedent problem).
You can also use local no-index repository, which is much easier to set up. One could think of caching some local packages but then we would have another "mode" to take into account (local cached / local not cached). I doubt this last idea would be worth the complexity. |
Wherever these issues are captured on GitHub, could you ping me on the respective GitHub issues? The tl;dr is that haskell.nix needs to turn a |
Sorry I think I was unclear above. While I do think clearing things from the cabal store is independent, caching is the main appeal of this feature request. My problem with
Thanks for this link! I agree that this is easier to set up than a hackage-server, but it's still a lot of work compared to just having a set of
Done that now. On haskell.nix stuff, I agree with you that a proper API is necessary for these two projects to interact. Yet, I think this feature request would solve this specific problem with a lot less work than setting that up. haskell.nix does the right thing for stack projects in this case and that's because stack deals with this in the way I'm suggesting. |
This comment from one of the linked issues seems to be calling for this feature as well: #5444 (comment) |
@TeofilC Thank you for the link and the ping. Let me emphasize that I didn't mean to diminish the problems with the current DX! I should have pointed out right away that it was my experience with source-repository-packages in the cardano ecosystem that led me to write the tool that Michael mentions in that thread! I think at some point I had a git-wrapper script that would share the checkouts between projects, it was saving multiple gigabytes of downloads (and time!). Somehow, in my mind this is orthogonal from the local/global distinction but maybe it should not be (ew.g. tests enabled by default comes up a lot). The problem cabal-install rebuilding things is a little bit more complicated though. |
Oh well, it looks like Oleg is right (I should not be surprised 😂).
So, it looks like source-repository-packages can automatically considered global. The checkout is not shared but the build is. |
Another data point as I rediscover the codebase:
works and it is considered global, and the build is cached in the store. The source distribution is not shared but downloading a tarball might be more efficient that a git checkout. On other hand, At least the user guide clear about the use case for each option. |
Yes, very fair! Rebuilding logic is always surprisingly tricky
The build being shared is good to hear! I'm not sure how I've missed this thanks for pointing it out! So, I guess this reduces this issue to just putting the checkouts into the cabal store?
This seems like a great workaround! I'll give this a try. Though I still think having a proper fix for the One thing about this that really confuses me is why this is considered global at all. All of the |
So a point of confusion about the local/global thing is the particular behaviour we see with
I think our hypothesis was that this was caused by |
This is the script I was using https://gist.github.com/andreabedini/9647abb8b3d647a4020fd07e568a85c4, of course use it at your own risk :)
I don't know if I can call it "a fix". We might have identified some wishes but nothing that is broken or wrong. There seem to be a desire for:
which cabal does (may) not have a solution for. This use case needs to be understood in the context of the current code and behaviour if we want to make progress.
Either the documentation is wrong or we are totally confused about what is local and what is global.
|
Thanks! I'll take a look
Yes well put! I would also add the following requirement to your list:
Definitely! It feels to me like someone needs to spend a bit of time figuring out all the details of how all these parts fit together, before we can figure out how to proceed? I'd be happy to tackle this at this at some point, but I can't promise when I'll have time to do that |
Notes for our future selves: this seems to be relevant bit
It's in Distribution.Client.ProjectPlanning, part of the project elaboration phase. |
And local packages are defined in rebuildProject plan above:
Looking at findProjectPackages it looks like everything was called "local package" (as the comment in the elaboration phase above seem to confirm). |
Here's an issue with pervasive global caching of src-repository-packages. Suppose I point to HEAD of a repo. Now, with every build where that repo is updated, I will get a new checkout and a new compilation artifact, and these will go in the global store where they are never garbage collected. I think this could drive users somewhat nuts. We may want to limit to packages that point to a specific commit alone, for example. |
Using a local noindex repository sounds like the right thing to do for this use case. |
This is a great point. I feel like it deserves its own ticket, since it can be a problem irrespective of this feature. Even if you only cache these locally, you'd still have to redownload with each build, which would be quite slow. |
Summary
When overriding dependencies using
source-repository-package
, the overridden packages become local packages.This means that neither the source code or build results get cached between projects.
It also makes it difficult for
nix
tooling (or similar) to provide pre-cached packages as cabal-install will be reluctant to use a version of a package coming from a package database provided by this tooling.Proposal
Add a setting to
source-repository-package
stanzas that allow setting it to be local or global.Default this to local if it depends on a local package, ie, to enforce a local package transitive closure property.
I think this default would work well for I think the two main use cases:
The text was updated successfully, but these errors were encountered: