Add: Support building in nix-shell. (#1670)

Can now run the demo script inside a nix-shell which provides a GHC libdir.
This commit is contained in:
Nicholas Clarke 2019-06-14 16:11:32 +02:00 committed by Neil Mitchell
parent 952959293f
commit 0058173e29

View File

@ -31,8 +31,11 @@ import CmdLineParser
import DynFlags
import Panic
import GHC
import GHC.Paths
import qualified GHC.Paths
-- Set the GHC libdir to the nix libdir if it's present.
getLibdir :: IO FilePath
getLibdir = fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR"
main :: IO ()
main = do
@ -78,7 +81,7 @@ showEvent lock e = withLock lock $ print e
-- | Create a GHC session that will be subsequently reused.
newSession :: [String] -> IO HscEnv
newSession flags = runGhc (Just libdir) $ do
newSession flags = getLibdir >>= \libdir -> runGhc (Just libdir) $ do
damlDFlags <- getSessionDynFlags
(dflags', leftover, warns) <- parseDynamicFlagsCmdLine damlDFlags $ map noLoc flags