Heat a skillet over medium high heat and cook onions, thyme, and bay leaf in butter for 5 minutes; season with salt and pepper, lower heat and cook until onions are browned, about 10 to 15 minutes, transfer to a plate, discard bay leaf.
Meanwhile, bring a large pot of salted water to a boil, add pasta and cook until al dente; drain and return to pot.
Melt 2 tablespoons butter in the skillet over medium heat.
Whisk in flour for about a minute, then whisk in chicken stock and milk and bring to a boil.
Season with salt, pepper, nutmeg, lower heat and cook until thickened, about 5 minutes.
Stir in cheese to melt.
Combine onions and cheese sauce with pasta and toss.