Downloading dependencies on nixpkgs-unstable using nix-shell

I am on NixOS 16.09 and I want to use packages that are currently only in nixpkgs-unstable / nixos-unstable.

Using nix-channel --add , I was able to add nixpkgs-unstable to my (custom) channels and use it to install the latest version of some packages using nix-env .

However, I understand that although nix-env depends on user channels, nix-shell instead depends on the NIX_PATH environment NIX_PATH , in my case:

 $ echo $NIX_PATH nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels 

Thus, this clearly shows the problem: nix-shell will use the NIXOS 16.09 system-wide channel instead of the custom nixpkgs-unstable channel.

Right now, I'm using this workaround:

 nix-shell -I nixpkgs=~/.nix-defexpr/channels/nixpkgs 

It doesn't look very pretty to me. What would be the recommended way to do this?

Is it possible to add something like:

 export NIX_PATH="nixpkgs=~/.nix-defexpr/channels/nixpkgs:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels" 

to my .profile ? This is also not very beautiful.

+5
source share
2 answers

Welcome to the long-standing confusion with nix-env and NIX_PATH . It is explicitly stated that nix-env does not use NIX_PATH, which makes it (I think) the only Nix tool that does not respect NIX_PATH .

So, the actual problem is nix-env here, not nix-shell . I will write a bunch of problems in the Nix bug tracker about this:

I am currently using this workaround:

So now you can see that this is not a workaround. It is recommended that you always specify which Nixpkgs you would like to use: your root channel version, your channel version, remote channel version up, local git check, or a fixed version of git.

+6
source

To fulfill a different answer, here is a good link I just found that explains NIX_PATH and the fact that nix-env does not use it: http://lethalman.blogspot.fr/2014/09/nix-pill-15- nix-search-paths.html

+1
source

Source: https://habr.com/ru/post/1259553/


All Articles