NixOS 重建失败,因为 NIX_PATH 中的某些目录不存在

NixOS 重建失败,因为 NIX_PATH 中的某些目录不存在

当我尝试重建 NixOS 时,它失败了,因为它无法根据NIX_PATH.发生这种情况是因为我尝试切换nixos-unstable到频道23.11并意外添加然后nixpkgs-unstable将其删除。重新添加通道并没有改变错误。

这里有什么问题吗?

该目录/nix/var/nix/profiles/per-user/root/channels仅包含一个文件 ,manifest.nix并且存在同级目录channel-2-linkchannels-1-link包含更多文件,包括目录nixos

NIX_PATH,我的频道和整个错误报告都在这里:

~> $env.NIX_PATH
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

~> sudo nix-channel --list
nixos https://nixos.org/channels/nixos-unstable

~> sudo nixos-rebuild switch --upgrade
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error:
       … <borked>

         at «none»:0: (source not available)

       … while calling the 'import' builtin

         at «string»:1:6:

            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |      ^

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
building Nix...
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 «none»:0: (source not available)
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error: file 'nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
/tmp/nixos-rebuild.TFvl5H/nix
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «none»:0: (source not available)
building the system configuration...
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 «none»:0: (source not available)

答案1

我仍然不知道这里到底出了什么问题,但我读了的手册nix-channel我可以运行sudo nix-channel --rollback以返回 Nix 通道之前的正确状态。这解决了我的问题。

相关内容