When is postHooks used in a derivation?

Some packages in nixpkgs define setup hooks and add them to the array postHooks.

nixpkgs/setup-hook.sh at de71be7723a5e9e6078420071d28db3815842594 · NixOS/nixpkgs · GitHub is an example.

When are those hooks executed during the build process for a package?