spack/share/spack
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
..
bash Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
bootstrap bootstrap: add clingo 3.13 binaries and more (#47126) 2024-10-24 08:55:14 +02:00
csh Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
docker Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
docs/docker/module-file-tutorial Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
fish Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
gitlab/cloud_pipelines Revert "CI: Set the cache path for all platforms (#49373)" (#49381) 2025-03-08 08:29:05 +01:00
keys update tutorial command for v0.18.0 and new gpg key (#30904) 2022-05-28 02:36:20 +00:00
logo add artisanal handcrafted SVG Spack logo. (#6165) 2017-11-06 22:42:16 -08:00
qa Assign priorities to configuration scopes (take 2) (#49187) 2025-02-26 10:52:19 -08:00
templates Don't inject import statements in package recipes 2024-12-05 12:48:00 -08:00
setup-env.bat Normalize Spack Win entry points (#38648) 2024-10-25 15:23:29 -04:00
setup-env.csh Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
setup-env.fish Fix setup.fish syntax (#49176) 2025-02-25 07:11:55 -06:00
setup-env.ps1 Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
setup-env.sh Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
setup-tutorial-env.sh Remove years from license headers (#48352) 2025-01-02 15:40:28 +01:00
spack-completion.bash spack verify libraries: verify dependencies of installed packages can be resolved (#49124) 2025-02-24 11:28:06 +01:00
spack-completion.fish Support independent includes with conditional, optional, and remote entries (#48784) 2025-03-09 19:33:44 -07:00