* 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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bootMount="@bootMount@"
|
bootDevice="@bootDevice@"
|
||||||
if test -z "$bootMount"; then bootMount=/boot; fi
|
if test -z "$bootDevice"; then bootDevice=/boot; fi
|
||||||
|
|
||||||
|
|
||||||
echo "updating the GRUB menu..."
|
echo "updating the GRUB menu..."
|
||||||
|
@ -28,11 +28,11 @@ timeout 5
|
||||||
GRUBEND
|
GRUBEND
|
||||||
|
|
||||||
|
|
||||||
if test -n "@grubSplashImage@"; then
|
if test -n "@splashImage@"; then
|
||||||
splashLocation=@grubSplashImage@
|
splashLocation=@splashImage@
|
||||||
# Splash images in /nix/store don't seem to work, so copy them.
|
# Splash images in /nix/store don't seem to work, so copy them.
|
||||||
cp -f $splashLocation /boot/background.xpm.gz
|
cp -f $splashLocation /boot/background.xpm.gz
|
||||||
splashLocation="$bootMount/background.xpm.gz"
|
splashLocation="$bootDevice/background.xpm.gz"
|
||||||
echo "splashimage $splashLocation" >> $tmp
|
echo "splashimage $splashLocation" >> $tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ fi
|
||||||
configurationCounter=0
|
configurationCounter=0
|
||||||
configurationLimit="@configurationLimit@"
|
configurationLimit="@configurationLimit@"
|
||||||
numAlienEntries=`cat <<EOF | egrep '^[[:space:]]*title' | wc -l
|
numAlienEntries=`cat <<EOF | egrep '^[[:space:]]*title' | wc -l
|
||||||
@extraGrubEntries@
|
@extraEntries@
|
||||||
EOF`
|
EOF`
|
||||||
|
|
||||||
if test $((configurationLimit+numAlienEntries)) -gt 190; then
|
if test $((configurationLimit+numAlienEntries)) -gt 190; then
|
||||||
|
@ -100,8 +100,8 @@ addEntry() {
|
||||||
cp "$(readlink -f "$path/init")" /boot/nixos-init
|
cp "$(readlink -f "$path/init")" /boot/nixos-init
|
||||||
cat > /boot/nixos-grub-config <<EOF
|
cat > /boot/nixos-grub-config <<EOF
|
||||||
title Emergency boot
|
title Emergency boot
|
||||||
kernel ${bootMount:-/boot}/nixos-kernel systemConfig=$(readlink -f "$path") init=/boot/nixos-init $(cat "$path/kernel-params")
|
kernel ${bootDevice:-/boot}/nixos-kernel systemConfig=$(readlink -f "$path") init=/boot/nixos-init $(cat "$path/kernel-params")
|
||||||
initrd ${bootMount:-/boot}/nixos-initrd
|
initrd ${bootDevice:-/boot}/nixos-initrd
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ EOF
|
||||||
copyToKernelsDir $initrd; initrd=$result
|
copyToKernelsDir $initrd; initrd=$result
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$bootMount"; then
|
if test -n "$bootDevice"; then
|
||||||
kernel=$(echo $kernel | sed -e "s^/boot^$bootMount^")
|
kernel=$(echo $kernel | sed -e "s^/boot^$bootDevice^")
|
||||||
initrd=$(echo $initrd | sed -e "s^/boot^$bootMount^")
|
initrd=$(echo $initrd | sed -e "s^/boot^$bootDevice^")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local confName=$(if test -e $path/configuration-name; then
|
local confName=$(if test -e $path/configuration-name; then
|
||||||
|
@ -137,19 +137,19 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# Additional entries specified verbatim by the configuration.
|
# Additional entries specified verbatim by the configuration.
|
||||||
extraGrubEntries=`cat <<EOF
|
extraEntries=`cat <<EOF
|
||||||
@extraGrubEntries@
|
@extraEntries@
|
||||||
EOF`
|
EOF`
|
||||||
|
|
||||||
|
|
||||||
if test -n "@extraGrubEntriesBeforeNixos@"; then
|
if test -n "@extraEntriesBeforeNixOS@"; then
|
||||||
echo "$extraGrubEntries" >> $tmp
|
echo "$extraEntries" >> $tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
addEntry "NixOS - Default" $default ""
|
addEntry "NixOS - Default" $default ""
|
||||||
|
|
||||||
if test -z "@extraGrubEntriesBeforeNixos@"; then
|
if test -z "@extraEntriesBeforeNixOS@"; then
|
||||||
echo "$extraGrubEntries" >> $tmp
|
echo "$extraEntries" >> $tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add all generations of the system profile to the menu, in reverse
|
# Add all generations of the system profile to the menu, in reverse
|
||||||
|
|
|
@ -1,13 +1,27 @@
|
||||||
{pkgs, config, ...}:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
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
|
###### interface
|
||||||
let
|
|
||||||
inherit (pkgs.lib) mkOption mkIf;
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
boot = {
|
|
||||||
loader = {
|
boot.loader.grub = {
|
||||||
grub = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -16,7 +30,7 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
grubDevice = mkOption {
|
device = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "/dev/hda";
|
example = "/dev/hda";
|
||||||
description = "
|
description = "
|
||||||
|
@ -26,14 +40,14 @@ let
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
bootMount = mkOption {
|
bootDevice = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "(hd0,0)";
|
example = "(hd0,0)";
|
||||||
description = "
|
description = "
|
||||||
If the system partition may be wiped on reinstall, it is better
|
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 have /boot on a small partition. To do it, we need to explain
|
||||||
to GRUB where the kernels live. Specify the partition here (in
|
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 = "";
|
default = "";
|
||||||
example = "
|
example = "
|
||||||
title Windows
|
title Windows
|
||||||
|
@ -56,14 +70,14 @@ let
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraGrubEntriesBeforeNixos = mkOption {
|
extraEntriesBeforeNixOS = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
description = "
|
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 {
|
default = pkgs.fetchurl {
|
||||||
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
|
url = http://www.gnome-look.org/CONTENT/content-files/36909-soft-tux.xpm.gz;
|
||||||
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
|
sha256 = "14kqdx2lfqvh40h6fjjzqgff1mwk74dmbjvmqphi6azzra7z8d59";
|
||||||
|
@ -94,46 +108,27 @@ let
|
||||||
different file system than /boot.
|
different file system than /boot.
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
|
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
let
|
|
||||||
|
|
||||||
grubMenuBuilder = pkgs.substituteAll {
|
config = mkIf config.boot.loader.grub.enable {
|
||||||
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
|
|
||||||
|
|
||||||
{
|
system.build.menuBuilder = grubMenuBuilder;
|
||||||
require = [
|
|
||||||
options
|
|
||||||
|
|
||||||
# config.system.build
|
|
||||||
# ../system/system-options.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
system = mkIf config.boot.loader.grub.enable {
|
|
||||||
build = {
|
|
||||||
menuBuilder = grubMenuBuilder;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Common attribute for boot loaders so only one of them can be
|
# Common attribute for boot loaders so only one of them can be
|
||||||
# set at once
|
# set at once.
|
||||||
boot.loader.id = "grub";
|
system.boot.loader.id = "grub";
|
||||||
boot.loader.kernelFile = "vmlinuz";
|
system.boot.loader.kernelFile = "vmlinuz";
|
||||||
};
|
|
||||||
|
|
||||||
environment.extraPackages = mkIf config.boot.loader.grub.enable [ pkgs.grub ];
|
environment.extraPackages = mkIf config.boot.loader.grub.enable [ pkgs.grub ];
|
||||||
|
|
||||||
# and many other things that have to be moved inside this file.
|
# 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 alias "services.xserver.slim.theme" to "services.xserver.displayManager.slim.theme"
|
||||||
++ rename obsolete "environment.extraPackages" to "environment.systemPackages"
|
++ 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.
|
) # do not add renaming after this.
|
||||||
|
|
|
@ -46,7 +46,8 @@ let
|
||||||
config.nesting.children;
|
config.nesting.children;
|
||||||
|
|
||||||
|
|
||||||
systemBuilder = let
|
systemBuilder =
|
||||||
|
let
|
||||||
kernelPath = "${config.boot.kernelPackages.kernel}/" +
|
kernelPath = "${config.boot.kernelPackages.kernel}/" +
|
||||||
"${config.system.boot.loader.kernelFile}";
|
"${config.system.boot.loader.kernelFile}";
|
||||||
in
|
in
|
||||||
|
@ -110,7 +111,7 @@ let
|
||||||
# Boot loaders
|
# Boot loaders
|
||||||
bootLoader = config.system.boot.loader.id;
|
bootLoader = config.system.boot.loader.id;
|
||||||
grub = if config.boot.loader.grub.enable then pkgs.grub else null;
|
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;
|
configurationName = config.boot.loader.grub.configurationName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue