What is "Guix?" — a brief overview
The name "Guix" might be confusing because it actually refers to several related things, or you could say it is one big thing with many individually moving parts.
This article on Guix is a continuation of an article I wrote earlier which gave a more general overview of what makes Guix (and Nix) unique as package managers and operating systems. In this article, I go into more detail about what Guix is.
This article in brief:
I describe all the various things that are meant when someone is talking about "Guix." The important parts of "Guix" include:
- Guile
a compiler of the Scheme programming language, and the engine which runs the Guix package manager. Guile is a compiler of the Scheme programming language. It is similar in function to Python on other Linux distributions, but it nowhere near similar to Python in theory from a programming language perspective. (It is in theory a thousand times better than Python, or will be someday soon, in my humble opinion.) You must have the Guile compiler to use any part of Guix.
- Guix
a package manager used to build pieces of software.
- Guix packages
code written in Guile using the Guix API which describes how a piece software can be built and installed onto a computer.
- Guix channels
a database of packages executable by Guix all inter-related software packages. These "packages" are not the apps themselves, just the instructions on how to download, build, and install apps.
- Guix OS
a Linux distribution in which every piece of softwre from the C compiler to the kernel to the userland aplications, are all built from the Guix Packages database.
The parts of Guix
When someone is talking about "Guix" they are usually referring to one of 3 things:
- a package manager
- a package database (an "app store", also called a "channel")
- an operating system (a Linux distribution)
The Guix package manager
Guix is a software package manager written in Guile Scheme used to declare the existence of each piece of software used in an application. These pieces include the Guix OS and all apps that run on Guix OS.
Guix the package manager is an actual executable program and Scheme API. It is analogous to Debian's "Apt", Fedora's "DNF", or Nix OS's "Nix". End users of Guix OS will use it, often directly on the command line, in order to install software on their Guix OS computer.
The Guix executable and API is itself a package in the Guix Packages database, and you must use it to install and use Guix software. You do not need to use Guix OS to use the Guix package manager, you can build your own Guix Packages database using the Guix package manager alone. It is theoretically possible to (for example) build an OpenBSD or FreeBSD distribution on Guix. The only hard dependencies are the the Guile compiler, and the GCC compiler used to build Guile.
The Guix package manager, and by extension Guix OS, is quite unlike the other package manager or Linux distributions because it uses highly advanced algorithms to provide guarantees on the exact code that is running in the system. These algorithms are in a few ways similar to blockchain technology, though it would be misleading for me to call Guix Packages a "blockchain", so I won't call it that.
The advantage of Guix is that it can guarantee that every piece of software in the system is built in the exact same way, byte for byte, for any given computer chip (ISA). This is extremely important for software engineers and system technicians who need to guarantee that the correct software is running on their computer systems. It is analogous to a food factory in which there are automated checks that occur at every stage of production which ensure harmful or poisonous materials do not end up in food.
From the perspective a user of Guix OS, if you ever install an app that turns out to be buggy or unreliable, with a single command you can almost instantly "roll-back" the installation of that app, and the system continues running as if installing that app never happened.
This however does not provide the kind of security guarantees that might protect you from evil hackers. As with any other computer system, it is possible for an evil hacker to cause serious damage to a Guix OS computer. Guix OS just makes it a little easier for the good hackers to find whatever changes might have been caused by the evil hackers, and to mitigate the damage they caused.
Guix package databases ("channels")
This is a database full of pieces of code called "packages" where each package describes how to build and install a single piece of software. The package database is calld a "channel," I will use the terms "channel" and "package database" interchangably. You can install multiple channels, but you do need to install all of the packages in a channel at once in order to use it. The package in a channel do NOT include the any of the actual apps or software components themselves, these are just instructions on (declarations about) how to build and install software.
When you install an app using Guix, you do not need to
build the software itself. Once actually uses a package to
build a piece of software, that software that gets built is placed
into a cache. The local copy of the cache database exists as a
directory: /gnu/store
. When you use the software
installed by the Guix package manager, you are running the executable
code that is stored in this cache.
Guix is a binary software distribution, not a
source distribution, so it is unlike the Gentoo Linux, FreeBSD, or
OpenBSD operating systems. Guix, by it's very blockchain-like nature,
guarantees that software built on one computer will be identical to
software built on any other like computer (provided your
computer hardware, the "ISA", is identical to the computer that built
it). So it is safe to copy parts of the /gnu/store
cache
onto other computers and use it as is.
You might confuse Guix for a source distribution because Guix does
make it easy to build software from its source code. And software
developers very often use it for this purpose, and to develop new
applications. But if you are not a software developer, you can just
copy binary packages built by Guix onto your computer from
a /gnu/store
cache anywhere.
What goes into the /gnu/store
cache? Well, anything
you need to use the software you install goes in the store. But at the
very minimum, if you actually want to use the Guix package manager and
a Guix channel (package database), the /gnu/store
must
contain:
The Guix package manager
The Guix Packages database itself (all of the channels containing Guix packages)
The Guile Scheme compiler, which includes the interpreter and runtime used to execute the the package manager, and also to execute every piece of code for each "package", which does the actual work of installing the software.
When you actually use the software in this store, directory tree
called a "profile" is constructed somewhere where you
can easily access it. You can create profiles anywhere, easily, but
most Guix users have one profile in their /home/
directory. The tree sructure is similar to any other Linux or Unix
system: it contains directories
called /bin
, /lib
, /share
, /etc
,
and /src
. However, in this directory tree, there are only
symbolic links to actual objects in the /gnu/store
cache.
The nice thing about "profiles" is that you can easily, almost
instantly, "roll back" or undo software installation. Profiles are
very easy to create and delete as you need them. If you choose to
delete software from your computer, you simply delete the profile in
which it exists, and then run a process called "garbage collection"
(the guix gc
command) which checks that every package is
linked to some profile. All packages not linked to a profile are
deleted from the /gnu/store
cache automatically.
As long as you have not run garbage collection, you can undo and redo software installation nearly as easily as it is to push "Ctrl-Z" on your keyboard.
Guix OS
Guix OS a Linux distribution that uses Guix Packages to build the entire operating system, from the OS kernel, up to and including every single app that runs on the OS. You do not need to install all of Guix OS to use Guix the package manager, but using the Guix OS has a few other advantages:
You are guaranteed that the code that runs your whole operating system is exactly what is described by the Guix packages, and is identical to every other like computer (of the same ISA).
The configuration of your system is "declarative." You do not actually install or remove software yourself. You "declare" (in a Guix configuration file) that software is to exist on your computer, and the Guix package manager performs whatever steps necessary to make that software exist as you described it.
The whole operating system that you actually use is just an ordinary "profile", so you can rollback (undo or redo) any changes to your software configuration. For example: "oops" did the software you install suddenly cause WiFi to stop working? Just reboot and undo that software installation from the Grub menu. This makes Guix OS systems highly reliable.
Drawbacks
The biggest drawback to Guix OS is that it does not have as many apps in its app store (the main Guix Packages channel). Guix OS is an official GNU project, and they enforce extremely strict regulations on the software they allow in their package database (channel). But this does not prevent other people from creating their own channels with less stringent legal or security requirements. So gradually, other people with interest in Guix have introduced their own channels that allow for a wider variety of software to be used on Guix OS.
The other big drawback is that you may often find yourself in a position where you must know something about how to use the Guix API to install software – and for that, you need to know a little bit about how to write Scheme code. If have used Emacs before, configuring Guix is very similar.
But if you are willing to learn, if you have some expertise in building and installing your own software from source code, you will probably enjoy learning and using Guix for how easy it makes it for you to build and install software, and to undo mistakes you might make. So I hope this article has given you a better idea of what Guix is, and you are inspired to learn more about how to use it. If so your next step is the <a href="https://guix.gnu.org">Guix website.</a>
Happy hacking!