Skip to content

Commit 5331fac

Browse files
committed
[VIRT] rename dir + looking-glass + scream
1 parent 9148f0a commit 5331fac

File tree

11 files changed

+112
-58
lines changed

11 files changed

+112
-58
lines changed

hosts/probook-445g6/hardware.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ in {
2626
[ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
2727
kernelModules = [ ];
2828
};
29-
extraModulePackages = [ ];
30-
kernelModules = [ "kvm-amd" ];
31-
kernelParams = [ ];
3229
kernel.sysctl = {
3330
"net.ipv4.icmp_echo_ignore_broadcasts" = 1; # Refuse ICMP echo requests
3431
};

hosts/thinkpad-e595/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
};
6767
distractions.steam.enable = true;
6868
};
69-
virtualize.enable = true;
7069
};
7170

7271
# KDE-Connect + Start-up indicator

hosts/thinkpad-e595/hardware.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ in {
3939
kernelModules = [ ];
4040
};
4141
extraModulePackages = [ config.boot.kernelPackages.acpi_call ];
42-
kernelModules = [ "thinkpad_acpi" "acpi_call" "kvm_amd" ];
42+
kernelModules = [ "thinkpad_acpi" "acpi_call" ];
4343
kernelParams = [ "pcie_aspm.policy=performance" ];
4444
kernel.sysctl = {
4545
"net.ipv4.icmp_echo_ignore_broadcasts" = 1; # Refuse ICMP echo requests

modules/desktop/distractions/lutris.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ in {
1818
user.packages = attrValues ({
1919
lutris =
2020
pkgs.lutris.override { extraLibraries = pkgs: [ pkgs.jansson ]; };
21-
} // optionalAttrs (config.modules.virtualize.wine.enable == false) {
21+
} // optionalAttrs (config.modules.virtualisation.wine.enable == false) {
2222
inherit (pkgs) winetricks;
2323
inherit (pkgs.wineWowPackages) fonts stagingFull;
2424
});

modules/virtualize/containers/archlinux.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
let inherit (lib.modules) mkIf;
44
in {
5-
options.modules.virtualize.containers.archlinux =
5+
options.modules.virtualisation.containers.archlinux =
66
let inherit (lib.options) mkEnableOption;
77
in { enable = mkEnableOption "arch-linux container"; };
88

9-
config = mkIf config.modules.virtualize.containers.archlinux.enable {
9+
config = mkIf config.modules.virtualisation.containers.archlinux.enable {
1010
virtualisation.libvirtd = {
1111
enable = true;
1212
qemuVerbatimConfig = ''

modules/virtualize/containers/transmission.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
let
44
inherit (lib.modules) mkIf;
5-
cfg = config.modules.virtualize.containers.transmission;
5+
cfg = config.modules.virtualisation.containers.transmission;
66
in {
7-
options.modules.virtualize.containers.transmission = let
7+
options.modules.virtualisation.containers.transmission = let
88
inherit (lib.options) mkOption mkEnableOption;
99
inherit (lib.types) path str;
1010
in {

modules/virtualize/default.nix

Lines changed: 0 additions & 42 deletions
This file was deleted.

modules/virtualize/kvm.nix

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{ options, config, lib, pkgs, ... }:
2+
3+
let
4+
inherit (lib.attrsets) attrValues;
5+
inherit (lib.modules) mkIf;
6+
virtCfg = config.modules.virtualisation;
7+
in {
8+
options.modules.virtualisation.kvm = let inherit (lib.options) mkEnableOption;
9+
in {
10+
enable = mkEnableOption "Kernel-based Virutal Machine.";
11+
vendor = lib.types.enum [ "amd" "intel" ] "amd";
12+
};
13+
14+
config = mkIf virtCfg.kvm.enable {
15+
virtCfg.looking-glass.enable = true;
16+
17+
user.packages = attrValues { inherit (pkgs) virt-manager; };
18+
19+
boot = {
20+
kernelModules =
21+
# https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#modprobe.d
22+
[ "kvm-${virtCfg.vendor}" "vfio" "vfio_iommu_type1" "vfio_pci" ];
23+
kernelParams = [
24+
"${virtCfg.vendor}_iommu=on"
25+
"${virtCfg.vendor}_iommu=pt"
26+
"kvm.ignore_msrs=1" # https://pve.proxmox.com/wiki/PCI_Passthrough#Tips
27+
];
28+
extraModprobeConfig = ''
29+
softdep drm pre: vfio vfio-pci
30+
'';
31+
};
32+
33+
virtualisation = {
34+
libvirtd = {
35+
enable = true;
36+
onBoot = "ignore";
37+
onShutdown = "shutdown";
38+
qemu = {
39+
ovmf = true;
40+
swtpm = true;
41+
runAsRoot = false;
42+
};
43+
};
44+
};
45+
46+
user.extraGroups = [ "libvirtd" ];
47+
48+
systemd.user.services.scream-ivshmem = {
49+
after =
50+
[ "libvirtd.service" "pipewire.service" "pipewire-pulse.service" ];
51+
wantedBy = [ "graphical-session.target" ];
52+
partOf = [ "graphical-session.target" ];
53+
serviceConfig = {
54+
Type = "simple";
55+
Restart = "on-failure";
56+
ExecStart = "${lib.getExe pkgs.scream} -m /dev/shm/scream -o pulse";
57+
};
58+
};
59+
};
60+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{ options, config, lib, pkgs, ... }:
2+
3+
let inherit (lib.modules) mkIf;
4+
in {
5+
options.modules.virtualisation.looking-glass =
6+
let inherit (lib.options) mkEnableOption;
7+
in {
8+
enable =
9+
mkEnableOption "KVM(s) VGA PCI Pass-through without peripherals.";
10+
};
11+
12+
config = mkIf config.modules.virtualisation.looking-glass.enable {
13+
14+
hm.programs.looking-glass-client = {
15+
enable = true;
16+
package = pkgs.unstable.looking-glass-client;
17+
settings = {
18+
app = {
19+
allowDMA = true;
20+
shmFile = "/dev/shm/looking-glass";
21+
};
22+
input = {
23+
rawMouse = true;
24+
escapeKey = "56"; # linux/input-event-codes.h
25+
};
26+
spice = {
27+
enable = true;
28+
audio = true;
29+
};
30+
win = {
31+
autoResize = true;
32+
borderless = true;
33+
quickSplash = true;
34+
};
35+
};
36+
};
37+
};
38+
}

modules/virtualize/podman.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ let
44
inherit (lib.attrsets) attrValues;
55
inherit (lib.modules) mkIf;
66
in {
7-
options.modules.virtualize.podman = let inherit (lib.options) mkEnableOption;
8-
in { enable = mkEnableOption "Enable the Podman container engine"; };
7+
options.modules.virtualisation.podman =
8+
let inherit (lib.options) mkEnableOption;
9+
in { enable = mkEnableOption "Enable the Podman container engine"; };
910

10-
config = mkIf config.modules.virtualize.podman.enable {
11+
config = mkIf config.modules.virtualisation.podman.enable {
1112
virtualisation.podman = {
1213
enable = true;
1314
dockerCompat = true; # docker = podman (alias)

0 commit comments

Comments
 (0)