diff --git a/lib/spack/docs/env_vars_yaml.rst b/lib/spack/docs/env_vars_yaml.rst new file mode 100644 index 00000000000..3fd2a881538 --- /dev/null +++ b/lib/spack/docs/env_vars_yaml.rst @@ -0,0 +1,34 @@ +.. Copyright Spack Project Developers. See COPYRIGHT file for details. + + SPDX-License-Identifier: (Apache-2.0 OR MIT) + +.. _env-vars-yaml: + +============================================= +Environment Variable Settings (env_vars.yaml) +============================================= + +Spack allows you to include shell environment variable modifications +for a spack environment by including an ``env_vars.yaml``. Environment +varaibles can be modified by setting, unsetting, appending, and prepending +variables in the shell environment. +The changes to the shell environment will take effect when the spack +environment is activated. + +for example, + +.. code-block:: yaml + + env_vars: + set: + ENVAR_TO_SET_IN_ENV_LOAD: "FOO" + unset: + ENVAR_TO_UNSET_IN_ENV_LOAD: + prepend_path: + PATH_LIST: "path/to/prepend" + append_path: + PATH_LIST: "path/to/append" + remove_path: + PATH_LIST: "path/to/remove" + + diff --git a/lib/spack/docs/environments.rst b/lib/spack/docs/environments.rst index 4ef3b67b63f..27f9a772e23 100644 --- a/lib/spack/docs/environments.rst +++ b/lib/spack/docs/environments.rst @@ -1000,6 +1000,28 @@ For example, the following environment has three root packages: This allows for a much-needed reduction in redundancy between packages and constraints. +------------------------------- +Modifying Environment Variables +------------------------------- + +Spack Environments can modify the active shell's environment variables when activated. The environment can be +configured to set, unset, prepend, or append using ``env_vars`` configuration in the ``spack.yaml`` or through config scopes +file: + +.. code-block:: yaml + + spack: + env_vars: + set: + ENVAR_TO_SET_IN_ENV_LOAD: "FOO" + unset: + ENVAR_TO_UNSET_IN_ENV_LOAD: + prepend_path: + PATH_LIST: "path/to/prepend" + append_path: + PATH_LIST: "path/to/append" + remove_path: + PATH_LIST: "path/to/remove" ----------------- Environment Views diff --git a/lib/spack/docs/index.rst b/lib/spack/docs/index.rst index 077b1e11cbd..07209b35861 100644 --- a/lib/spack/docs/index.rst +++ b/lib/spack/docs/index.rst @@ -75,6 +75,7 @@ or refer to the full manual below. packages_yaml build_settings environments + env_vars_yaml containers mirrors module_file_support