{-# LANGUAGE NoImplicitPrelude #-} module Stack.Options.NixParser where import qualified Data.Text as T import Options.Applicative import Options.Applicative.Args import Options.Applicative.Builder.Extra import Stack.Nix import Stack.Options.Utils import Stack.Prelude import Stack.Types.Nix nixOptsParser :: Bool -> Parser NixOptsMonoid nixOptsParser :: Bool -> Parser NixOptsMonoid nixOptsParser Bool hide0 = NixOptsMonoid -> NixOptsMonoid overrideActivation (NixOptsMonoid -> NixOptsMonoid) -> Parser NixOptsMonoid -> Parser NixOptsMonoid forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (First Bool -> First Bool -> First [Text] -> First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid NixOptsMonoid (First Bool -> First Bool -> First [Text] -> First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) -> Parser (First Bool) -> Parser (First Bool -> First [Text] -> First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> FilePath -> FilePath -> Mod FlagFields (Maybe Bool) -> Parser (First Bool) firstBoolFlagsNoDefault FilePath nixCmdName FilePath "use of a Nix-shell. Implies 'system-ghc: true'" Mod FlagFields (Maybe Bool) forall (f :: * -> *) a. Mod f a hide Parser (First Bool -> First [Text] -> First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) -> Parser (First Bool) -> Parser (First [Text] -> First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> FilePath -> FilePath -> Mod FlagFields (Maybe Bool) -> Parser (First Bool) firstBoolFlagsNoDefault FilePath "nix-pure" FilePath "use of a pure Nix-shell. Implies '--nix' and 'system-ghc: true'" Mod FlagFields (Maybe Bool) forall (f :: * -> *) a. Mod f a hide Parser (First [Text] -> First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) -> Parser (First [Text]) -> Parser (First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser [Text] -> Parser (First [Text]) forall (f :: * -> *) a. Alternative f => f a -> f (First a) optionalFirst (Mod OptionFields [FilePath] -> Parser [Text] textArgsOption (FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "nix-packages" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "NAMES" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "List of packages that should be available in the nix-shell (space separated)" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> Mod OptionFields [FilePath] forall (f :: * -> *) a. Mod f a hide)) Parser (First FilePath -> First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) -> Parser (First FilePath) -> Parser (First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser FilePath -> Parser (First FilePath) forall (f :: * -> *) a. Alternative f => f a -> f (First a) optionalFirst (ReadM FilePath -> Mod OptionFields FilePath -> Parser FilePath forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM FilePath forall s. IsString s => ReadM s str (FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "nix-shell-file" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "FILE" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer ([FilePath] -> Completer fileExtCompleter [FilePath ".nix"]) Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Nix file to be used to launch a nix-shell (for regular Nix users)" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Mod OptionFields FilePath forall (f :: * -> *) a. Mod f a hide)) Parser (First [Text] -> First [Text] -> FirstFalse -> NixOptsMonoid) -> Parser (First [Text]) -> Parser (First [Text] -> FirstFalse -> NixOptsMonoid) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser [Text] -> Parser (First [Text]) forall (f :: * -> *) a. Alternative f => f a -> f (First a) optionalFirst (Mod OptionFields [FilePath] -> Parser [Text] textArgsOption (FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "nix-shell-options" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "OPTIONS" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Additional options passed to nix-shell" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> Mod OptionFields [FilePath] forall (f :: * -> *) a. Mod f a hide)) Parser (First [Text] -> FirstFalse -> NixOptsMonoid) -> Parser (First [Text]) -> Parser (FirstFalse -> NixOptsMonoid) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser [Text] -> Parser (First [Text]) forall (f :: * -> *) a. Alternative f => f a -> f (First a) optionalFirst (Mod OptionFields [FilePath] -> Parser [Text] textArgsOption (FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "nix-path" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "PATH_OPTIONS" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields [FilePath] forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Additional options to override NIX_PATH parts (notably 'nixpkgs')" Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] -> Mod OptionFields [FilePath] forall a. Semigroup a => a -> a -> a <> Mod OptionFields [FilePath] forall (f :: * -> *) a. Mod f a hide)) Parser (FirstFalse -> NixOptsMonoid) -> Parser FirstFalse -> Parser NixOptsMonoid forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> FilePath -> FilePath -> Mod FlagFields FirstFalse -> Parser FirstFalse firstBoolFlagsFalse FilePath "nix-add-gc-roots" FilePath "addition of packages to the nix GC roots so nix-collect-garbage doesn't remove them" Mod FlagFields FirstFalse forall (f :: * -> *) a. Mod f a hide ) where hide :: Mod f a hide = Bool -> Mod f a forall (f :: * -> *) a. Bool -> Mod f a hideMods Bool hide0 overrideActivation :: NixOptsMonoid -> NixOptsMonoid overrideActivation NixOptsMonoid m = if Bool -> First Bool -> Bool forall a. a -> First a -> a fromFirst Bool False (NixOptsMonoid -> First Bool nixMonoidPureShell NixOptsMonoid m) then NixOptsMonoid m { nixMonoidEnable :: First Bool nixMonoidEnable = (Maybe Bool -> First Bool forall a. Maybe a -> First a First (Maybe Bool -> First Bool) -> (First Bool -> Maybe Bool) -> First Bool -> First Bool forall b c a. (b -> c) -> (a -> b) -> a -> c . Bool -> Maybe Bool forall a. a -> Maybe a Just (Bool -> Maybe Bool) -> (First Bool -> Bool) -> First Bool -> Maybe Bool forall b c a. (b -> c) -> (a -> b) -> a -> c . Bool -> First Bool -> Bool forall a. a -> First a -> a fromFirst Bool True) (NixOptsMonoid -> First Bool nixMonoidEnable NixOptsMonoid m) } else NixOptsMonoid m textArgsOption :: Mod OptionFields [FilePath] -> Parser [Text] textArgsOption = ([FilePath] -> [Text]) -> Parser [FilePath] -> Parser [Text] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap ((FilePath -> Text) -> [FilePath] -> [Text] forall a b. (a -> b) -> [a] -> [b] map FilePath -> Text T.pack) (Parser [FilePath] -> Parser [Text]) -> (Mod OptionFields [FilePath] -> Parser [FilePath]) -> Mod OptionFields [FilePath] -> Parser [Text] forall b c a. (b -> c) -> (a -> b) -> a -> c . Mod OptionFields [FilePath] -> Parser [FilePath] argsOption