git.iko.soy/typeable/cabal2nix
on master help sign in
Fix build for hpack-0.22.0.

Versions of hpack >= 0.22 redefine some functions. The extra filepath seems to just be a configuration file which we should probably just ignore. Ref https://github.com/fpco/stackage/issues/3208

commit2160534d0c8870d258bd381c81ee6ad275258cf2 authorTom Smalley <tfsmalley@gmail.com> dateTue 23 Jan 2018, 17:52 (9 years ago) parent42b218e
2 files changed+10−1
cabal2nix.cabal+1−1 src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+9
cabal2nix.cabal+1−1
@@ -104,7 +104,7 @@ library
104104 , filepath
105105 , hackage-db >2
106106 , hopenssl >=2
107− , hpack == 0.21.*
107+ , hpack >= 0.21 && < 0.23
108108 , language-nix
109109 , lens
110110 , optparse-applicative
src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+9
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12module Distribution.Nixpkgs.Haskell.PackageSourceSpec
23 ( Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage
34 ) where
@@ -191,10 +192,18 @@ handleIO = Exception.handle
191192
192193hpackDirectory :: FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
193194hpackDirectory dir = do
195+#if MIN_VERSION_hpack(0,22,0)
196+ mPackage <- liftIO $ Hpack.readPackageConfig "" $ dir </> "package.yaml"
197+#else
194198 mPackage <- liftIO $ Hpack.readPackageConfig $ dir </> "package.yaml"
199+#endif
195200 case mPackage of
196201 Left err -> liftIO $ hPutStrLn stderr ("*** hpack error: " ++ show err ++ ". Exiting.") >> exitFailure
202+#if MIN_VERSION_hpack(0,22,0)
203+ Right (pkg', _) -> do
204+#else
197205 Right (_, pkg') -> do
206+#endif
198207 let hpackOutput = Hpack.renderPackage Hpack.defaultRenderSettings 2 [] [] pkg'
199208 hash = printSHA256 $ digestString (digestByName "sha256") hpackOutput
200209 case parseGenericPackageDescription hpackOutput of