Live data from Hacker News

Going immutable on macOS, using Nix-Darwin

carette.xyz

41–50 of 80 posts

Re: Going immutable on macOS, using Nix-Darwin

#41
post #22

Earlier quoted context omitted.

That's mostly solved with env managers for python/ruby/node/..., takes at most a few minutes to fully set up and learn, and doesn't get constantly broken by macOS updates. Even for things like trying out a new shell you can temporarily move the dotfiles somewhere and restore them back and it still takes less time than converting everything to Nix.

This is my feeling too. Nix is a relatively high time investment for a tool that tries to do everything, when you might not need or want everything and using the specific language’s tooling is more than sufficient and quicker. It takes a few minutes to install and do `uv sync`, or `nvm install`, or whatever, on a repository on a new computer, and it just works. Until Nix gets there, and I’m skeptical it will because…

I think the comparison is "X-as-code", like with Terraform and other tools.

If you just want a throwaway VM, it's straightforward to create one through the UI cloud console. Whereas, terraform is nevertheless still a useful tool to use to manage VMs.

For stuff like installing development dependencies.. it's maybe not difficult to copy-and-paste instructions from a readme, but solutions like devcontainers or Nix's development shells can be useful even if costing more overhead.

Re: Going immutable on macOS, using Nix-Darwin

#42
post #8

I see this: > The consequence is me, spending a few hours debugging my environment instead of writing code. But then I also see this: > I’ve spent a lot of time recently moving my entire workflow into a declarative system using nix. I can see how this can be beneficial for someone who switches systems very often, reinstalls their OS from scratch very often, or just derives a lot of pleasure/peace of mind knowing that…

Nix is not worth it if all you want is configuring your home computer. The learning curve is steep and has a tall onboarding cliff. The only way you get positive ROI from Nix is either you enjoy the journey, or you use it to do more than just managing a single computer: you manage a fleet, you build thin application container images, you bundle all your software, you have devshells, repeatable tests and deploys, etc.…

It's worth it for me. I learnt and set up my home manager config once in 2024 and I now only occasionally make light tweaks. But I deploy it on every personal computer or remote development servers at my jobs (previous and current). Granted, I'm probably one of the handful of people in my community who uses nix, because it's too arcane - but I've already paid the cost.

Re: Going immutable on macOS, using Nix-Darwin

#43

Earlier quoted context omitted.

That's mostly solved with env managers for python/ruby/node/..., takes at most a few minutes to fully set up and learn, and doesn't get constantly broken by macOS updates. Even for things like trying out a new shell you can temporarily move the dotfiles somewhere and restore them back and it still takes less time than converting everything to Nix.

> Even for things like trying out a new shell you can temporarily move the dotfiles somewhere and restore them back... I think the closest mainstream UX for "you can try out this program without having to install it" is running a Docker image. :) I'd say Nix is second best at everything related to packages.

until you need to start combining things. Docker is conceptually a VM the encapsulates everything nicely, but it ironically doesn't "compose" nearly as well as nix flakes or shells. With Nix you start out with a base env and can trivially extend it hierarchically and jump up and down the tree super easily, and without having to roll your own microservice architecture each time just to get stuff to work together.

Re: Going immutable on macOS, using Nix-Darwin

#45

I've tried nix-darwin a time or two in the past. Every few years when homebrew makes a "hostile" change and I get upset I consider trying it again (now most recently with changes to gatekeeper). I think I'll get to doing so in the next year or so. But I think just in fairness, the comparison here for flakes should be to Homebrew bundles. My packages are managed in a bundle: https://github.com/Julian/dotfiles/blob/mai…

> the comparison here for flakes should be to Homebrew bundles.

The bundler integration for nix-darwin actually just bakes tightly-controlled Brewfiles. It’s still worthwhile though, since part of the “tightly-controlled” means better cleanup when you remove things.

Re: Going immutable on macOS, using Nix-Darwin

#46

Earlier quoted context omitted.

In the six years you are using your computer, do you ever expect to run into versioning issues and conflicts? Homebrew packages conflicting with local packages, something you compile give needs a different python/ruby/node/rust/whatever version that you have locally installed, you want to quickly try out a new package or upgrade without changing your system but have the option of rolling back safely, need to quickly…

That's mostly solved with env managers for python/ruby/node/..., takes at most a few minutes to fully set up and learn, and doesn't get constantly broken by macOS updates. Even for things like trying out a new shell you can temporarily move the dotfiles somewhere and restore them back and it still takes less time than converting everything to Nix.

Fully spot on, I don't get what is that hard to set a couple of environment variables, and mayby symbolic links, depending on the OS and language being used.

A simple UNIX script or PowerShell utility takes care of it.

None of the ones I have used during the last decades has ever grown to more than like 20 lines of code, minus comments.

Re: Going immutable on macOS, using Nix-Darwin

#47

Earlier quoted context omitted.

Nix is not worth it if all you want is configuring your home computer. The learning curve is steep and has a tall onboarding cliff. The only way you get positive ROI from Nix is either you enjoy the journey, or you use it to do more than just managing a single computer: you manage a fleet, you build thin application container images, you bundle all your software, you have devshells, repeatable tests and deploys, etc.…

Right. Nix is a wonderful technology. But I would not argue it is practical if you can afford "just fix it when it breaks". A nix setup more/less requires you to pay all the cost up front. I appreciate putting in the effort now so that I don't have to later for stuff like declarative dev environments. It's really nice to not have to copy-and-paste installation instructions from a README. -- I did like the point: unti…

Yeah, I'm a Nix user and fan but I'm still going to be stuck fixing it when it breaks. The biggest thing that I have to remind myself is that reproducible != "just works." Once you get to what you want, you're set but until then and every change after, there's a chance you'll be in the weeds.

At least from my usage, the fact that your configuration is all tied to whether the entirety of nixpkgs-unstable is working can be a real headache. Like recently when CMake was upgraded to 4.0, it took down a healthy handful of packages, which meant you couldn't update anything until things were resolved or you were really fluent in Nix hackery. (I was the former)

Re: Going immutable on macOS, using Nix-Darwin

#48

Earlier quoted context omitted.

> Even for things like trying out a new shell you can temporarily move the dotfiles somewhere and restore them back... I think the closest mainstream UX for "you can try out this program without having to install it" is running a Docker image. :) I'd say Nix is second best at everything related to packages.

until you need to start combining things. Docker is conceptually a VM the encapsulates everything nicely, but it ironically doesn't "compose" nearly as well as nix flakes or shells. With Nix you start out with a base env and can trivially extend it hierarchically and jump up and down the tree super easily, and without having to roll your own microservice architecture each time just to get stuff to work together.

Docker OTOH composes whole services nicely: if my project needs a redis cache and postgres instance, I don't have to faff about with local ports, traefik can pick up my web server, and so on. I use a flake to create and lock a local development toolchain, but it's no help in managing the services.

One thing I haven't tried yet is building a container from a flake, which would have obvious benefits for reproducibility. Still don't think it would help with service orchestration though.

Re: Going immutable on macOS, using Nix-Darwin

#49

I've tried nix-darwin a time or two in the past. Every few years when homebrew makes a "hostile" change and I get upset I consider trying it again (now most recently with changes to gatekeeper). I think I'll get to doing so in the next year or so. But I think just in fairness, the comparison here for flakes should be to Homebrew bundles. My packages are managed in a bundle: https://github.com/Julian/dotfiles/blob/mai…

Very nice, I think I'll be moving my "must-have" homebrew packages to a Brewfile. FYI tho, Homebrew no longer supports Brewfile.lock.json (it was always just a log anyway, not a lockfile). https://github.com/Homebrew/homebrew-bundle/pull/1509
Post reply on HN