Getting "nixpkgs not found" error with nix-shell

When I run nix-shell -p nix-info --run "nix-info -m" (or any nix-shell command in general) I’m getting the following error:

error:
       … <borked>

         at «none»:0: (source not available)

       … while calling the 'import' builtin

         at «string»:1:18:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (nix-info) ]; } ""
             |                  ^

       (stack trace truncated; use '--show-trace' to show the full trace)

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

       at «none»:0: (source not available)

My User’s NIX_PATH env variable has the following value:

/Users/user/.nix-defexpr/channels:darwin-config=/Users/user/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels

For root (sudo sh -c 'echo $NIX_PATH') the env variable value is empty.

The output of nix-channel --list is empty both for user and root.

How can I investigate the issue? I’m suspicious of the nix-channels being empty, but I haven’t changed any configuration regarding that, I’ve installed nix via Determinate Nix Installer and I’m using nix-darwin with Home Manager plugin and all packages get installed with no problems when I run darwin-rebuild switch --flake ~/.config/nix-darwin.

The detsys installer doesn’t configure channels:

  • nix-channel --update is not run, ~/.nix-channels is not provisioned

I’m not sure what’s up here, but you might want to start pulling in `nix-shell -p` doesn't work · Issue #234 · DeterminateSystems/nix-installer · GitHub.

It sounded like they thought setting extra-nix-path would fix this case, so maybe confirm that entry is still in /etc/nix/nix.conf?

Thanks! I confirm, after adding extra-nix-path = nixpkgs=flake:nixpkgs to /etc/nix/nix.conf I’m no longer getting that error :+1: It’s surprising as I’ve just installed Nix via Determinate Nix Installer less than a month ago, and the fix PR linked to the issue you’ve mentioned is 1 year old… But I didn’t install it from scratch, had an older installation on my system (via the official Nix installation method) so perhaps I just didn’t purge everything correctly. Thanks again!

1 Like