Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distributing a Haskell program on Homebrew

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.

like image 406
mk12 Avatar asked Jul 22 '12 20:07

mk12


1 Answers

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

like image 68
Itkovian Avatar answered Sep 28 '22 16:09

Itkovian