The answer is yes. However, you will have to take into account that you won’t have many absences from the country, as this could be detrimental to your application for Spanish nationality. Depending on your nationality, you will be able to apply for a Spanish passport after 2 or 10 years of residence.