Skip to content

Commit

Permalink
Add nix package manager detector and error if not installed (#2641)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
LucilleH authored Aug 26, 2022
1 parent e9c08b4 commit 822511a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nix/nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ package nix
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
"strings"
)

func Shell(path string) error {
_, err := exec.LookPath("nix-shell")
if err != nil {
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.")
}
cmd := exec.Command("nix-shell", path)
// Default to the shell already being used.
shell := os.Getenv("SHELL")
Expand Down

0 comments on commit 822511a

Please sign in to comment.