Dual Booting NixOS and Windows: Difference between revisions
imported>Fadenb m →MBR + Grub: syntaxhighlight |
imported>Leocp1 added GRUB EFI configuration |
||
Line 20: | Line 20: | ||
Source: https://zimbatm.com/journal/2016/09/09/nixos-window-dual-boot/ | Source: https://zimbatm.com/journal/2016/09/09/nixos-window-dual-boot/ | ||
= EFI + Grub = | |||
<nowiki>systemd-boot</nowiki> can not load EFI binaries from other partitions, | |||
and a pre-exisitng EFI partition from a Windows install may be smaller than we would like our <nowiki>/boot</nowiki> partition to be. If we still want Windows and NixOS to use the same EFI partition, we can use GRUB instead. | |||
Here we assume: | |||
* the EFI partition has been mounted on <nowiki>/boot/efi</nowiki> | |||
* <nowiki>$FS_UUID</nowiki> is the UUID of the EFI partition | |||
* the <nowiki>boot.loader.systemd-boot.enable = true;</nowiki> line added to configuration.nix by <nowiki>nixos-generate-config</nowiki> has been removed | |||
<syntaxhighlight lang="nix"> | |||
{ config, ... }: | |||
{ | |||
boot.loader = { | |||
efi = { | |||
canTouchEfiVariables = true; | |||
# assuming /boot/efi is the mount point of the EFI partition in NixOS | |||
efiSysMountPoint = "/boot/efi"; | |||
}; | |||
grub = { | |||
# despite what the configuration.nix manpage seems to indicate, | |||
# as of release 17.09, setting device to "nodev" will still call | |||
# `grub-install` if efiSupport is true | |||
# (the devices list is not used by the EFI grub install, | |||
# but must be set to some value in order to pass an assert in grub.nix) | |||
devices = [ "nodev" ]; | |||
efiSupport = true; | |||
enable = true; | |||
# set $FS_UUID to the UUID of the EFI partition | |||
extraEntries = '' | |||
menuentry "Windows" { | |||
insmod part_gpt | |||
insmod fat | |||
insmod search_fs_uuid | |||
insmod chain | |||
search --fs--uid --set=root $FS_UUID | |||
chainloader /EFI/Microsoft/Boot/bootmgfw.efi | |||
} | |||
''; | |||
version = 2; | |||
}; | |||
}; | |||
}</syntaxhighlight> | |||
Sources: | |||
* [https://wiki.archlinux.org/index.php/GRUB#Windows_installed_in_UEFI-GPT_Mode_menu_entry Arch Wiki GRUB article] | |||
* [https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/loader/grub/install-grub.pl NixOS GRUB installer] (check the code block beginning with <nowiki># install EFI GRUB</nowiki>) |