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 'initrd' in bootspec, "Bootspec should contain initrd field when initrd is enabled"
116 assert 'initrdSecrets' not in bootspec, "Bootspec should not contain initrdSecrets when there's no initrdSecrets"
120 # Check that initrd secrets create corresponding entries in bootspec.
121 initrd-secrets = makeTest {
122 name = "bootspec-with-initrd-secrets";
123 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
126 imports = [ standard ];
127 environment.systemPackages = [ pkgs.jq ];
128 # It's probably the case, but we want to make it explicit here.
129 boot.initrd.enable = true;
130 boot.initrd.secrets."/some/example" = pkgs.writeText "example-secret" "test";
137 machine.wait_for_unit("multi-user.target")
139 machine.succeed("test -e /run/current-system/boot.json")
141 bootspec = json.loads(machine.succeed("jq -r '.\"org.nixos.bootspec.v1\"' /run/current-system/boot.json"))
143 assert 'initrdSecrets' in bootspec, "Bootspec should contain an 'initrdSecrets' field given there's an initrd secret"
148 # Check that specialisations create corresponding entries in bootspec.
149 specialisation = makeTest {
150 name = "bootspec-with-specialisation";
151 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
154 imports = [ standard ];
155 environment.systemPackages = [ pkgs.jq ];
156 specialisation.something.configuration = {};
163 machine.wait_for_unit("multi-user.target")
165 machine.succeed("test -e /run/current-system/boot.json")
166 machine.succeed("test -e /run/current-system/specialisation/something/boot.json")
168 sp_in_parent = json.loads(machine.succeed("jq -r '.\"org.nixos.specialisation.v1\".something' /run/current-system/boot.json"))
169 sp_in_fs = json.loads(machine.succeed("cat /run/current-system/specialisation/something/boot.json"))
171 assert sp_in_parent['org.nixos.bootspec.v1'] == sp_in_fs['org.nixos.bootspec.v1'], "Bootspecs of the same specialisation are different!"
175 # Check that extensions are propagated.
176 extensions = makeTest {
177 name = "bootspec-with-extensions";
178 meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
180 nodes.machine = { config, ... }: {
181 imports = [ standard ];
182 environment.systemPackages = [ pkgs.jq ];
183 boot.bootspec.extensions = {
184 "org.nix-tests.product" = {
185 osRelease = config.environment.etc."os-release".source;
192 machine.wait_for_unit("multi-user.target")
194 current_os_release = machine.succeed("cat /etc/os-release")
195 bootspec_os_release = machine.succeed("cat $(jq -r '.\"org.nix-tests.product\".osRelease' /run/current-system/boot.json)")
197 assert current_os_release == bootspec_os_release, "Filename referenced by extension has unexpected contents"