nixos/incus: add support for software TPMs

Was previously broken due to a missing runtime dependency.

> Error: Failed to start device "vtpm": Failed to validate environment: Required tool 'swtpm' is missing
This commit is contained in:
Martin Weinelt 2024-04-23 11:55:16 +02:00
parent c6d4afecd0
commit 8541ec6d85
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
2 changed files with 11 additions and 1 deletions

View File

@ -41,6 +41,7 @@ let
qemu-utils
rsync
squashfsTools
swtpm
systemd
thin-provisioning-tools
util-linux

View File

@ -30,6 +30,9 @@ in
memorySize = 1024;
diskSize = 4096;
# Provide a TPM to test vTPM support for guests
tpm.enable = true;
incus.enable = true;
};
networking.nftables.enable = true;
@ -47,8 +50,14 @@ in
with subtest("virtual-machine image can be imported"):
machine.succeed("incus image import ${vm-image-metadata}/*/*.tar.xz ${vm-image-disk}/nixos.qcow2 --alias nixos")
with subtest("virtual-machine can be created"):
machine.succeed("incus create nixos ${instance-name} --vm --config limits.memory=512MB --config security.secureboot=false")
with subtest("virtual tpm can be configured"):
machine.succeed("incus config device add ${instance-name} vtpm tpm path=/dev/tpm0")
with subtest("virtual-machine can be launched and become available"):
machine.succeed("incus launch nixos ${instance-name} --vm --config limits.memory=512MB --config security.secureboot=false")
machine.succeed("incus start ${instance-name}")
with machine.nested("Waiting for instance to start and be usable"):
retry(instance_is_up)