6 ms·
The Nix hype machine comes up on HN every few weeks. As someone who tried Nix-- never understood what the big selling point is-- what can Nix do my existing to
by shantnutiwari 5y ago
The Nix hype machine comes up on HN every few weeks.
As someone who tried Nix-- never understood what the big selling point is-- what can Nix do my existing tools can't? (without me spending 6 months)
Nix can create isolated environments, but as far as I see, you can only install the tools Nix repo supports. And the official examples only give toy examples --here's a simple python script you can run with Nix-- but I can just run this simple script in a virtual env, or docker if I have 2-3 different scripts.
What problem is Nix solving? What pain does it fix that is so important it would justify me spending 6 months on it?
And then there is NixOS, which again, I have no idea-- I can create my own Linux distribution that is what, reproducible? Again, is this a real problem anyone faces (and that isnt fixed by docker or ansible or any of the other hundreds of tools)?
My point is: Why is Nix getting so much hype when I dont see them solving any real problems? Sure, they promise a lot, but I have yet to see any real solutions.
Hence the Nix Hype Machine
- IshKebab 5y agoI don't know how you managed to try it without realising its selling points. It's written in huge text at the top of the home page: > Reproducible builds and deployments > Learn how to make reproducible, declarative and reliable systems.
- cies 5y agoHe does not understand those words I'm afraid. Maybe he just did not run into problems with non-reproducible builds yet. Give him time :)
- rkangel 5y agoI use Nix in a very simple way - reproducible dev environments. This is very similar to what you might do with Docker - have the right version of the right dev tools. The result is much more user friendly though because it's layered "over the top" of my normal environment rather than being it's own world (but if I want to run things in their own world I can just run nix shell with --pure). I can then use that same environment to do CI without even creating a docker image, e.g. this for Gitlab CI: image: nixos/nix:latest before_script: - nix-env -f shell.nix -i -A buildInputs If the amount of stuff is big, or you need to build things rather than get them out of Nix cache, then you can build the docker image using Nix tooling instead. You can also use Nix to control what is on a machine. E.g. for our lab setup we had a gateway machine behind which was all the test equipment. NixOS was great for having the exact config of that machine checked into version control so we could recreate it. It's far more reliable than Ansible or something like that.
- nvarsj 5y agoExactly. Getting the exact local dev environment as CI with so few lines of code is awesome and I don't think any other tool can do this.
- benreesman 5y agoNix/NixOS has a few key advantages: - everything from kernel and drivers up is specified declaratively in a uniform, expressive way. You version control your entire infrastructure. Not in the sense of a Dockerfile. The Ansible stuff, the Dockerfile, the build of your library, the build of your own software is in one language that can happily and easily reference each other as a unified system. - with a few caveats, you are cryptographically guaranteed to get the same result, every time, no matter what. if it worked once, it will never break again. - it has mechanisms reminiscent of git or something: you can checkout a different computer or set of computers, and if you don’t like the result, revert to what you had before. - it treats patching of arbitrary software as a completely typical and first-class activity. if anything doesn’t work how you want, you write a patch, check it in, and it works now and always will. upstream at your leisure or not at all. - you get exactly what you want on your system, no more, no less. no gnome-keyring-daemon bullshit on your headless server Ubuntu 20.04 LTS. - caching of artifacts both locally and via cache servers run by you or others or both is very granular. no giant slabs of docker composition towering ever higher.
- seanparsons 5y agoI would say the following for NixOS (which is a distro itself not a way to make a distro): - I have machine configurations that if say a HDD dies means I can just replace it and be pretty much where I was an hour later from scratch. - I can update a configuration (even doing the equivalent of a major OS update) without fear as it's possible to just use the old configuration if something is broken. For Nix in general: - Can define versioned development environments which aren't awkwardly sandboxed as they are in Docker. - It's possible to make multi language/ecosystem builds. - Builds only build what needs building. - You can build on one machine and ship the build to another as if that machine had built it.
- rgoulter 5y ago> As someone who tried Nix-- never understood what the big selling point is-- what can Nix do my existing tools can't? (without me spending 6 months) Right. The benefits are clearer for DevOps than for developer workstations. (e.g. Nix makes it easy to declare the set of packages installed, with atomic rollbacks). For developers, I think it's still worth keeping an eye on, since Nix provides a programmatic way of dealing with packages of software; and dealing with packages of software is pretty much what a developer will need to do when driving their system. e.g. project READMEs typically list some commands for setting up a developer environment; Nix promises a consistent, single command for that (if projects provide Nix files). For most things that you can do with Nix, there's a quicker + dirtier approach already. e.g. VSCode allows isolated/ephemeral dev environments with remote containers; Docker provides an easy way to be confident software will run a certain way in other system; ZFS/btrfs snapshots allow for rolling back changes; nvm/rvm/asdf allow for project-specific versions of packages; apt-get/brew provide a way of installing packages to a system... Nix is an elegant and coherent solution to these kinds of problems. > Nix can create isolated environments, but as far as I see, you can only install the tools Nix repo supports. Not at all! -- It's comparable to e.g. Docker: With Docker, you can run containers using images served from DockerHub.. but you also have the option of building Docker images and using those. With Nix, you describe the packages/libraries/tools you want with Nix. This varies from trivially easy, to "have to really understand what you're doing" difficult.
- ParetoOptimal 5y ago> For most things that you can do with Nix, there's a quicker + dirtier approach already. If you do very typical things that are within the sweet spot of the quick and dirty solutions, you'll likely see nix as redundant. If for some reason, the quick and dirty solutions always seem to break for you you'll grow to love nix and likely NixOS.
- m45t3r 5y ago> Nix can create isolated environments, but as far as I see, you can only install the tools Nix repo supports. And the official examples only give toy examples --here's a simple python script you can run with Nix-- but I can just run this simple script in a virtual env, or docker if I have 2-3 different scripts. Well, for one, someone send me a random Python script with a dependency on a PostgreSQL driver (that probably needs to compile some C library). Just the script, no `requirements.txt` or `Pipfile.lock` or `pyproject.toml` files declaring the dependencies. I could have just created a virtualenv and tried to install it using pip, that would probably fail because I don't have a proper C compiler setup. Or maybe I have but it is missing headers. Maybe it will work because there is already a wheel for my system, but maybe it will not because some other random reason. Instead, I just wrote two lines for shebang: #! /usr/bin/env nix-shell #! nix-shell -i python3 -p python3 python3Packages.psycopg2 And them `chmod +x ./script.py && ./script.py`, and everything is working. > What problem is Nix solving? What pain does it fix that is so important it would justify me spending 6 months on it? Really the meme that you need to spend months just to use Nix properly needs to die. I literally skimped the docs and got a working NixOS install at my first try on the system [1]. The default configuration is really well documented with examples, and I think most people can get what they want quickly. Eventually I wanted to use something that was not packaged on nixpkgs, or I started to want to upgrade some specific packages without using unstable. At that point it was when I started to think Nix was kinda of painful (not because it was difficult to do, however the documentation is not good and you end up searching a lot until you find some answers). At that point yes, it is kinda a journey, but it is very similar to learning a new language: you eventually can get very proficient at it, but you never stop learning. > And then there is NixOS, which again, I have no idea-- I can create my own Linux distribution that is what, reproducible? Again, is this a real problem anyone faces (and that isnt fixed by docker or ansible or any of the other hundreds of tools)? Try to have reproducible system with Ansible. Yeah, I tried. It simply doesn't work well. Ansible is always a pain because steps randomly fail in a new machine, and you can waste hours of debugging for simply issues. Not NixOS: if your configuration builds there is a great chance that everything will work. NixOS is the only system that I am sure that I have the exactly same configuration as my other systems, as long I am running the same commit from my nix-configs repository. Can't say the same for Ansible: if I setup a machine using Ansible right now and 2 days from now, pretty sure they will have different package versions (since the repository will have changed them), for example. Also, you don't have rollbacks with Ansible. Yeah, you can have ZFS/Btrfs taking periodic snapshots and use this for rollbacks. This is not the same though. The UX in NixOS is simply so much better (reboot your system and select which generation you want to boot). > My point is: Why is Nix getting so much hype when I dont see them solving any real problems? Sure, they promise a lot, but I have yet to see any real solutions. Well, my point is: Nix solves real problems. Maybe you are not bitten as much as I am with them, maybe you think that spend half a hour trying to get a random Python script to work is fine. And I completely concur with you. It doesn't mean that Nix is not worth your time though. [1]: Now, I think the fact that I used Arch Linux before really helped, since both NixOS and Arch Linux have an installation process that is completely terminal based instead of a proper installer.
- yakak 5y agoWhat problem is Debian solving? There was already a poor binary packaging system for GNU/Linux, so why did they create another one? Sure it's easy to switch between similar systems but it is also marginal or useless. NixOS and Guix present alternative systems that reuse functional developer skills. If you don't have or want those skills then they aren't going to make any more sense than choosing Smalltalk or a lisp machine while being resistant to leveraging their respective paradigms.
- chriswarbo 5y ago> what can Nix do my existing tools can't? Nothing; even CSS is Turing-complete. It's all a question of how easy, how secure, how reproducible, etc. > as far as I see, you can only install the tools Nix repo supports Lol what? Nix literally just executes a given command, with given arguments and given environment variables. This comment is like saying "Makefiles can only build C projects". Just like Make, if you can build something with some shell commands, then you can build it with Nix. It's often as simple as: runCommand "my-program" { myEnvVar = myValue; } '' put your shell commands here mv my-build-product "$out" '' ('runCommand' tells Nix to run a Bash executable, with the given env vars (including the given commands), and a "default builder" script as argument (that "builder" will eval the given commands)) > Again, is this a real problem anyone faces (and that isnt fixed by docker or ansible or any of the other hundreds of tools)? Nix has been around for two decades. It's more appropriate to ask what was the point of creating Docker, Ansible, virtualenv, etc. when Nix already existed. > And then there is NixOS, which again, I have no idea-- I can create my own Linux distribution that is what, reproducible? Maybe you're getting hung up on terminology; if you would consider "Ubuntu, but with my SSH config file" as "my own Linux distribution", then sure, NixOS creates Linux distributions. If you would call that "configuring a Linux system", then NixOS is for configuring Linux systems.
- yjftsjthsd-h 5y ago> Nix has been around for two decades. It's more appropriate to ask what was the point of creating Docker, Ansible, virtualenv, etc. when Nix already existed. Nix, after two decades, still has an incredibly sharp learning curve, especially to build your own packages. Docker has almost no learning curve, including creating your own images and sharing them with the world.
- chriswarbo 5y agoI disagree. Defining packages is pretty easy, e.g. with import <nixpkgs> {}; runCommand "my-thing" { someSortOfSource = fetchurl { url = "https://example.com/thing.tar.gz"; sha256 = "0000000000000000000000000000000000000000000000000000000000000000"; }; buildInputs = [ gcc python3 whatever-else-you-like ]; } '' tar xzf "$someSortOfSource" cd whateverWasInThatTarball run whatever commands you like mv whatever-the-result-should-be "$out" '' The actual commands can usually be copy/pasted from the README or INSTALL file of whatever project you're "packaging". > Docker has almost no learning curve, including creating your own images and sharing them with the world. It took me several attempts to learn Docker, and I'm still very much a newbie with it. To be fair, most of the difficulty I had was due to my misunderstandings; e.g. "surely nobody actually does that?" (e.g. "download entire OS just to run a command"; "ignore all the hashing and just fetch 'latest'"; "run 'apt-get -y update' without having any idea what it's going to do a week from now"; etc.) Once Docker 'clicked' for me (i.e. I realised that indeed, people are doing that sort of stuff), it became much easier. It's also when I completely lost interest in Docker, and started using OCI containers instead (you can get remarkably far with just 'tar', 'sha256sum' and 'jq'!). These days my only interaction with Docker is when other people's containers cause an outage at work, due to Docker blowing through all the disk space on our cloud servers. (Fun fact: you can resize AWS disk partitions on-the-fly, but not if they're 100% full, since the partition-editing commands try to allocate temp files)
- mindslight 5y agoFrom the bottom-up, the core problem Nix solves is that of programmatically expressing package composition, in terms of reproducible builds [0]. For instance, it does away with the common notion of ambient "system libraries", and instead makes it so every single dependency is specified by the build file. If you've ever compiled a compiler and followed the folk advice to do three stages, or did cross compilation and had to juggle build/host/target triplets, Nix takes those patterns and expresses them executably. Nixos extends this reproducibility up to the level of the OS. Rather than a machine being a giant ball of mutable state, some of it pushed around by configuration management, Nix pulls the entire system state up to a single top value which is set by the bootloader (or similar high-level mutable cell). Like switching to functional programming, at first it just appears different, difficult, and not compelling. But after you start to understand the paradigm, a lot of nice capabilities just fall out, that would otherwise be effectively out of reach. [0] Not deterministic builds per se, which is an ongoing effort.
- cies 5y ago> Hence the Nix Hype Machine I find it disgusting you talk about an opensource effort of mostly volunteers like this. And I think you are wrong. There is no machine: it's people. Yes it's hard. It might not be for you. But it is cool to some people, so they talk about it. Other replies to your comment answer your questions well (showing people really care). This is not bought marketing BS but some "agency machine". This is the labor of love of many. And you are simply dismissive.
- tomberek 5y agoI can confidently compile and run multiple incompatible versions of software simultaneously. I can build projects from years ago. I can package large projects from different ecosystems (python 2/3, c/c++, go, Javascript, Octave, Rust) and be confident they will not interfere with each other. I can try bleeding edge software with no risk to it interfering with my system. It is faster and less hassle than juggling various Docker containers and VMs. It protects me from dependency hell. Using Nix to manage an operating system (ie: NixOS) then gives me those benefits for my entire machine. Then I get even more benefits when using Nix on any other (not even necessarily NixOS) machine by pushing around package closures and managing a simple binary cache. But overall: it makes me more productive. It is my secret weapon to manage the complexity of software development. The benefit is not on day 1, but on day 100 and day 1000.