* Make the graphical boot work on GRUB 2 in the case where /nix/store

is not on the same partition as /boot (i.e. when
  boot.loader.grub.bootDevice is set): just copy the background image
  and the font to /boot.

svn path=/nixos/trunk/; revision=18979
This commit is contained in:
Eelco Dolstra 2009-12-15 21:11:39 +00:00
parent 79073c7b3d
commit 79bcc7618e
2 changed files with 13 additions and 29 deletions

View File

@ -28,32 +28,25 @@ esac
prologue() {
if test -n "@splashImage@"; then
splashLocation="@splashImage@"
if test "$grubVersion" -eq 1 ; then
# Splash images in /nix/store don't seem to work, so copy them.
cp -f $splashLocation /boot/background.xpm.gz
splashLocation="$bootDevice/background.xpm.gz"
fi
fi
case "$grubVersion" in
1)
cp -f "@splashImage@" /boot/background.xpm.gz
cat > "$1" << GRUBEND
# Automatically generated. DO NOT EDIT THIS FILE!
default @default@
timeout @timeout@
GRUBEND
if test -n "@splashImage@"; then
echo "splashimage $splashLocation" >> "$1"
echo "splashimage $bootDevice/background.xpm.gz" >> "$1"
fi
;;
2)
cp -f @grub@/share/grub/unicode.pf2 /boot/grub/unicode.pf2
cat > "$1" <<EOF
# Automatically generated. DO NOT EDIT THIS FILE!
set default=@default@
set timeout=@timeout@
if loadfont @grub@/share/grub/unicode.pf2 ; then
if loadfont $bootDevice/grub/unicode.pf2; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
@ -61,13 +54,14 @@ if loadfont @grub@/share/grub/unicode.pf2 ; then
fi
EOF
if test -n "@splashImage@"; then
cp -f "@splashImage@" /boot/background.png
# FIXME: GRUB 1.97 doesn't resize the background image
# if it doesn't match the video resolution.
cat >> "$1" <<EOF
insmod png
if background_image $splashLocation ; then
set color_normal=black/black
set color_highlight=magenta/black
if background_image $bootDevice/background.png; then
set color_normal=white/black
set color_highlight=black/white
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
@ -244,8 +238,7 @@ for generation in $(
done
# Atomically update /boot/grub/menu.lst. !!! should do an fsync()
# here on $tmp, especially on ext4.
# Atomically update the GRUB configuration file.
mv $tmp $target

View File

@ -4,12 +4,12 @@ with pkgs.lib;
let
grub = if config.boot.loader.grub.version == 1 then pkgs.grub else pkgs.grub2;
grubMenuBuilder = pkgs.substituteAll {
src = ./grub-menu-builder.sh;
isExecutable = true;
grub = if config.boot.loader.grub.version == 1
then pkgs.grub
else pkgs.grub2;
inherit grub;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
inherit (config.boot.loader.grub) copyKernels extraEntries extraEntriesBeforeNixOS
@ -156,17 +156,8 @@ in
system.boot.loader.id = "grub";
system.boot.loader.kernelFile = "vmlinuz";
environment.systemPackages =
mkIf config.boot.loader.grub.enable
(let version = config.boot.loader.grub.version; in
assert version != 1 -> version == 2;
environment.systemPackages = mkIf config.boot.loader.grub.enable [ grub ];
if version == 1
then [ pkgs.grub ]
else [ pkgs.grub2 ]);
# and many other things that have to be moved inside this file.
};
}