aboutsummaryrefslogtreecommitdiffstats
path: root/nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 17:56:39 +0000
committertv <tv@krebsco.de>2026-11-30 19:51:09 +0000
commit62f857e35f94e98b3205502e410f0d727fa5ecc5 (patch)
tree9f1197abecef97948480d710cfa4b01ad0dacf47 /nix
parent94c73688f08dd4a6bb25c75e62cdaf7849f6c0a1 (diff)
enstate: --stage, a submission for the next generation
Plans against --schema, stores the snapshot under it, and puts no views in place and runs no reactions: the running generation goes on as it is, keeping what it has no slot for, and the switch (--migrate) brings the new views. The way to fill a required slot a generation adds before switching to it, and to bring a host's first state: with the new system's enstate, schema and configuration. Tests, and a subtest of the VM test that does so.
Diffstat (limited to 'nix')
-rw-r--r--nix/test.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/nix/test.nix b/nix/test.nix
index f2739eb..d2f69d9 100644
--- a/nix/test.nix
+++ b/nix/test.nix
@@ -52,6 +52,11 @@ pkgs.testers.runNixOSTest {
systemd.services.consumer = credential 50 config "retiolum.key";
};
+ # Adds a required slot: a submission for it is staged before switching.
+ specialisation.added.configuration = {
+ enstate.channels.secrets.slots."extra.key" = key;
+ };
+
specialisation.retyped.configuration = {
enstate.channels.secrets.slots = lib.mkForce {
"tinc.key" = key // {
@@ -110,6 +115,26 @@ pkgs.testers.runNixOSTest {
machine.fail("/run/booted-system/specialisation/retyped/bin/switch-to-configuration test")
machine.succeed("enstate --status | grep -q 'filled tinc.key'")
+ with subtest("a generation that adds a required slot: staged with its own enstate, then switched to"):
+ new = "/run/booted-system/specialisation/added"
+ machine.fail(f"{new}/bin/switch-to-configuration test")
+ machine.succeed(
+ "mkdir -p /root/added",
+ "printf X > /root/added/key",
+ """echo '{"channel": "secrets", "items": {"extra.key": {"source": {"file": "key"}}}}' """
+ "> /root/added/sources.json",
+ f"{new}/sw/bin/enstate --pack /root/added/sources.json --out /root/added/submission",
+ f"{new}/sw/bin/enstate --plan /root/added/submission --schema {new}/etc/enstate/schema.json --config {new}/etc/enstate/config.json",
+ f"{new}/sw/bin/enstate --stage /root/added/submission --schema {new}/etc/enstate/schema.json --config {new}/etc/enstate/config.json",
+ )
+ machine.fail("test -e /run/enstate/views/secrets.extra.key")
+ seen("tinc.key L")
+ machine.succeed(f"{new}/bin/switch-to-configuration test")
+ machine.wait_until_succeeds("grep -qx X /run/enstate/views/secrets.extra.key/extra.key")
+ seen("tinc.key L")
+ machine.succeed("/run/booted-system/bin/switch-to-configuration test")
+ machine.succeed("enstate --status | grep -q 'kept extra.key'")
+
with subtest("after a reboot, the views are there again"):
machine.shutdown()
machine.start()