summaryrefslogtreecommitdiffstats
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2019-05-20 21:42:40 -0500
committerGitHub <noreply@github.com>2019-05-20 21:42:40 -0500
commit022d8ab861cea9508f407ffe906c713b2b1ee529 (patch)
tree29544b4e30fd2496cd37dd3b33d3407818401737 /nixos/modules/system
parentafd8f69d945e26e499a894dc10fe44a3c4d0a42c (diff)
parentd88d675051db1ac390b4064a00cb2cdfaa78a6af (diff)
Merge pull request #61036 from cdepillabout/nixos-memtest-loader
nixos/systemd-boot: add support for memtest86 EFI app
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py27
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix15
2 files changed, 42 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
index 6016a85ea061..940d4c0eb973 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
@@ -33,6 +33,15 @@ initrd {initrd}
options {kernel_params}
"""
+# The boot loader entry for memtest86.
+#
+# 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.
+MEMTEST_BOOT_ENTRY = """title MemTest86
+efi /efi/memtest86/BOOTX64.efi
+"""
+
def write_loader_conf(profile, generation):
with open("@efiSysMountPoint@/loader/loader.conf.tmp", 'w') as f:
if "@timeout@" != "":
@@ -199,6 +208,24 @@ def main():
if os.readlink(system_dir(*gen)) == args.default_config:
write_loader_conf(*gen)
+ memtest_entry_file = "@efiSysMountPoint@/loader/entries/memtest86.conf"
+ if os.path.exists(memtest_entry_file):
+ os.unlink(memtest_entry_file)
+ shutil.rmtree("@efiSysMountPoint@/efi/memtest86", ignore_errors=True)
+ if "@memtest86@" != "":
+ mkdir_p("@efiSysMountPoint@/efi/memtest86")
+ for path in glob.iglob("@memtest86@/*"):
+ if os.path.isdir(path):
+ shutil.copytree(path, os.path.join("@efiSysMountPoint@/efi/memtest86", os.path.basename(path)))
+ else:
+ shutil.copy(path, "@efiSysMountPoint@/efi/memtest86/")
+
+ memtest_entry_file = "@efiSysMountPoint@/loader/entries/memtest86.conf"
+ memtest_entry_file_tmp_path = "%s.tmp" % memtest_entry_file
+ with open(memtest_entry_file_tmp_path, 'w') as f:
+ f.write(MEMTEST_BOOT_ENTRY)
+ os.rename(memtest_entry_file_tmp_path, memtest_entry_file)
+
# Since fat32 provides little recovery facilities after a crash,
# it can leave the system in an unbootable state, when a crash/outage
# happens shortly after an update. To decrease the likelihood of this
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
index 03a5fece82ee..ad464a456bcd 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix
@@ -25,6 +25,8 @@ let
inherit (cfg) consoleMode;
inherit (efi) efiSysMountPoint canTouchEfiVariables;
+
+ memtest86 = if cfg.memtest86.enable then pkgs.memtest86-efi else "";
};
in {
@@ -85,6 +87,19 @@ in {
</itemizedlist>
'';
};
+
+ memtest86 = {
+ enable = mkOption {
+ default = false;
+ type = types.bool;
+ description = ''
+ Make MemTest86 available from the systemd-boot menu. MemTest86 is a
+ program for testing memory. MemTest86 is an unfree program, so
+ this requires <literal>allowUnfree</literal> to be set to
+ <literal>true</literal>.
+ '';
+ };
+ };
};
config = mkIf cfg.enable {