Skip to content

Commit

Permalink
Create new function for all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeland73 committed Aug 11, 2023
1 parent 44ae470 commit 4248d69
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
14 changes: 10 additions & 4 deletions internal/impl/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,15 +932,21 @@ func (d *Devbox) PackageNames() []string {
}

func (d *Devbox) Packages() []*devpkg.Package {
userPackages := devpkg.PackageFromStrings(d.PackageNames(), d.lockfile)
pluginPackages, err := d.PluginManager().PluginInputs(userPackages)
return devpkg.PackageFromStrings(d.PackageNames(), d.lockfile)
}

// AllPackages returns user packages and plugin packages concatenated in
// correct order
func (d *Devbox) AllPackages() ([]*devpkg.Package, error) {
userPackages := d.Packages()
pluginPackages, err := d.PluginManager().PluginPackages(userPackages)
if err != nil {
panic(err)
return nil, err
}
// We prioritize plugin packages so that the php plugin works. Not sure
// if this is behavior we want for user plugins. We may need to add an optional
// priority field to the config.
return append(pluginPackages, userPackages...)
return append(pluginPackages, userPackages...), nil
}

func (d *Devbox) Includes() []plugin.Includable {
Expand Down
6 changes: 5 additions & 1 deletion internal/impl/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ func (d *Devbox) pendingPackagesForInstallation(ctx context.Context) ([]*devpkg.
if err != nil {
return nil, err
}
for _, pkg := range d.Packages() {
packages, err := d.AllPackages()
if err != nil {
return nil, err
}
for _, pkg := range packages {
_, err := nixprofile.ProfileListIndex(&nixprofile.ProfileListIndexArgs{
List: list,
Lockfile: d.lockfile,
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (m *Manager) ApplyOptions(opts ...managerOption) {
}
}

func (m *Manager) PluginInputs(inputs []*devpkg.Package) ([]*devpkg.Package, error) {
func (m *Manager) PluginPackages(inputs []*devpkg.Package) ([]*devpkg.Package, error) {
result := []*devpkg.Package{}
for _, input := range inputs {
config, err := getConfigIfAny(input, m.ProjectDir())
Expand Down
5 changes: 4 additions & 1 deletion internal/shellgen/flake_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ func newFlakePlan(ctx context.Context, devbox devboxer) (*flakePlan, error) {
}
}

packages := devbox.Packages()
packages, err := devbox.AllPackages()
if err != nil {
return nil, err
}
flakeInputs := flakeInputs(ctx, packages)
nixpkgsInfo := getNixpkgsInfo(devbox.Config().NixPkgsCommitHash())

Expand Down
1 change: 1 addition & 0 deletions internal/shellgen/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type devboxer interface {
Config() *devconfig.Config
Lockfile() *lock.File
Packages() []*devpkg.Package
AllPackages() ([]*devpkg.Package, error)
PluginManager() *plugin.Manager
ProjectDir() string
}
Expand Down

0 comments on commit 4248d69

Please sign in to comment.