@@ -2,6 +2,7 @@ module Cabal2Nix.Package ( cabal2nix ) where
3import Cabal2Nix.License
3import Cabal2Nix.License
4import Cabal2Nix.PostProcess
4import Cabal2Nix.PostProcess
5+import Cabal2Nix.Normalize
5import Data.Maybe
6import Data.Maybe
6import Distribution.Compiler
7import Distribution.Compiler
7import qualified Distribution.Package as Cabal
8import qualified Distribution.Package as Cabal
@@ -16,20 +17,20 @@ import Data.List
16import Data.Char
17import Data.Char
18cabal2nix :: Cabal.GenericPackageDescription -> Derivation
19cabal2nix :: Cabal.GenericPackageDescription -> Derivation
19−cabal2nix cabal = postProcess $ MkDerivation
20+cabal2nix cabal = normalize $ postProcess $ MkDerivation
20 { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
21 { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
21 , version = Cabal.pkgVersion pkg
22 , version = Cabal.pkgVersion pkg
22 , sha256 = "cabal2nix left the she256 field undefined"
23 , sha256 = "cabal2nix left the she256 field undefined"
23 , isLibrary = isJust (Cabal.library tpkg)
24 , isLibrary = isJust (Cabal.library tpkg)
24 , isExecutable = not (null (Cabal.executables tpkg))
25 , isExecutable = not (null (Cabal.executables tpkg))
25− , buildDepends = normalizeNixNames (filter (`notElem` (name : corePackages)) $ map unDep deps)
26+ , buildDepends = map unDep deps
26− , buildTools = normalizeNixBuildTools (filter (`notElem` coreBuildTools) $ map unDep tools)
27+ , buildTools = map unDep tools
27− , extraLibs = normalizeNixLibs libs
28+ , extraLibs = libs
28− , pkgConfDeps = normalizeNixLibs pcs
29+ , pkgConfDeps = pcs
29 , runHaddock = True
30 , runHaddock = True
30 , metaSection = Meta
31 , metaSection = Meta
31 { homepage = Cabal.homepage descr
32 { homepage = Cabal.homepage descr
32− , description = normalizeDescription (Cabal.synopsis descr)
33+ , description = Cabal.synopsis descr
33 , license = fromCabalLicense (Cabal.license descr)
34 , license = fromCabalLicense (Cabal.license descr)
34 , platforms = []
35 , platforms = []
35 , maintainers = []
36 , maintainers = []
@@ -52,25 +53,3 @@ cabal2nix cabal = postProcess $ MkDerivation
53unDep :: Cabal.Dependency -> String
54unDep :: Cabal.Dependency -> String
54unDep (Cabal.Dependency (Cabal.PackageName x) _) = x
55unDep (Cabal.Dependency (Cabal.PackageName x) _) = x
56−normalizeDescription :: String -> String
57−normalizeDescription desc
59− | last desc == '.' && length (filter ('.'==) desc) == 1 = normalizeDescription (reverse (tail (reverse desc)))
60− | otherwise = unwords (words desc) >>= quote
62−quote :: Char -> [Char]
66−normalizeList :: [String] -> [String]
67−normalizeList = nub . sortBy (\x y -> compare (map toLower x) (map toLower y))
69−normalizeNixNames :: [String] -> [String]
70−normalizeNixNames = normalizeList . map toNixName
72−normalizeNixLibs :: [String] -> [String]
73−normalizeNixLibs = normalizeList . concatMap libNixName
75−normalizeNixBuildTools :: [String] -> [String]
76−normalizeNixBuildTools = normalizeList . concatMap buildToolNixName