-
Notifications
You must be signed in to change notification settings - Fork 207
Add cabal freeze files and use them automatically #1561
Conversation
Is this to guarantee reproducibility between the cabal and stack builds? What is the process for updating them, from stack, and from cabal? |
No. I don't care about the stack builds. Freeze files are meant for application authors to ensure users can build: https://www.haskell.org/cabal/users-guide/nix-local-build.html#cabal-v2-freeze
I have no idea how to use stack, this has nothing to do with stack. Also see https://www.haskell.org/cabal/users-guide/nix-local-build.html#cabal-v2-freeze I manually added the |
Out of interest, did you test it somehow that it works as intended? |
Yes, I built with ghc-8.6.5 and ghc-8.4.4. |
This is probably a good idea |
But I think we need some semi automatic way of updating them, without hand-editing afterward. |
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.
Not sure if I like big generated files, but it does bring us one step closer to having a reproducible CI for cabal. It entails some more maintenance burden, though, but probably, only once a month?
Something like that.
There's a ticket about it: haskell/cabal#4071 |
@fendor Having exactly reproducable builds with cabal is important, as it becomes a more popular delivery mechanism. And it is largely similar to what we are doing with stack, for the non-snapshot deps in the stack-XXX.yaml files. So yes, some process that allows us to update, either when needed deps change (like |
There's one gotcha. To be 100% reproducible, we would need to freeze the hackage index as well (which can be done too). In some rare cases, hackage revisions (which are in-place updates to .cabal files) can retroactively break a build plan. This doesn't happen often, but can. I would omit this step though, unless it becomes a problem. |
Would that not be enough? Which is a lot simpler |
How would that be enough? A hackage state has not just one version of a package. |
It provides a frozen input to the solver, so should result in a frozen output. As I understand it. |
I think there may be more affecting the solver than just the hackage state (e.g. already installed packages, global config?, ...). |
cabal.project.8.4.4
Outdated
@@ -0,0 +1 @@ | |||
cabal.project |
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.
Shouldn't that include the with-compiler = ghc-8.4.4
?
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.
Why? That makes it harder to maintain cabal.project
and haskell/cabal#4071 suggests otherwise.
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.
well as it is you could do a cabal --project-file cabal.project.8.4.4
and it would use the ghc on $PATH (ghc-8.6.5 f. e.) although you has ghc-8.4.4 in $PATH. Maybe doing that makes no sense but then this one could be removed, or is it needed for some reason?
EDIT: i guess it is needed to make cabal use the freeze version indirectly but the script could search for the .freeze
directly and remove this one.
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.
well as it is you could do a
cabal --project-file cabal.project.8.4.4
and it would use the ghc on $PATH (ghc-8.6.5 f. e.)
cabal --project-file cabal.project.8.4.4
will use cabal.project.8.4.4.freeze
unconditionally.
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.
Yeah, i edited my comment
cabal.project.8.6.5
Outdated
@@ -0,0 +1 @@ | |||
cabal.project |
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.
Same here about with-compiler
There is no |
@jneira Stack and cabal are not in sync with these files. Rather we provide for cabal a mechanism to compile on any system with the same build-plan. It is in general decoupled of |
I somewhat expect that would be a |
Cabal has nothing to do with stack. There is nothing to sync. freeze files are optional and only added for things that someone has tested.
Nothing. Same as what is already in the README. It will simply default to using the original |
Yeah i think it is clear enough 😉. I was talking about similar functionality using different tools.
Ok, i think using the last minor version will cover enough use cases. We could add the rest of them afterwards |
@jneira hold on with the merge, I'll add freeze files for the other versions. I'm installing all ghc versions via ghcup. I'll also add a script for regenerating them. |
Well i think i am still used to stack.yaml files and the more similar cabal one maybe could be create a
But i suppose it doesnt follow cabal conventions. I still don fully like to have "dummy" (for me)
ok, thanks for that |
Done, please check if you can run |
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.
Nitpick: can we move these cabal.project.GHC_VER files into the install directory if they are to mainly be used by the install script?
They are not mainly used for the install script. |
Is it to be mainly used by |
As already explained: freeze files correspond to the project files. The project file lives at the top of the project hierarchy. The project and freeze files are used to build hie (with or without the shake build system). |
My wording was unclear: is the intention that people will run |
Again: they can do that or use shake.
No, they don't have to specifiy that. |
I see, the freeze file seems to contain the compiler id part. I'm getting sold on this idea now, but I still think we should put them into a separate As for the 8.6.5 freeze file, I'm not able to build it:
|
That's not how project files are to be used. And it might break tools (which search upwards for project files). They are supposed to be in top-level.
Yes, because you didn't run |
These project files won't be picked up by any tools since they don't match "*.project", at least not for the hie-vscode-languageserver extensions or any of the default project markers in the README anyway.
Might be worthwhile looking into adding |
I don't understand what that means.
As explained, I don't think that is necessary right now. It's kind of a heavy shoot, imo. |
I am not gonna ask for more changes, but i want to note for future follow ups, as a reminder, that the pinned deps (and the script to generate them) are os dependent (correct me if i am wrong) |
Not sure that is necessary. This script doesn't have to be run by users at all and only ~once a month by one developer. Surely there's someone running linux.
The worst case is that windows-specific deps don't make it into the freeze file. Are there any deps that only exist on windows? If not, then there's no issue. |
Mmm i can do a diff but as we can see in the example i posted above it has We can accept the possible risk of failing builds in windows due to unpinned deps but i would prefer to have parity between os's. If we want those os specific files we'll need generate them in that os and i would prefer again to not have to do it manually. |
@alanz cabal developers wrt only using index file:
I've never used this approach, so I cannot comment on how smooth it is. I guess we could give that a try instead. If we are lucky, one index state will work for all ghc versions even. But I'll have to test that. We would also need to pin cabal-install somehow. However, the documentation of index-state still suggests to use a freeze file: https://www.haskell.org/cabal/users-guide/nix-local-build.html#cfg-field-index-state
Another downside of using index-state only would be that you don't really know if you broke the solver, once you changed the .cabal file (especially thinking upper bounds). But that could be a job for CI. |
|
This is kinda heavy, but it should work well on 32bit and 64bit arches. The alternative was to copy-paste a lot of cabal-install code that is not exposed. There seems to be no value in that for a development script. The alternative to this script is simply running 'cabal v2-update' twice and then copy-pasting the output manually to cabal.project.
This reverts commit 93ecb1e.
This reverts commit 8e61c59.
To be honest , it seems to me that freeze files was not designed for being distributed but to be automatically generated by each developer and git ignored (like
That limits somewhat the solution (CI checks already builds although you don't pin the index state) but to be fair it is still a improvement. Btw, is it possible that, in a specific hackage index state, the builds work for an os but not for others for any ghc version? |
The documentation says the opposite:
Freeze files are meant to be distributed. What you mean is |
The freeze files are optional and shake will pick them up if they exist for the current requested ghc version.