1 import ../make-test-python.nix (
6 incus ? pkgs.incus-lts,
11 releases = import ../../release.nix { configuration.documentation.enable = lib.mkForce false; };
13 container-image-metadata = releases.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system};
14 container-image-rootfs = releases.lxdContainerImage.${pkgs.stdenv.hostPlatform.system};
17 name = "lxd-to-incus";
20 maintainers = lib.teams.lxc.members;
35 name = "nixostestbr0";
38 "ipv4.address" = "10.0.100.1/24";
49 network = "nixostestbr0";
54 pool = "nixostest_pool";
61 name = "nixos_notdefault";
67 name = "nixostest_pool";
78 networking.nftables.enable = true;
82 def lxd_wait_for_preseed(_) -> bool:
83 _, output = machine.systemctl("is-active lxd-preseed.service")
84 return ("inactive" in output)
86 def lxd_instance_is_up(_) -> bool:
87 status, _ = machine.execute("lxc exec container --disable-stdin --force-interactive /run/current-system/sw/bin/systemctl -- is-system-running")
90 def incus_instance_is_up(_) -> bool:
91 status, _ = machine.execute("incus exec container --disable-stdin --force-interactive /run/current-system/sw/bin/systemctl -- is-system-running")
94 with machine.nested("initialize lxd and resources"):
95 machine.wait_for_unit("sockets.target")
96 machine.wait_for_unit("lxd.service")
97 retry(lxd_wait_for_preseed)
99 machine.succeed("lxc image import ${container-image-metadata}/*/*.tar.xz ${container-image-rootfs}/*/*.tar.xz --alias nixos")
100 machine.succeed("lxc launch nixos container")
101 retry(lxd_instance_is_up)
103 machine.wait_for_unit("incus.service")
105 with machine.nested("run migration"):
106 machine.succeed("${pkgs.incus}/bin/lxd-to-incus --yes")
108 with machine.nested("verify resources migrated to incus"):
109 machine.succeed("incus config show container")
110 retry(incus_instance_is_up)
111 machine.succeed("incus exec container -- true")
112 machine.succeed("incus profile show default | grep nixostestbr0")
113 machine.succeed("incus profile show default | grep nixostest_pool")
114 machine.succeed("incus profile show nixos_notdefault")
115 machine.succeed("incus storage show nixostest_pool")
116 machine.succeed("incus network show nixostestbr0")