Place the walnuts, pecans, almonds, cashews and pistachios on a rimmed baking sheet and spread out into an even layer.
In a spice grinder, food processor or high-speed blender, combine the fennel seed, red pepper flakes if using (omit if you don’t like spicy) and garlic powder. Pulse several times until a fine powder forms. Place in a small bowl and set aside.
Place a medium skillet over a medium-low heat and add the butter and rosemary. Cook until the butter melts. Remove from the heat.
Drizzle the melted butter mixture and maple syrup over the nuts. Toss to coat. Sprinkle the spice mixture over the nuts. Sprinkle with salt and pepper. Toss again to coat.
Bake, tossing the nuts every 5 minutes to make sure they toast evenly, until toasted and fragrant, about 20 minutes.
Taste the nuts and add more kosher salt if necessary. Allow to cool completely. Store the nuts in airtight containers in a cool dark place for up to 2 weeks. Enjoy!