git.iko.soy/typeable/cabal2nix
on master help sign in
Re-factoring
d32ed2cPeter Simons
src/Cabal2Nix/PostProcess.hs−3
@@ -42,9 +42,6 @@ hooks = over (mapped._1) (\str -> fromMaybe (error ("invalid constraint: " ++ sh
42 , ("wxcore", set (libraryDepends . pkgconfig . contains (dep "wxGTK")) True)
42 , ("wxcore", set (libraryDepends . pkgconfig . contains (dep "wxGTK")) True)
43 ]
43 ]
44
44
45−dep :: String -> Dependency
46−dep s = Dependency (PackageName s) anyVersion
47−
48gitAnnexHook :: Derivation -> Derivation
45gitAnnexHook :: Derivation -> Derivation
49gitAnnexHook = set phaseOverrides gitAnnexOverrides . over (executableDepends . system) (Set.union buildInputs)
46gitAnnexHook = set phaseOverrides gitAnnexOverrides . over (executableDepends . system) (Set.union buildInputs)
50 where
47 where
src/Distribution/Nixpkgs/Haskell.hs+9−15
@@ -8,8 +8,8 @@ module Distribution.Nixpkgs.Haskell
8 , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs
8 , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs
9 , phaseOverrides, editedCabalFile, metaSection
9 , phaseOverrides, editedCabalFile, metaSection
10 , BuildInfo, haskell, pkgconfig, system, tool
10 , BuildInfo, haskell, pkgconfig, system, tool
11− , dependencies
11+ , dependencies, anyDep
12− , unDep
12+ , dep, unDep
13 )
13 )
14 where
14 where
15
15
@@ -37,6 +37,8 @@ data BuildInfo = BuildInfo
37
37
38makeLenses ''BuildInfo
38makeLenses ''BuildInfo
39
39
40+makeLensesFor [("_haskell", "anyDep"), ("_pkgconfig", "anyDep"), ("_system", "anyDep"), ("_tool", "anyDep")] ''BuildInfo
41+
40instance Monoid BuildInfo where
42instance Monoid BuildInfo where
41 mempty = BuildInfo mempty mempty mempty mempty
43 mempty = BuildInfo mempty mempty mempty mempty
42 BuildInfo w1 x1 y1 z1 `mappend` BuildInfo w2 x2 y2 z2 = BuildInfo (w1 `mappend` w2) (x1 `mappend` x2) (y1 `mappend` y2) (z1 `mappend` z2)
44 BuildInfo w1 x1 y1 z1 `mappend` BuildInfo w2 x2 y2 z2 = BuildInfo (w1 `mappend` w2) (x1 `mappend` x2) (y1 `mappend` y2) (z1 `mappend` z2)
@@ -113,7 +115,7 @@ instance NFData VersionRange where rnf = genericRnf
113instance NFData Dependency where rnf = genericRnf
115instance NFData Dependency where rnf = genericRnf
114
116
115instance Pretty Derivation where
117instance Pretty Derivation where
116− pPrint MkDerivation {..} = funargs (map text ("mkDerivation" : toAscList inputs)) $$ vcat
118+ pPrint drv@(MkDerivation {..}) = funargs (map text ("mkDerivation" : toAscList inputs)) $$ vcat
117 [ text "mkDerivation" <+> lbrace
119 [ text "mkDerivation" <+> lbrace
118 , nest 2 $ vcat
120 , nest 2 $ vcat
119 [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
121 [ attr "pname" $ doubleQuotes $ disp (packageName _pkgid)
@@ -141,18 +143,7 @@ instance Pretty Derivation where
141 where
143 where
142 inputs :: Set String
144 inputs :: Set String
143 inputs = Set.unions [ _extraFunctionArgs
145 inputs = Set.unions [ _extraFunctionArgs
144− , Set.map unDep (_haskell _libraryDepends)
146+ , view (dependencies . anyDep . to (Set.map unDep)) drv
145− , Set.map unDep (_haskell _executableDepends)
146− , Set.map unDep (_haskell _testDepends)
147− , Set.map unDep (_system _libraryDepends)
148− , Set.map unDep (_system _executableDepends)
149− , Set.map unDep (_system _testDepends)
150− , Set.map unDep (_pkgconfig _libraryDepends)
151− , Set.map unDep (_pkgconfig _executableDepends)
152− , Set.map unDep (_pkgconfig _testDepends)
153− , Set.map unDep (_tool _libraryDepends)
154− , Set.map unDep (_tool _executableDepends)
155− , Set.map unDep (_tool _testDepends)
156 , Set.fromList ["fetch" ++ derivKind _src | derivKind _src /= "" && not isHackagePackage]
147 , Set.fromList ["fetch" ++ derivKind _src | derivKind _src /= "" && not isHackagePackage]
157 ]
148 ]
158
149
@@ -180,6 +171,9 @@ pPrintBuildInfo prefix bi = vcat
180 , setattr (prefix++"ToolDepends") (Set.map unDep (bi^.tool))
171 , setattr (prefix++"ToolDepends") (Set.map unDep (bi^.tool))
181 ]
172 ]
182
173
174+dep :: String -> Dependency
175+dep s = Dependency (PackageName s) anyVersion
176+
183unDep :: Dependency -> String
177unDep :: Dependency -> String
184unDep (Dependency (PackageName x) _) = x
178unDep (Dependency (PackageName x) _) = x
185
179