2 ms·
It's really hard to explain it because Nix is a paradigm shift (I think that's why it is hard initially grasp it). But you can use it for things like: - decla
by takeda 3y ago
It's really hard to explain it because Nix is a paradigm shift (I think that's why it is hard initially grasp it).
But you can use it for things like:
- declare your application with all dependencies explicitly, so when someone else wants to build it they can (I would argue this is the primary purpose and rest is just built on top of that)
- common dev environment (so other developers can get the same dev environment as you with all exact same build tools)
- build toolchain (for example if you do embedded environment)
- you could use it as a replacement for homebrew/mac ports
- a configuration file holding your .dot files (home manager)
- if you use NixOS (OS that was built around Nix) then you have OS with a built-in configuration management (i.e. salt/puppet/ansible/chef) that is truly declarative
I think this[1] also shows some crazy stuff you can do with it.
Regarding question around Docker, the great thing is that if you define your application as a nix derivation, then you can easily generate docker that just contains your application and dependencies (the docker in that case is just a deployment unit). The reproducible environment is what docker promised, but practically failed to deliver. Instead of deliver reproducibility, it actually delivered repeatability.
[1] https://youtu.be/6Le0IbPRzOE?t=109 https://youtu.be/6Le0IbPRzOE?t=109
- esafak 3y agoThank you for the explanation. Let me see if I understood. The basic draw is that it offers a programming language-agnostic specification for dependency management, replacing language-specific specifications like requirements.txt. Then you pair it with a containerization technology like Docker or Podman. And if you use NixOS, you can skip the last part?
- takeda 3y ago> Thank you for the explanation. Let me see if I understood. The basic draw is that it offers a programming language-agnostic specification for dependency management, replacing language-specific specifications like requirements.txt Yes, actually I got interested in Nix because with requirements.txt I could only define python dependencies, and I had no control over for example installing postgresql C library that psycopg2 depends on. > Then you pair it with a containerization technology like Docker or Podman You don't have to, but you can, given that in most places containers are being used a lot of people use nix that way. > And if you use NixOS, you can skip the last part? Yes, although keep in mind that for example the requirement is to use Kubernetes then you would have to use Kubernetes. But if you need to create for example an EC2 instance. You can use Ubuntu + ansible or you could use NixOS. Honestly I don't have much experience with NixOS as at my workplace we are mandated to use specific distro for everything. Edit: I forgot to add additional benefits with using NixOS compared to Ubuntu + ansible for example. All updates are atomic. You either end up with the new configuration or the old configuration, there's no in-between as it would happen with ansible. Second big benefit is easy way to rollback.