Preheat the oven to 375°F. Lightly grease the bottom and sides of an 8-inch cake pan.
Pour the cajeta over the bottom and sides of the cake pan using a brush or the back of a spoon (you can heat the cajeta very slightly in the microwave so that it is easier to spread).
Make the Cake:
Combine the sugar, flour, cocoa powder, baking soda, baking powder, and salt in a large bowl and whisk until well blended. In a separate bowl, whisk together the buttermilk, vegetable oil, egg, and vanilla. Add to the flour mixture, whisking until thoroughly combined. Pour the cake batter into the pan and set aside.
Make the Flan:
Combine the evaporated milk, condensed milk, eggs, vanilla, and salt in a blender and blend until there are no visible lumps. Pour gently over the cake batter.
Cover loosely with foil, place in a large baking dish, and fill the baking dish with hot water so that it comes halfway up the sides. Bake until a toothpick inserted into the center comes out clean, about 50 minutes.
Remove the cake pan from the baking dish and allow to cool for at least 4 hours or refrigerate overnight. To unmold, lightly pass a warm knife around the edge, place a plate or dish on top, and carefully but rapidly flip over. Garnish with the toasted nuts. Serve cold or at room temperature.
Photo: Ed Anderson © 2010
Reprinted with permission from My Sweet Mexico: Recipes for Authentic Pastries, Breads, Candies, Beverages, and Frozen Treats by Fany Gerson, copyright © 2010. Published by Ten Speed Press, a division of Random House, Inc