cabal design

Isaac Jones ijones at syntaxpolice.org
Fri Sep 16 13:02:32 EDT 2005


"Simon Marlow" <simonmar at microsoft.com> writes:

> Ok, I've read through this discussion.  Could somebody explain to me why
> this whole "virtualization" thing can't be solved by simply adding the
> flag
>
>   --package-db=<file>
>
> to Cabal?  It would be another option in the --user/--global family.
> The idea isn't new - I'm sure we've discussed this before.  It seems to
> suffer from none of the problems of the other suggestions, but perhaps
> I'm missing something.  For Hugs, the <file> would actually specify a
> directory.  Additionally, --package-db=<file> is a step on the way to
> other things that we want to do (--in-place).

The problem I have with --package-db= as a directory for Hugs (and
nhc, and jhc) is that it conflicts with the meaning of the --prefix
flag.  That is, if you specify a package database, it changes the
location of the installation, which is not what you might expect.
Also, we'd have to make sure people don't try to use --prefix and
--package-db together in the case of Hugs (unless they're equal).

> It seems to me that the requirement is basically this:
>
>   - To be able to install packages in a group, such that
>     all packages in the group are registered in a single,
>     separate, package database.
>
> the fact that in the proposed use cases the packages are also installed
> under a pseudo-root is a red herring as far as Cabal is concerned.  We
> don't care where you install your packages or what files they contain.

Right, but it matters for Hugs because of how Hugs finds packages.

> So the question becomes how to specify which "package group" a package
> should be registered in.  I propose the simplest thing: tell Cabal the
> location of a package database.  

Another option, since this will only really work for GHC, is to add
--ghc-options and --ghc-pkg-options and people can specifcy the
database they want, and it'll be clear that it's not a portable
option.

> The other proposals (--prefix and --root) require Cabal to magically
> derive the location of the package database from the "root"
> directory, but that's magic that we don't need/want IMO.

So for the sake of those who haven't read the wiki page, here's my
--root= proposal.  This basically directly implements "virtualization"
in Cabal:

    * For GHC
      o --prefix now becomes $(ROOT)/$(PREFIX)
      o the ghc-pkg file is stored in $(ROOT)/.whatever
      o Cabal adds package-conf related flags to ghc and ghc-pkg to
        look at $(ROOT)/.whatever.
    * For Hugs
      o -P$(ROOT)/usr/lib/hugs will be added
      o Hugs still has issues if --prefix isn't something Hugs knows
        about (as now). See web page below for comments on how to
        solve that problem.

http://www.haskell.org/hawiki/Cabal_2fVirtualizationRequirements

I like this because it makes sense for GHC, Hugs, nhc, and jhc.  I
agree that finding the package database for GHC is a bit of magic at
that point, but really what --root= is saying is just the same as
--package-db=, except that it's admitting that you can't do this
without changing the installation location for Hugs, etc.  So the
location of packages.conf is derived from --root instead of being
directly specified by --package-db.  I don't think that's a lot of
magic.


peace,

  isaac


More information about the Libraries mailing list