I learnt long-time ago package management and OSX don't mix. Instead I use a VM and run a linux variant on that using VirtualBox.
It's come a very long way. Linux is still nicer of course but with migration to ARM you're more likely to find ARM versions of the typical tools in brew rather than typical linux repositories (although that has also got much better in the last 2 years due to ARM gaining market share in the enterprise/datacentre market).
And since Virtualbox is not releasing ARM virtualisation on macOS, as of now the free mac virtualisation tools are quite poor.