-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirtualisation.nix
68 lines (58 loc) · 1.43 KB
/
virtualisation.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
let
# RTX 3070 Ti
gpuIDs = [
"10de:24a0" # Graphics
"10de:228b" # Audio
];
in { config, lib, pkgs, inputs, ... }:
let
stable = inputs.stable.legacyPackages.${pkgs.system};
master = inputs.master.legacyPackages.${pkgs.system};
staging = inputs.staging.legacyPackages.${pkgs.system};
in
{
options.vfio.enable = with lib;
mkEnableOption "Configure the machine for VFIO";
config = let cfg = config.vfio;
in {
virtualisation = {
docker = {
enable = true;
rootless = {
enable = true;
setSocketVariable = true;
};
};
podman.enable = true;
libvirtd = {
enable = true;
qemu.vhostUserPackages = with pkgs; [ virtiofsd ];
};
spiceUSBRedirection.enable = true;
waydroid.enable = true;
};
programs = {
virt-manager.enable = true;
};
boot = {
initrd.kernelModules = [
"vfio_pci"
"vfio"
"vfio_iommu_type1"
"nvidia"
"nvidia_modeset"
"nvidia_uvm"
"nvidia_drm"
];
kernelParams = [
"amd_iommu=on"
] ++ lib.optional cfg.enable
# Isolate the GPU
("vfio-pci.ids=" + lib.concatStringsSep "," gpuIDs);
};
specialisation."VFIO".configuration = {
system.nixos.tags = [ "with-vfio" ];
vfio.enable = true;
};
};
}