6
votes

I'm writing a program in Haskell on my Mac (command line executable, not an app). I'm using GitHub to host the git repository and homepage. I made the <project>.cabal and Setup.hs files since Cabal makes it easy to build, test and generate documentation. I might also upload to Hackage, I don't know.

When I tag version 1.0, I want to make a Homebrew formula to download the tarball from GitHub and build it. I want the only dependency to be GHC.

I will use runhaskell Setup configure/build/install (with the prefix as /usr/local/Cellar/…) rather than the cabal command to avoid depending on cabal-install.

This is all fine until I start using packages from Hackage, e.g. blaze-builder and aeson. How should I manage this?

I don't want to force non-Haskellers to have to download the whole Haskell platform. Ideally, people should be able to just let Homebrew install GHC before it builds my program, and then if they so choose, remove GHC after. If I make the Haskell platform a dependency and first install my Haskell dependencies through cabal-install or similar,

  1. The ~/.cabal/ folder with the packages will be left behind, even if afterwards they
    brew uninstall haskell-platform
  2. I might as well only be going through Hackage and making people cabal install it, i.e. limit the scope for the most part to Haskellers.

I see Cabal(-install) + Hackage as a useful tool for development and for Haskellers but not appropriate for this.

Should I just download the source of the packages I'm using and include it in my source tree, adding it to the build command as well? Or should I be using the --package-db option (found here)? Or could my formula download the tarball for the package on the fly and build it too?

I looked at cabal2arch a bit (Arch wiki, GitHub repo) but I'm not sure how it handles dependencies, or if it's just doing what I don't want to do.

2
Wouldn't it be easier to distribute a binary so non Haskeleers don't need to build it. There is a packager mentioned on Haskell wiki Haskellers can build from source using cabal.mmmmmm
The link you mentioned is for app bundles—my program is a command line tool. It would be easier, yes, but I really like homebrew as a package manager and it likes to build everything from source (see the "Why are you compiling everything?" section in github.com/mxcl/homebrew/wiki/FAQ). You can use "bottles" with homebrew but that is really for things which take hours to build (like Qt), and you can't host the binary just anywhere.mk12
But most users don't have homebrew and surely easier for users to download a simple binary for the compiled program rather than a package manager. If you must use a manager try macports and make your code a port then macports will build it centrally and users download prebuilt binaries.mmmmmm
I don't really like macports, and if I distributed a binary I don't know where I would host it. I just wanted to provide a convenient one liner for people who use homebrew, and the only barrier to me doing that is figuring out how to handle the hackage dependencies. This isn't so much a practical question of distribution as it is, how do I do this specific thing?mk12
Is there no way to make a homebrew formula for blaze-builder, aeson, etc. and add them as dependencies?Daniel Wagner

2 Answers

1
votes

In my opinion, if you decide to go with a package manager, you should make sure all dependencies can be built or are readily available in some other way. If you are only relying on GHC and its core set of libraries, there should be no need for the entire platform to be built alongside.

However, if you wish to build from source (which, IMO is a good idea in numerous, but not all) cases, then building all dependencies is something you have to live with. We do the same for our build system [1] we use in an HPC environment for deploying scientific software on our supercomputers. But it does come at a cost. Bootstrapping such a system can require quite some time, since you want the entire toolchain and all required libraries to be present.

In fact, as we speak, I am putting support in our build system for GHC and haskell packages, and yes, dependencies will be pulled in as well, if needed. At the very least, I'll make sure we can deploy cabal such that our users can install Haskell stuff on their accounts if they desire.

TL;DR Add support for dependencies.

[1] http://hpcugent.github.com/easybuild

0
votes

Hledger is a Haskell program and it can be installed just using homebrew. You can take a look here in the formula file:

https://github.com/Homebrew/homebrew-core/blob/master/Formula/hledger.rb

As you can see in the file, they are some dependencies included ghc and cabal-install.