mergeResolvedFlakeToLockfile updates the lockfile entry for a flake ref. It compares on Resolved (which embeds the locked rev) rather than Version since flake refs don't carry a semver. It honors the same LastModified staleness guard as the nixpkgs path.
( pkg *devpkg.Package, resolved *lock.Package, existing *lock.Package, lockfile *lock.File, )
| 231 | // flake refs don't carry a semver. It honors the same LastModified staleness |
| 232 | // guard as the nixpkgs path. |
| 233 | func (d *Devbox) mergeResolvedFlakeToLockfile( |
| 234 | pkg *devpkg.Package, |
| 235 | resolved *lock.Package, |
| 236 | existing *lock.Package, |
| 237 | lockfile *lock.File, |
| 238 | ) error { |
| 239 | if existing.Resolved == resolved.Resolved { |
| 240 | ux.Finfof(d.stderr, "Already up-to-date %s\n", pkg) |
| 241 | return nil |
| 242 | } |
| 243 | |
| 244 | // Skip the guard if either side is missing a timestamp — treat unknown as |
| 245 | // not-older so we don't block a legit update. |
| 246 | if existing.LastModified != "" && resolved.LastModified != "" && |
| 247 | existing.LastModified > resolved.LastModified { |
| 248 | ux.Fwarningf( |
| 249 | d.stderr, |
| 250 | "Resolved ref for %s has older last_modified time. Not updating\n", |
| 251 | pkg, |
| 252 | ) |
| 253 | return nil |
| 254 | } |
| 255 | |
| 256 | ux.Finfof(d.stderr, "Updating %s %s\n", pkg, describeFlakeUpdate(existing, resolved)) |
| 257 | useResolvedPackageInLockfile(lockfile, pkg, resolved, existing) |
| 258 | return nil |
| 259 | } |
| 260 | |
| 261 | // describeFlakeUpdate renders a short human-readable diff between two flake |
| 262 | // lockfile entries. It prefers short revs when both sides have them, falls |
no test coverage detected