git.iko.soy/typeable/cabal2nix
on master help sign in
Cabal2Nix: added a separate name-mapping function for build tools
67bbe8ePeter Simons
src/Cabal2Nix/Name.hs+7−1
@@ -1,7 +1,8 @@
1−module Cabal2Nix.Name ( toNixName, libNixName ) where
1+module Cabal2Nix.Name ( toNixName, libNixName, buildToolNixName ) where
2
2
3import Data.Char
3import Data.Char
4
4
5+-- | Map Cabal names to Nix attribute names.
5toNixName :: String -> String
6toNixName :: String -> String
6toNixName [] = error "toNixName: empty string is not a valid argument"
7toNixName [] = error "toNixName: empty string is not a valid argument"
7toNixName name = f name
8toNixName name = f name
@@ -37,3 +38,8 @@ libNixName "X11" = return "libX11"
37libNixName "xft" = return "libXft"
38libNixName "xft" = return "libXft"
38libNixName "z" = return "zlib"
39libNixName "z" = return "zlib"
39libNixName x = return x
40libNixName x = return x
41+
42+-- | Map build tool names to Nix attribute names.
43+buildToolNixName :: String -> String
44+buildToolNixName "cabal" = "cabalInstall"
45+buildToolNixName x = toNixName x
src/Cabal2Nix/Package.hs+4−1
@@ -22,7 +22,7 @@ cabal2nix cabal = MkDerivation
22 , isLibrary = isJust (Cabal.library tpkg)
22 , isLibrary = isJust (Cabal.library tpkg)
23 , isExecutable = not (null (Cabal.executables tpkg))
23 , isExecutable = not (null (Cabal.executables tpkg))
24 , buildDepends = normalizeNixNames (filter (`notElem` (name : corePackages)) $ map unDep deps)
24 , buildDepends = normalizeNixNames (filter (`notElem` (name : corePackages)) $ map unDep deps)
25− , buildTools = normalizeNixNames (filter (`notElem` coreBuildTools) $ map unDep tools)
25+ , buildTools = normalizeNixBuildTools (filter (`notElem` coreBuildTools) $ map unDep tools)
26 , extraLibs = normalizeNixLibs libs
26 , extraLibs = normalizeNixLibs libs
27 , pkgConfDeps = normalizeNixLibs pcs
27 , pkgConfDeps = normalizeNixLibs pcs
28 , runHaddock = True
28 , runHaddock = True
@@ -70,3 +70,6 @@ normalizeNixNames = normalizeList . map toNixName
70
70
71normalizeNixLibs :: [String] -> [String]
71normalizeNixLibs :: [String] -> [String]
72normalizeNixLibs = normalizeList . concatMap libNixName
72normalizeNixLibs = normalizeList . concatMap libNixName
73+
74+normalizeNixBuildTools :: [String] -> [String]
75+normalizeNixBuildTools = normalizeList . map buildToolNixName