78 points · by KolenCh · 2y ago · 32 comments
Thanks for posting the link to sponsor this work.
Here's a template config to get started:
https://github.com/juspay/nix-dev-home
---
That said, nix-darwin is still useful for doing system level things, like enabling Touch ID for `sudo`. I use that in my config: https://github.com/srid/nixos-config
- Located in the nix store, so not indexed by Spotlight
- Not signed so I have to grant permissions all over again when an app gets rebuilt
Available as a plug-and-play module for nix-darwin and home-manager: https://github.com/hraban/mac-app-util
EDIT: Hm seems to not affect every app.
Did you have any of these issues?
- Learn Nix
- Homebrew can be a pain. I've had several occasions where it broke something on my system with its magic. The main reason for this is its imperative (as opposed to declarative) nature. You can easily install things that clash with other software installed on your system.
- You can easily install different versions of the same software without having to worry about clashes
- Fully declarative configuration. You know exactly what is installed on your system at any time.
- Portable reproducible configuration. Imagine you get a new laptop. Because you have have your system configuration declared with nix and home-manager you can copy the configuration file, run install, and your system is set up, exactly the way the old one was.
- To add to the above, you can also do the same with non-MacOS systems if you make your config conditional on MacOS. I sometimes want to work on a remote Linux machine. I can set up a full dev environment with all the tools I use locally with a single command now.
Not nearly as reproducible but: this is something I’m working on. Stay tuned…
Declarative, reproducible, and no fiddling with macOS specific stuff.
Plus, we had instructions in our wiki for dealing with homebrew package installation failures and conflicts with macOS-installed versions of required software, needing to install other programs like Ruby version manager, etc to fix these issues. but with Nix I just setup a devshell and got the exact version we needed installed with no issues.
And this can be pinned and reproduced for every developer using Nix, eliminating the hassle for everyone.
A lot of people don’t realize Homebrew is spying on them every time they run it.
The docs have been updated too, https://docs.brew.sh/Analytics states
> Homebrew gathers anonymous analytics using InfluxDB. You will be notified the first time you run brew update or install Homebrew. Analytics are not enabled until after this notice is shown, to ensure that you can opt out without ever sending analytics data.
The other big issues are languages. Most compilers and what not will build artifacts linked to the Nix store, which can result in surprising side effects. I tried switching to pyenv using Nix but then I had strange side-effects when trying to use it with poetry. So now I just install all of my language tools using homebrew and have had zero issues since.
I.e. it “steals” those brew cask formula and automatically repackage them as nix packages.
A closely related usage would be macOS with nix with nix-darwin, and using nix-darwin config to includes brew casks. This way, nix-darwin assumes brew exists and uses brew to install those casks.
This does have a major distinction on where the applications actually located, where some applications would upset if it is not inside /Applications.