From 62acac7285af37c861e0e66f77df88a249235b96 Mon Sep 17 00:00:00 2001 From: Kabbone Date: Thu, 2 May 2024 09:56:41 +0200 Subject: [PATCH] virtualisation: restructure kvm module options and enable libvirt by default --- hosts/desktop/default.nix | 9 ++++----- hosts/kabtop/default.nix | 1 + hosts/laptop/default.nix | 1 + hosts/nasbackup/default.nix | 2 +- hosts/steamdeck/default.nix | 11 ++++++----- modules/desktop/virtualisation/default.nix | 2 +- modules/desktop/virtualisation/kvm-amd.nix | 12 ++++++++++++ modules/desktop/virtualisation/kvm-intel.nix | 13 +++++++++++++ modules/desktop/virtualisation/qemu.nix | 6 ------ 9 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 modules/desktop/virtualisation/kvm-amd.nix create mode 100644 modules/desktop/virtualisation/kvm-intel.nix diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 661d96e..03d0384 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -22,11 +22,10 @@ { imports = # For now, if applying to other system, swap files [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix - #[(import ../../modules/desktop/hyprland/default.nix)] ++ # Window Manager - [(import ../../modules/desktop/sway/default.nix)] ++ # Window Manager - #[(import ../../modules/editors/nvim/config/default.nix)] ++ # Window Manager - (import ../../modules/desktop/virtualisation) ++ # Docker - (import ../../modules/hardware); # Hardware devices + [(import ../../modules/desktop/sway/default.nix)] ++ # Window Manager + (import ../../modules/desktop/virtualisation) ++ # libvirt + Docker + [(import ../../modules/desktop/virtualisation/kvm-amd)] ++ # kvm module options + (import ../../modules/hardware); # Hardware devices boot = { # Boot options kernelPackages = pkgs.linuxPackages_latest; diff --git a/hosts/kabtop/default.nix b/hosts/kabtop/default.nix index a5c273c..e61a0e0 100644 --- a/hosts/kabtop/default.nix +++ b/hosts/kabtop/default.nix @@ -23,6 +23,7 @@ imports = # For now, if applying to other system, swap files [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix [(import ../../modules/desktop/virtualisation/docker.nix)] ++ # Docker + [(import ../../modules/desktop/virtualisation/kvm-amd.nix)] ++ # kvm module options (import ../../modules/services/server) ++ # Server Services (import ../../modules/hardware); # Hardware devices diff --git a/hosts/laptop/default.nix b/hosts/laptop/default.nix index 8520999..06ac488 100644 --- a/hosts/laptop/default.nix +++ b/hosts/laptop/default.nix @@ -25,6 +25,7 @@ #[(import ../../modules/desktop/hyprland/default.nix)] ++ # Window Manager [(import ../../modules/desktop/sway/default.nix)] ++ # Window Manager [(import ../../modules/desktop/virtualisation/docker.nix)] ++ # Docker + [(import ../../modules/desktop/virtualisation/kvm-intel.nix)] ++ # kvm module options (import ../../modules/hardware); # Hardware devices boot = { # Boot options diff --git a/hosts/nasbackup/default.nix b/hosts/nasbackup/default.nix index 03df733..9705814 100644 --- a/hosts/nasbackup/default.nix +++ b/hosts/nasbackup/default.nix @@ -22,7 +22,7 @@ { imports = # For now, if applying to other system, swap files [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix - (import ../../modules/desktop/virtualisation) ++ # Docker + #[(import ../../modules/desktop/virtualisation/docker.nix)] ++ # Docker (import ../../modules/services/nasbackup) ++ # Server Services (import ../../modules/hardware); # Hardware devices diff --git a/hosts/steamdeck/default.nix b/hosts/steamdeck/default.nix index 198c841..e3d1d4d 100644 --- a/hosts/steamdeck/default.nix +++ b/hosts/steamdeck/default.nix @@ -22,10 +22,11 @@ { imports = # For now, if applying to other system, swap files [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix - [(import ../../modules/desktop/steam/default.nix)] ++ # Window Manager - [(import ../../modules/desktop/kde/default.nix)] ++ # Window Manager - [(import ../../modules/desktop/virtualisation/docker.nix)] ++ # Docker - (import ../../modules/hardware); # Hardware devices + [(import ../../modules/desktop/steam/default.nix)] ++ # jovian steam + [(import ../../modules/desktop/kde/default.nix)] ++ # Window Manager + (import ../../modules/desktop/virtualisation) ++ # libvirt + Docker + [(import ../../modules/desktop/virtualisation/kvm-amd.nix)] ++ # kvm module options + (import ../../modules/hardware); # Hardware devices boot = { # Boot options loader = { # EFI Boot @@ -87,5 +88,5 @@ tailscale.enable = true; }; - security.pam.enableSSHAgentAuth = true; + security.pam.sshAgentAuth.enable = true; } diff --git a/modules/desktop/virtualisation/default.nix b/modules/desktop/virtualisation/default.nix index 6ccd3d4..ba19133 100644 --- a/modules/desktop/virtualisation/default.nix +++ b/modules/desktop/virtualisation/default.nix @@ -13,5 +13,5 @@ [ ./docker.nix -# ./qemu.nix + ./qemu.nix ] diff --git a/modules/desktop/virtualisation/kvm-amd.nix b/modules/desktop/virtualisation/kvm-amd.nix new file mode 100644 index 0000000..adecc5d --- /dev/null +++ b/modules/desktop/virtualisation/kvm-amd.nix @@ -0,0 +1,12 @@ +# +# KVM module options amd +# + +{ config, pkgs, user, ... }: + +{ # Add libvirtd and kvm to userGroups + boot.extraModprobeConfig = '' + options kvm_amd nested=0 avic=1 npt=1 + ''; # Needed to run OSX-KVM +} + diff --git a/modules/desktop/virtualisation/kvm-intel.nix b/modules/desktop/virtualisation/kvm-intel.nix new file mode 100644 index 0000000..e4f2607 --- /dev/null +++ b/modules/desktop/virtualisation/kvm-intel.nix @@ -0,0 +1,13 @@ +# +# KVM module options intel +# + +{ config, pkgs, user, ... }: + +{ # Add libvirtd and kvm to userGroups + boot.extraModprobeConfig = '' + options kvm_intel nested=1 + options kvm_intel emulate_invalid_guest_state=0 + options kvm ignore_nsrs=1 + ''; # Needed to run OSX-KVM +} diff --git a/modules/desktop/virtualisation/qemu.nix b/modules/desktop/virtualisation/qemu.nix index 1e4f94a..e9a25e3 100644 --- a/modules/desktop/virtualisation/qemu.nix +++ b/modules/desktop/virtualisation/qemu.nix @@ -5,12 +5,6 @@ { config, pkgs, user, ... }: { # Add libvirtd and kvm to userGroups - boot.extraModprobeConfig = '' - options kvm_intel nested=1 - options kvm_intel emulate_invalid_guest_state=0 - options kvm ignore_nsrs=1 - ''; # Needed to run OSX-KVM - users.groups.libvirtd.members = [ "root" "${user}" ]; virtualisation = {