git.iko.soy/typeable/stackage2nix
on master help sign in
Show default values of cli options
c2c5d44Dmitry Bushev
src/Runner.hs+10−12
@@ -16,18 +16,8 @@ run :: IO ()
16run = do
16run = do
17 opts <- execParser pinfo
17 opts <- execParser pinfo
18 stackYaml <- either fail pure =<< readStackConfig (opts ^. optStackYaml)
18 stackYaml <- either fail pure =<< readStackConfig (opts ^. optStackYaml)
19−
20 -- generate stackage packages
19 -- generate stackage packages
21− let
22− s2nOptions = S2n.Options
23− { S2n.optBuildPlanFile = opts ^. optStackageBuildPlan
24− , S2n.optAllCabalHashes = opts ^. optAllCabalHashes
25− , S2n.optNixpkgsRepository = opts ^. optNixpkgsRepository
26− , S2n.optNixpkgsMap = Nothing
27− , S2n.optOutPackages = opts ^. optStackageOutPackages
28− , S2n.optOutConfig = opts ^. optStackageOutConfig }
29− buildPlan <- S2n.run s2nOptions
20+ buildPlan <- S2n.run $ mkS2nOptions opts
30−
31 -- generate haskell packages override
21 -- generate haskell packages override
32 let
22 let
33 pkgConfig = mkPackageConfig (opts ^. optPlatform) (opts ^. optCompilerId)
23 pkgConfig = mkPackageConfig (opts ^. optPlatform) (opts ^. optCompilerId)
@@ -36,7 +26,6 @@ run = do
36 $ stackYaml ^. scPackages
26 $ stackYaml ^. scPackages
37 let
27 let
38 out = PP.overrideHaskellPackages overrideConfig packages
28 out = PP.overrideHaskellPackages overrideConfig packages
39−
40 writeFile (opts ^. optOutFile) (show out)
29 writeFile (opts ^. optOutFile) (show out)
41 putStrLn $ "\nDerivation was written to " ++ opts ^. optOutFile
30 putStrLn $ "\nDerivation was written to " ++ opts ^. optOutFile
42
31
@@ -45,3 +34,12 @@ mkOverrideConfig opts ghcVersion = OverrideConfig
45 { _ocGhc = ghcVersion
34 { _ocGhc = ghcVersion
46 , _ocStackagePackages = opts ^. optStackageOutPackages
35 , _ocStackagePackages = opts ^. optStackageOutPackages
47 , _ocStackageConfig = opts ^. optStackageOutConfig }
36 , _ocStackageConfig = opts ^. optStackageOutConfig }
37+
38+mkS2nOptions :: Options -> S2n.Options
39+mkS2nOptions opts = S2n.Options
40+ { S2n.optBuildPlanFile = opts ^. optStackageBuildPlan
41+ , S2n.optAllCabalHashes = opts ^. optAllCabalHashes
42+ , S2n.optNixpkgsRepository = opts ^. optNixpkgsRepository
43+ , S2n.optNixpkgsMap = Nothing
44+ , S2n.optOutPackages = opts ^. optStackageOutPackages
45+ , S2n.optOutConfig = opts ^. optStackageOutConfig }
src/Runner/Cli.hs+7−4
@@ -54,8 +54,9 @@ outFile :: Parser FilePath
54outFile = option str
54outFile = option str
55 ( long "nix-out-file"
55 ( long "nix-out-file"
56 <> metavar "NIX_OUT_FILE"
56 <> metavar "NIX_OUT_FILE"
57− <> help "path where to write output derivation"
57+ <> help "path to output derivation"
58− <> value "default.nix" )
58+ <> value "default.nix"
59+ <> showDefaultWith id )
59
60
60nixpkgsRepository :: Parser FilePath
61nixpkgsRepository :: Parser FilePath
61nixpkgsRepository = option str
62nixpkgsRepository = option str
@@ -89,14 +90,16 @@ stackageOutPackages = option str
89 ( long "nix-stackage-packages"
90 ( long "nix-stackage-packages"
90 <> metavar "STACKAGE_PACKAGES"
91 <> metavar "STACKAGE_PACKAGES"
91 <> help "name of the output file for the package set"
92 <> help "name of the output file for the package set"
92− <> value "configuration-packages.nix" )
93+ <> value "configuration-packages.nix"
94+ <> showDefaultWith id)
93
95
94stackageOutConfig :: Parser FilePath
96stackageOutConfig :: Parser FilePath
95stackageOutConfig = option str
97stackageOutConfig = option str
96 ( long "nix-stackage-config"
98 ( long "nix-stackage-config"
97 <> metavar "STACKAGE_CONFIG"
99 <> metavar "STACKAGE_CONFIG"
98 <> help "name of the output file for the package set configuration"
100 <> help "name of the output file for the package set configuration"
99− <> value "packages.nix" )
101+ <> value "packages.nix"
102+ <> showDefaultWith id)
100
103
101stackYamlArg :: Parser FilePath
104stackYamlArg :: Parser FilePath
102stackYamlArg = Opts.argument str
105stackYamlArg = Opts.argument str