1 import ./make-test-python.nix ({ pkgs, ... }: {
3 meta.maintainers = with pkgs.lib.maintainers; [ fpletz ];
13 libvirtd.enable = true;
15 boot.supportedFilesystems = [ "zfs" ];
16 networking.hostId = "deadbeef"; # needed for zfs
17 networking.nameservers = [ "192.168.122.1" ];
18 security.polkit.enable = true;
19 environment.systemPackages = with pkgs; [ virt-manager ];
24 nixosInstallISO = (import ../release.nix {}).iso_minimal.${pkgs.hostPlatform.system};
25 virshShutdownCmd = if pkgs.stdenv.isx86_64 then "shutdown" else "destroy";
29 virthost.wait_for_unit("sockets.target")
31 with subtest("enable default network"):
32 virthost.succeed("virsh net-start default")
33 virthost.succeed("virsh net-autostart default")
34 virthost.succeed("virsh net-info default")
36 with subtest("check if partition disk pools works with parted"):
37 virthost.succeed("fallocate -l100m /tmp/foo; losetup /dev/loop0 /tmp/foo; echo 'label: dos' | sfdisk /dev/loop0")
38 virthost.succeed("virsh pool-create-as foo disk --source-dev /dev/loop0 --target /dev")
39 virthost.succeed("virsh vol-create-as foo loop0p1 25MB")
40 virthost.succeed("virsh vol-create-as foo loop0p2 50MB")
42 with subtest("check if virsh zfs pools work"):
43 virthost.succeed("fallocate -l100m /tmp/zfs; losetup /dev/loop1 /tmp/zfs;")
44 virthost.succeed("zpool create zfs_loop /dev/loop1")
45 virthost.succeed("virsh pool-define-as --name zfs_storagepool --source-name zfs_loop --type zfs")
46 virthost.succeed("virsh pool-start zfs_storagepool")
47 virthost.succeed("virsh vol-create-as zfs_storagepool disk1 25MB")
49 with subtest("check if nixos install iso boots and network works"):
51 "virt-install -n nixos --osinfo=nixos-unstable --ram=1024 --graphics=none --disk=`find ${nixosInstallISO}/iso -type f | head -n1`,readonly=on --import --noautoconsole"
53 virthost.succeed("virsh domstate nixos | grep running")
54 virthost.wait_until_succeeds("ping -c 1 nixos")
55 virthost.succeed("virsh ${virshShutdownCmd} nixos")
56 virthost.wait_until_succeeds("virsh domstate nixos | grep 'shut off'")