node.js - NixOS 安装特定的 NodeJS 版本

标签 node.js nixos nixpkgs

我可以看到 NixOS 有这些版本可供安装:

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

然而 systemPackages 不喜欢我安装 nodejs-5.9.0因为它提示说:

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)

这表明我做错了什么。我宁愿不只是安装 nix-env -i ...因为我希望在系统范围内使用它(并且我正在为我所有的开发机器构建我的标准 NixOS 配置)。

根据nixpkgs repository v6 可用,但我不知道如何判断 nixos-rebuild通过 configuration.nix 或其他方式安装它。

如何正确配置它以便我可以安装最新版本的 NodeJS,或者特别是 5.9.0?

最佳答案

事实证明这是可能的,但我使用了错误的包名。如果您使用 nix-env -qaP | 查询grep nodejs 你从它的命名空间中获取名称:

$ 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

我特别想要 nodejs-5.9.0,这意味着我需要使用 nodejs-5_x 包,如上所述(强调我的)。

关于node.js - NixOS 安装特定的 NodeJS 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38436527/

相关文章:

package-managers - Nix/NixOS 中的循环依赖以一个简单的例子解释

nixos - 如何在 NixOs 上修改 php.ini 配置?

nix - Nix 派生中的隔离临时文件

php - 如何在 node.js 和 PHP 之间进行通信?

node.js - 如何以编程方式启动/停止 Metro Bundler

javascript - 如何将集合中的一份文档发布到客户端?

node.js - 设置 Jade 布局的 CSS 路径

haskell - 在 NixOS 中使用堆栈 1.8.0 (当前 `stack upgrade --git` )?

qt - 如何在 qt 库中使用调试符号为 qt 5.5 创建开发 shell

nix - Nixpkgs 存储库中定义的 `callPackage` 在哪里(或如何找到一般的 Nix lambda 定义)?