By using the functional derivative technique we study the binding energies of on- and off-axis donors in compositionally modulated nanowires and in nanowires with variable thickness and different profiles of the cross-sections along the axis, in the presence of the external electric field applied parallel to the growth direction. We show that the electronic properties of donors in narrow non-homogeneous wires are very sensitive to the variation of their positions, the heterostructure geometry and the composition. Binding energy dependencies on the electric field strength, the barrier and well widths, the wire radius, as well as the donor position are consistently described using our formulation. Our simple method should be useful for analyzing a variety of more complex nanowire superlattice structures and nanowires with variable cross-section profiles, for which more rigorous approaches require extensive numerical calculations.