{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE OverloadedStrings #-}
module Stack.Types.Nix
( NixOpts (..)
, NixOptsMonoid (..)
, nixAddGCRootsArgName
, nixEnableArgName
, nixInitFileArgName
, nixPackagesArgName
, nixPathArgName
, nixPureShellArgName
, nixShellOptsArgName
) where
import Data.Aeson.Types ( FromJSON (..) )
import Data.Aeson.WarningParser
( WithJSONWarnings, (..:?), withObjectWarnings )
import Generics.Deriving.Monoid ( mappenddefault, memptydefault )
import Stack.Prelude
data NixOpts = NixOpts
{ NixOpts -> Bool
enable :: !Bool
, NixOpts -> Bool
pureShell :: !Bool
, NixOpts -> [Text]
packages :: ![Text]
, NixOpts -> Maybe FilePath
initFile :: !(Maybe FilePath)
, NixOpts -> [Text]
shellOptions :: ![Text]
, NixOpts -> Bool
addGCRoots :: !Bool
}
deriving Int -> NixOpts -> ShowS
[NixOpts] -> ShowS
NixOpts -> FilePath
(Int -> NixOpts -> ShowS)
-> (NixOpts -> FilePath) -> ([NixOpts] -> ShowS) -> Show NixOpts
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NixOpts -> ShowS
showsPrec :: Int -> NixOpts -> ShowS
$cshow :: NixOpts -> FilePath
show :: NixOpts -> FilePath
$cshowList :: [NixOpts] -> ShowS
showList :: [NixOpts] -> ShowS
Show
data NixOptsMonoid = NixOptsMonoid
{ NixOptsMonoid -> First Bool
enable :: !(First Bool)
, NixOptsMonoid -> First Bool
pureShell :: !(First Bool)
, NixOptsMonoid -> First [Text]
packages :: !(First [Text])
, NixOptsMonoid -> First FilePath
initFile :: !(First FilePath)
, NixOptsMonoid -> First [Text]
shellOptions :: !(First [Text])
, NixOptsMonoid -> First [Text]
path :: !(First [Text])
, NixOptsMonoid -> FirstFalse
addGCRoots :: !FirstFalse
}
deriving (NixOptsMonoid -> NixOptsMonoid -> Bool
(NixOptsMonoid -> NixOptsMonoid -> Bool)
-> (NixOptsMonoid -> NixOptsMonoid -> Bool) -> Eq NixOptsMonoid
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NixOptsMonoid -> NixOptsMonoid -> Bool
== :: NixOptsMonoid -> NixOptsMonoid -> Bool
$c/= :: NixOptsMonoid -> NixOptsMonoid -> Bool
/= :: NixOptsMonoid -> NixOptsMonoid -> Bool
Eq, (forall x. NixOptsMonoid -> Rep NixOptsMonoid x)
-> (forall x. Rep NixOptsMonoid x -> NixOptsMonoid)
-> Generic NixOptsMonoid
forall x. Rep NixOptsMonoid x -> NixOptsMonoid
forall x. NixOptsMonoid -> Rep NixOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NixOptsMonoid -> Rep NixOptsMonoid x
from :: forall x. NixOptsMonoid -> Rep NixOptsMonoid x
$cto :: forall x. Rep NixOptsMonoid x -> NixOptsMonoid
to :: forall x. Rep NixOptsMonoid x -> NixOptsMonoid
Generic, Int -> NixOptsMonoid -> ShowS
[NixOptsMonoid] -> ShowS
NixOptsMonoid -> FilePath
(Int -> NixOptsMonoid -> ShowS)
-> (NixOptsMonoid -> FilePath)
-> ([NixOptsMonoid] -> ShowS)
-> Show NixOptsMonoid
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NixOptsMonoid -> ShowS
showsPrec :: Int -> NixOptsMonoid -> ShowS
$cshow :: NixOptsMonoid -> FilePath
show :: NixOptsMonoid -> FilePath
$cshowList :: [NixOptsMonoid] -> ShowS
showList :: [NixOptsMonoid] -> ShowS
Show)
instance FromJSON (WithJSONWarnings NixOptsMonoid) where
parseJSON :: Value -> Parser (WithJSONWarnings NixOptsMonoid)
parseJSON = FilePath
-> (Object -> WarningParser NixOptsMonoid)
-> Value
-> Parser (WithJSONWarnings NixOptsMonoid)
forall a.
FilePath
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings FilePath
"NixOptsMonoid" ((Object -> WarningParser NixOptsMonoid)
-> Value -> Parser (WithJSONWarnings NixOptsMonoid))
-> (Object -> WarningParser NixOptsMonoid)
-> Value
-> Parser (WithJSONWarnings NixOptsMonoid)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
First Bool
enable <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixEnableArgName
First Bool
pureShell <- Maybe Bool -> First Bool
forall a. Maybe a -> First a
First (Maybe Bool -> First Bool)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser (First Bool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixPureShellArgName
First [Text]
packages <- Maybe [Text] -> First [Text]
forall a. Maybe a -> First a
First (Maybe [Text] -> First [Text])
-> WriterT WarningParserMonoid Parser (Maybe [Text])
-> WriterT WarningParserMonoid Parser (First [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixPackagesArgName
First FilePath
initFile <- Maybe FilePath -> First FilePath
forall a. Maybe a -> First a
First (Maybe FilePath -> First FilePath)
-> WriterT WarningParserMonoid Parser (Maybe FilePath)
-> WriterT WarningParserMonoid Parser (First FilePath)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object
-> Text -> WriterT WarningParserMonoid Parser (Maybe FilePath)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixInitFileArgName
First [Text]
shellOptions <- Maybe [Text] -> First [Text]
forall a. Maybe a -> First a
First (Maybe [Text] -> First [Text])
-> WriterT WarningParserMonoid Parser (Maybe [Text])
-> WriterT WarningParserMonoid Parser (First [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixShellOptsArgName
First [Text]
path <- Maybe [Text] -> First [Text]
forall a. Maybe a -> First a
First (Maybe [Text] -> First [Text])
-> WriterT WarningParserMonoid Parser (Maybe [Text])
-> WriterT WarningParserMonoid Parser (First [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixPathArgName
FirstFalse
addGCRoots <- Maybe Bool -> FirstFalse
FirstFalse (Maybe Bool -> FirstFalse)
-> WriterT WarningParserMonoid Parser (Maybe Bool)
-> WriterT WarningParserMonoid Parser FirstFalse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Text -> WriterT WarningParserMonoid Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixAddGCRootsArgName
NixOptsMonoid -> WarningParser NixOptsMonoid
forall a. a -> WriterT WarningParserMonoid Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NixOptsMonoid
{ First Bool
$sel:enable:NixOptsMonoid :: First Bool
enable :: First Bool
enable
, First Bool
$sel:pureShell:NixOptsMonoid :: First Bool
pureShell :: First Bool
pureShell
, First [Text]
$sel:packages:NixOptsMonoid :: First [Text]
packages :: First [Text]
packages
, First FilePath
$sel:initFile:NixOptsMonoid :: First FilePath
initFile :: First FilePath
initFile
, First [Text]
$sel:shellOptions:NixOptsMonoid :: First [Text]
shellOptions :: First [Text]
shellOptions
, First [Text]
$sel:path:NixOptsMonoid :: First [Text]
path :: First [Text]
path
, FirstFalse
$sel:addGCRoots:NixOptsMonoid :: FirstFalse
addGCRoots :: FirstFalse
addGCRoots
}
instance Semigroup NixOptsMonoid where
<> :: NixOptsMonoid -> NixOptsMonoid -> NixOptsMonoid
(<>) = NixOptsMonoid -> NixOptsMonoid -> NixOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault
instance Monoid NixOptsMonoid where
mempty :: NixOptsMonoid
mempty = NixOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
mappend :: NixOptsMonoid -> NixOptsMonoid -> NixOptsMonoid
mappend = NixOptsMonoid -> NixOptsMonoid -> NixOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)
nixEnableArgName :: Text
nixEnableArgName :: Text
nixEnableArgName = Text
"enable"
nixPureShellArgName :: Text
nixPureShellArgName :: Text
nixPureShellArgName = Text
"pure"
nixPackagesArgName :: Text
nixPackagesArgName :: Text
nixPackagesArgName = Text
"packages"
nixInitFileArgName :: Text
nixInitFileArgName :: Text
nixInitFileArgName = Text
"shell-file"
nixShellOptsArgName :: Text
nixShellOptsArgName :: Text
nixShellOptsArgName = Text
"nix-shell-options"
nixPathArgName :: Text
nixPathArgName :: Text
nixPathArgName = Text
"path"
nixAddGCRootsArgName :: Text
nixAddGCRootsArgName :: Text
nixAddGCRootsArgName = Text
"add-gc-roots"