I am on NixOS 16.09 and I want to use packages which are currently only in nixpkgs-unstable / nixos-unstable.
Using nix-channel --add
, I was able to add nixpkgs-unstable to my (user) channels and use it to install the latest version of some packages with nix-env
.
However, I understand that while nix-env
depends on user-defined channels, nix-shell
instead depends on the NIX_PATH
environment variable, 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
So this clearly shows the problem: nix-shell
is going to use the system-wide NixOS 16.09 channel instead of the user-defined nixpkgs-unstable channel.
Right now, I am using this workaround:
nix-shell -I nixpkgs=~/.nix-defexpr/channels/nixpkgs
It does not look very pretty to me. What would be the recommended way of doing this?
Is it 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
? It does not look very pretty either.
Welcome to a long-standing confusion with nix-env
and NIX_PATH
. It is explicitly stated, that nix-env
doesn't use NIX_PATH, which makes it (I think) the only Nix tool which doesn't respect NIX_PATH
.
So, the actual problem is with nix-env
here, not nix-shell
. I'll post a bunch of issues on Nix bug tracker about this:
Right now, I using this workaround:
So now you can see, this isn't a workaround. It is a good practice to always specify which exact Nixpkgs you'd like to use: your roots channel version, your channel version, upstream remote channel version, local git checkout or pinned git version.
To complete the other answer, here is a good reference that 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With