replaceVars
pkgs.replaceVars
Functor
Docs pulled from | This Revision | 35 minutes ago
replaceVars
is a wrapper around the bash function substitute
in the stdenv. It allows for terse replacement of names in the specified path, while checking
for common mistakes such as naming a replacement that does nothing or forgetting a variable which
needs to be replaced.
As with the --subst-var-by
flag, names are encoded as @name@
in the provided file at the provided path.
Any unmatched variable names in the file at the provided path will cause a build failure.
Any remaining text that matches @[A-Za-z_][0-9A-Za-z_'-]@
in the output after replacement
has occurred will cause a build failure.
Inputs
path
(Store Path String)- The file in which to replace variables.
attrs
(AttrsOf String)- Each entry in this set corresponds to a
--subst-var-by
entry insubstitute
.
Example
{ replaceVars }:
replaceVars ./greeting.txt { world = "hello"; }
See ../../test/replace-vars/default.nix
for tests of this function.