git.iko.soy/typeable/stackage2nix
on master help sign in
Assemble path to Stack build plan from repo dir
commit90ac1ace9551c066826f476fac4efbb236b9df58 authorDmitry Bushev <bushevdv@gmail.com> dateTue 20 Jun 2017, 01:48 (9 years ago) parent75cbdd3
2 files changed+30−18
src/Runner.hs+17−11 src/Runner/Cli.hs+13−7
src/Runner.hs+17−11
@@ -6,6 +6,7 @@ import Distribution.Nixpkgs.Haskell.FromStack.Package
66import Distribution.Nixpkgs.Haskell.Stack
77import Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting as PP
88import Distribution.Version (Version(..))
9+import System.FilePath as Path
910import Options.Applicative
1011import Runner.Cli
1112import Stack.Config
@@ -20,26 +21,28 @@ import qualified Stackage2nix as S2n
2021run :: IO ()
2122run = do
2223 opts <- execParser pinfo
23− stackYaml <- either fail pure =<< readStackConfig (opts ^. optStackYaml)
24− (buildPlan, packageSetConfig) <- S2n.run $ mkS2nOptions opts
24+ stackConf <- either fail pure =<< readStackConfig (opts ^. optStackYaml)
25+ let
26+ s2nOpts = mkS2nOptions stackConf opts
27+ (buildPlan, packageSetConfig) <- S2n.run s2nOpts
2528 -- generate haskell packages override
2629 let
2730 pkgConfig = mkPackageConfig (opts ^. optPlatform) (opts ^. optCompilerId)
2831 overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
2932 packages <- traverse (packageDerivation pkgConfig (opts ^. optHackageDb))
30− $ stackYaml ^. scPackages
33+ $ stackConf ^. scPackages
3134 let
3235 out = PP.overrideHaskellPackages overrideConfig packages
3336 writeFile (opts ^. optOutFile) (show out)
3437 -- generate stackage packages
35− allNodes <- traverse (uncurry $ buildNodeM packageSetConfig)
38+ nodes <- traverse (uncurry $ buildNodeM packageSetConfig)
3639 $ Map.toList (bpPackages buildPlan)
37− let nodes = reachableDependencies (mkNode <$> packages) allNodes
40+ -- let nodes = reachableDependencies (mkNode <$> packages) allNodes
3841 withFile (opts ^. optStackageOutPackages) WriteMode $ \h -> do
39− hPutStrLn h ("# Generated by stack2nix from " ++ opts ^. optStackageBuildPlan)
42+ hPutStrLn h ("# Generated by stack2nix from " ++ S2n.optBuildPlanFile s2nOpts)
4043 hPutStrLn h $ render $ pPrintOutPackages (nodeDerivation <$> nodes)
4144 withFile (opts ^. optStackageOutConfig) WriteMode $ \h -> do
42− hPutStrLn h ("# Generated by stack2nix from " ++ opts ^. optStackageBuildPlan)
45+ hPutStrLn h ("# Generated by stack2nix from " ++ S2n.optBuildPlanFile s2nOpts)
4346 hPutStrLn h $ render $ pPrintOutConfig (bpSystemInfo buildPlan) nodes
4447 putStrLn $ "Derivation was written to " ++ opts ^. optOutFile
4548
@@ -49,10 +52,13 @@ mkOverrideConfig opts ghcVersion = OverrideConfig
4952 , _ocStackagePackages = opts ^. optStackageOutPackages
5053 , _ocStackageConfig = opts ^. optStackageOutConfig }
5154
52−mkS2nOptions :: Options -> S2n.Options
53−mkS2nOptions opts = S2n.Options
54− { S2n.optBuildPlanFile = opts ^. optStackageBuildPlan
55− , S2n.optAllCabalHashes = opts ^. optAllCabalHashes
55+mkS2nOptions :: StackConfig -> Options -> S2n.Options
56+mkS2nOptions conf opts = S2n.Options
57+ { S2n.optBuildPlanFile =
58+ (opts ^. optLtsHaskellPath) Path.</>
59+ (conf ^. scResolver . to unStackResolver) Path.<.>
60+ ".yaml"
61+ , S2n.optAllCabalHashes = opts ^. optAllCabalHashesPath
5662 , S2n.optNixpkgsRepository = opts ^. optNixpkgsRepository
5763 , S2n.optNixpkgsMap = Nothing
5864 , S2n.optOutPackages = opts ^. optStackageOutPackages
src/Runner/Cli.hs+13−7
@@ -19,8 +19,8 @@ data Options = Options
1919 { _optOutFile :: !FilePath
2020 , _optHackageDb :: !(Maybe HackageDb)
2121 , _optNixpkgsRepository :: !FilePath
22− , _optStackageBuildPlan :: !FilePath
23− , _optAllCabalHashes :: !FilePath
22+ , _optAllCabalHashesPath :: !FilePath
23+ , _optLtsHaskellPath :: !FilePath
2424 , _optStackageOutPackages :: !FilePath
2525 , _optStackageOutConfig :: !FilePath
2626 , _optCompilerId :: !CompilerId
@@ -35,8 +35,8 @@ options = Options
3535 <$> outFile
3636 <*> optional hackageDb
3737 <*> nixpkgsRepository
38− <*> stackageBuildPlan
39− <*> allCabalHashes
38+ <*> allCabalHashesPath
39+ <*> ltsHaskellPath
4040 <*> stackageOutPackages
4141 <*> stackageOutConfig
4242 <*> compilerId
@@ -72,11 +72,17 @@ stackageBuildPlan = option str
7272 <> metavar "STACKAGE_BUILD_PLAN"
7373 <> help "stackage build plan (YAML)" )
7474
75−allCabalHashes :: Parser FilePath
76−allCabalHashes = option str
75+allCabalHashesPath :: Parser FilePath
76+allCabalHashesPath = option str
7777 ( long "all-cabal-hashes"
7878 <> metavar "ALL_CABAL_HASHES"
79− <> help "path to all-cabal-hashes repository" )
79+ <> help "path to commercialhaskell/all-cabal-hashes repository" )
80+
81+ltsHaskellPath :: Parser FilePath
82+ltsHaskellPath = option str
83+ ( long "lts-haskell"
84+ <> metavar "LTS_HASKELL_DIR"
85+ <> help "path to fpco/lts-haskell repository" )
8086
8187stackResolver :: Parser StackResolver
8288stackResolver = StackResolver <$>