Install with Nix?

Can Rescript be installed with Nixpkgs/NixOS? On nixpkgs, I could install bs-platform, but not the new rescript version.

I also tried installed it through yarn on NixOS, but I get build failures in the pre/post install because it seems to be looking for global bins that don’t exists on NixOS.

1 Like

Hm, we don’t offer any official Nix package… the bs-platform package was created by community members. Don’t really know much about Nix, so it’s probably pretty hard to diagnose the issue.

What binaries is it looking for?

well, i’m working in a solution to port rescript to nix but ocaml/reason/rescript environments in nix kinda… sucks haha

i also tried to port melange, but that went to far than i have knowledge

Would you upload your build log somewhere so I can have a look?

When installing rescript on NixOS using yarn/npm, you will notice that the shipped binaries don’t work. This is to be expected on NixOS. In my case, this causes the compiler to be compiled in the post-install hook of rescript. This takes a long time, but works if you have all the required build dependencies.

We have “solved” this by wrapping yarn with a script that calls autopatchelf on the shipped binaries at the right stage. With npm you can use a hook for this.


If ninja is not found it tries to build from from source with python using /usr/bin/python which doesn’t exits on nixos (I believe this was the path, I don’t recall 100% now). But after adding ninja to my nix shell, rescript was able to install as expected through yarn!

I’m hitting some other issues now though because a few of of my deps (relude & bs-bastet) use bisect_ppx & my project uses decco. I was able to fix the bisect_ppx problem by manually removing the dependencies bsconfig.json (since bisect is really a dev dependency for the projects that use them). But there seems to be some problem finding the decco ppx, the error I get is:

Dependency on decco
rescript: [1/6] src/Decco_Codecs.ast
FAILED: src/Decco_Codecs.ast
sh: /../project/node_modules/decco/./ppx: No such file or directory

  We've found a bug for you!

  Error while running external preprocessor
Command line: /../project/node_modules/decco/./ppx '/tmp/' '/tmp/'

rescript: [2/6] src/Decco.ast
FAILED: src/Decco.ast
sh: /../project/node_modules/decco/./ppx: No such file or directory

  We've found a bug for you!

  Error while running external preprocessor
Command line: /../project/node_modules/decco/./ppx '/tmp/' '/tmp/'

FAILED: cannot make progress due to previous errors.
Failure: /../project/node_modules/rescript/linux/ninja.exe
Location: /../project/node_modules/decco/lib/bs

But if I do ls node_modules/decco, then I see:

bsconfig.json  lib  LICENSE  package.json  postinstall.js  ppx  ppx-osx.exe  ppx-windows.exe  ppx.cmd  src

so decco/pxx does indeed exist. Not really sure where to go from here, but I guess the main issue of installing rescript on nixos is resolved

interesting! could you provide any examples on how to implement that? actually I didn’t know that rescript publish the binaries… this will hel me on how to port to nexos directly

hmm kinda strange… it’s trying to find a /decco/./ppx/ folder when actually it needs /decco/ppx/

I’ll try to reproduce this