Skip to content

Commit ef4cd1e

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

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

devbox.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"packages": [
33
"go@latest",
4-
"runx:golangci/golangci-lint@latest"
4+
"runx:golangci/golangci-lint@latest",
5+
"vim@latest"
56
],
67
"env": {
78
"GOENV": "off",

devbox.lock

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@
2323
},
2424
"runx:golangci/golangci-lint@latest": {
2525
"resolved": "runx:golangci/golangci-lint@latest"
26+
},
27+
"vim@latest": {
28+
"last_modified": "2023-09-27T18:02:17Z",
29+
"resolved": "github:NixOS/nixpkgs/517501bcf14ae6ec47efd6a17dda0ca8e6d866f9#vim",
30+
"source": "devbox-search",
31+
"version": "9.0.1897",
32+
"systems": {
33+
"aarch64-darwin": {
34+
"store_path": "/nix/store/ljl4mh36bsr1sk7gagyn2v2hsn4b880s-vim-9.0.1897"
35+
},
36+
"aarch64-linux": {
37+
"store_path": "/nix/store/h12mgqn9wgvwlpwsdpxzjjs205awlhyv-vim-9.0.1897"
38+
},
39+
"x86_64-darwin": {
40+
"store_path": "/nix/store/an96p2a9l235cyw0iiq9brqhlwd43jpl-vim-9.0.1897"
41+
},
42+
"x86_64-linux": {
43+
"store_path": "/nix/store/mspb2bklaqssjwpmcicwvsmqrh1ffb96-vim-9.0.1897"
44+
}
45+
}
2646
}
2747
}
2848
}
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)