In a skillet, melt 2 tablespoons butter over medium-high heat. Stir in the onions, thyme and bay leaf for 5 minutes; season with salt and pepper. Lower the heat and cook until the onions are browned, 10 to 15 minutes. Transfer to a plate and discard the bay leaf. Reserve the skillet.
Meanwhile, bring a large pot of water to a boil, salt it, add the pasta and cook until al dente. Drain and return to the pot.
In the reserved skillet, melt the remaining 2 tablespoons butter over medium heat. Whisk in the flour for 1 minute, then whisk in the chicken stock and milk and bring to a boil; season with salt, pepper and nutmeg. Lower the heat and cook until thickened, about 5 minutes. Stir in the cheese until melted.
Combine the onions and sauce with the pasta and toss well.