git.iko.soy/typeable/cabal2nix
on master help sign in
Merge pull request #5 from kosmikus/out

Comments for TODO.

commitfcf14da7f303f9df755c3edde447bfda0fae2326 authorPeter Simons <simons@cryp.to> dateMon 8 Aug 2011, 03:45 (15 years ago) parentcfa97a8aa76621
3 files changed+83−7
TODO+58 src/Cabal2Nix/CorePackages.hs+5 src/Cabal2Nix/Package.hs+20−7
TODO+58
@@ -1,36 +1,94 @@
1+* Should we use the github issue tracker for this?
2+
3+[[
14* Include build-tools field in the list of dependencies.
25
36 Example: haskell-src-exts/1.11.1/haskell-src-exts.cabal needs this.
47
8+ +1, this is important.
9+
10+ Done.
11+]]
12+
513* Allow patching the cabal file before processing it. This is required
614 to enable/disable cabal flags.
715
816 Example: pandoc/1.8.2.1/pandoc.cabal
917
18+ Better approach 1: Allow flag settings to be specified via cabal2nix
19+ command line.
20+
21+ Better approach 2: Allow flag choices in the generated Nix expressions.
22+ Default values in Cabal translate to default values in Nix.
23+ Then when generating the composition file, select flag choices that
24+ are appropriate.
25+
26+[[
1027* What is Integer-gmp, and is it required? Figure out what's going on in
1128 'double-conversion'.
1229
30+ No, integer-gmp and ghc are core packages missing from the core list.
31+ double-conversion needs a text version more recent than the current
32+ platform. I wouldn't support it for now.
33+
34+ Done.
35+]]
36+
1337* The ':' at the expression argument list shouldn't be separated with a
1438 blank.
1539
40+ According to my coding style, it should. Colon is a binary operator.
41+ Binary operators should *always* be *surrounded* by spaces.
42+
1643* networkBytestring doesn't exist anymore.
1744
1845* Hipmunk has some weird 'm' library as input.
1946
47+ Well, that'd be -libm. Should be added to the library translation list.
48+ libm is probably in stdenv. So the type of library translation should
49+ probably become String -> [String] ...
50+
2051* terminfo lacks input extensibleExceptions and ncurses.
2152
53+ extensible-exceptions actually is a core library. It wasn't in ghc-6.10,
54+ though. I'm not sure what to do here: either remove it as a core package,
55+ consequently include it where it's a dependency, but set it to null for
56+ all newer GHCs. Or drop support for ghc-6.10 completely, and keep it as
57+ a core package.
58+
59+ The ncurses dependency isn't properly specified in the Cabal file. It'll
60+ have to be provided externally.
61+
2262* benchpress lacks a time buildInput.
2363
64+ Same story for time as for extensible-exceptions above.
65+
2466* OpenAL lacks an openal build input.
2567
68+ Another one that isn't specified in the Cabal files.
69+
2670* SDL-image lacks SDL_image buildInput.
2771
2872* SDL-ttf lacks SDL_ttf buildInput.
2973
3074* SDL-mixer lacks SDL_mixer buildInput.
3175
76+ I looked at these. I think they'll have to be patched. These deps
77+ aren't properly declared in the Cabal file.
78+
3279* wxcore needs buildInputs: wxGTK, mesa, libX11.
3380
81+ Also not in the Cabal file.
82+
83+[[
3484* applications/editors/leksah/default.nix generates an infinite
3585 recursion because the expression expects itself as an argument. Not
3686 sure why that is happening.
87+
88+ We should remove a self-dependency of a library. A package providing
89+ both library and binary can have a dependency on the library from the
90+ binary. That occurs with leksah. The current flattening includes that
91+ dep, but it shouldn't.
92+
93+ Done.
94+]]
src/Cabal2Nix/CorePackages.hs+5
@@ -8,16 +8,21 @@ corePackages :: [String]
88corePackages = [
99 "array",
1010 "base",
11+ "bin-package-db",
1112 "bytestring",
1213 "Cabal",
1314 "containers",
1415 "directory",
1516 "extensible-exceptions",
17+ "ffi",
1618 "filepath",
19+ "ghc",
20+ "ghc-binary",
1721 "ghc-prim",
1822 "haskell2010",
1923 "haskell98",
2024 "hpc",
25+ "integer-gmp",
2126 "old-locale",
2227 "old-time",
2328 "pretty",
src/Cabal2Nix/Package.hs+20−7
@@ -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,
@@ -85,13 +94,16 @@ showNixPkg (Pkg name ver sha256 url desc lic deps libs platforms maintainers) =
8594 pkgDeps :: [String]
8695 pkgDeps = (nub $ sort $ map libNixName libs) ++
8796 (nub $ sort $ map toNixName $
88− filter (`notElem` corePackages) $ map unDep deps)
97+ 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