Heat pan to medium.
Toast the nuts for 4-5 minutes until they start turning brown and releasing aromas. Remove from the pan.
Add whole spices, if using, and toast for 20-40 seconds minutes. Remove from the pan.
Lastly, toast the sesame seeds.
Add nuts to the spice grinder and press a few times. Check the texture - it should be coarse but without too large pieces. Pulse a couple of more times if required and transfer to a mixing bowl.
If using whole spices, add them to the grinder together with salt and ground spice. Pulse a few time to just break them. Transfer to the mixing bowl with nuts.
Add the roasted sesame seeds to the bowl and mix everything together.
You can safely store dukkah for a few months in an airtight container.