lucyllewy / macOS-Linux-VM-with-Rosetta

309 stars 27 forks source link

NixOS VM: "Failed to add binary format 'rosetta': Invalid argument" #21

Closed runeksvendsen closed 1 year ago

runeksvendsen commented 1 year ago

Hi there,

Firstly, thanks for creating this project!

I'm trying to get it working with a NixOS VM (ISO: https://hydra.nixos.org/build/196616052) without success.

I have added this snippet to /etc/nixos/configuration.nix: as per the README (https://github.com/diddledani/macOS-Linux-VM-with-Rosetta#setting-up-rosetta), and have mounted /var/run/rosetta.
When I try to activate the configuration, I get an error. I have taken this picture of the VM screen, with the output of a couple of commands to hopefully help in debugging: IMG_5306

So, actually activating the configuration (and thus running update-binfmts) I get this error:

Failed to add binary format 'rosetta': Invalid argument

If I manually run /run/binfmt/rosetta I get the following error message (which may be totally irrelevant, since I'm not supposed to run it manually, but I figured it may be relevant so I'm including it):

rosetta error: Rosetta is only intended to run on Apple Silicon with a macOS host using Virtualizartion.framework with Rosetta mode enabled

My laptop is a 2021 14-inch MacBook Pro (M1) running macOS Ventura 13.0.

runeksvendsen commented 1 year ago

Update

I found that I had not properly escaped the backslashes in the constants passed to --magic and --mask. However, after I fixed this issue I get a kernel error "Internal error: Oops: 96000047": IMG_5370

runeksvendsen commented 1 year ago

Wait. Looks like I didn't properly activate the new (properly escaped) config. After trying again the config was activated successfully. Now I just need to figure out how to get a x86 binary on arm64 NixOS...