diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index d470f69d033df..fd4f819e67f4f 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -1223,10 +1223,19 @@ Example removing all references to the compiler in the output: ### `runHook` \ {#fun-runHook} -Execute \ and the values in the array associated with it. The array's name is determined by removing `Hook` from the end of \ and appending `Hooks`. +Execute \ and the values in the array associated with it. The array's name is determined by removing `Hook` from the end of \ 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` \ {#fun-runOneHook} + +Run all hooks that `runHook` would, but exit after the first successful hook. +Failing hooks are ignored. + +### `echoCmd` \ \ {#fun-echoCmd} + +Print (but don't execute) a command and unambiguously mark word splits. + ### `substitute` \ \ \ {#fun-substitute} Performs string substitution on the contents of \, writing the result to \. The substitutions in \ are of the following form: diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 98eeded49b8c4..059efb58e174e 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -200,6 +200,11 @@ _logHook() { # were added, stopping if any fails (returns a non-zero exit # code). The hooks for are the shell function or variable # , and the values of the shell array ‘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 @@ -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 @@ -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