Skip to content

One freeze-file per GHC version #7367

Open

Description

@andreasabel

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.

Activity

  1. phadej commented on Apr 22, 2021

    @phadej
    Collaborator

    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.

  2. fgaz commented on May 3, 2021

    @fgaz
    Member

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

  3. fgaz commented on Jun 21, 2021

    @fgaz
    Member

    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

  4. jneira commented on Jun 21, 2021

    @jneira
    Member

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

  5. gbaz commented on Aug 26, 2021

    @gbaz
    Collaborator

    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.

  6. andreabedini commented on May 15, 2023

    @andreabedini
    Collaborator

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

  7. michaelpj commented on May 16, 2023

    @michaelpj
    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.

  8. andreabedini commented on May 17, 2023

    @andreabedini
    Collaborator

    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.

  9. philderbeast commented on Apr 23, 2024

    @philderbeast
    Collaborator

    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? ↩

  10. philderbeast commented on Apr 23, 2024

    @philderbeast
    Collaborator

    This is already possible using imports;

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

  11. philderbeast commented on Apr 23, 2024

    @philderbeast
    Collaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions