diff options
author | r-vdp <ramses@well-founded.dev> | 2024-01-24 18:15:28 +0100 |
---|---|---|
committer | r-vdp <ramses@well-founded.dev> | 2024-03-02 02:11:32 +0100 |
commit | a8ab8b59a75a4bf0675fb3785e76c54873044f9e (patch) | |
tree | 965e489b9c8c00ca3fbf74859bfe0abfd818a07c /nixos/tests | |
parent | 0267739e11e44bb791b747565758c6446b01eac7 (diff) |
systemd-boot: introduce options to set a sort-key for systemd-boot entries
Without sort-keys specified on entries, the entries are sorted only by file name (in decreasing order, so starting at the end of the alphabet!), without taking any other fields into account (see [the boot loader specification reference][1]). Moreover, entries without a sort-key are always ordered after all entries with a sort-key, so by not adding a sort-key to the NixOS ones, we cannot add a sort-key to any other entry while keeping it below the NixOS entries. So currently we have options to set the file names for additional entries like memtest and netbootxyz. However, as mentioned above, the sorting by file name is not very intuitive and actually sorts in the opposite order of what is currently mentioned in the option descriptions. With this commit, we set a configurable sort-key on all NixOS entries, and add options for setting the sort-keys for the memtest and netbootxyz entries. The sorting by sort-key is more intuitive (it starts at the start of the alphabet) and also takes into account the machine-id and version for entries with identical sort-keys. We use a bootspec extension to store the sort keys, which allows us to redefine the sort key for individual specialisations without needing any special casing. [1]: https://uapi-group.org/specifications/specs/boot_loader_specification/#sorting
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/systemd-boot.nix | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/nixos/tests/systemd-boot.nix b/nixos/tests/systemd-boot.nix index 1b7e83253e59e..410b24036a004 100644 --- a/nixos/tests/systemd-boot.nix +++ b/nixos/tests/systemd-boot.nix @@ -93,6 +93,7 @@ in machine.wait_for_unit("multi-user.target") machine.succeed("test -e /boot/loader/entries/nixos-generation-1.conf") + machine.succeed("grep 'sort-key nixos' /boot/loader/entries/nixos-generation-1.conf") # Ensure we actually booted using systemd-boot # Magic number is the vendor UUID used by systemd-boot. @@ -164,7 +165,9 @@ in nodes.machine = { pkgs, lib, ... }: { imports = [ common ]; - specialisation.something.configuration = {}; + specialisation.something.configuration = { + boot.loader.systemd-boot.sortKey = "something"; + }; }; testScript = '' @@ -177,6 +180,9 @@ in machine.succeed( "grep -q 'title NixOS (something)' /boot/loader/entries/nixos-generation-1-specialisation-something.conf" ) + machine.succeed( + "grep 'sort-key something' /boot/loader/entries/nixos-generation-1-specialisation-something.conf" + ) ''; }; @@ -254,25 +260,25 @@ in }; testScript = '' - machine.succeed("test -e /boot/loader/entries/o_netbootxyz.conf") + machine.succeed("test -e /boot/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/netbootxyz/netboot.xyz.efi") ''; }; - entryFilename = makeTest { - name = "systemd-boot-entry-filename"; + memtestSortKey = makeTest { + name = "systemd-boot-memtest-sortkey"; meta.maintainers = with pkgs.lib.maintainers; [ Enzime julienmalka ]; nodes.machine = { pkgs, lib, ... }: { imports = [ common ]; boot.loader.systemd-boot.memtest86.enable = true; - boot.loader.systemd-boot.memtest86.entryFilename = "apple.conf"; + boot.loader.systemd-boot.memtest86.sortKey = "apple"; }; testScript = '' - 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/memtest86.conf") machine.succeed("test -e /boot/efi/memtest86/memtest.efi") + machine.succeed("grep 'sort-key apple' /boot/loader/entries/memtest86.conf") ''; }; @@ -283,7 +289,6 @@ in nodes.machine = { pkgs, lib, ... }: { imports = [ commonXbootldr ]; boot.loader.systemd-boot.memtest86.enable = true; - boot.loader.systemd-boot.memtest86.entryFilename = "apple.conf"; }; testScript = { nodes, ... }: '' @@ -293,8 +298,7 @@ in machine.wait_for_unit("multi-user.target") machine.succeed("test -e /efi/EFI/systemd/systemd-bootx64.efi") - 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/memtest86.conf") machine.succeed("test -e /boot/EFI/memtest86/memtest.efi") ''; }; @@ -386,9 +390,9 @@ in machine.succeed("${finalSystem}/bin/switch-to-configuration boot") machine.fail("test -e /boot/efi/fruits/tomato.efi") machine.fail("test -e /boot/efi/nixos/.extra-files/efi/fruits/tomato.efi") - machine.succeed("test -e /boot/loader/entries/o_netbootxyz.conf") + machine.succeed("test -e /boot/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/netbootxyz/netboot.xyz.efi") - machine.succeed("test -e /boot/efi/nixos/.extra-files/loader/entries/o_netbootxyz.conf") + machine.succeed("test -e /boot/efi/nixos/.extra-files/loader/entries/netbootxyz.conf") machine.succeed("test -e /boot/efi/nixos/.extra-files/efi/netbootxyz/netboot.xyz.efi") ''; }; |