I am assuming that you contracted to have a home built for a sum you both agreed on. Did you give the earnest money to the builder (something most Realtors tell you to avoid) or did an agent get it? The agent has rules they must obey, while a builder will likely put the money into the operating account and so it is much harder to get back.
The lender will not lend more than what the appraisal came in at, so someone has to make up the difference somehow. The easiest way is for Mr Builder to reduce the sales price to the amount of the appraisal. Another option is for you both to eat some and split it or come up with a price agreeable to you both. The builder could drop some and you could pay more down.
I just hope you did not give the builder the $8000.... more