Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/systemd-boot: add support for memtest86 EFI app #61036

Merged
merged 2 commits into from May 21, 2019

Conversation

cdepillabout
Copy link
Member

@cdepillabout cdepillabout commented May 6, 2019

This commit adds support for installing the memtest86 EFI app and adding a boot entry for it with systemd-boot.

In order to test this, you can set the following in /etc/nixos/configuration.nix:

{ config, pkgs, ...}:

{
  boot.loader.systemd-boot.memtest86.enable = true;
}

This should work as long as you have boot.loader.systemd-boot.enable set to true.

You'll also need allowUnfree set to true, since memtest86 is not open source.

Motivation for this change

I wanted a way to install memtest86 easily from NixOS. This is a follow-up of #60967.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This commit adds support for installing the memtest86 EFI app and adding
a boot entry for it with systemd-boot.
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above code does the following:

  1. Delete /boot/loader/entries/memtest86.conf if it exists.
  2. Delete the /boot/efi/memtest86/ directory. (This is the directory that contains the actual memtest86 UEFI app, called BOOTX64.efi.)
  3. If boot.loader.systemd-boot.memtest86.enable is set to true, the @memtest86@ string will be replaced with the path to the memtest86-efi derivation, so the following things will be done. (If boot.loader.systemd-boot.memtest86.enable is set to false, none of the following will be done.)
    1. Create the /boot/efi/memtest86/ directory.
    2. Copy all the files from the memtest86-efi derivation to the /boot/efi/memtest86/.
    3. Create the /boot/loader/entries/memtest86.conf file.

The above is relatively similar to what this script is doing for the actual nixos generation loader files.

@cdepillabout
Copy link
Member Author

Pinging @c0bw3b @JohnAZoidberg and @Lassulus since they all did reviews of #60967.


Also, on cdepillabout@8c85e24#commitcomment-33415487 @JohnAZoidberg suggested that it would be nice if there was a general NixOS module to install arbitrary EFI apps.

I think this would be a great idea, but it is somewhat out of scope for this PR. Ideally this PR (#61036) would get merged in, and then someone would send a PR adding a general module to install arbitrary EFI apps. Once that gets merged in, I'll send a follow-up PR adapting memtest86 to use it.

description = ''
Make MemTest86 available from the systemd-boot menu. MemTest86 is a
program for testing memory. MemTest86 is a non-open-source program, so
this requires <literal>allowUnfree</literal> to be set to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open source != free software ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ yheah I'm not going down that rabbit hole here and now!
My check was merely on the description clearly explaining the precondition on using this. ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not looking for a discussion either :D
But the option is literally called Unfree - so I think the description should use the same choice words.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit d88d675, I changed non-open-source to unfree.

@@ -25,6 +25,8 @@ let
inherit (cfg) consoleMode;

inherit (efi) efiSysMountPoint canTouchEfiVariables;

memtest86 = if cfg.memtest86.enable then pkgs.memtest86-efi else "";
Copy link
Contributor

@c0bw3b c0bw3b May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone try to enable it anyway with allowUnfree = false it will bring memtest86-efi into scope but the next nixos-rebuild should fail to eval with a clear enough error message. So it works as intended.

EDIT: virtualisation.virtualbox.host.enableExtensionPack does it in a similar fashion.

@matthewbauer matthewbauer merged commit 022d8ab into NixOS:master May 21, 2019
@cdepillabout cdepillabout deleted the nixos-memtest-loader branch May 21, 2019 02:51
cdepillabout added a commit to cdepillabout/nixpkgs that referenced this pull request Jul 28, 2019
….03)

This commit adds support for installing the memtest86 EFI app and adding
a boot entry for it with systemd-boot.

Backported from NixOS#61036.

(cherry picked from commit b12ea62)
(cherry picked from commit d88d675)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants