Commit fb232797 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Default to global installs on Windows

User installs by default elsewhere. Note that this default only
affects new config files. Existing windows users will need to
change their config file or delete it and let it be re-created.
parent ae99d866
......@@ -47,6 +47,8 @@ import Distribution.Simple.Setup
import qualified Distribution.Simple.Setup as ConfigFlags
import qualified Distribution.Simple.Setup as Cabal
import Distribution.Verbosity (Verbosity, normal)
import Distribution.System
( OS(Windows), buildOS )
import Hackage.Types
( RemoteRepo(..), Repo(..), Username(..), Password(..) )
......@@ -116,6 +118,13 @@ defaultCacheDir = do dir <- defaultCabalDir
defaultCompiler :: CompilerFlavor
defaultCompiler = fromMaybe GHC defaultCompilerFlavor
defaultUserInstall :: Bool
defaultUserInstall = case buildOS of
-- We do global installs by default on Windows
Windows -> False
-- and per-user installs by default everywhere else
_ -> True
defaultUserInstallDirs :: IO (InstallDirs (Flag PathTemplate))
defaultUserInstallDirs =
do userPrefix <- defaultCabalDir
......@@ -130,15 +139,15 @@ defaultSavedConfig :: IO SavedConfig
defaultSavedConfig =
do userInstallDirs <- defaultUserInstallDirs
cacheDir <- defaultCacheDir
return SavedConfig
{ configFlags = mempty {
ConfigFlags.configHcFlavor = toFlag defaultCompiler
, ConfigFlags.configVerbosity = toFlag normal
, ConfigFlags.configUserInstall = toFlag True
, ConfigFlags.configInstallDirs = error
"ConfigFlags.installDirs: avoid this field. Use UserInstallDirs \
\ or GlobalInstallDirs instead"
}
return SavedConfig {
configFlags = mempty {
ConfigFlags.configHcFlavor = toFlag defaultCompiler
, ConfigFlags.configVerbosity = toFlag normal
, ConfigFlags.configUserInstall = toFlag defaultUserInstall
, ConfigFlags.configInstallDirs = error
"ConfigFlags.installDirs: avoid this field. Use UserInstallDirs \
\ or GlobalInstallDirs instead"
}
, configUserInstallDirs = userInstallDirs
, configGlobalInstallDirs = defaultGlobalInstallDirs
, configCacheDir = toFlag cacheDir
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment