Nix-shell -p always fails with infinite recursion

nix-shell -p <any-package> seems to fail consistently with exactly this error in all cases:

─❯ nix-shell -p cowsay                                                                                                                                                                                                                                       ─╯
error: infinite recursion encountered

       at /nix/store/f9mc8nca8cw4p3jjx6gy5kdspybrfmlh-nixos-22.05.998.d17a56d90ec/nixos/lib/fixed-points.nix:69:67:

           68|   #
           69|   extends = f: rattrs: self: let super = rattrs self; in super // f self super;
             |                                                                   ^

I mostly use the new nix commands, so this isn’t a showstopper, but it’s odd and annoying.

I also have many project-specific flake.nixes which are automatically activated by direnv upon cd-ing. In some of these, the same error appears, but the environment activation seems to be working ok.

Does this ring any bells? Any hints on how to fix it?

Edit: it’s also preventing nix-index (which I’ve never consciously used before, but which appears in some recipe I’m following) from working, with exactly the same error.

Not seeing the same (though I’m not using flakes at all yet). Perhaps --show-trace will give a hint as to where it’s diving off into the recursion?

Errm, OK, it now simply works.

I first observed this problem around 48 hours ago, it was definitely still there (in a variety of shells, contexts, etc) just before I posted … and now it’s gone. I have definitely not rebuilt my system or my home-manager in the interim. WTF‽

I spend so much time bumbling around Nix, because I really want … need consistent, reproducible behaviour in order to keep my sanity when dealing with computers. And then stuff like this happens. I … just … whuh? …

[Aside: how often is --show-trace actually helpful? I go through periods of using it, and wasting lots of time trawling through the tons of info it sometimes spews, never getting anything useful out of it, which leads me to forgetting about it for a while. Then the cycle repeats.]

Do you use any of overlays or package overrides?

Hmm, yes. I was hacking on packaging something up as an overlay. But I explicitly removed that to make sure that it wasn’t responsible. Maybe I made a mistake and didn’t remove it when I thought I had. Yes, this (unfinished) overlay could well be the cause.

The error message was singularly useless.