about summary refs log tree commit diff
path: root/nixos/tests/bootspec.nix
diff options
context:
space:
mode:
authorRaito Bezarius <masterancpp@gmail.com>2022-12-21 23:28:21 +0100
committerRaito Bezarius <masterancpp@gmail.com>2022-12-21 23:28:21 +0100
commit5dd2e60371cc749dbccd44719df9a8c18a29d346 (patch)
treea80d919cef1aac6a5e408292c7c68d6a9ede3bd7 /nixos/tests/bootspec.nix
parentfa09312274c4ff0c93677e534fd5b40bff8cca05 (diff)
nixos/activation/bootspec: make initrd optional, serialize system, precise extensions' type
Diffstat (limited to 'nixos/tests/bootspec.nix')
-rw-r--r--nixos/tests/bootspec.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/nixos/tests/bootspec.nix b/nixos/tests/bootspec.nix
index 13360bb1eaa2e..8616cfdd937c4 100644
--- a/nixos/tests/bootspec.nix
+++ b/nixos/tests/bootspec.nix
@@ -90,6 +90,32 @@ in
     '';
   };
 
+  # Check that initrd create corresponding entries in bootspec.
+  initrd = makeTest {
+    name = "bootspec-with-initrd";
+    meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
+
+    nodes.machine = {
+      imports = [ standard ];
+      environment.systemPackages = [ pkgs.jq ];
+      # It's probably the case, but we want to make it explicit here.
+      boot.initrd.enable = true;
+    };
+
+    testScript = ''
+      import json
+
+      machine.start()
+      machine.wait_for_unit("multi-user.target")
+
+      machine.succeed("test -e /run/current-system/bootspec/boot.json")
+
+      bootspec = json.loads(machine.succeed("jq -r '.v1' /run/current-system/bootspec/boot.json"))
+
+      assert all(key in bootspec for key in ('initrd', 'initrdSecrets')), "Bootspec should contain initrd or initrdSecrets field when initrd is enabled"
+    '';
+  };
+
   # Check that specialisations create corresponding entries in bootspec.
   specialisation = makeTest {
     name = "bootspec-with-specialisation";