Scrub the walls with warm, soapy water and a bristle brush. This will remove any topical residue.
Mix a solution of warm water and ammonia. Mix ½ cup of ammonia to 1 gallon of water. For tough jobs, it's safe to mix up to a 50-50 solution of ammonia and water.
Wash the walls with a clean bristle brush and the ammonia solution. Let it dry completely.
Seal the walls with a shellac-based primer/sealer. Allow this layer to dry completely. If you notice glaring imperfections, or old layers of paint showing through, apply another layer and let it dry completely before applying the paint.
Paint the walls with high-quality, latex-based acrylic enamel paint. Apply at least two coats. Once the paint has dried completely, you should no longer be able to smell cigarette smoke.