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

Multi-package projects #27

Closed

Conversation

HariAmoor-professional
Copy link
Contributor

Closes #7

Labeled as draft b/c not yet tested

Copy link
Collaborator

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Some thoughts about the design and implementation. I hope it's helpful.

topLevelPackages = mkOption {
type = types.submodule {
options = {
enableMultiPkgs = mkBoolOption {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be inferred from dirs != []?

devShell = with pkgs.haskell.lib;
(addBuildTools package buildTools).envFunc { withHoogle = true; };
(addBuildTools package buildTools).envFunc (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps instead of envFunc, hp.shellFor would be nicer, because it merges the environments of multiple packages.

if cfg.topLevelPackages.enableMultiPkgs then
hp.${cfg.topLevelPackages.defaultPkg}
else
cfg.modifier (hp.callCabal2nixWithOptions cfg.name cfg.root "" { });
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's desirable to use the overlay (haskellPackages.extend) even in case of a single package, because it removes the possibility of accidentally using the Nixpkgs version of the package instead of the locally defined one.

@@ -110,6 +110,32 @@ in
};
};
};
topLevelPackages = mkOption {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the topLevelPackages namespace shouldn't be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@roberth Then how do you define defaultPkg? Or should you not need to?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not need to define a single package.

Currently haskellProjects.<proj> defined a flake packages package for each <proj>. That 1:1 relation is what package is for, but now we'll have multiple packages per project.
For each haskellProjects.<proj>.dirs.*, we could have a package named <proj>-<dirname>.
Ideally we'd use the actual package name instead of the directory name.

A list of directories is actual a bit "high level". I think a good first step is to create an attrsOf submodule for the locally defined packages. For example:
haskellProjects.<proj>.package.<pkgname>.src
haskellProjects.<proj>.package.<pkgname>.packageAttribute (default: ${proj}-${pkgname})

The logic for that should be more straightforward to implement than dirs, but you can still write dirs to make use of those options and get a good separation of concerns. It also allows a bit more control: customizing the package attribute, and perhaps some extra options to pass to cabal2nix.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, the structure should be more or less like that. I just put a concrete proposal here (should have done it long ago to assist in this PR): #7 (comment)

The flakeAttribute part (or packageAttribute in the above comment) is still not clear to me. I suppose we can finalize that once the general functionality is in place (in the PR).

flake-module.nix Outdated Show resolved Hide resolved
Change `buildInputs` to `nativeBuildInputs`

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
@HariAmoor-professional
Copy link
Contributor Author

Closed in favor of a new PR (to be delivered)

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.

Multi-package projects
3 participants