1 { system ? builtins.currentSystem,
3 pkgs ? import ../.. { inherit system config; }
6 with import ../lib/testing-python.nix { inherit system pkgs; };
11 virtualisation.useBootLoader = true;
14 boot.loader.grub.enable = true;
17 boot.loader.systemd-boot.enable = true;
20 virtualisation.useEFIBoot = true;
21 boot.loader.efi.canTouchEfiVariables = true;
22 boot.loader.grub.efiSupport = true;
23 environment.systemPackages = [ pkgs.efibootmgr ];
26 boot.bootspec.enable = true;
37 name = "systemd-boot-with-bootspec";
38 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
40 nodes.machine = standard;
44 machine.wait_for_unit("multi-user.target")
46 machine.succeed("test -e /run/current-system/boot.json")
51 name = "grub-with-bootspec";
52 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
55 boot.bootspec.enable = true;
66 machine.wait_for_unit("multi-user.target")
68 machine.succeed("test -e /run/current-system/boot.json")
72 legacy-boot = makeTest {
73 name = "legacy-boot-with-bootspec";
74 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
77 boot.bootspec.enable = true;
87 machine.wait_for_unit("multi-user.target")
89 machine.succeed("test -e /run/current-system/boot.json")
93 # Check that initrd create corresponding entries in bootspec.
95 name = "bootspec-with-initrd";
96 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
99 imports = [ standard ];
100 environment.systemPackages = [ pkgs.jq ];
101 # It's probably the case, but we want to make it explicit here.
102 boot.initrd.enable = true;
109 machine.wait_for_unit("multi-user.target")
111 machine.succeed("test -e /run/current-system/boot.json")
113 bootspec = json.loads(machine.succeed("jq -r '.\"org.nixos.bootspec.v1\"' /run/current-system/boot.json"))
115 assert all(key in bootspec for key in ('initrd', 'initrdSecrets')), "Bootspec should contain initrd or initrdSecrets field when initrd is enabled"
119 # Check that specialisations create corresponding entries in bootspec.
120 specialisation = makeTest {
121 name = "bootspec-with-specialisation";
122 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
125 imports = [ standard ];
126 environment.systemPackages = [ pkgs.jq ];
127 specialisation.something.configuration = {};
134 machine.wait_for_unit("multi-user.target")
136 machine.succeed("test -e /run/current-system/boot.json")
137 machine.succeed("test -e /run/current-system/specialisation/something/boot.json")
139 sp_in_parent = json.loads(machine.succeed("jq -r '.\"org.nixos.specialisation.v1\".something' /run/current-system/boot.json"))
140 sp_in_fs = json.loads(machine.succeed("cat /run/current-system/specialisation/something/boot.json"))
142 assert sp_in_parent['org.nixos.bootspec.v1'] == sp_in_fs['org.nixos.bootspec.v1'], "Bootspecs of the same specialisation are different!"
146 # Check that extensions are propagated.
147 extensions = makeTest {
148 name = "bootspec-with-extensions";
149 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
151 nodes.machine = { config, ... }: {
152 imports = [ standard ];
153 environment.systemPackages = [ pkgs.jq ];
154 boot.bootspec.extensions = {
155 "org.nix-tests.product" = {
156 osRelease = config.environment.etc."os-release".source;
163 machine.wait_for_unit("multi-user.target")
165 current_os_release = machine.succeed("cat /etc/os-release")
166 bootspec_os_release = machine.succeed("cat $(jq -r '.\"org.nix-tests.product\".osRelease' /run/current-system/boot.json)")
168 assert current_os_release == bootspec_os_release, "Filename referenced by extension has unexpected contents"