What is the difference between `placeholder "out"` and `$out`

I find nixpkgs use placeholder "out" instead of $out. But why? Are there any benefits?

By the way, I cannot find placeholder in the nix manual.

Well, $out is a shell variable that is only defined once you enter the build environment. You can use it in any bash snippet, typically in buildPhase, installPhase and all the pre/postStuff. In some rare cases however, you need to reference $out in a place where it it not accessible, or not convenient to use $out itself. For example if you want to use it in a string built by nix and included in the derivation in such a way that it does not go through variable expansion in bash. $(placeholder "out") was designed for such cases. $out should always be preferred when possible, so just have a look at `placeholder uses to find examples of situations that require it.

The (scarce) documentation is in the Nix manual, (not to be confused with the nixpkgs manual, or the nixos manual) in the release notes of v2.0. See https://nixos.org/nix/manual/#ssec-relnotes-2.0 and search for “placeholder”.