Start of GPU passthrough plan

This commit is contained in:
Nathan McCarty 2022-10-09 21:43:38 -04:00
parent bf3c4fca2d
commit f76c3e17a7
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
4 changed files with 85 additions and 51 deletions

View File

@ -33,6 +33,9 @@
sshKey = config.sops.secrets."borg-ssh-key".path;
};
};
hardware = {
amdPassthrough = true;
};
config = {
isDesktop = true;
setupGrub = true;

View File

@ -102,6 +102,8 @@ in
# Logitech hardware support
# On by default if the system is a desktop
logitech = mkDefaultOption "logitech" config.nathan.config.isDesktop;
# AMD Single gpu passthrough
amdPassthrough = mkEnableOption "logitech";
};
# Linux specific configuration
config = {

View File

@ -4,10 +4,34 @@ let
in
with lib;
{
config = {
config = mkMerge [
{
hardware.logitech.wireless = mkIf nw.logitech {
enable = true;
enableGraphical = true;
};
};
}
(mkIf nw.amdPassthrough {
# Turn on IOMMU and the needed drivers
boot = {
kernelParams = [ "amd_iommu=on" ];
kernelModules = [ "kvm-amd" "vifo-pci" ];
};
# Enable libvirtd
virtualisation.libvirtd = {
enable = true;
onBoot = "ignore";
onShutdown = "shutdown";
qemu = {
ovmf = {
enable = true;
package = pkgs.OVMFFull;
runAsRoot = true;
};
swtpm.enable = true;
};
};
})
];
}

View File

@ -3,7 +3,8 @@ let
nc = config.nathan.config;
in
with lib; {
config = {
config = mkMerge [
{
users = {
# If we install the user and the system is hardended, then disable mutable users
mutableUsers = !(nc.installUser && nc.harden);
@ -48,5 +49,9 @@ with lib; {
] else [ ];
# Configure the timezone
time.timeZone = "America/New_York";
};
}
(mkIf config.nathan.config.hardware.amdPassthrough {
users.users."${nc.user}".extraGroups = [ "libvirtd" ];
})
];
}