"openTmpFile: does not exist" Error When Building Haskell App

I have a Haskell project and I’m using direnv with nix-direnv to provide an environment for building my application. When I run cabal build in the project directory, I get the following output:

Build profile: -w ghc-9.6.6 -O1
In order, the following will be built (use -v for more details):
 - rainbow-hash-ld-0.1.0.0 (lib) (first run)
 - rainbow-hash-ld-0.1.0.0 (exe:rainbow-hash-ld) (first run)
Configuring library for rainbow-hash-ld-0.1.0.0...
/tmp/nix-shell-2376382-0: openTempFile: does not exist (No such file or directory)
Error: [Cabal-7125]
Failed to build rainbow-hash-ld-0.1.0.0 (which is required by exe:rainbow-hash-ld from rainbow-hash-ld-0.1.0.0). The failure occurred during the configure step.

Can someone enlighten me as to what the problem might be?

Note that I can build the project using nix-build when not using direnv.

I have a suspicion about what the cause may be here. The default.nix file calls callCabal2nix on some Github source repos here. I haven’t dug into it but I wonder if that call is ultimately creating a nix-shell, which would be a shell-within-a-shell, and may be causing this issue. Thoughts?

I’ve been able to resolve this issue. I believe I was hitting this bug. After a sudo nixos-rebuild switch, it seems to be fixed.