Yes, I ended up with a similar solution.
Would be nice if this would have been done by the configure_file though.