jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

fix(nix): add support for Nix forks #2091

Closed SapphicCode closed 1 month ago

SapphicCode commented 1 month ago

Summary

Increases leniency for nix --version output to support Nix forks, such as Lix:

nix (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab

How was it tested?

On Lix:

$ nix --version
nix (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab

$ go run ./cmd/devbox run nix --version
nix (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab

$ go run ./cmd/devbox shell
# (works as expected)

On Nix:

$ nix shell nixpkgs#nix

$ nix --version
nix (Nix) 2.18.2

$ go run ./cmd/devbox run nix --version
nix (Nix) 2.18.2

$ go run ./cmd/devbox shell
# (works as expected)

What did it look like before?

$ go run ./cmd/devbox shell
Error: nix: ensure install: get version: parse nix version: nix (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab

exit status 1
gcurtis commented 1 month ago

@SapphicCode thanks for the PR! I made the regex a little more lenient and added some tests. I'll merge this after tests pass.