Skip to content

Commit

Permalink
usbip: allow configuring script snippet to get ip address
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Apr 3, 2024
1 parent d558975 commit 97469c8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/usbip.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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"
Expand Down

0 comments on commit 97469c8

Please sign in to comment.