Skip to content

Commit 822511a

Browse files
authored
Add nix package manager detector and error if not installed (#2641)
## Summary Check if nix package manager is installed before calling nix ## How was it tested? `go build -o devbox cmd/devbox/main.go` `devbox shell` ## Is this change backwards-compatible? Yes
1 parent e9c08b4 commit 822511a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

nix/nix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ package nix
66
import (
77
"bytes"
88
"encoding/json"
9+
"errors"
910
"fmt"
1011
"os"
1112
"os/exec"
1213
"strings"
1314
)
1415

1516
func Shell(path string) error {
17+
_, err := exec.LookPath("nix-shell")
18+
if err != nil {
19+
return errors.New("Could not find nix in your PATH\nInstall nix by following the instructions at https://nixos.org/download.html and make sure you've set up your PATH correctly.")
20+
}
1621
cmd := exec.Command("nix-shell", path)
1722
// Default to the shell already being used.
1823
shell := os.Getenv("SHELL")

0 commit comments

Comments
 (0)