git.iko.soy/typeable/stackage2nix
on master help sign in
Add --with-stackage flags
commita01f83be0379533e2de896bb72a7893f73270afc authorDmitry Bushev <bushevdv@gmail.com> dateMon 1 Jan 2018, 23:54 (9 years ago) parent558ab8b
2 files changed+23−12
src/Runner.hs+9−5 src/Runner/Cli.hs+14−7
src/Runner.hs+9−5
@@ -1,6 +1,7 @@
11module Runner ( run ) where
22
33import Control.Lens
4+import Control.Monad
45import Data.Foldable as F
56import Data.List as L
67import Distribution.Nixpkgs.Haskell.FromStack
@@ -60,6 +61,7 @@ run = do
6061 stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
6162 $ Map.toAscList (bpPackages buildPlan)
6263 let
64+ generateStackage = opts ^. optWithStackage || opts ^. optWithStackageClosure
6365 -- Nixpkgs generic-builder puts hscolour on path for all libraries
6466 withHscolour pkgs =
6567 let hscolour = F.find ((== "hscolour") . nodeName) stackagePackages
@@ -71,17 +73,19 @@ run = do
7173 -- does: pruning only after generating full set of packages allows
7274 -- us to make sure all those extra dependencies are explicitly
7375 -- listed as well.
74− nodes = case opts ^. optOutPackagesClosure of
76+ nodes = case opts ^. optWithStackageClosure of
7577 True -> Set.toAscList
7678 $ withHscolour
7779 $ flip reachableDependencies stackagePackages
7880 -- Originally reachable nodes are root nodes
7981 $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
8082 False -> stackagePackages
81− writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
82− $ pPrintOutPackages (view nodeDerivation <$> nodes)
83− writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
84− $ pPrintOutConfig (bpSystemInfo buildPlan) nodes
83+ when generateStackage $ do
84+ writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
85+ $ pPrintOutPackages (view nodeDerivation <$> nodes)
86+ writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
87+ $ pPrintOutConfig (bpSystemInfo buildPlan) nodes
88+ -- TODO: generate stackage override
8589 writeOutFile (stackYaml ^. syFilePath) (opts ^. optOutDerivation)
8690 $ PP.overrideHaskellPackages overrideConfig stackConfPackages
8791
src/Runner/Cli.hs+14−7
@@ -30,10 +30,11 @@ data Options = Options
3030 , _optLtsHaskellRepo :: FilePath
3131 , _optOutStackagePackages :: FilePath
3232 , _optOutStackageConfig :: FilePath
33− , _optOutPackagesClosure :: Bool
3433 , _optOutDerivation :: FilePath
3534 , _optDoCheckPackages :: Bool
3635 , _optDoHaddockPackages :: Bool
36+ , _optWithStackage :: Bool
37+ , _optWithStackageClosure :: Bool
3738 , _optHackageDb :: Maybe HackageDb
3839 , _optNixpkgsRepository :: FilePath
3940 , _optCompilerId :: CompilerId
@@ -59,10 +60,11 @@ options = Options
5960 <*> ltsHaskellRepo
6061 <*> outStackagePackages
6162 <*> outStackageConfig
62− <*> outPackagesClosure
6363 <*> outDerivation
6464 <*> doCheckPackages
6565 <*> doHaddockPackages
66+ <*> withStackage
67+ <*> withStackageClosure
6668 <*> optional hackageDb
6769 <*> nixpkgsRepository
6870 <*> compilerId
@@ -113,11 +115,6 @@ outStackageConfig = option str
113115 <> value "configuration-packages.nix"
114116 <> showDefaultWith id)
115117
116−outPackagesClosure :: Parser Bool
117−outPackagesClosure = flag True False
118− ( long "no-packages-closure"
119− <> help "produce full set of stackage packages, not just dependencies" )
120−
121118outDerivation :: Parser FilePath
122119outDerivation = option str
123120 ( long "out-derivation"
@@ -136,6 +133,16 @@ doHaddockPackages = flag True False
136133 ( long "no-haddock"
137134 <> help "disable haddock for project packages")
138135
136+withStackage :: Parser Bool
137+withStackage = switch
138+ ( long "--with-stackage"
139+ <> help "generate full Stackage" )
140+
141+withStackageClosure :: Parser Bool
142+withStackageClosure = switch
143+ ( long "--with-stackage-closure"
144+ <> help "generate Stackage subset containing only build dependencies" )
145+
139146resolver :: Parser StackResolver
140147resolver = StackResolver <$> option text
141148 ( long "resolver"