What is Nix
There’s nix: the language, nix: the package manager (think apt, dnf…) and related NixOS, the OS based on nix (both language and package manager). I won’t go further than that and it’s not necessary for now except to say that it is the one package manager with the most packages available.
Which Nix are we talking about here?
The package manager.
Why use Nix?
Recently I was playing with IP ranges, so you could use a package like ipcalc but you have to install it and then it will stay there… even if you do remove it, maybe something will be left behind. And let’s not think about conflicts on dependences… Nix solves both problems, but for that, you need to install it.
Installing Nix
While you can use the official installer: https://nixos.org/download/ But the one I recommend and I’m using is: https://github.com/DeterminateSystems/nix-installer Which handles a lot of problems, including some quicks of some distros (including even MacOS and distros under Windows WSL).
Using Nix:
Before using it, I do need to expand on what you know about Nix here. All packages are packages that have their own list of dependencies, which also might have their own list. If you know JS and the package.json, it’s like that.
One-of use
Do you need something only occasionally? Maybe you want to test something or evaluate which option is better? nix-shell -p plus the name of the package(s) (which, by the way, you can find here: https://search.nixos.org/packages). That’s it. All you need to know is that it will create a shell with the packages available, and if it has conflicting dependencies? It will just use the ones it needs and ignore the rest. Once you exit the shell, it’s all gone (* terms and conditions apply).
Actually “install”
nix profile install nixpkgs# package name and if needed, nixpkgs#other-package all in one line. Now it’s installed and ready to use.
Removing things
If you “installed”, then remove with nix profile remove package name, and that’s it. Then for those you’ve removed and those you’ve played around with nix-shell… nix-store --gc and it will be actually, all gone with disk space freed.
Outro
I can’t see myself without Nix anymore… it’s just so handy to pull packages as you need them without worrying about having to remove them later or weird problems happening because you, at some point, had installed something that needed some version of some dependency and it never got updated. If you start checking out nix (language), nix (package manager) and NixOS, then you’ll probably be overwhelmed by the sheer amount of information, but believe me that these 2 (3 if you consider the one to clear unused dependencies) is all you need to solve most of the problems you might have and even just manage your dependencies overall. And if something didn’t work OOTB? Just install it the way you would normally.
Conclusion
In conclusion, Nix is a powerful package manager that can help you manage your dependencies and packages with ease. With its ability to create a shell with the packages available and its ability to install and remove packages with ease, Nix is a great tool to have in your toolkit.
FAQs
Q: What is Nix?
A: Nix is a package manager that allows you to easily install and manage packages on your system.
Q: Why use Nix?
A: Nix solves the problem of having to install and remove packages, and it also helps to manage dependencies and conflicts.
Q: How do I install Nix?
A: You can install Nix using the official installer or the recommended installer from Determinate Systems.
Q: How do I use Nix?
A: You can use Nix to create a shell with the packages available, install and remove packages, and manage dependencies and conflicts.
Q: Is Nix difficult to learn?
A: Nix has a steep learning curve, but once you understand the basics, it is relatively easy to use.
Q: Can I use Nix on my Mac or Windows machine?
A: Yes, Nix can be used on Mac and Windows machines, including those running under Windows WSL.

