@@ -2,6 +2,7 @@ module Cabal2Nix.Package ( cabal2nix ) where
22
33import Cabal2Nix.License
44import Cabal2Nix.PostProcess
5+import Cabal2Nix.Normalize
56import Data.Maybe
67import Distribution.Compiler
78import qualified Distribution.Package as Cabal
@@ -16,20 +17,20 @@ import Data.List
1617import Data.Char
1718
1819cabal2nix :: Cabal.GenericPackageDescription -> Derivation
19−cabal2nix cabal = postProcess $ MkDerivation
20+cabal2nix cabal = normalize $ postProcess $ MkDerivation
2021 { pname = let Cabal.PackageName x = Cabal.pkgName pkg in x
2122 , version = Cabal.pkgVersion pkg
2223 , sha256 = "cabal2nix left the she256 field undefined"
2324 , isLibrary = isJust (Cabal.library tpkg)
2425 , isExecutable = not (null (Cabal.executables tpkg))
25− , buildDepends = normalizeNixNames (filter (`notElem` (name : corePackages)) $ map unDep deps)
26− , buildTools = normalizeNixBuildTools (filter (`notElem` coreBuildTools) $ map unDep tools)
27− , extraLibs = normalizeNixLibs libs
28− , pkgConfDeps = normalizeNixLibs pcs
26+ , buildDepends = map unDep deps
27+ , buildTools = map unDep tools
28+ , extraLibs = libs
29+ , pkgConfDeps = pcs
2930 , runHaddock = True
3031 , metaSection = Meta
3132 { homepage = Cabal.homepage descr
32− , description = normalizeDescription (Cabal.synopsis descr)
33+ , description = Cabal.synopsis descr
3334 , license = fromCabalLicense (Cabal.license descr)
3435 , platforms = []
3536 , maintainers = []
@@ -52,25 +53,3 @@ cabal2nix cabal = postProcess $ MkDerivation
5253
5354unDep :: Cabal.Dependency -> String
5455unDep (Cabal.Dependency (Cabal.PackageName x) _) = x
55−
56−normalizeDescription :: String -> String
57−normalizeDescription desc
58− | null desc = []
59− | last desc == '.' && length (filter ('.'==) desc) == 1 = normalizeDescription (reverse (tail (reverse desc)))
60− | otherwise = unwords (words desc) >>= quote
61−
62−quote :: Char -> [Char]
63−quote '"' = "\\\""
64−quote c = [c]
65−
66−normalizeList :: [String] -> [String]
67−normalizeList = nub . sortBy (\x y -> compare (map toLower x) (map toLower y))
68−
69−normalizeNixNames :: [String] -> [String]
70−normalizeNixNames = normalizeList . map toNixName
71−
72−normalizeNixLibs :: [String] -> [String]
73−normalizeNixLibs = normalizeList . concatMap libNixName
74−
75−normalizeNixBuildTools :: [String] -> [String]
76−normalizeNixBuildTools = normalizeList . concatMap buildToolNixName