gpu
This commit is contained in:
parent
e912a53b71
commit
13136326ee
|
@ -3,7 +3,7 @@
|
|||
./fonts
|
||||
./yazi
|
||||
./sound
|
||||
./vm
|
||||
# ./vm
|
||||
./retro
|
||||
./packages
|
||||
./misc
|
||||
|
|
54
modules/gpu/default.nix
Normal file
54
modules/gpu/default.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{ pkgs, config, ... }:
|
||||
let
|
||||
# Change this to your username.
|
||||
user = "joy";
|
||||
# Change this to match your system's CPU.
|
||||
platform = "amd";
|
||||
# Change this to specify the IOMMU ids you wrote down earlier.
|
||||
vfioIds = [ "10de:249c" "10de:228b" ];
|
||||
in {
|
||||
# Configure kernel options to make sure IOMMU & KVM support is on.
|
||||
boot = {
|
||||
kernelModules = [ "kvm-${platform}" "vfio_virqfd" "vfio_pci" "vfio_iommu_type1" "vfio" ];
|
||||
kernelParams = [ "${platform}_iommu=on" "${platform}_iommu=pt" "kvm.ignore_msrs=1" ];
|
||||
extraModprobeConfig = "options vfio-pci ids=${builtins.concatStringsSep "," vfioIds}";
|
||||
};
|
||||
|
||||
# Add a file for looking-glass to use later. This will allow for viewing the guest VM's screen in a
|
||||
# performant way.
|
||||
systemd.tmpfiles.rules = [
|
||||
"f /dev/shm/looking-glass 0660 ${user} qemu-libvirtd -"
|
||||
];
|
||||
|
||||
# Add virt-manager and looking-glass to use later.
|
||||
environment.systemPackages = with pkgs; [
|
||||
virt-manager
|
||||
looking-glass-client
|
||||
];
|
||||
|
||||
# Enable virtualisation programs. These will be used by virt-manager to run your VM.
|
||||
virtualisation = {
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
user="${user}"
|
||||
'';
|
||||
|
||||
# Don't start any VMs automatically on boot.
|
||||
onBoot = "ignore";
|
||||
# Stop all running VMs on shutdown.
|
||||
onShutdown = "shutdown";
|
||||
|
||||
qemu = {
|
||||
package = pkgs.qemu_kvm;
|
||||
ovmf = enabled;
|
||||
verbatimConfig = ''
|
||||
namespaces = []
|
||||
user = "+${builtins.toString config.users.users.${user}.uid}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
users.users.${user}.extraGroups = [ "qemu-libvirtd" "libvirtd" "disk" ];
|
||||
}
|
|
@ -57,6 +57,7 @@
|
|||
gnome.gnome-calculator
|
||||
gnome.gnome-disk-utility
|
||||
#random utils
|
||||
pciutils
|
||||
cliphist
|
||||
wl-clipboard
|
||||
git
|
||||
|
|
Loading…
Reference in a new issue