Preheat oven to 375°F and butter a 9x13 inch baking dish.
Make roux by melting butter in a saucepan, whisking in flour, and cooking 1 minute until toasted.
Add milk and cream slowly while whisking. Stir in garlic, salt, pepper, and nutmeg. Cook until thickened, about 5 minutes.
Remove from heat and stir in half the cheddar and all the Gruyere until smooth.
Layer half the potatoes and onions in the dish, pour half the sauce over top. Repeat with remaining potatoes, onions, and sauce. Top with remaining cheddar.
Cover tightly with foil and bake 45 minutes. Uncover and bake 30-40 minutes more until potatoes are tender and top is golden.
Rest 10-15 minutes before serving to let sauce thicken.