{-# LANGUAGE DeriveDataTypeable #-} module Propellor.Types.Chroot where import Propellor.Types import Propellor.Types.Empty import Propellor.Types.Info import qualified Data.Semigroup as Sem import qualified Data.Map as M import Data.Monoid import Prelude data ChrootInfo = ChrootInfo { ChrootInfo -> Map FilePath Host _chroots :: M.Map FilePath Host , ChrootInfo -> ChrootCfg _chrootCfg :: ChrootCfg } deriving (Int -> ChrootInfo -> ShowS [ChrootInfo] -> ShowS ChrootInfo -> FilePath forall a. (Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a showList :: [ChrootInfo] -> ShowS $cshowList :: [ChrootInfo] -> ShowS show :: ChrootInfo -> FilePath $cshow :: ChrootInfo -> FilePath showsPrec :: Int -> ChrootInfo -> ShowS $cshowsPrec :: Int -> ChrootInfo -> ShowS Show, Typeable) instance IsInfo ChrootInfo where propagateInfo :: ChrootInfo -> PropagateInfo propagateInfo ChrootInfo _ = Bool -> PropagateInfo PropagateInfo Bool False instance Sem.Semigroup ChrootInfo where ChrootInfo old <> :: ChrootInfo -> ChrootInfo -> ChrootInfo <> ChrootInfo new = ChrootInfo { _chroots :: Map FilePath Host _chroots = forall k a. Ord k => Map k a -> Map k a -> Map k a M.union (ChrootInfo -> Map FilePath Host _chroots ChrootInfo old) (ChrootInfo -> Map FilePath Host _chroots ChrootInfo new) , _chrootCfg :: ChrootCfg _chrootCfg = ChrootInfo -> ChrootCfg _chrootCfg ChrootInfo old forall a. Semigroup a => a -> a -> a <> ChrootInfo -> ChrootCfg _chrootCfg ChrootInfo new } instance Monoid ChrootInfo where mempty :: ChrootInfo mempty = Map FilePath Host -> ChrootCfg -> ChrootInfo ChrootInfo forall a. Monoid a => a mempty forall a. Monoid a => a mempty mappend :: ChrootInfo -> ChrootInfo -> ChrootInfo mappend = forall a. Semigroup a => a -> a -> a (Sem.<>) instance Empty ChrootInfo where isEmpty :: ChrootInfo -> Bool isEmpty ChrootInfo i = forall (t :: * -> *). Foldable t => t Bool -> Bool and [ forall t. Empty t => t -> Bool isEmpty (ChrootInfo -> Map FilePath Host _chroots ChrootInfo i) , forall t. Empty t => t -> Bool isEmpty (ChrootInfo -> ChrootCfg _chrootCfg ChrootInfo i) ] data ChrootCfg = NoChrootCfg | SystemdNspawnCfg [(String, Bool)] deriving (Int -> ChrootCfg -> ShowS [ChrootCfg] -> ShowS ChrootCfg -> FilePath forall a. (Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a showList :: [ChrootCfg] -> ShowS $cshowList :: [ChrootCfg] -> ShowS show :: ChrootCfg -> FilePath $cshow :: ChrootCfg -> FilePath showsPrec :: Int -> ChrootCfg -> ShowS $cshowsPrec :: Int -> ChrootCfg -> ShowS Show, ChrootCfg -> ChrootCfg -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: ChrootCfg -> ChrootCfg -> Bool $c/= :: ChrootCfg -> ChrootCfg -> Bool == :: ChrootCfg -> ChrootCfg -> Bool $c== :: ChrootCfg -> ChrootCfg -> Bool Eq) instance Sem.Semigroup ChrootCfg where ChrootCfg v <> :: ChrootCfg -> ChrootCfg -> ChrootCfg <> ChrootCfg NoChrootCfg = ChrootCfg v ChrootCfg NoChrootCfg <> ChrootCfg v = ChrootCfg v SystemdNspawnCfg [(FilePath, Bool)] l1 <> SystemdNspawnCfg [(FilePath, Bool)] l2 = [(FilePath, Bool)] -> ChrootCfg SystemdNspawnCfg ([(FilePath, Bool)] l1 forall a. Semigroup a => a -> a -> a <> [(FilePath, Bool)] l2) instance Monoid ChrootCfg where mempty :: ChrootCfg mempty = ChrootCfg NoChrootCfg mappend :: ChrootCfg -> ChrootCfg -> ChrootCfg mappend = forall a. Semigroup a => a -> a -> a (Sem.<>) instance Empty ChrootCfg where isEmpty :: ChrootCfg -> Bool isEmpty ChrootCfg c= ChrootCfg c forall a. Eq a => a -> a -> Bool == ChrootCfg NoChrootCfg