I’m having the same issue when I enable services.envfs on 23.11. More specifically, it seems that /bin/ is not mounted properly, as lsing the directory produces the same error, “Transport endpoint is not connected”.
The very 1st thing i did was a sudo nixos-rebuild switch --upgrade before i added any custom configs
Straight after that i add the services.envfs.enable = true; and then aa rebuild and tested a simple bash scriot with a bin/bash shebang and worked no issues.
After that i put in my custom snippets and carried on as usual. I have no idea to why it worked now and not from the upgrade