Live data from Hacker News

What Is Nix?

engineering.shopify.com

271–280 of 344 posts

Re: What Is Nix?

#271
post #262
post #257

Earlier quoted context omitted.

I'm sure there are reasons for it, but it still sucks. It ought to be possible to use binary caches and still swap out the path. (Modifying a string in an ELF executable isn't that hard.)

The problem is how it affects all the hashes, which aren't recalculable in such an easy way.

Could you not check the hashes before doing the substitution?

Re: What Is Nix?

#272
post #257

Earlier quoted context omitted.

I'm sure there are reasons for it, but it still sucks. It ought to be possible to use binary caches and still swap out the path. (Modifying a string in an ELF executable isn't that hard.)

Modifying a string in ELF is hard. As long as the string has the same length as the original one, it has a good chance to work (but still fails for compressed data). But if you want an arbitrary directory, you need to replace it with a different length path, and that will probably break a lot of things.

It's not that hard if you leave some spare space for string constants in the .rodata section. Nix already patches ELF executables as things stand.

Re: What Is Nix?

#273
post #240

The only takeaway I get from this article is... Why is Nix? And from skimming along the comments, both on HN and on Disqus, there's a lot of confused people trying to understand/describe the difference between Nix and Docker, because although the article described how Nix works in a very technical way, it didn't explain what it can be actually used for.

Here are my favourite use-cases:

* automatically installing all project libraries and dependencies so you can build your project without having to apt install a bunch of stuff first. This is done through direnv/lorri, so when you cd into the project directory, direnv uses nix to install everything automatically. Very quick onboarding and also no need to keep up with the various company projects' deps.

* building docker images with intentional layering so deltas remain small is a breeze: buildLayeredImage.

* with home-manager I can ensure my dotfiles have all their dependencies so vim plugins and whatnot just work. It also means I get the same nice home environment on _any_ Linux distro I choose.

* Same as above except for my entire system with NixOS.

* Shipping packages with specific config defaults _only_ for your project directory so you don't have to worry about making everyone configure something is also a breeze with Nix package overlays and overrides.

* You can even have Nix modules for your VPN connection and the like so co-workers can import that into their home-manager or NixOS configuration, and if it changes so does your system/home config next time you build it.

Re: What Is Nix?

#274

Earlier quoted context omitted.

The PhD thesis that goes with Nix is a really great intro to it. It's very accessible and well-structured. It motivates the need for a new take on package management by analogy to memory management in programming languages. It contrasts how software deployment works today (“Fuck it, I’m sure /usr/bin/local/python is a reference to a python 2.7.12 install with PIL available”) to how we used to write software (“Fuck it…

The downside is that the approach works best when packages are aware of the Nix approach. But the packages have not been written with Nix in mind, and some work is needed per package to adapt to the approach.

That's really a flaw with how those packages have been designed rather than a flaw with Nix. We've known that it is a terrible idea to put everything into global directories, edit `PATH` and so on for literally decades.

Re: What Is Nix?

#275
post #258

Earlier quoted context omitted.

But what if they're using different versions of OpenSSL?

It'll only rebuild the packages that depended on that particular openssl. This is an area where Nix shines, because all packages are explicitly bound to their dependencies, it means it's no longer relevant what one file happens to be occupying `/usr/lib/libssl.so`, or even `/lib/x86_64-linux-gnu/libc.so.6`, so you can be running different apps that rely on totally different glibc versions alongside each other with no…

I mean if there's a bug, it's not enough to patch one particular OpenSSL. You have to audit manually, so Nix won't make much of a difference.

Re: What Is Nix?

#276
post #247

Is Nix only handling the build part (with configure flags etc.) or is it also used to configure services, for example? I'm not versed in devops/provisioning etc., but say, I had a NixOS system with some server software (mail server, DNS server, whatever). Would I still want to use Chef/Puppet/Ansible, or is that included in the Nix ecosystem?

yes, it's included. Nix config files will automatically generate and run services. There's also Nixops which is a tool to push these config to remote machines ie cloud vms.

Re: What Is Nix?

#278
post #263

I really wish nix was the solution, but I'm not sure it is. I currently don't install anything on my base system, but do it via docker. Looking through my dockerfiles, currently I have stuff installed via: * apt * apt preceded by apt-key add * wget/curl * pip & pip3 * git clone * go get * npm install * snap And that's even though I try to avoid esoteric package managers as much as possible. (For example, there was so…

nix is the solution. It's totally different from any random packager you've seen. It goes the reversed direction of abstracting dependencies away: it makes dependencies explicit (and reproducible!)

Re: What Is Nix?

#279

Hearing about Nix couldn’t have come at a better time. Having just got a new Mac, seems like the perfect time to try a fresh Nix-only setup.

from now on every new machines will be easily replicated with configs from older machines: copy the config file over, type one command and let nix does the rest

Re: What Is Nix?

#280
post #53

I have always wanted to try Nix, but not sure how installing software from source outside the package system works. With Arch Linux, it's pretty easy to create an AUR package if it doesn't exist, or simply install it outside the package system. Is it easy to create Nix packages (based on the features of Nix, I'm guessing no)? What about if you don't feel like creating a package?

you can always find examples to learn from in nixpkgs git repo. If the package can build from source, look at other package with similar dependencies. If the package is binary distribution (eg closed source), follow this guide: https://nixos.wiki/wiki/Packaging/Binaries
Post reply on HN