Live data from Hacker News

Using Nix on macOS

checkoway.net

61–70 of 116 posts

Re: Using Nix on macOS

#61

There is absolutely no way I can recommend using this at work. Nix is way too complicated. Its already bad enough being the git goto person. Nix is so complicated it somehow makes git look simple.

I completely disagree. It took me a while to work through the peculiarities of NixOS and get my OS setup, but the benefits are immense now that I'm using it. And I'm using it as a daily driver at a large tech company developing and maintaining mission critical systems. It's really no different from Vim in this respect. Most people will bounce off due to the learning curve, but once you get past it, the benefits are t…

Says the only person using vim

Re: Using Nix on macOS

#62

Something not mentioned here is that each and every single macOS update will break your Nix install too. This is, by far, the most frustrating part of using Nix on macOS.

Could you elaborate on what broke when you updated macOS? Granted, my Nix installation is a single-user installation (so it doesn't have the edited /etc/bashrc and /etc/zshrc that get overridden), but it worked without any issues after I updated from Big Sur to Monterey, so I'm curious about your experience. The only things that broke for me after the update were the xcode command-line tools, which break for everyone…

I imagine GP is talking about every macOS update forcibly overwriting /etc/zshrc.

They bothered writing a system capable of dropping the conflicted file in Relocated Items for us to optionally use--but they appear to be only using it for /etc/bashrc, and not /etc/zshrc. So, people who use zsh by choice or default get dumped on a bit :/

Some background in https://github.com/NixOS/nix/issues/3616

Re: Using Nix on macOS

#63
post #24

Perhaps what is missing is the book "Nix - The good parts". Not saying Nix is not good overall, but getting a condensed description what is worth knowing, leaving out what can be ignored or is obsolete, would be quite valuable.

Here you go: - don't use nix-env ever - enable and use the new nix command (nix3) - enable and use flakes - use home-manager - if on macOS, use nix-darwin - with flakes, freely use nixpkgs unstable (stable is still useful, but flakes provide their own stability through pinned versions).

And you do this to install MySQL?

Re: Using Nix on macOS

#64
post #15

This post focused solely on the Nix package manager and Nix packages - for anyone that uses MacOS but is interesting in trying NixOS (or using it within a VM in MacOS), I definitely recommend Mitchell Hashimoto's NixOS repo: https://github.com/mitchellh/nixos-config Honestly, doing that may be easier and a better option than using Nix packages in MacOS.

> Honestly, doing that may be easier and a better option than using Nix packages in MacOS. Respectfully, I disagree. I’ve been using Nix on a couple of my Macs, including on an M1, and I’ve cutdown my dependence on homebrew almost to the point of its absence; I rely more on Nix packages, than on Homebrew packages. Having said that, I still wouldn’t recommend anyone using Nix; steep learning curve, and too many rough…

I recently had tried to use Nix again after a hiatus. I wished to use Nix to replace Homebrew, but also for managing versions, of like Ruby or dotnet.

Sadly, it's not quite there for my needs, but it's getting better. Flakes are more fleshed out, the CLI is improving in it's user experience. I still don't feel like I understand the language works and build my flakes off of copying/pasting the one that works.

Re: Using Nix on macOS

#65

There is absolutely no way I can recommend using this at work. Nix is way too complicated. Its already bad enough being the git goto person. Nix is so complicated it somehow makes git look simple.

I completely disagree. It took me a while to work through the peculiarities of NixOS and get my OS setup, but the benefits are immense now that I'm using it. And I'm using it as a daily driver at a large tech company developing and maintaining mission critical systems. It's really no different from Vim in this respect. Most people will bounce off due to the learning curve, but once you get past it, the benefits are t…

> benefits are immense

Such as?

Re: Using Nix on macOS

#66
post #59

Earlier quoted context omitted.

Here you go: - don't use nix-env ever - enable and use the new nix command (nix3) - enable and use flakes - use home-manager - if on macOS, use nix-darwin - with flakes, freely use nixpkgs unstable (stable is still useful, but flakes provide their own stability through pinned versions).

I’m looking at nix-darwin but there is no explanation on what it actually does https://github.com/LnL7/nix-darwin

It's like a system-wide home-manager alternative for Darwin systems. Or the other way - a NixOS-like whole system management that works on top of Darwin.

For some examples: you can manage your homebrew packages, set keyboard preferences, trackpad settings, updates, finder defaults, etc through the nix config.

Re: Using Nix on macOS

#67
post #55
post #32

Earlier quoted context omitted.

This blog post follows IanTheHenry's method for declarative environments via nix-env, which was produced when Ian was following a methodology for learning Nix that deliberately eschewed engagement with the Nix community in favor of relying only on the official documentation. So it doesn't use flakes or any unofficial community tools that could make setup 'easier' in the sense of being a bit more ready-made. Anyway I…

I mean.. it sounds wrong[0]. I don't think flakes are really mandatory given that the status quo is stuff like brew, but home manager actually does "the thing" that Nix people are talking about. Without something like home manager or NixOS, you really are only halfway to what the actual pitch is for nix. (Aside: I can't imagine figuring out how to use nix just from the official documentation. Those documents are a to…

> I mean.. it sounds wrong[0]. I don't think flakes are really mandatory given that the status quo is stuff like brew, but home manager actually does "the thing" that Nix people are talking about. Without something like home manager or NixOS, you really are only halfway to what the actual pitch is for nix

I agree— I really like NixOS-like module systems and how they merge together different bits of config to bring the benefits of Nix to configuration management. Being able to configure the whole OS or a big chunk of it via Nix, including running services, managing users, pre-configuring various programs, and more, from a unified interface in a simple language like Nix is awesome.

Declarative package management is great but the broader configuration/service management stuff is even better.

> Aside: I can't imagine figuring out how to use nix just from the official documentation.

That's part of what makes Ian Henry's blog series on the topic compelling! Nobody really learns it that way, and so he's putting the docs to an unusual and much-needed test. Definitely check it out :)

Re: Using Nix on macOS

#68
post #35

Earlier quoted context omitted.

Totally, this post is doing a disservice to Nix.

I think that's a bit unfair to the author, whose goal is clearly to document their own setup on a didactic way rather than to say > here, paste this into your terminal for the easiest way to get up and running with Nix in a fashion that's representative of community common practices I think it's a good blog post which, carefully read, teaches lots of useful things about Nix in a pretty concise way. It's totally fair…

The post directly says that the easy path is more complicated, which just isn't true. It will dissuade new users from even trying Nix. That is a disservice.

Re: Using Nix on macOS

#69
post #65

Earlier quoted context omitted.

I completely disagree. It took me a while to work through the peculiarities of NixOS and get my OS setup, but the benefits are immense now that I'm using it. And I'm using it as a daily driver at a large tech company developing and maintaining mission critical systems. It's really no different from Vim in this respect. Most people will bounce off due to the learning curve, but once you get past it, the benefits are t…

> benefits are immense Such as?

Rolling release; entire config stored in git, allowing for reproduceable setup - I can get a new machine the exact same state in 30 minutes with a few KB in config. Super easy rollback if I break something. Never wondering if something is gonna break with an update. Never wasting time trying to figure out how I set something up before, because it's explicitly declared in config. Standard config language for everything across the system. Ability to roll your own OS in any shape you like. Much easier package creation than RPM or debs. Decentralized composable config - you can pull from many git repos to build your system. Ability to have multiple versions of packages and libs installed at once. Immutable file system except for home folder and a few other paths. Ability to set up temporary dev environments and package installs.

With every change I make, the system only gets more stable, predictable, and reliable, which is the exact opposite of every Linux distribution I've ever user before, which had to be wiped and reinstalled every couple years, after which I'd have endless struggle sessions getting everything set up. I'll never go back.

Re: Using Nix on macOS

#70
post #56
post #15

Earlier quoted context omitted.

> Honestly, doing that may be easier and a better option than using Nix packages in MacOS. Respectfully, I disagree. I’ve been using Nix on a couple of my Macs, including on an M1, and I’ve cutdown my dependence on homebrew almost to the point of its absence; I rely more on Nix packages, than on Homebrew packages. Having said that, I still wouldn’t recommend anyone using Nix; steep learning curve, and too many rough…

Yeah, I switched completely to nix after being frustrated with homebrew constantly breaking things (any time I installed something. (Usually involving libicu being replaced with a different version.) And then had to pick up homebrew again for a couple of things. I _really_ like being able to drop into a shell with a few additional packages installed. But nix does have a learning curve and some rough edges. I found it…

MacPorts is a better alternative to Homebrew, I never had any problems with it.
Post reply on HN