Search code examples
node.jsnixosnixpkgs

NixOS install specific NodeJS version


I can see that NixOS has these versions available for install:

...
nodejs-0.10-statsd-0.7.2
nodejs-0.10.42
nodejs-4.3.1
nodejs-5.9.0
...

yet systemPackages doesn't like me installing nodejs-5.9.0 as it complains that:

error: syntax error, unexpected INT, expecting ID or OR_KW or DOLLAR_CURLY or '"', at /etc/nixos/configuration.nix:49:14
(use ‘--show-trace’ to show detailed location information)
error: syntax error, unexpected INT, expecting ID or OR_KW or DOLLAR_CURLY or '"', at /etc/nixos/configuration.nix:49:14
(use ‘--show-trace’ to show detailed location information)
building the system configuration...
error: syntax error, unexpected INT, expecting ID or OR_KW or DOLLAR_CURLY or '"', at /etc/nixos/configuration.nix:49:14
(use ‘--show-trace’ to show detailed location information)

which suggests to me I'm doing something wrong. I'd rather not just install with nix-env -i ... because I want it system-wide (and I'm building my standard NixOS configuration for all my dev' machines).

According to the nixpkgs repository v6 is available, but I've no idea how to tell nixos-rebuild through configuration.nix or otherwise how to install it.

How can I configure this properly so I can install the latest version of NodeJS, or 5.9.0 specifically?


Solution

  • Turns out it was possible but I was using the wrong package name. If you query with nix-env -qaP | grep nodejs you get the name from its namespace:

    $ nix-env -qaP | grep nodejs
    nixos.statsd                                                          nodejs-0.10-statsd-0.7.2
    nixos.nodejs-0_10                                                     nodejs-0.10.42
    nixos.nodejs                                                          nodejs-4.3.1
    *nixos.nodejs-5_x                                                      nodejs-5.9.0*
    nixos.azure-cli                                                       nodejs-azure-cli-0.9.15
    nixos.dnschain                                                        nodejs-dnschain-0.5.3
    nixos.groovebasin                                                     nodejs-groovebasin-1.5.1
    nixos.keybase                                                         nodejs-keybase-0.8.25
    nixos.npm2nix                                                         nodejs-npm2nix-5.12.0
    nixos.pumpio                                                          nodejs-pump.io-git-2015-11-09
    nixos.ripple-rest                                                     nodejs-ripple-rest-1.7.0-rc1
    nixos.shout                                                           nodejs-shout-0.51.1
    nixos.sloc                                                            nodejs-sloc-0.1.9
    nixos.wring                                                           nodejs-wring-1.0.0
    

    I wanted nodejs-5.9.0 specifically, which means I need to use the nodejs-5_x package as described above (emphasis mine).