Packaging the Rescript Language Server tooling


I’m going to try and learn Rescript, and step one of learning a language is getting the LSP working.

I can’t install it from the nodePackages package set because it doesn’t exist.

I am trying to package it as a flake so that I can use it in my directory where I’m going to build a toy frontend with Rescript (as a learning exercise).

I’m having a hard time because the language server project’s directory structure has several package.json files in it.

This is my repository: github.

In the README I described the issues I was having and what I’m trying to do.

There is a ‘postinstall’ script in the top-level package.json of the rescript language server repository that is running a script that assumes that npm install for directories that consumers of the LSP don’t seem to need, like the tools directory, will succeed.

In my flake, I have tried to tell NPM to not do the ‘postinstall’ script and instead let me handle building the parts that need building in the buildPhase. I have tried setting the dontNpmInstall and dontNpmBuild flags for the top-level package to true, and I’ve tried writing dummy installPhases that just echo a string in the bash shell. Even though I did that, running $ nix build prints an error message, and when I look at the log in the nix store, I see that it has failed because it’s still trying to run this ‘postinstall’ package.json script.

I like Flakes and if possible I wanted to package this as a flake so that Nix users could easily use it in project-level flakes like the one that I am trying to make, but I also understand that contributing to the nodePackages package set may be the correct thing to do.

I’ve only ever made one Nix ‘package’ in my life, and that builds Neovim for me and installs my plugins repo. I was fortunate there in that I didn’t need to do anything with Javascript dependencies.

I’m hoping for some advice about which direction I should take to try and package this Rescript language server.

I recently had the same issue, I am also not that well experienced in packaging stuff for nix but i was able to make it work.

Great! I’m confused though. I clicked on this link, and it looks ilke a flake that is mostly empty.

I don’t see anything about how to fetch the npm dependencies, build the dune subprojects or anything.

Thanks to some help from con-f-use in the NIxOs discord I was able to get my flake running.

It still has a lot of junk comments, TODOs and unnecessary print statements, but it’s here rescript-lsp-flake/flake.nix at a70374b324fad16b68b24a2359badbaad2e08ebc · MattBrooks95/rescript-lsp-flake · GitHub