Merge pull request #226821 from enc0urage/memtest
This commit is contained in:
commit
56700d64b1
|
@ -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, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
memtest86 = pkgs.memtest86plus;
|
memtest86 = pkgs.memtest86plus;
|
||||||
efiSupport = config.boot.loader.grub.efiSupport;
|
|
||||||
cfg = config.boot.loader.grub.memtest86;
|
cfg = config.boot.loader.grub.memtest86;
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -19,11 +17,8 @@ in
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Make Memtest86+ (or MemTest86 if EFI support is enabled),
|
Make Memtest86+, a memory testing program, available from the GRUB
|
||||||
a memory testing program, available from the
|
boot menu.
|
||||||
GRUB boot menu. MemTest86 is an unfree program, so
|
|
||||||
this requires `allowUnfree` to be set to
|
|
||||||
`true`.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,34 +58,12 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkMerge [
|
config = mkIf cfg.enable {
|
||||||
(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 = ''
|
boot.loader.grub.extraEntries = ''
|
||||||
menuentry "Memtest86+" {
|
menuentry "Memtest86+" {
|
||||||
linux16 @bootRoot@/memtest.bin ${toString cfg.params}
|
linux @bootRoot@/memtest.bin ${toString cfg.params}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
boot.loader.grub.extraFiles."memtest.bin" = "${memtest86}/memtest.bin";
|
boot.loader.grub.extraFiles."memtest.bin" = "${memtest86}/memtest.bin";
|
||||||
})
|
};
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ let
|
||||||
|
|
||||||
inherit (config.system.nixos) distroName;
|
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;
|
netbootxyz = optionalString cfg.netbootxyz.enable pkgs.netbootxyz-efi;
|
||||||
|
|
||||||
|
@ -147,10 +147,8 @@ in {
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Make MemTest86 available from the systemd-boot menu. MemTest86 is a
|
Make MemTest86+ available from the systemd-boot menu. MemTest86+ is a
|
||||||
program for testing memory. MemTest86 is an unfree program, so
|
program for testing memory.
|
||||||
this requires `allowUnfree` to be set to
|
|
||||||
`true`.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -193,8 +191,8 @@ in {
|
||||||
default = {};
|
default = {};
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{ "memtest86.conf" = '''
|
{ "memtest86.conf" = '''
|
||||||
title MemTest86
|
title MemTest86+
|
||||||
efi /efi/memtest86/memtest86.efi
|
efi /efi/memtest86/memtest.efi
|
||||||
'''; }
|
'''; }
|
||||||
'';
|
'';
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
|
@ -213,7 +211,7 @@ in {
|
||||||
type = types.attrsOf types.path;
|
type = types.attrsOf types.path;
|
||||||
default = {};
|
default = {};
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{ "efi/memtest86/memtest86.efi" = "''${pkgs.memtest86-efi}/BOOTX64.efi"; }
|
{ "efi/memtest86/memtest.efi" = "''${pkgs.memtest86plus}/memtest.efi"; }
|
||||||
'';
|
'';
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
A set of files to be copied to {file}`/boot`.
|
A set of files to be copied to {file}`/boot`.
|
||||||
|
@ -276,11 +274,8 @@ in {
|
||||||
boot.loader.supportsInitrdSecrets = true;
|
boot.loader.supportsInitrdSecrets = true;
|
||||||
|
|
||||||
boot.loader.systemd-boot.extraFiles = mkMerge [
|
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 {
|
(mkIf cfg.memtest86.enable {
|
||||||
"efi/memtest86/BOOTX64.efi" = "${pkgs.memtest86-efi}/BOOTX64.efi";
|
"efi/memtest86/memtest.efi" = "${pkgs.memtest86plus.efi}";
|
||||||
})
|
})
|
||||||
(mkIf cfg.netbootxyz.enable {
|
(mkIf cfg.netbootxyz.enable {
|
||||||
"efi/netbootxyz/netboot.xyz.efi" = "${pkgs.netbootxyz-efi}";
|
"efi/netbootxyz/netboot.xyz.efi" = "${pkgs.netbootxyz-efi}";
|
||||||
|
@ -291,7 +286,7 @@ in {
|
||||||
(mkIf cfg.memtest86.enable {
|
(mkIf cfg.memtest86.enable {
|
||||||
"${cfg.memtest86.entryFilename}" = ''
|
"${cfg.memtest86.entryFilename}" = ''
|
||||||
title MemTest86
|
title MemTest86
|
||||||
efi /efi/memtest86/BOOTX64.efi
|
efi /efi/memtest86/memtest.efi
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
(mkIf cfg.netbootxyz.enable {
|
(mkIf cfg.netbootxyz.enable {
|
||||||
|
|
|
@ -118,14 +118,11 @@ in
|
||||||
nodes.machine = { pkgs, lib, ... }: {
|
nodes.machine = { pkgs, lib, ... }: {
|
||||||
imports = [ common ];
|
imports = [ common ];
|
||||||
boot.loader.systemd-boot.memtest86.enable = true;
|
boot.loader.systemd-boot.memtest86.enable = true;
|
||||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
|
||||||
"memtest86-efi"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.succeed("test -e /boot/loader/entries/memtest86.conf")
|
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 ];
|
imports = [ common ];
|
||||||
boot.loader.systemd-boot.memtest86.enable = true;
|
boot.loader.systemd-boot.memtest86.enable = true;
|
||||||
boot.loader.systemd-boot.memtest86.entryFilename = "apple.conf";
|
boot.loader.systemd-boot.memtest86.entryFilename = "apple.conf";
|
||||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
|
||||||
"memtest86-efi"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.fail("test -e /boot/loader/entries/memtest86.conf")
|
machine.fail("test -e /boot/loader/entries/memtest86.conf")
|
||||||
machine.succeed("test -e /boot/loader/entries/apple.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