    -- | Maintainer: Sean Whitton <spwhitton@spwhitton.name>

    module Propellor.Property.Timezone where

    import Propellor.Base
    import qualified Propellor.Property.Apt as Apt
    import qualified Propellor.Property.File as File

    -- | A timezone from /usr/share/zoneinfo
    type Timezone = String

    -- | Sets the system's timezone
    configured :: Timezone -> Property DebianLike
    configured :: Timezone -> Property DebianLike
    configured zone :: Timezone
    zone = Timezone -> [Timezone] -> Property UnixLike
    File.hasContent "/etc/timezone" [Timezone
    zone]
    	Property UnixLike
    -> Property DebianLike
    -> CombinedType (Property UnixLike) (Property DebianLike)
    forall x y. Combines x y => x -> y -> CombinedType x y
    `onChange` Property DebianLike
    update
    	Property DebianLike -> Timezone -> Property DebianLike
    forall p. IsProp p => p -> Timezone -> p
    `describe` (Timezone
    zone Timezone -> Timezone -> Timezone
    forall a. [a] -> [a] -> [a]
    ++ " timezone configured")
      where
    	update :: CombinedType (Property DebianLike) (Property UnixLike)
    update = Timezone -> [(Timezone, Timezone, Timezone)] -> Property DebianLike
    Apt.reConfigure "tzdata" [(Timezone, Timezone, Timezone)]
    forall a. Monoid a => a
    mempty
    		-- work around a bug in recent tzdata.  See
    		-- https://bugs.launchpad.net/ubuntu/+source/tzdata/+bug/1554806/
    		Property DebianLike
    -> Property UnixLike
    -> CombinedType (Property DebianLike) (Property UnixLike)
    forall x y. Combines x y => x -> y -> CombinedType x y
    `requires` Timezone -> Property UnixLike
    File.notPresent "/etc/localtime"