git.iko.soy/typeable/stackage2nix
on master help sign in
Remove explicit sorting
49a4e20Dmitry Bushev
ci-stackage2nix+1−1
@@ -16,7 +16,7 @@ if [ ! -d "$ALL_CABAL_HASHES_DIR" ]; then
16fi
16fi
17
17
18set -x
18set -x
19−stack exec -- stackage2nix \
19+time stack exec -- stackage2nix \
20 --lts-haskell "$STACKAGE_REPO" \
20 --lts-haskell "$STACKAGE_REPO" \
21 --all-cabal-hashes "$ALL_CABAL_HASHES_DIR" \
21 --all-cabal-hashes "$ALL_CABAL_HASHES_DIR" \
22 --hackage-db "$HOME/.cabal/packages/hackage.haskell.org/01-index.tar" \
22 --hackage-db "$HOME/.cabal/packages/hackage.haskell.org/01-index.tar" \
src/Distribution/Nixpkgs/Haskell/FromStack/Package.hs+12−4
@@ -1,8 +1,9 @@
1module Distribution.Nixpkgs.Haskell.FromStack.Package where
1module Distribution.Nixpkgs.Haskell.FromStack.Package where
2
2
3import Control.Lens
3import Control.Lens
4−import Data.Graph (Graph, Vertex)
5import Data.Foldable as F
4import Data.Foldable as F
5+import Data.Function (on)
6+import Data.Graph (Graph, Vertex)
6import Data.Maybe
7import Data.Maybe
7import Data.Monoid
8import Data.Monoid
8import Data.Ord as O
9import Data.Ord as O
@@ -28,6 +29,12 @@ data Node = Node
28
29
29makeLenses ''Node
30makeLenses ''Node
30
31
32+instance Eq Node where
33+ (==) = (==) `on` nodeName
34+
35+instance Ord Node where
36+ compare = compare `on` nodeName
37+
31mkNode :: Derivation -> Node
38mkNode :: Derivation -> Node
32mkNode _nodeDerivation = Node{..}
39mkNode _nodeDerivation = Node{..}
33 where
40 where
@@ -73,12 +80,13 @@ buildNodeGraph :: [Node] -> (Graph, FromVertex, FromKey)
73buildNodeGraph nodes = Graph.graphFromEdges
80buildNodeGraph nodes = Graph.graphFromEdges
74 [(node, nodeName node, Set.toList $ nodeDepends node) | node <- nodes]
81 [(node, nodeName node, Set.toList $ nodeDepends node) | node <- nodes]
75
82
76−reachableDependencies :: [Node] -> [Node] -> [Node]
83+reachableDependencies :: [Node] -> [Node] -> Set.Set Node
77−reachableDependencies keyNodes nodes = view _1 . fromVertex <$> reachableVertices
84+reachableDependencies keyNodes nodes = Set.map (view _1 . fromVertex) reachableVerticesS
78 where
85 where
79 (graph, fromVertex, fromKey) = buildNodeGraph nodes
86 (graph, fromVertex, fromKey) = buildNodeGraph nodes
80 keys = mapMaybe (fromKey . nodeName) keyNodes
87 keys = mapMaybe (fromKey . nodeName) keyNodes
88+ reachableVerticesS = F.foldr1 Set.union
81− reachableVertices = concatMap F.toList $ Graph.dfs graph keys
89+ $ (Set.fromList . F.toList) <$> Graph.dfs graph keys
82
90
83-- pretty printing
91-- pretty printing
84
92
src/Runner.hs+5−6
@@ -59,7 +59,7 @@ run = do
59 , enableHaddock = opts ^. optDoHaddockStackage
59 , enableHaddock = opts ^. optDoHaddockStackage
60 , enableBenchmark = False }
60 , enableBenchmark = False }
61 stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
61 stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
62− $ Map.toList (bpPackages buildPlan)
62+ $ Map.toAscList (bpPackages buildPlan)
63
63
64 let
64 let
65 -- Find all reachable dependencies in stackage set to stick into
65 -- Find all reachable dependencies in stackage set to stick into
@@ -69,13 +69,12 @@ run = do
69 -- does: pruning only after generating full set of packages allows
69 -- does: pruning only after generating full set of packages allows
70 -- us to make sure all those extra dependencies are explicitly
70 -- us to make sure all those extra dependencies are explicitly
71 -- listed as well.
71 -- listed as well.
72− reachableStackagePackages = case opts ^. optOutPackagesClosure of
72+ nodes = case opts ^. optOutPackagesClosure of
73+ True -> Set.toAscList
73− True -> flip reachableDependencies stackagePackages
74+ $ flip reachableDependencies stackagePackages
74 -- Originally reachable nodes are root nodes
75 -- Originally reachable nodes are root nodes
75 $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
76 $ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
76 False -> stackagePackages
77 False -> stackagePackages
77− -- Sort final packages to make the order consistent
78− nodes = L.sortOn nodeName reachableStackagePackages
79 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
78 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
80 $ pPrintOutPackages (view nodeDerivation <$> nodes)
79 $ pPrintOutPackages (view nodeDerivation <$> nodes)
81 writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
80 writeOutFile buildPlanFile (opts ^. optOutStackageConfig)
@@ -98,7 +97,7 @@ run = do
98 (opts ^. optNixpkgsRepository)
97 (opts ^. optNixpkgsRepository)
99 buildPlan
98 buildPlan
100 nodes <- traverse (uncurry (buildNode packageSetConfig packageConfig))
99 nodes <- traverse (uncurry (buildNode packageSetConfig packageConfig))
101− $ Map.toList (bpPackages buildPlan)
100+ $ Map.toAscList (bpPackages buildPlan)
102
101
103 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
102 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
104 $ pPrintOutPackages (view nodeDerivation <$> nodes)
103 $ pPrintOutPackages (view nodeDerivation <$> nodes)