Unverified Commit 72b5a1c0 authored by PerchunPak's avatar PerchunPak Committed by Diogo Correia
Browse files

doc: add wasip1 rust package example

parent d66c6c9d
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -736,6 +736,35 @@ stdenv.mkDerivation (finalAttrs: {
})
```

### Compiling `wasm32-wasip1` package {#compiling-wasm32-wasip1-package}

```nix
pkgsCross.wasi32.callPackage (
  {
    fetchFromGitHub,
    rustPlatform,
    lld,
  }:
  rustPlatform.buildRustPackage (finalAttrs: {
    pname = "zellij-harpoon";
    version = "0.3.0";

    src = fetchFromGitHub {
      owner = "Nacho114";
      repo = "harpoon";
      tag = "v${finalAttrs.version}";
      hash = "sha256-JmYcbzxIF6qZs2/RKuspHqNpyDibGp9CVQJj47y/BOQ=";
    };

    cargoHash = "sha256-lsv5Wssakni18jif++fPo3Z5WyBtvPsGpWwG3abR7jQ=";

    # these two lines are currently required
    env.RUSTFLAGS = "-C linker=wasm-ld";
    nativeBuildInputs = [ lld ];
  })
) { }
```

## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo}

### Simple operation {#simple-operation}
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@
  "cmake-ctest-variables": [
    "index.html#cmake-ctest-variables"
  ],
  "compiling-wasm32-wasip1-package": [
    "index.html#compiling-wasm32-wasip1-package"
  ],
  "coq-withPackages": [
    "index.html#coq-withPackages"
  ],