BUG: Infinit checking NixOS configuration
Svenum opened this issue · comments
Sven Ziegler commented
If I import a domain like this definition = nixvirt.lib.domain.writeXML (import ./kvm/win10gpu.nix {inherit disk_path; inherit nvram_path; inherit pkgs;});
the config gets checked forever.
Even if I add the content form win10gpu.nix directly in config.nix its loading and loading.
win10gpu.nix
{ disk_path, nvram_path, pkgs }:
{
# VM Infos
name = "Windows GPU Nix";
uuid = "c08333dc-33f9-4117-969a-ac46e19ba81f";
description = "A Windows VM with GPU passthrough and looking-glass";
# CPU and RAM
vcpu = { count = 12; placement = "static"; };
memory = { count = 24; unit = "GiB"; };
cpu = {
mode = "host-passthrough";
check = "none";
migratable = true;
topology = {
sockets = 1;
dies = 1;
cores = 6;
threads = 2;
};
};
# OS
os = {
type = "hvm";
arch = "x86_64";
machine = "pc-q35-8.2";
boot = { dev = "hd"; };
loader = {
readonly = true;
type = "pflash";
path = "${pkgs.OVMFFull.fd}/FV/OVMF_CODE.ms.fd";
};
nvram = {
template = "${pkgs.OVMFFull.fd}/FV/OVMF_VARS.ms.fd";
path = "${nvram_path}/win10gpu.nvram";
};
};
features = {
acpi = {};
apic = {};
hyperv = {
mode = "custom";
relaxed = { state = true; };
vapic = { state = true; };
spinlocks = { state = true; retries = 8191; };
vendor_id = { state = true; value = "1234567890ab"; };
};
kvm.hidden = { state = true; };
vmport.state = false;
};
clock = {
offset = "localtime";
timer = [
{ name = "rtc"; tickpolicy = "catchup"; }
{ name = "pit"; tickpolicy = "delay"; }
{ name = "hpet"; present = false; }
{ name = "hypervclock"; present = true; }
];
};
# PowerManagement
# MISSING
# <on_poweroff>destroy</on_poweroff>
# <on_reboot>restart</on_reboot>
# <on_crash>destroy</on_crash>
pm = {
suspend-to-mem = { enabled = false; };
suspend-to-disk = { enabled = false; };
};
# Devices
devices = {
emulator = "${pkgs.qemu}/bin/qemu-system-x86_64";
# Disks
disk = [
{
type = "file";
device = "disk";
driver = {
name = "qemu";
type = "qcow2";
discard = "unmap";
};
source.file = "${disk_path}/win10gpu.qcow2";
target = { dev = "sda"; bus = "sata"; };
}
];
# Network
interface = {
type = "network";
mac.address = "52:54:00:04:63:98";
source.network = "default";
model.type = "e1000e";
};
# Input
input = [
{ type = "keyboard"; bus = "virtio"; }
{ type = "mouse"; bus = "virtio"; }
];
# Video + Audio
graphics = {
type = "spice";
autoport = true;
listen = { type = "address"; };
image = { compression = false; };
};
video = {
model = {
type = "vga";
vram = 65536;
heads = 1;
primary = true;
};
};
sound = { model = "ich9"; };
audio = { id = 1; type = "spice"; };
# Interfaces
controller = [
{ type = "usb"; index = 0; model = "qemu-xhci"; ports = 15; }
{ type = "pci"; index = 0; model = "pcie-root"; }
{ type = "virtio-serial"; index = 0; }
];
serial = [
{
type = "pty";
target = { type = "isa-serial"; port = 0; model.name = "isa-serial"; };
}
];
console = [
{
type = "pty";
target = { type = "serial"; port = 0; };
}
];
channel = [
{
type = "spicevmc";
target = { type = "virtio"; name = "com.redhat.spice.0"; };
}
];
# Other
watchdog = { model = "itco"; action = "reset"; };
memballoon.model = "none";
#shmem = [
# {
# name = "looking-glass-sven";
# model.type = "ivshmem-plain";
# size = { unit = "M"; count = 128; };
# }
#];
#hostdev = [
# {
# mode = "subsystem";
# type = "pci";
# managed = true;
# source.address = {
# domain = "0x0000";
# bus = "0x03";
# slot = "0x00";
# function = "0x0";
# };
# }
# {
# mode = "subsystem";
# type = "pci";
# managed = true;
# source.address = {
# domain = "0x0000";
# bus = "0x03";
# slot = "0x00";
# function = "0x1";
# };
# }
#];
# MISSING
# <shmem name="looking-glass-sven">
# <model type="ivshmem-plain"/>
# <size unit="M">128</size>
# </shmem>
#
# <hostdev mode="subsystem" type="pci" managed="yes">
# <source>
# <address domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
# </source>
# <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
# </hostdev>
# <hostdev mode="subsystem" type="pci" managed="yes">
# <source>
# <address domain="0x0000" bus="0x03" slot="0x00" function="0x1"/>
# </source>
# <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
# </hostdev>
};
qemu-commandline = {
arg = [
{ value = "-cpu"; }
{ value = "host,kvm=off,hv_vendor_id=null"; }
{ value = "-machine"; }
{ value = "q35"; }
];
};
}
config.nix
{ lib, systemConfig, nixvirt, pkgs, ... }:
let
nvram_path = /home/sven/.local/share/libvirt/qemu;
disk_path = /home/sven/.local/share/libvirt/images;
win10gpu_config = import ./kvm/win10gpu.nix {inherit disk_path; inherit nvram_path; inherit pkgs;};
in
{
# Enable virtualisation
virtualisation.libvirt.swtpm.enable = true;
virtualisation.libvirt.enable = true;
virtualisation.libvirt.connections."qemu:///system" = {
# Add pools
pools = [
{
definition = nixvirt.lib.pool.writeXML {
name = "default";
uuid = "689ba4f2-da57-43e4-9723-a0551e871c8a";
type = "dir";
target = {
path = "/var/lib/libvirt/images";
};
};
path = "/var/lib/libvirt/images";
}
{
definition = nixvirt.lib.pool.writeXML {
name = "images";
uuid = "464a4f52-bbf4-479e-9b2b-ed27116aab7b";
type = "dir";
target = {
path = "${disk_path}";
};
};
volumes = [
{
definition = nixvirt.lib.volume.writeXML {
name = "win10gpu.qcow2";
capacity = { count = 250; unit = "GiB"; };
target = {
format = { type = "qcow2"; };
};
};
}
];
active = true;
}
{
definition = nixvirt.lib.pool.writeXML {
name = "isos";
uuid = "5217ddb8-29c2-4a4d-b976-73b9dde59e43";
type = "dir";
target = {
path = "/home/sven/.local/share/libvirt/isos";
};
};
active = true;
}
];
# Add windows Domain
domains = lib.mkIf (systemConfig.networking.hostName == "Shi") [
{ definition = nixvirt.lib.domain.writeXML win10gpu_config; }
{ definition = ./kvm/win10gpu.xml; }
{ definition = ./kvm/win10.xml; }
];
};
}
Sven Ziegler commented
Found the issue. It was the import on the large qcow2 file.