Skip to content

Commit 9df671e

Browse files
committed
[perf] in syncPackagesToProfile, only removeExtraItemsFromProfile is mode is not install
1 parent 6ca1aea commit 9df671e

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
@@ -305,8 +305,8 @@ func (d *Devbox) profilePath() (string, error) {
305305
return absPath, errors.WithStack(os.MkdirAll(filepath.Dir(absPath), 0o755))
306306
}
307307

308-
// syncPackagesToProfile ensures that all packages in devbox.json exist in the nix profile,
309-
// and no more.
308+
// syncPackagesToProfile can ensure that all packages in devbox.json exist in the nix profile,
309+
// and no more. However, it may skip some steps depending on the `mode`.
310310
func (d *Devbox) syncPackagesToProfile(ctx context.Context, mode installMode) error {
311311
defer debug.FunctionTimer().End()
312312
defer trace.StartRegion(ctx, "syncPackagesToProfile").End()
@@ -334,9 +334,12 @@ func (d *Devbox) syncPackagesToProfile(ctx context.Context, mode installMode) er
334334
}
335335

336336
// Second, remove any packages from the nix-profile that are not in the config
337-
itemsToKeep, err := d.removeExtraItemsFromProfile(ctx, profileDir, profileItems, packages)
338-
if err != nil {
339-
return err
337+
itemsToKeep := profileItems
338+
if mode != install {
339+
itemsToKeep, err = d.removeExtraItemsFromProfile(ctx, profileDir, profileItems, packages)
340+
if err != nil {
341+
return err
342+
}
340343
}
341344

342345
// we are done if mode is uninstall

trace.out

49.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)