@@ -21,6 +21,7 @@ type PkgURL = String
21type PkgDescription = String
21type PkgDescription = String
22type PkgLicense = License
22type PkgLicense = License
23type PkgDependencies = [Dependency] -- [CondTree ConfVar [Dependency] ()]
23type PkgDependencies = [Dependency] -- [CondTree ConfVar [Dependency] ()]
24+type PkgBuildTools = [Dependency]
24type PkgExtraLibs = [String]
25type PkgExtraLibs = [String]
25type PkgPlatforms = [String]
26type PkgPlatforms = [String]
26type PkgMaintainers = [String]
27type PkgMaintainers = [String]
@@ -32,15 +33,17 @@ data Pkg = Pkg PkgName
32 PkgDescription
33 PkgDescription
33 PkgLicense
34 PkgLicense
34 PkgDependencies
35 PkgDependencies
35 PkgExtraLibs
37 PkgExtraLibs
36 PkgPlatforms
38 PkgPlatforms
37 PkgMaintainers
39 PkgMaintainers
38 deriving (Show)
40 deriving (Show)
40showNixPkg :: Pkg -> String
42showNixPkg :: 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
43− doc = braces (fsep $ punctuate comma $ map text ("cabal" : pkgDeps)) <+>
45+ doc = braces (fsep $ punctuate comma $
46+ map text ("cabal" : pkgBuildTools ++ pkgDeps)) <+>
44 colon $$ text "" $$
47 colon $$ text "" $$
46 text "cabal.mkDerivation" <+> lparen <> text "self" <+>
49 text "cabal.mkDerivation" <+> lparen <> text "self" <+>
@@ -49,6 +52,12 @@ showNixPkg (Pkg name ver sha256 url desc lic deps libs platforms maintainers) =
49 attr "pname" $ doubleQuotes (text name),
52 attr "pname" $ doubleQuotes (text name),
50 attr "version" $ doubleQuotes showVer,
53 attr "version" $ doubleQuotes showVer,
51 attr "sha256" $ doubleQuotes (text sha256),
54 attr "sha256" $ doubleQuotes (text sha256),
55+ onlyIf pkgBuildTools $
57+ text "extraBuildInputs" <+> equals <+> lbrack,
58+ nest 2 $ fsep $ map text pkgBuildTools,
52 onlyIf pkgDeps $
61 onlyIf pkgDeps $
54 text "propagatedBuildInputs" <+> equals <+> lbrack,
63 text "propagatedBuildInputs" <+> equals <+> lbrack,
@@ -86,12 +95,15 @@ showNixPkg (Pkg name ver sha256 url desc lic deps libs platforms maintainers) =
86 pkgDeps = (nub $ sort $ map libNixName libs) ++
95 pkgDeps = (nub $ sort $ map libNixName libs) ++
87 (nub $ sort $ map toNixName $
96 (nub $ sort $ map toNixName $
88 filter (`notElem` (name : corePackages)) $ map unDep deps)
97 filter (`notElem` (name : corePackages)) $ map unDep deps)
98+ pkgBuildTools :: [String]
99+ pkgBuildTools = nub $ sort $ map toNixName $ map unDep tools
91cabal2nix :: GenericPackageDescription -> PkgSHA256 -> PkgPlatforms -> PkgMaintainers -> Pkg
102cabal2nix :: GenericPackageDescription -> PkgSHA256 -> PkgPlatforms -> PkgMaintainers -> Pkg
92cabal2nix cabal sha256 platforms maintainers =
103cabal2nix cabal sha256 platforms maintainers =
93 Pkg pkgname pkgver sha256 url desc lic
104 Pkg pkgname pkgver sha256 url desc lic
94 (buildDepends tpkg)
105 (buildDepends tpkg)
96 [ "self.stdenv.lib.platforms." ++ p | p <- platforms ]
108 [ "self.stdenv.lib.platforms." ++ p | p <- platforms ]
97 [ "self.stdenv.lib.maintainers." ++ m | m <- maintainers ]
109 [ "self.stdenv.lib.maintainers." ++ m | m <- maintainers ]
@@ -112,11 +124,12 @@ cabal2nix cabal sha256 platforms maintainers =
113 libDeps = map libBuildInfo $ maybeToList (library tpkg)
125 libDeps = map libBuildInfo $ maybeToList (library tpkg)
114 exeDeps = map buildInfo $ executables tpkg
126 exeDeps = map buildInfo $ executables tpkg
115− libsExtra = concatMap extraLibs (libDeps ++ exeDeps)
127+ libsExtra = concatMap extraLibs (libDeps ++ exeDeps)
116− libsPkgC = map unDep $ concatMap pkgconfigDepends (libDeps ++ exeDeps)
128+ libsPkgCfg = map unDep $ concatMap pkgconfigDepends (libDeps ++ exeDeps)
129+ tools = concatMap buildTools (libDeps ++ exeDeps)
117 -- add pkgconfig as an extra dependency if there are any pkgconfig deps
130 -- add pkgconfig as an extra dependency if there are any pkgconfig deps
118− libs = libsExtra ++ (if null libsPkgC then []
131+ libs = libsExtra ++ (if null libsPkgCfg then []
119− else ("pkgconfig" : libsPkgC))
132+ else ("pkgconfig" : libsPkgCfg))
121unDep :: Dependency -> String
134unDep :: Dependency -> String
122unDep (Dependency (PackageName x) _) = x
135unDep (Dependency (PackageName x) _) = x