From 22259e187f18e369e03f27ae6012c1925e35bc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=AD=C3=B0=20Steinn=20Geirsson?= Date: Tue, 17 Mar 2026 12:57:33 +0000 Subject: [PATCH] Add usbDevices option for USB device passthrough Co-Authored-By: Claude Opus 4.6 --- modules/options.nix | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/modules/options.nix b/modules/options.nix index c559bba..90577ea 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -602,6 +602,43 @@ let ''; }; + usbDevices = lib.mkOption { + type = lib.types.listOf ( + lib.types.submodule { + options = { + vendorId = lib.mkOption { + type = lib.types.str; + description = "USB vendor ID (hex, e.g., '17ef')."; + example = "17ef"; + }; + productId = lib.mkOption { + type = lib.types.str; + description = "USB product ID (hex, e.g., '60e0')."; + example = "60e0"; + }; + serial = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "USB serial number to match a specific device. If null, matches all devices with this VID:PID."; + example = "A02019100900"; + }; + }; + } + ); + default = [ ]; + description = '' + USB devices to pass through to this VM. Devices are attached when the VM starts + and detached when it stops. Matched by VID:PID, optionally narrowed by serial number. + If multiple physical devices match a VID:PID (and no serial filter), all are attached. + ''; + example = lib.literalExpression '' + [ + { vendorId = "17ef"; productId = "60e0"; } + { vendorId = "046d"; productId = "c52b"; serial = "A02019100900"; } + ] + ''; + }; + guestPrograms = lib.mkOption { type = lib.types.listOf lib.types.package; default = [ ];