Krispy Kreme Doughnut is nearing a deal to acquire Insomnia Cookies in a move that would help the coffee and doughnut chain move beyond the glazed treats for which it is known, sources familiar with the situation tell CNBC.

The deal would be one further — albeit small — building block in the coffee and restaurant empire that European investment firm JAB Holding has been putting together. JAB, which acquired Krispy Kreme in 2016 for $1.35 billion, also owns Keurig Dr Pepper, Peet's Coffee & Tea and Panera Bread Co.

The deal, which values Insomnia Cookies at less than $500 million, could be announced within the next few weeks, the sources said.

The sources, who cautioned a deal could still fall apart, requested anonymity because the information is confidential. Krispy Kreme and Insomina weren't immediately available to comment.

Insomnia Cookies was founded in 2003 by University of Pennsylvania student Seth Berkowitz. Its stores, which stay open and deliver until 3:00 a.m., are often situated near college campuses, helping it to cater to late night revelers. It has more than 135 locations and sells cookies, brownies and cold milk.

Winston-Salem, North Carolina-based Krispy Kreme is known best for its signature fresh and hot glazed doughnuts that roll off its conveyor belts. It has nearly 1,400 retail shops in 32 countries.

Buying Insomnia Cookies would help Krispy Kreme reach more diners than its doughnut loyalists, as well as provide new delivery infrastructure.

There also could be opportunities to bundle the two products together, for example selling a day-old doughnut at a discount alongside an Insomnia Cookie.

Krispy Kreme's main rival, Dunkin' Donuts, has experimented with new menu items over the years in efforts bring in customers at different times of the day.