Welcome! We notice you're using an outdated browser, which will result in a degraded experience on this site. Please consider a modern, fully supported browser.

webbureaucrat

The articles are just window-dressing for code snippets I want to keep.

Finding a Successful Build of NodeJS in Nixpkgs

My latest irritation has been using NodeJS with Nix. Unfortunately, I've had a few unfortunate draws pulling versions of nixpkgs that build the entire NodeJS V8 runtime from source. It's been a pain and I would like to not go through that any more, so I am documenting the steps to avoid it.

It's not you; it's Node.

If you find yourself building NodeJS from source on nix, you can console yourself that at least you didn't really do anything wrong--this is an issue with the NodeJS packages being very flaky on Hydra these days. The builds are often failing when nixpkgs gets built, and that failure gets passed onto you.

So the goal is to find a version of nixpkgs that has the version of NodeJS you want and successfully built that version in Hydra.

Let's begin.

Steps to finding a successfully pre-built NodeJS version from Nix's Hydra

  1. Identify the NodeJS version you want to use using the nixpkgs search site. For this example, I will be using nodejs_24 because it is the most recent version of NodeJS available at the time of this article.
  2. Identify your system platform by running
nix-instantiate --eval --expr 'builtins.currentSystem'

For this example, I will be using my own system, "x86_64-linux".

  1. Search for your NodeJS package on Hydra. For example, these are my search results when I search for "nodejs_24".
  2. Locate the proper job in the search results to see the builds for that job.

And now we can see the problem. At the time of this article, I can see that the nodejs_24 package is failing to build with alarming regularity.

Now we can click on one of these succeeding builds and then along the top bar click on "Inputs". Now we can see the revision we need to select for our nixpkgs property in our Nix expression.

And we're done. I hope this article saves someone some searching, and I hope NodeJS gets a little more reliable. Thank you for reading.

I write to learn, so I welcome your constructive criticism. Report issues on GitLab.

← Home