Skip to content

Commit

Permalink
[VIRT] rename dir + looking-glass + scream
Browse files Browse the repository at this point in the history
  • Loading branch information
Icy-Thought committed Dec 17, 2024
1 parent 9148f0a commit 5331fac
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 58 deletions.
3 changes: 0 additions & 3 deletions hosts/probook-445g6/hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ in {
[ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
kernelModules = [ ];
};
extraModulePackages = [ ];
kernelModules = [ "kvm-amd" ];
kernelParams = [ ];
kernel.sysctl = {
"net.ipv4.icmp_echo_ignore_broadcasts" = 1; # Refuse ICMP echo requests
};
Expand Down
1 change: 0 additions & 1 deletion hosts/thinkpad-e595/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
};
distractions.steam.enable = true;
};
virtualize.enable = true;
};

# KDE-Connect + Start-up indicator
Expand Down
2 changes: 1 addition & 1 deletion hosts/thinkpad-e595/hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ in {
kernelModules = [ ];
};
extraModulePackages = [ config.boot.kernelPackages.acpi_call ];
kernelModules = [ "thinkpad_acpi" "acpi_call" "kvm_amd" ];
kernelModules = [ "thinkpad_acpi" "acpi_call" ];
kernelParams = [ "pcie_aspm.policy=performance" ];
kernel.sysctl = {
"net.ipv4.icmp_echo_ignore_broadcasts" = 1; # Refuse ICMP echo requests
Expand Down
2 changes: 1 addition & 1 deletion modules/desktop/distractions/lutris.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ in {
user.packages = attrValues ({
lutris =
pkgs.lutris.override { extraLibraries = pkgs: [ pkgs.jansson ]; };
} // optionalAttrs (config.modules.virtualize.wine.enable == false) {
} // optionalAttrs (config.modules.virtualisation.wine.enable == false) {
inherit (pkgs) winetricks;
inherit (pkgs.wineWowPackages) fonts stagingFull;
});
Expand Down
4 changes: 2 additions & 2 deletions modules/virtualize/containers/archlinux.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

let inherit (lib.modules) mkIf;
in {
options.modules.virtualize.containers.archlinux =
options.modules.virtualisation.containers.archlinux =
let inherit (lib.options) mkEnableOption;
in { enable = mkEnableOption "arch-linux container"; };

config = mkIf config.modules.virtualize.containers.archlinux.enable {
config = mkIf config.modules.virtualisation.containers.archlinux.enable {
virtualisation.libvirtd = {
enable = true;
qemuVerbatimConfig = ''
Expand Down
4 changes: 2 additions & 2 deletions modules/virtualize/containers/transmission.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

let
inherit (lib.modules) mkIf;
cfg = config.modules.virtualize.containers.transmission;
cfg = config.modules.virtualisation.containers.transmission;
in {
options.modules.virtualize.containers.transmission = let
options.modules.virtualisation.containers.transmission = let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) path str;
in {
Expand Down
42 changes: 0 additions & 42 deletions modules/virtualize/default.nix

This file was deleted.

60 changes: 60 additions & 0 deletions modules/virtualize/kvm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ options, config, lib, pkgs, ... }:

let
inherit (lib.attrsets) attrValues;
inherit (lib.modules) mkIf;
virtCfg = config.modules.virtualisation;
in {
options.modules.virtualisation.kvm = let inherit (lib.options) mkEnableOption;
in {
enable = mkEnableOption "Kernel-based Virutal Machine.";
vendor = lib.types.enum [ "amd" "intel" ] "amd";
};

config = mkIf virtCfg.kvm.enable {
virtCfg.looking-glass.enable = true;

user.packages = attrValues { inherit (pkgs) virt-manager; };

boot = {
kernelModules =
# https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#modprobe.d
[ "kvm-${virtCfg.vendor}" "vfio" "vfio_iommu_type1" "vfio_pci" ];
kernelParams = [
"${virtCfg.vendor}_iommu=on"
"${virtCfg.vendor}_iommu=pt"
"kvm.ignore_msrs=1" # https://pve.proxmox.com/wiki/PCI_Passthrough#Tips
];
extraModprobeConfig = ''
softdep drm pre: vfio vfio-pci
'';
};

virtualisation = {
libvirtd = {
enable = true;
onBoot = "ignore";
onShutdown = "shutdown";
qemu = {
ovmf = true;
swtpm = true;
runAsRoot = false;
};
};
};

user.extraGroups = [ "libvirtd" ];

systemd.user.services.scream-ivshmem = {
after =
[ "libvirtd.service" "pipewire.service" "pipewire-pulse.service" ];
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig = {
Type = "simple";
Restart = "on-failure";
ExecStart = "${lib.getExe pkgs.scream} -m /dev/shm/scream -o pulse";
};
};
};
}
38 changes: 38 additions & 0 deletions modules/virtualize/looking-glass.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{ options, config, lib, pkgs, ... }:

let inherit (lib.modules) mkIf;
in {
options.modules.virtualisation.looking-glass =
let inherit (lib.options) mkEnableOption;
in {
enable =
mkEnableOption "KVM(s) VGA PCI Pass-through without peripherals.";
};

config = mkIf config.modules.virtualisation.looking-glass.enable {

hm.programs.looking-glass-client = {
enable = true;
package = pkgs.unstable.looking-glass-client;
settings = {
app = {
allowDMA = true;
shmFile = "/dev/shm/looking-glass";
};
input = {
rawMouse = true;
escapeKey = "56"; # linux/input-event-codes.h
};
spice = {
enable = true;
audio = true;
};
win = {
autoResize = true;
borderless = true;
quickSplash = true;
};
};
};
};
}
7 changes: 4 additions & 3 deletions modules/virtualize/podman.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ let
inherit (lib.attrsets) attrValues;
inherit (lib.modules) mkIf;
in {
options.modules.virtualize.podman = let inherit (lib.options) mkEnableOption;
in { enable = mkEnableOption "Enable the Podman container engine"; };
options.modules.virtualisation.podman =
let inherit (lib.options) mkEnableOption;
in { enable = mkEnableOption "Enable the Podman container engine"; };

config = mkIf config.modules.virtualize.podman.enable {
config = mkIf config.modules.virtualisation.podman.enable {
virtualisation.podman = {
enable = true;
dockerCompat = true; # docker = podman (alias)
Expand Down
7 changes: 4 additions & 3 deletions modules/virtualize/wine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ let
inherit (lib.attrsets) attrValues;
inherit (lib.modules) mkIf;
in {
options.modules.virtualize.wine = let inherit (lib.options) mkEnableOption;
in { enable = mkEnableOption "compatibility layer -> windows.exe"; };
options.modules.virtualisation.wine =
let inherit (lib.options) mkEnableOption;
in { enable = mkEnableOption "compatibility layer -> windows.exe"; };

config = mkIf config.modules.virtualize.wine.enable {
config = mkIf config.modules.virtualisation.wine.enable {
user.packages = attrValues {
inherit (pkgs) bottles winetricks;
inherit (pkgs.wineWowPackages) fonts stagingFull;
Expand Down

0 comments on commit 5331fac

Please sign in to comment.