@@ -5,15 +5,13 @@ package devbox
55
66import (
77 "context"
8- "fmt"
98 "io/fs"
109 "os"
1110 "path/filepath"
1211
1312 "github.com/pkg/errors"
1413 "go.jetpack.io/devbox/internal/devpkg"
1514 "go.jetpack.io/devbox/internal/nix"
16- "go.jetpack.io/devbox/internal/nix/nixprofile"
1715
1816 "go.jetpack.io/devbox/internal/xdg"
1917)
@@ -47,7 +45,9 @@ func (d *Devbox) addDevboxUtilityPackage(ctx context.Context, pkgName string) er
4745 return nil
4846}
4947
50- func (d * Devbox ) removeDevboxUtilityPackage (pkgName string ) error {
48+ func (d * Devbox ) removeDevboxUtilityPackage (
49+ ctx context.Context , pkgName string ,
50+ ) error {
5151 pkg := devpkg .PackageFromStringWithDefaults (pkgName , d .lockfile )
5252 installables , err := pkg .Installables ()
5353 if err != nil {
@@ -59,20 +59,15 @@ func (d *Devbox) removeDevboxUtilityPackage(pkgName string) error {
5959 return err
6060 }
6161
62- profile , err := nixprofile .ProfileListItems (d .stderr , utilityProfilePath )
63- if err != nil {
64- return err
65- }
66-
6762 for _ , installable := range installables {
68- for i , profileItem := range profile {
69- if profileItem . MatchesUnlockedReference ( installable ) {
70- err = nix . ProfileRemove ( utilityProfilePath , fmt . Sprint ( i ))
71- if err != nil {
72- return err
73- }
74- // We are done with this installable. Now, remove the next installable:
75- break
63+ storePaths , err := nix . StorePathsFromInstallable ( ctx , installable , false )
64+ if err != nil {
65+ return err
66+ }
67+
68+ for _ , storePath := range storePaths {
69+ if err = nix . ProfileRemove ( utilityProfilePath , storePath ); err != nil {
70+ return err
7671 }
7772 }
7873 }
0 commit comments