Skip to content

Commit

Permalink
Fail if cabal update fails (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar authored and jmitchell committed Feb 14, 2018
1 parent 486a88f commit b614c56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/Stack2nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Data.Maybe (isJust)
import Data.Monoid ((<>))
import Paths_stack2nix (version)
import Stack2nix.External.Stack
import Stack2nix.External.Util (runCmdFrom)
import Stack2nix.External.Util (runCmdFrom, failHard)
import Stack2nix.External.VCS.Git (Command (..), ExternalCmd (..),
InternalCmd (..), git)
import Stack2nix.Types (Args (..))
Expand Down Expand Up @@ -46,8 +46,10 @@ stack2nix args@Args{..} = do
tryGit tmpDir >> handleStackConfig (Just argUri) tmpDir
where
updateCabalPackageIndex :: IO ()
updateCabalPackageIndex =
getEnv "HOME" >>= \home -> void $ runCmdFrom home "cabal" ["update"]
updateCabalPackageIndex = do
home <- getEnv "HOME"
out <- runCmdFrom home "cabal" ["update"]
void $ failHard out

tryGit :: FilePath -> IO ()
tryGit tmpDir = do
Expand Down
9 changes: 0 additions & 9 deletions src/Stack2nix/External/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Stack2nix.External.Stack
( PackageRef(..), runPlan
) where

import Control.Applicative ((<|>))
import Data.List (concat)
import qualified Data.Map.Strict as M
import Data.Maybe (fromJust)
Expand Down Expand Up @@ -112,7 +111,6 @@ runPlan baseDir remoteUri args@Args{..} = do
ensureExecutable ("haskell.compiler.ghc" ++ ghcnixversion)
withBuildConfig globals $ planAndGenerate buildOpts baseDir remoteUri args ghcnixversion


getGhcVersionIO :: GlobalOpts -> FilePath -> IO (CompilerVersion 'CVWanted)
getGhcVersionIO go stackFile = do
cp <- canonicalizePath stackFile
Expand All @@ -122,13 +120,6 @@ getGhcVersionIO go stackFile = do
runRIO runner $ loadConfig mempty Nothing (SYLOverride fp)
loadCompilerVersion go lc

{-
TODO:
- replace "ghc" in package list with value encoding compiler version
- handle custom shell.nix (see mshellFile in Stack.Nix.runShellAndExit)
- remove baseDir arguments; due to withCurrentDirectory it should always be PWD.
-}

globalOpts :: FilePath -> FilePath -> Args -> GlobalOpts
globalOpts currentDir stackRoot Args{..} =
go { globalReExecVersion = Just "1.5.1" -- TODO: obtain from stack lib if exposed
Expand Down

0 comments on commit b614c56

Please sign in to comment.