NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.8k forks source link

Package request: Javy #239900

Open Industrial opened 1 year ago

Industrial commented 1 year ago

Project description

Rust package that compiles JavaScript code into WebAssembly.

Metadata

Here is my attempt to get it to run but it's probably not the desired approach: https://gist.github.com/Industrial/799f7e91e27c422d76b0208e240b8ecd/c1d51a127ce235cdcb665f1641bf65f05a54e0ed

augustebaum commented 6 months ago

I also tried to package it with the following "derivation".

At this stage the build fails with:

note: the wasm32-wasi target may not be installed

which makes sense, but I don't understand how to install it without some external tool like fenix or rust-overlay.

{
  fetchFromGitHub,
  rustPlatform,
  pkg-config,
  openssl,
}: let
  version = "unstable-2024-03-05";
in
  rustPlatform.buildRustPackage {
    pname = "javy";
    inherit version;

    src = fetchFromGitHub {
      owner = "bytecodealliance";
      repo = "javy";
      rev = "0a32f865ee17accd38d1b2fe0b8371ee30e4fa5b";
      hash = "sha256-vZXZ+Q/nkDmG6br4B87q7rZZIEWYf4Pdz4Yk7PntV6c=";
    };

    nativeBuildInputs = [pkg-config];

    buildInputs = [openssl];

    buildPhase = ''
      cargo build -p javy-core --target=wasm32-wasi -r
      cargo build -p javy-cli -r
    '';

    cargoHash = "sha256-2cF2SabPU0iqUWwZXjzsUhSvV9vb61mesOmD8lVPEI0=";
  }