feat(tvix/boot): boot nixos VM
This makes use of the vmCmdline and assertVMOutput to boot a NixOS VM off of `tvix-store virtiofs` have it write a message on successful bootup, then have it shut down again. We check we see the message in the output. Seeding the store with the closure it's what's currently taking most of the time (as it's all linear still), so log a message before booting the VM. Change-Id: I6887d935f589eb0ad6507033c01337e1ec500a0b Reviewed-on: https://cl.tvl.fyi/c/depot/+/11191 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
This commit is contained in:
parent
538d5fc8ee
commit
cf47294b9e
1 changed files with 34 additions and 0 deletions
|
@ -70,12 +70,38 @@ let
|
||||||
tvix-store --otlp=false copy
|
tvix-store --otlp=false copy
|
||||||
'' + ''
|
'' + ''
|
||||||
# Invoke a VM using tvix as the backing store, ensure the outpath appears in its listing.
|
# Invoke a VM using tvix as the backing store, ensure the outpath appears in its listing.
|
||||||
|
echo "Starting VM…"
|
||||||
|
|
||||||
CH_CMDLINE="${vmCmdline}" run-tvix-vm 2>&1 | tee output.txt
|
CH_CMDLINE="${vmCmdline}" run-tvix-vm 2>&1 | tee output.txt
|
||||||
grep "${assertVMOutput}" output.txt
|
grep "${assertVMOutput}" output.txt
|
||||||
'';
|
'';
|
||||||
requiredSystemFeatures = [ "kvm" ];
|
requiredSystemFeatures = [ "kvm" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemFor = sys: (depot.ops.nixos.nixosFor sys).system;
|
||||||
|
|
||||||
|
testSystem = systemFor ({ modulesPath, pkgs, ... }: {
|
||||||
|
# Set some options necessary to evaluate.
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
# TODO: figure out how to disable this without causing eval to fail
|
||||||
|
fileSystems."/" = {
|
||||||
|
device = "/dev/root";
|
||||||
|
fsType = "tmpfs";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.getty.helpLine = "Onwards and upwards.";
|
||||||
|
systemd.services.do-shutdown = {
|
||||||
|
after = [ "getty.target" ];
|
||||||
|
description = "Shut down again";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = "/run/current-system/sw/bin/systemctl poweroff --when=+10s";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Don't warn about stateVersion.
|
||||||
|
system.stateVersion = "24.05";
|
||||||
|
});
|
||||||
|
|
||||||
in
|
in
|
||||||
depot.nix.readTree.drvTargets
|
depot.nix.readTree.drvTargets
|
||||||
{
|
{
|
||||||
|
@ -101,4 +127,12 @@ depot.nix.readTree.drvTargets
|
||||||
path = depot.tvix.store;
|
path = depot.tvix.store;
|
||||||
isClosure = true;
|
isClosure = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
closure-nixos = (mkBootTest {
|
||||||
|
blobServiceAddr = "objectstore+file://$PWD/blobs";
|
||||||
|
path = testSystem;
|
||||||
|
isClosure = true;
|
||||||
|
vmCmdline = "init=${testSystem}/init panic=-1"; # reboot immediately on panic
|
||||||
|
assertVMOutput = "Onwards and upwards.";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue