Negative reinforceme. You may want to try "negative reinforcement" which is essentially a punishment every time you do it. You can put on a nail polish or something else that tastes bad. Then every time you bite your nails, you experience a bad taste. This may help you stop.
Onychophagia. Treating the underlying anxiety - or possibly bipolar disorder - can go a long way in helping. For those with generalized anxiety disorder, Buspirone can be very effective. If hypomania, mood stabilization may assist. Cognitive behavior therapies would emphasize alternative means of anxiety relief including relaxation protocols, distress tolerance strategies, and exposure. Rub a worry stone?