How to troubleshoot an infinite recursion error?

For better or worse, my habit when I need a flake.nix is to find two (or more) which do what I need and then place their contents in a single file, deleting fragments here or there until I have merged them into a single valid flake.

I was doing that when I came up with this one: https://github.com/MatrixManAtYrService/bug-2023-09-03/blob/0f4d88f8a2ec7dffa2ebd903a086538c1d17c386/flake.nix

To replicate the behavior I’m talking about, run this:

nix build 'github:MatrixManAtYrService/bug-2023-09-03'

On one machine, it just hangs for a while and then my terminal closes. On another, it takes 20 minutes and then fails like this:

evaluating derivation 'github:MatrixManAtYrService/bug-2023-09-03#packages.x86_64-linux.default'error: stack overflow (possible infinite recursion)

How can I capture more information about this failure? Is it a problem with my flake, or a problem with poetry2nix? If the latter, what kind of info should I collect for a bug report?

Thanks in advance!

My guess is that the problem is in this line:

myapp = mkPoetryApplication { projectDir = self; };

Maybe you could try something like this:

myapp = mkPoetryApplication { projectDir = ./.; };

I wondered about that too, but that shouldn’t change anything, and the self is verbatim from the poetry2nix template (as is most of this mini flake): https://github.com/nix-community/poetry2nix/blob/f6b24e8a116c50e5c6fecc83a244772cd5c86361/templates/app/flake.nix#L20

Either nobody ever tested that template or this is a nix bug.

Hey guys, thanks for taking a look. I encountered the same error with this change:

-        myapp = mkPoetryApplication { projectDir = self; };
+        myapp = mkPoetryApplication { projectDir = ./.; };

So I think it’s something else.

I had the same problem. This is what fixed it for me: PSA: poetry2nix is currently broken with nixpkgs-unstable

more information there:

4 Likes