-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dioxus-cli: 0.6.0 -> 0.6.1 #366178
base: master
Are you sure you want to change the base?
dioxus-cli: 0.6.0 -> 0.6.1 #366178
Conversation
We could patch the lookup directory easily: --- a/src/wasm_bindgen.rs
+++ b/src/wasm_bindgen.rs
@@ -233,10 +233,15 @@ impl WasmBindgen {
/// Get the installation directory for the wasm-bindgen executable.
async fn install_dir() -> anyhow::Result<PathBuf> {
- let bindgen_dir = dirs::data_local_dir()
- .expect("user should be running on a compatible operating system")
- .join("dioxus/wasm-bindgen/");
+ let tool_dir = if let Ok(dir) = std::env::var("DIOXUS_TOOL_DIR") {
+ PathBuf::from(dir)
+ } else {
+ dirs::data_local_dir()
+ .expect("user should be running on a compatible operating system")
+ .join("dioxus/")
+ };
+ let bindgen_dir = tool_dir.join("wasm-bindgen/");
fs::create_dir_all(&bindgen_dir).await?;
Ok(bindgen_dir) postFixup = ''
mkdir -p $out/libexec/wasm-bindgen
ln -s ${wasm-bindgen-cli}/bin/wasm-bindgen $out/libexec/wasm-bindgen/wasm-bindgen-${wasm-bindgen-cli.version}
wrapProgram $out/bin/dx \
--set DIOXUS_TOOL_DIR "$out/libexec"
''; Only issue is that the error messages aren't very helpful in the event you have a version mismatch: > dx serve --example hello_world --platform web
12:59:23 [dev] Failed to verify tooling: I/O Error: No such file or directory (os error 2)
dx will proceed, but you might run into errors later.
12:59:23 [dev] Build failed: Other(Failed to write main executable)
Caused by:
0: Failed to generate wasm-bindgen bindings
1: No such file or directory (os error 2) Though I suppose we could also patch the error message too? |
could we have the version, hash, and cargoHash be parameters that we can override, could just be me but I'm having issues using overrideAttrs |
for what its worth I've got the wrapping of wasm-bindgen-cli working like this on my end wasm-bindgen-cli = pkgs.wasm-bindgen-cli.override {
version = "0.2.99";
hash = "sha256-1AN2E9t/lZhbXdVznhTcniy+7ZzlaEp/gwLEAucs6EA=";
cargoHash = "sha256-DbwAh8RJtW38LJp+J9Ht8fAROK9OabaJ85D9C/Vkve4=";
};
dioxus-cli = pkgs.dioxus-cli.overrideAttrs (drv: rec {
version = "0.6.1";
src = pkgs.fetchCrate {
inherit version;
pname = drv.pname;
hash = "sha256-mQnSduf8SHYyUs6gHfI+JAvpRxYQA1DiMlvNofImElU=";
};
cargoDeps = drv.cargoDeps.overrideAttrs (lib.const {
name = "${drv.cargoDeps.name}-vendor";
inherit src;
outputHash = "sha256-QiGnBoZV4GZb5MQ3K/PJxCfw0p/7qDmoE607hlGKOns=";
});
postFixup = if pkgs.stdenv.isDarwin then ''
mkdir -p "$out/home/Library/Application Support/dioxus/wasm-bindgen"
ln -s ${lib.getExe wasm-bindgen-cli} "$out/home/Library/Application Support/dioxus/wasm-bindgen/wasm-bindgen-${wasm-bindgen-cli.version}"
wrapProgram $out/bin/dx \
--set HOME $out/home
'' else ''
mkdir -p $out/share/dioxus/wasm-bindgen
ln -s ${lib.getExe wasm-bindgen-cli} $out/share/dioxus/wasm-bindgen/wasm-bindgen-${wasm-bindgen-cli.version}
wrapProgram $out/bin/dx \
--set XDG_DATA_HOME $out/share
'';
checkFlags = drv.checkFlags ++ ["--skip=wasm_bindgen::test"];
nativeBuildInputs = drv.nativeBuildInputs ++ [pkgs.makeBinaryWrapper];
}); where I'm using dx within another rustPlatform.buildRustPackage derivation to build a fullstack dioxus app edit: |
I have some pull requests open with Dioxus to try to make building - in particular building manually without the cli tool on nix - easier. DioxusLabs/dioxus#3419 There is an issue opened saying it should be possible to have it lookup wasm-bindgen in the path instead of automatically downloading it. Nothing has come of it yet though. |
Anyone want to make this change into a PR and submit it to Dioxus? (although I think the environment variable should point directly to the executable, not the directory) |
v0.6.1 added auto-downloading of wasm-bindgen to the CLI, hence the new skipped tests.
dx now installs wasm-bindgen to
{data_local_dir}/dioxus/wasm-bindgen/wasm-bindgen-{version}
. Assuming you symlink the correct version of wasm-bindgen to this location, everything still works fine.I'll look into wrapping/patching dx to make this more seamless.
Since it uses dirs::data_local_dir, we can't easily wrap on MacOS without overriding $HOME, which isn't ideal. Dioxus also supports reading global config from
{data_local_dir}
, so overriding it would break some functionality.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.