Skip to content
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

Add project.plan-nix.freeze #1055

Merged
merged 4 commits into from
Mar 4, 2021
Merged

Add project.plan-nix.freeze #1055

merged 4 commits into from
Mar 4, 2021

Conversation

hamishmack
Copy link
Collaborator

Issues with cabal.project.freeze files can be tricky to debug.
While it is possible to run without a freeze file and look
at the plan-nix or plan-nix.json (the plan.json) created when
haskell.nix configured the project, it would be nice to
also have the output of cabal freeze as it will be in the
correct format and contains a different subset of plan.json
than the plan-nix.

This might also be useful for automating updating of .freeze
files.

Issues with `cabal.project.freeze` files can be tricky to debug.
While it is possible to run without a freeze file and look
at the `plan-nix` or `plan-nix.json` (the `plan.json`) created when
haskell.nix configured the project, it would be nice to
also have the output of `cabal freeze` as it will be in the
correct format and contains a different subset of `plan.json`
than the `plan-nix`.

This might also be useful for automating updating of `.freeze`
files.
@hamishmack hamishmack requested a review from rvl February 23, 2021 07:22
@hamishmack
Copy link
Collaborator Author

bors try

iohk-bors bot added a commit that referenced this pull request Feb 23, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 23, 2021

try

Build failed:

@@ -436,7 +437,7 @@ let
index-state = cached-index-state;
sha256 = index-sha256-found;
}
} cabal v2-configure \
} cabal v2-freeze \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do if the user supplied a freeze file? Does it overwrite it? That would be bad, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do if the user supplied a freeze file? Does it overwrite it? That would be bad, right?

At this point it is running in a temp dir. It seems to do a v2-configure then save out the new version over the top.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems wrong? If the user gives us a freeze file (and this function takes one) then surely we should use that unequivocally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used by cabal. The existing freeze file may not include constraints for all the packages. The one cabal outputs will be more complete. For instance if I just include constraints: any.base ==4.14.1.0 in freeze file:

% cat $(nix-build -E '(((import ./. {}).pkgs-unstable.haskell-nix.tool "ghc8104" "hello" {version = "1.0.0.2"; cabalProjectFreeze = "constraints: any.base ==4.14.1.0";}).project).plan-nix.freeze')
trace: No index state specified for hello, using the latest index state that we know about (2021-02-23T00:00:00Z)!
building '/nix/store/cb2ri159gm7i7jsblgjwa5vi69iqqk3r-cabal.project.freeze.drv'...
building '/nix/store/8y5mcs03rr7apj89na4hnn28d0p0pakn-hello-plan-to-nix-pkgs.drv'...
Using index-state 2021-02-23T00:00:00Z
Warning: The package list for 'hackage.haskell.org-at-2021-02-23T000000Z' is
18681 days old.
Run 'cabal update' to get the latest list of available packages.
Warning: Requested index-state2021-02-23T00:00:00Z is newer than
'hackage.haskell.org-at-2021-02-23T000000Z'! Falling back to older state
(2021-02-22T23:55:38Z).
Resolving dependencies...
Wrote freeze file:
/private/tmp/nix-build-hello-plan-to-nix-pkgs.drv-0/tmp.R874CaSGyv/cabal.project.freeze
constraints: any.base ==4.14.1.0,
             any.ghc-prim ==0.6.1,
             hello -threaded,
             any.integer-gmp ==1.0.3.0,
             any.rts ==1.0

I get the same output for constraints: any.base ==4.*, but for constraints: any.base ==5.* cabal v2-freeze fails to find a solution. I don't know if there is a way to tell cabal to be more strict and require all the constraints to be in the cabal.project.freeze file. I guess if there is not we could build one by comparing the original version with the one it spits out and returning an error if they differ.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, if it includes the constraints from the input freeze file and gives you one with strictly more constraints then I'm fine with it. Worth a comment, though!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it will be "strictly more constraints". I suspect that if the input freeze file includes a constraint on a package that is not picked at all (Win32 for instance when building for linux), the output may not include a constraint at all.

I don't think that is something we should fix in Haskell.Nix though (it seems more like a cabal v2-freeze problem). I have added a comment describing .freeze as The 'cabal.project.freeze' file created by 'cabal v2-freeze'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added:

    # Using `cabal v2-freeze` will configure the project (since
    # it is not configured yet), taking the existing `cabal.project.freeze`
    # file into account.  Then it "writes out a freeze file which
    # records all of the versions and flags that are picked" (from cabal docs).

@hamishmack
Copy link
Collaborator Author

bors try

iohk-bors bot added a commit that referenced this pull request Mar 4, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 4, 2021

@hamishmack hamishmack merged commit cb264f6 into master Mar 4, 2021
@iohk-bors iohk-bors bot deleted the hkm/plan-nix.freeze branch March 4, 2021 03:46
booniepepper pushed a commit to booniepepper/haskell.nix that referenced this pull request Feb 4, 2022
Issues with `cabal.project.freeze` files can be tricky to debug.
While it is possible to run without a freeze file and look
at the `plan-nix` or `plan-nix.json` (the `plan.json`) created when
haskell.nix configured the project, it would be nice to
also have the output of `cabal freeze` as it will be in the
correct format and contains a different subset of `plan.json`
than the `plan-nix`.

This might also be useful for automating updating of `.freeze`
files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants