Merge pull request #226821 from enc0urage/memtest
This commit is contained in:
commit
56700d64b1
3 changed files with 21 additions and 59 deletions
|
@ -1,12 +1,10 @@
|
|||
# This module adds Memtest86+/Memtest86 to the GRUB boot menu.
|
||||
|
||||
# This module adds Memtest86+ to the GRUB boot menu.
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
memtest86 = pkgs.memtest86plus;
|
||||
efiSupport = config.boot.loader.grub.efiSupport;
|
||||
cfg = config.boot.loader.grub.memtest86;
|
||||
in
|
||||
|
||||
|
@ -19,11 +17,8 @@ in
|
|||
default = false;
|
||||
type = types.bool;
|
||||
description = lib.mdDoc ''
|
||||
Make Memtest86+ (or MemTest86 if EFI support is enabled),
|
||||
a memory testing program, available from the
|
||||
GRUB boot menu. MemTest86 is an unfree program, so
|
||||
this requires `allowUnfree` to be set to
|
||||
`true`.
|
||||
Make Memtest86+, a memory testing program, available from the GRUB
|
||||
boot menu.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -63,34 +58,12 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
(mkIf (cfg.enable && efiSupport) {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.params == [];
|
||||
message = "Parameters are not available for MemTest86";
|
||||
}
|
||||
];
|
||||
|
||||
boot.loader.grub.extraFiles = {
|
||||
"memtest86.efi" = "${pkgs.memtest86-efi}/BOOTX64.efi";
|
||||
};
|
||||
|
||||
boot.loader.grub.extraEntries = ''
|
||||
menuentry "Memtest86" {
|
||||
chainloader /memtest86.efi
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf (cfg.enable && !efiSupport) {
|
||||
boot.loader.grub.extraEntries = ''
|
||||
menuentry "Memtest86+" {
|
||||
linux16 @bootRoot@/memtest.bin ${toString cfg.params}
|
||||
}
|
||||
'';
|
||||
|
||||
boot.loader.grub.extraFiles."memtest.bin" = "${memtest86}/memtest.bin";
|
||||
})
|
||||
];
|
||||
config = mkIf cfg.enable {
|
||||
boot.loader.grub.extraEntries = ''
|
||||
menuentry "Memtest86+" {
|
||||
linux @bootRoot@/memtest.bin ${toString cfg.params}
|
||||
}
|
||||
'';
|
||||
boot.loader.grub.extraFiles."memtest.bin" = "${memtest86}/memtest.bin";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ let
|
|||
|
||||
inherit (config.system.nixos) distroName;
|
||||
|
||||
memtest86 = optionalString cfg.memtest86.enable pkgs.memtest86-efi;
|
||||
memtest86 = optionalString cfg.memtest86.enable pkgs.memtest86plus;
|
||||
|
||||
netbootxyz = optionalString cfg.netbootxyz.enable pkgs.netbootxyz-efi;
|
||||
|
||||
|
@ -147,10 +147,8 @@ in {
|
|||
default = false;
|
||||
type = types.bool;
|
||||
description = lib.mdDoc ''
|
||||
Make MemTest86 available from the systemd-boot menu. MemTest86 is a
|
||||
program for testing memory. MemTest86 is an unfree program, so
|
||||
this requires `allowUnfree` to be set to
|
||||
`true`.
|
||||
Make MemTest86+ available from the systemd-boot menu. MemTest86+ is a
|
||||
program for testing memory.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -193,8 +191,8 @@ in {
|
|||
default = {};
|
||||
example = literalExpression ''
|
||||
{ "memtest86.conf" = '''
|
||||
title MemTest86
|
||||
efi /efi/memtest86/memtest86.efi
|
||||
title MemTest86+
|
||||
efi /efi/memtest86/memtest.efi
|
||||
'''; }
|
||||
'';
|
||||
description = lib.mdDoc ''
|
||||
|
@ -213,7 +211,7 @@ in {
|
|||
type = types.attrsOf types.path;
|
||||
default = {};
|
||||
example = literalExpression ''
|
||||
{ "efi/memtest86/memtest86.efi" = "''${pkgs.memtest86-efi}/BOOTX64.efi"; }
|
||||
{ "efi/memtest86/memtest.efi" = "''${pkgs.memtest86plus}/memtest.efi"; }
|
||||
'';
|
||||
description = lib.mdDoc ''
|
||||
A set of files to be copied to {file}`/boot`.
|
||||
|
@ -276,11 +274,8 @@ in {
|
|||
boot.loader.supportsInitrdSecrets = true;
|
||||
|
||||
boot.loader.systemd-boot.extraFiles = mkMerge [
|
||||
# TODO: This is hard-coded to use the 64-bit EFI app, but it could probably
|
||||
# be updated to use the 32-bit EFI app on 32-bit systems. The 32-bit EFI
|
||||
# app filename is BOOTIA32.efi.
|
||||
(mkIf cfg.memtest86.enable {
|
||||
"efi/memtest86/BOOTX64.efi" = "${pkgs.memtest86-efi}/BOOTX64.efi";
|
||||
"efi/memtest86/memtest.efi" = "${pkgs.memtest86plus.efi}";
|
||||
})
|
||||
(mkIf cfg.netbootxyz.enable {
|
||||
"efi/netbootxyz/netboot.xyz.efi" = "${pkgs.netbootxyz-efi}";
|
||||
|
@ -291,7 +286,7 @@ in {
|
|||
(mkIf cfg.memtest86.enable {
|
||||
"${cfg.memtest86.entryFilename}" = ''
|
||||
title MemTest86
|
||||
efi /efi/memtest86/BOOTX64.efi
|
||||
efi /efi/memtest86/memtest.efi
|
||||
'';
|
||||
})
|
||||
(mkIf cfg.netbootxyz.enable {
|
||||
|
|
|
@ -118,14 +118,11 @@ in
|
|||
nodes.machine = { pkgs, lib, ... }: {
|
||||
imports = [ common ];
|
||||
boot.loader.systemd-boot.memtest86.enable = true;
|
||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
||||
"memtest86-efi"
|
||||
];
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.succeed("test -e /boot/loader/entries/memtest86.conf")
|
||||
machine.succeed("test -e /boot/efi/memtest86/BOOTX64.efi")
|
||||
machine.succeed("test -e /boot/efi/memtest86/memtest.efi")
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -152,15 +149,12 @@ in
|
|||
imports = [ common ];
|
||||
boot.loader.systemd-boot.memtest86.enable = true;
|
||||
boot.loader.systemd-boot.memtest86.entryFilename = "apple.conf";
|
||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
||||
"memtest86-efi"
|
||||
];
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.fail("test -e /boot/loader/entries/memtest86.conf")
|
||||
machine.succeed("test -e /boot/loader/entries/apple.conf")
|
||||
machine.succeed("test -e /boot/efi/memtest86/BOOTX64.efi")
|
||||
machine.succeed("test -e /boot/efi/memtest86/memtest.efi")
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue