oizys/hosts/othalan/virt/default.nix

71 lines
1.5 KiB
Nix
Raw Normal View History

2024-12-12 14:13:29 -06:00
{
inputs,
pkgs,
flake,
enabled,
...
}:
let
inherit (inputs) NixVirt;
defaultNetwork = {
definition = NixVirt.lib.network.writeXML (
NixVirt.lib.network.templates.bridge {
uuid = "e7955c23-8750-4405-ab2c-37aeee441f67";
subnet_byte = 24;
}
);
};
2024-12-19 11:24:24 -06:00
win-desktop = pkgs.stdenvNoCC.mkDerivation rec {
name = "win10vm";
unpackPhase = "true";
version = "unstable";
windows10Logo = pkgs.fetchurl {
url = "https://upload.wikimedia.org/wikipedia/commons/c/c7/Windows_logo_-_2012.png";
hash = "sha256-uVNgGUo0NZN+mUmvMzyk0HKnhx64uqT4YWGSdeBz3T4=";
};
desktopItem = pkgs.makeDesktopItem {
name = "win10vm";
exec = "VBoxManage startvm win10";
icon = "${windows10Logo}";
desktopName = "Windows 10 VM";
};
installPhase = ''
install -Dm0644 {${desktopItem},$out}/share/applications/win10vm.desktop
'';
};
2024-12-12 14:13:29 -06:00
in
{
imports = [
(flake.module "NixVirt")
];
programs.virt-manager = enabled;
virtualisation = {
libvirt = enabled // {
swtpm = enabled;
connections."qemu:///system" = {
networks = [ defaultNetwork ];
domains = [
{ definition = ./win11.xml; }
];
};
};
libvirtd.qemu = {
# ovmf.packages = [ pkgs.OVMFFull.fd ];
vhostUserPackages = [ pkgs.virtiofsd ];
};
# Enable USB redirection (optional)
spiceUSBRedirection = enabled;
};
users.users.daylin = {
extraGroups = [ "libvirtd" ];
};
2024-12-19 11:24:24 -06:00
environment.systemPackages = [ win-desktop ];
2024-12-12 14:13:29 -06:00
}