diff --git a/doc/stdenv.xml b/doc/stdenv.xml
index c78bc0933e2..cb2bab690a5 100644
--- a/doc/stdenv.xml
+++ b/doc/stdenv.xml
@@ -845,6 +845,16 @@ following:
Defaults to man doc info.
+
+ setupHook
+ A package can export a setup hook by setting this
+ variable. The setup hook, if defined, is copied to
+ $out/nix-support/setup-hook. Environment
+ variables are then substituted in it using substituteAll.
+
+
preFixupHook executed at the start of the fixup
@@ -921,6 +931,154 @@ the doDist is not set.
+Shell functions
+
+The standard environment provides a number of useful
+functions.
+
+
+
+
+
+ ensureDirargs
+ Creates the specified directories, including all
+ necessary parent directories, if they do not already
+ exist.
+
+
+
+
+ substitute
+ infile
+ outfile
+ subs
+
+
+ Performs string substitution on the contents of
+ infile, writing the result to
+ outfile. The substitutions in
+ subs are of the following form:
+
+
+
+
+ s1
+ s2
+ Replace every occurence of the string
+ s1 by
+ s2.
+
+
+
+
+ varName
+ Replace every occurence of
+ @varName@ by
+ the contents of the environment variable
+ varName. This is useful for
+ generating files from templates, using
+ @...@ in the
+ template as placeholders.
+
+
+
+
+ varName
+ s
+ Replace every occurence of
+ @varName@ by
+ the string s.
+
+
+
+
+
+
+ Example:
+
+
+substitute ./foo.in ./foo.out \
+ --replace /usr/bin/bar $bar/bin/bar \
+ --replace "a string containing spaces" "some other text" \
+ --subst-var someVar
+
+
+
+
+ substitute is implemented using the
+ replace
+ command. Unlike with the sed command, you
+ don’t have to worry about escaping special characters. It
+ supports performing substitutions on binary files (such as
+ executables), though there you’ll probably want to make sure
+ that the replacement string is as long as the replaced
+ string.
+
+
+
+
+
+
+ substituteInPlace
+ file
+ subs
+ Like substitute, but performs
+ the substitutions in place on the file
+ file.
+
+
+
+
+ substituteAll
+ infile
+ outfile
+ Replaces every occurence of
+ @varName@, where
+ varName is any environment variable, in
+ infile, writing the result to
+ outfile. For instance, if
+ infile has the contents
+
+
+#! @bash@/bin/sh
+PATH=@coreutils@/bin
+echo @foo@
+
+
+ and the environment contains
+ bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39
+ and
+ coreutils=/nix/store/68afga4khv0w...-coreutils-6.12,
+ but does not contain the variable foo, then the
+ output will be
+
+
+#! /nix/store/bmwp0q28cf21...-bash-3.2-p39/bin/sh
+PATH=/nix/store/68afga4khv0w...-coreutils-6.12/bin
+echo @foo@
+
+
+ That is, no substitution is performed for undefined variables.
+
+
+
+
+ stripHash
+ path
+ Strips the directory and hash part of a store
+ path, and prints (on standard output) only the name part. For
+ instance, stripHash
+ /nix/store/68afga4khv0w...-coreutils-6.12 print
+ coreutils-6.12.
+
+
+
+
+
+
+
+
Package setup hooksThe following packages provide a setup hook: