mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-04 11:32:03 +00:00
* 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. svn path=/nixos/trunk/; revision=34081
This commit is contained in:
parent
67d5f2b444
commit
3dd0718939
|
@ -4,7 +4,9 @@ with pkgs.lib;
|
|||
|
||||
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 @@ in
|
|||
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 @@ in
|
|||
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 @@ in
|
|||
|
||||
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 @@ in
|
|||
|
||||
environment.systemPackages = mkIf config.boot.loader.grub.enable [ grub ];
|
||||
|
||||
system.build.grub = grub;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -26,28 +26,23 @@ if [ "$action" = "switch" -o "$action" = "boot" ]; then
|
|||
|
||||
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
|
||||
|
|
|
@ -186,12 +186,10 @@ let
|
|||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue