Skip to content

Commit

Permalink
Merge pull request #3470 from commercialhaskell/fix-nix-stack-clean
Browse files Browse the repository at this point in the history
Fix "stack clean" with --nix #3468
  • Loading branch information
mgsloan authored Oct 4, 2017
2 parents b076f2c + 741fd5c commit 25dcf07
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,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
Expand Down
4 changes: 3 additions & 1 deletion src/Stack/Runners.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ())
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ()
Expand Down

0 comments on commit 25dcf07

Please sign in to comment.