DEV Community

Ray Harris
Ray Harris

Posted on • Updated on

Day 7: Uninstalling NixOS from my Macbook Pro

Yes, you read that right. NixOS on MBP was a mistake. Now, almost a year later, I am ready to undo this nightmare.

Bad idea from the start

While the setup from my earlier post did work for me, I found myself running into problems later on.

Firstly, I needed to run first aid on the Apple partitions frequently. I think it was needed every time the laptop died, which was quite frequent as this one has a terrible battery and I was using it only once every few weeks at most.

Secondly, using NixOS on this machine has been unpleasant compared to on my desktop. The touchpad is hypersensitive and undersensitive at the same time. The touchbar is useless and leaves me without an escape key (let alone useful function or media control keys).

Thirdly, I just don't like the idea of my hardware working so hard against me. Seemingly everything about the Macbook is designed to make dual booting this way as painful as possible. Too many tricks and workarounds are needed compared to a normal computer. It should be easy!!

I'd like to buy a Lenovo or XPS or something some day. Maybe even a nice Framework if I get rich. For now, I feel the need to simplify, and I'm starting with this laptop.

Remove NixOS

In MacOS, open disk utility and review what you've got. It probably looks something like this

Image description

Here I have one big Apple partition (which Apple subdivides on its own automatically), a few smaller partitions for NixOS (disk0s3, disk0s4, disk0s5), plus the mutually accessible partition named CrossData. My screenshot also shows "Nix Store" on the left, but that's only because I tried installing the nix package manager on MacOS at some point. I never really got into that, so I unfortunately don't have much to share about it for now! Maybe later!

Let's move over to the terminal and check the partitions that way too. Run

diskutil list
Enter fullscreen mode Exit fullscreen mode

to see something like this:

Image description

Let's get to work. The four Microsoft Basic Data partitions are the ones we'll delete and give back to Apple. Start by ensuring they're all unmounted by running these

diskutil unmount disk0s3
Enter fullscreen mode Exit fullscreen mode
diskutil unmount disk0s4
Enter fullscreen mode Exit fullscreen mode
diskutil unmount disk0s5
Enter fullscreen mode Exit fullscreen mode
diskutil unmount disk0s6
Enter fullscreen mode Exit fullscreen mode

Only the last one would be expected to be mounted when running MacOS, but it's harmless to run the command for the others anyway.

Now, with great care and knowledge that you definitely backed up any important data, wipe those partitions

diskutil eraseVolume free %noformat% disk0s3
Enter fullscreen mode Exit fullscreen mode
diskutil eraseVolume free %noformat% disk0s4
Enter fullscreen mode Exit fullscreen mode
diskutil eraseVolume free %noformat% disk0s5
Enter fullscreen mode Exit fullscreen mode
diskutil eraseVolume free %noformat% disk0s6
Enter fullscreen mode Exit fullscreen mode

Can't go back now!

Let's check out the damage.

diskutil list
Enter fullscreen mode Exit fullscreen mode

Image description

Looks like we have a floating 250GB of free space. Let's merge that back into the main apple partition. What's nice is we can do this in the GUI of disk utility, giving us confidence that Apple likes what we're doing. Here's what it looks like now:

Image description

So click "Partition" at the top of this window to bring up this view:

Image description

By the time you're reading this, there could be a new MacOS with a different UI, but I hope it should still be easy to select and delete the free space. Here's what it looked like for me with MacOS Sonoma

Image description

The quicktime recording was canceled during the process, but there were no surprises after hitting "Partition". Checking disk utility and now I see things looking good.

Image description

Image description

Clean out the EFI partition

Remember that mess we made in here? We should at least do something about it. Not sure if Apple will handle it for us. Let's find out.

diskutil mount disk0s1
Enter fullscreen mode Exit fullscreen mode

Now it shows up in file explorer and we can see what's still there:

Image description

There's rEFInd, nixos, linux, systemd... I don't even remember which of the others belong in there or don't.

Let's delete at least rEFInd and nixos. First check what's there

ls /Volumes/EFI/EFI
Enter fullscreen mode Exit fullscreen mode

Image description

This shows the same thing which makes sense.

sudo rm -rf /Volumes/EFI/EFI/refind
Enter fullscreen mode Exit fullscreen mode
sudo rm -rf /Volumes/EFI/EFI/nixos
Enter fullscreen mode Exit fullscreen mode

Time to reboot. Going to Apple>Shut down. We'll also reset the NVRAM by holding CMD+Option+P+R after hitting power to turn it on again (Macs previously used PRAM instead of NVRAM but we get to keep the old keyboard shortcut to reset it).

I got the apple logo quickly and after continuing to hold the keys for a moment, it flashed and added a loading bar beneath. Boom, Apple login screen! No Bootloader. Everything seems to be working. I checked the EFI partition contents and still saw systemd and Linux in there. Nothing meaningful inside though, so I'm not going to worry about it for now.

Re-enable secure boot

Remember shutting that off? Hehe. Let's turn it back on. Shut down again and boot up. This time holding cmd+r for recovery mode.

Auth as admin, then at the top choose Utilities > Startup Security Utility. There are two selections to make here. Make the second one first. Select Disallow booting from external or removable media under Allowed Boot Media, then select Full Security under Secure Boot.

This is the screenshot from Apple's support site. It's not exactly what I see, but it's close.

Image description

It asks to select startup disk which I do easily since there's just one option. Then choose Restart and confirm to save the changes.

Oops. I got an error. Unable to verify startup disk. Yikes! Even doing First Aid with disk utility didn't help at all. So what do to? Turn it off and back on again, I suppose. Shutting down and booting up again gave me a warning that said a software update was required to use this drive. I agreed and let it do its thing. After a few reboots and loading bars, I finally got an error. It ended up in a loop trying to reboot.

Holding down the power button to force shut down, then rebooting into recovery again with CMR+R got me out of that cycle. Still couldn't set the boot security.

I was able to reinstall Ventura via Recovery mode, which despite giving an error at one point, did succeed. And then once entering recovery mode again, I could set secure boot successfully.

Woohoo! I'm done with this nightmare! Now it'll be easy to wipe this thing for resale some day.

What's next

Running NixOS on a laptop is indefinitely suspended project for me now. However, I did build a new gaming PC and am looking forward to putting NixOS on there and trying out Steam Proton. Additionally, my old desktop does still have NixOS, and I'm planning to embrace that and convert it into a home server of some sort. My ideas are to have a media server as well as to look into setting up a home-based Siri replacement. We'll see! Whatever I do, I'll share here on this blog.

Good luck out there!

Top comments (0)