Some mathematicians worked out a way to fairly do districting, similar to having one kid cut the cake and the other kid gets first choice:
"A partisan districting protocol with provably nonpartisan outcomes" by Wesley Pegden, Ariel D. Procaccia, Dingli Yu https://arxiv.org/abs/1710.08781