feat: kernel 6.13, emily's custom udev rule for passing through devices to vm, various app changes
This commit is contained in:
parent
9ac1768033
commit
3120f90b5d
8 changed files with 129 additions and 37 deletions
|
@ -20,9 +20,7 @@
|
|||
hardware.bluetooth.enable = true;
|
||||
|
||||
boot.kernelPackages =
|
||||
lib.mkIf
|
||||
(lib.versionOlder pkgs.linux.version "6.9")
|
||||
pkgs.linuxPackages_latest;
|
||||
pkgs.linuxPackages_testing;
|
||||
|
||||
# Not needed on NixOS 24.05+
|
||||
# Disable pcr for linux kernel testing 6.9-rc4+
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# from https://github.com/j-brn/nixos-vfio
|
||||
{ std, lib, pkgs, config, ... }:
|
||||
|
||||
with lib;
|
||||
|
@ -115,7 +116,20 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; [ kvmfr ];
|
||||
# So I can build for kernel 6.13
|
||||
# til https://github.com/gnif/LookingGlass/pull/1154 is merged
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; [
|
||||
(kvmfr.overrideAttrs (old: {
|
||||
patches = [ ]; # The patches have already since been merged
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "zeule";
|
||||
repo = "LookingGlass";
|
||||
rev = "7740692e3000c2019e21b9861585960174dd5ddc";
|
||||
sha256 = "sha256-2ayH8FXOn4Bflf55WvhMWTDMLwvucmofD3POI72bC+Q=";
|
||||
};
|
||||
}))
|
||||
];
|
||||
|
||||
services.udev.packages = optionals (cfg.devices != [ ]) [ udevPackage ];
|
||||
|
||||
environment.etc = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# from https://github.com/j-brn/nixos-vfio
|
||||
{ lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
|
@ -30,8 +31,6 @@ in {
|
|||
# got this list, nor which i actually *need*, but either way
|
||||
# this was an immense help:
|
||||
# https://forum.level1techs.com/t/solved-unable-to-connect-to-libvirt-qemu-system-after-changing-to-kernel-module/219006
|
||||
|
||||
#
|
||||
config.virtualisation.libvirtd.qemu.verbatimConfig = ''
|
||||
namespaces = []
|
||||
|
||||
|
|
35
nixos/vm.nix
35
nixos/vm.nix
|
@ -31,6 +31,41 @@ in {
|
|||
|
||||
config = let cfg = config.vfio;
|
||||
in {
|
||||
# Move me
|
||||
services.udev.packages = [
|
||||
(
|
||||
let
|
||||
virsh = "${config.virtualisation.libvirtd.package}/bin/virsh";
|
||||
updateBin = pkgs.writeShellScript "vm-pass-usb-update.sh" ''
|
||||
# todo param
|
||||
vm_name="win10"
|
||||
read -r -d ''\'''\' xml_template <<'EOF'
|
||||
<hostdev mode='subsystem' type='usb' managed='no'>
|
||||
<source>
|
||||
<address bus='%s' device='%s'/>
|
||||
</source>
|
||||
</hostdev>
|
||||
EOF
|
||||
BUSNUM=$((10#$BUSNUM))
|
||||
DEVNUM=$((10#$DEVNUM))
|
||||
if test "$ACTION" = "add"
|
||||
then
|
||||
printf "$xml_template" "$BUSNUM" "$DEVNUM" | \
|
||||
${virsh} attach-device --persistent -- "$vm_name" /dev/stdin
|
||||
elif test "$ACTION" = "remove"
|
||||
then
|
||||
printf "$xml_template" "$BUSNUM" "$DEVNUM" | \
|
||||
${virsh} detach-device --persistent -- "$vm_name" /dev/stdin
|
||||
fi
|
||||
'';
|
||||
in
|
||||
pkgs.writeTextDir "/lib/udev/rules.d/99-vm-attach-usb-anker-hub.rules" ''
|
||||
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="5411", ATTR{idVendor}!="0bda", ATTR{idProduct}!="5411", RUN+="${updateBin}"
|
||||
SUBSYSTEM=="usb", ACTION=="remove", RUN+="${updateBin}"
|
||||
''
|
||||
)
|
||||
];
|
||||
|
||||
# Useful:
|
||||
# https://nixos.mayflower.consulting/blog/2020/06/17/windows-vm-performance/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue