Skip to content

Commit da47197

Browse files
committed
[perf] in syncPackagesToProfile, only removeExtraItemsFromProfile is mode is not install
1 parent 609f2bc commit da47197

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed
45.1 KB
Binary file not shown.

internal/impl/packages.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ func (d *Devbox) profilePath() (string, error) {
301301
return absPath, errors.WithStack(os.MkdirAll(filepath.Dir(absPath), 0o755))
302302
}
303303

304-
// syncPackagesToProfile ensures that all packages in devbox.json exist in the nix profile,
305-
// and no more.
304+
// syncPackagesToProfile can ensure that all packages in devbox.json exist in the nix profile,
305+
// and no more. However, it may skip some steps depending on the `mode`.
306306
func (d *Devbox) syncPackagesToProfile(ctx context.Context, mode installMode) error {
307307
defer debug.FunctionTimer().End()
308308
defer trace.StartRegion(ctx, "syncPackagesToProfile").End()
@@ -330,9 +330,12 @@ func (d *Devbox) syncPackagesToProfile(ctx context.Context, mode installMode) er
330330
}
331331

332332
// Second, remove any packages from the nix-profile that are not in the config
333-
itemsToKeep, err := d.removeExtraItemsFromProfile(ctx, profileDir, profileItems, packages)
334-
if err != nil {
335-
return err
333+
itemsToKeep := profileItems
334+
if mode != install {
335+
itemsToKeep, err = d.removeExtraItemsFromProfile(ctx, profileDir, profileItems, packages)
336+
if err != nil {
337+
return err
338+
}
336339
}
337340

338341
// we are done if mode is uninstall

trace.out

49.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)