-
Notifications
You must be signed in to change notification settings - Fork 264
First Pass at a Haskell Package Planner #773
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
func (p *V2Planner) IsRelevantForPackages(packages []string) bool { | ||
p.userPackages = packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of scope for this PR, but this is a strange API, where we save packages
as a side-effect in a boolean IsRelevantForPackages function call....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also weird that we do 2 passes of the regex, one to detect if the planner is relevant, and another to actually create the shell plan -- should we be storing the results of the IsRelevantForPackages
and then reusing it in GetShellPlan
?
452360c
to
8799fce
Compare
This is now working for both the versioned and default GHC packages. My Go code may be a bit gnarly, so happy to make updates where needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lagoja mostly lgtm, but what do you think of the union idea below?
pkgs := p.GetShellPlan(srcDir).DevPackages | ||
mutualPkgs := lo.Intersect(userPkgs, pkgs) | ||
// Only apply shell plan if user packages list all the packages from shell plan. | ||
if len(mutualPkgs) == len(pkgs) { | ||
// if merge fails, we return no errors for now. | ||
result, _ = plansdk.MergeShellPlans(result, p.GetShellPlan(srcDir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is safe given our haskell and php planners. The getRelevantPlanners
should filter appropriately.
internal/impl/devbox.go
Outdated
// If the DevPackages are empty, set them to userDefinedPkgs. | ||
if len(shellPlan.DevPackages) == 0 { | ||
shellPlan.DevPackages = userDefinedPkgs | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Lagoja I think we want a union of userDefinedPkgs and DevPackages. That way, each shell planner can be focussed purely on its own packages. And we don't drop other user packages.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that might be safer, but it means that planners can't filter the package list after adding them to the definition, which leads to weird stuff like including PHP extensions and haskell compilers twice.
I'll test with union, and if everything works we can go that way for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this to:
shellPlan.DevPackages = pkgslice.Unique(append(shellPlan.DevPackages, userDefinedPkgs...))
Summary
This PR addresses #29, using a similar framework as our PHP planner. It makes it possible to use Haskell packages installed via
haskellPackages
alongside GHC.This PR is incomplete - right now it only works for the default
ghc
in Nixpkg. We should make sure that we can detect when users request a different compiler version (likehaskell.compiler.ghc810
)How was it tested?
Default GHC: Use the following devbox.json:
Run
devbox shell
, then runghc-pkg list | grep aeson
to make sure that it installed correctlyVersioned GHC: Use the following devbox.json
Run
devbox shell
, then runghc-pkg list | grep aeson
to make sure that it installed correctly. Also confirm that other packages installed as expected