* 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:
parent
c9f5889ad1
commit
636a9e7e32
|
@ -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
|
||||
|
|
|
@ -1,107 +1,7 @@
|
|||
{pkgs, config, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
with pkgs.lib;
|
||||
|
||||
options = {
|
||||
boot = {
|
||||
loader = {
|
||||
grub = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable the GRUB boot loader.
|
||||
'';
|
||||
};
|
||||
|
||||
grubDevice = mkOption {
|
||||
default = "";
|
||||
example = "/dev/hda";
|
||||
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.
|
||||
";
|
||||
};
|
||||
|
||||
bootMount = 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.
|
||||
";
|
||||
};
|
||||
|
||||
configurationName = mkOption {
|
||||
default = "";
|
||||
example = "Stable 2.6.21";
|
||||
description = "
|
||||
Grub entry name instead of default.
|
||||
";
|
||||
};
|
||||
|
||||
extraGrubEntries = mkOption {
|
||||
default = "";
|
||||
example = "
|
||||
title Windows
|
||||
chainloader (hd0,1)+1
|
||||
";
|
||||
description = "
|
||||
Any additional entries you want added to the Grub boot menu.
|
||||
";
|
||||
};
|
||||
|
||||
extraGrubEntriesBeforeNixos = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Wheter extraGrubEntries are put before the Nixos-default option
|
||||
";
|
||||
};
|
||||
|
||||
grubSplashImage = mkOption {
|
||||
default = pkgs.fetchurl {
|
||||
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
|
||||
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
|
||||
};
|
||||
example = null;
|
||||
description = "
|
||||
Background image used for Grub. It must be a 640x480,
|
||||
14-colour image in XPM format, optionally compressed with
|
||||
<command>gzip</command> or <command>bzip2</command>. Set to
|
||||
<literal>null</literal> to run Grub in text mode.
|
||||
";
|
||||
};
|
||||
|
||||
configurationLimit = mkOption {
|
||||
default = 100;
|
||||
example = 120;
|
||||
description = "
|
||||
Maximum of configurations in boot menu. GRUB has problems when
|
||||
there are too many entries.
|
||||
";
|
||||
};
|
||||
|
||||
copyKernels = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether the Grub menu builder should copy kernels and initial
|
||||
ramdisks to /boot. This is necessary when /nix is on a
|
||||
different file system than /boot.
|
||||
";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
|
||||
###### implementation
|
||||
let
|
||||
|
||||
grubMenuBuilder = pkgs.substituteAll {
|
||||
|
@ -109,31 +9,126 @@ let
|
|||
isExecutable = true;
|
||||
inherit (pkgs) bash;
|
||||
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
|
||||
inherit (config.boot.loader.grub) copyKernels extraGrubEntries extraGrubEntriesBeforeNixos
|
||||
grubSplashImage bootMount configurationLimit;
|
||||
inherit (config.boot.loader.grub) copyKernels extraEntries extraEntriesBeforeNixOS
|
||||
splashImage bootDevice configurationLimit;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
require = [
|
||||
options
|
||||
|
||||
# config.system.build
|
||||
# ../system/system-options.nix
|
||||
];
|
||||
###### interface
|
||||
|
||||
system = mkIf config.boot.loader.grub.enable {
|
||||
build = {
|
||||
menuBuilder = grubMenuBuilder;
|
||||
options = {
|
||||
|
||||
boot.loader.grub = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable the GRUB boot loader.
|
||||
'';
|
||||
};
|
||||
|
||||
device = mkOption {
|
||||
default = "";
|
||||
example = "/dev/hda";
|
||||
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.
|
||||
";
|
||||
};
|
||||
|
||||
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).
|
||||
";
|
||||
};
|
||||
|
||||
configurationName = mkOption {
|
||||
default = "";
|
||||
example = "Stable 2.6.21";
|
||||
description = "
|
||||
Grub entry name instead of default.
|
||||
";
|
||||
};
|
||||
|
||||
extraEntries = mkOption {
|
||||
default = "";
|
||||
example = "
|
||||
title Windows
|
||||
chainloader (hd0,1)+1
|
||||
";
|
||||
description = "
|
||||
Any additional entries you want added to the Grub boot menu.
|
||||
";
|
||||
};
|
||||
|
||||
extraEntriesBeforeNixOS = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether extraEntries are included before the default option.
|
||||
";
|
||||
};
|
||||
|
||||
splashImage = mkOption {
|
||||
default = pkgs.fetchurl {
|
||||
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
|
||||
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
|
||||
};
|
||||
example = null;
|
||||
description = "
|
||||
Background image used for Grub. It must be a 640x480,
|
||||
14-colour image in XPM format, optionally compressed with
|
||||
<command>gzip</command> or <command>bzip2</command>. Set to
|
||||
<literal>null</literal> to run Grub in text mode.
|
||||
";
|
||||
};
|
||||
|
||||
configurationLimit = mkOption {
|
||||
default = 100;
|
||||
example = 120;
|
||||
description = "
|
||||
Maximum of configurations in boot menu. GRUB has problems when
|
||||
there are too many entries.
|
||||
";
|
||||
};
|
||||
|
||||
copyKernels = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether the Grub menu builder should copy kernels and initial
|
||||
ramdisks to /boot. This is necessary when /nix is on a
|
||||
different file system than /boot.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# Common attribute for boot loaders so only one of them can be
|
||||
# set at once
|
||||
boot.loader.id = "grub";
|
||||
boot.loader.kernelFile = "vmlinuz";
|
||||
};
|
||||
|
||||
|
||||
environment.extraPackages = mkIf config.boot.loader.grub.enable [ pkgs.grub ];
|
||||
###### implementation
|
||||
|
||||
# and many other things that have to be moved inside this file.
|
||||
config = mkIf config.boot.loader.grub.enable {
|
||||
|
||||
system.build.menuBuilder = grubMenuBuilder;
|
||||
|
||||
# Common attribute for boot loaders so only one of them can be
|
||||
# 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.
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue