Skip to content

Commit

Permalink
Only pre-load compiler version for --nix (fixes #2459)
Browse files Browse the repository at this point in the history
  • Loading branch information
borsboom committed Aug 16, 2016
1 parent 03eca73 commit 5607c06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/Stack/Nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ import System.Process.Read (getEnvOverride)
reexecWithOptionalShell
:: M env m
=> Maybe (Path Abs Dir)
-> CompilerVersion
-> IO CompilerVersion
-> IO ()
-> m ()
reexecWithOptionalShell mprojectRoot compilerVersion inner =
reexecWithOptionalShell mprojectRoot getCompilerVersion inner =
do config <- asks getConfig
inShell <- getInShell
isReExec <- asks getReExec
if nixEnable (configNix config) && not inShell && not isReExec
then runShellAndExit mprojectRoot compilerVersion getCmdArgs
then runShellAndExit mprojectRoot getCompilerVersion getCmdArgs
else liftIO inner
where
getCmdArgs = do
Expand All @@ -71,16 +71,17 @@ reexecWithOptionalShell mprojectRoot compilerVersion inner =
runShellAndExit
:: M env m
=> Maybe (Path Abs Dir)
-> CompilerVersion
-> IO CompilerVersion
-> m (String, [String])
-> m ()
runShellAndExit mprojectRoot compilerVersion getCmdArgs = do
runShellAndExit mprojectRoot getCompilerVersion getCmdArgs = do
config <- asks getConfig
envOverride <- getEnvOverride (configPlatform config)
(cmnd,args) <- fmap (escape *** map escape) getCmdArgs
mshellFile <-
traverse (resolveFile (fromMaybeProjectRoot mprojectRoot)) $
nixInitFile (configNix config)
compilerVersion <- liftIO getCompilerVersion
let pkgsInConfig = nixPackages (configNix config)
ghc = nixCompiler compilerVersion
pkgs = pkgsInConfig ++ [ghc]
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Runners.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ withBuildConfigExt go@GlobalOpts{..} mbefore inner mafter = do
go
(inner' lk)

compilerVersion <- loadCompilerVersion manager go lc
let getCompilerVersion = loadCompilerVersion manager go lc
runStackTGlobal manager (lcConfig lc) go $
Docker.reexecWithOptionalContainer
(lcProjectRoot lc)
mbefore
(runStackTGlobal manager (lcConfig lc) go $
Nix.reexecWithOptionalShell (lcProjectRoot lc) compilerVersion (inner'' lk0))
Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion (inner'' lk0))
mafter
(Just $ liftIO $
do lk' <- readIORef curLk
Expand Down
8 changes: 4 additions & 4 deletions src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,13 @@ setupCmd :: SetupCmdOpts -> GlobalOpts -> IO ()
setupCmd sco@SetupCmdOpts{..} go@GlobalOpts{..} = do
(manager,lc) <- loadConfigWithOpts go
withUserFileLock go (configStackRoot $ lcConfig lc) $ \lk -> do
compilerVersion <- loadCompilerVersion manager go lc
let getCompilerVersion = loadCompilerVersion manager go lc
runStackTGlobal manager (lcConfig lc) go $ do
Docker.reexecWithOptionalContainer
(lcProjectRoot lc)
Nothing
(runStackTGlobal manager (lcConfig lc) go $
Nix.reexecWithOptionalShell (lcProjectRoot lc) compilerVersion $
Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion $
runStackLoggingTGlobal manager go $ do
(wantedCompiler, compilerCheck, mstack) <-
case scoCompilerVersion of
Expand Down Expand Up @@ -724,7 +724,7 @@ execCmd ExecOpts {..} go@GlobalOpts{..} =
(ExecRunGhc, args) -> return ("ghc", "-e" : "Main.main" : args)
(manager,lc) <- liftIO $ loadConfigWithOpts go
withUserFileLock go (configStackRoot $ lcConfig lc) $ \lk -> do
compilerVersion <- loadCompilerVersion manager go lc
let getCompilerVersion = loadCompilerVersion manager go lc
runStackTGlobal manager (lcConfig lc) go $
Docker.reexecWithOptionalContainer
(lcProjectRoot lc)
Expand All @@ -735,7 +735,7 @@ execCmd ExecOpts {..} go@GlobalOpts{..} =
menv <- liftIO $ configEnvOverride config plainEnvSettings
Nix.reexecWithOptionalShell
(lcProjectRoot lc)
compilerVersion
getCompilerVersion
(runStackTGlobal manager (lcConfig lc) go $
exec menv cmd args))
Nothing
Expand Down

0 comments on commit 5607c06

Please sign in to comment.