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