Suivant: , Précédent: , Monter: Contribuer   [Table des matières][Index]


22.7 Source Tree Structure

If you’re willing to contribute to Guix beyond packages, or if you’d like to learn how it all fits together, this section provides a guided tour in the code base that you may find useful.

Overall, the Guix source tree contains almost exclusively Guile modules, each of which can be seen as an independent library (voir Modules dans GNU Guile Reference Manual).

The following table gives an overview of the main directories and what they contain. Remember that in Guile, each module name is derived from its file name—e.g., the module in file guix/packages.scm is called (guix packages).

guix

This is the location of core Guix mechanisms. To illustrate what is meant by “core”, here are a few examples, starting from low-level tools and going towards higher-level tools:

(guix store)

Connecting to and interacting with the build daemon (voir Le dépôt).

(guix derivations)

Creating derivations (voir Dérivations).

(guix gexps)

Writing G-expressions (voir G-Expressions).

(guix packages)

Defining packages and origins (voir Référence de package).

(guix download)
(guix git-download)

The url-fetch and git-fetch origin download methods (voir Référence de origin).

(guix swh)

Fetching source code from the Software Heritage archive.

(guix search-paths)

Implementing search paths (voir Chemins de recherche).

(guix build-system)

The build system interface (voir Systèmes de construction).

(guix profiles)

Implementing profiles.

guix/build-system

This directory contains specific build system implementations (voir Systèmes de construction), such as:

(guix build-system gnu)

the GNU build system;

(guix build-system cmake)

the CMake build system;

(guix build-system pyproject)

The Python “pyproject” build system.

guix/build

This contains code generally used on the “build side” (voir strata of code). This includes code used to build packages or other operating system components, as well as utilities:

(guix build utils)

Utilities for package definitions and more (voir Utilitaires de construction).

(guix build gnu-build-system)
(guix build cmake-build-system)
(guix build pyproject-build-system)

Implementation of build systems, and in particular definition of their build phases (voir Phases de construction).

(guix build syscalls)

Interface to the C library and to Linux system calls.

guix/scripts

This contains modules corresponding to guix sub-commands. For example, the (guix scripts shell) module exports the guix-shell procedure, which directly corresponds to the guix shell command (voir Invoquer guix shell).

guix/import

This contains supporting code for the importers and updaters (voir Invoquer guix import, and voir Invoquer guix refresh). For example, (guix import pypi) defines the interface to PyPI, which is used by the guix import pypi command.

The directories we have seen so far all live under guix/. The other important place is the gnu/ directory, which contains primarily package definitions as well as libraries and tools for Guix System (voir Configuration du système) and Guix Home (voir Configuration du dossier personnel), all of which build upon functionality provided by (guix …) modules49.

gnu/packages

This is by far the most crowded directory of the source tree: it contains package modules that export package definitions (voir Modules de paquets). A few examples:

(gnu packages base)

Module providing “base” packages: glibc, coreutils, grep, etc.

(gnu packages guile)

Guile and core Guile packages.

(gnu packages linux)

The Linux-libre kernel and related packages.

(gnu packages python)

Python and core Python packages.

(gnu packages python-xyz)

Miscellaneous Python packages (we were not very creative).

In any case, you can jump to a package definition using guix edit (voir Invoquer guix edit) and view its location with guix show (voir Invoquer guix package).

gnu/packages/patches

This directory contains patches applied against packages and obtained using the search-patches procedure.

gnu/services

This contains service definitions, primarily for Guix System (voir Services) but some of them are adapted and reused for Guix Home as we will see below. Examples:

(gnu services)

The service framework itself, which defines the service and service type data types (voir Composition de services).

(gnu services base)

“Base” services (voir Services de base).

(gnu services desktop)

“Desktop” services (voir Services de bureaux).

(gnu services shepherd)

Support for Shepherd services (voir Services Shepherd).

You can jump to a service definition using guix system edit and view its location with guix system search (voir Invoquer guix system).

gnu/system

These are core Guix System modules, such as:

(gnu system)

Defines operating-system (voir Référence de operating-system).

(gnu system file-systems)

Defines file-system (voir Systèmes de fichiers).

(gnu system mapped-devices)

Defines mapped-device (voir Périphériques mappés).

gnu/build

These are modules that are either used on the “build side” when building operating systems or packages, or at run time by operating systems.

(gnu build accounts)

Creating /etc/passwd, /etc/shadow, etc. (voir Comptes utilisateurs).

(gnu build activation)

Activating an operating system at boot time or reconfiguration time.

(gnu build file-systems)

Searching, checking, and mounting file systems.

(gnu build linux-boot)
(gnu build hurd-boot)

Booting GNU/Linux and GNU/Hurd operating systems.

(gnu build linux-initrd)

Creating a Linux initial RAM disk (voir Disque de RAM initial).

gnu/home

This contains all things Guix Home (voir Configuration du dossier personnel); examples:

(gnu home services)

Core services such as home-files-service-type.

(gnu home services ssh)

SSH-related services (voir Shell sécurisé).

gnu/installer

This contains the text-mode graphical system installer (voir Installation graphique guidée).

gnu/machine

These are the machine abstractions used by guix deploy (voir Invoquer guix deploy).

gnu/tests

This contains system tests—tests that spawn virtual machines to check that system services work as expected (voir Lancer la suite de tests).

Last, there’s also a few directories that contain files that are not Guile modules:

nix

This is the C++ implementation of guix-daemon, inherited from Nix (voir Invoquer guix-daemon).

tests

These are unit tests, each file corresponding more or less to one module, in particular (guix …) modules (voir Lancer la suite de tests).

doc

This is the documentation in the form of Texinfo files: this manual and the Cookbook. Voir Writing a Texinfo File dans GNU Texinfo, for information on Texinfo markup language.

po

This is the location of translations of Guix itself, of package synopses and descriptions, of the manual, and of the cookbook. Note that .po files that live here are pulled directly from Weblate (voir Traduire Guix).

etc

Miscellaneous files: shell completions, support for systemd and other init systems, Git hooks, etc.

With all this, a fair chunk of your operating system is at your fingertips! Beyond grep and git grep, voir La configuration parfaite on how to navigate code from your editor, and voir Utiliser Guix de manière interactive for information on how to use Scheme modules interactively. Enjoy!


Notes de bas de page

(49)

For this reason, (guix …) modules must generally not depend on (gnu …) modules, with notable exceptions: (guix build-system …) modules may look up packages at run time—e.g., (guix build-system cmake) needs to access the cmake variable at run time—, (guix scripts …) often rely on (gnu …) modules, and the same goes for some of the (guix import …) modules.


Suivant: Consignes d’empaquetage, Précédent: Alternative Setups, Monter: Contribuer   [Table des matières][Index]