@@ -1,11 +1,12 @@
11{-# LANGUAGE FlexibleContexts #-}
22{-# LANGUAGE OverloadedStrings #-}
33{-# LANGUAGE QuasiQuotes #-}
4+{-# LANGUAGE ScopedTypeVariables #-}
45module Obelisk.Command.VmBuilder where
56
67import Control.Applicative (liftA2)
78import Control.Monad (unless)
8−import Control.Monad.Catch (try)
9+import Control.Monad.Catch (try, handle)
910import Control.Monad.IO.Class (liftIO)
1011import Data.Either (isRight)
1112import Data.Monoid ((<>))
@@ -42,13 +43,16 @@ containerName = "obelisk-docker-nix-builder"
4243
4344-- | Check to see if the Docker container exists. This will exit with a helpful message if Docker is not installed.
4445containerExists :: MonadObelisk m => m Bool
45−containerExists = withExitFailMessage needDockerMsg $ do
46+containerExists = handle (\(_ :: IOError) -> failWith needDockerMsg) $ do
4647 containerNames <- fmap (map T.strip . T.lines) $
4748 readProcessAndLogStderr Error $
4849 proc "docker" ["container", "list", "--all", "--format", "{{.Names}}"]
4950 pure $ containerName `elem` containerNames
5051 where
51− needDockerMsg = "This feature requires that you have Docker installed and the `docker` command available on your PATH. Please go https://docs.docker.com/ to install Docker and try this command again."
52+ needDockerMsg = T.intercalate "\n"
53+ [ "This feature requires that you have Docker installed and the `docker` command available on your PATH."
54+ , "Please go https://docs.docker.com/ to install Docker and try this command again."
55+ ]
5256
5357-- | SSH port on localhost that connects to the container.
5458containerSshPort :: Int