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

Allow to build with cabal #2027

Merged
merged 8 commits into from
Sep 30, 2020

Conversation

hasufell
Copy link
Contributor

@hasufell hasufell commented Aug 11, 2020

The process to create these files is roughly:

  1. run stack2cabal
  2. work around cabal bugs (see source-repository-package not optional haskell/cabal#5444)
  3. disable tests to avoid build failures with --enable-tests from
    unrelated packages (cabal considers all packages defined via
    source-repository-package as local and will try to build its tests)
  4. fix package constraints in cabal.project.freeze, where stackage
    constraints were overwritten in stack.yaml files (usually raising
    a version number)

Rationale:

  1. good to support all available tools as options for interested users
  2. cabal allows easier managing of package bounds (and testing against
    latest package versions)
  3. Byron-Rewrite node's integration #1303 is an excellent workaround for nix users, but requires nix.
    This should be the go-to fallback in case cabal project files
    get out of sync for too long.

@rvl
Copy link
Contributor

rvl commented Aug 12, 2020

Thanks for the PR, but last time someone did this the cabal build broke pretty much the next day.
And this will do the same.
The process to keep the cabal.project file updated is manual and undocumented, with debugging steps required, and no CI checks.

But even if the cabal.project file were fastidiously maintained, the package set which the cabal solver chooses will not be the same as the LTS snapshot from the stack build. So cabal users will have different package versions and therefore different build/test results than stack users.

It is not hard to install stack to build the project.

It is also not that hard to install nix. And by building with cabal inside a nix-shell you get the correct versions of Haskell dependencies prebuilt from cache, as well as all required system libraries (e.g. systemd, libsodium), and all the build tools, including cabal itself.

@hasufell
Copy link
Contributor Author

Thanks for the PR, but last time someone did this the cabal build broke pretty much the next day. And this will do the same.

I'm using cabal as my primary tool, so I'd like to maintain these files. But I agree that CI should run cabal as well. Once I'm more familiar with those pieces, I'll be happy to provide a PR for that part as well.

The process to keep the cabal.project file updated is manual and undocumented, with debugging steps required, and no CI checks.

That is unfortunate, but I believe that is true for nix as well (which also disables systemd for example). Synchronizing build systems always has a maintenance cost. I believe it not to be high though.

The package set which the cabal solver chooses will not be the same as the LTS snapshot from the stack build. So cabal users will have different package versions and therefore different build/test results than stack users.

The cabal.freeze file is generated from the LTS snapshot, so the solver will choose the same, unless cabal.freeze file is modified afterwards.

It is not hard to install stack to build the project.

I think choice is good and it is consistent with what cardano-node does, especially since this isn't just about developers, but also users trying to build the project.

cabal.project Outdated Show resolved Hide resolved
@hasufell hasufell force-pushed the PR/fix-cabal-build branch 3 times, most recently from 481e4ea to 40c746d Compare August 21, 2020 10:24
@hasufell
Copy link
Contributor Author

ping

@hasufell hasufell force-pushed the PR/fix-cabal-build branch 5 times, most recently from bd4bf4e to aea38af Compare August 27, 2020 11:14
gen-cabal-nosystemd.sh Outdated Show resolved Hide resolved
@hasufell
Copy link
Contributor Author

Instructions on how to update the cabal files is in the commit:

  1. Run stack2cabal
  2. Disable tests and benchmarks of local packages
    (those specified via source-repository-package...
    this won't be needed with cabal-3.4 anymore, because it won't treat
    them as local anymore)
  3. Hackage packages in packages in cardano-1.19.x.yaml or extra-deps
    in stack.yaml, which are specified as git repositories might
    have different versions than the stack resolver. stack2cabal
    cannot pick these up, so these must be adjusted manually (or deleted) in
    cabal.project.freeze (at the time of writing: http-client and persistent).

@hasufell
Copy link
Contributor Author

Another good argument for this is that it unbreaks cabal on windows.

@rvl
Copy link
Contributor

rvl commented Aug 31, 2020

Another good argument for this is that it unbreaks cabal on windows.

Have you actually tried building this branch with cabal on windows?

@hasufell
Copy link
Contributor Author

Have you actually tried building this branch with cabal on windows?

@Anviking did I think?

@hasufell hasufell force-pushed the PR/fix-cabal-build branch 2 times, most recently from 292381e to 371daf5 Compare August 31, 2020 20:22
@hasufell
Copy link
Contributor Author

hasufell commented Sep 1, 2020

Have you actually tried building this branch with cabal on windows?

I just did and it's a major step forward for windows support.

I described how to build cardano-wallet with cabal on windows here: https://gist.github.com/hasufell/0deaeb316eb8a3ad8ad9bf1266b332f8

This also has the advantage over stack that you have a properly up2date msys2 installation and it allows easy adding of native dependencies via mingw-pkg.

@hasufell
Copy link
Contributor Author

Anything blocking this? There's been no further objections and the process to update the cabal files is documented.

@KtorZ
Copy link
Member

KtorZ commented Sep 16, 2020

@hasufell may you modify the wiki as we talked about? i.e. illustrate the steps with examples and give more details about vague words like "adjust" or "disable". Consider this from the point of view of someone who is not familiar with cabal.

@hasufell
Copy link
Contributor Author

hasufell commented Sep 16, 2020

@hasufell may you modify the wiki as we talked about? i.e. illustrate the steps with examples and give more details about vague words like "adjust" or "disable". Consider this from the point of view of someone who is not familiar with cabal.

I'm not sure what is missing. All the steps necessary are explained. If you would give it a shot and let me know what specifically didn't work or wasn't clear, that would be helpful.

I'd suggest to use ghcup to install cabal-3.4.0.0-rc3, so the second step can be skipped.

The process to create these files is as follows:

1. Run stack2cabal
2. Disable tests and benchmarks of local packages
   (those specified via source-repository-package...
   this won't be needed with cabal-3.4 anymore, because it won't treat
   them as local anymore)
3. Hackage packages in `packages` in `cardano-1.19.x.yaml` or `extra-deps`
   in `stack.yaml`, which are specified as git repositories might
   have different versions than the stack resolver. `stack2cabal`
   cannot pick these up, so these must be adjusted manually (or deleted) in
   `cabal.project.freeze` (at the time of writing: http-client and persistent).

Rationale:

1. good to support all available tools as options for interested users
2. cabal allows easier managing of package bounds (and testing against
   latest package versions and different GHCs, because it is not
   constrained to stackage)
3. doesn't require nix, which is an additional step to set up and
   maintain and requires significant amount of disk space
Julian Ospald added 2 commits September 25, 2020 15:55
This is mainly due to a cabal bug and should be removed in
the future: haskell/cabal#5444

There are various distros, where installing development files
of libsystemd won't be an option:

- Alpine (doesn't have systemd at all)
- Gentoo (not installable when eudev is installed)
- Exherbo (not installable when eudev is installed)

Users are expected to run the script and then execute cabal like so:

  cabal build --project-file=cabal.nosystemd.project all
@hasufell
Copy link
Contributor Author

Rebased and wiki updated.

@hasufell
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Sep 28, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 28, 2020

try

Build failed:

The Haskell.nix shellFor function provides Haskell package
dependencies and all their dependencies.

This new nix/cabal-shell.nix file only provides a compiler, build
tools and system libraries, and lets Cabal build the Haskell package
dependencies.
Using nix-shell and "cabal build --project-file=cabal-nix.project",
all Haskell dependencies will be downloaded from the IOHK cache,
rather than built locally.
@rvl
Copy link
Contributor

rvl commented Sep 30, 2020

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 30, 2020

Build succeeded:

@iohk-bors iohk-bors bot merged commit cd72918 into cardano-foundation:master Sep 30, 2020
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.

3 participants