I do not know what exactly triggered this to start happening:
[root@nixos:~]# nixos-rebuild switch --upgrade
unpacking channels...
warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs’ 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...
warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs’ does not exist, ignoring
error: file ‘nixpkgs/nixos’ was not found in the Nix search path (add it using $NIX_PATH or -I)
warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs’ does not exist, ignoring
error: file ‘nixpkgs’ was not found in the Nix search path (add it using $NIX_PATH or -I)
/tmp/nixos-rebuild.l2pkKY/nix
warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs’ does not exist, ignoring
error: file ‘nixpkgs’ was not found in the Nix search path (add it using $NIX_PATH or -I)
building the system configuration...
warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs’ does not exist, ignoring
error: file ‘nixpkgs/nixos’ was not found in the Nix search path (add it using $NIX_PATH or -I)
[root@nixos:~]# nixos-version
17.03.1700.51a83266d1 (Gorilla)
[root@nixos:~]# nix-env --version
nix-env (Nix) 1.11.13
[root@nixos:~]# nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion
warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs’ does not exist, ignoring
error: file ‘nixpkgs’ was not found in the Nix search path (add it using $NIX_PATH or -I)
[root@nixos:~]# grep build-use-sandbox /etc/nix/nix.conf
build-use-sandbox = false
I've sorted this out via IRC. The "nixos" channel was renamed via nix-channel.
sudo nix-channel --add https://nixos.org/channels/nixos-17.03 nixos
What I did was manually edit the channels configuration file to have:
https://nixos.org/channels/nixos-17.03 stable
Not realizing that would break it.
Might be a good idea to have some check for this type of error in Nix and give a better error message as I seen similar errors on google but with no fix.
Another way to trigger this is to expect nix.nixPath
to add to the existing items by default. In my configuration I added
nix.nixPath = [
nixpkgs-overlays=/etc/nixos/overlays
];
which removed nixpkgs
and nixos-config
from $NIX_PATH
. To be able to run nixos-rebuild switch
again fix or remove the troublesome nix.nixPath
listed above and run
nixos-rebuild switch -I nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs -I nixos-config=/etc/nixos/configuration.nix
This will fix the $NIX_PATH
.
I had this problem when I ran a nix-channel --remove nixos19
command followed by a nix-channel --add <url> nixpkgs
command in order to rename a channel (I'm a total newb to NixOS trying to install for the first time right now and tinkering while at it). Then I was able to fix it by running nix-channel --update
, which created the missing files at /nix/var/nix/profiles/per-user/trusktr/channels/nixpkgs/nixos
which I believe were deleted when I ran the nix-channel --remove
command.
Most helpful comment
Another way to trigger this is to expect
nix.nixPath
to add to the existing items by default. In my configuration I addedwhich removed
nixpkgs
andnixos-config
from$NIX_PATH
. To be able to runnixos-rebuild switch
again fix or remove the troublesomenix.nixPath
listed above and runThis will fix the
$NIX_PATH
.