Skip to content

Handle internal libraries correctly #539

@sternenseemann

Description

@sternenseemann

Since 2.0, Cabal has a notion of internal libraries (which is any named library in the cabal file):

Cabal 2.0 and later support “internal libraries”, which are extra named libraries (as opposed to the usual unnamed library section). […]

Internal libraries are also useful for packages that define multiple executables, but do not define a publicly accessible library. Internal libraries are only visible internally in the package (so they can only be added to the build-depends of same-package libraries, executables, test suites, etc.) Internal libraries locally shadow any packages which have the same name; consequently, don’t name an internal library with the same name as an external dependency if you need to be able to refer to the external dependency in a build-depends declaration.

My intuition would be that we'd need to detect these and disable the internal library (i.e. setting isLibrary = false; in simple cases). An obvious example of this is jacinda which has an executable and an internal library we should not install.

It gets trickier if you have an internal library (e.g. for the test suite and executable) and a public library. We probably need to teach the generic-builder.nix in nixpkgs to distinguish between public and internal library instead of relying on isLibrary (which should only describe whether we have a public library or not).

What is a bit unclear to me is whether a public library can depend on an internal one and if we would need to install the internal one in such cases.

See also NixOS/nixpkgs#155924 (comment).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Enhancements

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions