I've not really been in your situation, but my 5 y.o. dd also has peanut and tree nut allergies. Thankfully, she's not contact allergic, just by ingestion. With me making and taking her food/snacks most places, and explaining to her why she can't have what the other kids are having, we've not had any issues outside of our home.
Is your son allergic to all nuts? What about seeds? My daughter is allergic to peanut, walnut, pecan, pistachio, and cashew, but can eat almonds and seeds (sunflower, flax, pumpkin, sesame and chia are what we mostly use) freely. I bake a lot with almond and sunflower butter and the seeds for healthy, filling, portable snacks.
Other than cookies and homemade snack bars, I'll have to think some on other lightweight backpack ideas. Oh, what about making some jerkey? Or, if your hikes are only a few hours, what about cheesesticks or boiled eggs and some dried fruit?