error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

I've used sh <(curl -L ) --daemon to install Nix. After installation completed run nix-shell -p nix-info --run "nix-info -m" to verify the installation. It returns the following error

Output

warning: Nix search path entry '/nix/var/nix/profiles/per-user/kana/channels' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I) at «string»:1:25: 1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } "" | ^
(use '--show-trace' to show detailed location information)
2

3 Answers

I had the same issue. Every reference of <nixkpgs> in my scripts failed with the error message you described, on a freshly installed Ubuntu 22.04.2 LTS.

My solution:

nix-channel --add
nix-channel --update

To verify, that your issue is actually mine, the output of nix-channel --list was empty for me.

I guess there is a bug in the installation. I used the multi-user install process as you did.

3

make sure that the nix environment file is sourced correctly. Try to start a new terminal as described in

3

Ultimate what worked for me was to take matters into my own hands and set the NIX_PATH variable manually, like so:

export NIX_PATH=nixpkgs=

(I eventually added it to my ~/.bashrc and ~./zshrc files). I use a MacBook btw.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like