go/workspace: fix nix-instantiate exec error typecast
Also skip nix tests on systems without nix.
Change-Id: I4c0069a429df10a496b2651c2506b2d4625d5f43
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1585
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/go/workspace/nix.go b/go/workspace/nix.go
index 8d005a7..22b50cf 100644
--- a/go/workspace/nix.go
+++ b/go/workspace/nix.go
@@ -48,8 +48,10 @@
cmd := exec.CommandContext(ctx, "nix-instantiate", args...)
out, err := cmd.Output()
if err != nil {
- eerr := err.(*exec.ExitError)
- return fmt.Errorf("nix-instantiate failed: %w, stderr: %q", err, eerr.Stderr)
+ if eerr, ok := err.(*exec.ExitError); ok {
+ return fmt.Errorf("nix-instantiate failed: %w, stderr: %q", err, eerr.Stderr)
+ }
+ return fmt.Errorf("nix-instantiate failed: %w", err)
}
if err := json.Unmarshal(out, target); err != nil {