moved files to make more sense and added experimental desktop configuration

This commit is contained in:
Greg Leyda 2022-07-12 16:54:56 -04:00 committed by ISnortPennies
parent 22c5b6f826
commit 50fae0b2eb
38 changed files with 533 additions and 191 deletions

50
modules/vfio.nix Normal file
View file

@ -0,0 +1,50 @@
{
boot = {
kernelParams = [ "amd_iommu=on" ];
boot.kernelModules = [ "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ];
initrd.kernelModules = [ "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ];
extraModprobeConfig = "options vfio-pci ids=10de:228e,10de:2504";
};
virtualisation = {
libvirtd = {
enable = true;
qemu = {
runAsRoot = false;
ovmf = {
enable = true;
package = pkgs.OVMFFull;
};
};
};
};
environment.systemPackages = with pkgs; [ virt-manager ];
systemd.services.libvirtd.preStart = let
qemuHook = pkgs.writeScript "qemu-hook" ''
#!${pkgs.stdenv.shell}
GUEST_NAME="$1"
OPERATION="$2"
SUB_OPERATION="$3"
if [ "$GUEST_NAME" == "Main_VM" ]; then
if [ "$OPERATION" == "start" ]; then
systemctl set-property --runtime -- user.slice AllowedCPUs=0,1,2,6,7,8
systemctl set-property --runtime -- system.slice AllowedCPUs=0,1,2,6,7,8
systemctl set-property --runtime -- init.scope AllowedCPUs=0,1,2,6,7,8
fi
if [ "$OPERATION" == "stopped" ]; then
systemctl set-property --runtime -- user.slice AllowedCPUs=0-11
systemctl set-property --runtime -- system.slice AllowedCPUs=0-11
systemctl set-property --runtime -- init.scope AllowedCPUs=0-11
fi
fi
'';
in ''
mkdir -p /var/lib/libvirt/hooks
chmod 755 /var/lib/libvirt/hooks
# Copy hook files
ln -sf ${qemuHook} /var/lib/libvirt/hooks/qemu
'';
}