Nix-shell creates /tmp/env-vars?

When I’m running nix-shell as root and as a regular user, the regular user prints an error that /tmp/env-vars can’t be written to.

It seems that this is a harmless message in my case, but I have to wonder why /tmp/env-vars is created in the first place and why it’s not cleaned up. It seems to be part of the builder, and I’m assuming that nix-shell creates a derivation for the required packages. Should it not make the derivation in a private temp directory?