@@ -797,7 +797,7 @@ Hook executed at the start of the distribution phase.
797797
798798Hook executed at the end of the distribution phase.
799799
800−## Shell functions {#ssec-stdenv-functions}
800+## Shell functions and utilities {#ssec-stdenv-functions}
801801
802802The standard environment provides a number of useful functions.
803803
@@ -821,6 +821,19 @@ There’s many more kinds of arguments, they are documented in `nixpkgs/pkgs/bui
821821
822822Using the `makeBinaryWrapper` implementation is usually preferred, as it creates a tiny _compiled_ wrapper executable, that can be used as a shebang interpreter. This is needed mostly on Darwin, where shebangs cannot point to scripts, [due to a limitation with the `execve`-syscall](https://stackoverflow.com/questions/67100831/macos-shebang-with-absolute-path-not-working). Compiled wrappers generated by `makeBinaryWrapper` can be inspected with `less <path-to-wrapper>` - by scrolling past the binary data you should be able to see the shell command that generated the executable and there see the environment variables that were injected into the wrapper.
823823
824+### `remove-references-to -t` \<storepath\> [ `-t` \<storepath\> ... ] \<file\> ... {#fun-remove-references-to}
825+
826+Removes the references of the specified files to the specified store files. This is done without changing the size of the file by replacing the hash by `eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee`, and should work on compiled executables. This is meant to be used to remove the dependency of the output on inputs that are known to be unnecessary at runtime. Of course, reckless usage will break the patched programs.
827+To use this, add `removeReferencesTo` to `nativeBuildInputs`.
828+
829+As `remove-references-to` is an actual executable and not a shell function, it can be used with `find`.
830+Example removing all references to the compiler in the output:
831+```nix
832+postInstall = ''
833+ find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
834+'';
835+```
836+
824837### `substitute` \<infile\> \<outfile\> \<subs\> {#fun-substitute}
825838
826839Performs string substitution on the contents of \<infile\>, writing the result to \<outfile\>. The substitutions in \<subs\> are of the following form: