* Add rename clauses for the old Grub options.

* Renamed some of the new Grub options to more sensible names
  (e.g. extraGrubEntries to extraEntries, bootMount to bootDevice,
  etc.).

svn path=/nixos/trunk/; revision=17494
This commit is contained in:
Eelco Dolstra 2009-09-29 09:50:38 +00:00
parent c9f5889ad1
commit 636a9e7e32
4 changed files with 139 additions and 137 deletions

View File

@ -11,8 +11,8 @@ if test -z "$1"; then
exit 1
fi
bootMount="@bootMount@"
if test -z "$bootMount"; then bootMount=/boot; fi
bootDevice="@bootDevice@"
if test -z "$bootDevice"; then bootDevice=/boot; fi
echo "updating the GRUB menu..."
@ -28,11 +28,11 @@ timeout 5
GRUBEND
if test -n "@grubSplashImage@"; then
splashLocation=@grubSplashImage@
if test -n "@splashImage@"; then
splashLocation=@splashImage@
# Splash images in /nix/store don't seem to work, so copy them.
cp -f $splashLocation /boot/background.xpm.gz
splashLocation="$bootMount/background.xpm.gz"
splashLocation="$bootDevice/background.xpm.gz"
echo "splashimage $splashLocation" >> $tmp
fi
@ -40,7 +40,7 @@ fi
configurationCounter=0
configurationLimit="@configurationLimit@"
numAlienEntries=`cat <<EOF | egrep '^[[:space:]]*title' | wc -l
@extraGrubEntries@
@extraEntries@
EOF`
if test $((configurationLimit+numAlienEntries)) -gt 190; then
@ -100,8 +100,8 @@ addEntry() {
cp "$(readlink -f "$path/init")" /boot/nixos-init
cat > /boot/nixos-grub-config <<EOF
title Emergency boot
kernel ${bootMount:-/boot}/nixos-kernel systemConfig=$(readlink -f "$path") init=/boot/nixos-init $(cat "$path/kernel-params")
initrd ${bootMount:-/boot}/nixos-initrd
kernel ${bootDevice:-/boot}/nixos-kernel systemConfig=$(readlink -f "$path") init=/boot/nixos-init $(cat "$path/kernel-params")
initrd ${bootDevice:-/boot}/nixos-initrd
EOF
fi
@ -110,9 +110,9 @@ EOF
copyToKernelsDir $initrd; initrd=$result
fi
if test -n "$bootMount"; then
kernel=$(echo $kernel | sed -e "s^/boot^$bootMount^")
initrd=$(echo $initrd | sed -e "s^/boot^$bootMount^")
if test -n "$bootDevice"; then
kernel=$(echo $kernel | sed -e "s^/boot^$bootDevice^")
initrd=$(echo $initrd | sed -e "s^/boot^$bootDevice^")
fi
local confName=$(if test -e $path/configuration-name; then
@ -137,19 +137,19 @@ fi
# Additional entries specified verbatim by the configuration.
extraGrubEntries=`cat <<EOF
@extraGrubEntries@
extraEntries=`cat <<EOF
@extraEntries@
EOF`
if test -n "@extraGrubEntriesBeforeNixos@"; then
echo "$extraGrubEntries" >> $tmp
if test -n "@extraEntriesBeforeNixOS@"; then
echo "$extraEntries" >> $tmp
fi
addEntry "NixOS - Default" $default ""
if test -z "@extraGrubEntriesBeforeNixos@"; then
echo "$extraGrubEntries" >> $tmp
if test -z "@extraEntriesBeforeNixOS@"; then
echo "$extraEntries" >> $tmp
fi
# Add all generations of the system profile to the menu, in reverse

View File

@ -1,13 +1,27 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
grubMenuBuilder = pkgs.substituteAll {
src = ./grub-menu-builder.sh;
isExecutable = true;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
inherit (config.boot.loader.grub) copyKernels extraEntries extraEntriesBeforeNixOS
splashImage bootDevice configurationLimit;
};
in
{
###### interface
options = {
boot = {
loader = {
grub = {
boot.loader.grub = {
enable = mkOption {
default = true;
@ -16,7 +30,7 @@ let
'';
};
grubDevice = mkOption {
device = mkOption {
default = "";
example = "/dev/hda";
description = "
@ -26,14 +40,14 @@ let
";
};
bootMount = mkOption {
bootDevice = mkOption {
default = "";
example = "(hd0,0)";
description = "
If the system partition may be wiped on reinstall, it is better
to have /boot on a small partition. To do it, we need to explain
to GRUB where the kernels live. Specify the partition here (in
GRUB notation.
GRUB notation).
";
};
@ -45,7 +59,7 @@ let
";
};
extraGrubEntries = mkOption {
extraEntries = mkOption {
default = "";
example = "
title Windows
@ -56,14 +70,14 @@ let
";
};
extraGrubEntriesBeforeNixos = mkOption {
extraEntriesBeforeNixOS = mkOption {
default = false;
description = "
Wheter extraGrubEntries are put before the Nixos-default option
Whether extraEntries are included before the default option.
";
};
grubSplashImage = mkOption {
splashImage = mkOption {
default = pkgs.fetchurl {
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
@ -94,46 +108,27 @@ let
different file system than /boot.
";
};
};
};
};
};
in
###### implementation
let
###### implementation
grubMenuBuilder = pkgs.substituteAll {
src = ./grub-menu-builder.sh;
isExecutable = true;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
inherit (config.boot.loader.grub) copyKernels extraGrubEntries extraGrubEntriesBeforeNixos
grubSplashImage bootMount configurationLimit;
};
in
config = mkIf config.boot.loader.grub.enable {
{
require = [
options
# config.system.build
# ../system/system-options.nix
];
system = mkIf config.boot.loader.grub.enable {
build = {
menuBuilder = grubMenuBuilder;
};
system.build.menuBuilder = grubMenuBuilder;
# Common attribute for boot loaders so only one of them can be
# set at once
boot.loader.id = "grub";
boot.loader.kernelFile = "vmlinuz";
};
# set at once.
system.boot.loader.id = "grub";
system.boot.loader.kernelFile = "vmlinuz";
environment.extraPackages = mkIf config.boot.loader.grub.enable [ pkgs.grub ];
# and many other things that have to be moved inside this file.
};
}

View File

@ -36,6 +36,12 @@ in zipModules ([]
# ++ rename alias "services.xserver.slim.theme" to "services.xserver.displayManager.slim.theme"
++ rename obsolete "environment.extraPackages" to "environment.systemPackages"
# Old Grub-related options.
++ rename obsolete "boot.copyKernels" to "boot.loader.grub.copyKernels"
++ rename obsolete "boot.extraGrubEntries" to "boot.loader.grub.extraEntries"
++ rename obsolete "boot.extraGrubEntriesBeforeNixos" to "boot.loader.grub.extraEntriesBeforeNixOS"
++ rename obsolete "boot.grubDevice" to "boot.loader.grub.device"
++ rename obsolete "boot.bootMount" to "boot.loader.grub.bootDevice"
) # do not add renaming after this.

View File

@ -46,7 +46,8 @@ let
config.nesting.children;
systemBuilder = let
systemBuilder =
let
kernelPath = "${config.boot.kernelPackages.kernel}/" +
"${config.system.boot.loader.kernelFile}";
in
@ -110,7 +111,7 @@ let
# Boot loaders
bootLoader = config.system.boot.loader.id;
grub = if config.boot.loader.grub.enable then pkgs.grub else null;
grubDevice = config.boot.loader.grub.grubDevice;
grubDevice = config.boot.loader.grub.device;
configurationName = config.boot.loader.grub.configurationName;
};