MacOS Nix Setup (an alternative to Homebrew)

submited by
Style Pass
2021-07-13 20:00:27

I recently got a new Macbook, and began setting up the Nix package manager to install my developer toolset. I mainly did this to try and have a working setup without installing Homebrew. Since I ran into a few issues, I wanted to briefly document what I did and why in case others wanted to try the same.

The long answer: I’ve been frustrated with Homebrew’s user experience for years now, and used this opportunity to start afresh. The default non-Homebrew answer is the venerable MacPorts, which has been around for quite a while. Most people who aren’t functional programming or build system nerds should probably use MacPorts, as it has been around long enough to have good support documentation floating around the internet. Unfortunately I’m a sucker for hermetic builds 1, so I decided to try Nix.

In addition, Nix has one cool feature I haven’t seen anywhere else: temporarily installing packages using nix-shell. For example, I can install ripgrep inside a temporary shell, and the package is automatically cleaned up when I’m done:

Leave a Comment