From 13ac0a309b0b9626268e37eedc30769ad053491b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 8 Mar 2012 21:37:30 +0000 Subject: [PATCH] Allow a way to install grub to multiple devices (for /boot on soft raid arrays). svn path=/nixos/trunk/; revision=32913 --- modules/installer/grub/grub.nix | 14 ++++++++++++++ .../system/activation/switch-to-configuration.sh | 4 +++- modules/system/activation/top-level.nix | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) 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; };