{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Stack.Types.Nix
( NixOpts (..)
, NixOptsMonoid (..)
, nixAddGCRootsArgName
, nixEnableArgName
, nixInitFileArgName
, nixPackagesArgName
, nixPathArgName
, nixPureShellArgName
, nixShellOptsArgName
) where
import Generics.Deriving.Monoid ( mappenddefault, memptydefault )
import Pantry.Internal.AesonExtended
import Stack.Prelude
data NixOpts = NixOpts
{ NixOpts -> Bool
nixEnable :: !Bool
, NixOpts -> Bool
nixPureShell :: !Bool
, NixOpts -> [Text]
nixPackages :: ![Text]
, NixOpts -> Maybe FilePath
nixInitFile :: !(Maybe FilePath)
, NixOpts -> [Text]
nixShellOptions :: ![Text]
, NixOpts -> Bool
nixAddGCRoots :: !Bool
}
deriving (Int -> NixOpts -> ShowS
[NixOpts] -> ShowS
NixOpts -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [NixOpts] -> ShowS
$cshowList :: [NixOpts] -> ShowS
show :: NixOpts -> FilePath
$cshow :: NixOpts -> FilePath
showsPrec :: Int -> NixOpts -> ShowS
$cshowsPrec :: Int -> NixOpts -> ShowS
Show)
data NixOptsMonoid = NixOptsMonoid
{ NixOptsMonoid -> First Bool
nixMonoidEnable :: !(First Bool)
, NixOptsMonoid -> First Bool
nixMonoidPureShell :: !(First Bool)
, NixOptsMonoid -> First [Text]
nixMonoidPackages :: !(First [Text])
, NixOptsMonoid -> First FilePath
nixMonoidInitFile :: !(First FilePath)
, NixOptsMonoid -> First [Text]
nixMonoidShellOptions :: !(First [Text])
, NixOptsMonoid -> First [Text]
nixMonoidPath :: !(First [Text])
, NixOptsMonoid -> FirstFalse
nixMonoidAddGCRoots :: !FirstFalse
}
deriving (NixOptsMonoid -> NixOptsMonoid -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NixOptsMonoid -> NixOptsMonoid -> Bool
$c/= :: NixOptsMonoid -> NixOptsMonoid -> Bool
== :: NixOptsMonoid -> NixOptsMonoid -> Bool
$c== :: NixOptsMonoid -> NixOptsMonoid -> Bool
Eq, 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
$cto :: forall x. Rep NixOptsMonoid x -> NixOptsMonoid
$cfrom :: forall x. NixOptsMonoid -> Rep NixOptsMonoid x
Generic, Int -> NixOptsMonoid -> ShowS
[NixOptsMonoid] -> ShowS
NixOptsMonoid -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [NixOptsMonoid] -> ShowS
$cshowList :: [NixOptsMonoid] -> ShowS
show :: NixOptsMonoid -> FilePath
$cshow :: NixOptsMonoid -> FilePath
showsPrec :: Int -> NixOptsMonoid -> ShowS
$cshowsPrec :: Int -> NixOptsMonoid -> ShowS
Show)
instance FromJSON (WithJSONWarnings NixOptsMonoid) where
parseJSON :: Value -> Parser (WithJSONWarnings NixOptsMonoid)
parseJSON = forall a.
FilePath
-> (Object -> WarningParser a)
-> Value
-> Parser (WithJSONWarnings a)
withObjectWarnings FilePath
"NixOptsMonoid"
( \Object
o -> do
First Bool
nixMonoidEnable <- forall a. Maybe a -> First a
First forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixEnableArgName
First Bool
nixMonoidPureShell <- forall a. Maybe a -> First a
First forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixPureShellArgName
First [Text]
nixMonoidPackages <- forall a. Maybe a -> First a
First forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixPackagesArgName
First FilePath
nixMonoidInitFile <- forall a. Maybe a -> First a
First forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixInitFileArgName
First [Text]
nixMonoidShellOptions <- forall a. Maybe a -> First a
First forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixShellOptsArgName
First [Text]
nixMonoidPath <- forall a. Maybe a -> First a
First forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixPathArgName
FirstFalse
nixMonoidAddGCRoots <- Maybe Bool -> FirstFalse
FirstFalse forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Text -> WarningParser (Maybe a)
..:? Text
nixAddGCRootsArgName
forall (f :: * -> *) a. Applicative f => a -> f a
pure NixOptsMonoid{First Bool
First FilePath
First [Text]
FirstFalse
nixMonoidAddGCRoots :: FirstFalse
nixMonoidPath :: First [Text]
nixMonoidShellOptions :: First [Text]
nixMonoidInitFile :: First FilePath
nixMonoidPackages :: First [Text]
nixMonoidPureShell :: First Bool
nixMonoidEnable :: First Bool
nixMonoidAddGCRoots :: FirstFalse
nixMonoidPath :: First [Text]
nixMonoidShellOptions :: First [Text]
nixMonoidInitFile :: First FilePath
nixMonoidPackages :: First [Text]
nixMonoidPureShell :: First Bool
nixMonoidEnable :: First Bool
..}
)
instance Semigroup NixOptsMonoid where
<> :: NixOptsMonoid -> NixOptsMonoid -> NixOptsMonoid
(<>) = forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault
instance Monoid NixOptsMonoid where
mempty :: NixOptsMonoid
mempty = forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
mappend :: NixOptsMonoid -> NixOptsMonoid -> NixOptsMonoid
mappend = 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"