@@ -121,8 +121,7 @@ func (d *Devbox) mergeResolvedPackageToLockfile(
121
121
// sync the profile so we don't need to do this manually.
122
122
ux .Fwarning (d .stderr , "Failed to remove %s from profile: %s\n " , pkg , err )
123
123
}
124
- resolved .AllowInsecure = existing .AllowInsecure
125
- lockfile .Packages [pkg .Raw ] = resolved
124
+ useResolved (lockfile , pkg , resolved , existing )
126
125
return nil
127
126
}
128
127
@@ -133,30 +132,33 @@ func (d *Devbox) mergeResolvedPackageToLockfile(
133
132
lockfile .Packages [pkg .Raw ].Systems = map [string ]* lock.SystemInfo {}
134
133
}
135
134
135
+ newSystems := map [string ]* lock.SystemInfo {}
136
136
userSystem := nix .System ()
137
137
updated := false
138
138
for sysName , newSysInfo := range resolved .Systems {
139
+ newSystems [sysName ] = newSysInfo
140
+
141
+ // Check whether we are actually updating any system info.
139
142
if sysName == userSystem {
140
143
// The resolved pkg has a system info for the user's system, so add/overwrite it.
141
144
if ! newSysInfo .Equals (existing .Systems [userSystem ]) {
142
145
// We only guard this so that the ux messaging is accurate. We could overwrite every time.
143
- lockfile .Packages [pkg .Raw ].Systems [userSystem ] = newSysInfo
144
146
updated = true
145
147
}
146
148
} else {
147
149
// Add other system infos if they don't exist, or if we have a different StorePath. This may
148
- // overwrite an existing CAPath , but to ensure correctness we should ensure that all StorePaths
150
+ // overwrite an existing StorePath , but to ensure correctness we should ensure that all StorePaths
149
151
// come from the same package version.
150
152
existingSysInfo , exists := existing .Systems [sysName ]
151
153
if ! exists || existingSysInfo .StorePath != newSysInfo .StorePath {
152
- lockfile .Packages [pkg .Raw ].Systems [sysName ] = newSysInfo
153
154
updated = true
154
155
}
155
156
}
156
157
}
157
158
if updated {
158
- // if we are updating the system info, then we should also update the resolved path
159
- lockfile .Packages [pkg .Raw ].Resolved = resolved .Resolved
159
+ // if we are updating the system info, then we should also update the other fields
160
+ useResolved (lockfile , pkg , resolved , existing )
161
+ lockfile .Packages [pkg .Raw ].Systems = newSystems
160
162
161
163
ux .Finfo (d .stderr , "Updated system information for %s\n " , pkg )
162
164
return nil
@@ -193,3 +195,13 @@ func (d *Devbox) attemptToUpgradeFlake(pkg *devpkg.Package) error {
193
195
194
196
return nil
195
197
}
198
+
199
+ func useResolved (
200
+ lockfile * lock.File ,
201
+ pkg * devpkg.Package ,
202
+ resolved * lock.Package ,
203
+ existing * lock.Package ,
204
+ ) {
205
+ lockfile .Packages [pkg .Raw ] = resolved
206
+ lockfile .Packages [pkg .Raw ].AllowInsecure = existing .AllowInsecure
207
+ }
0 commit comments