Skip to content

Commit d312585

Browse files
committed
remove ProfileInstallPackage
1 parent a859c19 commit d312585

File tree

2 files changed

+13
-32
lines changed

2 files changed

+13
-32
lines changed

internal/devbox/util.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@ import (
1010
"path/filepath"
1111

1212
"github.com/pkg/errors"
13-
"go.jetpack.io/devbox/internal/nix/nixprofile"
1413

14+
"go.jetpack.io/devbox/internal/devpkg"
15+
"go.jetpack.io/devbox/internal/nix/nixprofile"
1516
"go.jetpack.io/devbox/internal/xdg"
1617
)
1718

1819
// addDevboxUtilityPackage adds a package to the devbox utility profile.
1920
// It's used to install applications devbox might need, like process-compose
2021
// This is an alternative to a global install which would modify a user's
2122
// environment.
22-
func (d *Devbox) addDevboxUtilityPackage(ctx context.Context, pkg string) error {
23+
func (d *Devbox) addDevboxUtilityPackage(ctx context.Context, pkgName string) error {
24+
pkg := devpkg.PackageFromStringWithDefaults(pkgName, d.lockfile)
25+
installable, err := pkg.Installable()
26+
if err != nil {
27+
return err
28+
}
2329
profilePath, err := utilityNixProfilePath()
2430
if err != nil {
2531
return err
2632
}
27-
28-
return nixprofile.ProfileInstallPackage(ctx, &nixprofile.ProfileInstallPackageArgs{
29-
Lockfile: d.lockfile,
30-
Package: pkg,
33+
return nixprofile.ProfileInstall(ctx, &nixprofile.ProfileInstallArgs{
34+
Installable: installable,
35+
PackageName: pkgName,
3136
ProfilePath: profilePath,
3237
Writer: d.stderr,
3338
})

internal/nix/nixprofile/profile.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -194,32 +194,6 @@ func parseNixProfileListItem(line string) (*NixProfileListItem, error) {
194194
}, nil
195195
}
196196

197-
// TODO drop the Profile prefix from this name.
198-
type ProfileInstallPackageArgs struct {
199-
CustomStepMessage string
200-
Lockfile *lock.File
201-
Package string
202-
ProfilePath string
203-
Writer io.Writer
204-
}
205-
206-
// ProfileInstallPackage installs a Devbox package into a profile.
207-
// TODO drop the Profile prefix from this name.
208-
func ProfileInstallPackage(ctx context.Context, args *ProfileInstallPackageArgs) error {
209-
pkg := devpkg.PackageFromStringWithDefaults(args.Package, args.Lockfile)
210-
installable, err := pkg.Installable()
211-
if err != nil {
212-
return err
213-
}
214-
return ProfileInstall(ctx, &ProfileInstallArgs{
215-
CustomStepMessage: args.CustomStepMessage,
216-
Installable: installable,
217-
PackageName: args.Package,
218-
ProfilePath: args.ProfilePath,
219-
Writer: args.Writer,
220-
})
221-
}
222-
223197
// TODO drop the Profile prefix from this name.
224198
type ProfileInstallArgs struct {
225199
CustomStepMessage string
@@ -230,6 +204,8 @@ type ProfileInstallArgs struct {
230204
Writer io.Writer
231205
}
232206

207+
// ProfileInstall installs a package into a profile. Its a convenience wrapper around nix.ProfileInstall
208+
// that can print nicer output when installing multiple packages.
233209
// TODO drop the Profile prefix from this name.
234210
func ProfileInstall(ctx context.Context, args *ProfileInstallArgs) error {
235211
stepMsg := args.PackageName

0 commit comments

Comments
 (0)