Add vfio on starlight

This commit is contained in:
Artemis Tosini 2022-02-01 06:59:17 +00:00
parent a0aae6859d
commit e405957978
Signed by: artemist
GPG key ID: ADFFE553DCBB831E
2 changed files with 35 additions and 0 deletions

View file

@ -5,6 +5,7 @@
./boot-config.nix ./boot-config.nix
./hardware-configuration.nix ./hardware-configuration.nix
./scripts.nix ./scripts.nix
./vfio.nix
../../sets/builder.nix ../../sets/builder.nix
../../sets/cpu/amd.nix ../../sets/cpu/amd.nix
../../sets/fpga.nix ../../sets/fpga.nix

34
system/starlight/vfio.nix Normal file
View file

@ -0,0 +1,34 @@
{ pkgs, pkgs-unstable, ... }:
# based on https://alexbakker.me/post/nixos-pci-passthrough-qemu-vfio.html
{
environment.systemPackages = [
pkgs-unstable.looking-glass-client
pkgs.scream
];
boot.initrd = {
availableKernelModules = [ "amdgpu" "vfio-pci" ];
preDeviceCommands = ''
echo vfio-pci > /sys/bus/pci/devices/0000:0b:00.0/driver_override
echo vfio-pci > /sys/bus/pci/devices/0000:0b:00.1/driver_override
modprobe -i vfio-pci
'';
};
systemd.tmpfiles.rules = [
"f /dev/shm/scream 0660 artemis qemu-libvirtd -"
"f /dev/shm/looking-glass 0660 artemis qemu-libvirtd -"
];
systemd.user.services.scream-ivshmem = {
enable = true;
description = "Scream IVSHMEM";
serviceConfig = {
ExecStart = "${pkgs.scream}/bin/scream -m /dev/shm/scream -o pulse";
Restart = "always";
};
wantedBy = [ "multi-user.target" ];
requires = [ "pulseaudio.service" ];
};
}