tweaking vm options

This commit is contained in:
serenity-F 2026-04-19 22:47:26 +10:00
parent 768340f8e3
commit 0cd9d9ea95
No known key found for this signature in database

View file

@ -1,46 +1,52 @@
{ user, pkgs, ... }: { user, pkgs, ... }:
let let
# Name of the group needed to use VirtualBox #sharePublicSourceDirectory = "/home/${user}/Public/"; # it's named public right
vmgroup = "vmusers"; #sharePublicTargetDirectory = "F:"; # for windows
in { in {
# Permissions configuration # Security
users = { #users.groups = { # creates grouped virtualisation permissions
# Gives users virtualisation permissions #kvm.members = [ "${user}" "${anotherUser}" ];
groups.kvm.members = [ "${user}" ]; #libvirtd.members = [ "${user}" "${anotherUser}" ];
groups.libvirtd.members = [ "${user}" ]; #};
extraGroups."${vmgroup}".members = [ "${user}" ]; users.users."${user}" = { # Gives primary user virtualisation permissions
users."${user}".extraGroups = [ "${vmgroup}" ]; extraGroups = [ "libvirtd" "kvm" ];
}; };
networking.firewall.trustedInterfaces = [ "virbr0" ]; # network bridge to VM
# https://wiki.nixos.org/wiki/Virt-manager#Networking
# Inactive by default, enable in host by running:
# `sudo virsh net-start default`
# Enable it automatically it at boot by running:
# `sudo virsh net-autostart default`
# Virtualisation packages # virtualisation
programs.virt-manager.enable = true; # simple vm frontend
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
gnome-boxes # VM frontend dnsmasq # for vm networking
dnsmasq # Vm networking #phodav # for vm fileshare
phodav # Fileshare with guest VMs
]; ];
# Virtualisation configuration
virtualisation = { virtualisation = {
# Base virtualisation set up #cores = 4; # fine for now
libvirtd.enable = true; graphics = true; # run qemu in gui or no gui mode
# TPM emulation for Win11 spiceUSBRedirection.enable = true; # for USB passthrough
libvirtd.qemu = { libvirtd = {
swtpm.enable = true; enable = true;
}; qemu = {
# Enables USB passthrough vhostUserPackages = with pkgs; [ virtiofsd ]; # host fileshare
spiceUSBRedirection.enable = true; swtpm.enable = true; # tpm emulation for windows 11
# VirtualBox configuration runAsRoot = true; # for `passthrough` security on fileshare
virtualbox = { };
# Enables VirtualBox with this machine as the host
#host.enable = false;
# Increases security when using VirtualBox
#host.enableHardening = true;
# Needed for USB2 and USB3 passthrough
#host.enableExtensionPack = true;
}; };
#sharedDirectories = { # list of directories to share to VMs
#Public = { # ~/Public
#securityModel = "passthrough";
#source = "${sharePublicSourceDirectory}";
#target = "${sharePublicTargetDirectory}";
#};
#};
}; };
} }