13

I've used sh <(curl -L https://nixos.org/nix/install) --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)
Jitesh Prajapati
  • 2,533
  • 4
  • 29
  • 51
Anto
  • 153
  • 1
  • 7

3 Answers3

5

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 https://nixos.org/channels/nixpkgs-unstable
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.

Lars
  • 166
  • 3
  • 5
2

make sure that the nix environment file is sourced correctly. Try to start a new terminal as described in https://nix.dev/tutorials/install-nix#verify-installation

makefu
  • 116
  • 5
  • 1
    "nix environment file is sourced correctly" am I having a stroke? Does the install guide mention an environment file anywhere? I'm following the guide exactly, except I'm using the "nix" package in Arch Linux rather than their install script. The [Arch Nix wiki](https://wiki.archlinux.org/title/Nix) also doesn't mention any environment file. – Hubro Dec 31 '22 at 15:17
  • The Arch Nix wiki defines in step 2: Configure environment: `$ nix-env --install` – makefu Feb 11 '23 at 20:58
  • Not sure what that does, but in my defense that was added to the wiki several weeks after my last comment. – Hubro Feb 12 '23 at 01:09
-1

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=https://github.com/NixOS/nixpkgs/archive/74e2faf5965a12e8fa5cff799b1b19c6cd26b0e3.tar.gz

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