git.iko.soy/typeable/cabal2nix
on master help sign in
Fix package lookup for shadowed system packages

System packages which have the same package name as haskell packages should be brought into scope by using `inherit systemPackageName;`. Previously, `hackage2nix` would generate `systemPackageName = null` or nothing at all instead. The change introduces a slight problem for executables that depend on themselves as a tool (c2hs' testsuite for example depends on the c2hs tool). To fix this, such a dependency is now removed in the normalization step of cabal2nix.

commit3e12e46bbba5fe8c46af552295fce6d3f3a0c157 authorBenno Fünfstück <benno.fuenfstueck@gmail.com> dateSat 15 Aug 2015, 18:17 (11 years ago) parent34b77b8
2 files changed+4−4
src/Cabal2Nix/Normalize.hs+1 src/hackage2nix.hs+3−4
src/Cabal2Nix/Normalize.hs+1
@@ -26,6 +26,7 @@ normalize drv = drv
2626normalizeBuildInfo :: PackageName -> BuildInfo -> BuildInfo
2727normalizeBuildInfo (PackageName pname) bi = bi
2828 & haskell . contains (Identifier pname) .~ False
29+ & tool . contains (Identifier pname) .~ False
2930 & tool %~ normalizeNixBuildTools . Set.filter (\(Identifier n) -> n `notElem` coreBuildTools)
3031
3132 {-
src/hackage2nix.hs+3−4
@@ -206,9 +206,8 @@ generatePackageSet config hackage nixpkgs = do
206206
207207 formatOverride :: Attribute -> Maybe Path -> Doc
208208 formatOverride n Nothing = space <> text n <> text " = null;" -- missing attribute
209− formatOverride n (Just []) -- Haskell package:
210− | n == name = formatOverride n Nothing -- refers to a missing system library
211− | otherwise = mempty -- found by callPackage
209+ formatOverride n (Just []) = (text " inherit" <+> text n) <> semi
210+ formatOverride _ (Just ["self"]) = mempty -- callPackage finds this package already
212211 formatOverride n (Just p) = (text " inherit" <+> parens (text (intercalate "." p)) <+> text n) <> semi
213212
214213 overrides :: Doc
@@ -238,7 +237,7 @@ generatePackageSet config hackage nixpkgs = do
238237
239238resolveHackageThenNixpkgsAttribute :: Nixpkgs -> Hackage -> Attribute -> Maybe Path
240239resolveHackageThenNixpkgsAttribute nixpkgs hackage name
241− | Just _ <- Map.lookup name hackage = Just []
240+ | Just _ <- Map.lookup name hackage = Just ["self"]
242241 | p@(Just _) <- resolveNixpkgsAttribute nixpkgs name = p
243242 | otherwise = Nothing
244243