nixos/systemd-boot: add edk2-uefi-shell boot option
We already have a edk2-uefi-shell package in nixpkgs, but adding it to systemd-boot was somewhat tedious. Now it's a single line of nix.
This commit is contained in:
parent
548206583d
commit
f2e5b04c4e
@ -29,6 +29,8 @@ let
|
||||
$out
|
||||
'';
|
||||
|
||||
edk2ShellEspPath = "efi/edk2-uefi-shell/shell.efi";
|
||||
|
||||
systemdBootBuilder = pkgs.substituteAll rec {
|
||||
name = "systemd-boot";
|
||||
|
||||
@ -72,6 +74,8 @@ let
|
||||
|
||||
netbootxyz = optionalString cfg.netbootxyz.enable pkgs.netbootxyz-efi;
|
||||
|
||||
edk2-uefi-shell = optionalString cfg.edk2-uefi-shell.enable pkgs.edk2-uefi-shell;
|
||||
|
||||
checkMountpoints = pkgs.writeShellScript "check-mountpoints" ''
|
||||
fail() {
|
||||
echo "$1 = '$2' is not a mounted partition. Is the path configured correctly?" >&2
|
||||
@ -343,6 +347,29 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
edk2-uefi-shell = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Make the EDK2 UEFI Shell available from the systemd-boot menu.
|
||||
It can be used to manually boot other operating systems or for debugging.
|
||||
'';
|
||||
};
|
||||
|
||||
sortKey = mkOption {
|
||||
type = types.str;
|
||||
default = "o_edk2-uefi-shell";
|
||||
description = ''
|
||||
`systemd-boot` orders the menu entries by their sort keys,
|
||||
so if you want something to appear after all the NixOS entries,
|
||||
it should start with {file}`o` or onwards.
|
||||
|
||||
See also {option}`boot.loader.systemd-boot.sortKey`..
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
extraEntries = mkOption {
|
||||
type = types.attrsOf types.lines;
|
||||
default = { };
|
||||
@ -476,6 +503,9 @@ in
|
||||
(mkIf cfg.netbootxyz.enable {
|
||||
"efi/netbootxyz/netboot.xyz.efi" = "${pkgs.netbootxyz-efi}";
|
||||
})
|
||||
(mkIf cfg.edk2-uefi-shell.enable {
|
||||
${edk2ShellEspPath} = "${pkgs.edk2-uefi-shell}/shell.efi";
|
||||
})
|
||||
];
|
||||
|
||||
boot.loader.systemd-boot.extraEntries = mkMerge [
|
||||
@ -493,6 +523,13 @@ in
|
||||
sort-key ${cfg.netbootxyz.sortKey}
|
||||
'';
|
||||
})
|
||||
(mkIf cfg.edk2-uefi-shell.enable {
|
||||
"edk2-uefi-shell.conf" = ''
|
||||
title EDK2 UEFI Shell
|
||||
efi /${edk2ShellEspPath}
|
||||
sort-key ${cfg.edk2-uefi-shell.sortKey}
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
boot.bootspec.extensions."org.nixos.systemd-boot" = {
|
||||
|
@ -339,6 +339,21 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
edk2-uefi-shell = makeTest {
|
||||
name = "systemd-boot-edk2-uefi-shell";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ iFreilicht ];
|
||||
|
||||
nodes.machine = { ... }: {
|
||||
imports = [ common ];
|
||||
boot.loader.systemd-boot.edk2-uefi-shell.enable = true;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.succeed("test -e /boot/loader/entries/edk2-uefi-shell.conf")
|
||||
machine.succeed("test -e /boot/efi/edk2-uefi-shell/shell.efi")
|
||||
'';
|
||||
};
|
||||
|
||||
memtestSortKey = makeTest {
|
||||
name = "systemd-boot-memtest-sortkey";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ];
|
||||
|
Loading…
Reference in New Issue
Block a user