Recently got my hands on the beautifully typeset Mastering Nim hardcopy - which uses the pixels nimble package in its code examples. Pixels depends on sdl2 dylib that is of x86_64 arch. Brew only installs arm64 arch dylibs. This leads to linker errors
Here is the workaround:
Install rosetta
/usr/sbin/softwareupdate --install-rosetta
Download homebrew that downloads x86_64
cd ~/Downloads
mkdir homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
'Install' this homebrew
sudo mv homebrew /usr/local/homebrew
Update your shell init - for example in ~/.zshrc
export PATH=/usr/local/homebrew/bin:$PATH
export DYLD_LIBRARY_PATH=/usr/local/homebrew/lib:$DYLD_LIBRARY_PATH
alias axbrew='arch -x86_64 /usr/local/homebrew/bin/brew'
Install sdl2 dependencies - this will take a while In a new terminal or after source ~/.zshrc
# sdl2 needs python-setuptools but brew doesn't install it automatically
axbrew install python-setuptools
axbrew install sdl2{,_gfx,_image,_mixer,_net,_ttf}
You should now be able to run the code examples from the book.