NixOS/nixpkgs — pull request #2598 by peti (2014-05-10 12:35:56+00:00)
Title: Re-write the Haskell Platform out of haskell-defaults.nix

Re-write the Haskell Platform out of haskell-defaults.nix.

We used to configure library versions for every compiler that corresponded (roughly) to the Haskell Platform that was current at the time the compiler was released, i.e. GHC 6.10.4 builds would run with ancient versions of QuickCheck, HTTP, etc. This whole approach is now gone. The Haskell Platform has no effect on our default library selection any more; we generally provide the latest version possible that the respective compiler can build.

To simplify our configuration even further, we dropped all intermediate GHC releases from all-packages.nix. What remains is a haskellPackages_ghcXYZ set for the latest version of every major release branch, i.e. GHC 6.10.4, 6.12.3, 7.0.4, 7.2.2, 7.4.2, 7.6.3, 7.8.2, and 7.9.x (HEAD snapshot).

Furthermore, there are some new features:

- The ghcXYZPrefs settings in haskell-defaults.nix now automatically inherit entries from older platforms: an override configured in ghc722Prefs is automatically visible for all newer compilers, too. In the old scheme, entries that were necessary for multiple platforms had to be duplicated in all of them, so this change has reduced the number of necessary overrides quite a bit. The downside is that overriding an attribute for only one particular GHC version has become more difficult, because the override needs to be "undone" in the next "prefs" function to keep it from propagating. I've found that this is no problem in practice, because overrides that apply only to one particular GHC version don't occur much in practice.

We could take things even further and split each prefs function into two: a ghc782OrLaterPrefs function, which does propagate its attributes, and a ghc782Prefs function, which does not. It seemed like overkill to do that now, though.

- 'cabalLatest' is a variant of the 'cabal' builder designed that drives the build with a recent version of Cabal, instead of the version shipped with the compiler. This function is useful for building packages that use funky Cabal features that GHC 6.x and friends don't support. With this builder, the compiler will be able to handle those Cabal files.

On modern compilers, however, cabalLatest does nothing, i.e. it's just an alias for 'cabal'. The reason for this is that overriding Cabal is tricky -- it's a core library -- and a number of builds fail with version conflicts when built with a non-standard Cabal library. This applies particularly to every package that uses hspec/doctest for their test suite as these libraries depend on the GHC-API, which in turn depends on Cabal. So these packages always pull the native version in.

- The 'cabal' builder has a brand-new argument called 'extension'. That function is "self : super : {}" by default, but, users can override it to mess with the attribute set passed to cabal.mkDerivation. An example use would be the definition of darcs in all-packages.nix:

darcs = haskellPackages.darcs.override {
cabal = haskellPackages.cabal.override {
extension = self : super : {
isLibrary = false;
configureFlags = "-f-library " + super.configureFlags or "";
};
};
};

In this case, extension disables building the library part of the package to give us an executable-only version that has no dependencies on GHC or any other Haskell packages.

The 'self' argument refers to the final version of the attribute set and 'super' refers to the original attribute set.