git.iko.soy/typeable/cabal2nix
on master help sign in
Require Cabal 2.x.
commitcbae3e6a3bbc2623a24b784c717b55a9d035f044 authorPeter Simons <simons@cryp.to> dateMon 24 Jul 2017, 12:45 (9 years ago) parent360fc39
15 files changed+104−118
.travis.yml+3 cabal2nix.cabal+5−5 hackage2nix/HackageGit.hs+3−3 hackage2nix/Main.hs+1−1 package.yaml+2−2 src/Cabal2nix.hs+4−4 src/Distribution/Nixpkgs/Haskell/Derivation.hs+2−2 src/Distribution/Nixpkgs/Haskell/FromCabal.hs+15−25 src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+4−4 src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs+29−27 src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+2−2 src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs+12−10 src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+1−1 src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+15−21 src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+6−11
.travis.yml+3
@@ -41,6 +41,9 @@ matrix:
4141 - compiler: "ghc-8.0.2"
4242 # env: TEST=--disable-tests BENCH=--disable-benchmarks
4343 addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
44+ - compiler: "ghc-8.2.1"
45+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
46+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
4447
4548before_install:
4649 - HC=${CC}
cabal2nix.cabal+5−5
@@ -66,7 +66,7 @@ author: Peter Simons,
6666maintainer: Peter Simons <simons@cryp.to>
6767license: BSD3
6868license-file: LICENSE
69−tested-with: GHC > 7.10 && < 8.1
69+tested-with: GHC > 7.10 && < 8.3
7070build-type: Custom
7171cabal-version: >= 1.10
7272
@@ -93,7 +93,7 @@ library
9393 , ansi-wl-pprint
9494 , base < 5
9595 , bytestring
96− , Cabal > 1.24 && < 2
96+ , Cabal > 2
9797 , containers
9898 , deepseq >= 1.4
9999 , directory
@@ -141,7 +141,7 @@ executable cabal2nix
141141 , ansi-wl-pprint
142142 , base < 5
143143 , bytestring
144− , Cabal > 1.24 && < 2
144+ , Cabal > 2
145145 , containers
146146 , deepseq >= 1.4
147147 , directory
@@ -173,7 +173,7 @@ executable hackage2nix
173173 , ansi-wl-pprint
174174 , base < 5
175175 , bytestring
176− , Cabal > 1.24 && < 2
176+ , Cabal > 2
177177 , containers
178178 , deepseq >= 1.4
179179 , directory
@@ -212,7 +212,7 @@ test-suite doctests
212212 , ansi-wl-pprint
213213 , base < 5
214214 , bytestring
215− , Cabal > 1.24 && < 2
215+ , Cabal > 2
216216 , containers
217217 , deepseq >= 1.4
218218 , directory
hackage2nix/HackageGit.hs+3−3
@@ -16,7 +16,7 @@ import Distribution.Nixpkgs.Hashes
1616import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
1717import Distribution.Package
1818import Distribution.PackageDescription
19−import Distribution.PackageDescription.Parse ( parsePackageDescription, ParseResult(..) )
19+import Distribution.PackageDescription.Parse ( parseGenericPackageDescription, ParseResult(..) )
2020import Distribution.Text
2121import Distribution.Version
2222import OpenSSL.Digest ( digest, digestByName )
@@ -31,7 +31,7 @@ readHackage path = getSubDirs path >>= foldM discoverPackageVersions mempty
3131 discoverPackageVersions :: Hackage -> String -> IO Hackage
3232 discoverPackageVersions db pkg = do
3333 vs <- getSubDirs (path </> pkg)
34− return (Map.insert (PackageName pkg) (Set.fromList (Prelude.map fromString vs)) db)
34+ return (Map.insert (mkPackageName pkg) (Set.fromList (Prelude.map fromString vs)) db)
3535
3636getSubDirs :: FilePath -> IO [FilePath]
3737getSubDirs path = do
@@ -47,7 +47,7 @@ readPackage :: FilePath -> PackageIdentifier -> IO (GenericPackageDescription, S
4747readPackage dirPrefix (PackageIdentifier name version) = do
4848 let cabalFile = dirPrefix </> unPackageName name </> display version </> unPackageName name <.> "cabal"
4949 buf <- BS.readFile cabalFile
50− cabal <- case parsePackageDescription (decodeUTF8 buf) of
50+ cabal <- case parseGenericPackageDescription (decodeUTF8 buf) of
5151 ParseOk _ a -> return a
5252 ParseFailed err -> fail (cabalFile ++ ": " ++ show err)
5353 return (cabal, printSHA256 (digest (digestByName "sha256") buf))
hackage2nix/Main.hs+1−1
@@ -201,4 +201,4 @@ resolveConstraint' (Dependency name vrange) hackage
201201 | otherwise = Nothing
202202
203203mangle :: PackageIdentifier -> String
204−mangle (PackageIdentifier (PackageName name) v) = name ++ '_' : [ if c == '.' then '_' else c | c <- display v ]
204+mangle (PackageIdentifier name v) = unPackageName name ++ '_' : [ if c == '.' then '_' else c | c <- display v ]
package.yaml+2−2
@@ -59,7 +59,7 @@ license-file: LICENSE
5959github: nixos/cabal2nix
6060category: Distribution, Nix
6161stability: stable
62−tested-with: GHC > 7.10 && < 8.1
62+tested-with: GHC > 7.10 && < 8.3
6363description: >
6464 Convert Cabal files into Nix build instructions. Users of Nix can install the
6565 latest version by running:
@@ -84,7 +84,7 @@ dependencies:
8484 - ansi-wl-pprint
8585 - base < 5
8686 - bytestring
87− - Cabal > 1.24 && < 2
87+ - Cabal > 2
8888 - containers
8989 - deepseq >= 1.4
9090 - directory
src/Cabal2nix.hs+4−4
@@ -19,7 +19,7 @@ import Distribution.Nixpkgs.Haskell
1919import Distribution.Nixpkgs.Haskell.FromCabal
2020import Distribution.Nixpkgs.Haskell.PackageSourceSpec
2121import Distribution.Nixpkgs.Meta
22−import Distribution.PackageDescription ( FlagName(..), FlagAssignment )
22+import Distribution.PackageDescription ( mkFlagName, FlagAssignment )
2323import Distribution.Simple.Utils ( lowercase )
2424import Distribution.System
2525import Distribution.Text
@@ -34,7 +34,7 @@ import Text.PrettyPrint.HughesPJClass ( Doc, Pretty(..), text, vcat, hcat, semi
3434data Options = Options
3535 { optSha256 :: Maybe String
3636 , optMaintainer :: [String]
37−--, optPlatform :: [String] -- TODO: fix command line handling of platforms
37+--, optPlatform :: [String] -- TODO: fix command line handling of platforms
3838 , optHaddock :: Bool
3939 , optDoCheck :: Bool
4040 , optJailbreak :: Bool
@@ -176,5 +176,5 @@ cabal2nix args = do
176176
177177readFlagList :: [String] -> FlagAssignment
178178readFlagList = map tagWithValue
179− where tagWithValue ('-':fname) = (FlagName (lowercase fname), False)
180− tagWithValue fname = (FlagName (lowercase fname), True)
179+ where tagWithValue ('-':fname) = (mkFlagName (lowercase fname), False)
180+ tagWithValue fname = (mkFlagName (lowercase fname), True)
src/Distribution/Nixpkgs/Haskell/Derivation.hs+2−2
@@ -23,7 +23,7 @@ import Distribution.Nixpkgs.Haskell.BuildInfo
2323import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
2424import Distribution.Nixpkgs.Meta
2525import Distribution.Package
26−import Distribution.PackageDescription ( FlagAssignment, FlagName(..) )
26+import Distribution.PackageDescription ( FlagAssignment, unFlagName )
2727import GHC.Generics ( Generic )
2828import Language.Nix
2929import Language.Nix.PrettyPrinting
@@ -137,7 +137,7 @@ instance Pretty Derivation where
137137 , Set.fromList ["fetch" ++ derivKind _src | derivKind _src /= "" && not isHackagePackage]
138138 ]
139139
140− renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text f | (FlagName f, enable) <- _cabalFlags ]
140+ renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text (unFlagName f) | (f, enable) <- _cabalFlags ]
141141 ++ map text (toAscList _configureFlags)
142142 isHackagePackage = "mirror://hackage/" `isPrefixOf` derivUrl _src
143143 sourceAttr (DerivationSource{..})
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+15−25
@@ -7,7 +7,6 @@ module Distribution.Nixpkgs.Haskell.FromCabal
77 )
88 where
99
10−import Control.Arrow ( second )
1110import Control.Lens
1211import Data.Maybe
1312import Data.Set ( Set )
@@ -24,7 +23,10 @@ import qualified Distribution.Nixpkgs.Meta as Nix
2423import Distribution.Package
2524import Distribution.PackageDescription
2625import qualified Distribution.PackageDescription as Cabal
27−import Distribution.PackageDescription.Configuration
26+import Distribution.Types.LegacyExeDependency as Cabal
27+import Distribution.Types.PkgconfigDependency as Cabal
28+import Distribution.PackageDescription.Configuration as Cabal
29+import Distribution.Types.ComponentRequestedSpec as Cabal
2830import Distribution.System
2931import Distribution.Text ( display )
3032import Distribution.Version
@@ -40,7 +42,13 @@ fromGenericPackageDescription haskellResolver nixpkgsResolver arch compiler flag
4042 -- We have to call the Cabal finalizer several times with different resolver
4143 -- functions, and this convenience function makes our code shorter.
4244 finalize :: HaskellResolver -> Either [Dependency] (PackageDescription,FlagAssignment)
43− finalize resolver = finalizePackageDescription flags resolver arch compiler constraints (enableBenchmarks (enableTests genDesc))
45+ finalize resolver = finalizePD flags requestedComponents resolver arch compiler constraints genDesc
46+
47+ requestedComponents :: ComponentRequestedSpec
48+ requestedComponents = defaultComponentRequestedSpec
49+ { testsRequested = True
50+ , benchmarksRequested = True
51+ }
4452
4553 descr :: PackageDescription; missingDeps :: [Dependency]
4654 (descr,missingDeps) = case finalize jailbrokenResolver of
@@ -93,7 +101,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags (Packag
93101 xrev = maybe 0 read (lookup "x-revision" customFieldsPD)
94102
95103 resolveInHackage :: Identifier -> Binding
96− resolveInHackage i | (i^.ident) `elem` [ n | (Dependency (PackageName n) _) <- missingDeps ] = bindNull i
104+ resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _) <- missingDeps ] = bindNull i
97105 | otherwise = binding # (i, path # ["self",i]) -- TODO: "self" shouldn't be hardcoded.
98106
99107 goodScopes :: Set [Identifier]
@@ -109,15 +117,15 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags (Packag
109117 | otherwise = bindNull i
110118
111119 resolveInHackageThenNixpkgs :: Identifier -> Binding
112− resolveInHackageThenNixpkgs i | haskellResolver (Dependency (PackageName (i^.ident)) anyVersion) = resolveInHackage i
120+ resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion) = resolveInHackage i
113121 | otherwise = resolveInNixpkgs i
114122
115123 convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo
116124 convertBuildInfo Cabal.BuildInfo {..} = mempty
117125 & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- targetBuildDepends ]
118126 & system .~ Set.fromList [ resolveInNixpkgs y | x <- extraLibs, y <- libNixName x ]
119− & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | Dependency (PackageName x) _ <- pkgconfigDepends, y <- libNixName x ]
120− & tool .~ Set.fromList [ resolveInHackageThenNixpkgs y | Dependency (PackageName x) _ <- buildTools, y <- buildToolNixName x ]
127+ & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | PkgconfigDependency x _ <- pkgconfigDepends, y <- libNixName (unPkgconfigName x) ]
128+ & tool .~ Set.fromList [ resolveInHackageThenNixpkgs y | LegacyExeDependency x _ <- buildTools, y <- buildToolNixName x ]
121129
122130 convertSetupBuildInfo :: Cabal.SetupBuildInfo -> Nix.BuildInfo
123131 convertSetupBuildInfo bi = mempty
@@ -125,21 +133,3 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags (Packag
125133
126134bindNull :: Identifier -> Binding
127135bindNull i = binding # (i, path # ["null"])
128−
129−enableTests :: GenericPackageDescription -> GenericPackageDescription
130−enableTests gd = gd { condTestSuites = flaggedTests }
131− where
132− flaggedTests :: [(String, CondTree ConfVar [Dependency] TestSuite)]
133− flaggedTests = map (second (mapTreeData enableTest)) (condTestSuites gd)
134−
135− enableTest :: TestSuite -> TestSuite
136− enableTest t = t { testEnabled = True }
137−
138−enableBenchmarks :: GenericPackageDescription -> GenericPackageDescription
139−enableBenchmarks gd = gd { condBenchmarks = flaggedBenchmarks }
140− where
141− flaggedBenchmarks :: [(String, CondTree ConfVar [Dependency] Benchmark)]
142− flaggedBenchmarks = map (second (mapTreeData enableBenchmark)) (condBenchmarks gd)
143−
144− enableBenchmark :: Benchmark -> Benchmark
145− enableBenchmark t = t { benchmarkEnabled = True }
src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs+4−4
@@ -6,7 +6,7 @@ import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
66
77import Distribution.Package
88import Distribution.PackageDescription
9−import Data.Version
9+import Distribution.Version
1010
1111configureCabalFlags :: PackageIdentifier -> FlagAssignment
1212configureCabalFlags (PackageIdentifier name version)
@@ -38,7 +38,7 @@ configureCabalFlags (PackageIdentifier name version)
3838 | name == "haskeline" = [enable "terminfo"]
3939 | name == "haste-compiler" = [enable "portable"]
4040 | name == "highlighting-kate" = [enable "pcre-light"]
41− | name == "hlibsass" && version >= Version [0,1,5] []
41+ | name == "hlibsass" && version >= mkVersion [0,1,5]
4242 = [enable "externalLibsass"]
4343 | name == "hmatrix" = [enable "openblas"]
4444 | name == "hslua" = [enable "system-lua"]
@@ -55,7 +55,7 @@ configureCabalFlags (PackageIdentifier name version)
5555 | otherwise = []
5656
5757enable :: String -> (FlagName,Bool)
58−enable name = (FlagName name, True)
58+enable name = (mkFlagName name, True)
5959
6060disable :: String -> (FlagName,Bool)
61−disable name = (FlagName name, False)
61+disable name = (mkFlagName name, False)
src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs+29−27
@@ -1,37 +1,39 @@
1+{-# LANGUAGE ViewPatterns #-}
2+
13module Distribution.Nixpkgs.Haskell.FromCabal.License ( fromCabalLicense ) where
24
35import Distribution.Nixpkgs.License
46import Distribution.License ( License(..), knownLicenses )
57import Distribution.Text (display)
68import Data.List (intercalate)
7−import Data.Version
9+import Distribution.Version
810
911-- TODO: Programatically strip trailing zeros from license version numbers.
1012
1113fromCabalLicense :: Distribution.License.License -> Distribution.Nixpkgs.License.License
12−fromCabalLicense (GPL Nothing) = Unknown (Just "GPL")
13−fromCabalLicense (GPL (Just (Version [2] []))) = Known "stdenv.lib.licenses.gpl2"
14−fromCabalLicense (GPL (Just (Version [3] []))) = Known "stdenv.lib.licenses.gpl3"
15−fromCabalLicense (GPL (Just (Version [3,0] []))) = Known "stdenv.lib.licenses.gpl3"
16−fromCabalLicense (LGPL Nothing) = Unknown (Just "LGPL")
17−fromCabalLicense (LGPL (Just (Version [2,1] []))) = Known "stdenv.lib.licenses.lgpl21"
18−fromCabalLicense (LGPL (Just (Version [2] []))) = Known "stdenv.lib.licenses.lgpl2"
19−fromCabalLicense (LGPL (Just (Version [3] []))) = Known "stdenv.lib.licenses.lgpl3"
20−fromCabalLicense (LGPL (Just (Version [3,0] []))) = Known "stdenv.lib.licenses.lgpl3"
21−fromCabalLicense (AGPL Nothing) = Unknown (Just "AGPL")
22−fromCabalLicense (AGPL (Just (Version [3] []))) = Known "stdenv.lib.licenses.agpl3"
23−fromCabalLicense (AGPL (Just (Version [3,0] []))) = Known "stdenv.lib.licenses.agpl3"
24−fromCabalLicense (MPL (Version [2,0] [])) = Known "stdenv.lib.licenses.mpl20"
25−fromCabalLicense BSD2 = Known "stdenv.lib.licenses.bsd2"
26−fromCabalLicense BSD3 = Known "stdenv.lib.licenses.bsd3"
27−fromCabalLicense BSD4 = Known "stdenv.lib.licenses.bsdOriginal"
28−fromCabalLicense MIT = Known "stdenv.lib.licenses.mit"
29−fromCabalLicense PublicDomain = Known "stdenv.lib.licenses.publicDomain"
30−fromCabalLicense UnspecifiedLicense = Known "stdenv.lib.licenses.unfree"
31−fromCabalLicense AllRightsReserved = Known "stdenv.lib.licenses.unfree"
32−fromCabalLicense (Apache Nothing) = Known "stdenv.lib.licenses.asl20"
33−fromCabalLicense (Apache (Just (Version [2,0] []))) = Known "stdenv.lib.licenses.asl20"
34−fromCabalLicense ISC = Known "stdenv.lib.licenses.isc"
35−fromCabalLicense OtherLicense = Unknown Nothing
36−fromCabalLicense l = error $ "Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown license"
37− ++ show l ++"\nChoose one of: " ++ intercalate ", " (map display knownLicenses)
14+fromCabalLicense (GPL Nothing) = Unknown (Just "GPL")
15+fromCabalLicense (GPL (Just (versionNumbers -> [2]))) = Known "stdenv.lib.licenses.gpl2"
16+fromCabalLicense (GPL (Just (versionNumbers -> [3]))) = Known "stdenv.lib.licenses.gpl3"
17+fromCabalLicense (GPL (Just (versionNumbers -> [3,0]))) = Known "stdenv.lib.licenses.gpl3"
18+fromCabalLicense (LGPL Nothing) = Unknown (Just "LGPL")
19+fromCabalLicense (LGPL (Just (versionNumbers -> [2,1]))) = Known "stdenv.lib.licenses.lgpl21"
20+fromCabalLicense (LGPL (Just (versionNumbers -> [2]))) = Known "stdenv.lib.licenses.lgpl2"
21+fromCabalLicense (LGPL (Just (versionNumbers -> [3]))) = Known "stdenv.lib.licenses.lgpl3"
22+fromCabalLicense (LGPL (Just (versionNumbers -> [3,0]))) = Known "stdenv.lib.licenses.lgpl3"
23+fromCabalLicense (AGPL Nothing) = Unknown (Just "AGPL")
24+fromCabalLicense (AGPL (Just (versionNumbers -> [3]))) = Known "stdenv.lib.licenses.agpl3"
25+fromCabalLicense (AGPL (Just (versionNumbers -> [3,0]))) = Known "stdenv.lib.licenses.agpl3"
26+fromCabalLicense (MPL (versionNumbers -> [2,0])) = Known "stdenv.lib.licenses.mpl20"
27+fromCabalLicense BSD2 = Known "stdenv.lib.licenses.bsd2"
28+fromCabalLicense BSD3 = Known "stdenv.lib.licenses.bsd3"
29+fromCabalLicense BSD4 = Known "stdenv.lib.licenses.bsdOriginal"
30+fromCabalLicense MIT = Known "stdenv.lib.licenses.mit"
31+fromCabalLicense PublicDomain = Known "stdenv.lib.licenses.publicDomain"
32+fromCabalLicense UnspecifiedLicense = Known "stdenv.lib.licenses.unfree"
33+fromCabalLicense AllRightsReserved = Known "stdenv.lib.licenses.unfree"
34+fromCabalLicense (Apache Nothing) = Known "stdenv.lib.licenses.asl20"
35+fromCabalLicense (Apache (Just (versionNumbers -> [2,0]))) = Known "stdenv.lib.licenses.asl20"
36+fromCabalLicense ISC = Known "stdenv.lib.licenses.isc"
37+fromCabalLicense OtherLicense = Unknown Nothing
38+fromCabalLicense l = error $ "Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown license"
39+ ++ show l ++"\nChoose one of: " ++ intercalate ", " (map display knownLicenses)
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs+2−2
@@ -10,8 +10,8 @@ import Language.Nix
1010
1111-- | Map Cabal names to Nix attribute names.
1212toNixName :: PackageName -> Identifier
13−toNixName (PackageName "") = error "toNixName: invalid empty package name"
14−toNixName (PackageName n) = fromString n
13+toNixName "" = error "toNixName: invalid empty package name"
14+toNixName n = fromString (unPackageName n)
1515
1616-- | Map library names specified in Cabal files to Nix package identifiers.
1717--
src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs+12−10
@@ -1,3 +1,5 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+
13module Distribution.Nixpkgs.Haskell.FromCabal.Normalize ( normalize, normalizeCabalFlags ) where
24
35import Control.Lens
@@ -8,7 +10,7 @@ import Data.String
810import Distribution.Nixpkgs.Haskell
911import Distribution.Nixpkgs.Meta
1012import Distribution.Package
11−import Distribution.PackageDescription ( FlagAssignment, FlagName(..) )
13+import Distribution.PackageDescription ( FlagAssignment, mkFlagName, unFlagName )
1214import Distribution.Simple.Utils ( lowercase )
1315import Language.Nix hiding ( quote )
1416
@@ -20,12 +22,12 @@ normalize drv = drv
2022 & over benchmarkDepends (normalizeBuildInfo (packageName drv))
2123 & over metaSection normalizeMeta
2224 & over cabalFlags normalizeCabalFlags
23− & jailbreak %~ (&& (packageName drv /= PackageName "jailbreak-cabal"))
25+ & jailbreak %~ (&& (packageName drv /= "jailbreak-cabal"))
2426
2527normalizeBuildInfo :: PackageName -> BuildInfo -> BuildInfo
26−normalizeBuildInfo (PackageName pname) bi = bi
27− & haskell %~ Set.filter (\b -> view localName b /= fromString pname)
28− & tool %~ Set.filter (\b -> view localName b /= fromString pname)
28+normalizeBuildInfo pname bi = bi
29+ & haskell %~ Set.filter (\b -> view localName b /= fromString (unPackageName pname))
30+ & tool %~ Set.filter (\b -> view localName b /= fromString (unPackageName pname))
2931
3032normalizeMeta :: Meta -> Meta
3133normalizeMeta meta = meta
@@ -45,14 +47,14 @@ quote ('"':cs) = '\\' : '"' : quote cs
4547quote (c:cs) = c : quote cs
4648quote [] = []
4749
48−-- |When a flag is specified multiple times, the first occurrence
49−-- counts. This is counter-intuitive, IMHO, but it's how cabal does it.
50−-- Flag names are spelled in all lowercase.
50+-- | When a flag is specified multiple times, the first occurrence counts. This
51+-- is counter-intuitive, IMHO, but it's how cabal does it. Flag names are
52+-- spelled in all lowercase.
5153--
52−-- >>> normalizeCabalFlags [(FlagName "foo", True), (FlagName "FOO", True), (FlagName "Foo", False)]
54+-- >>> normalizeCabalFlags [(mkFlagName "foo", True), (mkFlagName "FOO", True), (mkFlagName "Foo", False)]
5355-- [(FlagName "foo",True)]
5456
5557normalizeCabalFlags :: FlagAssignment -> FlagAssignment
5658normalizeCabalFlags flags' = nubBy ((==) `on` fst) (sortBy (compare `on` fst) flags)
5759 where
58− flags = [ (FlagName (lowercase n), b) | (FlagName n, b) <- flags' ]
60+ flags = [ (mkFlagName (lowercase (unFlagName n)), b) | (n, b) <- flags' ]
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+1−1
@@ -27,7 +27,7 @@ fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesW
2727 collidesWithHaskellName b = view localName b `Set.member` buildDeps
2828
2929 myName :: Identifier
30− myName = ident # n where PackageName n = packageName drv
30+ myName = ident # unPackageName (packageName drv)
3131
3232 buildDeps :: Set Identifier
3333 buildDeps = Set.delete myName (setOf (dependencies . haskell . folded . localName) drv)
src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+15−21
@@ -1,7 +1,3 @@
1−{-# LANGUAGE CPP #-}
2−{-# LANGUAGE OverloadedStrings #-}
3−{-# LANGUAGE DeriveGeneric #-}
4−{-# LANGUAGE StandaloneDeriving #-}
51{-# OPTIONS_GHC -fno-warn-orphans #-}
62
73module Distribution.Nixpkgs.Haskell.OrphanInstances ( ) where
@@ -13,45 +9,47 @@ import qualified Data.Text as T
139import Data.Yaml
1410import Distribution.Compiler
1511import Distribution.License
16−import Distribution.ModuleName hiding ( main, fromString )
1712import Distribution.Package
1813import Distribution.PackageDescription
1914import Distribution.System
2015import Distribution.Text
16+import Distribution.Types.CondTree
17+import Distribution.Types.ExecutableScope
18+import Distribution.Types.ForeignLib
19+import Distribution.Types.ForeignLibOption
20+import Distribution.Types.ForeignLibType
21+import Distribution.Types.IncludeRenaming
22+import Distribution.Types.Mixin
2123import Distribution.Version
2224import Language.Haskell.Extension
2325
24−#if !MIN_VERSION_Cabal(1,23,0)
25−import GHC.Generics ( Generic )
26−deriving instance Generic (CondTree v c a)
27−deriving instance Generic (Condition a)
28−deriving instance Generic ConfVar
29−deriving instance Generic Flag
30−deriving instance Generic GenericPackageDescription
31−#else
3226instance NFData SetupBuildInfo
33−#endif
34−
3527instance (NFData v, NFData c, NFData a) => NFData (CondTree v c a)
28+instance (NFData v, NFData c, NFData a) => NFData (CondBranch v c a)
3629instance NFData Arch
3730instance NFData Benchmark
3831instance NFData BenchmarkInterface
3932instance NFData BenchmarkType
4033instance NFData BuildInfo
4134instance NFData BuildType
35+instance NFData LibVersionInfo
4236instance NFData CompilerFlavor
4337instance NFData ConfVar
44−instance NFData Dependency
38+instance NFData ExecutableScope
39+instance NFData IncludeRenaming
40+instance NFData ForeignLibType
41+instance NFData ForeignLibOption
4542instance NFData Executable
4643instance NFData Extension
4744instance NFData Flag
45+instance NFData Mixin
4846instance NFData FlagName
4947instance NFData GenericPackageDescription
5048instance NFData KnownExtension
5149instance NFData Language
5250instance NFData Library
51+instance NFData ForeignLib
5352instance NFData License
54−instance NFData ModuleName
5553instance NFData ModuleReexport
5654instance NFData ModuleRenaming
5755instance NFData OS
@@ -62,16 +60,12 @@ instance NFData SourceRepo
6260instance NFData TestSuite
6361instance NFData TestSuiteInterface
6462instance NFData TestType
65−instance NFData VersionRange
6663instance NFData a => NFData (Condition a)
6764instance NFData Platform
6865instance NFData CompilerInfo
6966instance NFData CompilerId
7067instance NFData AbiTag
7168
72−instance IsString PackageName where
73− fromString = text2isString "PackageName"
74−
7569instance IsString Version where
7670 fromString = text2isString "Version"
7771
src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs+6−11
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Maybe
99import qualified Data.ByteString.Lazy.Char8 as LBS8
1010import Data.List ( isSuffixOf, isPrefixOf )
1111import Data.Maybe
12−import Data.Version
1312import Distribution.Hackage.DB.Parsed
1413import Distribution.Nixpkgs.Fetch
1514import Distribution.Nixpkgs.Hashes
@@ -17,7 +16,7 @@ import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
1716import qualified Distribution.Package as Cabal
1817import Distribution.PackageDescription
1918import qualified Distribution.PackageDescription as Cabal
20−import Distribution.Text ( simpleParse )
19+import Distribution.Text ( simpleParse, display )
2120import OpenSSL.Digest ( digest, digestByName )
2221import System.Directory ( doesDirectoryExist, doesFileExist, createDirectoryIfMissing, getHomeDirectory, getDirectoryContents )
2322import System.Exit ( exitFailure )
@@ -35,7 +34,6 @@ getPackage optHackageDB source = do
3534 (derivSource, pkgDesc) <- fetchOrFromDB optHackageDB source
3635 flip Package pkgDesc <$> maybe (sourceFromHackage (sourceHash source) (showPackageIdentifier pkgDesc) $ sourceCabalDir source) return derivSource
3736
38−
3937fetchOrFromDB :: Maybe String -> Source -> IO (Maybe DerivationSource, Cabal.GenericPackageDescription)
4038fetchOrFromDB optHackageDB src
4139 | "cabal://" `isPrefixOf` sourceUrl src = fmap ((,) Nothing) . fromDB optHackageDB . drop (length "cabal://") $ sourceUrl src
@@ -54,15 +52,12 @@ fromDB optHackageDB pkg = do
5452 Just r -> return r
5553 Nothing -> hPutStrLn stderr "*** no such package in the cabal database (did you run cabal update?). " >> exitFailure
5654 where
55+ pkgId :: Cabal.PackageIdentifier
5756 pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParse pkg)
58− Cabal.PackageName name = Cabal.pkgName pkgId
59− version = Cabal.pkgVersion pkgId
57+ name = Cabal.unPackageName (Cabal.packageName pkgId)
6058
6159 lookupVersion :: DB.Map DB.Version Cabal.GenericPackageDescription -> Maybe Cabal.GenericPackageDescription
62− lookupVersion
63− | null (versionBranch version) = fmap snd . listToMaybe . reverse . DB.toAscList
64− | otherwise = DB.lookup version
65−
60+ lookupVersion = fmap snd . listToMaybe . reverse . DB.toAscList
6661
6762readFileMay :: String -> IO (Maybe String)
6863readFileMay file = do
@@ -117,9 +112,9 @@ sourceFromHackage optHash pkgId cabalDir = do
117112 exitFailure
118113
119114showPackageIdentifier :: Cabal.GenericPackageDescription -> String
120−showPackageIdentifier pkgDesc = name ++ "-" ++ showVersion version where
115+showPackageIdentifier pkgDesc = name ++ "-" ++ display version where
121116 pkgId = Cabal.package . Cabal.packageDescription $ pkgDesc
122− Cabal.PackageName name = Cabal.packageName pkgId
117+ name = Cabal.unPackageName (Cabal.packageName pkgId)
123118 version = Cabal.packageVersion pkgId
124119
125120cabalFromPath :: FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)