git.iko.soy/typeable/cabal2nix
on master help sign in
Cabal2Nix: added a separate name-mapping function for build tools

We need this to generate cabal-dev, which depends on a build tool called "cabal", which is provided by the "cabal-install" package.

commit67bbe8eaee9edec4252df26674b75da47ff4c561 authorPeter Simons <simons@cryp.to> dateFri 19 Aug 2011, 15:06 (15 years ago) parent22281d7
2 files changed+11−2
src/Cabal2Nix/Name.hs+7−1 src/Cabal2Nix/Package.hs+4−1
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
22
33import Data.Char
44
5+-- | Map Cabal names to Nix attribute names.
56toNixName :: String -> String
67toNixName [] = error "toNixName: empty string is not a valid argument"
78toNixName name = f name
@@ -37,3 +38,8 @@ libNixName "X11" = return "libX11"
3738libNixName "xft" = return "libXft"
3839libNixName "z" = return "zlib"
3940libNixName 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
2222 , isLibrary = isJust (Cabal.library tpkg)
2323 , isExecutable = not (null (Cabal.executables tpkg))
2424 , 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)
2626 , extraLibs = normalizeNixLibs libs
2727 , pkgConfDeps = normalizeNixLibs pcs
2828 , runHaddock = True
@@ -70,3 +70,6 @@ normalizeNixNames = normalizeList . map toNixName
7070
7171normalizeNixLibs :: [String] -> [String]
7272normalizeNixLibs = normalizeList . concatMap libNixName
73+
74+normalizeNixBuildTools :: [String] -> [String]
75+normalizeNixBuildTools = normalizeList . map buildToolNixName