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

Support cabal projects #28

Open
Fresheyeball opened this issue Nov 29, 2017 · 12 comments
Open

Support cabal projects #28

Fresheyeball opened this issue Nov 29, 2017 · 12 comments

Comments

@Fresheyeball
Copy link

This is a very nice tool, and I wish I could use it without stack.

@ndmitchell
Copy link
Owner

What's the reason for wanting to avoid stack? A simple stack init && weeder should be enough, so you don't have to use stack for day to day development - I don't.

If you do want to use Cabal, that's possible, but requires passing some extra flags to Cabal, then modifying Weeder to find the suitable output files. If there was a volunteer to do that I can give a few pointers.

@ndmitchell ndmitchell changed the title Please provide support for cabal projects Support cabal projects Nov 30, 2017
@Fresheyeball
Copy link
Author

I just don't use stack, since I manage haskell dependencies with nix. Can you tell me more about the output files?

@ndmitchell
Copy link
Owner

Ah, that makes a lot more sense. To a first approximation weeder needs to find the list of cabal files (easy if you aren't using stack), and from there find all the -dump-hi output files, which Stack generates as standard (hence why Stack makes it a lot easier). The options are to compile for Cabal/Nix using -dump-hi, or convert the .hi files after-the-fact. I don't know which one is easier, but happy with either approach.

@robcohen
Copy link

I also would like to use nix/cabal with weeder. The CI setup I have does not rely on stack, so that's not an option. If I can figure out how to do this, I'll do my best to submit a patch. If you know of any resources that document how I might do this, please let me know.

@robcohen
Copy link

Is it possible you meant "-ddump-hi" as documented here?

@ndmitchell
Copy link
Owner

Yep, I definitely meant -ddump-hi!

If you want to integrate it the file to replace/augment is https://github.com/ndmitchell/weeder/blob/master/src/Weeder.hs#L37-L42 which calls things in https://github.com/ndmitchell/weeder/blob/master/src/Stack.hs. Basically find the project, make sure it has .hi files and then get its necessary info.

@robcohen
Copy link

Thanks a lot, I appreciate the guidance!

@cleverca22
Copy link

mkDerivation = args: super.mkDerivation (args // {
  configureFlags = (args.configureFlags or []) ++ [ "--ghc-options=-ddump-hi" ];
});

if you put this inside your haskell package overrides, it will modify the configureFlags that get passed to cabal, and then you will probably have dump-hi files in every output path

@ndmitchell
Copy link
Owner

If you demand that anyone who has built with Cabal must have already passed ddump-hi then it probably isn't too hard a problem to solve - just rewriting things to look for cabal files and find hi files in a different place. Ideally in that case it would automatically figure out stack vs Cabal (perhaps with a setting to force one mode or the other).

@cleverca22
Copy link

input-output-hk/cardano-sl#3400
this restructures the file to have multiple haskell overlays, and then an optional overlay that does cabal configure --ghc-options=-ddump-hi for the entire set of haskell packages

@Shimuuar
Copy link

Shimuuar commented Mar 6, 2019

So what I found about generating *.dump-hi files using cabal new-build.

  1. One needs to pass both -ddump-hi and -ddump-to-file to GHC. This could be done either using cabal new-build --ghc-option=-ddump-hi --ghc-option=-ddump-to-file ... invocation or using nix overrides.

  2. All *.dump-hi files are located inside dist-newstyle even if project contains multiple packages

  3. cabal doesn't clean up dist-newstyle so it may contain files from older builds. For example if one bumps version in cabal file and rebuilds. dist-newstyle will contain files from both old and new version

@ndmitchell
Copy link
Owner

Weeder 2.0 is being developed at https://github.com/ocharles/weeder so I suggest you go see if that fixes your issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants