Self-trapping transition for a nonlinear impurity within a linear chain