Nail holes are often an unavoidable part of cabinet assembly, and most cabinetmakers minimize their visual impact by using finish nails with heads that aren't much larger than their shanks. After sinking the heads with a nail punch, they fill the holes with wood filler. The filler is often a poor match for the wood color, but after sanding and finishing, the colors are close enough to blend, and because the holes are small, they all but disappear. The more fastidious craftsperson who isn't satisfied with this level of blending has other options.
Besides having a color that only approximates the wood it is designed to fill, conventional wood fillers aren't wood, and they don't accept stain in the same way. You can avoid using a conventional wood filler by making your own. A simple way to do it is to gather the dust left over after sanding the cabinet and mix it with a drop or two of clear lacquer. While it is still wet, force the mixture into the nail holes with your finger, then wait for the lacquer to dry. After sanding, the holes will blend more closely than if you had used a conventional filler.
A more time-consuming approach, but one that is necessary if you want to hide nail holes on a finished cabinet, is to extend the wood grain artificially over the holes by painting the grain with a stained finish, or glaze. This technique requires careful color-matching, an accurate artist's brush and a steady hand. You can mix any wood color in lacquer or varnish by adding the four basic wood tones, which are burnt and raw sienna and burnt and raw umber, in the correct proportions. After you've covered the holes, protect the glazing by applying a fresh coat of clear finish over the whole cabinet.
While nail holes are necessary under certain circumstances, there are times when you can avoid them by using different assembly techniques. Instead of nailing from the outside, glue and screw strips to the insides of the pieces as you fit them together and glue or nail the pieces from the inside. Most makers of fine cabinets employ this technique, not only because it hides the fasteners, but because it makes a stronger cabinet. You can even assemble trim pieces, which many craftspeople nail to the edges of the cabinet openings almost as an afterthought, in this way.