git.iko.soy/typeable/cabal2nix
on master help sign in
PostProcess.hs: extend the fixGtkBuilds function to re-produce the old state of hackage-packages.nix

With the new data structures in place, we can generate a more accurate version of hackage-packages.nix. I'd like to tackle this incrementally, though, so I've added a couple of nasty hacks to the post-processor that don't make much sense but ensure that the hackage-packages.nix file we generate looks pretty much like the previous one.

commitd28da8669fafa8d8d6bf0313c70239bc15c69ca9 authorPeter Simons <simons@cryp.to> dateWed 26 Aug 2015, 16:58 (11 years ago) parent3cc1b16
1 file changed+12−2
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+12−2
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs+12−2
@@ -3,6 +3,7 @@
33module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess ) where
44
55import Internal.Lens
6+import Data.Set.Lens
67import Data.Maybe
78import Data.Set ( Set )
89import qualified Data.Set as Set
@@ -17,9 +18,18 @@ postProcess :: Derivation -> Derivation
1718postProcess deriv = foldr ($) (fixGtkBuilds deriv) [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]
1819
1920fixGtkBuilds :: Derivation -> Derivation
20−fixGtkBuilds drv = drv & dependencies . pkgconfig %~ (`Set.difference` buildDeps)
21+fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesWithHaskellName)
22+ & dependencies . system %~ Set.filter (not . collidesWithHaskellName)
23+ & dependencies . tool %~ Set.filter (not . collidesWithHaskellName)
2124 where
22− buildDeps = drv ^. dependencies . haskell
25+ collidesWithHaskellName :: Binding -> Bool
26+ collidesWithHaskellName b = view localName b `Set.member` buildDeps
27+
28+ myName :: Identifier
29+ myName = create ident n where PackageName n = packageName drv
30+
31+ buildDeps :: Set Identifier
32+ buildDeps = Set.delete myName (setOf (dependencies . haskell . folded . localName) drv)
2333
2434hooks :: [(Dependency, Derivation -> Derivation)]
2535hooks = over (mapped._1) (\str -> fromMaybe (error ("invalid constraint: " ++ show str)) (simpleParse str))