Deleted ~/.stack/setup-exe-cache, stack clean --full and then stack build works. Not sure if I have to do this every time after nix-collect-garbage.
~/.stack/setup-exe-cache
stack clean --full
stack build
nix-collect-garbage