You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Outputs] Add store-paths of package outputs to devbox.lock (#1814)
## Summary
This PR updates the `devbox.lock` file to incorporate the expanded
response from `/v2/resolve` api. This `/v2/response` incorporates
store-paths for each output of the nix package.
To do so, we update `lock.SystemInfo` to expect `[]Output` instead of
the previous `StorePath string`. This `SystemInfo` struct needs to be
backwards-compatible to read existing `devbox.lock` files that have the
`StorePath` string. So, the read-path in `lock.GetFile` has some
fallback code to handle this scenario, where the `StorePath` is added as
`Output{ Name: "out", path: <path>, Default: true}`.
The main challenge with writing this PR was that we don't want to update
`devbox.lock` _unless_ there's been an explicit user action of the form
`devbox update` or `devbox add` or `devbox remove`. Unfortunately, the
`lock.File` gets internally updated by various code paths using its
`file.Resolve()` function, and so it was (previously) hard for the
lockfile
to track when an add/remove/update action happened.
To work around this, I have more explicitly invoked `lockfile.Add` and
`lockfile.Remove` in the "add package" and "remove package" code paths.
I think this is safe to do, but let me know if you feel a better path
exists. This lets us track whether to write the lockfile with the legacy
format of `lock.SystemInfo` (i.e. Store Path) or the modern format (i.e.
[]Output).
## How was it tested?
1. `devbox update` in devbox-repo doesn't have changes so the lock file
wasn't changed.
2. `rm -rf .devbox && devbox shell`. The lockfile wasn't changed.
3. `devbox add prometheus` added the package in the modern []Output
format of SystemInfo, and also updated the other packages to use the
modern SystemInfo format.
0 commit comments