on master help sign in
Add: Support building in nix-shell. (#1670)

Can now run the demo script inside a nix-shell which provides a GHC libdir.

commit0058173e292c3e52a6811792c19b8dd849467671 authorNicholas Clarke <nick@topos.org.uk> dateFri 14 Jun 2019, 16:11 (7 years ago) parent9529592
1 file changed+5−2
test/Demo.hs+5−2
test/Demo.hs+5−2
@@ -31,8 +31,11 @@ import CmdLineParser
3131import DynFlags
3232import Panic
3333import GHC
34−import GHC.Paths
34+import qualified GHC.Paths
3535
36+-- Set the GHC libdir to the nix libdir if it's present.
37+getLibdir :: IO FilePath
38+getLibdir = fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR"
3639
3740main :: IO ()
3841main = do
@@ -78,7 +81,7 @@ showEvent lock e = withLock lock $ print e
7881
7982-- | Create a GHC session that will be subsequently reused.
8083newSession :: [String] -> IO HscEnv
81−newSession flags = runGhc (Just libdir) $ do
84+newSession flags = getLibdir >>= \libdir -> runGhc (Just libdir) $ do
8285 damlDFlags <- getSessionDynFlags
8386 (dflags', leftover, warns) <- parseDynamicFlagsCmdLine damlDFlags $ map noLoc flags
8487