Help packaging mipsy (wasm-pack error)

I’m trying to package GitHub - XavierCooney/mipsy-editor-features for neovim. I think I’m pretty close (kind of adding as I’m going, and haven’t yet gotten to install phase).

There’s a step where you have to run wasm-pack, and I’m getting a permission denied error. Anyone have any ideas what’s going wrong? (Also, let me know if you have any ideas on how to improve the package declaration, maybe it’s bit verbose. I’ll tidy it up a bit by inheriting source and declaring version variables. This is just a first draft.).

{
  fetchFromGitHub,
  wasm-pack,
  python3,
  buildNpmPackage,
  rustPlatform,
  stdenv,
}:
let
  mipsySource =  fetchFromGitHub {
    owner = "insou22";
    repo = "mipsy";
    rev = "7edd349cfdd8680579a86a89666ff4ad8a65415b";
    hash = "sha256-1S3y4bKd3j5pL4jFVoSg2pzxf54hAQX3V/6A6zHAO6U=";
  };

  src = stdenv.mkDerivation {
    pname = "mipsy-editor-features-source";
    version = "latest";

    src = fetchFromGitHub {
      owner = "XavierCooney";
      repo = "mipsy-editor-features";
      rev = "b6d5d59521499ccd71eeec3ab6e59402d15eb962";
      hash = "sha256-RFm4SaaYQ/XvBrlqfGWych6fl7TyYEJecnRw/iiKuuw=";
    };

    installPhase = ''
      runHook preInstall

      mkdir -p $out
      mkdir -p $out/mipsy
      cp -r $src/* $out
      cp -r ${mipsySource}/* $out/mipsy/

      runHook postInstall
    '';
  };

  python = python3.withPackages (python-pkgs: [
    python-pkgs.pyyaml
  ]);

  wasmModule = rustPlatform.buildRustPackage {
    pname = "mipsy-editor-features-wasm";
    version = "latest";
    
    src = src;

    nativeBuildInputs = [ wasm-pack ];

    cargoHash = "sha256-bMWyvjvY5whGYbpYlffpKLszf4VcA8W80pm/iiOPZvk=";

    buildPhase = ''
      runHook preBuild
      cd mipsy_vscode/
      wasm-pack build --target nodejs --release --mode no-install
      cd ../
      runHook postBuild
    '';

    installPhase = ''
      runHook preInstall


      mkdir -p $out/src
      cp -r ./* $out/src

      runHook postInstall
    '';

  };

in
  buildNpmPackage {
    inherit src;
    pname = "mipsy-editor-features";
    version = "latest";

    npmBuildScript = "compile";

    npmDepsHash = "sha256-GhW7vs/n6mTfiXDawY1KEnCQ8Fo/2UGEEowrrnInQuc=";

    nativeBuildInputs = [ 
      python
    ];

    configurePhase = ''
      runHook preConfigure

      python generate_syntax.py

      echo ${wasmModule}

      runHook postConfigure
    '';

}

I have a curse that right when I make a post like this I find the solution (I think this is a new record for me). Had to put HOME=$(mktemp -d) before the wasm-pack. nixpkgs/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix at b5d0681604d2acd74818561bd2f5585bfad7087d · NixOS/nixpkgs · GitHub

I’ll leave this unsolved until I get a full working package declaration.


EDIT:

Took a while, not super pretty, got it working. You can check out the latest commit for having it be a full LSP server.

Took a while,