Live data from Hacker News

Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

zero-to-nix.com

201–210 of 227 posts

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#201

Earlier quoted context omitted.

> I don't even know how to specifically update my `nix` I just clean reinstalled when I went from v2 to v3. Thats the great thing about nix... the rebuilt system is still the same after I installed : ) Note that in nix v3, updating nix is a simple `sudo nix upgrade-nix`, which is really nice.

Is that with flakes though? That's my thing, i'm using flakes, and it's difficult to know what is with flakes or without. Updating my root `nixpkgs` did seem to update my `nix` CLI, but that felt a bit heavy handed. I had a difficult time finding out how to override just the Nix CLI version.

Flakes and 'nix command' are actually 2 separate, experimental features. I think the new nix command has some dependence on flakes, but I'm not sure what. I use flakes though, so you should be good as well. I think it would only potentially be an issue for non-flakes?

I really, really, really wish they would rip the band-aid off and just have everything assume flakes with an easy opt-out. Let all the newcomers reap the benefits of a massively simplified model.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#202

Earlier quoted context omitted.

> would love to see a discussion from somebody who really likes Nix on why it isn't ready for prime time yet The daemon needs to be run as root root in a standard multi-user install which rules out HPC-like envs where Nix would actually shine. There are workarounds but none of them official. Tooling and documentation are on the same level as for a random esoteric programming language. I love Nix but have been hesitan…

> There are workarounds but none of them official. But does it need to be official? Wouldn't that at the same time bloat nix even more? Isn't it enough if core people of the community for example build https://github.com/nix-community/nix-user-chroot ? > In reality the only easy way to get it done is to use additional non-foss software That is not true at all. You can use a nix docker image, a 5 line nix file and 2 c…

> But does it need to be official?

When looking at the up-front time investment and long-term effects, it’s (counterintuitively) crucial that it be official.

If you’re lucky unofficial things eventually end up being official and work fine, but much more often unofficial things die on the vine. If you’re really unlucky the whole branch rots and the system you built on that branch ends up isolated on the ground.

Apologies for stretching the metaphor, it’s been a long day.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#203
post #194

Earlier quoted context omitted.

So you're saying that it is not a language, package manager, cli and community, but it is a language, a package manager and a cli (and I guess we can assume that talking about the "Nix community" makes sense). How was the parent wrong again?

There is the nix language and the nix program which is a package manager and cli at the same time. There might also be the running joke in German that nix literally means nothing but there is no etc. nix does not generally refer to anything else.

Sandro is right that the language is called Nix and the CLI is called Nix. Though, part of the trouble is that Nix handles multiple things (eg. Dev environments) and is often referred to separately as the Nix Package Manager. Realistically, people do talk about "Nix" as one of many of these things which confuses a lot of people. Even the name NixOS is confusing for those unfamiliar with Nix.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#204

Earlier quoted context omitted.

> I would love to see a discussion from somebody who really likes Nix on why it isn't ready for prime time yet/just play devil's advocate aloud on why it isn't the greatest thing since sliced bread. Top reasons in my mind: 1. Error messages. Even with my >1 year of experience using NixOS full-time, I've encountered errors that I simply _cannot_ fix. This is getting better (recent nix releases let you introspect probl…

I don't know much about Nix, but I'm planning on reading more about it. Since you mentioned packer/proxmox/nixos-generators - am I understanding correctly that nix could be used instead of packer to generate a vm image/template for proxmox(or whatever hypervisor)? Is it limited to NixOS or could it create a centos image as an example? I've used a combination of packer+ansible/chef/salt to create images, but it's alwa…

> [...] am I understanding correctly that nix could be used instead of packer to generate a vm image/template for proxmox(or whatever hypervisor)?

That's correct, although as you mention later, it's limited to NixOS. It's an unfortunate constraint given how tremendously powerful it is, but the limitation makes sense. nixos-generators is literally a nix function that accepts a NixOS configuration and operates on the nix value in order to construct the VM image, so it wouldn't work quite the same without nix at the core.

Because nix "knows" about the total definition of the system, nixos-generators can do wonderful things like construct an AMI image or VMWare image without talking to any hypervisor APIs or cloud APIs at all - it knows how to construct the system from the "ground up" and you just end up with a big disk image file after the appropriate `nix build ...` command, no AWS keys or running Proxmox API required.

It's a tradeoff, to be sure. But if the use case fits - which for us, it does quite well - you can be outrageously productive. Adding an entirely new image format takes as long as typing a new line in `flake.nix`, and I leverage a common NixOS module between all the image types to invoke a quick and easy local qemu VM when I'd like to experiment locally.

It's become hard to imagine what managing a "normal" system would be like with the features I get by baking it all into a NixOS configuration.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#205
post #144
post #110

Earlier quoted context omitted.

For vscode, I like the `arrterian.nix-env-selector` extension. Can IntelliJ be configured to simply use whatever JDK belongs to the `javac` in PATH? If so, it should suffice to simply start it in a `nix-shell`. If not, maybe setting `JAVA_HOME` in your `.envrc` could help?

VSCode and IntelliJ also both have direnv plugins for importing env vars from direnv after the fact. You can use that alongside direnv's Nix integration to load those variables without relaunching your editor/IDE!

omg how did I not know about these?!?

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#206
post #81

If I could push this to my kindle as an epub with an index. It would be great if these document frameworks would support it. At least a PDF.

Quite duly noted! I'd love to provide other formats and will investigate this very soon. I can't guarantee that I'll come up with a solution given how vast and variegated the space is, but it's worth trying.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#207

I would love to see a discussion from somebody who really likes Nix on why it isn't ready for prime time yet/just play devil's advocate aloud on why it isn't the greatest thing since sliced bread. I feel like I must not be doing anything "serious" enough to need package reproducibility at that high level. I'm aware of things like git checkout/tags, package-lock.json, Cargo.lock, Docker image tags. What is a real worl…

Some things are much harder in practice than in theory. I recently had to work with a JavaScript project that doesn’t get a lot of maintenance love. It requires a JavaScript version that is no longer part of Nixpkgs. Now try figuring out how to build just that version and also make Yarn use that version. It’s not incredibly hard but the documentation is not obvious to find. Then go on a very very long walk while your…

> Then go on a very very long walk while your Darwin machine is now compiling node.

Yes, if you fall off the happy-path of cached public hydra builds you can easily go from "a few seconds" to "lol maybe today?". Cross-compilation especially is likely to burn you bad in this regard.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#208

I wish guides like these contained screenshots. Do people use Nix for desktop OSes? As a VM they SSH into? A collection of config scripts that they don't directly issue commands to? I certainly can't tell from a quick glance of this guide

Nix is pretty usable for both desktops and headless servers. Personally, I even use it on macOS without much trouble. My system looks like any other install of Ventura, but all of my configuration, ranging from the terminal and VS Code to macOS-specific system preferences and Safari, is done declaratively in Nix [1]. The overwhelming majority of my installed software also comes from Nix packages, with some exceptions…

Interesting, so you are running both home-manager and nix-darwin? When I got into the game, it seemed like they were a bit of a one-or-the-other. I use home-manager but keep homebrew around for some cask management and its mostly "out of band" right now, so I'd be interested to move that "in band" if possible.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#209
post #171

I would love to see a discussion from somebody who really likes Nix on why it isn't ready for prime time yet/just play devil's advocate aloud on why it isn't the greatest thing since sliced bread. I feel like I must not be doing anything "serious" enough to need package reproducibility at that high level. I'm aware of things like git checkout/tags, package-lock.json, Cargo.lock, Docker image tags. What is a real worl…

> I would love to see a discussion from somebody who really likes Nix on why it isn't ready for prime time yet I have several friends who use Nix and generally recommend it. I do believe I think enough like them to like Nix for the same reasons (declarative, reproducible). I've asked them to play devil's advocate, and I generally get the downsides, but... There is one downside that I feel they can't tell me, but they…

My biggest gripe is they invented their own expression language that could have easily been more familiar. Instead it adds to the learning curve.

Re: Zero to Nix, an unofficial, opinionated, gentle introduction to Nix

#210
post #62

Earlier quoted context omitted.

> MacOS is still a second-class citizen in the Nix world and a fair amount of stuff doesn't work properly In my experience: With fewer nix users on macOS, it's more likely you'll run into software which isn't in the binary cache, & so will compile from source. (brew also does this). With fewer nix users on macOS, it's may take longer for packages broken on macOS to be fixed. It's a bit more of a hurdle to use .app pr…

.app programs which require Xcode to build weren't in the binary caches altogether, last I checked. Stuff with proprietary software in its build toolchain doesn't get built on Hydra. I just use brew for .apps (and only for .apps) when I'm on macOS.

Yep, I use Brew with a Brewfile to handle most casks. A select few I've manually created derivations for. This seems to be the path of much less resistance.
Post reply on HN