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