making memtest grub entries work again
I'm not any good at perl, and I only came up with this after many slow attempts. Any review welcome. But until this, memtest was broken, and extraPrepareConfig as well, in grub.
This commit is contained in:
parent
3e734ba695
commit
358239348a
@ -13,10 +13,11 @@ let
|
||||
grubConfig = pkgs.writeText "grub-config.xml" (builtins.toXML
|
||||
{ splashImage = f config.boot.loader.grub.splashImage;
|
||||
grub = f grub;
|
||||
shell = "${pkgs.stdenv.shell}";
|
||||
fullVersion = (builtins.parseDrvName config.system.build.grub.name).version;
|
||||
inherit (config.boot.loader.grub)
|
||||
version extraConfig extraPerEntryConfig extraEntries
|
||||
extraEntriesBeforeNixOS configurationLimit copyKernels timeout
|
||||
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels timeout
|
||||
default devices;
|
||||
});
|
||||
|
||||
|
@ -30,6 +30,7 @@ sub writeFile {
|
||||
my $grub = get("grub");
|
||||
my $grubVersion = int(get("version"));
|
||||
my $extraConfig = get("extraConfig");
|
||||
my $extraPrepareConfig = get("extraPrepareConfig");
|
||||
my $extraPerEntryConfig = get("extraPerEntryConfig");
|
||||
my $extraEntries = get("extraEntries");
|
||||
my $extraEntriesBeforeNixOS = get("extraEntriesBeforeNixOS") eq "true";
|
||||
@ -188,6 +189,8 @@ addEntry("NixOS - Default", $defaultConfig);
|
||||
|
||||
$conf .= "$extraEntries\n" unless $extraEntriesBeforeNixOS;
|
||||
|
||||
# extraEntries could refer to @bootRoot@, which we have to substitute
|
||||
$conf =~ s/\@bootRoot\@/$bootRoot/g;
|
||||
|
||||
# Add entries for all previous generations of the system profile.
|
||||
$conf .= "submenu \"NixOS - Old configurations\" {\n" if $grubVersion == 2;
|
||||
@ -211,6 +214,10 @@ foreach my $link (@links) {
|
||||
|
||||
$conf .= "}\n" if $grubVersion == 2;
|
||||
|
||||
# Run extraPrepareConfig in sh
|
||||
if ($extraPrepareConfig ne "") {
|
||||
system((get("shell"), "-c", $extraPrepareConfig));
|
||||
}
|
||||
|
||||
# Atomically update the GRUB config.
|
||||
my $confFile = $grubVersion == 1 ? "/boot/grub/menu.lst" : "/boot/grub/grub.cfg";
|
||||
|
@ -22,17 +22,17 @@ in
|
||||
extraEntries = if config.boot.loader.grub.version == 2 then
|
||||
''
|
||||
menuentry "${memtest86.name}" {
|
||||
linux16 $bootRoot/memtest.bin
|
||||
linux16 @bootRoot@/memtest.bin
|
||||
}
|
||||
''
|
||||
else
|
||||
''
|
||||
menuentry "${memtest86.name}"
|
||||
linux16 $bootRoot/memtest.bin
|
||||
linux16 @bootRoot@/memtest.bin
|
||||
'';
|
||||
extraPrepareConfig =
|
||||
''
|
||||
cp ${memtest86}/memtest.bin /boot/memtest.bin;
|
||||
${pkgs.coreutils}/bin/cp ${memtest86}/memtest.bin /boot/memtest.bin;
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user