diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index b23c50e8364..55e9ae48fb1 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -774,7 +774,7 @@ The standard environment provides a number of useful functions. ### `makeWrapper` \ \ \ {#fun-makeWrapper} -Constructs a wrapper for a program with various possible arguments. For example: +A setup-hook that can be added to a derivation's inputs. It adds a `makeWrapper` bash function that constructs a wrapper for a program with various possible arguments. For example: ```bash # adds `FOOBAR=baz` to `$out/bin/foo`’s environment @@ -790,6 +790,14 @@ There’s many more kinds of arguments, they are documented in `nixpkgs/pkgs/bui `wrapProgram` is a convenience function you probably want to use most of the time. +### `makeBinaryWrapper` \ \ \ {#fun-makeBinaryWrapper} + +A setup-hook very similar to `makeWrapper`, only 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). The arguments it accepts are similar to those of `makeWrapper` and they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-binary-wrapper.sh`. + +Compiled wrappers generated by `makeBinaryWrapper` can be inspected with `less ` - by scrolling past the binary data you should be able to see the C code that generated the executable and there see the environment variables that were injected into the wrapper. + +Similarly to `wrapProgram`, the `makeBinaryWrapper` setup-hook provides a `wrapProgramBinary` with similar command line arguments. + ### `substitute` \ \ \ {#fun-substitute} Performs string substitution on the contents of \, writing the result to \. The substitutions in \ are of the following form: @@ -865,7 +873,13 @@ someVar=$(stripHash $name) Convenience function for `makeWrapper` that automatically creates a sane wrapper file. It takes all the same arguments as `makeWrapper`, except for `--argv0`. -It cannot be applied multiple times, since it will overwrite the wrapper file. +It cannot be applied multiple times, since it will overwrite the wrapper file and you will end up with double wrapping. + +### `wrapProgramBinary` \ \ {#fun-wrapProgramBinary} + +Convenience function for `makeWrapperBinary` that automatically creates a sane wrapper file. It takes all the same arguments as `makeBinaryWrapper`, except for `--argv0`. + +It cannot be applied multiple times, since it will overwrite the wrapper file and you will end up with double wrapping. ## Package setup hooks {#ssec-setup-hooks}