It appears that the derivations produced by nix-direnv are removed when running nix's garbage collection. Troubleshooting this issue led me to a git issue in the NixOS/nix repo [1]. Enabling both `keep-derivations` and `keep-outputs` worked for me as recommended, and now nix-direnv is working.
[1]: https://github.com/NixOS/nix/issues/2208
This was clearing TMPDIR since it was first not setting the
`tmp_backup` local variable, and then, since `tmp_backup` was null, it
was unsetting TMPDIR.
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>