diff options
author | Doron Behar <doron.behar@gmail.com> | 2021-10-02 01:20:41 +0300 |
---|---|---|
committer | Tobias Bergkvist <tobias@bergkv.ist> | 2021-10-19 05:30:42 -0700 |
commit | ba86a1916b483c50f85e32c0ac1547bae06f498f (patch) | |
tree | 0f5d8061b37c2145aac3365144f7a68b89d1211e /doc | |
parent | c310cb0d941cfaaf265e895f41b97db19eb9c69d (diff) | |
download | nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.tar nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.tar.gz nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.tar.bz2 nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.tar.lz nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.tar.xz nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.tar.zst nixlib-ba86a1916b483c50f85e32c0ac1547bae06f498f.zip |
makeBinaryWrapper: Document
Diffstat (limited to 'doc')
-rw-r--r-- | doc/stdenv/stdenv.chapter.md | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index b23c50e83644..55e9ae48fb16 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` \<executable\> \<wrapperfile\> \<args\> {#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` \<executable\> \<wrapperfile\> \<args\> {#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 <!-- TODO: make them identical? --> 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 <path-to-wrapper>` - 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` \<infile\> \<outfile\> \<subs\> {#fun-substitute} Performs string substitution on the contents of \<infile\>, writing the result to \<outfile\>. The substitutions in \<subs\> 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` \<executable\> \<makeBinaryWrapperArgs\> {#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} |