I could never get into nix on Mac os. Maybe it's a different thing if you use nixOS but I'm not willing to make that jump. It seems the clear barrier to entry to nix is UX and to an extent the custom language they use. Maybe this problem can be solved with LLMs. We need an LLM fine tuned to write nix language.
Package management on macOS with Nix-Darwin
21–30 of 33 posts
Re: Package management on macOS with Nix-Darwin
#22I have all the love and appreciation in the world for enjoying a weekend spent in configuration files. But I feel the need to state the obvious: This is a long blog post ending with a preview to "future installments of the guide" to use nix, while almost everything that you need to know with homebrew is `brew install/update/upgrade/uninstall`, and I have rarely run into any trouble with brew, and none at all in recen…
With nix, each project can define its own dependencies that have no impact on other projects. Combined with direnv, all you need is to `cd` into your project and you have the all of the dependencies at the right versions in your PATH.
Additionally, while definitely more complicated, nix (with nix-darwin and home-manager) can do way more than homebrew does. You can declaratively define pretty much the entire configuration for your machine.
I got a new Mac last week and with just a `git clone` and a few commands I had all my CLI tools installed, dotfiles setup, desktop apps installed, and even all of my macOS system settings configured.
Re: Package management on macOS with Nix-Darwin
#23Earlier quoted context omitted.
I use it to install a bunch of Homebrew casks and a small number of regular packages to support those casks. It works perfectly well! My biggest annoyance is that Homebrew is really slow; the Homebrew part of my Nix-Darwin rebuilds usuay takes 3-5x as long as everything else combined. Homebrew is really slow even when it has nothing to do. The only caveat worth mentioning is that the module built into Nix-Darwin does…
Make sure you are disabling auto-update and auto-upgrade for most of the homebrew slowness. I like to roll the update/upgrade into a single, intentional call rather than rely on homebrews built-in logic.
https://github.com/LnL7/nix-darwin/blob/230a197063de9287128e...
and
https://github.com/LnL7/nix-darwin/blob/230a197063de9287128e...
By default, brew commands run manually do still perform the automatic updates, though. That can be disabled with the following Nix-Darwin option: https://daiderd.com/nix-darwin/manual/#opt-homebrew.global.a...
Re: Package management on macOS with Nix-Darwin
#24I could never get into nix on Mac os. Maybe it's a different thing if you use nixOS but I'm not willing to make that jump. It seems the clear barrier to entry to nix is UX and to an extent the custom language they use. Maybe this problem can be solved with LLMs. We need an LLM fine tuned to write nix language.
Re: Package management on macOS with Nix-Darwin
#25I tried setting up nix-darwin with home-manager, but it just made the system more confusing to operate. Ended up using home-manager standalone without flakes. Works like a charm.
Re: Package management on macOS with Nix-Darwin
#26Earlier quoted context omitted.
Make sure you are disabling auto-update and auto-upgrade for most of the homebrew slowness. I like to roll the update/upgrade into a single, intentional call rather than rely on homebrews built-in logic.
That's the default for Nix Darwin's Homebrew module, see: https://github.com/LnL7/nix-darwin/blob/230a197063de9287128e... and https://github.com/LnL7/nix-darwin/blob/230a197063de9287128e... By default, brew commands run manually do still perform the automatic updates, though. That can be disabled with the following Nix-Darwin option: https://daiderd.com/nix-darwin/manual/#opt-homebrew.global.a...
Re: Package management on macOS with Nix-Darwin
#27Earlier quoted context omitted.
I'm recently back on macOS for work, and I wanted to love nix-darwin, but just couldn't get it even installed / basics running well enough to start to enjoy configuring things with it. The whole flakes mess really doesn't help. (Maybe if you're already running NixOS and familiar with the latest it's a lot easier.) I couldn't even uninstall it cleanly, since the Mac was new I gave up after some time and decided it was…
The hardest part of Nix module systems for foreign operating systems, like Nix-Darwin and Home Manager, is absolutely installing them. The difficult bits are the bits they don't control— the parts where they plug into the underlying OS. If you wanna give Nix-Darwin another go, I'm happy to help. Feel free to hit me up in the main Nix / NixOS channel or the Nix on macOS channel on Matrix. Getting everything working sh…
1) on install, nix-darwin complains about the nix.conf that determinate sets up
2) on uninstall, determinate complains about nix-darwin being installed
Re: Package management on macOS with Nix-Darwin
#28Earlier quoted context omitted.
That's the default for Nix Darwin's Homebrew module, see: https://github.com/LnL7/nix-darwin/blob/230a197063de9287128e... and https://github.com/LnL7/nix-darwin/blob/230a197063de9287128e... By default, brew commands run manually do still perform the automatic updates, though. That can be disabled with the following Nix-Darwin option: https://daiderd.com/nix-darwin/manual/#opt-homebrew.global.a...
I'm not sure whats taking so long then. My entire darwin-rebuild switch takes ~1s without the homebrew commands. If I manually run homebrew separately it takes ~4s the first time and ~1.5s in subsequent runs.
The other problem is that each brew invocation is slow, and I have to invoke it twice before I can even call that script, due to some quirks of how my Homebrew prefix is set up.
Idk, maybe I'll just... not. I'm not currently actually using any KDE apps on Mac.
Re: Package management on macOS with Nix-Darwin
#29Earlier quoted context omitted.
The hardest part of Nix module systems for foreign operating systems, like Nix-Darwin and Home Manager, is absolutely installing them. The difficult bits are the bits they don't control— the parts where they plug into the underlying OS. If you wanna give Nix-Darwin another go, I'm happy to help. Feel free to hit me up in the main Nix / NixOS channel or the Nix on macOS channel on Matrix. Getting everything working sh…
Any advice on getting the determinate installer and nix-darwin (via flakes) to be more seamless together? I have a decent setup, but the install/remove is clunkier than it needs to be because 1) on install, nix-darwin complains about the nix.conf that determinate sets up 2) on uninstall, determinate complains about nix-darwin being installed
a. build darwin-rebuild from the Nix-Darwin flake
b. do a darwin-rebuild build --flake of the target system
c. delete all of the files Nix-Darwin will complain about colliding with upon first install, including `/etc/nix/nix.conf`
d. run the activation scripts in the built system directly, like
./result/activate-user
sudo ./result/activate
For (d), make sure you run them in that order because it's actually the user activation script which ensures that /run/current-system exists.For (c), just inspect the files in `result/etc` (or wherever you put the symlink to your built system, or directly from the Nix store) and compare them to what already exists in `/etc`, e.g.,
find result/etc/ -type l | sed -E 's|^result||g' | xargs -I{} sh -c "test -f '{}' && echo '{}'"
should give you a list of files to nuke or back up or whatever, if you're trying to automate this.2. Nix-Darwin has its own uninstaller whose job is to go remove all the references to `/etc/static` from `/etc` and some launchd crap, which are the bits and pieces that the Determinate Nix Installer finds and complains about when you try to uninstall Nix with an active Nix-Darwin installation. The uninstaller gets installed by default (try `less $(which darwin-uninstaller)`), but if it's missing for some reason you can also run it from the flake like `nix run github:LnL7/nix-darwin#darwin-uninstaller`.
Re: Package management on macOS with Nix-Darwin
#30Without reading the article: I've used Nix on macOS without nix-darwin or home-manager for some time now. I define my packages in a flake.nix that exports an environment and I use install using `nix profile`.