LnL7 / nix-darwin

nix modules for darwin
MIT License
2.78k stars 429 forks source link

Installing Rosetta 2 #786

Open flexwie opened 11 months ago

flexwie commented 11 months ago

Is there a nix-darwin way to enabling rosetta support for Apple silicon Macs?

Enzime commented 11 months ago

Not currently, but you could do something like:

{
  system.activationScripts.extraActivation.text = ''
    softwareupdate --install-rosetta --agree-to-license
  '';
}

One possible issue with making a nix-darwin module for this is that there isn't an uninstaller as far as I'm aware so disabling a nix-darwin option wouldn't be able to uninstall Rosetta.

jpickwell commented 11 months ago

It is possible to uninstall Rosetta, but the issue is getting around SIP because Rosetta is protected by it. Disabling/enabling SIP requires a reboot each time, and as far as I know, you have to perform the disabling/enabling in recovery mode.

Here's an article about uninstalling Rosetta 2: https://machow2.com/uninstall-rosetta-mac/

xav-ie commented 8 months ago

Perhaps there is an angle of having this and other advanced options, but the pre-requisite is having SIP disabled? If you want to uninstall, you can automate the process of rebooting into recovery mode: https://apple.stackexchange.com/questions/366857/how-can-i-enter-recovery-mode-for-mac-os-on-an-imac-remotely

But as the comments say in that post, there is no way to run commands remotely, or any pre-meditated commands. And I think that is by Apple's design of a recovery mode. So it does not make sense to have an option like this unless you already have SIP disabled.

Does it make sense to add this as an option but only if SIP is disabled?

I am not opposed to that, but if that is not viable, I don't think this makes sense to keep open.

Enzime commented 8 months ago

I would accept PRs that add an option that installs Rosetta without being able to uninstall it as I think this is a feature a lot of people use and the uninstall part isn't very common as far as I can tell.

For implementing the uninstaller, if the option defaults to null and is then explicitly set to false then we could detect if macOS is booted with SIP disabled and if it is then we perform the uninstall, otherwise we could show users instructions for disabling SIP.

xav-ie commented 8 months ago

I am thinking about working on a or for this :). I need to learn more about sip though, bc I think you can partially disable it, not just ‘csrutil disable’.