|
4 | 4 | package boxcli
|
5 | 5 |
|
6 | 6 | import (
|
7 |
| - "fmt" |
8 | 7 | "os"
|
9 | 8 |
|
10 | 9 | "github.com/samber/lo"
|
11 | 10 | "github.com/spf13/cobra"
|
12 |
| - "go.jetpack.io/devbox/internal/boxcli/usererr" |
13 | 11 | "go.jetpack.io/devbox/internal/nix"
|
14 | 12 | "go.jetpack.io/devbox/internal/ux"
|
15 |
| - "go.jetpack.io/devbox/internal/vercheck" |
16 | 13 | )
|
17 | 14 |
|
18 | 15 | const nixDaemonFlag = "daemon"
|
@@ -51,24 +48,15 @@ func runInstallNixCmd(cmd *cobra.Command) error {
|
51 | 48 |
|
52 | 49 | // ensureNixInstalled verifies that nix is installed and that it is of a supported version
|
53 | 50 | func ensureNixInstalled(cmd *cobra.Command, _args []string) error {
|
54 |
| - if err := nix.EnsureNixInstalled(cmd.ErrOrStderr(), nixDaemonFlagVal(cmd)); err != nil { |
55 |
| - return err |
56 |
| - } |
57 |
| - |
58 |
| - ver, err := nix.Version() |
59 |
| - if err != nil { |
60 |
| - return fmt.Errorf("failed to get nix version: %w", err) |
61 |
| - } |
62 |
| - |
63 |
| - // ensure minimum nix version installed |
64 |
| - if vercheck.SemverCompare(ver, "2.12.0") < 0 { |
65 |
| - return usererr.New("Devbox requires nix of version >= 2.12. Your version is %s. Please upgrade nix and try again.\n", ver) |
66 |
| - } |
67 |
| - return nil |
| 51 | + return nix.EnsureNixInstalled(cmd.ErrOrStderr(), nixDaemonFlagVal(cmd)) |
68 | 52 | }
|
69 | 53 |
|
70 | 54 | // We return a closure to avoid printing the warning every time and just
|
71 | 55 | // printing it if we actually need the value of the flag.
|
| 56 | +// |
| 57 | +// TODO: devbox.Open should run nix.EnsureNixInstalled and do this logic |
| 58 | +// internally. Then setup can decide if it wants to pass in the value of the |
| 59 | +// nixDaemonFlag (if changed). |
72 | 60 | func nixDaemonFlagVal(cmd *cobra.Command) func() *bool {
|
73 | 61 | return func() *bool {
|
74 | 62 | if !cmd.Flags().Changed(nixDaemonFlag) {
|
|
0 commit comments