I have a colleague who had the following issue on OS X:
They ran roughly the following sequence of commands:
$ nix-channel --add https://nixos.org/channels/nixos-16.09/ nixos-16.09
$ nix-channel --update
$ nix-channel --remove nixos-16.09
$ nix-channel --add https://nixos.org/channels/nixos-16.03/ nixpkgs
$ nix-channel --update
... which left them with a ~/.nix-defexpr/channels directory that looks like this:
$ ls ~/.nix-defexpr/channels/
binary-caches/
manifest.nix
nixos-16.09/
nixpkgs/
... where the nixos-16.09 directory is still left behind after --removeing the channel and --update.
Whenever they run nix-env to install something, nix-env uses ~/.nix-defexpr/nixos-16.09 as the path for the base set of expressions instead of nixpkgs like my colleague intended.
The documentation from nix-env says that nix-env uses the contents of ~/.nix-defexpr as the default path, but:
~/.nix-defexpr/channelsnix-env use the NIX_PATH environment variable (which was correctly configured in my colleague's case)?you may be interested in https://github.com/NixOS/nix/issues/993
I have experienced this as well. This makes the expectation that nix-env using
clever helped me on the IRC channel to remove my rogue channel: nix-env -p /nix/var/nix/profiles/per-user/cmcdragonkai/channels -e /nix/store/qf450s7ayjaijqlaqmf6m2wp053ifvas-nixos-17.03-17.03beta320.ade5837. That force removes the nixos-17.03 channel, and now my nix-env respects <nixpkgs> again!
Most helpful comment
I have experienced this as well. This makes the expectation that nix-env using fail when you don't realise that a rogue channel is left in the channels directory.
clever helped me on the IRC channel to remove my rogue channel:
nix-env -p /nix/var/nix/profiles/per-user/cmcdragonkai/channels -e /nix/store/qf450s7ayjaijqlaqmf6m2wp053ifvas-nixos-17.03-17.03beta320.ade5837. That force removes thenixos-17.03channel, and now my nix-env respects<nixpkgs>again!