
Müjdat KorkmazSoftware Developer
How to Use Specific Node.js Version in Coolify using Nixpacks

I’ve been using Coolify for a few months now and I deploy anything from hobby projects to production applications with it. So far, all things considered, I’ve had a great experience! Kudos to Coolify Labs!
Coolify can build your apps in few different ways such as with Dockerfile, Docker Compose or Nixpacks. The most automated one would be Nixpacks, which takes care of many things for you, so you don’t have to deal with Docker and whatnot.
However, as you may have realized, if you’re using Nixpacks to build your applications you cannot set specific Node.js Versions, and that may work for most cases, but sometimes you may need a specific Node.js version rather than what Nixpacks supports, which are only the major versions.
I’d like to point out that Coolify cannot do anything about it, since it’s a Nixpacks specific issue but this workaround allows you to use Nixpacks as your build tool without making any changes to your current setup within Coolify. First, I’ll show you how you can set a Node.js version in general and from that I’ll move onto the workaround.
How to Set a Major Node Version in Coolify using Nixpacks
There are more methods, but my preferred one is to use the following environment variable:
NIXPACKS_NODE_VERSION=22
This will set the Node.js to the major Version of 22, however, this way, you don’t have any control over which major 22.x version will be installed and used for your build. As of now, it’s 22.11.0 but what if your app needs something newer than 22.12?
How to Set a Specific Node Version in Coolify using Nixpacks
Now, if you’ve already set your major Node.js version using the environment variable, that’s already the first step towards the workaround, because we can just keep it there! Now comes the tricky part, which is to create a nixpacks.toml file, this file will help us pin a specific Node.js version.
buildImage = 'ghcr.io/railwayapp/nixpacks:latest'
[phases.setup]
nixpkgsArchive = '51ad838b03a05b1de6f9f2a0fffecee64a9788ee'
The configuration file above will pin the Node.js version to 22.13.1 and here’s how it does that:
- It specifies which Docker image of Nixpacks will use to build your application, which is tagged as latest
- It then defines at which part of the process it hooks in which is the setup phase.
- Then with nixpkgsArchive option, it pins the Nix package which is Node.js in our case, and that hash is the commit hash of the specific commit that introduced the specific Node.js version, which in this case is the 22.13.1 and in fact you can find that commit details by here.
Now, if you’ve wanted v22.13.1, then you’re in luck because the file above will give you that, however, for other versions you need to go to the nixpkgs repository and search for commits within the repository that introduces a change within the following folder:
pkgs/development/web/nodejs
You can use the commit history to get the list of commits.
Alternatively you can use “nodejs_22” or similar as the search term within the repository, and this will list plenty of commits which follow the naming convention here.
Once you find that commit, just click on it and copy the commit hash from the URL and use it in your nixpacks.toml file as seen above in the example and set that as the value of nixpkgsArchive. Now you can redeploy your application and Nixpacks will use that pinned version as for the build process.