Segfault on nix-shell -p <program>

I am on nixos. And I get a segfault when I do nixos -p ‘program’

[jason@nixos:~]$ nix-shell -p hello
Segmentation fault

If I change into a nixrepo I cloned for package searching I can install packages just fine.

#nix clone https://github.com/NixOS/nixpkgs.git created nixpkgs
[jason@nixos:~/nixpkgs]$ nix-shell -p hello
these paths will be fetched (0.04 MiB download, 0.19 MiB unpacked):
  /nix/store/gdh8165b7rg4y53v64chjys7mbbw89f9-hello-2.10
copying path '/nix/store/gdh8165b7rg4y53v64chjys7mbbw89f9-hello-2.10' from 'https://cache.nixos.org'...

Any tips for debugging this? I am guessing I wiped out some environment variable that tells nix-shell where to find its packages.

Is the environment variable NIX_PATH not set or does not contain something like nixpkgs=/path/to/nixpkgs? If that’s the case nix-shell should default to shell.nix and then default.nix inside the current directory which would explain the difference.
But the segmentation fault should still not happen (probably caused by a shell.nix or default.nix file in your home directory).

Thanks primeos. This is what my NIX_PATH looks like

[jason@nixos:~]$ echo $NIX_PATH
/home/jason/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

But the segmentation fault should still not happen (probably caused by a shell.nix or default.nix file in your home directory).

Your intuition on this was correct. I can actually use nix-shell from any directory except for my home.

These are the files in my home directory right now with nix in their name. Ill try removing them one by

one and seeing which one is causing the problem.
[nix-shell:~]$ ls -la | grep -i nix
drwxr-xr-x  2 jason users    4096 Apr  6 15:55 .nix-defexpr
drwxr-xr-x  9 jason users    4096 Apr  1 21:54 nixpkgs
lrwxrwxrwx  1 jason users      44 Feb 23 19:22 .nix-profile -> /nix/var/nix/profiles/per-user/jason/profile
lrwxrwxrwx  1 jason users      59 Mar  3 18:03 result -> /nix/store/yf6l0yy5n2ssfnz1rkizvc6lfznhrzg4-krita-4.1.7.101

edit:
hmm I moved all those files to a folder called test. And home directory nixpkgs still segfaulted. But then I noticed there were some other files -A --attr, and -p in my home directory that I assume were there by accident. Once I removed those home directory nix-shell worked. I still don’t quite understand what was happening but it seems to be solved thanks for your help. I don’t think I would have solved this with out it.