Evaluate a bash command (subshell) in a Dockerfile

Hello,

I am new to docker, and I am trying to create a self contained Dockerfile which fetches and installas always the latest version of the haxe compiler (it tries to discover the latest version from an online json file.) To discover that I would use a subshell in any shellscript and assign the latest version to an environment variable but it doesn’t look to work in a docker file.

Here the snippet of code which fails (wget find the whole curl with the $ unevaluated):

ENV HAXE_VERSION $(curl -s http://haxe.org/website-content/downloads/versions.json | python -c 'import json,sys;print json.loads(sys.stdin.read())["current"]' 2> /dev/null)
ENV HAXEURL http://haxe.org/website-content/downloads/$HAXE_LATEST/downloads/haxe-$HAXE_LATEST-linux64.tar.gz
RUN wget -O - $HAXEURL | tar xzf - --strip=1 -C $HAXEPATH

Did I miss any good practice or key feature?
I could for sure create a throwaway shell script and copy it inside but I don’t find that enough elegant, and I would like to avoid generating the Dockerfile being that still my first container.