Nix looks for expressions at NIX_PATH
.
NIX_PATH
is very similar to PATH
but used by nix expressions (an expression is search on the NIX_PATH
from left to right)
$ nix-instantiate --eval -E '<nixpkgs>'
/nix/var/nix/profiles/per-user/root/channels/nixos
$ echo $NIX_PATH
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
<nixpkgs>
is refering to a path in our filesystem specified by NIX_PATH
$ nix-instantiate --eval -E '<ping>' # Obviously not found.
# But if we add it to the `NIX_PATH`
$ NIX_PATH=$PATH nix-instantiate --eval -E '<ping>'
# NIX_PATH has this handy syntax:
$ NIX_PATH="ping=/bin/ping" nix-instantiate --eval -E '<ping>'
<ping>
equivalent to ./ping
but for nix expressions.
To find where is exactly on the system:
$ nix-instantiate --find-file nixpkgs
# Then, print .version and .version-suffix
nix-env
is a little different than nix-instantiate/nix-build
.
nix-env
uses ~/.nix-defexpr
instead of NIX_PATH
(though NIX_PATH usually includes .nix-defexpr).
Try this in order:
$ nix-channel --update
# and try to rebuild
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixos-unstable
$ nix-channel --update nixos-unstable # Now you can import <nixos-unstable> {};
# and try to rebuild
# Navigate to your channel's expressions (google it) and find the package
$ vim default.nix $ alter the url and the sha256 (use `nix-prefetch-url url` to get the sha256)
On NixOS, you must run those commands as root because the channels are at root level.