Load path environment variable for cabal sources?

Tim Cuthbertson tim at gfxmonk.net
Sat Aug 4 16:15:54 CEST 2012


Hi all,

I've done some digging into distributing haskell libraries outside of
cabal/hackage, using zeroinstall (http://0install.net). My current
results distributing compiled libraries have been somewhat fragile,
due to having no good way of tracking changes to the GHC abi and
forcing a rebuild of libraries when mismatches are found.

I don't at this point care for distributing binary-only libraries,
that is just how zeroinstall likes to work (compile all dependencies
into a usable binary form, then compile the program that depends on
them).

I'm wondering if the problem could be worked around by only ever
distributing libraries as source-only, and just statically linking
programs (which I believe is the default already). This would lead to
too much compilation since already-compiled libraries would not be
used, but that's better than it not working as soon as GHC is upgraded
(which I believe is my current status).

When distributing precompiled libraries, I've been adding them to
GHC_PKG_PATH - `cabal build` will then use these binaries to satisfy
dependencies of the app I'm building. What I would like is for the
same mechanism, but for sources instead of precompiled binaries.

I have a working cut of this after some hacking, which basically involves:

 - putting all dependencies' source directories into a colon-separated
environment variable, "CABAL_PKG_PATH" (this is how zeroinstall
typically makes dependancies available)
 - Creating a temporary cabal config file that specifies a single
`local-repo` location inside the (throwaway) build dir
 - populating said local-repo folder, by traversing each path in
$CABAL_PKG_PATH and:
    - find the cabal file in each directory
    - extract important metadata (name and version) from the cabal file
    - add the cabal file to 00-index.tar as {name}/{version}/{name}.cabal
    - tarring up the source directory and placing it under
{name}/{version}/{name}-{version}.tar.gz
 - run `cabal install` from the program's source directory with
$CABAL_CONF, --builddir and --prefix set appropriately

Tarring up all source packages in particular seems fairly wasteful,
and it all seems like quite a few hoops to jump through in order to
construct something that looks like a hackage cache (which I don't
particularly want, but it seems to be the only way to make them
available).

So I was wondering if there is any simpler way to populate a set of
local sources such that `cabal install` will be able to find them?
It's quite likely that it was never really intended to work with
anything other than a hackage-style DB, but I thought it couldn't hurt
to ask :)

Cheers,
 - Tim.



More information about the cabal-devel mailing list