Nix: `nix-env` selecting old channels in `~/.nix-defexpr`

Created on 20 Sep 2016  路  2Comments  路  Source: NixOS/nix

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:

  • (A) It does not explain how it selects between multiple channels if there is more than one channel still present in ~/.nix-defexpr/channels
  • (B) This seems like confusing behavior. Why doesn't nix-env use the NIX_PATH environment variable (which was correctly configured in my colleague's case)?

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 the nixos-17.03 channel, and now my nix-env respects <nixpkgs> again!

All 2 comments

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 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 the nixos-17.03 channel, and now my nix-env respects <nixpkgs> again!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luc65r picture luc65r  路  3Comments

Infinisil picture Infinisil  路  3Comments

eqyiel picture eqyiel  路  3Comments

vaibhavsagar picture vaibhavsagar  路  3Comments

bryanhuntesl picture bryanhuntesl  路  3Comments