git.iko.soy/typeable/stackage2nix
on master help sign in
Add --with-stackage flags
a01f83bDmitry Bushev
src/Runner.hs+9−5
@@ -1,6 +1,7 @@
1module Runner ( run ) where
1module Runner ( run ) where
2
2
3import Control.Lens
3import Control.Lens
4+import Control.Monad
4import Data.Foldable as F
5import Data.Foldable as F
5import Data.List as L
6import Data.List as L
6import Distribution.Nixpkgs.Haskell.FromStack
7import Distribution.Nixpkgs.Haskell.FromStack
@@ -60,6 +61,7 @@ run = do
60 stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
61 stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
61 $ Map.toAscList (bpPackages buildPlan)
62 $ Map.toAscList (bpPackages buildPlan)
62 let
63 let
64+ generateStackage = opts ^. optWithStackage || opts ^. optWithStackageClosure
63 -- Nixpkgs generic-builder puts hscolour on path for all libraries
65 -- Nixpkgs generic-builder puts hscolour on path for all libraries
64 withHscolour pkgs =
66 withHscolour pkgs =
65 let hscolour = F.find ((== "hscolour") . nodeName) stackagePackages
67 let hscolour = F.find ((== "hscolour") . nodeName) stackagePackages
@@ -71,17 +73,19 @@ run = do
71 -- does: pruning only after generating full set of packages allows
73 -- does: pruning only after generating full set of packages allows
72 -- us to make sure all those extra dependencies are explicitly
74 -- us to make sure all those extra dependencies are explicitly
73 -- listed as well.
75 -- listed as well.
74− nodes = case opts ^. optOutPackagesClosure of
76+ nodes = case opts ^. optWithStackageClosure of
75 True -> Set.toAscList
77 True -> Set.toAscList
76 $ withHscolour
78 $ withHscolour
77 $ flip reachableDependencies stackagePackages
79 $ flip reachableDependencies stackagePackages
78 -- Originally reachable nodes are root nodes
80 -- Originally reachable nodes are root nodes
79 $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
81 $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
80 False -> stackagePackages
82 False -> stackagePackages
83+ when generateStackage $ do
81− writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
84+ writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
82− $ pPrintOutPackages (view nodeDerivation <$> nodes)
85+ $ pPrintOutPackages (view nodeDerivation <$> nodes)
83− writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
86+ writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
84− $ pPrintOutConfig (bpSystemInfo buildPlan) nodes
87+ $ pPrintOutConfig (bpSystemInfo buildPlan) nodes
88+ -- TODO: generate stackage override
85 writeOutFile (stackYaml ^. syFilePath) (opts ^. optOutDerivation)
89 writeOutFile (stackYaml ^. syFilePath) (opts ^. optOutDerivation)
86 $ PP.overrideHaskellPackages overrideConfig stackConfPackages
90 $ PP.overrideHaskellPackages overrideConfig stackConfPackages
87
91
src/Runner/Cli.hs+14−7
@@ -30,10 +30,11 @@ data Options = Options
30 , _optLtsHaskellRepo :: FilePath
30 , _optLtsHaskellRepo :: FilePath
31 , _optOutStackagePackages :: FilePath
31 , _optOutStackagePackages :: FilePath
32 , _optOutStackageConfig :: FilePath
32 , _optOutStackageConfig :: FilePath
33− , _optOutPackagesClosure :: Bool
34 , _optOutDerivation :: FilePath
33 , _optOutDerivation :: FilePath
35 , _optDoCheckPackages :: Bool
34 , _optDoCheckPackages :: Bool
36 , _optDoHaddockPackages :: Bool
35 , _optDoHaddockPackages :: Bool
36+ , _optWithStackage :: Bool
37+ , _optWithStackageClosure :: Bool
37 , _optHackageDb :: Maybe HackageDb
38 , _optHackageDb :: Maybe HackageDb
38 , _optNixpkgsRepository :: FilePath
39 , _optNixpkgsRepository :: FilePath
39 , _optCompilerId :: CompilerId
40 , _optCompilerId :: CompilerId
@@ -59,10 +60,11 @@ options = Options
59 <*> ltsHaskellRepo
60 <*> ltsHaskellRepo
60 <*> outStackagePackages
61 <*> outStackagePackages
61 <*> outStackageConfig
62 <*> outStackageConfig
62− <*> outPackagesClosure
63 <*> outDerivation
63 <*> outDerivation
64 <*> doCheckPackages
64 <*> doCheckPackages
65 <*> doHaddockPackages
65 <*> doHaddockPackages
66+ <*> withStackage
67+ <*> withStackageClosure
66 <*> optional hackageDb
68 <*> optional hackageDb
67 <*> nixpkgsRepository
69 <*> nixpkgsRepository
68 <*> compilerId
70 <*> compilerId
@@ -113,11 +115,6 @@ outStackageConfig = option str
113 <> value "configuration-packages.nix"
115 <> value "configuration-packages.nix"
114 <> showDefaultWith id)
116 <> showDefaultWith id)
115
117
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−
121outDerivation :: Parser FilePath
118outDerivation :: Parser FilePath
122outDerivation = option str
119outDerivation = option str
123 ( long "out-derivation"
120 ( long "out-derivation"
@@ -136,6 +133,16 @@ doHaddockPackages = flag True False
136 ( long "no-haddock"
133 ( long "no-haddock"
137 <> help "disable haddock for project packages")
134 <> help "disable haddock for project packages")
138
135
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+
139resolver :: Parser StackResolver
146resolver :: Parser StackResolver
140resolver = StackResolver <$> option text
147resolver = StackResolver <$> option text
141 ( long "resolver"
148 ( long "resolver"