Skip to content

Commit

Permalink
cli: fix broken flag for non-m3 devices on macOS 15
Browse files Browse the repository at this point in the history
Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
  • Loading branch information
abiosoft committed Aug 13, 2024
1 parent c1818be commit a66b375
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func init() {
}

// nested virtualization
if util.M3() && util.MacOS15OrNewer() {
if util.MacOSNestedVirtualizationSupported() {
startCmd.Flags().BoolVarP(&startCmdArgs.NestedVirtualization, "nested-virtualization", "z", false, "enable nested virtualization")
startCmd.Flag("nested-virtualization").Hidden = true
}
Expand Down Expand Up @@ -457,7 +457,7 @@ func prepareConfig(cmd *cobra.Command) {
startCmdArgs.VZRosetta = current.VZRosetta
}
}
if util.MacOS15OrNewer() {
if util.MacOSNestedVirtualizationSupported() {
if !cmd.Flag("nested-virtualization").Changed {
startCmdArgs.NestedVirtualization = current.NestedVirtualization
}
Expand Down
2 changes: 1 addition & 1 deletion environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func newConf(ctx context.Context, conf config.Config) (l limaconfig.Config, err
}
}

if util.MacOS15OrNewer() {
if util.MacOSNestedVirtualizationSupported() {
l.NestedVirtualization = conf.NestedVirtualization
}
}
Expand Down
5 changes: 5 additions & 0 deletions util/macos.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func MacOS13OrNewer() bool { return minMacOSVersion("13.0.0") }
// MacOS15OrNewer returns if the current OS is macOS 15 or newer.
func MacOS15OrNewer() bool { return minMacOSVersion("15.0.0") }

// MacOSNestedVirtualizationSupported returns if the current device supports nested virtualization.
func MacOSNestedVirtualizationSupported() bool {
return M3() && MacOS15OrNewer()
}

func minMacOSVersion(version string) bool {
if !MacOS() {
return false
Expand Down

0 comments on commit a66b375

Please sign in to comment.