Skip to content

Adds sublib support #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2019
Merged

Adds sublib support #63

merged 4 commits into from
Mar 13, 2019

Conversation

angerman
Copy link
Collaborator

This adds the sublib test. Execute with

nix build -f default.nix cabal-sublib --show-trace

and enjoy the gore!

Changing modules/plan.nix to:

@@ -53,7 +53,8 @@ with types;
 
       let m = if revision == null
               then (abort "${name} has no revision!")
-              else revision modArgs;
+              else revision (modArgs // { hsPkgs = hsPkgs // m.components.sublibs; });
       in m // { flags = lib.mapAttrs (_: lib.mkDefault) (m.flags // revArgs.flags or {}); }
     ) (lib.filterAttrs (n: v: v == null || v.revision != null ) module.packages);
   };

does get us a bit further. However, this results in the dependency to be a raw sublib instead of a package. And subsequently leads to breakage in the builder/comp-builder.nix.

@ElvishJerricco
Copy link
Contributor

I don't think we want sublibs in the global package set, do we? Shouldn't we instead just augment the hsPkgs provided to each package to include its sublibs?

@angerman
Copy link
Collaborator Author

I don't think we want sublibs in the global package set, do we? Shouldn't we instead just augment the hsPkgs provided to each package to include its sublibs?

Right! That's precisely what I tried to get done properly :-)
See
https://github.com/input-output-hk/haskell.nix/pull/63/files#diff-b43b54fd141cefb908e8f8c428a5fa5f

@angerman angerman changed the title Adds sublib tests Adds sublib support Feb 22, 2019
#
# Note 2: if a package contains multiple libs (lib + sublibs) SETUP register will generate a
# folder isntead of a file for the configuration. Therfore if the result is a folder,
# we need to register each and every element of that folder.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there only be one package per derivation? Why would there be multiple?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the issue is the all target. If you run the following on a cabal file with a sublibrary:

$ runghc Setup.hs configure # without component target, as we do for `all`.
$ runghc Setup.hs register --gen-pkg-config=pkg.conf

you end up with a folder for pkg.conf that contains the package configuration file for the library as well as the sublibrary.

If you don't have sublibraries, pkg.conf is your package configuration file.

Copy link
Contributor

Choose a reason for hiding this comment

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

@angerman So this only comes up when a package depends on the all component? That shouldn't happen, should it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why should this not happen? Why wouldn't we build the all component? We do allow this right now (and the test case tried to do precisely that).

Thus, unless we want to remove the all component again, I'm afraid we'll need to keep this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@angerman The all component is, to my understanding, only for the sake of users who want a shell for all, plus the novel purpose of building all components in one derivation. The intention is that components will depend on components, not on any all derivation.

@angerman angerman merged commit 8ffa7cd into master Mar 13, 2019
@angerman angerman deleted the feature/sublibs branch March 13, 2019 07:43
andreabedini pushed a commit to andreabedini/haskell.nix that referenced this pull request Sep 14, 2022
andreabedini pushed a commit to andreabedini/haskell.nix that referenced this pull request Sep 14, 2022
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.

2 participants