{-# LANGUAGE DeriveAnyClass #-}
module Hercules.API.Agent.Evaluate.EvaluateEvent.DerivationInfo where
import Control.Applicative
import Control.Lens
import qualified Data.Aeson as A
import Data.Aeson.Lens
import Hercules.API.Prelude
type OutputNameText = Text
type DerivationPathText = Text
data DerivationInfo
= DerivationInfo
{ derivationPath :: DerivationPathText,
platform :: Text,
requiredSystemFeatures :: [Text],
inputDerivations :: Map DerivationPathText [OutputNameText],
inputSources :: [DerivationPathText],
outputs :: Map OutputNameText OutputInfo
}
deriving (Generic, Show, Eq, ToJSON, ToSchema)
instance FromJSON DerivationInfo where
parseJSON = A.genericParseJSON A.defaultOptions . fixup
where
fixup :: A.Value -> A.Value
fixup = _Object . at "requiredSystemFeatures" %~ (<|> Just (A.Array mempty))
data OutputInfo
= OutputInfo
{ path :: Text,
isFixed :: Bool
}
deriving (Generic, Show, Eq, ToJSON, FromJSON, ToSchema)