2021-05-30 19:10:28 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
psCfg = config.pub-solar;
|
|
|
|
cfg = config.pub-solar.virtualisation;
|
2021-12-11 20:08:20 +00:00
|
|
|
doesGaming = config.pub-solar.gaming.enable;
|
|
|
|
extraObsPlugins =
|
|
|
|
if doesGaming
|
|
|
|
then [pkgs.obs-studio-plugins.looking-glass-obs]
|
|
|
|
else [];
|
2021-05-30 19:10:28 +00:00
|
|
|
in {
|
|
|
|
options.pub-solar.virtualisation = {
|
|
|
|
enable = mkEnableOption "Life in libvirt";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
boot.kernelParams = [
|
|
|
|
"amd_iommu=on"
|
2022-04-30 13:15:29 +00:00
|
|
|
"intel_iommu=on"
|
2021-05-30 19:10:28 +00:00
|
|
|
"iommu=pt"
|
|
|
|
];
|
|
|
|
|
2022-05-04 17:21:54 +00:00
|
|
|
virtualisation.spiceUSBRedirection.enable = true;
|
|
|
|
|
2021-05-30 19:10:28 +00:00
|
|
|
virtualisation.libvirtd = {
|
|
|
|
enable = true;
|
2022-01-19 00:13:15 +00:00
|
|
|
qemu.ovmf.enable = true;
|
2021-05-30 19:10:28 +00:00
|
|
|
};
|
|
|
|
users.users = pkgs.lib.setAttrByPath [psCfg.user.name] {
|
|
|
|
extraGroups = ["libvirtd"];
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
coreutils-full
|
|
|
|
usbutils
|
|
|
|
libvirt
|
|
|
|
libvirt-glib
|
|
|
|
qemu
|
|
|
|
virt-manager
|
2023-05-17 21:56:46 +00:00
|
|
|
python3Packages.libvirt
|
2021-05-30 19:10:28 +00:00
|
|
|
gvfs
|
|
|
|
edk2
|
|
|
|
OVMF
|
|
|
|
win-virtio
|
2021-12-11 20:08:20 +00:00
|
|
|
looking-glass-client
|
|
|
|
lgcl
|
2021-05-30 19:10:28 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
home-manager = with pkgs;
|
|
|
|
pkgs.lib.setAttrByPath ["users" psCfg.user.name] {
|
|
|
|
xdg.dataFile."libvirt/.keep".text = "# this file is here to generate the directory";
|
2021-12-11 20:08:20 +00:00
|
|
|
home.packages = extraObsPlugins;
|
2021-05-30 19:10:28 +00:00
|
|
|
};
|
|
|
|
|
2021-12-11 20:08:20 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"f /dev/shm/looking-glass 0660 ${psCfg.user.name} kvm"
|
|
|
|
];
|
|
|
|
networking.bridges.virbr1.interfaces = [];
|
|
|
|
networking.interfaces.virbr1 = {
|
|
|
|
ipv4.addresses = [
|
|
|
|
{
|
|
|
|
address = "192.168.123.1";
|
|
|
|
prefixLength = 24;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-05-30 19:10:28 +00:00
|
|
|
};
|
|
|
|
}
|