Flavorful bacon end strips are the secret weapon in this rich weeknight pasta.
Cook bacon, onion, and garlic in a large straight-sided skillet over medium heat, stirring occasionally, until bacon is browned, about 10 minutes. Stir in chopped thyme. Remove from heat.
Meanwhile, in a large pot of salted boiling water, cook pasta until al dente, about 2 minutes less than according to package instructions. Drain, reserving 2 cups pasta water.
Melt butter in a small saucepan.Whisk in flour; cook until melted and smooth, about 1 minute. Slowly whisk in milk and 1/2 cup pasta water until smooth. Bring to a boil, remove from heat, and whisk in cheeses.
Return skillet to medium-high heat; add 1/2 cup pasta water and cook, scraping up browned bits, 1 to 2 minutes. Add cooked spaghetti and cheese sauce. Stir, adding remaining pasta water, 1/4 cup at a time, until sauce is creamy and evenly coats pasta. Taste and season as needed. Serve, sprinkled with pepper and thyme leaves.