Infinite recursion as user

Something is messed up in my system, but I don’t know what. I do remember adding/deleting a user and adding/removing channels, so maybe it’s related to that? I copied my configuration.nix to a VM, and the error doesn’t occur.
The issue occurs as user, and not as root. As root, everything works fine.

Any tips or debugging advice appreciated. If I can avoid a re-install that would be great.

nix-info debug output: greghab@nixGreg> nix-info --debug - Pastebin.com
nixos-rebuild switch debug output: [1] greghab@nixGreg> nixos-rebuild switch --show-trace - Pastebin.com

[not working] nix-info:

  • (Note: This part looks suspicious: system: 0, multi-user?: no,)
greghab@nixGreg> nix-info                                                                                                                                                                                                                                                                                                    ~
error: infinite recursion encountered, at undefined position
system: 0, multi-user?: no, version: nix-env (Nix) 2.3.6, channels(greghab): "", channels(root): "nixos-20.03.2176.a84b797b28e", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
greghab@nixGreg> sudo nix-info                                                                                                                                                                                                                                                                                               ~
[sudo] password for greghab: 
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.3.6, channels(greghab): "", channels(root): "nixos-20.03.2176.a84b797b28e", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
greghab@nixGreg>    

Channels:

[1] greghab@nixGreg> nix-channel --list                                                                                                                                                                                                                                                                                      ~
greghab@nixGreg> sudo nix-channel --list                                                                                                                                                                                                                                                                                     ~
nixos https://nixos.org/channels/nixos-20.03

[working] Fresh VM nix-info:

greghab@nixVM> nix-info                                                       ~
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.3.6, nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
greghab@nixVM> sudo nix-info                                                  ~
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.3.6, nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
greghab@nixVM>

[working] Fresh VM Channels:

[1] greghab@nixVM> nix-channel --list                                                                                                                                                                                                                                                                                      ~
greghab@nixVM> sudo nix-channel --list                                                                                                                                                                                                                                                                                     ~
nixos https://nixos.org/channels/nixos-20.03

solving infinite recursion is easy. Use binary search :slight_smile:

  • comment half of configuration file
  • try nixos-rebuild build
  • if still infinite recursion, then bisect the rest of config file
  • if some other error, fix that error and retry
  • if no error, then infinite recursion problem is in commented section. Bisect that

But you say you can’t reproduce that in a VM. Maybe you have ~/.config/nixpkgs/config.nix? or ~/.config/nixpkgs/overlays? Try to strace the call to nix-info and grep only .nix files which don’t live in /nix/store and in nixpkgs checkout – maybe one of those has the infinite recursion?

++ nix-instantiate --eval --strict -E '(import <nixpkgs> {}).system'
error: infinite recursion encountered, at undefined position

So the infinite recursion happens when merely trying to access an attribute off of the imported nixpkgs.

Do you have any user overlays set up? Anything in ~/.config/nixpkgs/overlays?

@danbst @lilyball thank you so much for the help. I had a package that I had manually added into ~/.config/nixpkgs/overlays a long time ago that was causing problems. I completely forgot that there was a local ~/.config/nixpkgs that existed for the user and that I had added a package to that local config.