1 import ../make-test-python.nix ({ pkgs, lib, ... }:
4 releases = import ../../release.nix {
6 # Building documentation makes the test unnecessarily take a longer time:
7 documentation.enable = lib.mkForce false;
9 # Our tests require `grep` & friends:
10 environment.systemPackages = with pkgs; [busybox];
14 lxd-image-metadata = releases.lxdVirtualMachineImageMeta.${pkgs.stdenv.hostPlatform.system};
15 lxd-image-disk = releases.lxdVirtualMachineImage.${pkgs.stdenv.hostPlatform.system};
17 instance-name = "instance1";
19 name = "lxd-virtual-machine";
21 nodes.machine = {lib, ...}: {
27 # Ensure we have enough memory for the nested virtual machine
30 lxc.lxcfs.enable = true;
36 def instance_is_up(_) -> bool:
37 status, _ = machine.execute("lxc exec ${instance-name} --disable-stdin --force-interactive /run/current-system/sw/bin/true")
40 machine.wait_for_unit("sockets.target")
41 machine.wait_for_unit("lxd.service")
42 machine.wait_for_file("/var/lib/lxd/unix.socket")
44 # Wait for lxd to settle
45 machine.succeed("lxd waitready")
47 machine.succeed("lxd init --minimal")
49 with subtest("virtual-machine image can be imported"):
50 machine.succeed("lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-disk}/nixos.qcow2 --alias nixos")
52 with subtest("virtual-machine can be launched and become available"):
53 machine.succeed("lxc launch nixos ${instance-name} --vm --config limits.memory=512MB --config security.secureboot=false")
54 with machine.nested("Waiting for instance to start and be usable"):
57 with subtest("lxd-agent is started"):
58 machine.succeed("lxc exec ${instance-name} systemctl is-active lxd-agent")