1. Be willing to pay them obscene amounts of money. Yes, this means more than the next employer is willing to pay. No matter what folks say, size does matter. Salary is just a way of keeping score.
2. Creative Freedom - don't do endless micromanaging on coding style, and restricting open source from being used.
3. Free energy - ample supply of caffeine and sugary snacks goes a long way
4. Technology Stipend - Good craftsmen understand that they need the best tools to do their jobs. Don't stick them with some random corporate IT-issued desktop with Windows98 on it.
5. Stroke their ego about once a week.
The truly good companies that are able to attact and retain the smartest developers are all good at some combination of the 5 items above.
The party adjourned to a hot tub, yes. Fully clothed, I might add. -- IBM employee, testifying in California State Supreme Court