haskell/cabal — pull request #993 by 23Skidoo (2012-08-08 06:43:41+00:00)
Title: Implement package environment file parsing

This series of patches implements the second of the two infrastructure changes required to add sandboxes (aka package environments, hermetic builds) to Cabal. It adds a new config file type - a package environment file, as described in [1]. The bulk of the implementation is contained in the new module `Distribution.Client.PackageEnvironment`.

Example of a package environment file:

```
-- inherit: /home/$USERNAME/.cabal/config
-- constraints: foo ==1.0, foo +use_blah -use_blurb
-- preferences: bar ==2.0
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /home/$USERNAME/.cabal/packages
local-repo: /path/tol/.cabal-sandbox/packages
logs-dir: /path/to/.cabal-sandbox/logs
world-file: /path/to/.cabal-sandbox/world
user-install: False
package-db: /path/to/.cabal-sandbox/packages.conf.d

install-dirs
prefix: /path/to/.cabal-sandbox
-- bindir: $prefix/bin
-- libdir: $prefix/lib
-- libsubdir: $pkgid/$compiler
-- libexecdir: $prefix/libexec
-- datadir: $prefix/share
-- datasubdir: $pkgid
-- docdir: $datadir/doc/$pkgid
-- htmldir: $docdir/html
-- haddockdir: $htmldir

-- Other configuration:
-- optimization: True
-- with-compiler: /path/to/my-special-ghc
```

The package environment file looks a lot like `~/.cabal/config` and supports the same configuration options. The differences are:

* An `inherit` option to allow inheriting from `~/.cabal/config` or other config files.
* Options `constraint` and `preference` are replaced with `constraints` and `preferences` that are parsed as comma-separated lists.
* A single `install-dirs` section instead of the user and the global one.
* The default install directory is `./.cabal-sandbox` instead of `$HOME/.cabal`.

[1] http://hackage.haskell.org/trac/hackage/wiki/PackageEnvironments