Author: eelco
Date: Mon May 14 01:53:47 2012
New Revision: 34081
URL: https://nixos.org/websvn/nix/?rev=34081&sc=1

Log:
* Give an error at evaluation time if boot.loader.grub.device or
  boot.loader.grub.devices are not set, rather than complaining about
  it when it's too late.

Modified:
   nixos/trunk/modules/installer/grub/grub.nix
   nixos/trunk/modules/system/activation/switch-to-configuration.sh
   nixos/trunk/modules/system/activation/top-level.nix

Modified: nixos/trunk/modules/installer/grub/grub.nix
==============================================================================
--- nixos/trunk/modules/installer/grub/grub.nix Mon May 14 01:33:11 2012        
(r34080)
+++ nixos/trunk/modules/installer/grub/grub.nix Mon May 14 01:53:47 2012        
(r34081)
@@ -4,7 +4,9 @@
 
 let
 
-  grub = if config.boot.loader.grub.version == 1 then pkgs.grub else 
pkgs.grub2;
+  cfg = config.boot.loader.grub;
+
+  grub = if cfg.version == 1 then pkgs.grub else pkgs.grub2;
 
   grubMenuBuilder = pkgs.substituteAll {
     src = ./grub-menu-builder.sh;
@@ -48,15 +50,11 @@
         example = "/dev/hda";
         type = with pkgs.lib.types; uniq string;
         description = ''
-          The device on which the boot loader, GRUB, will be
-          installed.  If empty, GRUB won't be installed and it's your
-          responsibility to make the system bootable.  The special
-          value <literal>nodev</literal> 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
-          <literal>devices</literal>.
+          The device on which the GRUB boot loader will be installed.
+          The special value <literal>nodev</literal> means that a GRUB
+          boot menu will be generated, but GRUB itself will not
+          actually be installed.  To install GRUB on multiple devices,
+          use <literal>boot.loader.grub.devices</literal>.
         '';
       };
 
@@ -67,7 +65,7 @@
         description = ''
           The devices on which the boot loader, GRUB, will be
           installed. Can be used instead of <literal>device</literal> to
-          install grub into multiple devices (as softraid arrays holding 
/boot).
+          install grub into multiple devices (e.g., if as softraid arrays 
holding /boot).
         '';
       };
 
@@ -197,7 +195,13 @@
 
   config = mkIf config.boot.loader.grub.enable {
 
-    system.build.menuBuilder = grubMenuBuilder;
+    boot.loader.grub.devices = optional (cfg.device != "") cfg.device;
+
+    system.build = mkAssert (cfg.devices != [])
+      "You must set the ‘boot.loader.grub.device’ option to make the system 
bootable."
+      { menuBuilder = grubMenuBuilder;
+        inherit grub;
+      };
 
     # Common attribute for boot loaders so only one of them can be
     # set at once.
@@ -206,8 +210,6 @@
 
     environment.systemPackages = mkIf config.boot.loader.grub.enable [ grub ];
 
-    system.build.grub = grub;
-
   };
 
 }

Modified: nixos/trunk/modules/system/activation/switch-to-configuration.sh
==============================================================================
--- nixos/trunk/modules/system/activation/switch-to-configuration.sh    Mon May 
14 01:33:11 2012        (r34080)
+++ nixos/trunk/modules/system/activation/switch-to-configuration.sh    Mon May 
14 01:53:47 2012        (r34081)
@@ -26,28 +26,23 @@
     
     if [ "@bootLoader@" = "grub" ]; then
         
-      if [ -n '@grubDevices@' ]; then
-          mkdir -m 0700 -p /boot/grub
-          @menuBuilder@ @out@
+        mkdir -m 0700 -p /boot/grub
+        @menuBuilder@ @out@
 
-          # If the GRUB version has changed, then force a reinstall.
-          oldGrubVersion="$(cat /boot/grub/version 2>/dev/null || true)"
-          newGrubVersion="@grubVersion@"
+        # If the GRUB version has changed, then force a reinstall.
+        oldGrubVersion="$(cat /boot/grub/version 2>/dev/null || true)"
+        newGrubVersion="@grubVersion@"
 
-          if [ "$NIXOS_INSTALL_GRUB" = 1 -o "$oldGrubVersion" != 
"$newGrubVersion" ]; then
-              for dev in @grubDevices@; do
-                  if [ "$dev" != nodev ]; then
-                      echo "installing the GRUB bootloader on $dev..."
-                      @grub@/sbin/grub-install "$(readlink -f "$dev")" 
--no-floppy
-                  fi
-              done
-              echo "$newGrubVersion" > /boot/grub/version
-          fi
+        if [ "$NIXOS_INSTALL_GRUB" = 1 -o "$oldGrubVersion" != 
"$newGrubVersion" ]; then
+            for dev in @grubDevices@; do
+                if [ "$dev" != nodev ]; then
+                    echo "installing the GRUB bootloader on $dev..."
+                    @grub@/sbin/grub-install "$(readlink -f "$dev")" 
--no-floppy
+                fi
+            done
+            echo "$newGrubVersion" > /boot/grub/version
+        fi
           
-      else
-          echo "Warning: don't know how to make this configuration bootable; 
please set \`boot.loader.grub.device'." 1>&2
-      fi
-      
     elif [ "@bootLoader@" = "generationsDir" ]; then
         @menuBuilder@ @out@
     elif [ "@bootLoader@" = "efiBootStub" ]; then

Modified: nixos/trunk/modules/system/activation/top-level.nix
==============================================================================
--- nixos/trunk/modules/system/activation/top-level.nix Mon May 14 01:33:11 
2012        (r34080)
+++ nixos/trunk/modules/system/activation/top-level.nix Mon May 14 01:53:47 
2012        (r34081)
@@ -186,12 +186,10 @@
       if config.boot.loader.grub.enable
       then (builtins.parseDrvName config.system.build.grub.name).version
       else "";
-    grubDevices = with pkgs.lib; let
+    grubDevices =
+      let
         wrapQuotes = s: "\"" + s + "\"";
-        allDevices = [ config.boot.loader.grub.device ] ++
-          config.boot.loader.grub.devices;
-        definedDevices = filter (s: s != "") allDevices;
-      in map wrapQuotes definedDevices;
+      in map wrapQuotes config.boot.loader.grub.devices;
     configurationName = config.boot.loader.grub.configurationName;
   };
 
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to