git.iko.soy/typeable/cabal2nix
on master help sign in
Include executable/library flags.
commitdc02ae78cc1c38a3df38fdb79672e31d041cc320 authorAndres Loeh <mail@andres-loeh.de> dateMon 8 Aug 2011, 16:38 (15 years ago) parent35766d3
1 file changed+15−1
src/Cabal2Nix/Package.hs+15−1
src/Cabal2Nix/Package.hs+15−1
@@ -20,6 +20,8 @@ type PkgSHA256 = String
2020type PkgURL = String
2121type PkgDescription = String
2222type PkgLicense = License
23+type PkgIsLib = Bool
24+type PkgIsExe = Bool
2325type PkgDependencies = [Dependency] -- [CondTree ConfVar [Dependency] ()]
2426type PkgBuildTools = [Dependency]
2527type PkgExtraLibs = [String]
@@ -33,6 +35,8 @@ data Pkg = Pkg PkgName
3335 PkgURL
3436 PkgDescription
3537 PkgLicense
38+ PkgIsLib
39+ PkgIsExe
3640 PkgDependencies
3741 PkgBuildTools
3842 PkgExtraLibs
@@ -47,7 +51,9 @@ prepunctuate p (d:ds) = d : map (p <>) ds
4751
4852
4953showNixPkg :: Pkg -> String
50−showNixPkg (Pkg name ver sha256 url desc lic deps tools libs pcs platforms maintainers) = render doc
54+showNixPkg (Pkg name ver sha256 url desc lic isLib isExe deps
55+ tools libs pcs platforms maintainers) =
56+ render doc
5157 where
5258 doc = sep [
5359 lbrace <+> (fcat $ prepunctuate (comma <> text " ") $
@@ -63,6 +69,8 @@ showNixPkg (Pkg name ver sha256 url desc lic deps tools libs pcs platforms maint
6369 attr "pname" $ doubleQuotes (text name),
6470 attr "version" $ doubleQuotes showVer,
6571 attr "sha256" $ doubleQuotes (text sha256),
72+ boolattr "isLibrary" True isLib,
73+ boolattr "isExecutable" False isExe,
6674 listattr "buildDepends" pkgDeps,
6775 listattr "buildTools" pkgBuildTools,
6876 listattr "extraLibraries" pkgLibs,
@@ -88,6 +96,9 @@ showNixPkg (Pkg name ver sha256 url desc lic deps tools libs pcs platforms maint
8896 ]
8997 attr n v = text n <+> equals <+> v <> semi
9098 onlyIf p d = if not (null p) then d else empty
99+ boolattr n d v = if v /= d then
100+ attr n (if v then text "true" else text "false")
101+ else empty
91102 listattr n vs = onlyIf vs $ sep [
92103 text n <+> equals <+> lbrack,
93104 nest 2 $ fsep $ map text vs,
@@ -105,6 +116,7 @@ showNixPkg (Pkg name ver sha256 url desc lic deps tools libs pcs platforms maint
105116cabal2nix :: GenericPackageDescription -> PkgSHA256 -> PkgPlatforms -> PkgMaintainers -> Pkg
106117cabal2nix cabal sha256 platforms maintainers =
107118 Pkg pkgname pkgver sha256 url desc lic
119+ isLib isExe
108120 (buildDepends tpkg)
109121 tools
110122 libs
@@ -126,6 +138,8 @@ cabal2nix cabal sha256 platforms maintainers =
126138 (Platform I386 Linux) -- shouldn't be hardcoded
127139 (CompilerId GHC (Version [7,0,4] [])) -- dito
128140 [] cabal
141+ isLib = isJust (library tpkg)
142+ isExe = not (null (executables tpkg))
129143 libDeps = map libBuildInfo $ maybeToList (library tpkg)
130144 exeDeps = map buildInfo $ executables tpkg
131145 libs = concatMap extraLibs (libDeps ++ exeDeps)