@@ -1,5 +1,8 @@
1−module Cli where
1+{-# LANGUAGE TemplateHaskell #-}
22
3+module Runner.Cli where
4+
5+import Control.Lens
36import Data.Monoid ( (<>) )
47import Data.Text as T
58import qualified Distribution.Compat.ReadP as P
@@ -7,25 +10,37 @@ import Distribution.Compiler as Compiler
710import Distribution.Nixpkgs.Haskell.Stack
811import Distribution.System as System
912import qualified Distribution.Text as Text
10−import Options.Applicative
13+import Options.Applicative as Opts
1114import Stack.Config
1215import Stack.Types
1316
1417
18+newtype StackagePackages = StackagePackages { fromStackagePackages :: FilePath }
19+ deriving (Show)
20+
21+makePrisms ''StackagePackages
22+
23+newtype StackageConfig = StackageConfig { fromStackageConfig :: FilePath }
24+ deriving (Show)
25+
26+makePrisms ''StackageConfig
27+
1528data Options = Options
16− { optStackResolver :: Maybe StackResolver
17− , optHackageDb :: Maybe HackageDb
18− , optFlags :: [CabalFlag]
19− , optCompilerId :: CompilerId
20− , optPlatform :: Platform
21− , optStackYaml :: FilePath
29+ { _optHackageDb :: Maybe HackageDb
30+ , _optStackagePackages :: StackagePackages
31+ , _optStackageConfig :: StackageConfig
32+ , _optCompilerId :: CompilerId
33+ , _optPlatform :: Platform
34+ , _optStackYaml :: FilePath
2235 } deriving (Show)
2336
37+makeLenses ''Options
38+
2439options :: Parser Options
2540options = Options
26− <$> optional stackResolver
27− <*> optional hackageDb
28− <*> many cabalFlag
41+ <$> optional hackageDb
42+ <*> stackagePackages
43+ <*> stackageConfig
2944 <*> compilerId
3045 <*> platform
3146 <*> stackYamlArg
@@ -44,8 +59,22 @@ stackResolver = StackResolver <$>
4459 <> metavar "RESOLVER"
4560 <> help "override stack resolver" )
4661
62+stackagePackages :: Parser StackagePackages
63+stackagePackages = StackagePackages <$>
64+ option str
65+ ( long "nix-stackage-packages"
66+ <> metavar "STACKAGE_PACKAGES"
67+ <> help "path to packages file generated by 'stackage2nix'" )
68+
69+stackageConfig :: Parser StackageConfig
70+stackageConfig = StackageConfig <$>
71+ option str
72+ ( long "nix-stackage-config"
73+ <> metavar "STACKAGE_CONFIG"
74+ <> help "path to packages config file generated by 'stackage2nix'" )
75+
4776stackYamlArg :: Parser FilePath
48−stackYamlArg = argument str
77+stackYamlArg = Opts.argument str
4978 ( metavar "STACK_YAML"
5079 <> value "stack.yaml" )
5180