Skip to content

One freeze-file per GHC version #7367

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

Open
andreasabel opened this issue Apr 21, 2021 · 11 comments
Open

One freeze-file per GHC version #7367

andreasabel opened this issue Apr 21, 2021 · 11 comments

Comments

@andreasabel
Copy link
Member

There should be one freeze file per GHC version (like there is a build directory per GHC version in v2-cabal). Otherwise, freeze does not work as expected in a multi-GHC environment. I expect cabal v2-freeze -w ghc-x.y.z to work analogously to cabal v2-build -w ghc-x.y.z.

Currently there is a single cabal.project.freeze.

See also #2245.

@phadej
Copy link
Collaborator

phadej commented Apr 22, 2021

I agree, freeze file makes mostly sense for single compiler only.

This is challenging. Freeze file is just a convention, it's not "special". It is an unrestricted appendix to cabal.project (hardcoded like cabal.project.include). So this feature request is not much different then asking to select different cabal.project files based on --with-compiler flag. This is even more challenging then builddir in cabal.project (#5271), but the reason is the same: compiler can be set in cabal.project with with-compiler: ....

I'm afraid that project configuration have to be reworked in some non-trivial way to support this.

EDIT: an important constraint is that project configuration can be read in <10ms, to guarantee interactive-fast responses for no-build-op operations (e.g. cabal list-bin). Otherwise people (including myself) will loudly complain about why cabal-install become slow.

@fgaz
Copy link
Member

fgaz commented May 3, 2021

We could partially get there by adding a --freeze-file flag that works like the --project-file one

@fgaz
Copy link
Member

fgaz commented Jun 21, 2021

By the way, the freeze file can be changed, just together with the main project file: --project-file affects all kinds of project files together, so using --project-file=cabal.project.ghc-x.y would make cabal pick up a cabal.project.ghc-x.y.freeze (and cabal.project.ghc-x.y.local) file.

This might be a nuisance when the project file is big and has to be copied multiple times, but it works, and symlinks can solve the duplication

@jneira
Copy link
Member

jneira commented Jun 21, 2021

only want to note that symlinking in windows is not reliable in general

@gbaz
Copy link
Collaborator

gbaz commented Aug 26, 2021

I think that explicit includes (discussed on related ticket) plus allowing includes in conditional stanzas would give a way to do this, albeit not the most seamless ux for it.

@andreabedini
Copy link
Collaborator

After getting explicit includes and cabal freeze -w; is there anything left to this ticket or it can it be close?

@michaelpj
Copy link
Collaborator

Just wanted to note that it's not enough to have one per compiler version, it can also vary per platform. So in principle you need one per compiler-version/platform combination.

@andreabedini
Copy link
Collaborator

andreabedini commented May 17, 2023

it can also vary per platform

It can also vary based on the output of pkg-config. IMHO this can be left to the user. I have seen many projects have separate project files per compiler version, so it's not impossible.

@philderbeast
Copy link
Collaborator

philderbeast commented Apr 23, 2024

This is already possible using imports1;

$ cabal freeze --project-file=cabal.project --with-compiler=ghc-9.8.2
...
Resolving dependencies...
Wrote freeze file:
/.../cabal.project.freeze

$ mv cabal.project.freeze cabal.ghc-9.8.2.freeze

Then edit the project to import the compiler-specific freeze file guarded by a conditional;

$ git diff
diff --git a/cabal.project b/cabal.project
index e368c280c..d71207795 100644
--- a/cabal.project
+++ b/cabal.project
@@ -4,3 +4,6 @@ import: project-cabal/pkgs.config
 import: project-cabal/constraints.config
 
 tests: True
+
+if impl(ghc == 9.8.2)
+    import: cabal.ghc-9.8.2.freeze

Footnotes

  1. This was already suggested on [nix-local-build] Allow specifying freeze file for other commands #3587 in https://github.com/haskell/cabal/issues/3587#issuecomment-234773265 and https://github.com/haskell/cabal/issues/3587#issuecomment-234788956. That same issue also notes it is also "difficult to support multiple compiler versions in a project" but this was before conditionals in projects, wasn't it?

@philderbeast
Copy link
Collaborator

This is already possible using imports;

We could add this to the cookbook section on reproducible builds.

@philderbeast
Copy link
Collaborator

philderbeast commented Apr 23, 2024

Another option is to have one project per GHC version. Each would then be individually freezable.

That's what Updo does with its cabal.project for the current GHC version and its cabal.upgrade.project when upgrading to another GHC version. If more versions are required than current (default) and upgrade then Updo can generate GHC-prefixed projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants