diff --git a/lib/load-cabal-plan.nix b/lib/load-cabal-plan.nix index 14ba6db55a..adf3a6898d 100644 --- a/lib/load-cabal-plan.nix +++ b/lib/load-cabal-plan.nix @@ -47,7 +47,15 @@ let name = pkgs.lib.removePrefix "${prefix}:" n; value = (if cabal2nixComponents == null then {} else cabal2nixComponents.${collectionName}.${name}) // { buildable = true; - } // lookupDependencies hsPkgs c.depends c.exe-depends; + } // lookupDependencies hsPkgs ( + c.depends + # If plan.json uses a single unit for this package (build-type: Custom), + # then it will leave the package itself out of `c.depends` for the + # components of the package. + # Haskell.nix builds the components separately so we need + # to add the `library` component as a dependency. + ++ pkgs.lib.optional (p ? components && p.components ? lib) p.id + ) c.exe-depends; in { inherit name value; } )) components)); in diff --git a/test/setup-deps/pkg/src/Pkg.hs b/test/setup-deps/pkg/src/Pkg.hs new file mode 100644 index 0000000000..fc1111aa2e --- /dev/null +++ b/test/setup-deps/pkg/src/Pkg.hs @@ -0,0 +1,4 @@ +module Pkg where + +foo :: Int +foo = 1 diff --git a/test/setup-deps/pkg/src/conduit-test.hs b/test/setup-deps/pkg/src/conduit-test.hs deleted file mode 100644 index 696025f9fc..0000000000 --- a/test/setup-deps/pkg/src/conduit-test.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Main where - -import Conduit - -main = return ()