spack/lib/spack/docs
Tamara Dahlgren 3f8dcfc6ed
Support independent includes with conditional, optional, and remote entries (#48784)
Supersedes #46792.
Closes #40018.
Closes #31026.
Closes #2700.

There were a number of feature requests for os-specific config. This enables os-specific
config without adding a lot of special sub-scopes.

Support `include:` as an independent configuration schema, allowing users to include
configuration scopes from files or directories. Includes can be:
* conditional (similar to definitions in environments), and/or
* optional (i.e., the include will be skipped if it does not exist).

Includes can be paths or URLs (`ftp`, `https`, `http` or `file`). Paths can be absolute or
relative . Environments can include configuration files using the same schema. Remote includes 
must be checked by `sha256`.

Includes can also be recursive, and this modifies the config system accordingly so that
we push included configuration scopes on the stack *before* their including scopes, and
we remove configuration scopes from the stack when their including scopes are removed.

For example, you could have an `include.yaml` file (e.g., under `$HOME/.spack`) to specify
global includes:

```
include:
- ./enable_debug.yaml
- path: https://github.com/spack/spack-configs/blob/main/NREL/configs/mac/config.yaml
  sha256: 37f982915b03de18cc4e722c42c5267bf04e46b6a6d6e0ef3a67871fcb1d258b
```

Or an environment `spack.yaml`:

```
spack:
  include:
  - path: "/path/to/a/config-dir-or-file"
    when: os == "ventura"
  - ./path/relative/to/containing/file/that/is/required
  - path: "/path/with/spack/variables/$os/$target"
    optional: true
  - path: https://raw.githubusercontent.com/spack/spack-configs/refs/heads/main/path/to/required/raw/config.yaml
    sha256: 26e871804a92cd07bb3d611b31b4156ae93d35b6a6d6e0ef3a67871fcb1d258b
```

Updated TODO:
- [x] Get existing unit tests to pass with Todd's changes
- [x] Resolve new (or old) circular imports
- [x] Ensure remote includes (global) work
- [x] Ensure remote includes for environments work (note: caches remote
      files under user cache root)
- [x] add sha256 field to include paths, validate, and require for remote includes
- [x] add sha256 remote file unit tests
- [x] revisit how diamond includes should work
- [x] support recursive includes
- [x] add recursive include unit tests
- [x] update docs and unit test to indicate ordering of recursive includes with
      conflicting options is deferred to follow-on work

---------

Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
Co-authored-by: Peter Scheibel <scheibel1@llnl.gov>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2025-03-09 19:33:44 -07:00
..
_gh_pages_redirect Use https for links (#19244) 2020-10-09 11:24:09 -05:00
_pygments Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
_static make empty _static directory "exist" to git 2014-01-09 14:03:32 +01:00
_templates docs: re-enable google analytics (#43974) 2024-05-02 21:56:19 -04:00
build_systems Docs/bugfix: correct return for Adding flags to configure (#48434) 2025-01-29 13:04:22 -08:00
example_files Implement an optional compiler bootstrapping phase 2019-09-13 22:57:15 -07:00
images Update release documentation (#46991) 2024-10-16 09:11:53 +02:00
tables build caches: collect files to relocate while tarballing w/o file (#48212) 2024-12-24 10:53:13 -07:00
.gitignore docs: Replace package list with packages.spack.io (#40251) 2023-10-01 05:36:22 +02:00
basic_usage.rst spack verify libraries: verify dependencies of installed packages can be resolved (#49124) 2025-02-24 11:28:06 +01:00
binary_caches.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
bootstrapping.rst Fix creating a bootstrap mirrors (#48252) 2025-01-27 22:37:29 +00:00
build_settings.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
build_systems.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
chain.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
command_index.in Rework command reference in docs, add spack commands command 2018-02-12 20:25:17 -08:00
conf.py Assign priorities to configuration scopes (take 2) (#49187) 2025-02-26 10:52:19 -08:00
config_yaml.rst Solver: Cache Concretization Results (#48198) 2025-02-28 12:42:00 -06:00
configuration.rst Support independent includes with conditional, optional, and remote entries (#48784) 2025-03-09 19:33:44 -07:00
containers.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
contribution_guide.rst Remove pipelines and images based on ppc64le (#48767) 2025-01-29 16:36:25 +01:00
developer_guide.rst Deprecate Spec.concretize/Spec.concretized in favor of spack.concretize.concretize_one (#47971) 2025-01-15 10:13:19 +01:00
environments.rst Support independent includes with conditional, optional, and remote entries (#48784) 2025-03-09 19:33:44 -07:00
extensions.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
features.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
frequently_asked_questions.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
getting_started.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
gpu_configuration.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
include_yaml.rst Support independent includes with conditional, optional, and remote entries (#48784) 2025-03-09 19:33:44 -07:00
index.rst Support independent includes with conditional, optional, and remote entries (#48784) 2025-03-09 19:33:44 -07:00
Makefile API Docs: fix broken reference targets 2021-07-16 08:30:56 -07:00
mirrors.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
module_file_generation.svg SC17: reworked module file tutorial section (#5657) 2017-11-12 00:27:20 -08:00
module_file_support.rst Add version attributes up_to_1, up_to_2, up_to_3 (#38410) 2025-01-15 13:07:17 +01:00
packages_yaml.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
packaging_guide.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
pipelines.rst Reproducer should deduce artifact root from concrete environment (#45281) 2025-02-21 10:46:43 -06:00
replace_conda_homebrew.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
repositories.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
requirements.txt build(deps): bump pytest from 8.3.4 to 8.3.5 in /lib/spack/docs (#49268) 2025-03-03 19:18:42 -06:00
signing.rst Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
spack.yaml Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00