feat: kernel 6.13, emily's custom udev rule for passing through devices to vm, various app changes

This commit is contained in:
Evar 2025-01-31 22:38:03 -05:00
parent 9ac1768033
commit 3120f90b5d
8 changed files with 129 additions and 37 deletions

27
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "nixos-rebuild switch",
"type": "shell",
"command": "nixos-rebuild switch --flake .#atreus --use-remote-sudo",
"detail": "Switches to the current config with use remote sudo.",
"promptOnClose": true,
"presentation": {
"echo": false,
"reveal": "always",
"revealProblems": "never",
"close": true,
"focus": true,
"panel": "dedicated",
"showReuseMessage": true,
"clear": true
},
"runOptions": {
"instanceLimit": 1
}
}
]
}

7
bridge-nic.xml Normal file
View file

@ -0,0 +1,7 @@
<interface type="bridge">
<mac address="52:54:00:33:7d:5e"/>
<source bridge="winvm0"/>
<model type="virtio"/>
<link state="up"/>
<address type="pci" domain="0x0000" bus="0x0b" slot="0x00" function="0x0"/>
</interface>

60
flake.lock generated
View file

@ -6,11 +6,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1737224637,
"narHash": "sha256-FAytebF/lOl8ESnf3iaIEFCLw0+4uU/Tthb08B169hA=",
"lastModified": 1738087375,
"narHash": "sha256-GLyNtU9A2VN22jNRHZ2OXuFfTJLh8uEVVt+ftsKUX0c=",
"owner": "Aylur",
"repo": "ags",
"rev": "92bdcb227dc390e2edb122b5bb182b38456b6a5e",
"rev": "a6a7a0adb17740f4c34a59902701870d46fbb6a4",
"type": "github"
},
"original": {
@ -47,11 +47,11 @@
]
},
"locked": {
"lastModified": 1737052425,
"narHash": "sha256-sRX9eWJEThJ/0ZErG7LhHO9cFa3EIZloKA5NaLFfaF4=",
"lastModified": 1737670815,
"narHash": "sha256-ZCxxshGN7XooabArcoGkYSNx5yVunqjKJi2aTv6cznI=",
"owner": "aylur",
"repo": "astal",
"rev": "897c6d810acfd31e6cc55df7692755b177a84fcb",
"rev": "127e9cdcbf173846a3c40ddc0abfbb038df48042",
"type": "github"
},
"original": {
@ -67,11 +67,11 @@
]
},
"locked": {
"lastModified": 1737038063,
"narHash": "sha256-rMEuiK69MDhjz1JgbaeQ9mBDXMJ2/P8vmOYRbFndXsk=",
"lastModified": 1738148035,
"narHash": "sha256-KYOATYEwaKysL3HdHdS5kbQMXvzS4iPJzJrML+3TKAo=",
"owner": "nix-community",
"repo": "disko",
"rev": "bf0abfde48f469c256f2b0f481c6281ff04a5db2",
"rev": "18d0a984cc2bc82cf61df19523a34ad463aa7f54",
"type": "github"
},
"original": {
@ -124,11 +124,11 @@
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1737299337,
"narHash": "sha256-0NBrY2A7buujKmeCbieopOMSbLxTu8TFcTLqAbTnQDw=",
"lastModified": 1738275749,
"narHash": "sha256-PM+cGduJ05EZ+YXulqAwUFjvfKpPmW080mcuN6R1POw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "f8ef4541bb8a54a8b52f19b52912119e689529b3",
"rev": "a8159195bfaef3c64df75d3b1e6a68d49d392be9",
"type": "github"
},
"original": {
@ -139,11 +139,11 @@
},
"impermanence": {
"locked": {
"lastModified": 1736688610,
"narHash": "sha256-1Zl9xahw399UiZSJ9Vxs1W4WRFjO1SsNdVZQD4nghz0=",
"lastModified": 1737831083,
"narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "c64bed13b562fc3bb454b48773d4155023ac31b7",
"rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170",
"type": "github"
},
"original": {
@ -180,11 +180,11 @@
]
},
"locked": {
"lastModified": 1737257306,
"narHash": "sha256-lEGgpA4kGafc76+Amnz+gh1L/cwUS2pePFlf22WEyh8=",
"lastModified": 1737861961,
"narHash": "sha256-LIRtMvAwLGb8pBoamzgEF67oKlNPz4LuXiRPVZf+TpE=",
"owner": "nix-community",
"repo": "nix-index-database",
"rev": "744d330659e207a1883d2da0141d35e520eb87bd",
"rev": "79b7b8eae3243fc5aa9aad34ba6b9bbb2266f523",
"type": "github"
},
"original": {
@ -225,11 +225,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1737306472,
"narHash": "sha256-+X9KAryvDsIE7lQ0FdfiD1u33nOVgsgufedqspf77N4=",
"lastModified": 1737751639,
"narHash": "sha256-ZEbOJ9iT72iwqXsiEMbEa8wWjyFvRA9Ugx8utmYbpz4=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "cb3173dc5c746fa95bca1f035a7e4d2b588894ac",
"rev": "dfad538f751a5aa5d4436d9781ab27a6128ec9d4",
"type": "github"
},
"original": {
@ -240,11 +240,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1737062831,
"narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=",
"lastModified": 1737469691,
"narHash": "sha256-nmKOgAU48S41dTPIXAq0AHZSehWUn6ZPrUKijHAMmIk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c",
"rev": "9e4d5190a9482a1fb9d18adf0bdb83c6e506eaab",
"type": "github"
},
"original": {
@ -284,11 +284,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1736012469,
"narHash": "sha256-/qlNWm/IEVVH7GfgAIyP6EsVZI6zjAx1cV5zNyrs+rI=",
"lastModified": 1737885589,
"narHash": "sha256-Zf0hSrtzaM1DEz8//+Xs51k/wdSajticVrATqDrfQjg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8f3e1f807051e32d8c95cd12b9b421623850a34d",
"rev": "852ff1d9e153d8875a83602e03fdef8a63f0ecf8",
"type": "github"
},
"original": {
@ -300,11 +300,11 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1737110817,
"narHash": "sha256-DSenga8XjPaUV5KUFW/i3rNkN7jm9XmguW+qQ1ZJTR4=",
"lastModified": 1738297584,
"narHash": "sha256-AYvaFBzt8dU0fcSK2jKD0Vg23K2eIRxfsVXIPCW9a0E=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "041c867bad68dfe34b78b2813028a2e2ea70a23c",
"rev": "9189ac18287c599860e878e905da550aa6dec1cd",
"type": "github"
},
"original": {

View file

@ -13,7 +13,8 @@
# Social
pkgs.signal-desktop
pkgs.webcord # pkgs.webcord-vencord
# pkgs.webcord # pkgs.webcord-vencord
pkgs.vesktop
pkgs.telegram-desktop
# Productivity/Documents
@ -79,9 +80,20 @@
};
};
extensions = with pkgs.vscode-extensions; [
usernamehw.errorlens
rust-lang.rust-analyzer
vadimcn.vscode-lldb
vscodevim.vim
mkhl.direnv
jnoortheen.nix-ide
];
userSettings = {
"nix.enableLanguageServer" = true;
"nix.serverPath" = pkgs.nixd + "/bin/nixd";
"extensions.autoUpdate" = false;
};
};
}

View file

@ -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+

View file

@ -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 = {

View file

@ -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 = []

View file

@ -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/