Live data from Hacker News

Using Nix on macOS

checkoway.net

51–60 of 116 posts

Re: Using Nix on macOS

#51

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.

For all of my personal machines, I use NixOS (both hardware and in cloud machines). But for work, we have a soft-MacOS mandate. On that m1 macbook pro, I run nix-darwin for the mac specific settings I want, and packages that I run in macos, but everything else in a NixOS VM similar to mitchellh/nixos-config. I use UTM (a nice wrapper around qemu), but the rest is just standard nix config, of which, nearly all of it I…

Thanks for pointing out mitchellh/nixos-config. Do you have a config published for nixos with UTM? I’m having a heck of a time getting the screen resolution and font sizes where I want them and I’m kind of lost.

Re: Using Nix on macOS

#52
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 still wouldn’t recommend anyone using Nix; steep learning curve, and too many rough edges.

I'd like to think there are roughly two camps of people:

Those who hear about Nix's declarative nature, with its reproducible/'pure' nature, and generational installation, all of which allow for some pretty neat UX. To this group, Nix sounds technically interesting.

The other group, those who want a tool that just works, that's simple to use, and already get their job done with other package managers. -- I think for this group, Nix is going to be a bad tool to recommend, even if they keep hearing about how neat Nix is.

Rather. Nix is wonderful 95% of the time. But the 5% of the time you run into some problem, it's much more difficult to get unstuck compared to other tools. (Other knowledge is necessary but not sufficient, the community is small so maybe harder to find a StackOverflow post, the documentation is fragmented, etc.).

Re: Using Nix on macOS

#53
I have tried using nix for weeks on macOS and it’s been a really painful experience. I’ve pretty much given up. I don’t think they care much about user experience tbh.

Re: Using Nix on macOS

#55
post #32

That seems like a hell of a lot more work than just using Home-Manager and flakes. Flakes add a lot of boilerplate, but this seems excessive in comparison. And Home-Manager is quite easy.

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 total mismatch from what the audience needs, focusing way too much on how to write your own custom modules, and not nearly enough on actually consuming them or decent patterns for it)

[0]: people are allowed to do what they want. But the path chosen by this author is not the easy path

Re: Using Nix on macOS

#56
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…

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 tricky to use things like libraries outside of nix's build process. And there is a bit of an impedance mismatch when trying to use languages that have their own package management.

So I've got nix for a bunch of software, a couple of libraries in homebrew, and native package management for various languages (cargo, ghcup, lake, idris).

I also reluctantly installed agda via homebrew because I can't get it to build. (Haskell mostly works on M1).

Re: Using Nix on macOS

#57
post #7

Christ that's a lot of work, just to start working on work. I really want to like Nix, but the UX is frankly offputting. I really hope it improves to the point that it can be mindlessly installed.

I wouldn’t take this one blog post as gospel about how to use Nix. I’m not denying that it’s complicated, but doing declarative package management is not the only way to dip your toes into Nix. You can use it pretty much as a conventional package manager with none of the upsides of declarative package management (but none of the complexity either). On the surface level for people migrating from existing package manag…

People say that but yet nobody linked to a post explaining the “right way” of using nix on macOS

Re: Using Nix on macOS

#58

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.

[deleted]

Re: Using Nix on macOS

#59
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).

I’m looking at nix-darwin but there is no explanation on what it actually does

https://github.com/LnL7/nix-darwin

Re: Using Nix on macOS

#60

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[1].

[1](https://stackoverflow.com/questions/32893412/command-line-to...)

Post reply on HN