Passing Environment Variable as a Host header

I am generating a ha proxy config file using nix and I have a function which contains an argument host. The function uses the argument as follows:
http-check send meth GET uri ${endpoint} ver HTTP/1.1 hdr host ${host}
The value of the host is an environment variable.
The generated config file looks something like this
http-check send meth GET uri /endpoint ver HTTP/1.1 hdr host env(HOST_NAME)

However, the headers contain the literal string env(HOST_NAME) and aren’t getting resolved.