···1141114111421142If dependencies should be resolved at runtime, use `--suffix` to append fallback values to `PATH`.
1143114311441144-There’s many more kinds of arguments, they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh` for the `makeWrapper` implementation and in `nixpkgs/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh` for the `makeBinaryWrapper` implementation.
11441144+There’s many more kinds of arguments, they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh` for the `makeWrapper` implementation and in `nixpkgs/pkgs/by-name/ma/makeBinaryWrapper/make-binary-wrapper.sh` for the `makeBinaryWrapper` implementation.
1145114511461146`wrapProgram` is a convenience function you probably want to use most of the time, implemented by both `makeWrapper` and `makeBinaryWrapper`.
1147114711481148Using 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.
11491149+11501150+However, `makeWrapper` is more flexible and implements more arguments.
11511151+Use `makeWrapper` if you need the wrapper to use shell features (e.g. look up environment variables) at runtime.
1149115211501153### `remove-references-to -t` \<storepath\> [ `-t` \<storepath\> ... ] \<file\> ... {#fun-remove-references-to}
11511154
+12-2
pkgs/build-support/setup-hooks/make-wrapper.sh
···2222# --unset VAR : remove VAR from the environment
2323# --chdir DIR : change working directory (use instead of --run "cd DIR")
2424# --run COMMAND : run command before the executable
2525-# --add-flags ARGS : prepend ARGS to the invocation of the executable
2525+# --add-flag ARG : prepend the single argument ARG to the invocation of the executable
2626# (that is, *before* any arguments passed on the command line)
2727-# --append-flags ARGS : append ARGS to the invocation of the executable
2727+# --append-flag ARG : append the single argument ARG to the invocation of the executable
2828# (that is, *after* any arguments passed on the command line)
2929+# --add-flags ARGS : prepend ARGS verbatim to the Bash-interpreted invocation of the executable
3030+# --append-flags ARGS : append ARGS verbatim to the Bash-interpreted invocation of the executable
29313032# --prefix ENV SEP VAL : suffix/prefix ENV with VAL, separated by SEP
3133# --suffix
···164166 contents="$(cat "$fileName")"
165167 addValue "$p" "$varName" "$separator" "$contents"
166168 done
169169+ elif [[ "$p" == "--add-flag" ]]; then
170170+ flags=${params[n + 1]@Q}
171171+ n=$((n + 1))
172172+ flagsBefore="${flagsBefore-} $flags"
173173+ elif [[ "$p" == "--append-flag" ]]; then
174174+ flags=${params[n + 1]@Q}
175175+ n=$((n + 1))
176176+ flagsAfter="${flagsAfter-} $flags"
167177 elif [[ "$p" == "--add-flags" ]]; then
168178 flags="${params[$((n + 1))]}"
169179 n=$((n + 1))