Skip to content

Commit

Permalink
Fix components in build-type: Custom packages (#2257)
Browse files Browse the repository at this point in the history
* Fix components in `build-type: Custom` packages

These components may depend on the `library` component of the package however `plan.json` does not include that dependency (since cabal will build all the components at once).  This fix adds the library component as a dependency of the other components.

* ifdLevel 1

* Add comment and only include library if there is one.

* ifdLevel 2

* ifdLevel 3

* Fix broken test
  • Loading branch information
hamishmack authored Oct 9, 2024
1 parent 76c57d5 commit 1cc7d4b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 9 additions & 1 deletion lib/load-cabal-plan.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/setup-deps/pkg/src/Pkg.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Pkg where

foo :: Int
foo = 1
5 changes: 0 additions & 5 deletions test/setup-deps/pkg/src/conduit-test.hs

This file was deleted.

0 comments on commit 1cc7d4b

Please sign in to comment.