A general perturbation theory for the description of weak damping of linear spin wave modes in magnetic nanostructures is developed. This perturbative approach allows one to account for the usual uniform Gilbert damping, as well as for the spatially nonuniform (coordinate-dependent) and nonlocal (magnetization-texture-dependent) Gilbert-like dissipation mechanisms. Using the derived general expression, it is possible to calculate the damping rate of a particular spin wave mode if the frequency and the spatial profile of this mode, along with the relevant parameters of a magnetic material, are known. The examples demonstrating the applications of the developed general formalism include: (i) generalization of the damping rate of a spin wave mode propagating in a magnetic sample for the case of a non-uniform static magnetization or/and bias magnetic field; (ii) calculation of a damping rate of a gyrotropic mode in a vortex-state magnetic nanodot; (iii) evaluation of the spin diffusion influence on the damping rate of spin-wave modes in a conducting ferromagnet; (iv) calculation of damping rates of spin-wave modes in a ferromagnetic film in the presence of a spin pumping into an adjacent non-magnetic metal layer. The developed formalism is especially useful in micromagnetic simulations, as it allows one to calculate damping rates of spin wave modes based on the numerical solution of a conservative eigenmode problem.