Live data from Hacker News

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

zero-to-nix.com

61–70 of 227 posts

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

#61

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

Yes, all of the above - and much more.

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

#62

Earlier quoted context omitted.

It may not be a fad, but there's a lot of rose-colored hype that masks a world of tedium. New prospective users should be prepared for a lot of uphill grind with respect to configuring packages or defining their own packages. Every time I try to do seemingly simple tasks in Nix, I end up spending hours on the Nix discord channel trying to work out a solution with seasoned users (who invariably struggle to work out a…

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

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

#63
I have tried several times to dig into nix and make it stick. Each time I get a little further along, but I always get to the same stuck point: things that I am trying to combine are unclear to me how they should fit together, and/or there are just massive amounts of code for what should be a simple thing.

Nix flakes has indeed made it all quite a bit easier. But, sadly, in the interim, there are lots of things in an in-between state.

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

#64

Earlier quoted context omitted.

For me, the "borking" issue is largely resolved by running Btrfs. Just make a snapshot shortly before updating, and then I can revert to it if needed.

My problem is i don't know what gets borked immediately after updating unless it's catastrophic. Ie i've gone a fair bit of time before i realized some specific functionality of some program no longer works due to some unrelated change in an underlying dependency that i was unaware of. Oof. Granted Btrfs sounds great though, i've not used that. It would certainly help.

Yeah that's true. That's where the "largely" part of my comment does some work.

I just take occasional snapshots before I do things that I'm concerned may be catastrophic. But it definitely won't catch everything. It helps that I run Arch, and I update packages once a day, which only leaves me with under 40 (small) packages usually. So a quick cursory glance at which ones are updating usually tells me what to be cautious of. Display driver update, kernel update, etc.

If I'm not sure what went wrong, but I at least have a working snapshot, then I can get done what I need to get done, and then go back to troubleshooting. Rather than just having a broken system regardless.

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

#66
post #45
post #37

Earlier quoted context omitted.

Is this more deterministic than pointing Nixpkgs at a specific commit/tarball in the configuration? I have often done this to make reproducible builds in other Nix settings and it has worked well.

Yes, because it also makes your Nixpkgs config explicit (doesn't read ~/.config/nixpkgs/config.nix unless you source it in-repo) and doesn't rely on env vars (e.g., NIX_PATH) which are not given explicitly in the flake. But pinning Nixpkgs alone does get you much of the way there (and for many use cases— those where the only referent on it is 'nixpkgs' or 'nixos'— does make NIX_PATH redundant anyway).

> But pinning Nixpkgs alone does get you much of the way there (and for many use cases— those where the only referent on it is 'nixpkgs' or 'nixos'— does make NIX_PATH redundant anyway).

What is missing compared to using flakes? The only `NIX_PATH` components I normally use is `nixpkgs` which hooks into the whole channel system (which is bad), but by settings my `pkgs` variable to a specific commit/tarball, I can ignore `NIX_PATH` entirely, right?

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

#67
post #39
post #37

Earlier quoted context omitted.

Is this more deterministic than pointing Nixpkgs at a specific commit/tarball in the configuration? I have often done this to make reproducible builds in other Nix settings and it has worked well.

It is: using Flakes you're thrusted into a more pure evaluation mode by default, and it creates a (standard) artifact of the revision you're on: the flake.lock. You can get almost all the benefits Flakes brings without Flakes using alternatives like niv.

> It is: using Flakes you're thrusted into a more pure evaluation mode by default, and it creates a (standard) artifact of the revision you're on: the flake.lock.

Can you name a specific example of the kind of nondeterminism/nonreproducibility I risk by simply pinning Nixpkgs itself (or to be more principled, using Niv)?

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

#68

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

I can tell you that I do all three. My daily driver is a laptop running NixOS with a highly customised desktop environment. I also have a small VPS that running NixOS that I communicate with via SSH. Finally, as work, we use a nix flake to simplify our build system. Most days of the year, that is handled entirely by the CI script and I don't have to think about it.

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

#69

What problem does this solve?

Some problems Nix solves, as concisely as possible:

  - dependency conflicts
  - build reproducibility
  - configuration management
    - configuration drift
  - package management on restricted systems (i.e., installing stuff when you're not root)
  - shared library duplication
  - inconsistent state/broken system after a botched upgrade
This makes it nice for setting up development environments, building containers, and deploying servers.

(A lot of people also enjoy using it for their dotfiles, since it works on macOS as well as across all Linuxes. I personally love it on desktops and development workstations as well.)

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

#70
post #28

Is Nix good at dealing with cuda dependencies? I am always frustrated trying to deploy cuda-based environments onto machines with different sorts of GPUs.

I've setup pytorch with CUDA on nix and it was quite straightforward, but never tried anything more exotic.
Post reply on HN