Skip to content

Commit

Permalink
Upd Stackage lts
Browse files Browse the repository at this point in the history
  • Loading branch information
4e6 committed Dec 20, 2017
1 parent 39774d0 commit cc865d6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.stack-work
Paths_stackage2nix.hs
/*.nix
/result*
4 changes: 1 addition & 3 deletions src/Distribution/Nixpkgs/Haskell/FromStack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ data PackageSetConfig = PackageSetConfig

data PackageConfig = PackageConfig
{ enableCheck :: Bool
, enableHaddock :: Bool
, enableBenchmark :: Bool }
, enableHaddock :: Bool }

removeTests :: GenericPackageDescription -> GenericPackageDescription
removeTests gd = gd { condTestSuites = [] }
Expand Down Expand Up @@ -93,4 +92,3 @@ finalizePackage pkg pconf drv = drv
& src .~ pkgSource pkg
& doCheck &&~ enableCheck pconf
& runHaddock &&~ enableHaddock pconf
& benchmarkDepends %~ if enableBenchmark pconf then id else const mempty
18 changes: 13 additions & 5 deletions src/Distribution/Nixpkgs/Haskell/FromStack/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import qualified Data.Map as Map
import qualified Data.Set as Set

data Node = Node
{ _nodeDerivation :: Derivation
, _nodeTestDepends :: Set.Set String
, _nodeBenchmarkDepends :: Set.Set String
, _nodeOtherDepends :: Set.Set String }
{ _nodeDerivation :: Derivation
, _nodeTestDepends :: Set.Set String
, _nodeBenchmarkDepends :: Set.Set String
, _nodeExecutableDepends :: Set.Set String
, _nodeSetupDepends :: Set.Set String
, _nodeOtherDepends :: Set.Set String }

makeLenses ''Node

Expand All @@ -43,6 +45,8 @@ mkNode _nodeDerivation = Node{..}
$ view (s . (haskell <> tool)) _nodeDerivation
_nodeTestDepends = haskellDependencies testDepends
_nodeBenchmarkDepends = haskellDependencies benchmarkDepends
_nodeExecutableDepends = haskellDependencies executableDepends
_nodeSetupDepends = haskellDependencies setupDepends
_nodeOtherDepends = haskellDependencies (executableDepends <> libraryDepends)

nodeName :: Node -> String
Expand All @@ -52,7 +56,11 @@ nodeCycleDepends :: Node -> Set.Set String
nodeCycleDepends = _nodeTestDepends <> _nodeOtherDepends

nodeDepends :: Node -> Set.Set String
nodeDepends = _nodeTestDepends <> _nodeOtherDepends <> _nodeBenchmarkDepends
nodeDepends = _nodeTestDepends
<> _nodeOtherDepends
<> _nodeBenchmarkDepends
<> _nodeExecutableDepends
<> _nodeSetupDepends

findCycles :: [Node] -> [[Node]]
findCycles nodes = mapMaybe cyclic $
Expand Down
3 changes: 1 addition & 2 deletions src/Distribution/Nixpkgs/Haskell/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ packageDerivation conf optHackageDb stackPackage = do
isExtraDep = stackPackage ^. spExtraDep
pconf = PackageConfig
{ enableCheck = if isExtraDep then conf ^. spcDoCheckStackage else conf ^. spcDoCheckPackages
, enableHaddock = if isExtraDep then conf ^. spcDoHaddockStackage else conf ^. spcDoHaddockPackages
, enableBenchmark = not isExtraDep }
, enableHaddock = if isExtraDep then conf ^. spcDoHaddockStackage else conf ^. spcDoHaddockPackages }
return $ finalizePackage pkg pconf drv

genericPackageDerivation
Expand Down
11 changes: 7 additions & 4 deletions src/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ run = do
s2nPackageSetConfig = packageSetConfig { packageLoader = s2nLoader }
s2nPackageConfig = PackageConfig
{ enableCheck = opts ^. optDoCheckStackage
, enableHaddock = opts ^. optDoHaddockStackage
, enableBenchmark = False }
, enableHaddock = opts ^. optDoHaddockStackage }
stackagePackages <- traverse (uncurry (buildNode s2nPackageSetConfig s2nPackageConfig))
$ Map.toAscList (bpPackages buildPlan)

let
-- Nixpkgs generic-builder puts hscolour on path for all libraries
withHscolour pkgs =
let hscolour = F.find ((== "hscolour") . nodeName) stackagePackages
in maybe pkgs (`Set.insert` pkgs) hscolour
-- Find all reachable dependencies in stackage set to stick into
-- stackage packages file. This is performed on the full stackage
-- set rather than pruning stackage packages beforehand because
Expand All @@ -71,6 +74,7 @@ run = do
-- listed as well.
nodes = case opts ^. optOutPackagesClosure of
True -> Set.toAscList
$ withHscolour
$ flip reachableDependencies stackagePackages
-- Originally reachable nodes are root nodes
$ L.filter (\n -> mkPackageName (nodeName n) `Set.member` reachable) stackagePackages
Expand All @@ -88,8 +92,7 @@ run = do
buildPlanFile = LH.buildPlanFilePath (opts ^. optLtsHaskellRepo) stackResolver
packageConfig = PackageConfig
{ enableCheck = opts ^. optDoCheckStackage
, enableHaddock = opts ^. optDoHaddockStackage
, enableBenchmark = False }
, enableHaddock = opts ^. optDoHaddockStackage }
buildPlan <- LH.loadBuildPlan buildPlanFile
packageSetConfig <- LH.buildPackageSetConfig
(opts ^. optHackageDb)
Expand Down
2 changes: 1 addition & 1 deletion stack-ghc-822.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resolver: nightly-2017-12-08
resolver: lts-10.0
2 changes: 1 addition & 1 deletion stack.yaml

0 comments on commit cc865d6

Please sign in to comment.