The weakly nonlinear dynamics of long waves embedded in marginally stable shear flows that vary in the streamwise direction are shown to be governed by a variable-coefficient Boussinesq equation. Depending on the local stability characteristics of the flow, new nonmodal or modal instabilities may emerge that serve as natural mechanisms for achieving amplitude thresholds necessary for weakly nonlinear instability and the transition to fully finite-amplitude states.