Constraining dark matter candidates from structure formation