#1064899 nix-bin: fails to find nixpkgs, no $NIX_PATH found

Package:
nix-bin
Source:
nix-bin
Description:
Purely functional package manager (binaries)
Submitter:
Walter Bleach
Date:
2024-03-19 08:45:02 UTC
Severity:
normal
#1064899#5
Date:
2024-02-27 12:20:02 UTC
From:
To:
Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
   * What was the outcome of this action?
   * What outcome did you expect instead?

*** End of the template - remove these template lines ***

This is my first time trying out nix, however I could not get it to
work.

~$ sudo nix-shell -p cowsay
[sudo] password for farhad:
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 = [ (cowsay) ]; } ""
             |                         ^
(use '--show-trace' to show detailed location information)

whenever I try nix-shel or nix-env to use a package it seems to not be
able to find nixpkgs and fails to proceed anyh further.

I tried to manually upgrade nix from this link:
https://nixos.org/manual/nix/stable/installation/upgrading
however nothing changed

I also tried to use Arch Wiki's guide:
https://wiki.archlinux.org/index.php?title=Nix&oldid=684715
but adding a channel did not seem to resolve the issue either.

Needless to say i performed a full reboot after each action and nothing
seemed to be affected.
I could poke around further but lack of documentation for this package
and my lack of knowledge about nix is holding me back. I do not want to
use packages outside of debian 12 stable, or run random shell scripts on
my machine.

#1064899#10
Date:
2024-02-27 16:07:46 UTC
From:
To:

#1064899#15
Date:
2024-03-19 08:42:14 UTC
From:
To:
Do you want to run this as root (sudo)? If you add your user to the
nix-users group, I think you should be able to run `nix-shell -p
cowsay` as your user without sudo. (Assuming you also added a channel
like mention in the nix-channel man page.)

Oh, I also manually added this in ~/.bashrc:

if [ -e "$HOME/.nix-defexpr/channels" ]; then
  export NIX_PATH="$HOME/.nix-defexpr/channels${NIX_PATH:+:$NIX_PATH}"
fi

This seems like something we might want to consider handling in the
nix debian packaging by updating /etc/profile.d. (Or, at least mention
in /usr/share/doc/nix-bin/README.Debian.)