Skip to content
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

Add haskellProjects.foo.finalPackages to expose the final package set #52

Closed
srid opened this issue Jan 5, 2023 · 7 comments
Closed
Labels
good first issue Good for newcomers

Comments

@srid
Copy link
Owner

srid commented Jan 5, 2023

We want to expose the following as an option:

finalPackages = cfg.haskellPackages.extend finalOverlay;

This will be useful here: https://github.com/srid/ema-template/pull/45/files#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0L63

Where instead of using lib.getExe pkgs.haskellPackages.ghcid (incorrect, because ghcid was overriden) I can instead accurately use lib.getExe config.haskellPackages.main.finalPackages.ghcid.

@srid srid added the good first issue Good for newcomers label Jan 5, 2023
@roberth
Copy link
Collaborator

roberth commented Jan 5, 2023

perSystem.haskellProjects.<name>.haskellPackages would have been a nice name, but that's taken.

How about haskellProject.<name>.finalPackages?

You'll have to move the overlay logic from the perSystem level to the haskellProjects.<name> level to make that work, but I think that's a nice place for that logic to be anyway.

@srid
Copy link
Owner Author

srid commented Jan 5, 2023

Sure, finalPackages is better.

But, I'm questioning the naming of haskellPackages now. Should we rename it to something else, like basePackages? The idea being:

basePackages --[ source-overrides; overrides; local packages ]--> finalPackages

It is straightforward to explain, viz.: "You start from base packages, apply overrides and local packages, you get final package set".

@roberth
Copy link
Collaborator

roberth commented Jan 5, 2023

Sounds good to me!

@srid srid changed the title Add haskellPackages.foo.packages to expose the final package set Add haskellProjects.foo.finalPackages to expose the final package set Feb 1, 2023
@srid srid pinned this issue Feb 5, 2023
@srid
Copy link
Owner Author

srid commented Feb 6, 2023

How about this API, where we group overlay-affecting settings into a submodule called packageSet?

haskellProjects.foo = {
  devShell.enable = false;
  packageSet = {
    # The overlays are composed in the order they are shown here.
    base = pkgs.haskell.packages.ghc944;
    local = {
      mypkg.root = ./.;  # Assumes mypkg.cabal
    };
    source-overrides = { .. }; # Overrides by direct path to source
    overrides = self: super:  { .. };  # Raw Haskell overlay
  };

Users can then use config.haskellPackages.foo.packageSet.final to access all the packages. The idea is that we can say "start from base", then we apply local, then source-overrides and finally overrides, before creating the project specific haskell package set.

Does it make sense, from API documentation/comprehension/simplicity standpoint, to group the overlay related options like this? Or is it complex? I have a tendency introduce unnecessary abstractions, so it would be good to get some feedback here.

@maralorn
Copy link

maralorn commented Feb 6, 2023

Honestly: I think most interfaces are fine if they are well documented.

From the face of it, I don’t see anything wrong with this one, but problems may only become apparent when using it. Grouping all related options under packageSet will probably be a bit complicated for very simple flakes, but I don’t have a strong opinion about it. Besides packageSet.final I’d like to see a read-only option like packageSet.localPackages or something where one can get all local Haskell packages (to e.g. iterate over) but does not include other packages which could also be in the default packages attribute.

@srid
Copy link
Owner Author

srid commented Feb 6, 2023

I’d like to see a read-only option like packageSet.localPackages or something where one can get all local Haskell packages (to e.g. iterate over) but does not include other packages which could also be in the default packages attribute.

@maralorn With #63 you can access the local packages in the "foo" project using config.haskellProjects.foo.outputs.packages.

This was referenced Feb 8, 2023
@srid
Copy link
Owner Author

srid commented Feb 8, 2023

Done by #68; rest of discussion to continue in #72

@srid srid closed this as completed Feb 8, 2023
@srid srid unpinned this issue Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants