如何更新nix语言版本(builtins.langVersion)?

How to update nix language version (builtins.langVersion)?

我想运行在本地测试nixpkgs,我找到了this manual,但是不行

$ cd my/nixpkgs
$ nix-build --show-trace nixos/tests/login.nix
error: while evaluating the attribute ‘buildCommand’ of the derivation ‘vm-test-run-login’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-test-driver-login’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-vm’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating the attribute ‘text’ of the derivation ‘run-nixos-vm’ at /home/bjorn/projects/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:148:11:
while evaluating anonymous function at /home/bjorn/projects/nixpkgs/pkgs/build-support/closure-info.nix:9:1, called from /home/bjorn/projects/nixpkgs/nixos/modules/virtualisation/qemu-vm.nix:105:13:
assertion failed at /home/bjorn/projects/nixpkgs/pkgs/build-support/closure-info.nix:11:1

因为这个断言

assert builtins.langVersion >= 5;

如何更新langVersion?

$ nix-repl
Welcome to Nix version 1.11.16. Type :? for help.

nix-repl> builtins.langVersion
3

nix-repl>

感谢大卫·格雷森

我必须将 nixos 更新到不稳定(sudo nix-channel 很重要)

sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
sudo nixos-rebuild switch --upgrade
nix-instantiate --eval -E '(import <nixos> {}).lib.nixpkgsVersion'
nix-instantiate --eval -E 'builtins.langVersion'

如果你想在 17.09 上多呆一段时间,你可以使用这个 NixOS 配置只升级 Nix:

{ pkgs, ... }: {
  nix.package = pkgs.nixUnstable;
}

否则你可能更愿意切换到 18.03 而不是 unstable。如果你要使用 unstable,确保你使用的是 nixos-unstable,而不是 nixpkgs-unstable。参见 https://nixos.wiki/wiki/Nixpkgs#Channels