Stack: Add `stack hpack` to generate .cabal files without separate hpack executable

Created on 22 Dec 2017  路  5Comments  路  Source: commercialhaskell/stack

Motivation from chat logs:

What is the simplest way to get stack to generate a cabal file from package.yaml without building? I could do that using stack query, but is there a better/canonical way to do it?
stack build --dry-run will do it. I've wished for a stack hpack command myself.

hpack enhancement

Most helpful comment

What was the resolution here? stack build --dry-run does more than just run hpack

All 5 comments

I believe that despite its name, stack build --dry-run will invoke hpack. If the hpack exe is installed, I think you can also do stack exec hpack.

Is that sufficient? Should it be documented? Not sure it's worth a new command.

stack build --dry-run seems to work for me (it generates a .cabal file). The advantage of stack hpack is that it would use the _same_ version of hpack that Stack is built with, vs stack exec hpack which would use whatever version was last installed (if that's older than stack's, it will complain that the .cabal file was generated with a newer version of hpack, and if it's newer it will cause stack to make the same complaint).

I suppose there isn't much of an overhead to adding such aliases for common stuff.

Somewhat off topic, but I would also like stack ghc-pkg -- as a slightly more convenient way to run stack exec -- ghc-pkg

What was the resolution here? stack build --dry-run does more than just run hpack

I also encountered situations where something like stack hpack is necessary. I want to avoid that stack build --dry-run does setup, because it takes extra time especially when using nix integration.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwaldmann picture jwaldmann  路  4Comments

rrnewton picture rrnewton  路  4Comments

symbiont-joseph-kachmar picture symbiont-joseph-kachmar  路  3Comments

bitemyapp picture bitemyapp  路  3Comments

mgsloan picture mgsloan  路  3Comments