Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion doc/stdenv/stdenv.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -1223,10 +1223,19 @@ Example removing all references to the compiler in the output:

### `runHook` \<hook\> {#fun-runHook}

Execute \<hook\> and the values in the array associated with it. The array's name is determined by removing `Hook` from the end of \<hook\> and appending `Hooks`.
Execute \<hook\> and the values in the array associated with it. The array's name is determined by removing `Hook` from the end of \<hook\> and appending `Hooks`. Execution aborts on the first failing hook.

For example, `runHook postHook` would run the hook `postHook` and all of the values contained in the `postHooks` array, if it exists.

### `runOneHook` \<hook\> {#fun-runOneHook}

Run all hooks that `runHook` would, but exit after the first successful hook.
Failing hooks are ignored.

### `echoCmd` \<cmd\> \<args...\> {#fun-echoCmd}

Print (but don't execute) a command and unambiguously mark word splits.

### `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:
Expand Down
15 changes: 15 additions & 0 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ _logHook() {
# were added, stopping if any fails (returns a non-zero exit
# code). The hooks for <hookName> are the shell function or variable
# <hookName>, and the values of the shell array ‘<hookName>Hooks’.
#
# Documented in:
# - source: `doc/stdenv/stdenv.chapter.md`
# - stable docs: https://nixos.org/manual/nixpkgs/stable/#fun-runHook
# - unstable docs: https://nixos.org/manual/nixpkgs/unstable/#fun-runHook
runHook() {
local hookName="$1"
shift
Expand All @@ -219,6 +224,11 @@ runHook() {

# Run all hooks with the specified name, until one succeeds (returns a
# zero exit code). If none succeed, return a non-zero exit code.
#
# Documented in:
# - source: `doc/stdenv/stdenv.chapter.md`
# - stable docs: https://nixos.org/manual/nixpkgs/stable/#fun-runOneHook
# - unstable docs: https://nixos.org/manual/nixpkgs/unstable/#fun-runOneHook
runOneHook() {
local hookName="$1"
shift
Expand Down Expand Up @@ -283,6 +293,11 @@ _eval() {
# to split the command in three parts because the middle format string
# will be, and must be, repeated for each argument. The first argument
# goes before the ':' and is just for convenience.
#
# Documented in:
# - source: `doc/stdenv/stdenv.chapter.md`
# - stable docs: https://nixos.org/manual/nixpkgs/stable/#fun-echoCmd
# - unstable docs: https://nixos.org/manual/nixpkgs/unstable/#fun-echoCmd
echoCmd() {
printf "%s:" "$1"
shift
Expand Down
Loading