Handlebars Support

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.

VariableDescriptionLinux/UnixmacOSWindows
{{dir.this}}Directory containing the current hermit.tomlSame on all platforms - absolute path to config directory
{{dir.hermit}}Root hermit configuration directorySame 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/stateNot availableNot 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_DIRNot availableNot available
{{dir.executable}}User executables directory (optional)$XDG_BIN_HOME, $XDG_DATA_HOME/../bin or ~/.local/binNot availableNot 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.

VariableEnvironment VariableDefault on LinuxNotes
{{dir.xdg_home}}$XDG_HOME$HOMEFallback to HOME if not set
{{dir.xdg_config}}$XDG_CONFIG_HOME~/.configUser configuration files
{{dir.xdg_data}}$XDG_DATA_HOME~/.local/shareUser data files
{{dir.xdg_cache}}$XDG_CACHE_HOME~/.cacheUser cache files
{{dir.xdg_state}}$XDG_STATE_HOME~/.local/stateUser state files (logs, history, etc.)
{{dir.xdg_bin}}$XDG_BIN_HOME~/.local/binUser 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 the install action

tag

The values of the detected tags as specified in tags:

  • arch - for example might be aarch64

sys

System information:

  • sys.cpu_num - Number of CPU cores
  • sys.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 hermitgrab
  • hermit.exe - Absolute path to the hermitgrab executable
  • hermit.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.