Install scripts support several template variables that are dynamically replaced during processing:
$LOCATION(LocationId)Resolves to user-configured or default paths for common directories.
Available Location IDs:
ApplicationsPerformance - High-performance storage for app dataApplicationsCapacity - High-capacity storage for app dataDownloads - Download directoryDocuments - Documents directoryMedia - General media storagePhotos - Photo storageMusic - Music storageMovies - Movie storageShows - TV show storageVideos - Video storageVirtualizationPerformance - High-performance VM storageVirtualizationCapacity - High-capacity VM storageInstallMedia - Installation media storageVirtualDisks - Virtual disk storageExample:
"path": "$LOCATION(ApplicationsPerformance)/plex/data"
$RANDOM_STRING(length)Generates a random alphanumeric string of specified length. Useful for passwords, keys, and database names.
Example:
"password": "$RANDOM_STRING(12)"
$PARTNER_TOKEN([partnerId])A per-install credential for a partner app: an app whose API accepts only callers HexOS can vouch for. HexOS mints the value when the app is installed (signed with a HexOS key the partner holds the public half of), writes it into the env entry the macro sits in, keeps it across script updates and restore reinstalls like a generated secret, and never shows it to a script. The partner app checks it once at startup and then treats it as its API credential.
The argument is optional. Empty means the app being installed; a partner id names another registered partner, for a script that bundles one. Only a catalog script may use it: a custom script that asks for a partner token is refused.
Example:
"additional_envs": [
{ "name": "PARTNER_API_KEY", "value": "$PARTNER_TOKEN()" }
]
The env var's name is whatever the partner app reads. A hook or action script then calls the partner's API through ctx.partnerRequest and never handles the credential itself.
$SERVER_LAN_IPResolves to the server's LAN IP address. Useful for constructing URLs that point to services running on the TrueNAS server.
Example:
"additional_envs": [
{
"name": "ADVERTISE_IP",
"value": "http://$SERVER_LAN_IP:32400"
}
]
$SERVER_HOST_IDResolves to the server's unique host ID. This is particularly useful for constructing HexOS Tunnels (e.g., https://<host-id>.direct.hexos.com) for remote tunneled access to your apps and services.
Example:
{
"value": "https://$SERVER_HOST_ID.direct.hexos.com"
}
$APP_INSTALLED(appName)Checks if a specific app is installed on the TrueNAS system. Returns true if installed, false otherwise. The check is case-insensitive.
Example:
"$APP_INSTALLED(qbittorrent)" // Returns "true" or "false"
$QUESTION(key)Accesses user responses from installation questions. The value is replaced with the user's response, which can be a boolean, string, number, or empty. When used in conditional expressions, values are converted appropriately:
"true" or "false""false"Examples:
"enabled": "$QUESTION(enable_feature)" // Direct value replacement
"$IF($QUESTION(use_ssl), \"https\", \"http\")" // Boolean check
"$IF($QUESTION(port) != \"\", $QUESTION(port), \"8080\")" // Default value
$GPU_CONFIG()Automatically detects and configures GPU resources for applications. The macro queries the system's available GPUs and generates the appropriate TrueNAS GPU configuration object.
Basic Usage:
"resources": {
"gpus": "$GPU_CONFIG()"
}
Conditional Usage:
"gpus": "$IF($QUESTION(enable_gpu), '$GPU_CONFIG()', {'use_all_gpus': false})"
Detected Configurations & Expanded Values:
No GPU detected:
// System has no GPUs
"$GPU_CONFIG()" → {"use_all_gpus": false}
Intel integrated GPU detected:
// System has Intel UHD Graphics 770
"$GPU_CONFIG()" → {"use_all_gpus": true}
AMD GPU detected:
// System has AMD Radeon RX 6700 XT
"$GPU_CONFIG()" → {"use_all_gpus": true}
Single NVIDIA GPU detected (with drivers):
// System has NVIDIA RTX 4090
"$GPU_CONFIG()" → {
"use_all_gpus": true,
"nvidia_gpu_selection": {
"0000:01:00.0": {
"use_gpu": true,
"uuid": "GPU-8a5f3c21-b4e9-4d72-a123-456789abcdef"
}
}
}
Multiple NVIDIA GPUs detected (with drivers):
// System has 2x NVIDIA RTX A4000
"$GPU_CONFIG()" → {
"use_all_gpus": true,
"nvidia_gpu_selection": {
"0000:01:00.0": {
"use_gpu": true,
"uuid": "GPU-1a2b3c4d-5e6f-7890-abcd-ef1234567890"
},
"0000:02:00.0": {
"use_gpu": true,
"uuid": "GPU-9f8e7d6c-5b4a-3210-fedc-ba0987654321"
}
}
}
Mixed GPUs (Intel + NVIDIA with drivers):
// System has Intel UHD 770 + NVIDIA RTX 3060
"$GPU_CONFIG()" → {
"use_all_gpus": true,
"nvidia_gpu_selection": {
"0000:03:00.0": {
"use_gpu": true,
"uuid": "GPU-7c8d9e0f-1a2b-3c4d-5e6f-789012345678"
}
}
}
NVIDIA GPU without drivers (falls back to disabled):
// System has NVIDIA GPU but drivers not installed
"$GPU_CONFIG()" → {"use_all_gpus": false}
Common Use Cases:
NVIDIA Driver Update Steps:
NVIDIA drivers were installed already if this was a fresh install. However, if this system was adopted, or the drivers otherwise require manual updating, perform the following from within the TrueNAS UI:
docker.update with latest compatible NVIDIA drivers$IF(condition, trueValue, [falseValue])Provides conditional logic in install scripts. Evaluates a condition and returns different values based on the result.
Syntax Variations:
$IF(condition, trueValue, falseValue)$IF(condition, trueValue) - Returns empty string if false$IF(['condition1', 'condition2'], trueValue, falseValue, 'AND')$IF(['condition1', 'condition2'], trueValue, falseValue, 'OR')Supported Conditions:
true, false!condition$APP_INSTALLED(appName)$QUESTION(key)value1 == value2value1 != value2Example:
"additional_storage": [
"$IF($APP_INSTALLED(qbittorrent), '$MOUNTED_HOST_PATH($LOCATION(Downloads)/qbittorrent, /downloads)')",
"$IF($APP_INSTALLED(sabnzbd), '$MOUNTED_HOST_PATH($LOCATION(Downloads)/sabnzbd, /downloads)')",
"$IF($QUESTION(use_qbittorent), '$MOUNTED_HOST_PATH($LOCATION(Downloads)/qbittorent, /downloads/qbittorent)')",
...
]
Conditionally mounts download folders based on installed apps and user preferences
$MEMORY(percentage, minimum_mb)Dynamically allocates memory based on system resources. Takes the higher value between the percentage of system memory and the minimum specified in MB.
Example:
"memory": "$MEMORY(10%, 2048)"
This allocates either 10% of system memory or 2048MB, whichever is higher
$CPUS(percentage, minimum_cores)Sets the app's CPU limit from the server's CPU count. Takes the given percentage of the server's logical CPUs (threads), rounded down to whole CPUs, and never goes below the minimum. The result is also capped at the number of CPUs the server has, so a minimum larger than a small server can offer still installs.
percentage must include the % sign and be above 0 and at most 100.minimum_cores must be a whole number of at least 1.cpus requires.Example:
"resources": {
"limits": {
"cpus": "$CPUS(75%, 2)",
"memory": "$MEMORY(10%, 2048)"
}
}
Resulting values:
| Server CPUs | $CPUS(75%, 2) |
|---|---|
| 16 | 12 |
| 6 | 4 |
| 2 | 2 |
| 1 | 1 (capped at the server's CPUs) |
Use this for apps whose heavy work (indexing, transcoding, syncing a library) finishes sooner with more CPUs. A fixed number, such as "cpus": 2, is still the right choice for light apps.
$HOST_PATH(path)Creates a TrueNAS host path configuration object for predefined storage options.
Example:
"storage": {
"data": "$HOST_PATH($LOCATION(ApplicationsPerformance)/app/data)"
}
Expands to:
"storage": {
"data": {
"type": "host_path",
"host_path_config": {
"acl_enable": false,
"path": "/mnt/pool/apps/app/data"
}
}
}
$MOUNTED_HOST_PATH(host_path, container_path)Creates a TrueNAS host path configuration for additional storage mounts, mapping a host directory to a container path.
Example:
"additional_storage": [
"$MOUNTED_HOST_PATH($LOCATION(Movies), /movies)",
"$MOUNTED_HOST_PATH($LOCATION(Shows), /shows)"
]
Expands to:
"additional_storage": [
{
"type": "host_path",
"read_only": false,
"mount_path": "/movies",
"host_path_config": {
"acl_enable": false,
"path": "/mnt/pool/movies"
}
}
]