Open Rasmus-Bertell opened 4 days ago
Not sure if this is the cleanest solution, but it is possible to solve it like this:
diff --git a/modules/usbip.nix b/modules/usbip.nix
index 8ce755f..8f1cdf9 100644
--- a/modules/usbip.nix
+++ b/modules/usbip.nix
@@ -58,6 +58,7 @@ in
ip="${cfg.snippetIpAddress}"
echo "Starting auto attach for busid $busid on $ip."
+ cd "${pkgs.linuxPackages.usbip}/bin"
source ${usbipd-win-auto-attach} "$ip" "$busid"
'';
};
Or something more intricate like this:
diff --git a/modules/usbip.nix b/modules/usbip.nix
index 8ce755f..49845f2 100644
--- a/modules/usbip.nix
+++ b/modules/usbip.nix
@@ -1,10 +1,19 @@
{ config, lib, pkgs, ... }:
let
- usbipd-win-auto-attach = pkgs.fetchurl {
- url = "https://raw.githubusercontent.com/dorssel/usbipd-win/v4.2.0/Usbipd/WSL/auto-attach.sh";
- hash = "sha256-AiXbRWwOy48mxQxxpWPtog7AAwL3mU3ZSHxrVuVk8/s=";
- };
+ usbipd-win-wsl = pkgs.linkFarm "usbipd-win-wsl" [
+ {
+ name = "usbip";
+ path = "${pkgs.linuxPackages.usbip}/bin/usbip";
+ }
+ {
+ name = "auto-attach.sh";
+ path = pkgs.fetchurl {
+ url = "https://raw.githubusercontent.com/dorssel/usbipd-win/v4.2.0/Usbipd/WSL/auto-attach.sh";
+ hash = "sha256-AiXbRWwOy48mxQxxpWPtog7AAwL3mU3ZSHxrVuVk8/s=";
+ };
+ }
+ ];
cfg = config.wsl.usbip;
in
@@ -58,7 +67,8 @@ in
ip="${cfg.snippetIpAddress}"
echo "Starting auto attach for busid $busid on $ip."
- source ${usbipd-win-auto-attach} "$ip" "$busid"
+ cd "${usbipd-win-wsl}"
+ source ./auto-attach.sh "$ip" "$busid"
'';
};
A third option (and perhaps best one) is to patch the script:
diff --git a/modules/usbip.nix b/modules/usbip.nix
index 8ce755f..3ca8436 100644
--- a/modules/usbip.nix
+++ b/modules/usbip.nix
@@ -1,9 +1,16 @@
{ config, lib, pkgs, ... }:
let
- usbipd-win-auto-attach = pkgs.fetchurl {
- url = "https://raw.githubusercontent.com/dorssel/usbipd-win/v4.2.0/Usbipd/WSL/auto-attach.sh";
- hash = "sha256-AiXbRWwOy48mxQxxpWPtog7AAwL3mU3ZSHxrVuVk8/s=";
+ usbipd-win-auto-attach = pkgs.substitute {
+ src = pkgs.fetchurl {
+ url = "https://raw.githubusercontent.com/dorssel/usbipd-win/v4.2.0/Usbipd/WSL/auto-attach.sh";
+ hash = "sha256-AiXbRWwOy48mxQxxpWPtog7AAwL3mU3ZSHxrVuVk8/s=";
+ };
+ substitutions = [
+ "--replace"
+ "./usbip"
+ "usbip"
+ ];
};
We can also do more advanced options of the patching, like using resholve
.
Bug description
Tried to set up usbip on WSL with auto attach but I get an error in my logs which I believe is the result of the following change in the script which came with PR #493. Should probably revert back to 3.x version of the script until it's fixed upstream. Attaching works as intended if done manually.
WSL version