git.iko.soy/typeable/cabal2nix
on master help sign in
fromPackageDescription: ignore dependencies for non-buildable components

Having un-buildable components in a Cabal package is all the rage these days. Packages like stylish-cabal have test suites that depend on private Haskell libraries and therefore cannot be built, so these test suites are disabled by default and need an explicit flag to enable them. Now, if we try to generate a Nix expression that contains a reference to that private dependency, then we'll end up with something that does not evaluate because the corresponding name is missing from the package set. Previously, Cabal used to list those as "missing dependencies" during finalizeGenericPackageDescription and we used information to generate explicit "foo = null" assignments in the build function's argument list, but this is no longer the case because the incomplete build component is optional and therefore it's dependencies are, technically, not missing. I suppose the proper solution would be to generate all those overrides by performing an "is that a known Haskell package" lookup ourselves. Until that's implemented, however, we just ignore disabled build components.

commitbde18636a1cc9a65ca926bf987da87e0f408e575 authorPeter Simons <simons@cryp.to> dateTue 20 Feb 2018, 09:42 (9 years ago) parent4f2b161
1 file changed+1
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+1
src/Distribution/Nixpkgs/Haskell/FromCabal.hs+1
@@ -141,6 +141,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
141141 internalLibNames = fmap unqualComponentNameToPackageName . catMaybes $ libName <$> subLibraries
142142
143143 convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo
144+ convertBuildInfo Cabal.BuildInfo {..} | not buildable = mempty
144145 convertBuildInfo Cabal.BuildInfo {..} = mempty
145146 & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- targetBuildDepends, x `notElem` internalLibNames ]
146147 & system .~ Set.fromList [ resolveInNixpkgs y | x <- extraLibs, y <- libNixName x ]