yesodweb/yesod — pull request #489 by dudebout (2013-01-18 21:40:50+00:00)
Title: Hsenv interaction

From the discussion in #480 and following discussions in https://github.com/tmhedberg/hsenv/pull/9, it became clear that there is no perfectly clean way of interfacing `hsenv` with `yesod devel`.

There are two ways to specify the package database used by `ghc`, the `GHC_PACKAGE_PATH` environment variable and flags. In previous versions of `hsenv`, the environment variable was used and `yesod devel` was using that environment variable transparently. However, the newest version of Cabal, namely 1.16, refuses to run if this variable is set. In particular, since `yesod devel` is using Cabal, this variable cannot be set when running `yesod devel`. As a consequence, the package database set by `hsenv` is not picked up transparently anymore by `yesod devel`.

A problem specific to `yesod devel` ensues. Since `yesod devel` calls directly the GHC API, it does not use the `ghc` wrapper provided by `hsenv`. `yesod devel` therefore does not know about the package database provided by `hsenv`.

I have expanded `getBuildFlags` to realize when `hsenv` is in use and to add the appropriate flags when calling the GHC API.

I understand that programs are not supposed to know about `hsenv` and `hsenv`'s goal is to adapt around them. However, the direct use of the GHC API, in what is called in the source **a huge hack**, makes this goal almost unreachable.