How To Dual Boot Nixos and Arch Linux

NixOS has been my trusty companion for a good 4 years now. It’s like having a horse whisperer for the wild mustang that is running software. But one bronco still manages to remain unbroken by Nix, running games.

There are a number of titles I’ve been able to run without issue. I’ll give credit where credit is due, gaming on NixOS has come a long way. But there’s always that one game that won’t play ball. For me, it was Hogwarts Legacy, a birthday gift from my brother.

I won’t lie, I spent more hours than I’d like to admit trying to get it running. The quagmire of the sunk cost fallacy is easy to fall into. I started comparing the time spent getting NixOs to work vs dual boot Arch Linux. That’s when I made the call to dual boot Arch. The fun of reading Github Issues and Docs pale in comparison to Hogwarts Legacy.

Now, there is some documentation laying around but it wasn’t entirely clear to me. This is my normal “time to write a blog post” signal. Maybe you too have something that doesn’t run well on NixOS and you just want it to work. I’ve rarely, if ever, had problems with Arch Linux. I wrote about it in my One Week With NixOS post. It was time to attack this problem from another angle.

Step 1: Shrink Partition

My Nixos disk layout was simple:

  • 1 partition for /boot
  • 1 partition for /

Instead of buying a new disk, cause money and impatient, I decided to strink my root partition. But you can’t partition a disk while it’s in use, so get yourself a bootable thumb drive. I used my thumb drive that has NixOS on it. As much as I love CLI’s, I’d rather partition disks with GParted. Here’s an example article showing how to repartition and format.

Step 2: Install Archlinux

Now that you have a empty partition, it’s time to install Arch. In a past blog post, I wrote out my runbook for installing Arch with minimal instructions. It’s roughy based on the steps provided in the official arch wiki install docs.

This is where things started to get hazy in the existing documentation. When dual booting with NixOS, you don’t have to worry about the boot loader setup in Arch Linux. It means that you can skip step 6: Configure Grub with EFI in my blog post, or 3.8 Boot loader in the official docs. Messing with boot loaders has never been my thing.

Step 3: Get NixOS to Recognize Arch

NixOS has the option to enable os-prober for Grub. My config options ended up looking like:

boot.loader = {
  grub = {
    device = "nodev";
    enable = true;
    useOSProber = true;
    efiSupport = true;
  };
  efi.canTouchEfiVariables = true;
};

If this config is out of date, you can always check out my github repo for my current options. This option allows Nix to find your existing Arch installation for you and add it to Grub. The NixOS wiki has a section for understanding dual booting Nix and Windows that also has helpful tips.

I love this feature. It makes dual booting another linux system a snap. I may have to play with dual booting some other systems now that it’s this easy.

Conclusion

That’s it! From the beginning, I thought that dual booting NixOS was going to be too much work. In practice, it’s actually much easier than expected. Maybe you too have some software that doesn’t play nice with Nix. It’s always nice having a plan B!