{-# LANGUAGE DeriveAnyClass #-}

module Hercules.Agent.WorkerProtocol.Command.Eval where

import Data.Binary
import qualified Hercules.API.Agent.Evaluate.EvaluateTask as EvaluateTask
import Hercules.API.Agent.Evaluate.ImmutableGitInput (ImmutableGitInput)
import Hercules.Agent.NixFile.GitSource (GitSource)
import Hercules.Agent.WorkerProtocol.Event (ViaJSON)
import Hercules.Agent.WorkerProtocol.LogSettings
import Hercules.Agent.WorkerProtocol.Orphans ()
import Protolude

data Eval = Eval
  { Eval -> FilePath
cwd :: FilePath,
    Eval -> Text
file :: Text,
    Eval -> Map Text Arg
autoArguments :: Map Text Arg,
    -- | NB currently the options will leak from one evaluation to
    --   the next if you're running them in the same worker!
    --   (as of now, we use one worker process per evaluation)
    Eval -> [(Text, Text)]
extraNixOptions :: [(Text, Text)],
    Eval -> ViaJSON GitSource
gitSource :: ViaJSON GitSource,
    Eval -> Maybe (ViaJSON ImmutableGitInput)
srcInput :: Maybe (ViaJSON ImmutableGitInput),
    Eval -> Text
apiBaseUrl :: Text,
    Eval -> LogSettings
logSettings :: LogSettings,
    Eval -> ViaJSON Selector
selector :: ViaJSON EvaluateTask.Selector,
    Eval -> Bool
isFlakeJob :: Bool,
    Eval -> Maybe (Map Text ())
ciSystems :: Maybe (Map Text ()),
    Eval -> Bool
allowInsecureBuiltinFetchers :: Bool,
    Eval -> [ByteString]
allowedPaths :: [ByteString]
  }
  deriving ((forall x. Eval -> Rep Eval x)
-> (forall x. Rep Eval x -> Eval) -> Generic Eval
forall x. Rep Eval x -> Eval
forall x. Eval -> Rep Eval x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Eval x -> Eval
$cfrom :: forall x. Eval -> Rep Eval x
Generic, Get Eval
[Eval] -> Put
Eval -> Put
(Eval -> Put) -> Get Eval -> ([Eval] -> Put) -> Binary Eval
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [Eval] -> Put
$cputList :: [Eval] -> Put
get :: Get Eval
$cget :: Get Eval
put :: Eval -> Put
$cput :: Eval -> Put
Binary, Int -> Eval -> ShowS
[Eval] -> ShowS
Eval -> FilePath
(Int -> Eval -> ShowS)
-> (Eval -> FilePath) -> ([Eval] -> ShowS) -> Show Eval
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Eval] -> ShowS
$cshowList :: [Eval] -> ShowS
show :: Eval -> FilePath
$cshow :: Eval -> FilePath
showsPrec :: Int -> Eval -> ShowS
$cshowsPrec :: Int -> Eval -> ShowS
Show, Eval -> Eval -> Bool
(Eval -> Eval -> Bool) -> (Eval -> Eval -> Bool) -> Eq Eval
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Eval -> Eval -> Bool
$c/= :: Eval -> Eval -> Bool
== :: Eval -> Eval -> Bool
$c== :: Eval -> Eval -> Bool
Eq)

data Arg
  = LiteralArg ByteString
  | ExprArg ByteString
  deriving ((forall x. Arg -> Rep Arg x)
-> (forall x. Rep Arg x -> Arg) -> Generic Arg
forall x. Rep Arg x -> Arg
forall x. Arg -> Rep Arg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Arg x -> Arg
$cfrom :: forall x. Arg -> Rep Arg x
Generic, Get Arg
[Arg] -> Put
Arg -> Put
(Arg -> Put) -> Get Arg -> ([Arg] -> Put) -> Binary Arg
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [Arg] -> Put
$cputList :: [Arg] -> Put
get :: Get Arg
$cget :: Get Arg
put :: Arg -> Put
$cput :: Arg -> Put
Binary, Int -> Arg -> ShowS
[Arg] -> ShowS
Arg -> FilePath
(Int -> Arg -> ShowS)
-> (Arg -> FilePath) -> ([Arg] -> ShowS) -> Show Arg
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Arg] -> ShowS
$cshowList :: [Arg] -> ShowS
show :: Arg -> FilePath
$cshow :: Arg -> FilePath
showsPrec :: Int -> Arg -> ShowS
$cshowsPrec :: Int -> Arg -> ShowS
Show, Arg -> Arg -> Bool
(Arg -> Arg -> Bool) -> (Arg -> Arg -> Bool) -> Eq Arg
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Arg -> Arg -> Bool
$c/= :: Arg -> Arg -> Bool
== :: Arg -> Arg -> Bool
$c== :: Arg -> Arg -> Bool
Eq)