git.iko.soy/typeable/stackage2nix
on master help sign in
Support cabal2nix >2.5
commitf6c27f04474d65fbe0a320341700542b90228f5d authorDmitry Bushev <bushevdv@gmail.com> dateMon 11 Dec 2017, 20:28 (9 years ago) parent412c0b5
3 files changed+26−16
src/Distribution/Nixpkgs/Haskell/Stack.hs+15−10 src/Language/Nix/FilePath.hs+6−6 src/LtsHaskell.hs+5
src/Distribution/Nixpkgs/Haskell/Stack.hs+15−10
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12module Distribution.Nixpkgs.Haskell.Stack where
23
34import Control.Lens
@@ -7,6 +8,7 @@ import Distribution.Compiler as Compiler
78import Distribution.Nixpkgs.Fetch
89import Distribution.Nixpkgs.Haskell.Derivation
910import Distribution.Nixpkgs.Haskell.FromCabal as FromCabal
11+import Distribution.Nixpkgs.Haskell.FromStack as FromStack
1012import Distribution.Nixpkgs.Haskell.PackageSourceSpec as PackageSourceSpec
1113import Distribution.PackageDescription as PackageDescription
1214import Distribution.System as System
@@ -41,9 +43,17 @@ getStackPackageFromDb
4143 -> StackPackage
4244 -> IO Package
4345getStackPackageFromDb optHackageDb stackPackage =
46+#if MIN_VERSION_cabal2nix(2,6,0)
4447 PackageSourceSpec.getPackage
48+ False
4549 (unHackageDb <$> optHackageDb)
50+ Nothing
4651 (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
52+#else
53+ PackageSourceSpec.getPackage
54+ (unHackageDb <$> optHackageDb)
55+ (stackLocationToSource (stackPackage ^. spLocation) (stackPackage ^. spDir))
56+#endif
4757
4858stackLocationToSource
4959 :: PackageLocation
@@ -83,17 +93,12 @@ packageDerivation conf optHackageDb stackPackage = do
8393 pkg <- getStackPackageFromDb optHackageDb stackPackage
8494 let
8595 drv = genericPackageDerivation conf pkg
86− & src .~ pkgSource pkg
87− -- TODO: remove after Nixos/Nixpkgs #27196 released
88− & enableSeparateDataOutput .~ False
8996 & subpath %~ flip fromMaybe (stackPackage ^. spDir)
90− return $ if stackPackage ^. spExtraDep
91− then drv
92− & doCheck &&~ conf ^. spcDoCheckStackage
93− & runHaddock &&~ conf ^. spcDoHaddockStackage
94− else drv
95− & doCheck &&~ conf ^. spcDoCheckPackages
96− & runHaddock &&~ conf ^. spcDoHaddockPackages
97+ isExtraDep = stackPackage ^. spExtraDep
98+ pconf = PackageConfig
99+ { enableCheck = if isExtraDep then conf ^. spcDoCheckStackage else conf ^. spcDoCheckPackages
100+ , enableHaddock = if isExtraDep then conf ^. spcDoHaddockStackage else conf ^. spcDoHaddockPackages }
101+ return $ finalizePackage pkg pconf drv
97102
98103genericPackageDerivation
99104 :: StackPackagesConfig
src/Language/Nix/FilePath.hs+6−6
@@ -11,7 +11,7 @@ import Distribution.Compat.ReadP as ReadP
1111import Distribution.Text
1212import GHC.Generics (Generic)
1313import Prelude hiding (FilePath)
14−import qualified System.FilePath.Posix as Posix
14+import qualified System.FilePath as FP
1515import Test.QuickCheck as QC
1616import Text.PrettyPrint as PP
1717
@@ -25,7 +25,7 @@ instance NFData FilePath where
2525 rnf = rnf . unFilePath
2626
2727instance Arbitrary FilePath where
28− arbitrary = FilePath <$> QC.suchThat arbitrary Posix.isValid
28+ arbitrary = FilePath <$> QC.suchThat arbitrary FP.isValid
2929 shrink = fmap FilePath . shrink . unFilePath
3030
3131instance Text FilePath where
@@ -38,12 +38,12 @@ instance IsString FilePath where
3838parseFilePath :: ReadP r FilePath
3939parseFilePath = do
4040 path <- ReadP.munch (const True)
41− if Posix.isValid path
41+ if FP.isValid path
4242 then pure (FilePath path)
4343 else pfail
4444
4545renderFilePath :: FilePath -> String
46−renderFilePath = Posix.combine "."
47− . Posix.normalise
48− . Posix.dropTrailingPathSeparator
46+renderFilePath = FP.combine "."
47+ . FP.normalise
48+ . FP.dropTrailingPathSeparator
4949 . unFilePath
src/LtsHaskell.hs+5
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12module LtsHaskell where
23
34import AllCabalHashes
@@ -46,7 +47,11 @@ getPackageFromRepo allCabalHashesPath mSha1Hash pkgId = do
4647 (error (display pkgId ++ ": meta data has no SHA256 hash for the tarball"))
4748 (view (mHashes . at "SHA256") meta)
4849 source = DerivationSource "url" ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") "" tarballSHA256
50+#if MIN_VERSION_cabal2nix(2,6,0)
51+ return $ Package source False pkgDesc
52+#else
4953 return $ Package source pkgDesc
54+#endif
5055
5156getPackageFromDb :: Maybe HackageDb -> PackageIdentifier -> IO Package
5257getPackageFromDb mHackageDb pkgId =