Can you try using nix hash file foo.txt instead of nix hash path foo.txt? I’ve been using it in the past like this and can’t remember having issues. And I just checked and the resulting hashes are definitely different.
Also, not sure if that is related in any capacity, but I am also using nix store add-file foo.txt instead of the legacy binary.