Skip to content

Commit b74e651

Browse files
authored
[easy][global] Set lower priority for global (#698)
## Summary I'm running into some weird CICD resource issue on #695 so I'm splitting that up into smaller PRs. ## How was it tested? ```bash devbox global add go_1_20 devbox add go_1_19 devbox shell ```
1 parent f2ad449 commit b74e651

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/impl/packages.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func (d *Devbox) addPackagesToProfile(mode installMode) error {
8989
cmd := exec.Command(
9090
"nix", "profile", "install",
9191
"--profile", profileDir,
92+
"--priority", d.getPackagePriority(pkg),
9293
"--impure", // Needed to allow flags from environment to be used.
9394
nix.FlakeNixpkgs(d.cfg.Nixpkgs.Commit)+"#"+pkg,
9495
)
@@ -193,6 +194,18 @@ func (d *Devbox) pendingPackagesForInstallation() ([]string, error) {
193194
return pending, nil
194195
}
195196

197+
// This sets the priority of non-devbox.json packages to be slightly lower (higher number)
198+
// than devbox.json packages. This matters for profile installs, but doesn't matter
199+
// much for the flakes.nix file. There we rely on the order of packages (local ahead of global)
200+
func (d *Devbox) getPackagePriority(pkg string) string {
201+
for _, p := range d.cfg.RawPackages {
202+
if p == pkg {
203+
return "5"
204+
}
205+
}
206+
return "6" // Anything higher than 5 (default) would be correct
207+
}
208+
196209
var resetCheckDone = false
197210

198211
// resetProfileDirForFlakes ensures the profileDir directory is cleared of old

0 commit comments

Comments
 (0)