From 97469c8c4abd14e653bfe174e0e4fa747e2b258e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 3 Apr 2024 13:44:55 +0200 Subject: [PATCH] usbip: allow configuring script snippet to get ip address --- modules/usbip.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/usbip.nix b/modules/usbip.nix index 72a5d796..dfe045b1 100644 --- a/modules/usbip.nix +++ b/modules/usbip.nix @@ -17,6 +17,15 @@ in example = [ "4-1" ]; description = "Auto attach devices with provided Bus IDs."; }; + snippetIpAddress = { + type = lib.types.str; + default = "$(ip route list | sed -nE 's/(default)? via (.*) dev eth0 proto kernel/\2/p')"; + example = "127.0.0.1"; + description = '' + This snippet is used to obtain the address of the Windows host where Usbipd is running. + It can also be a plain IP address in case networkingMode=mirrored or wsl-vpnkit is used. + ''; + }; }; config = lib.mkIf (config.wsl.enable && cfg.enable) { @@ -39,7 +48,7 @@ in script = '' busid="$1" - ip="$(ip route list | sed -nE 's/(default)? via (.*) dev eth0 proto kernel/\2/p')" + ip="${cfg.snippetIpAddress}" echo "Starting auto attach for busid $busid on $ip." source ${usbipd-win-auto-attach} "$ip" "$busid"