git.iko.soy/typeable/cabal2nix
on master help sign in
Hackage4Nix/Nix.hs: improved recognition of the meta.platforms attribute
1a0438dPeter Simons
src/Hackage4Nix/Nix.hs+5−1
@@ -26,7 +26,9 @@ nixExpr2CabalExpr (Expr _ _ dict) =
26 buildTools = [ Dependency (PackageName dep) anyVersion | dep <- getRefList "buildTools" dict ]
26 buildTools = [ Dependency (PackageName dep) anyVersion | dep <- getRefList "buildTools" dict ]
27 extraLibs = getRefList "extraLibraries" dict
27 extraLibs = getRefList "extraLibraries" dict
28 pkgconfDeps = getRefList "pkgconfDepends" dict
28 pkgconfDeps = getRefList "pkgconfDepends" dict
29− platforms = [getRef "platforms" (getDict "meta" dict)]
29+ platform = getRef "platforms" (getDict "meta" dict)
30+ platforms = if null platform then [] else [platform]
31+ noHaddock = getBool "noHaddock" dict
30 maintainers = getRefList "maintainers" (getDict "meta" dict)
32 maintainers = getRefList "maintainers" (getDict "meta" dict)
31
33
32get' :: String -> Dictionary -> [Value]
34get' :: String -> Dictionary -> [Value]
@@ -41,6 +43,7 @@ getBool :: String -> Dictionary -> Bool
41getBool ref dict
43getBool ref dict
42 | [] <- get' ref dict = False
44 | [] <- get' ref dict = False
43 | BoolV b <- get ref dict = if b == Yes then True else False
45 | BoolV b <- get ref dict = if b == Yes then True else False
46+ | otherwise = error $ "getBool: unexpected value of " ++ show ref ++ " in " ++ show dict
44
47
45getString :: String -> Dictionary -> String
48getString :: String -> Dictionary -> String
46getString ref dict
49getString ref dict
@@ -70,6 +73,7 @@ getRef :: String -> Dictionary -> String
70getRef ref dict
73getRef ref dict
71 | [] <- get' ref dict = ""
74 | [] <- get' ref dict = ""
72 | AttributeV r <- get ref dict = flattenReference r
75 | AttributeV r <- get ref dict = flattenReference r
76+ | otherwise = error $ "getURL: unexpected value of " ++ show ref ++ " in " ++ show dict
73
77
74flattenReference :: Reference -> String
78flattenReference :: Reference -> String
75flattenReference (Reference rs) = concat (intersperse "." [ r | Ident r <- rs ])
79flattenReference (Reference rs) = concat (intersperse "." [ r | Ident r <- rs ])