summaryrefslogtreecommitdiff
path: root/src/Propellor/DotDir.hs
diff options
context:
space:
mode:
authorJoey Hess2016-04-05 11:29:09 -0400
committerJoey Hess2016-04-05 11:29:09 -0400
commit0ca752f9471a6dee173dec810c0749f4214e5304 (patch)
treeddb317ab3d5ded35053441cc3c335d7f5015fbbf /src/Propellor/DotDir.hs
parenta55ddfca3fe1ee3b297b21e7596f4182678ff6a6 (diff)
parentd53fb1907bab2da6c19bd83e5140149d7579740c (diff)
Merge remote-tracking branch 'spwhitton/fix-init-build' into joeyconfig
Diffstat (limited to 'src/Propellor/DotDir.hs')
-rw-r--r--src/Propellor/DotDir.hs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs
index 52ab0571..100342e8 100644
--- a/src/Propellor/DotDir.hs
+++ b/src/Propellor/DotDir.hs
@@ -71,6 +71,21 @@ interactiveInit = ifM (doesDirectoryExist =<< dotPropellor)
setup
)
+-- | Determine whether we need to create a cabal sandbox in ~/.propellor/,
+-- which we do if the user has configured cabal to require a sandbox, and the
+-- build system is cabal.
+cabalSandboxRequired :: IO Bool
+cabalSandboxRequired = ifM cabal
+ ( do
+ home <- myHomeDir
+ ls <- lines <$> readFile (home </> ".cabal" </> "config")
+ -- For simplicity, we assume a sane ~/.cabal/config here:
+ return $ "require-sandbox: True" `elem` ls
+ , return False
+ )
+ where
+ cabal = buildSystem >>= \bSystem -> return (bSystem == "cabal")
+
say :: String -> IO ()
say = outputConcurrent
@@ -120,7 +135,7 @@ setup :: IO ()
setup = do
sayLn "Propellor's configuration file is ~/.propellor/config.hs"
sayLn ""
- sayLn "Lets get you started with a simple config that you can adapt"
+ sayLn "Let's get you started with a simple config that you can adapt"
sayLn "to your needs. You can start with:"
sayLn " A: A clone of propellor's git repository (most flexible)"
sayLn " B: The bare minimum files to use propellor (most simple)"
@@ -139,6 +154,13 @@ setup = do
, Param "propellor.buildsystem"
, Param b
]
+ ifM cabalSandboxRequired
+ ( void $ boolSystem "cabal"
+ [ Param "sandbox"
+ , Param "init"
+ ]
+ , return ()
+ )
buildPropellor Nothing
sayLn ""
sayLn "Great! Propellor is bootstrapped."