git.iko.soy/typeable/stackage2nix
on master help sign in
Sort Stackage packages (#34)
b3131d3Dmitry Bushev
src/Runner.hs+17−14
@@ -59,22 +59,25 @@ run = do
59 stackagePackages <- traverse (uncurry (buildNodeM s2nPackageSetConfig s2nPackageConfig))
59 stackagePackages <- traverse (uncurry (buildNodeM s2nPackageSetConfig s2nPackageConfig))
60 $ Map.toList (bpPackages buildPlan)
60 $ Map.toList (bpPackages buildPlan)
61
61
62+ let
62− -- Find all reachable dependencies in stackage set to stick into
63+ -- Find all reachable dependencies in stackage set to stick into
63− -- stackage packages file. This is performed on the full stackage
64+ -- stackage packages file. This is performed on the full stackage
64− -- set rather than pruning stackage packages beforehand because
65+ -- set rather than pruning stackage packages beforehand because
65− -- stackage does not concern itself with build tools while cabal2nix
66+ -- stackage does not concern itself with build tools while cabal2nix
66− -- does: pruning only after generating full set of packages allows
67+ -- does: pruning only after generating full set of packages allows
67− -- us to make sure all those extra dependencies are explicitly
68+ -- us to make sure all those extra dependencies are explicitly
68− -- listed as well.
69+ -- listed as well.
69− let reachableStackagePackages = case opts ^. optOutPackagesClosure of
70+ reachableStackagePackages = case opts ^. optOutPackagesClosure of
70− True -> flip reachableDependencies stackagePackages
71+ True -> flip reachableDependencies stackagePackages
71− -- Originally reachable nodes are root nodes
72+ -- Originally reachable nodes are root nodes
72− $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
73+ $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
73− False -> stackagePackages
74+ False -> stackagePackages
75+ -- Sort final packages to make the order consistent
76+ nodes = L.sortOn nodeName reachableStackagePackages
74 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
77 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
75− $ pPrintOutPackages (view nodeDerivation <$> reachableStackagePackages)
78+ $ pPrintOutPackages (view nodeDerivation <$> nodes)
76 writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
79 writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
77− $ pPrintOutConfig (bpSystemInfo buildPlan) reachableStackagePackages
80+ $ pPrintOutConfig (bpSystemInfo buildPlan) nodes
78 writeOutFile (stackYaml ^. syFilePath) (opts ^. optOutDerivation)
81 writeOutFile (stackYaml ^. syFilePath) (opts ^. optOutDerivation)
79 $ PP.overrideHaskellPackages overrideConfig stackConfPackages
82 $ PP.overrideHaskellPackages overrideConfig stackConfPackages
80
83