Live data from Hacker News

Using Nix on macOS

checkoway.net

11–20 of 116 posts

Re: Using Nix on macOS

#11

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.

Yeah this post is basically how to build your own wrapper around nix to manage your Mac user environment because you didn't like some of the decisions the nix maintainers made. It's easier to just install nix following its directions and then exclusively use nix-shell or nix develop (with flakes) to activate development environments with specific tools. Kind of like a python virtual environment on steroids. Forget entirely about managing your user's global tools and packages unless or until you want to do that, you could just keep using homebrew!

Re: Using Nix on macOS

#12

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.

Yeah this post is basically how to build your own wrapper around nix to manage your Mac user environment because you didn't like some of the decisions the nix maintainers made. It's easier to just install nix following its directions and then exclusively use nix-shell or nix develop (with flakes) to activate development environments with specific tools. Kind of like a python virtual environment on steroids. Forget en…

Even managing global/user packages is fine, if you want parity with a normal package manager. nix-env is pretty simple to get started with.

Managing that declaratively is slightly more challenging. That’s when you need to understand the Nix language and use something like home-manager or the file approach in the blog post. But at this point, Nix is competing against something like Ansible/Puppet and not a standard package manager.

Re: Using Nix on macOS

#13

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.

Every complex tool is complicated, like planes with a lot of dashboard, buttons, levers and other stuff. But if you learn it you can achieve awesome success. Nix is same if you use right way after some learn, for example, to create reproducible dev environment.

Re: Using Nix on macOS

#14

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.

Totally, this post is doing a disservice to Nix.

Re: Using Nix on macOS

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

Re: Using Nix on macOS

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

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.

Re: Using Nix on macOS

#17
> Usually, your terminal emulator will create a login shell by default when you open a new terminal window. (Apple Terminal and iTerm2 both do.) And that’s generally the only time you create a login shell.

On a Linux system, login shells are only invoked when you actually create a new session which doesn't come from an existing session belonging to the same user. In other words, you get the when

  - you switch to a 'real' TTY and log in manually
  - you log in via your GUI session manager (GDM, SDDM, etc.)
  - you log in remotely, e.g., via SSH
But not when you open a new terminal emulator window. You can't just run `login` as your normal user inside a terminal emulator and get a new session either. You can check this with `finger` or `loginctl list-sessions`.

On macOS, those things do get you new sessions which are shown by `finger`. I wonder whether the difference reveals a macOS quirk or a Linux quirk.

Re: Using Nix on macOS

#18

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 be the same and the output will run exactly the same. Even going as far as to install an older cargo or meson or CMake if that's what's needed for backwards compatibility. And if you want to be safe, you can create a sandbox or "jail" and libraries will know how to deal with it instead of just crashing when they try to access something outside.

Re: Using Nix on macOS

#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”?

Re: Using Nix on macOS

#20
Why hasn’t anyone built a clone of npm/npx UX that uses Nix under the hood? I hear so much about how ideal the Nix model is, and how bad NPM is. It seems like this should be “easy”. What gives?
Post reply on HN