git.iko.soy/typeable/cabal2nix
on master help sign in
hackage2nix: generate the latest LTS package set only
commitb304101b5251c88d5e917a09a3469587e43734a9 authorPeter Simons <simons@cryp.to> dateTue 19 Jul 2016, 15:10 (10 years ago) parentcec8f95
2 files changed+8−16
hackage2nix/Main.hs+4−4 hackage2nix/Stackage.hs+4−12
hackage2nix/Main.hs+4−4
@@ -82,7 +82,7 @@ main = do
8282 . Map.delete "som" -- TODO: https://github.com/NixOS/cabal2nix/issues/164
8383 . Map.delete "type" -- TODO: https://github.com/NixOS/cabal2nix/issues/163
8484 hackage <- fixup <$> readHackage hackageRepository
85− snapshots <- runParIO (readLTSHaskell ltsHaskellRepository)
85+ lts <- readLTSHaskell ltsHaskellRepository
8686 nightly <- readStackageNightly stackageNightlyRepository
8787 let
8888 config :: Configuration
@@ -114,7 +114,7 @@ main = do
114114 [ Map.singleton name (Set.singleton (resolveConstraint c hackage)) | c@(Dependency name _) <- extraPackages config ]
115115
116116 stackagePackageSet :: Map PackageName (Map Version Spec)
117− stackagePackageSet = Map.fromListWith (Map.unionWith mergeSpecs) [ (n, Map.singleton (Stackage.version spec) spec) | snapshot <- nightly:snapshots, (n, spec) <- Map.toList (packages snapshot) ]
117+ stackagePackageSet = Map.fromListWith (Map.unionWith mergeSpecs) [ (n, Map.singleton (Stackage.version spec) spec) | snapshot <- [nightly,lts], (n, spec) <- Map.toList (packages snapshot) ]
118118
119119 db :: PackageMultiSet
120120 db = Map.unionsWith Set.union [ Map.map Set.singleton generatedDefaultPackageSet
@@ -187,14 +187,14 @@ main = do
187187 mapM_ (\pkg -> hPutStrLn h pkg >> hPutStrLn h "") pkgs
188188 hPutStrLn h "}"
189189
190− void $ runParIO $ flip parMapM snapshots $ \Snapshot {..} -> liftIO $ do
190+ forM_ [lts] $ \Snapshot {..} -> liftIO $ do
191191 let allPackages :: PackageSet
192192 allPackages = Map.difference
193193 (Map.fromList [ (name, Stackage.version spec) | (name, spec) <- Map.toList packages ] `Map.union` generatedDefaultPackageSet)
194194 corePackages'
195195
196196 ltsConfigFile :: FilePath
197− ltsConfigFile = nixpkgsRepository </> "pkgs/development/haskell-modules/configuration-" ++ show (pPrint snapshot) ++ ".nix"
197+ ltsConfigFile = nixpkgsRepository </> "pkgs/development/haskell-modules/configuration-lts.nix"
198198
199199 corePackages' :: PackageSet
200200 corePackages' = corePackages `Map.union` Map.fromList [("Cabal", Version [] []), ("rts", Version [] [])]
hackage2nix/Stackage.hs+4−12
@@ -4,11 +4,8 @@
44
55module Stackage where
66
7−import Control.DeepSeq
87import Control.Exception ( assert )
98import Control.Monad
10−import Control.Monad.Par.Combinator
11−import Control.Monad.Par.IO
129import Control.Monad.Trans
1310import Data.List
1411import Data.List.Split
@@ -17,7 +14,6 @@ import Data.Maybe
1714import Data.Time.Calendar
1815import Data.Yaml
1916import Distribution.Compiler
20−import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2117import Distribution.Package
2218import Distribution.Version
2319import GHC.Generics ( Generic )
@@ -47,22 +43,18 @@ data Snapshot = Snapshot
4743 , corePackages :: Map PackageName Version
4844 , packages :: Map PackageName Spec
4945 }
50− deriving (Show, Generic)
51−
52−deriving instance Generic SnapshotType
53−instance NFData Spec
54−instance NFData Snapshot
55−instance NFData SnapshotType
46+ deriving (Show)
5647
5748instance Pretty SnapshotType where
5849 pPrint STNightly = text "stackage-nightly"
5950 pPrint (STNightly2 _) = text "stackage-nightly"
6051 pPrint (STLTS m n) = text "lts-" <> int m <> char '.' <> int n
6152
62−readLTSHaskell :: FilePath -> ParIO [Snapshot]
53+readLTSHaskell :: FilePath -> IO Snapshot
6354readLTSHaskell dirPath = do
6455 filePaths <- liftIO (listFiles dirPath)
65− parMapM (liftIO . readSnapshot) [ dirPath </> p | p <- filePaths, takeExtension p == ".yaml" ]
56+ let latest = maximum (Prelude.filter (\p -> takeExtension p == ".yaml") filePaths)
57+ readSnapshot (dirPath </> latest)
6658
6759readStackageNightly :: FilePath -> IO Snapshot
6860readStackageNightly dirPath = do