summaryrefslogtreecommitdiffstats
path: root/nixos/tests/limine/additional-files.nix
blob: 9e7e001841859df0ebb130f879d541c670c9327c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ pkgs, lib, ... }:
{
  name = "additionalFiles";
  meta.maintainers = with lib.maintainers; [
    flokli
  ];
  meta.platforms = [
    "x86_64-linux"
  ];
  nodes.machine =
    { ... }:
    {
      virtualisation.useBootLoader = true;
      virtualisation.useEFIBoot = true;
      boot.loader.limine.enable = true;
      boot.loader.limine.efiSupport = true;
      boot.loader.timeout = 0;

      specialisation.withAdditionalFiles.configuration = { ... }: {
        boot.loader.limine.additionalFiles = {
          "efi/memtest86/memtest86.efi" = "${pkgs.memtest86-efi}/BOOTX64.efi";
        };
      };
      specialisation.withAdditionalFilesOther.configuration = { ... }: {
        boot.loader.limine.additionalFiles = {
          "efi/memtest86/memtest86.efi" = "${builtins.toFile "some-file" "some-content"}";
        };
      };
    };

  testScript =
    { nodes, ... }:
    let
      withAdditionalFiles =
        nodes.machine.specialisation.withAdditionalFiles.configuration.system.build.toplevel;
      withAdditionalFilesOther =
        nodes.machine.specialisation.withAdditionalFilesOther.configuration.system.build.toplevel;
    in
    ''
      machine.start()
      machine.wait_for_unit("multi-user.target")

      # switch to a generation with additional files and ensure they're present
      machine.succeed("${withAdditionalFiles}/bin/switch-to-configuration switch")
      machine.succeed("stat /boot/efi/memtest86/memtest86.efi")

      # switch to the next generation with something else in there and ensure it got updated
      machine.succeed("${withAdditionalFilesOther}/bin/switch-to-configuration switch")
      assert machine.succeed("cat /boot/efi/memtest86/memtest86.efi").strip() == "some-content"
    '';
}