Info returns Nix version information. It caches the result after the first call, which means it won't reflect any configuration changes to Nix. Create a new Nix instance to retrieve uncached information.
()
| 131 | // call, which means it won't reflect any configuration changes to Nix. Create a |
| 132 | // new Nix instance to retrieve uncached information. |
| 133 | func (n *Nix) Info() (Info, error) { |
| 134 | // Create the command first, which will catch any errors finding the Nix |
| 135 | // executable outside of the once. This allows us to retry after |
| 136 | // installing Nix. |
| 137 | cmd := n.Command("--version", "--debug") |
| 138 | if cmd.err != nil { |
| 139 | return Info{}, cmd.err |
| 140 | } |
| 141 | |
| 142 | n.infoOnce.Do(func() { |
| 143 | out, err := cmd.Output(context.Background()) |
| 144 | if err != nil { |
| 145 | var exitErr *exec.ExitError |
| 146 | if errors.As(err, &exitErr) && len(exitErr.Stderr) != 0 { |
| 147 | n.infoErr = redact.Errorf("nix command: %s: %q: %v", redact.Safe(cmd), exitErr.Stderr, err) |
| 148 | return |
| 149 | } |
| 150 | n.infoErr = redact.Errorf("nix command: %s: %v", redact.Safe(cmd), err) |
| 151 | return |
| 152 | } |
| 153 | n.info, n.infoErr = parseInfo(out) |
| 154 | }) |
| 155 | return n.info, n.infoErr |
| 156 | } |
| 157 | |
| 158 | // All major Nix versions supported by Devbox. |
| 159 | const ( |