Ah OK makes sense - so basically nix is outputting some escape sequences to stderr even though it’s piped. Actually, it probably isn’t the escape sequences that are the problem here - the \r at the beginning is probably causing issues with ripgrep’s output.
Thanks for debugging this. I’ve created nix CLI outputting ANSI escape sequences to stderr when piped · Issue #7558 · NixOS/nix · GitHub