Arrange the bacon in a large skillet, then set it over medium-low heat. Cook until browned and crispy. Transfer the bacon to layers of paper towels to drain, then chop into bite-size pieces. Carefully remove the excess grease from the skillet, leaving 2 tablespoons bacon fat behind.
Add the thinly sliced onion and salt to the bacon fat. Cook over medium-low heat for about 15 minutes, stirring frequently, until very soft and deeply golden. Add small splashes of water as needed to loosen the browned bits from the skillet and prevent the onions from burning.
Push the caramelized onions toward one side of the skillet. Add the butter to the open area and allow it to melt. Add the garlic and sauté for about 1 minute, until fragrant.
Stir in the dry ditalini and beef stock. Increase the heat and bring the stock to a boil. Cover the skillet, reduce the heat to a gentle simmer, and cook for approximately 10 minutes, or until the pasta is tender.
Remove the lid and stir well. Most of the beef stock should be absorbed, although a small amount of liquid remaining in the skillet is perfectly fine. Add the heavy cream and black pepper and stir to combine. Increase the heat to medium-low.
Add the shredded Gruyère and sharp cheddar. Stir gently until both cheeses have completely melted and the sauce is smooth and creamy.
Remove the skillet from the heat and scatter the crispy chopped bacon over the top. Allow the mac and cheese to rest for a few minutes as the sauce thickens, then serve warm.
