Skip to content

support multiple libraries in one package - #717

Open
m1-s wants to merge 1 commit into
NixOS:masterfrom
m1-s:subLibraries
Open

support multiple libraries in one package#717
m1-s wants to merge 1 commit into
NixOS:masterfrom
m1-s:subLibraries

Conversation

@m1-s

@m1-s m1-s commented Apr 17, 2026

Copy link
Copy Markdown

This PR adds support for multiple libraries in one package. These libraries can have visibility public or private.

Fixes #448

(This is my first contribution in this repo. I am not familiar with the codebase. Happy to hear feedback.)

@m1-s
m1-s marked this pull request as ready for review April 19, 2026 16:43
@m1-s

m1-s commented Apr 19, 2026

Copy link
Copy Markdown
Author

@L0neGamer fyi

@ju1m ju1m left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this problem @m1-s. I just did a surface review without understanding much about the code, I'm not part of cabal2nix's maintainers but I think it's important to improve the support for sub-libraries. Cheers.

, _testDepends = error "undefined Derivation.testDepends"
, _benchmarkDepends = error "undefined Derivation.benchmarkDepends"
, _subLibraryDepends = mempty
, _subLibraryDependencies = mempty

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: shouldn't those be error like others?

-- For backwards compatibility, libraryHaskellDepends is emitted as the
-- union of the main library deps and all sub-library deps. New consumers
-- should prefer the separate subLibraryDepends attrset.
mergedLibraryDepends = _libraryDepends `mappend` foldMap id (Map.elems subLibDeps)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mergedLibraryDepends = _libraryDepends `mappend` foldMap id (Map.elems subLibDeps)
mergedLibraryDepends = _libraryDepends `mappend` fold (Map.elems subLibDeps)

Unless you want a strict version, then it would be:

Suggested change
mergedLibraryDepends = _libraryDepends `mappend` foldMap id (Map.elems subLibDeps)
mergedLibraryDepends = _libraryDepends `mappend` foldMap' id (Map.elems subLibDeps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple public libraries

2 participants