git.iko.soy/typeable/stackage2nix
on master help sign in
Fix memory regression
518be58Dmitry Bushev
.travis.yml−1
@@ -14,7 +14,6 @@ cache:
14
14
15env:
15env:
16 - STACK_YAML=stack-ghc-802.yaml
16 - STACK_YAML=stack-ghc-802.yaml
17− - STACK_YAML=stack-ghc-821.yaml
18 - STACK_YAML=stack-ghc-822.yaml
17 - STACK_YAML=stack-ghc-822.yaml
19
18
20jobs:
19jobs:
CHANGELOG.md+1
@@ -24,3 +24,4 @@
24- Remove `--do-check-stackage` flag (enabled by default)
24- Remove `--do-check-stackage` flag (enabled by default)
25- Remove `--do-haddock-stackage` flag (enabled by default)
25- Remove `--do-haddock-stackage` flag (enabled by default)
26- Remove `--no-packages-closure` flag (use `--with-stackage-closure`)
26- Remove `--no-packages-closure` flag (use `--with-stackage-closure`)
27+- Remove `cabal2nix < 2.7.2` support #45
src/Distribution/Nixpkgs/Haskell/Stack.hs+7−38
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
2module Distribution.Nixpkgs.Haskell.Stack where
1module Distribution.Nixpkgs.Haskell.Stack where
3
2
4import Control.Lens
3import Control.Lens
@@ -9,6 +8,7 @@ import Distribution.Nixpkgs.Fetch
9import Distribution.Nixpkgs.Haskell.Derivation
8import Distribution.Nixpkgs.Haskell.Derivation
10import Distribution.Nixpkgs.Haskell.FromCabal as FromCabal
9import Distribution.Nixpkgs.Haskell.FromCabal as FromCabal
11import Distribution.Nixpkgs.Haskell.FromStack as FromStack
10import Distribution.Nixpkgs.Haskell.FromStack as FromStack
11+import Distribution.Nixpkgs.Haskell.Hackage as DB
12import Distribution.Nixpkgs.Haskell.PackageSourceSpec as PackageSourceSpec
12import Distribution.Nixpkgs.Haskell.PackageSourceSpec as PackageSourceSpec
13import Distribution.PackageDescription as PackageDescription
13import Distribution.PackageDescription as PackageDescription
14import Distribution.System as System
14import Distribution.System as System
@@ -16,13 +16,6 @@ import Network.URI as URI
16import Stack.Config
16import Stack.Config
17
17
18
18
19−newtype HackageDb = HackageDb { fromHackageDB :: T.Text }
20− deriving (Eq, Ord, Show)
21−
22−makePrisms ''HackageDb
23−
24−unHackageDb :: HackageDb -> String
25−unHackageDb = T.unpack . fromHackageDB
26
19
27data StackPackagesConfig = StackPackagesConfig
20data StackPackagesConfig = StackPackagesConfig
28 { _spcHaskellResolver :: HaskellResolver
21 { _spcHaskellResolver :: HaskellResolver
@@ -36,36 +29,12 @@ data StackPackagesConfig = StackPackagesConfig
36
29
37makeLenses ''StackPackagesConfig
30makeLenses ''StackPackagesConfig
38
31
39−-- TODO: cabal2nix versions [2.6.0, 2.7.1, 2.7.2] cause #45 memory usage regression
32+getStackPackageFromDb :: DB.HackageDB -> StackPackage -> IO Package
40−-- Possible fix would be to load 'Distribution.Nixpkgs.Haskell.Hackage.HackageDB'
41−-- beforehand and pass it as an argument
42−getStackPackageFromDb
43− :: Maybe HackageDb
44− -> StackPackage
45− -> IO Package
46−getStackPackageFromDb optHackageDb stackPackage = do
33+getStackPackageFromDb hackageDb stackPackage = do
47−#if MIN_VERSION_cabal2nix(2,7,2)
48 PackageSourceSpec.getPackage'
34 PackageSourceSpec.getPackage'
49 False
35 False
50− (PackageSourceSpec.loadHackageDB (unHackageDb <$> optHackageDb) Nothing)
51− (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
52−#elif MIN_VERSION_cabal2nix(2,7,1)
53− hackageDb <- PackageSourceSpec.loadHackageDB (unHackageDb <$> optHackageDb) Nothing
54− PackageSourceSpec.getPackage'
55− False
56− hackageDb
36+ (pure hackageDb)
57− (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
58−#elif MIN_VERSION_cabal2nix(2,6,0)
59− PackageSourceSpec.getPackage
60− False
61− (unHackageDb <$> optHackageDb)
62− Nothing
63− (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
64−#else
65− PackageSourceSpec.getPackage
66− (unHackageDb <$> optHackageDb)
67 (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
37 (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
68−#endif
69
38
70stackLocationToSource
39stackLocationToSource
71 :: PackageLocation
40 :: PackageLocation
@@ -98,11 +67,11 @@ stackLocationToSource pl mCabalDir = case pl of
98
67
99packageDerivation
68packageDerivation
100 :: StackPackagesConfig
69 :: StackPackagesConfig
101− -> Maybe HackageDb
70+ -> DB.HackageDB
102 -> StackPackage
71 -> StackPackage
103 -> IO Derivation
72 -> IO Derivation
104−packageDerivation conf optHackageDb stackPackage = do
73+packageDerivation conf hackageDb stackPackage = do
105− pkg <- getStackPackageFromDb optHackageDb stackPackage
74+ pkg <- getStackPackageFromDb hackageDb stackPackage
106 let
75 let
107 drv = genericPackageDerivation conf pkg
76 drv = genericPackageDerivation conf pkg
108 & subpath %~ flip fromMaybe (stackPackage ^. spDir)
77 & subpath %~ flip fromMaybe (stackPackage ^. spDir)
src/LtsHaskell.hs+10−14
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
2module LtsHaskell where
1module LtsHaskell where
3
2
4import AllCabalHashes
3import AllCabalHashes
@@ -24,6 +23,7 @@ import Stackage.BuildPlan
24import Stackage.Types (SystemInfo(..))
23import Stackage.Types (SystemInfo(..))
25import System.FilePath as Path
24import System.FilePath as Path
26
25
26+import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
27import qualified Data.Yaml as Yaml
27import qualified Data.Yaml as Yaml
28import qualified Data.Map as Map
28import qualified Data.Map as Map
29import qualified Data.Set as Set
29import qualified Data.Set as Set
@@ -47,21 +47,17 @@ getPackageFromRepo allCabalHashesPath mSha1Hash pkgId = do
47 (error (display pkgId ++ ": meta data has no SHA256 hash for the tarball"))
47 (error (display pkgId ++ ": meta data has no SHA256 hash for the tarball"))
48 (view (mHashes . at "SHA256") meta)
48 (view (mHashes . at "SHA256") meta)
49 source = DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256
49 source = DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256
50−#if MIN_VERSION_cabal2nix(2,6,0)
51 return $ Package source False pkgDesc
50 return $ Package source False pkgDesc
52−#else
53− return $ Package source pkgDesc
54−#endif
55
51
56−getPackageFromDb :: Maybe HackageDb -> PackageIdentifier -> IO Package
52+getPackageFromDb :: DB.HackageDB -> PackageIdentifier -> IO Package
57−getPackageFromDb mHackageDb pkgId =
53+getPackageFromDb hackageDb pkgId =
58− getStackPackageFromDb mHackageDb
54+ getStackPackageFromDb hackageDb
59 $ StackPackage (HackagePackage (T.pack $ Text.display pkgId)) True Nothing
55 $ StackPackage (HackagePackage (T.pack $ Text.display pkgId)) True Nothing
60
56
61−loadPackage :: Maybe HackageDb -> FilePath -> Maybe SHA1Hash -> PackageIdentifier -> IO Package
57+loadPackage :: DB.HackageDB -> FilePath -> Maybe SHA1Hash -> PackageIdentifier -> IO Package
62−loadPackage mHackageDb allCabalHashesPath mSha1Hash pkgId =
58+loadPackage hackageDb allCabalHashesPath mSha1Hash pkgId =
63 getPackageFromRepo allCabalHashesPath mSha1Hash pkgId
59 getPackageFromRepo allCabalHashesPath mSha1Hash pkgId
64− `catchIOError` const (getPackageFromDb mHackageDb pkgId)
60+ `catchIOError` const (getPackageFromDb hackageDb pkgId)
65
61
66ghcCompilerInfo :: Version -> CompilerInfo
62ghcCompilerInfo :: Version -> CompilerInfo
67ghcCompilerInfo v = CompilerInfo
63ghcCompilerInfo v = CompilerInfo
@@ -77,18 +73,18 @@ buildPlanContainsDependency packageVersions (Dependency depName versionRange) =
77 maybe False (`withinRange` versionRange) $ Map.lookup depName packageVersions
73 maybe False (`withinRange` versionRange) $ Map.lookup depName packageVersions
78
74
79buildPackageSetConfig
75buildPackageSetConfig
80− :: Maybe HackageDb
76+ :: DB.HackageDB
81 -> FilePath
77 -> FilePath
82 -> FilePath
78 -> FilePath
83 -> BuildPlan
79 -> BuildPlan
84 -> IO PackageSetConfig
80 -> IO PackageSetConfig
85−buildPackageSetConfig mHackageDb optAllCabalHashes optNixpkgsRepository buildPlan = do
81+buildPackageSetConfig hackageDb optAllCabalHashes optNixpkgsRepository buildPlan = do
86 nixpkgs <- readNixpkgPackageMap optNixpkgsRepository Nothing
82 nixpkgs <- readNixpkgPackageMap optNixpkgsRepository Nothing
87 let
83 let
88 systemInfo = bpSystemInfo buildPlan
84 systemInfo = bpSystemInfo buildPlan
89 packageVersions = fmap ppVersion (bpPackages buildPlan) `Map.union` siCorePackages systemInfo
85 packageVersions = fmap ppVersion (bpPackages buildPlan) `Map.union` siCorePackages systemInfo
90 return PackageSetConfig
86 return PackageSetConfig
91− { packageLoader = loadPackage mHackageDb optAllCabalHashes
87+ { packageLoader = loadPackage hackageDb optAllCabalHashes
92 , targetPlatform = Platform (siArch systemInfo) (siOS systemInfo)
88 , targetPlatform = Platform (siArch systemInfo) (siOS systemInfo)
93 , targetCompiler = ghcCompilerInfo (siGhcVersion systemInfo)
89 , targetCompiler = ghcCompilerInfo (siGhcVersion systemInfo)
94 , nixpkgsResolver = resolve (Map.map (Set.map (over path ("pkgs":))) nixpkgs)
90 , nixpkgsResolver = resolve (Map.map (Set.map (over path ("pkgs":))) nixpkgs)
src/Runner.hs+10−7
@@ -7,6 +7,8 @@ import Data.Maybe (fromMaybe)
7import Data.Semigroup ((<>))
7import Data.Semigroup ((<>))
8import Distribution.Nixpkgs.Haskell.FromStack
8import Distribution.Nixpkgs.Haskell.FromStack
9import Distribution.Nixpkgs.Haskell.FromStack.Package
9import Distribution.Nixpkgs.Haskell.FromStack.Package
10+import Distribution.Nixpkgs.Haskell.Hackage as DB
11+import Distribution.Nixpkgs.Haskell.PackageSourceSpec (loadHackageDB)
10import Distribution.Nixpkgs.Haskell.Stack
12import Distribution.Nixpkgs.Haskell.Stack
11import Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting as PP
13import Distribution.Nixpkgs.Haskell.Stack.PrettyPrinting as PP
12import Distribution.Version (Version)
14import Distribution.Version (Version)
@@ -30,6 +32,7 @@ import qualified LtsHaskell as LH
30run :: IO ()
32run :: IO ()
31run = do
33run = do
32 opts <- execParser pinfo
34 opts <- execParser pinfo
35+ hackageDb <- loadHackageDB (opts ^. optHackageDb) Nothing
33 let
36 let
34 -- With optparse-applicative it seems there's no way to make
37 -- With optparse-applicative it seems there's no way to make
35 -- 'StackageOptions' optional for Stackage override and required in
38 -- 'StackageOptions' optional for Stackage override and required in
@@ -46,12 +49,12 @@ run = do
46 let
49 let
47 stackResolver = stackConf ^. scResolver
50 stackResolver = stackConf ^. scResolver
48 stackPackagesConfig = mkStackPackagesConfig opts
51 stackPackagesConfig = mkStackPackagesConfig opts
49− stackConfPackages <- traverse (fmap mkNode . packageDerivation stackPackagesConfig (opts ^. optHackageDb))
52+ stackConfPackages <- traverse (fmap mkNode . packageDerivation stackPackagesConfig hackageDb)
50 $ stackConf ^. scPackages
53 $ stackConf ^. scPackages
51
54
52 case buildTarget of
55 case buildTarget of
53 TargetStackageClosure -> do
56 TargetStackageClosure -> do
54− (buildPlanFile, buildPlan, packageSetConfig) <- loadStackageBuildPlan stackResolver opts sopts
57+ (buildPlanFile, buildPlan, packageSetConfig) <- loadStackageBuildPlan hackageDb stackResolver opts sopts
55 let
58 let
56 overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
59 overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
57 stackageSetConfig = if opts ^. optTweaks . tExtraDepsRevisionLatest
60 stackageSetConfig = if opts ^. optTweaks . tExtraDepsRevisionLatest
@@ -84,7 +87,7 @@ run = do
84 $ PP.overrideHaskellPackages overrideConfig (view nodeDerivation <$> stackConfPackages)
87 $ PP.overrideHaskellPackages overrideConfig (view nodeDerivation <$> stackConfPackages)
85
88
86 TargetStackagePackages -> do
89 TargetStackagePackages -> do
87− (buildPlanFile, buildPlan, packageSetConfig) <- loadStackageBuildPlan stackResolver opts sopts
90+ (buildPlanFile, buildPlan, packageSetConfig) <- loadStackageBuildPlan hackageDb stackResolver opts sopts
88 let
91 let
89 overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
92 overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
90 stackageSetConfig = if opts ^. optTweaks . tExtraDepsRevisionLatest
93 stackageSetConfig = if opts ^. optTweaks . tExtraDepsRevisionLatest
@@ -112,7 +115,7 @@ run = do
112
115
113 -- Generate Stackage packages from resolver
116 -- Generate Stackage packages from resolver
114 OriginResolver stackResolver -> do
117 OriginResolver stackResolver -> do
115− (buildPlanFile, buildPlan, packageSetConfig) <- loadStackageBuildPlan stackResolver opts sopts
118+ (buildPlanFile, buildPlan, packageSetConfig) <- loadStackageBuildPlan hackageDb stackResolver opts sopts
116 nodes <- buildStackagePackages packageSetConfig buildPlan
119 nodes <- buildStackagePackages packageSetConfig buildPlan
117 let overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
120 let overrideConfig = mkOverrideConfig opts (siGhcVersion $ bpSystemInfo buildPlan)
118 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
121 writeOutFile buildPlanFile (opts ^. optOutStackagePackages)
@@ -122,12 +125,12 @@ run = do
122 writeOutFile buildPlanFile (opts ^. optOutDerivation)
125 writeOutFile buildPlanFile (opts ^. optOutDerivation)
123 $ PP.pPrintHaskellPackages overrideConfig
126 $ PP.pPrintHaskellPackages overrideConfig
124
127
125−loadStackageBuildPlan :: StackResolver -> Options -> StackageOptions -> IO (FilePath, BuildPlan, PackageSetConfig)
128+loadStackageBuildPlan :: DB.HackageDB -> StackResolver -> Options -> StackageOptions -> IO (FilePath, BuildPlan, PackageSetConfig)
126−loadStackageBuildPlan stackResolver opts sopts = do
129+loadStackageBuildPlan hackageDb stackResolver opts sopts = do
127 let buildPlanFile = LH.buildPlanFilePath (sopts ^. soptLtsHaskellRepo) stackResolver
130 let buildPlanFile = LH.buildPlanFilePath (sopts ^. soptLtsHaskellRepo) stackResolver
128 buildPlan <- LH.loadBuildPlan buildPlanFile
131 buildPlan <- LH.loadBuildPlan buildPlanFile
129 packageSetConfig <- LH.buildPackageSetConfig
132 packageSetConfig <- LH.buildPackageSetConfig
130− (opts ^. optHackageDb)
133+ hackageDb
131 (sopts ^. soptAllCabalHashesRepo)
134 (sopts ^. soptAllCabalHashesRepo)
132 (opts ^. optNixpkgsRepository)
135 (opts ^. optNixpkgsRepository)
133 buildPlan
136 buildPlan
src/Runner/Cli.hs+7−9
@@ -5,7 +5,6 @@ import Data.Monoid ( (<>) )
5import Data.Text as T
5import Data.Text as T
6import qualified Distribution.Compat.ReadP as P
6import qualified Distribution.Compat.ReadP as P
7import Distribution.Compiler as Compiler
7import Distribution.Compiler as Compiler
8−import Distribution.Nixpkgs.Haskell.Stack
9import Distribution.System as System
8import Distribution.System as System
10import qualified Distribution.Text as Text
9import qualified Distribution.Text as Text
11import Options.Applicative as Opts
10import Options.Applicative as Opts
@@ -55,7 +54,7 @@ data Options = Options
55 , _optDoCheckPackages :: Bool
54 , _optDoCheckPackages :: Bool
56 , _optDoHaddockPackages :: Bool
55 , _optDoHaddockPackages :: Bool
57 , _optTweaks :: Tweaks
56 , _optTweaks :: Tweaks
58− , _optHackageDb :: Maybe HackageDb
57+ , _optHackageDb :: Maybe FilePath
59 , _optNixpkgsRepository :: FilePath
58 , _optNixpkgsRepository :: FilePath
60 , _optCompilerId :: CompilerId
59 , _optCompilerId :: CompilerId
61 , _optPlatform :: Platform
60 , _optPlatform :: Platform
@@ -83,7 +82,7 @@ options = Options
83 <*> doCheckPackages
82 <*> doCheckPackages
84 <*> doHaddockPackages
83 <*> doHaddockPackages
85 <*> tweaks
84 <*> tweaks
86− <*> optional hackageDb
85+ <*> optional optionHackageDb
87 <*> nixpkgsRepository
86 <*> nixpkgsRepository
88 <*> compilerId
87 <*> compilerId
89 <*> platform
88 <*> platform
@@ -192,12 +191,11 @@ configOrigin =
192
191
193-- required for cabal2nix
192-- required for cabal2nix
194
193
195−hackageDb :: Parser HackageDb
194+optionHackageDb :: Parser FilePath
196−hackageDb = HackageDb <$>
195+optionHackageDb = option str
197− option text
198− ( long "hackage-db"
196+ ( long "hackage-db"
199− <> metavar "HACKAGE_DB"
197+ <> metavar "HACKAGE_DB"
200− <> help "path to the local hackage db in tar format" )
198+ <> help "path to the local hackage db in tar format" )
201
199
202cabalFlag :: Parser CabalFlag
200cabalFlag :: Parser CabalFlag
203cabalFlag = CabalFlag <$>
201cabalFlag = CabalFlag <$>
stack-ghc-7103.yamldeleted−26
@@ -1,26 +0,0 @@
1−resolver: lts-6.35
2−extra-deps:
3− - aeson-1.2.3.0
4− - amazonka-1.4.5
5− - amazonka-core-1.4.5
6− - amazonka-s3-1.4.5
7− - Cabal-2.0.0.2
8− - cabal2nix-2.5
9− - chunked-data-0.3.0
10− - classy-prelude-1.2.0.1
11− - classy-prelude-conduit-1.2.0
12− - conduit-combinators-1.1.1
13− - distribution-nixpkgs-1.1
14− - hopenssl-2.2.1
15− - http-client-0.5.7.1
16− - http-client-tls-0.3.5.1
17− - http-conduit-2.2.3.2
18− - inflections-0.3.0.0
19− - megaparsec-5.3.1
20− - mono-traversable-1.0.4.0
21− - mono-traversable-instances-0.1.0.0
22− - stackage-curator-0.15.1.0
23− - store-0.4.3.2
24− - store-core-0.4.1
25− - th-abstraction-0.2.6.0
26− - th-utilities-0.2.0.1
stack-ghc-802.yaml+3−2
@@ -1,7 +1,8 @@
1−resolver: lts-9.17
1+resolver: lts-9.21
2extra-deps:
2extra-deps:
3- Cabal-2.0.0.2
3- Cabal-2.0.0.2
4−- cabal2nix-2.5
4+- cabal2nix-2.7.2
5+- hackage-db-2.0
5- stackage-curator-0.15.0.0
6- stackage-curator-0.15.0.0
6nix:
7nix:
7 packages: [icu openssl zlib]
8 packages: [icu openssl zlib]
stack-ghc-821.yamldeleted−4
@@ -1,4 +0,0 @@
1−resolver: nightly-2017-11-24
2−extra-deps:
3− - cabal2nix-2.5
4− - hackage-db-1.22
stack-ghc-822.yaml+1−2
@@ -1,4 +1,3 @@
1resolver: lts-10.0
1resolver: lts-10.0
2extra-deps:
2extra-deps:
3− - cabal2nix-2.5
3+ - cabal2nix-2.7.2
4− - hackage-db-1.22
stackage2nix.cabal+2−2
@@ -31,11 +31,11 @@ library
31 , LtsHaskell
31 , LtsHaskell
32 , Paths_stackage2nix
32 , Paths_stackage2nix
33 build-depends: base > 4.7 && < 5
33 build-depends: base > 4.7 && < 5
34− , Cabal > 1.24
34+ , Cabal > 2
35 , QuickCheck
35 , QuickCheck
36 , aeson
36 , aeson
37 , bytestring
37 , bytestring
38− , cabal2nix >= 2.5
38+ , cabal2nix >= 2.7.2
39 , containers
39 , containers
40 , deepseq
40 , deepseq
41 , distribution-nixpkgs >= 1.1
41 , distribution-nixpkgs >= 1.1