git.iko.soy/typeable/stackage2nix
on master help sign in
Remove explicit sorting
commit49a4e205d92c5efa1d7519bb0336958de424368a authorDmitry Bushev <bushevdv@gmail.com> dateTue 12 Dec 2017, 00:59 (9 years ago) parent43e0013
3 files changed+18−11
ci-stackage2nix+1−1 src/Distribution/Nixpkgs/Haskell/FromStack/Package.hs+12−4 src/Runner.hs+5−6
ci-stackage2nix+1−1
@@ -16,7 +16,7 @@ if [ ! -d "$ALL_CABAL_HASHES_DIR" ]; then
1616fi
1717
1818set -x
19−stack exec -- stackage2nix \
19+time stack exec -- stackage2nix \
2020 --lts-haskell "$STACKAGE_REPO" \
2121 --all-cabal-hashes "$ALL_CABAL_HASHES_DIR" \
2222 --hackage-db "$HOME/.cabal/packages/hackage.haskell.org/01-index.tar" \
src/Distribution/Nixpkgs/Haskell/FromStack/Package.hs+12−4
@@ -1,8 +1,9 @@
11module Distribution.Nixpkgs.Haskell.FromStack.Package where
22
33import Control.Lens
4−import Data.Graph (Graph, Vertex)
54import Data.Foldable as F
5+import Data.Function (on)
6+import Data.Graph (Graph, Vertex)
67import Data.Maybe
78import Data.Monoid
89import Data.Ord as O
@@ -28,6 +29,12 @@ data Node = Node
2829
2930makeLenses ''Node
3031
32+instance Eq Node where
33+ (==) = (==) `on` nodeName
34+
35+instance Ord Node where
36+ compare = compare `on` nodeName
37+
3138mkNode :: Derivation -> Node
3239mkNode _nodeDerivation = Node{..}
3340 where
@@ -73,12 +80,13 @@ buildNodeGraph :: [Node] -> (Graph, FromVertex, FromKey)
7380buildNodeGraph nodes = Graph.graphFromEdges
7481 [(node, nodeName node, Set.toList $ nodeDepends node) | node <- nodes]
7582
76−reachableDependencies :: [Node] -> [Node] -> [Node]
77−reachableDependencies keyNodes nodes = view _1 . fromVertex <$> reachableVertices
83+reachableDependencies :: [Node] -> [Node] -> Set.Set Node
84+reachableDependencies keyNodes nodes = Set.map (view _1 . fromVertex) reachableVerticesS
7885 where
7986 (graph, fromVertex, fromKey) = buildNodeGraph nodes
8087 keys = mapMaybe (fromKey . nodeName) keyNodes
81− reachableVertices = concatMap F.toList $ Graph.dfs graph keys
88+ reachableVerticesS = F.foldr1 Set.union
89+ $ (Set.fromList . F.toList) <$> Graph.dfs graph keys
8290
8391-- pretty printing
8492
src/Runner.hs+5−6
@@ -59,7 +59,7 @@ run = do
5959 , enableHaddock = opts ^. optDoHaddockStackage
6060 , enableBenchmark = False }
6161 stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
62− $ Map.toList (bpPackages buildPlan)
62+ $ Map.toAscList (bpPackages buildPlan)
6363
6464 let
6565 -- Find all reachable dependencies in stackage set to stick into
@@ -69,13 +69,12 @@ run = do
6969 -- does: pruning only after generating full set of packages allows
7070 -- us to make sure all those extra dependencies are explicitly
7171 -- listed as well.
72− reachableStackagePackages = case opts ^. optOutPackagesClosure of
73− True -> flip reachableDependencies stackagePackages
72+ nodes = case opts ^. optOutPackagesClosure of
73+ True -> Set.toAscList
74+ $ flip reachableDependencies stackagePackages
7475 -- Originally reachable nodes are root nodes
7576 $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
7677 False -> stackagePackages
77− -- Sort final packages to make the order consistent
78− nodes = L.sortOn nodeName reachableStackagePackages
7978 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
8079 $ pPrintOutPackages (view nodeDerivation <$> nodes)
8180 writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
@@ -98,7 +97,7 @@ run = do
9897 (opts ^. optNixpkgsRepository)
9998 buildPlan
10099 nodes <- traverse (uncurry (buildNode packageSetConfig packageConfig))
101− $ Map.toList (bpPackages buildPlan)
100+ $ Map.toAscList (bpPackages buildPlan)
102101
103102 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
104103 $ pPrintOutPackages (view nodeDerivation <$> nodes)