Following this previous answer that was given to me, I started following the nixpkgs-unstable channel with a git clone of this repository: https://github.com/NixOS/nixpkgs-channels/

My clone is in ~/nixpkgs. I'm calling nix-shell with option -I ~ and it works fine. For nix-env the -I option does not exist but I understand that one should instead use the -f option. So far (on two different machines) I did just that (calling nix-env with option -f ~) and it worked fine.

Now, I'm on a third machine and I tried to reproduce the same process. I tried to install a package which is in nixpkgs-unstable but not on my system channel nixos-16.09 with the command nix-env -f ~ -iA nixpkgs.exercism but it fails with the following error message:

warning: name collision in input Nix expressions, skipping ‘/home/theo/nixpkgs’
error: attribute ‘exercism’ in selection path ‘nixpkgs.exercism’ not found

Searching for this error message gave me this http://lists.science.uu.nl/pipermail/nix-dev/2013-October/011898.html but I'm not in the situation described. I am not following any channel as a normal user (nix-channel --list answer is empty) and my only system-wide channel is called nixos (further confirmed by the fact that .nix-defexpr/ only contains channels_root/ which in turn contains binary-caches, manifest.nix and nixos).

What did I do wrong?

To note: I can fix my problem by issuing instead the command nix-env -f ~/nixpkgs -iA exercism but I still would really like to understand why my first solution did not work (even if it did work on two other machines).

1 Answer 1


Looking at the source it seems very likely you have another nixpkgs directory somewhere in ~.

nix-env searches (recursively) all directories for default.nix adding the parent directory as a top level attribute.

Using nix-env -f ~ seems like a bad idea - very much to search and chances for such collisions. Unless there's something I'm missing symlinking ~/nixpkgs into ~/.nix-defexpr seems like a good solution.

There's nothing wrong with simply using nix-env -f nixpkgs -iA exercism. In this form nix sees a default.nix directly in the -f argument and uses that as the top level attribute set.

If you can't find another nixpkgs directory, I'd try using the --show-trace option.

  • Thanks! You allowed me to understand at the same time why the commands nix-env -f ~ and nix-shell -I ~ were so slow at start-up. I will avoid using these in favor of nix-env -f ~/nixpkgs and nix-shell -I nixpkgs=~/nixpkgs now.
    – Zimm i48
    Dec 27, 2016 at 8:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .