diff --git a/modules/installer/grub/grub.nix b/modules/installer/grub/grub.nix index eaafec78653..1f9571fd7a5 100644 --- a/modules/installer/grub/grub.nix +++ b/modules/installer/grub/grub.nix @@ -54,6 +54,20 @@ in value nodev means that a GRUB boot menu will be generated, but GRUB itself will not actually be installed. + + To install grub into multiple devices look at + devices. + ''; + }; + + devices = mkOption { + default = []; + example = [ "/dev/hda" ]; + type = with pkgs.lib.types; listOf string; + description = '' + The devices on which the boot loader, GRUB, will be + installed. Can be used instead of device to + install grub into multiple devices (as softraid arrays holding /boot). ''; }; diff --git a/modules/system/activation/switch-to-configuration.sh b/modules/system/activation/switch-to-configuration.sh index 3be1b210d6a..75e004d7738 100644 --- a/modules/system/activation/switch-to-configuration.sh +++ b/modules/system/activation/switch-to-configuration.sh @@ -38,7 +38,9 @@ if [ "$action" = "switch" -o "$action" = "boot" ]; then if [ "$NIXOS_INSTALL_GRUB" = 1 -o "$oldGrubVersion" != "$newGrubVersion" ]; then echo "installing the GRUB bootloader..." - @grub@/sbin/grub-install "$(readlink -f "@grubDevice@")" --no-floppy + for a in @grubDevices@; do + @grub@/sbin/grub-install "$(readlink -f "$a")" --no-floppy + done echo "$newGrubVersion" > /boot/grub/version fi fi diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index b98242c3f33..a0a3b2c9b2f 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -171,7 +171,10 @@ let if config.boot.loader.grub.enable then (builtins.parseDrvName config.system.build.grub.name).version else ""; - grubDevice = config.boot.loader.grub.device; + grubDevices = let + wrapQuotes = s: "\"" + s + "\""; + in map wrapQuotes ([ config.boot.loader.grub.device ] ++ + config.boot.loader.grub.devices); configurationName = config.boot.loader.grub.configurationName; };