@@ -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