Dual Booting NixOS and Windows: Difference between revisions
IFreilicht (talk | contribs) Add method to boot Windows if it is installed on a different drive than NixOS |
→systemd-boot: more elegant way to dual-boot windows in uefi mode (at least as of 24.11) |
||
Line 123: | Line 123: | ||
===== systemd-boot ===== | ===== systemd-boot ===== | ||
As systemd-boot cannot directly load binaries from other ESPs<ref>https://github.com/systemd/systemd/issues/3252</ref>, let alone other disks, we have to employ [https://search.nixos.org/packages?channel=unstable&show=edk2-uefi-shell&from=0&size=50&sort=relevance&type=packages&query=edk2-uefi-shell edk2-uefi-shell] to implement a chainloading strategy<ref>https://wiki.archlinux.org/title/Systemd-boot#Boot_from_another_disk</ref>. The basic config looks like this:{{File|/etc/nixos/configuration.nix|nix|<nowiki> | As systemd-boot cannot directly load binaries from other ESPs<ref>https://github.com/systemd/systemd/issues/3252</ref>, let alone other disks, we have to employ [https://search.nixos.org/packages?channel=unstable&show=edk2-uefi-shell&from=0&size=50&sort=relevance&type=packages&query=edk2-uefi-shell edk2-uefi-shell] to implement a chainloading strategy<ref>https://wiki.archlinux.org/title/Systemd-boot#Boot_from_another_disk</ref>. The basic config looks like this:{{File|/etc/nixos/configuration.nix|nix|<nowiki> | ||
{ | { ... }: | ||
{ | { | ||
boot.loader = { | boot.loader = { | ||
efi.canTouchEfiVariables = true; | efi.canTouchEfiVariables = true; | ||
systemd-boot = { | |||
systemd-boot | enable = true; | ||
windows = { | |||
"windows" = | |||
let | |||
# To determine the name of the windows boot drive, boot into edk2 first, then run | |||
# `map -c` to get drive aliases, and try out running `FS1:`, then `ls EFI` to check | |||
# which alias corresponds to which EFI partition. | |||
boot-drive = "FS1"; | |||
in | |||
{ | |||
title = "Windows"; | |||
efiDeviceHandle = boot-drive; | |||
sortKey = "y_windows"; | |||
}; | |||
}; | |||
edk2-uefi-shell.enable = true; | |||
edk2-uefi-shell.sortKey = "z_edk2"; | |||
}; | }; | ||
}; | }; |