@@ -11,6 +11,7 @@ import Distribution.NixOS.Derivation.Cabal
11import Cabal2Nix.Name
11import Cabal2Nix.Name
12import Cabal2Nix.CorePackages
12import Cabal2Nix.CorePackages
13import Data.List
13import Data.List
15cabal2nix :: Cabal.GenericPackageDescription -> Derivation
16cabal2nix :: Cabal.GenericPackageDescription -> Derivation
16cabal2nix cabal = MkDerivation
17cabal2nix cabal = MkDerivation
@@ -19,10 +20,10 @@ cabal2nix cabal = MkDerivation
19 , sha256 = "cabal2nix left the she256 field undefined"
20 , sha256 = "cabal2nix left the she256 field undefined"
20 , isLibrary = isJust (Cabal.library tpkg)
21 , isLibrary = isJust (Cabal.library tpkg)
21 , isExecutable = not (null (Cabal.executables tpkg))
22 , isExecutable = not (null (Cabal.executables tpkg))
22− , buildDepends = pkgDeps
23+ , buildDepends = normalizeNixNames (filter (`notElem` (name : corePackages)) $ map unDep deps)
23− , buildTools = pkgBuildTools
24+ , buildTools = normalizeNixNames (filter (`notElem` coreBuildTools) $ map unDep tools)
24− , extraLibs = pkgLibs
25+ , extraLibs = normalizeNixLibs libs
25− , pkgConfDeps = pkgPCs
26+ , pkgConfDeps = normalizeNixLibs pcs
26 , runHaddock = True
27 , runHaddock = True
27 , metaSection = Meta
28 , metaSection = Meta
28 { homepage = Cabal.homepage descr
29 { homepage = Cabal.homepage descr
@@ -36,22 +37,16 @@ cabal2nix cabal = MkDerivation
36 descr = Cabal.packageDescription cabal
37 descr = Cabal.packageDescription cabal
37 pkg = Cabal.package descr
38 pkg = Cabal.package descr
38 Cabal.PackageName name = Cabal.pkgName pkg
39 Cabal.PackageName name = Cabal.pkgName pkg
39− deps = (Cabal.buildDepends tpkg)
40+ deps = Cabal.buildDepends tpkg
40− libDeps = map Cabal.libBuildInfo $ maybeToList (Cabal.library tpkg)
41+ libDeps = map Cabal.libBuildInfo (maybeToList (Cabal.library tpkg))
41− exeDeps = map Cabal.buildInfo $ Cabal.executables tpkg
42+ exeDeps = map Cabal.buildInfo (Cabal.executables tpkg)
42− tools = concatMap Cabal.buildTools (libDeps ++ exeDeps)
43+ tools = concatMap Cabal.buildTools (libDeps ++ exeDeps)
43− libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
44+ libs = concatMap Cabal.extraLibs (libDeps ++ exeDeps)
44− pcs = map unDep $ concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps)
45+ pcs = map unDep (concatMap Cabal.pkgconfigDepends (libDeps ++ exeDeps))
45 Right (tpkg, _) = finalizePackageDescription [] (const True)
46 Right (tpkg, _) = finalizePackageDescription [] (const True)
46− (Platform I386 Linux) -- shouldn't be hardcoded
47+ (Platform I386 Linux) -- shouldn't be hardcoded
47− (CompilerId GHC (Version [7,0,4] [])) -- dito
48+ (CompilerId GHC (Version [7,0,4] [])) -- dito
49− pkgLibs = nub $ sort $ concatMap libNixName libs
50− pkgPCs = nub $ sort $ concatMap libNixName pcs
51− pkgDeps = nub $ sort $ map toNixName $
52− filter (`notElem` (name : corePackages)) $ map unDep deps
53− pkgBuildTools = nub $ sort $ map toNixName $
54− filter (`notElem` coreBuildTools) $ map unDep tools
56unDep :: Cabal.Dependency -> String
51unDep :: Cabal.Dependency -> String
57unDep (Cabal.Dependency (Cabal.PackageName x) _) = x
52unDep (Cabal.Dependency (Cabal.PackageName x) _) = x
@@ -65,3 +60,12 @@ normalizeDescription desc
65quote :: Char -> [Char]
60quote :: Char -> [Char]
66quote '"' = "\\\""
61quote '"' = "\\\""
67quote c = [c]
62quote c = [c]
64+normalizeList :: [String] -> [String]
65+normalizeList = nub . sort {- By (\x y -> compare (map toLower x) (map toLower y)) -}
67+normalizeNixNames :: [String] -> [String]
68+normalizeNixNames = normalizeList . map toNixName
70+normalizeNixLibs :: [String] -> [String]
71+normalizeNixLibs = normalizeList . concatMap libNixName