Work on Haskell GHC wrapping.

Unify the wrapper environment that is build by the standard ghc-wrapper and by ghcWithPackages. So far the two wrapper environments have different approaches to pass NIX specific parameters to GHC. Now, one common approach is used. The idea is to reduce a source of errors that could appear when switching from one wrapper environment to the other. Both wrappers should work as before. If not, it is probably a bug of the new implementation.
NOTE: ghcWithPackages can also wrap a ghc-wrapper wrapped GHC now, not a ghcPlain.

A major change is the introduction of a patch for GHC. The patch makes GHC evaluate a NIX specific environment variable. The environment variable is used to hide NIX specific configurations. The idea is to integrate GHC in NIX without passing NIX specific parameters to GHC.
That reduces the risk of interference between the NIX specific parameters and e.g. parameters set by a tool.
NOTE: So far only GHC 7.8.3 is patched, and thus working! Further versions of GHC will be patched once the new wrapping concept is established and accepted.

Add caching of GHC packages search for ghc-wrapper.
So far ghc-wrapper searches for all available Haskell packages at every call. The result of the search is discarded. That can lead to delays in the execution. Now, the result is stored, so far under /tmp/nix-haskell-env-ghc-cache-*. The idea is that available Haskell packages can only change if either the system, default or user profile change. So results are cached for every combination of the three profiles.
NOTE: So far the caches are not deleted automatically. If you know of a way to propagate hooks that are provided by a package to postBuild of buildEnv that is used to create the profiles, please let me know!

ghcWithPackages provides the script "nix-ghc-env-exec" which allows to run a command wrapped for the GHC of ghcWithPackages.
ghcWithPackages also provides a script that initiates the GHC environment when sourced into a shell. The script is installed in etc/profile.d/ghc-env.sh, and might be sourced by some shells automatically.

Now, cabal.mkDerivation has the attribute flag "wrapExecutables" which wrappes executables automatically with a GHC environment of the GHC they are build with. That is useful for e.g. tools that need to find and interact with GHC to e.g. find all installed packages.
hdevtools and ghc-mod are changed to be wrapped with wrapExecutables.
How exactly does this patch relate to the re-factoring you've done? It is not obvious to me why a patch to hdevtools has to be merged in the same commit as a refactoring of the cabal build driver, two two things seem unrelated to me.