git.iko.soy/typeable/cabal2nix
on master help sign in
Build tools support.
commitaa766217542b8e6c7d7ecdb9eba23c730cdc324a authorAndres Loeh <mail@andres-loeh.de> dateMon 8 Aug 2011, 11:40 (15 years ago) parent204ce26
2 files changed+23−6
TODO+4 src/Cabal2Nix/Package.hs+19−6
TODO+4
@@ -1,11 +1,15 @@
11* Should we use the github issue tracker for this?
22
3+[[
34* Include build-tools field in the list of dependencies.
45
56 Example: haskell-src-exts/1.11.1/haskell-src-exts.cabal needs this.
67
78 +1, this is important.
89
10+ Done.
11+]]
12+
913* Allow patching the cabal file before processing it. This is required
1014 to enable/disable cabal flags.
1115
src/Cabal2Nix/Package.hs+19−6
@@ -21,6 +21,7 @@ type PkgURL = String
2121type PkgDescription = String
2222type PkgLicense = License
2323type PkgDependencies = [Dependency] -- [CondTree ConfVar [Dependency] ()]
24+type PkgBuildTools = [Dependency]
2425type PkgExtraLibs = [String]
2526type PkgPlatforms = [String]
2627type PkgMaintainers = [String]
@@ -32,15 +33,17 @@ data Pkg = Pkg PkgName
3233 PkgDescription
3334 PkgLicense
3435 PkgDependencies
36+ PkgBuildTools
3537 PkgExtraLibs
3638 PkgPlatforms
3739 PkgMaintainers
3840 deriving (Show)
3941
4042showNixPkg :: Pkg -> String
41−showNixPkg (Pkg name ver sha256 url desc lic deps libs platforms maintainers) = render doc
43+showNixPkg (Pkg name ver sha256 url desc lic deps tools libs platforms maintainers) = render doc
4244 where
43− doc = braces (fsep $ punctuate comma $ map text ("cabal" : pkgDeps)) <+>
45+ doc = braces (fsep $ punctuate comma $
46+ map text ("cabal" : pkgBuildTools ++ pkgDeps)) <+>
4447 colon $$ text "" $$
4548 vcat [
4649 text "cabal.mkDerivation" <+> lparen <> text "self" <+>
@@ -49,6 +52,12 @@ showNixPkg (Pkg name ver sha256 url desc lic deps libs platforms maintainers) =
4952 attr "pname" $ doubleQuotes (text name),
5053 attr "version" $ doubleQuotes showVer,
5154 attr "sha256" $ doubleQuotes (text sha256),
55+ onlyIf pkgBuildTools $
56+ sep [
57+ text "extraBuildInputs" <+> equals <+> lbrack,
58+ nest 2 $ fsep $ map text pkgBuildTools,
59+ rbrack <> semi
60+ ],
5261 onlyIf pkgDeps $
5362 sep [
5463 text "propagatedBuildInputs" <+> equals <+> lbrack,
@@ -86,12 +95,15 @@ showNixPkg (Pkg name ver sha256 url desc lic deps libs platforms maintainers) =
8695 pkgDeps = (nub $ sort $ map libNixName libs) ++
8796 (nub $ sort $ map toNixName $
8897 filter (`notElem` (name : corePackages)) $ map unDep deps)
98+ pkgBuildTools :: [String]
99+ pkgBuildTools = nub $ sort $ map toNixName $ map unDep tools
89100
90101
91102cabal2nix :: GenericPackageDescription -> PkgSHA256 -> PkgPlatforms -> PkgMaintainers -> Pkg
92103cabal2nix cabal sha256 platforms maintainers =
93104 Pkg pkgname pkgver sha256 url desc lic
94105 (buildDepends tpkg)
106+ tools
95107 libs
96108 [ "self.stdenv.lib.platforms." ++ p | p <- platforms ]
97109 [ "self.stdenv.lib.maintainers." ++ m | m <- maintainers ]
@@ -112,11 +124,12 @@ cabal2nix cabal sha256 platforms maintainers =
112124 [] cabal
113125 libDeps = map libBuildInfo $ maybeToList (library tpkg)
114126 exeDeps = map buildInfo $ executables tpkg
115− libsExtra = concatMap extraLibs (libDeps ++ exeDeps)
116− libsPkgC = map unDep $ concatMap pkgconfigDepends (libDeps ++ exeDeps)
127+ libsExtra = concatMap extraLibs (libDeps ++ exeDeps)
128+ libsPkgCfg = map unDep $ concatMap pkgconfigDepends (libDeps ++ exeDeps)
129+ tools = concatMap buildTools (libDeps ++ exeDeps)
117130 -- add pkgconfig as an extra dependency if there are any pkgconfig deps
118− libs = libsExtra ++ (if null libsPkgC then []
119− else ("pkgconfig" : libsPkgC))
131+ libs = libsExtra ++ (if null libsPkgCfg then []
132+ else ("pkgconfig" : libsPkgCfg))
120133
121134unDep :: Dependency -> String
122135unDep (Dependency (PackageName x) _) = x