{-# LANGUAGE NoImplicitPrelude #-}

module Stack.Types.EnvSettings
  ( EnvSettings (..)
  , minimalEnvSettings
  , defaultEnvSettings
  , plainEnvSettings
  ) where

import           Stack.Prelude

-- | Controls which version of the environment is used

data EnvSettings = EnvSettings
  { EnvSettings -> Bool
esIncludeLocals :: !Bool
  -- ^ include local project bin directory, GHC_PACKAGE_PATH, etc

  , EnvSettings -> Bool
esIncludeGhcPackagePath :: !Bool
  -- ^ include the GHC_PACKAGE_PATH variable

  , EnvSettings -> Bool
esStackExe :: !Bool
  -- ^ set the STACK_EXE variable to the current executable name

  , EnvSettings -> Bool
esLocaleUtf8 :: !Bool
  -- ^ set the locale to C.UTF-8

  , EnvSettings -> Bool
esKeepGhcRts :: !Bool
  -- ^ if True, keep GHCRTS variable in environment

  }
  deriving (EnvSettings -> EnvSettings -> Bool
(EnvSettings -> EnvSettings -> Bool)
-> (EnvSettings -> EnvSettings -> Bool) -> Eq EnvSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EnvSettings -> EnvSettings -> Bool
== :: EnvSettings -> EnvSettings -> Bool
$c/= :: EnvSettings -> EnvSettings -> Bool
/= :: EnvSettings -> EnvSettings -> Bool
Eq, Eq EnvSettings
Eq EnvSettings
-> (EnvSettings -> EnvSettings -> Ordering)
-> (EnvSettings -> EnvSettings -> Bool)
-> (EnvSettings -> EnvSettings -> Bool)
-> (EnvSettings -> EnvSettings -> Bool)
-> (EnvSettings -> EnvSettings -> Bool)
-> (EnvSettings -> EnvSettings -> EnvSettings)
-> (EnvSettings -> EnvSettings -> EnvSettings)
-> Ord EnvSettings
EnvSettings -> EnvSettings -> Bool
EnvSettings -> EnvSettings -> Ordering
EnvSettings -> EnvSettings -> EnvSettings
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: EnvSettings -> EnvSettings -> Ordering
compare :: EnvSettings -> EnvSettings -> Ordering
$c< :: EnvSettings -> EnvSettings -> Bool
< :: EnvSettings -> EnvSettings -> Bool
$c<= :: EnvSettings -> EnvSettings -> Bool
<= :: EnvSettings -> EnvSettings -> Bool
$c> :: EnvSettings -> EnvSettings -> Bool
> :: EnvSettings -> EnvSettings -> Bool
$c>= :: EnvSettings -> EnvSettings -> Bool
>= :: EnvSettings -> EnvSettings -> Bool
$cmax :: EnvSettings -> EnvSettings -> EnvSettings
max :: EnvSettings -> EnvSettings -> EnvSettings
$cmin :: EnvSettings -> EnvSettings -> EnvSettings
min :: EnvSettings -> EnvSettings -> EnvSettings
Ord, Int -> EnvSettings -> ShowS
[EnvSettings] -> ShowS
EnvSettings -> String
(Int -> EnvSettings -> ShowS)
-> (EnvSettings -> String)
-> ([EnvSettings] -> ShowS)
-> Show EnvSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EnvSettings -> ShowS
showsPrec :: Int -> EnvSettings -> ShowS
$cshow :: EnvSettings -> String
show :: EnvSettings -> String
$cshowList :: [EnvSettings] -> ShowS
showList :: [EnvSettings] -> ShowS
Show)

minimalEnvSettings :: EnvSettings
minimalEnvSettings :: EnvSettings
minimalEnvSettings =
  EnvSettings
  { esIncludeLocals :: Bool
esIncludeLocals = Bool
False
  , esIncludeGhcPackagePath :: Bool
esIncludeGhcPackagePath = Bool
False
  , esStackExe :: Bool
esStackExe = Bool
False
  , esLocaleUtf8 :: Bool
esLocaleUtf8 = Bool
False
  , esKeepGhcRts :: Bool
esKeepGhcRts = Bool
False
  }

-- | Default @EnvSettings@ which includes locals and GHC_PACKAGE_PATH.

--

-- Note that this also passes through the GHCRTS environment variable.

-- See https://github.com/commercialhaskell/stack/issues/3444

defaultEnvSettings :: EnvSettings
defaultEnvSettings :: EnvSettings
defaultEnvSettings = EnvSettings
  { esIncludeLocals :: Bool
esIncludeLocals = Bool
True
  , esIncludeGhcPackagePath :: Bool
esIncludeGhcPackagePath = Bool
True
  , esStackExe :: Bool
esStackExe = Bool
True
  , esLocaleUtf8 :: Bool
esLocaleUtf8 = Bool
False
  , esKeepGhcRts :: Bool
esKeepGhcRts = Bool
True
  }

-- | Environment settings which do not embellish the environment

--

-- Note that this also passes through the GHCRTS environment variable.

-- See https://github.com/commercialhaskell/stack/issues/3444

plainEnvSettings :: EnvSettings
plainEnvSettings :: EnvSettings
plainEnvSettings = EnvSettings
  { esIncludeLocals :: Bool
esIncludeLocals = Bool
False
  , esIncludeGhcPackagePath :: Bool
esIncludeGhcPackagePath = Bool
False
  , esStackExe :: Bool
esStackExe = Bool
False
  , esLocaleUtf8 :: Bool
esLocaleUtf8 = Bool
False
  , esKeepGhcRts :: Bool
esKeepGhcRts = Bool
True
  }