From 741fd5c39b6a809758082f172346401ef5288384 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 3 Oct 2017 19:00:16 -0700 Subject: [PATCH] Fix "stack clean" with --nix #3468 --- ChangeLog.md | 2 ++ src/Stack/Runners.hs | 4 +++- src/main/Main.hs | 9 +++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 792b1b3f46..b865e6cc9c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -140,6 +140,8 @@ Bug fixes: * docs.haskellstack.org RTD documentation search is replaced by the mkdocs search. Please see [#3376](https://github.com/commercialhaskell/stack/issues/3376). +* `stack clean` now works with nix. See + [#3468](https://github.com/commercialhaskell/stack/issues/3376). ## 1.5.1 diff --git a/src/Stack/Runners.hs b/src/Stack/Runners.hs index b7711d91bc..000145fc2e 100644 --- a/src/Stack/Runners.hs +++ b/src/Stack/Runners.hs @@ -128,6 +128,8 @@ withBuildConfigAndLock withBuildConfigAndLock go inner = withBuildConfigExt False go Nothing inner Nothing +-- | See issue #2010 for why this exists. Currently just used for the +-- specific case of "stack clean --full". withBuildConfigAndLockNoDocker :: GlobalOpts -> (Maybe FileLock -> RIO EnvConfig ()) @@ -177,7 +179,7 @@ withBuildConfigExt skipDocker go@GlobalOpts{..} mbefore inner mafter = loadConfi if skipDocker then runRIO (lcConfig lc) $ do forM_ mbefore id - liftIO $ inner'' lk0 + Nix.reexecWithOptionalShell (lcProjectRoot lc) getCompilerVersion (inner'' lk0) forM_ mafter id else runRIO (lcConfig lc) $ Docker.reexecWithOptionalContainer diff --git a/src/main/Main.hs b/src/main/Main.hs index 143085c92d..2c68d8f382 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -51,7 +51,7 @@ import Path import Path.IO import qualified Paths_stack as Meta import Stack.Build -import Stack.Clean (CleanOpts, clean) +import Stack.Clean (CleanOpts(..), clean) import Stack.Config import Stack.ConfigCmd as ConfigCmd import Stack.Constants @@ -581,7 +581,12 @@ setupCmd sco@SetupCmdOpts{..} go@GlobalOpts{..} = loadConfigWithOpts go $ \lc -> (Just $ munlockFile lk) cleanCmd :: CleanOpts -> GlobalOpts -> IO () -cleanCmd opts go = withBuildConfigAndLockNoDocker go (const (clean opts)) +cleanCmd opts go = + -- See issues #2010 and #3468 for why "stack clean --full" is not used + -- within docker. + case opts of + CleanFull{} -> withBuildConfigAndLock go (const (clean opts)) + CleanShallow{} -> withBuildConfigAndLockNoDocker go (const (clean opts)) -- | Helper for build and install commands buildCmd :: BuildOptsCLI -> GlobalOpts -> IO ()