The influence of a non-uniform medium on the Benjamin-Feir instability of weakly nonlinear deep-water waves has been investigated, and an approach via a suitable nonlinear Schrödinger equation was adopted. For the derivation of the relevant cubic Schrödinger equation. the approach of Yuen & Lake (1975) was followed and an applicable dispersion relation and energy equation was derived by the averaged Lagrangian technique. With the assumption that the lengthscale of current variation is much greater than the lengthscale of the wavepacket, a cubic Schrödinger equation with slowly varying coefficients is obtained. Three different examples of non-uniform media are treated: (i) waves on a current with variation along the stream; (ii) waves on a shear current; and (iii) long deep-water gravity waves interacting with shorter waves.