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

If both package.yaml and cabal exist, prefer package.yaml. #360

Merged
merged 1 commit into from Jul 18, 2018

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Jul 17, 2018

This is because in a nomal workflow, you would generate the .cabal
every now and then from the package.yaml file.

If you forget to do this generation and you have an old .cabal file
in your tree (common because for users of hpack, .cabal files are
usually in .gitignore), then until now nix would pick up the outdated
cabal file and you would accidentally be running against outdated cabal
contents.

So in this commit we change the logic from

"if *.cabal doens't exist, check if package.yaml exist, if so use hpack"

to

"if package.ymal exists, use hpack, otherwise use *.cabal"

This is because in a nomal workflow, you would generate the .cabal
every now and then from the package.yaml file.

If you forget to do this generation and you have an old .cabal file
in your tree (common because for users of hpack, .cabal files are
usually in .gitignore), then until now nix would pick up the outdated
cabal file and you would accidentally be running against outdated cabal
contents.

So in this commit we change the logic from

  "if *.cabal doens't exist, check if package.yaml exist, if so use hpack"

to

  "if package.ymal exists, use hpack, otherwise use *.cabal"
@nh2 nh2 force-pushed the hpack-ignore-existing-cabal-files branch from 356525c to 5721bed Compare July 17, 2018 10:48
@peti peti merged commit 868cc5e into NixOS:master Jul 18, 2018
@qrilka
Copy link
Contributor

qrilka commented Jan 30, 2019

I think this PR made cabal2nix CLI flags inconsistent, in cabal2nix --help I see the following:

  --hpack                  run hpack before configuring this package (only
                           non-hackage packages

And yet even if I don't specify this flag hpack gets uses if there is package.yaml.
So in the end hpack gets run not depending on whether was --hpack flag specified or not (though behavior differs a bit when there is no package.yaml).
As a way around that situation I plan to use data UseHpack = ForcedHpack | DefaultHpack | NoHpack instead of just a boolean and add --no-hpack flag to make use of the 3rd option

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.

None yet

3 participants