Has anyone tried to dual-boot NixOS with MacOS?

Well my question is that it seems the bootloader have been overwritten by NixOS, if I update MacOS to Mojave, will it wipe NixOS entries? If so, can I recover it? Has anyone tried that?

Well, NixOS re-install doesn’t wipe anything on the drive, and it re-uses /nix/store paths that you already have, so I’d expect you can go that way.

Just to be clear: If the uefi entry was wiped, I think I can recover it by:

  1. Use a bootable usb drive to boot into a NixOS image.
  2. Mount the disk partition that I previously install NixOS on to /mnt
  3. Use nixos-install to re-install NixOS. ( I set the nixos-config to ~/.config/nixpkgs/nixos.nix now, should I set it to /home/... here or /mnt/home/...?)
  4. re-create the root user.

Anything wrong?

Sounds OK… but no guarantees for me, i.e. certainly back up anything very important :wink:

Yeah I’m backing up my home directory preparing to take the adventure, good luck to myself :stuck_out_tongue:

I just installed NixOS on a Mac next to macOS. I just mounted /dev/sda1 and backed it up before and after.

Here is the diff:

[root@nixos:~]# restic diff edb732be 12a22a58
repository 6f7cd08d opened successfully, password is correct
comparing snapshot edb732be to 12a22a58:

+    /mnt/efi/EFI/BOOT/
+    /mnt/efi/EFI/BOOT/BOOTX64.EFI
+    /mnt/efi/EFI/nixos/
+    /mnt/efi/EFI/nixos/4zyh40mgxiq2c68m8njdnwvh30wnhn2d-linux-4.14.76-bzImage.efi
+    /mnt/efi/EFI/nixos/kl66ch5wq43gm1iiy702q8knwrfgcif7-initrd-initrd.efi
+    /mnt/efi/EFI/systemd/
+    /mnt/efi/EFI/systemd/systemd-bootx64.efi
+    /mnt/efi/loader/
+    /mnt/efi/loader/entries/
+    /mnt/efi/loader/entries/nixos-generation-1.conf
+    /mnt/efi/loader/loader.conf

Files:           6 new,     0 removed,     0 changed
Dirs:            5 new,     0 removed
Others:          0 new,     0 removed
Data Blobs:     16 new,     0 removed
Tree Blobs:     24 new,    19 removed
  Added:   12.986 MiB
  Removed: 52.477 KiB

So the NixOS install don’t removes anything from the EFI partition. I don’t know if macOS will delete or overwrite it, but i don’t think so. I have installed refind earlier and it is still there.

Booting macOS and NixOs works.

1 Like

Ah I forgot to update the info here :stuck_out_tongue: So yes everything is fine after an update, at least Mojave didn’t wipe anything, however the boot disk is changed from ‘EFI BOOT’ to ‘Macintosh HD’, so now I have to hold the option key to enter the efi menu so I can boot to NixOS. Can I fix it?

I was using this setup for many months and the only issue was when the EFI partition would get full of kernels. EFI was remembering the last bootloader that was being used for me. I was using the systemd bootloader and not grub.

For more details on the boot process:

Worked fine for me. You can even read (not write) the disk from mac if it’s not encrypted.