The formation of a disk galaxy within a growing dark halo