Skip to content

[remove nixpkgs] bug fix: update only the user's sysInfo, rather than for all systems #1259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/devpkg/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ func (p *Package) ContentAddressedPath() (string, error) {

ux.Fwarning(
os.Stderr,
"calculating local_store_path. This may be slow.\n"+
"Run `devbox update` to speed this up for next time.",
"calculating ca_store_path. This may be slow. "+
"Run `devbox update` to speed this up for next time.\n",
)
localPath, err := nix.ContentAddressedStorePath(sysInfo.StorePath)
if err != nil {
Expand Down
39 changes: 24 additions & 15 deletions internal/impl/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"go.jetpack.io/devbox/internal/boxcli/featureflag"
"go.jetpack.io/devbox/internal/devpkg"
"go.jetpack.io/devbox/internal/lock"
"go.jetpack.io/devbox/internal/nix"
"go.jetpack.io/devbox/internal/nix/nixprofile"
"go.jetpack.io/devbox/internal/searcher"
Expand Down Expand Up @@ -115,22 +116,30 @@ func (d *Devbox) updateDevboxPackage(
return err
}

// Check if the system info is missing for the user's system.
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
if sysInfo == nil {
d.lockfile.Packages[pkg.Raw] = newEntry
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
return nil
}
// If the newEntry has a system info for the user's system,
// then check if we need to update system info
if newEntry.Systems[userSystem] != nil {

// Check if the system info is missing for the user's system.
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
if sysInfo == nil {
if d.lockfile.Packages[pkg.Raw].Systems == nil {
d.lockfile.Packages[pkg.Raw].Systems = map[string]*lock.SystemInfo{}
}
d.lockfile.Packages[pkg.Raw].Systems[userSystem] = newEntry.Systems[userSystem]
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
return nil
}

// Check if the CAStorePath is missing for the user's system.
// Since any one user cannot add this field for all systems,
// we'll need to progressively add it to a project's lockfile.
if sysInfo.CAStorePath == "" {
// Update the CAStorePath for the user's system
d.lockfile.Packages[pkg.Raw].Systems[userSystem].CAStorePath = newEntry.Systems[userSystem].CAStorePath
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
return nil
// Check if the CAStorePath is missing for the user's system.
// Since any one user cannot add this field for all systems,
// we'll need to progressively add it to a project's lockfile.
if sysInfo.CAStorePath == "" {
// Update the CAStorePath for the user's system
d.lockfile.Packages[pkg.Raw].Systems[userSystem].CAStorePath = newEntry.Systems[userSystem].CAStorePath
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
return nil
}
}
}

Expand Down