In a small bowl, whisk together the flour, rosemary, salt and cayenne (if using).
In the bowl of a stand mixer with the paddle attachment (or you can use a rubber spatula and some arm strength), beat the softened butter and shredded cheese until well combined. Scrape down the sides.
Add the dry ingredients, and beat until the flour is incorporated and the mixture looks crumbly. Scrape down the sides. Drizzle in 2 teaspoons of water and beat until the mixture sticks together into a rough dough.
Transfer the dough to a work surface and shape it into a 10 to 11-inch long log (about 1 ½ inches in diameter). In a small bowl, beat the egg with 1 teaspoon of water. Brush the egg wash all over the log of dough (you won’t need it all). Spread the walnuts out onto a piece of parchment paper, and roll the dough in the walnuts to coat, pressing the walnuts gently to adhere.
Wrap the dough with plastic wrap and refrigerate it for at least 1 hour or for up to 48 hours. Do Ahead: The dough can be refrigerated for up to 2 days or frozen for up to 2 months. If freezing, place the wrapped log in a freezer bag or airtight container to prevent freezer burn. Defrost the dough in the refrigerator overnight.
Preheat the oven to 350˚F (175˚C). Line 2 large baking sheets with parchment paper.
Slice the dough into ¼-inch thick rounds and arrange them on the prepared baking sheets, spacing them 2 inches apart. Bake the wafers, rotating the pan positions halfway through, until they’re light golden on the edges, about 11-13 minutes. Let the wafers cool on the pans for a few minutes, then transfer them to a rack and let them cool completely (they will firm up as they cool). Transfer the cooled wafers to a platter, and serve.
Do Ahead: The log of dough can be tightly wrapped and frozen for up to 2 months. Defrost it overnight in the fridge. Once baked, the wafers can be frozen for up to 1 month (defrost them at room temperature before serving).