Custom prebuild SD Image for pi has too many levels of symlinks

Hey there,
I am trying to setup my pi 3B with Nixos.
I can not really use the official image on the pi and copy my nix configuration for a rebuild, because the pi only has 1Gb of RAM and just gets stuck every time.
So I built my own image, which works.

But I can not boot from this custom image.
The kernel boots up fine and a few other things as well, but at some point I get stuck because of a lot of messages in the journal, which look like this (for different programs of course):

(agetty)[853]: getty@tty1.service: Failed to execute /nix/store/x1dn0i2c0kj0bknzvllsgn3wyr5dy5dy-util-linux-2.39.2-bin/sbin/agetty: Too many levels of symbolic links
(agetty)[853]: getty@tty1.service: Failed at step EXEC spawning /nix/store/x1dn0i2c0kj0bknzvllsgn3wyr5dy5dy-util-linux-2.39.2-bin/sbin/agetty: Too many levels of symbolic links

I copied a few of them out of the journal as examples:


There are more like these, I just did not copy all.
I checked a few of these paths, all are executables, no symlinks themselves.

There is one of them, which is different though, and it is

/nix/store/jki9ha1xl66rlni9a0wg8rdb4l6kshgi-firewall-start/bin/firewall-start: line 4: /nix/store/nkfixravzj6hf1nd7ly48mr7l049p2bx-iptables-1.8.10/bin/iptables: Too many levels of symbolic links

this is a bash script, so I could have a look. Line 4 indeed points to
/nix/store/nkfixravzj6hf1nd7ly48mr7l049p2bx-iptables-1.8.10/bin/iptables with a few symlinks in-between, but less than 10 or so, so that should be fine.
Interestingly, the bash executable is found for this script, because the error occurs inside the script, not while starting it.

I think, that the other problems may not be the files itself, but dependencies (like in this bash script the iptables command).

Unfortunately, I do not have any access at all while the pi is powered on, because ssh and the terminal login both do not start for the same reason.
So only thing I can do is, to modify the files on the card using my PC and reading log files the same way.
I can however see the log live while booting (if the messages show up in the log on the screen at all, the given messages do not).

Anyone any ideas?

I found the problem:
Before I created the SD image, I built the whole system in a VM.
I then used the VM to create the used image.

The configuration.nix still contained the boot.binfmt.emulatedSystems = ["aarch64-linux"]; which was needed, so that the vm could build the image.

I removed it, and it works now.