diff options
| author | Sean Whitton <spwhitton@spwhitton.name> | 2016-04-03 12:13:25 -0700 |
|---|---|---|
| committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-04-03 12:13:25 -0700 |
| commit | d53fb1907bab2da6c19bd83e5140149d7579740c (patch) | |
| tree | 9f36ebc82b6f678484f2cfdfa26b84c6a6b0d1ae | |
| parent | a7503d1b107656f0635d6d965d0dca9bdda7839f (diff) | |
propellor --init inits a cabal sandbox when needed
| -rw-r--r-- | src/Propellor/DotDir.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Propellor/DotDir.hs b/src/Propellor/DotDir.hs index c911513a..3bf66c2b 100644 --- a/src/Propellor/DotDir.hs +++ b/src/Propellor/DotDir.hs @@ -66,6 +66,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 @@ -134,6 +149,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." |
