由于缺少 nixos 通道,nixos-rebuild 无法构建

问题描述

我想尝试切换频道。我做到了。

nix-channel --add .../nixos-unstable
nix-channel --remove  .../nixos-20.09
nix-channel --update

它起作用了,它创建了一个链接,我可以运行:

nixos-rebuild switch

但是,我的 i3 无法正常工作,所以我想回到 20.09:

nix-channel --add .../nixos-20.09
nix-channel --remove  .../nixos-unstable
nix-channel --update

但现在它不会重新创建该链接以及何时运行

nixos-rebuild switch

它失败了

warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist,ignoring
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I),at (string):1:13
building Nix...

搜索并尝试了一些对其他人有效的解决方案,例如重新启动、使用 sudo -i 运行 t,但到目前为止没有任何效果。如何重新创建该链接

解决方法

好的,我找到了一个方法: 我添加了一个不同名称的频道,而不是默认的 nixos-10.09 只是 nixos

nix-channel --add ..../nixos-20.09 nixos
nix-channel --remove nixos-20.09 
nix-channnel --update 

你瞧,链接已创建,一切又正常了!