-
Notifications
You must be signed in to change notification settings - Fork 249
[nix.System] call EnsureNixInstalled from devbox.Open, and cleanup function API #1374
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
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
fd2fab6
to
55e9d30
Compare
internal/nix/nix.go
Outdated
} | ||
} | ||
return cachedSystem | ||
} | ||
|
||
var cachedSystem string | ||
|
||
// TODO: rename to ComputeSystem or ComputePlatform? | ||
func System() (string, error) { | ||
func ComputeSystem() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComputeSystem should only return error (we always discard the string)
55e9d30
to
7380cb8
Compare
I had to bump the test-timeout to land this. We needed this PR for correctness. But I will pursue a fix to improve the test times. |
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Summary
nix.System
is widely used. So, in #1357 we wanted to change its API to justreturn
string
instead ofstring, error
.To do so, we cache the result in a
nix
package variable. And populate itduring
EnsureNixInstalled
.However,
EnsureNixInstalled
was only called from Cobra command functions. Butdevbox
as a library also now needs to call it. IMO, it should always have calledit since we do rely on
nix
being installed. This PR adds this.It also fixes up the API to:
System: string
andComputeSystem: (string, error)
.NOTE: inside
System
, I still do a best-effort to avoid panic by callingComputeSystem
. This can happen in edge-cases like some testsgenerate_test/TestWriteFromTemplate
that exercise internal functions reliant on
nix.System
without callingdevbox.Open
.How was it tested?
tests should pass