HDF

HDF Examples

This page showcases common real-world use cases for HDF and the LUTX toolchain.

1. Nginx Virtual Host Generation

HDF is perfect for managing many similar virtual host configurations.

Data (vhosts.hdf)

(vhosts
  (vhost
    (domain "example.com")
    (root "/var/www/example")
    (php true)
  )
  (vhost
    (domain "api.example.com")
    (root "/var/www/api")
    (php true)
  )
)

Template (nginx.lutx)

{{ 
  local hosts = hdf_query("vhosts.vhost")
  for _, h in ipairs(hosts) do
    local cfg = string.format([[
server {
    listen 80;
    server_name %s;
    root %s;
    index index.php index.html;
}]], h.domain, h.root)
    
    save("sites-enabled/" .. h.domain .. ".conf", cfg)
  end
}}

2. Docker Compose with Environment Selection

Use HDF to maintain a single source of truth for different environments (Staging vs. Production).

Data (env.hdf)

(environments
  (prod
    (image "webapp:v2.5.0")
    (replicas 5)
    (db_host "db.prod.internal")
  )
  (staging
    (image "webapp:latest")
    (replicas 1)
    (db_host "localhost")
  )
)

Command

./bin/lutx --dataset env.hdf --simple-query 'environments.(prod)' docker-compose.tpl

3. Complex Data Exports (CSV Replacement)

Exporting complex state that CSV cannot handle.
(audit_log
  (event
    (timestamp "2026-02-19T10:00:00Z")
    (user "admin")
    (action "login")
    (metadata
      (ip "1.2.3.4")
      (user_agent "Mozilla/5.0...")
    )
  )
)

4. Protobuf Schema Definitions

Define your schemas in HDF and generate .proto files for different services.
(message User
  (field int32 id 1)
  (field string email 2)
  (field bool active 3)
)