Open andreasabel opened 3 years ago
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.
We could partially get there by adding a --freeze-file
flag that works like the --project-file
one
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
only want to note that symlinking in windows is not reliable in general
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.
After getting explicit includes and cabal freeze -w
; is there anything left to this ticket or it can it be close?
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.
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.
This is already possible using imports[^1];
$ 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
[^1]: This was already suggested on #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?
This is already possible using imports;
We could add this to the cookbook section on reproducible builds.
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.
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 tocabal v2-build -w ghc-x.y.z
.Currently there is a single
cabal.project.freeze
.See also #2245.