Live data from Hacker News

Using Nix on macOS

checkoway.net

91–100 of 116 posts

Re: Using Nix on macOS

#91
I'm actually trying out Nix on a fresh Mac install since this week, but I'm not yet sure if I enjoy it. When things work it feels pretty great, documentation feels lacking though so when I want to do something I haven't done yet I generally try to find examples of something similar. I do think I'm beginning to understand the language better that reading the source nix files almost become the docs for me.

The main problem I have is when I try to install a package that fails to install, usually it has to compile. Like today I tried watchexec on my M1, doesn't work. Luckily I can just download a binary watchexec build to get around it but it would be nice to know how to get it working. Worked with homebrew. (but homebrew has it's own problems)

The other thing is that I like the idea of using nix-shell for projects, but I hoped they would be more isolated than they appear to be. It's possible for example to have files in a user directory which will be accessible to all projects and package versions I'm using. It hasn't become a problem yet in my testing so far though.

Reading other comments I decided I will also play with running things in a VM with NixOS. Maybe I'll end up with a mix of local Nix for some basic stuff and then a development VM.

Re: Using Nix on macOS

#92
post #67
post #55

Earlier quoted context omitted.

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 th…

I really like Nix's configuration language too. It seems to hit some sweet spot where it manages to be simple, expressive, versatile, and maintainable, all at the same time. So I find it sad when I see people almost instinctively dunk on the language. I wonder if recent efforts around documentation can improve things.

Re: Using Nix on macOS

#93
Nix as a home brew replacement without using homemanger/nix Darwin is not a great sell to me imo.

Using flakes and using it for project dependencies though is amazing and quite easy to use imo.

We decided to use it at my job for a new project and it's been pretty amazing https://link.medium.com/DwIGVmRZ6rb

Re: Using Nix on macOS

#94
post #91

I'm actually trying out Nix on a fresh Mac install since this week, but I'm not yet sure if I enjoy it. When things work it feels pretty great, documentation feels lacking though so when I want to do something I haven't done yet I generally try to find examples of something similar. I do think I'm beginning to understand the language better that reading the source nix files almost become the docs for me. The main pro…

Nix shell isn't supposed to provide file system isolation. It is a package manager after all, so what it does best is give a consistent dev environment with isolated dependencies. At that point if the program access mutable state and you want to prevent it (to a reasonable degree), you should use Docker or do it through the command line (like making $HOME point to somewhere else).

Re: Using Nix on macOS

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

Check out its manual to discover all of the configuration options you can set.

https://daiderd.com/nix-darwin/manual/index.html#sec-options

Re: Using Nix on macOS

#96
post #59

Earlier quoted context omitted.

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.

As a NixOS user, this sounds awesome! Thank you

Re: Using Nix on macOS

#97
post #94
post #91

I'm actually trying out Nix on a fresh Mac install since this week, but I'm not yet sure if I enjoy it. When things work it feels pretty great, documentation feels lacking though so when I want to do something I haven't done yet I generally try to find examples of something similar. I do think I'm beginning to understand the language better that reading the source nix files almost become the docs for me. The main pro…

Nix shell isn't supposed to provide file system isolation. It is a package manager after all, so what it does best is give a consistent dev environment with isolated dependencies. At that point if the program access mutable state and you want to prevent it (to a reasonable degree), you should use Docker or do it through the command line (like making $HOME point to somewhere else).

Oh yeah are definitely right there, I honestly don't know where the expectation came from because it makes perfect sense that it doesn't do that. Why would it. I think it was more me saying "would've been nice.".

I'm coming from homebrew + asdf, but so far Nix appears to be working fine for me. I think asdf has a lot of custom config to try and isolate version-specific shared files/modules etc. I can replicate it by setting some environment variables myself in nix shell file though. I've got my basic home manager setup (still need to migrate some manually managed files to nix config) and every project I work on is now running with their own shell.nix file. No huge problems yet, aside from the mentioned watchexec failing.

Not yet sure if I'll keep it in my regular workflow, it's been an interesting experience and I would be happy to not need homebrew anymore. (Might just try ports too). I'm also curious to see how fast new versions of software will be added/supported, so I'll have to at least keep this running until that happens.

Re: Using Nix on macOS

#98
post #91

I'm actually trying out Nix on a fresh Mac install since this week, but I'm not yet sure if I enjoy it. When things work it feels pretty great, documentation feels lacking though so when I want to do something I haven't done yet I generally try to find examples of something similar. I do think I'm beginning to understand the language better that reading the source nix files almost become the docs for me. The main pro…

Nix is fundamentally a source-based package manager, so it'll try to build packages from source. However, since Nix packages are reproducible, it'll check the official binary cache first to see if it has already been built on Nix's infrastructure and download from there it's there. That's why Nix acts like a binary-based package manager most of the time. However, if a package fails to build or does build but isn't available on the binary cache yet, it would inevitably fall back to source builds. You'd occasionally run into this if you use the unstable channel of Nixpkgs. You can check https://status.nixos.org/ to get a sense of how high the chances are of missing the binary cache. Basically the chances are high if the channel build is failing.

While source builds aren't completely avoidable, you can alleviate much of the pain with a combination of declarative package management and dependency locking. It's what long term Nix users most likely end up using:

* nix-darwin for managing system-wide configuration

* Home Manager for managing user-level configuration

* Nix Flakes for locking dependencies

Once you have a working config, the same config would run anywhere, anytime. You can then use GitHub Actions to automatically update dependencies and check if they all build before merging. Also as a last resort, you can always revert to a previous config if something goes wrong.

Re: Using Nix on macOS

#99

Earlier quoted context omitted.

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.

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

    services.xserver.videoDrivers = [ "qxl" ];
    services.spice-vdagentd.enable = true;

Re: Using Nix on macOS

#100
post #91

I'm actually trying out Nix on a fresh Mac install since this week, but I'm not yet sure if I enjoy it. When things work it feels pretty great, documentation feels lacking though so when I want to do something I haven't done yet I generally try to find examples of something similar. I do think I'm beginning to understand the language better that reading the source nix files almost become the docs for me. The main pro…

> Luckily I can just download a binary watchexec build to get around it but it would be nice to know how to get it working.

Using steam-run, nix-autobahn or using buildFHSUserEnv yourself.

Post reply on HN