1import ../make-test-python.nix ({ pkgs, lib, ... } :
2
3{
4 name = "lxd-preseed";
5
6 meta = {
7 maintainers = with lib.maintainers; [ adamcstephens ];
8 };
9
10 nodes.machine = { lib, ... }: {
11 virtualisation = {
12 diskSize = 4096;
13
14 lxc.lxcfs.enable = true;
15 lxd.enable = true;
16
17 lxd.preseed = {
18 networks = [
19 {
20 name = "nixostestbr0";
21 type = "bridge";
22 config = {
23 "ipv4.address" = "10.0.100.1/24";
24 "ipv4.nat" = "true";
25 };
26 }
27 ];
28 profiles = [
29 {
30 name = "nixostest_default";
31 devices = {
32 eth0 = {
33 name = "eth0";
34 network = "nixostestbr0";
35 type = "nic";
36 };
37 root = {
38 path = "/";
39 pool = "default";
40 size = "35GiB";
41 type = "disk";
42 };
43 };
44 }
45 ];
46 storage_pools = [
47 {
48 name = "nixostest_pool";
49 driver = "dir";
50 }
51 ];
52 };
53 };
54 };
55
56 testScript = ''
57 def wait_for_preseed(_) -> bool:
58 _, output = machine.systemctl("is-active lxd-preseed.service")
59 return ("inactive" in output)
60
61 machine.wait_for_unit("sockets.target")
62 machine.wait_for_unit("lxd.service")
63 with machine.nested("Waiting for preseed to complete"):
64 retry(wait_for_preseed)
65
66 with subtest("Verify preseed resources created"):
67 machine.succeed("lxc profile show nixostest_default")
68 machine.succeed("lxc network info nixostestbr0")
69 machine.succeed("lxc storage show nixostest_pool")
70 '';
71})