Handlebars Support
Several fields in hermit.toml support Handlebars syntax for templating. This allows you to dynamically insert values into your configuration.
Standard Directory Variables
These variables are based on the directories crate and provide platform-appropriate paths.
| Variable | Description | Linux/Unix | macOS | Windows |
|---|---|---|---|---|
{{dir.this}} | Directory containing the current hermit.toml | Same on all platforms - absolute path to config directory | ||
{{dir.hermit}} | Root hermit configuration directory | Same on all platforms - absolute path to hermit root | ||
{{dir.home}} | User’s home directory | $HOME or /home/username | $HOME or /Users/username | {FOLDERID_Profile} or C:\Users\username |
{{dir.config}} | User configuration directory | $XDG_CONFIG_HOME or ~/.config | $HOME/Library/Application Support | {FOLDERID_RoamingAppData} or C:\Users\username\AppData\Roaming |
{{dir.data}} | User data directory | $XDG_DATA_HOME or ~/.local/share | $HOME/Library/Application Support | {FOLDERID_RoamingAppData} or C:\Users\username\AppData\Roaming |
{{dir.cache}} | User cache directory | $XDG_CACHE_HOME or ~/.cache | $HOME/Library/Caches | {FOLDERID_LocalAppData} or C:\Users\username\AppData\Local |
{{dir.state}} | User state directory (optional) | $XDG_STATE_HOME or ~/.local/state | Not available | Not available |
{{dir.preference}} | User preferences directory | $XDG_CONFIG_HOME or ~/.config | $HOME/Library/Preferences | {FOLDERID_RoamingAppData} or C:\Users\username\AppData\Roaming |
{{dir.runtime}} | Runtime directory (optional) | $XDG_RUNTIME_DIR | Not available | Not available |
{{dir.executable}} | User executables directory (optional) | $XDG_BIN_HOME, $XDG_DATA_HOME/../bin or ~/.local/bin | Not available | Not available |
{{dir.config_local}} | Local configuration directory | $XDG_CONFIG_HOME or ~/.config | $HOME/Library/Application Support | {FOLDERID_LocalAppData} or C:\Users\username\AppData\Local |
{{dir.data_local}} | Local data directory | $XDG_DATA_HOME or ~/.local/share | $HOME/Library/Application Support | {FOLDERID_LocalAppData} or C:\Users\username\AppData\Local |
XDG-Specific Variables
These variables are primarily for Linux/Unix systems and follow the XDG Base Directory Specification.
| Variable | Environment Variable | Default on Linux | Notes |
|---|---|---|---|
{{dir.xdg_home}} | $XDG_HOME | $HOME | Fallback to HOME if not set |
{{dir.xdg_config}} | $XDG_CONFIG_HOME | ~/.config | User configuration files |
{{dir.xdg_data}} | $XDG_DATA_HOME | ~/.local/share | User data files |
{{dir.xdg_cache}} | $XDG_CACHE_HOME | ~/.cache | User cache files |
{{dir.xdg_state}} | $XDG_STATE_HOME | ~/.local/state | User state files (logs, history, etc.) |
{{dir.xdg_bin}} | $XDG_BIN_HOME | ~/.local/bin | User executables |
{{dir.xdg_runtime}} | $XDG_RUNTIME_DIR | (none) | Runtime files; only available if env var is set |
Variables and Contexts
With Handlebars, you can access contextual information:
var
In an install action, the variables as specified in the hermit.toml:
name- The name of theinstallaction
tag
The values of the detected tags as specified in tags:
arch- for example might beaarch64
sys
System information:
sys.cpu_num- Number of CPU coressys.mem_total- Total memory available
env
All environment variables are available through the env context. For example, {{env.PATH}} would access the $PATH environment variable.
hermit
HermitGrab-specific information:
hermit.version- The version of hermitgrabhermit.exe- Absolute path to the hermitgrab executablehermit.ubi- Absolute path to the hermitgrab executable plus the arguments to execute ubi commands
Helpers
The helper function snippet allows you to reference the contents of a defined snippet.