Building galaxy models with self-consistent prescriptions for stellar and nebular emission