Merge pull request 'chore(update): remove lix patch, minor waybar changes' (#2) from update into main
Reviewed-on: https://git.cnix.dev/cnst/cnix/pulls/2
This commit was merged in pull request #2.
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf mkEnableOption;
|
||||
cfg = config.nixos.services.libvirtd;
|
||||
cfg = config.nixos.services.virtualisation;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
nixos.services.libvirtd.enable = mkEnableOption "Enables libvirtd";
|
||||
nixos.services.virtualisation.enable = mkEnableOption "Enables virtualisation";
|
||||
};
|
||||
imports = [
|
||||
./vfio.nix
|
||||
];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.firewall.trustedInterfaces = [ "virbr0" ];
|
||||
@@ -21,7 +24,6 @@ in
|
||||
];
|
||||
|
||||
virtualisation = {
|
||||
kvmgt.enable = true;
|
||||
spiceUSBRedirection.enable = true;
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
@@ -34,5 +36,6 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
nixos.services.virtualisation.vfio.enable = true;
|
||||
};
|
||||
}
|
||||
41
modules/nixos/services/virtualisation/vfio.nix
Normal file
41
modules/nixos/services/virtualisation/vfio.nix
Normal file
@@ -0,0 +1,41 @@
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
gpuIDs = [
|
||||
"1002:13c0"
|
||||
"1002:1640"
|
||||
];
|
||||
|
||||
vfioIds = "vfio-pci.ids=" + lib.concatStringsSep "," gpuIDs;
|
||||
baseBootKernelParams = config.boot.kernelParams or [ ];
|
||||
cfg = config.nixos.services.virtualisation.vfio;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
nixos.services.virtualisation.vfio.enable =
|
||||
lib.mkEnableOption "Enable VFIO passthrough for the iGPU";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot = {
|
||||
initrd.kernelModules = [
|
||||
"vfio_pci"
|
||||
"vfio"
|
||||
"vfio_iommu_type1"
|
||||
];
|
||||
|
||||
kernelParams = [
|
||||
"amd_iommu=on"
|
||||
"iommu=pt"
|
||||
]
|
||||
++ [ vfioIds ];
|
||||
};
|
||||
|
||||
specialisation.vfio.configuration = {
|
||||
system.nixos.tags = [ "vfio" ];
|
||||
boot = {
|
||||
kernelParams = baseBootKernelParams ++ [ vfioIds ];
|
||||
blacklistedKernelModules = [ "amdgpu:0f:00.0" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user