NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.51k stars 1.5k forks source link

attempted channel upgrade b0rk's build environment, nixos-rebuild is broken #8467

Open clayt0nk opened 1 year ago

clayt0nk commented 1 year ago

Attempted upgrade to 23.05 by updating the channel, failed, now I revert the channel to the existing system state of 22.11 and nixos-rebuild is now broken:

526 nix-channel --add https://channels.nixos.org/nixos-22.11 527 nix-channel --update 528 nixos-rebuild --upgrade 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:

            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |             ^
(use '--show-trace' to show detailed location information)
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)
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)
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)
/tmp/nixos-rebuild.EJzXZw/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)
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)

I would expect restoring the channel and updating would restore build environment to sanity? This is not happening.....

nix-env --version output

nix-env (Nix) 2.11.1

abathur commented 1 year ago

Unless maybe the command you included is truncated, it doesn't look like you're naming the channel you're adding. Try: nix-channel --add https://channels.nixos.org/nixos-22.11 nixos

clayt0nk commented 1 year ago

Your right, I wasn't. Apparently that name field is optional, and if not present it uses the last part of the URL -- in the above case, nixos-22.11 -- as the channel name in the list. So I did remove the channel, and replaced it with an entry named "nixos" exactly as you suggested, and there is no change in behavior, I get the same list of errors in response to a nixos-rebuild

RaitoBezarius commented 1 year ago

It should be named nixpkgs actually because you are trying to import <nixpkgs/nixos>, think of those imports like C++ imports.

clayt0nk commented 1 year ago

That last got me through the goal posts, thanks to both of you for your assistance! With two successful channel upgrades in the bag, I might have to add a 2nd machine to my NixOS herd. ;-) So for the record, my channel now looks like this nixpkgs https://channels.nixos.org/nixos-23.05 and that works. From where I sit, it seems that the importance of the channel name is not reflected in the --help text for the nix-channel command, for instance. Should documentation be improved?