ArticleslgStudy

computer science

GNU Guix

GNU Guix is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand GNU Guix rather than just read about it. In short: GNU Guix (; portmanteau of Guile and Nix) is a functional programming cross-platform package manager and a tool to instantiate and manage Unix-like operating systems, inspired by the Nix package manager. Configuration and package recipes are written in Guile Scheme.

GNU Guix — main illustration
GNU Guix — illustration

Key takeaways

  • GNU Guix belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect GNU Guix to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of GNU Guix from memory before moving on to harder problems.

Reference excerpt

GNU Guix (; portmanteau of Guile and Nix) is a functional programming cross-platform package manager and a tool to instantiate and manage Unix-like operating systems, inspired by the Nix package manager. Configuration and package recipes are written in Guile Scheme. GNU Guix is the default package manager of the GNU Guix System distribution. Differing from traditional package managers, Guix (like Nix) uses a purely functional programming deployment model where software is installed into unique directories generated through cryptographic hash functions. All dependencies for each software are included in the input of each hash. This solves the problem of dependency hell, allowing multiple versions of the same software to coexist which makes packages portable and reproducible. Performing scientific computations in a Guix setup has been proposed as a promising response to the replication crisis. The development of GNU Guix is intertwined with the GNU Guix System, an installable operating system distribution using the Linux-libre kernel and the GNU Shepherd init system.

General features Guix packages are defined through functional Guile Scheme APIs designed for package management. Dependencies are tracked directly in this language through special values named "derivations" which are lazily evaluated by the Guix daemon. Guix keeps track of these references automatically so that installed packages can be garbage collected when no other package depends on them, at the cost of greater storage needs, all upgrades in Guix are guaranteed to be atomic and can be rolled back. The roll-back feature of Guix is inherited from the design of Nix and is rarely found in other package managers, since it requires an unorthodox approach to how the system should function (see MicroOS). However, the Guix package manager, like Nix, can be used on many distributions like Debian and Parabola. This also enables multiple users to safely install software on the same system without administrator privileges. Compared to traditional package managers, Guix package stores can grow considerably bigger and therefore require more bandwidth; although compared to container solutions (like Docker) that are also commonly employed to solve dependency hell, Guix is leaner and conforms to practices like don't repeat yourself and single source of truth. If the user chooses to build everything from source, an even larger amount of storage space and bandwidth is required.

The store Inherited from the design of Nix, most of the content of the package manager is kept in a directory /gnu/store where only the Guix daemon has write-access. This is achieved via specialised bind mounts, where the Store as a file system is mounted read only, prohibiting interference even from the root user, while the Guix daemon remounts the Store as read/writable in its own private namespace. Guix talks with this daemon to build things or fetch substitutes which are all kept in the store. Users are discouraged from ever manually touching the store by re-mounting it as writable since this defeats the whole purpose of the store.

Garbage collection Guix - like Nix - has built-in garbage collection facilities to help prune dead store items and keep the live ones.

Package definitions This is an example of a package definition for the hello-package:

It is written using Guile. The package recipes can easily be inspected (running e.g. guix edit hello) and changed in Guix, making the system transparent and very easy to modify.

Transactional upgrades Inherited from the design of Nix, all manipulation of store items is independent of each other, and the directories of the store begin with a base32-encoded hash of the source code of the derivation along with its inputs.

Profiles Guix package uses profiles generations, which are a collection of symbolic links (also known as "symlinks") to specific store items together comprising what the user has installed into the profile. Every time a package is installed or removed, a new generation will be built. For example, the profile of a user who only installed GNU Hello contains links to the store item which holds the version of hello installed with the currently used Guix. On version c087a90e06d7b9451f802323e24deb1862a21e0f of Guix, this corresponds to the item: /gnu/store/md2plii4g5sk66wg9cgwc964l3xwhrm9-hello-2.10 (built from the recipe above). In addition to symbolic links, each profile that Guix builds also contains a union of all the info-manuals, and the man pages, icons, fonts, etc., so a user can browse documentation and have access to all the icons and fonts installed. The default symbolic links to profile generations are stored under /var/guix.

Multiple user profiles The user can create any number of profiles by invoking guix package -p PROFILE-NAME COMMAND. A new directory with the profile-name as well as profile-generation-symlinks will then be created in the current directory.

Roll-back Guix package enables instantaneous roll-back to a previous profile generation via changing the symlink to an earlier profile generation. Profiles are also stored in the store e.g. this item is a profile containing hello above: /gnu/store/b4wipjlsapvnijmbawl7sh76087vpl4n-profile (built and activated when running guix install hello).

Shell environment Guix shell enables the user to easily enter an environment where all the necessary packages for development of software are present without clogging up the user's default profile with dependencies for multiple projects. E.g., running guix shell --development hello enters a throw-away environment where everything needed to compile hello on Guix is present (GNU Compiler Collection (GCC), Guile, etc.). Without the --development flag, only the package hello would be installed and not its build-dependencies. This supplants the guix environment command, which installs the dependencies of a package by default, as it was considered more intuitive for the command to install the specified packages by default and only install development dependencies with a flag.

Persistent development environment If a user wants a persistent gc-rooted environment that is not garbage collected on the next run of the Guix garbage collector they can create a root: e.g. running guix shell --root=hello-root --development hello enters an environment where everything needed to compile Guix is present and registered as a root in the current directory (by symlinking to the items in the store).

… excerpt ends here. Continue reading the full article.

Illustrations

GNU Guix illustration
GNU Guix illustration

Worked examples

Example 1 — a first encounter with GNU Guix

Start with the simplest possible case. Write down what GNU Guix claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to GNU Guix before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about GNU Guix ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of GNU Guix

In research
GNU Guix appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses GNU Guix in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
GNU Guix is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2013 software, Free package management systems, Free software programmed in Lisp, so understanding it makes those chapters shorter.
In everyday life
Look for GNU Guix outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “GNU Guix” →

How to study GNU Guix in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what GNU Guix means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain GNU Guix out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is GNU Guix in simple terms?

GNU Guix (; portmanteau of Guile and Nix) is a functional programming cross-platform package manager and a tool to instantiate and manage Unix-like operating systems, inspired by the Nix package manager. Configuration and package recipes are written in Guile Scheme.

Why does GNU Guix matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study GNU Guix?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on GNU Guix.

Tags

  • 2013 software
  • Free package management systems
  • Free software programmed in Lisp
  • Functional programming
  • GNU Project software
  • Linux distributions without systemd
  • Linux package management-related software
  • Software using the GNU General Public License

Keep exploring