Today we will talk about Nix , a purely functional package manager.
')
Why create another bike, this time with square wheels purely functional? Existing solutions:
they don’t cope with updating packages (updating can remove old packages, because of which you will have to delete all the programs dependent on these packages, or accept the contradictory state of the system)
do not take into account all the dependencies of each individual package (and can not do this)
do not know and can not know the exact combination of kernel versions, libraries and packages available on the computer
focused on centralized repositories, each of which will have a single package naming policy - as a result, packages of these repositories are often incompatible, even if the same underlying technology is used (RPM, DEB)
As a result, a lot of hard work falls on the volunteers, who day and night in the service of the fatherland. :)
How to solve this problem? Very simple, the guys from the University of Utrecht said: handle packages in the same way as the values of expressions in purely functional languages! How-how, the reader will ask?
Like that:
package is the result of calculating a pure function whose arguments are all package dependencies (other packages, that is)
the package being installed once in the system does not change (no side effects)
The two sentences above mean only that Nix never makes changes to the files on the disk, but only creates new files.
“How so? I have a disk of only 2 GB! ”- probably the reader was visited by something like this. :) The fact is that some packages can be quietly removed if other packages do not depend on them. This is very similar to garbage collection in modern programming languages.
We list the most notable advantages of Nix over other package managers:
it is perfectly allowed to contain several versions of the same package at the same time (for example, this may be useful if two applications require two versions of the same library) Immediately, we note that updating or deleting operations cannot damage other applications due to the fact that these operations never overwrite or delete files that are used by other packages.
all dependencies of a single package are tracked - a package that earned on a developer’s machine will also work on a user’s machine
atomicity of update operations and the ability to roll back any update (even if you pull the plug out of the socket during the update, the system will not suffer from it - but this, of course, should not be done for obvious reasons)
Transparent support for packages containing source code or compiled binaries ( Nix can automatically skip the compilation phase if the package is already available in compiled form)
binary patches (in addition to loading available binaries automatically, Nix can download the difference between two binaries)
On this optimistic note, we complete our reviewer.
update: formatting update: moved to the collective blog