2023-07-01 17:41:02 -04:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
gpuIDs = [
|
|
|
|
# 2080 super
|
|
|
|
"10de:1e81" # Graphics
|
|
|
|
"10de:10f8" # Audio
|
|
|
|
"10de:1ad8" # Usb ????
|
|
|
|
"10de:1ad9" # Usb ????
|
|
|
|
];
|
|
|
|
in {
|
2023-07-03 23:42:15 -04:00
|
|
|
##
|
|
|
|
## Packages
|
|
|
|
##
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
# Looking glass, avoids the need for another monitor
|
|
|
|
looking-glass-client
|
|
|
|
# For samba
|
|
|
|
cifs-utils
|
|
|
|
];
|
2023-07-03 21:14:35 -04:00
|
|
|
##
|
|
|
|
## Kernel configuration
|
|
|
|
##
|
2023-07-01 17:41:02 -04:00
|
|
|
boot = {
|
|
|
|
kernelParams = [
|
|
|
|
# enable iommu
|
|
|
|
"amd_iommu=on"
|
|
|
|
# Isolate the nvidia gpu
|
|
|
|
("vfio-pci.ids=" + lib.concatStringsSep "," gpuIDs)
|
|
|
|
];
|
|
|
|
# Modules needed
|
|
|
|
initrd.kernelModules = [ "vfio_pci" "vfio" "vfio_iommu_type1" ];
|
|
|
|
};
|
|
|
|
|
2023-07-03 21:14:35 -04:00
|
|
|
##
|
|
|
|
## Virtualization setup
|
|
|
|
##
|
2023-07-01 17:41:02 -04:00
|
|
|
virtualisation.spiceUSBRedirection.enable = true;
|
|
|
|
virtualisation.libvirtd = {
|
|
|
|
qemu = {
|
2023-07-03 21:14:35 -04:00
|
|
|
# Enable tpm for windows 11
|
2023-07-01 17:41:02 -04:00
|
|
|
swtpm.enable = true;
|
|
|
|
ovmf = {
|
|
|
|
enable = true;
|
2023-07-03 21:14:35 -04:00
|
|
|
# Needed for secure boot
|
2023-07-01 17:41:02 -04:00
|
|
|
packages = [ pkgs.OVMFFull.fd ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-07-03 21:14:35 -04:00
|
|
|
# Looking glass shared memory
|
2023-07-01 17:41:02 -04:00
|
|
|
systemd.tmpfiles.rules =
|
|
|
|
[ "f /dev/shm/looking-glass 0660 nathan qemu-libvirtd -" ];
|
2023-07-03 21:14:21 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
## Networking
|
|
|
|
##
|
2023-07-03 20:16:37 -04:00
|
|
|
# Setup bridge
|
|
|
|
networking.bridges = { "qemu-br0" = { interfaces = [ "enp6s0" ]; }; };
|
2023-07-03 21:14:21 -04:00
|
|
|
networking.interfaces.qemu-br0 = {
|
|
|
|
ipv4.addresses = [{
|
|
|
|
address = "10.0.0.247";
|
|
|
|
prefixLength = 21;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
networking.defaultGateway = "10.0.4.1";
|
|
|
|
networking.nameservers = [ "10.0.0.10" ];
|
2023-07-03 23:42:15 -04:00
|
|
|
|
|
|
|
##
|
|
|
|
## Samba share
|
|
|
|
##
|
|
|
|
services.samba = {
|
|
|
|
enable = true;
|
|
|
|
openFirewall = true;
|
|
|
|
extraConfig = ''
|
|
|
|
browseable = yes
|
|
|
|
smb encrypt = required
|
|
|
|
'';
|
|
|
|
shares = {
|
|
|
|
# You will still need to set up the user accounts to begin with:
|
|
|
|
# $ sudo smbpasswd -a yourusername
|
|
|
|
homes = {
|
|
|
|
browseable = "no";
|
|
|
|
"read only" = "no";
|
|
|
|
"guest ok" = "no";
|
|
|
|
};
|
2023-07-08 13:08:25 -04:00
|
|
|
Shared = {
|
|
|
|
path = "/home/nathan/Shared";
|
|
|
|
browesable = "yes";
|
|
|
|
"read only" = "no";
|
|
|
|
"guest ok" = "no";
|
|
|
|
"writable" = "yes";
|
|
|
|
};
|
2023-07-03 23:42:15 -04:00
|
|
|
};
|
|
|
|
};
|
2023-07-01 17:41:02 -04:00
|
|
|
}
|