Live data from Hacker News

Using Nix on macOS

checkoway.net

21–30 of 116 posts

Re: Using Nix on macOS

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

Nix is one of those rocket-powered chainsaw tools that you run into, and while it still scares me (and I often worry about accidentally cutting off a limb), it's much nicer to use than Homebrew. The only caviat is that your Nix store can get enormously huge, which is a big problem on Apple devices where storage comes at a premium.

I would naively expect that if you run garbage collection on a regular basis that it should take no more space. Is that not true, or is running it on a regular basis the sticking bit?

Re: Using Nix on macOS

#22
post #19

I hope Docker is not the final answer to reproducible and isolated processes because it’s a bit too complex and slow on anything other than Linux, IMO. Linux virtualization almost became a mandatory feature of a modern OS because of it. I wish there was something that would run on any POSIX, but that’s probably not enough ground to cover complete reproduction.

“Docker but it’s just a chroot”?

Yeah, you kid, but you know, it would solve a lot of the most common problems. Like a parent mentioned, most of the time you're just not linking to the right libraries. That’s it. Do we need to ship a whole kernel, have terrible IO and jump through a lot of hoops just for that?

Re: Using Nix on macOS

#23
post #19

Earlier quoted context omitted.

“Docker but it’s just a chroot”?

Yeah, you kid, but you know, it would solve a lot of the most common problems. Like a parent mentioned, most of the time you're just not linking to the right libraries. That’s it. Do we need to ship a whole kernel, have terrible IO and jump through a lot of hoops just for that?

I’m not kidding! I hacked together a bunch of env vars, carefully ordered tar unpacking, and some chrooting for dev envs at Airbnb years ago. It’s effective.

Re: Using Nix on macOS

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

Re: Using Nix on macOS

#25
post #23

Earlier quoted context omitted.

Yeah, you kid, but you know, it would solve a lot of the most common problems. Like a parent mentioned, most of the time you're just not linking to the right libraries. That’s it. Do we need to ship a whole kernel, have terrible IO and jump through a lot of hoops just for that?

I’m not kidding! I hacked together a bunch of env vars, carefully ordered tar unpacking, and some chrooting for dev envs at Airbnb years ago. It’s effective.

Sorry, sarcasm is hard on the web.

I think you were/are into something. I though about it but never managed to build it.

Re: Using Nix on macOS

#26
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.

Re: Using Nix on macOS

#27

Earlier quoted context omitted.

Nix is one of those rocket-powered chainsaw tools that you run into, and while it still scares me (and I often worry about accidentally cutting off a limb), it's much nicer to use than Homebrew. The only caviat is that your Nix store can get enormously huge, which is a big problem on Apple devices where storage comes at a premium.

I would naively expect that if you run garbage collection on a regular basis that it should take no more space. Is that not true, or is running it on a regular basis the sticking bit?

I suppose you could, but Nix (and NixOS) defaults to keeping packages for an insane amount of time. 3 months of regular Nix use can accrue ~300gb of packages, which is definitely not what you'd have on something like Homebrew.

Re: Using Nix on macOS

#28

I hope Docker is not the final answer to reproducible and isolated processes because it’s a bit too complex and slow on anything other than Linux, IMO. Linux virtualization almost became a mandatory feature of a modern OS because of it. I wish there was something that would run on any POSIX, but that’s probably not enough ground to cover complete reproduction.

My hope is that a lot of the difficulty in getting reproducible builds is caused by outdated libraries and techniques. For example, assuming that your code is in /usr/bin or /usr/lib, so any package manager has to emulate that. My hope is that eventually, you can just run `cargo build --reproducible` or `meson build --reproducible` or `make --reproducible`, and if your architecture is the same, the dependencies will…

cargo build --locked

There is a lockfile, even if it's not respected by default. Doesn't help with build.rs being able to do whatever it wants but it's better than default

Re: Using Nix on macOS

#29

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 reuse from the configuration for the rest of my machines.

Re: Using Nix on macOS

#30

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.

This is true, but in my experience it has mostly been pretty easy to deal with. Generally it's just a matter of re-linking /etc/zprofile and friends to the ones from the nix-darwin installer (if you're using nix-darwin, which I would recommend).
Post reply on HN