From patchwork Wed Mar 20 10:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 62018 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C5C2F27BBE2; Wed, 20 Mar 2024 11:08:48 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 94F3C27BBEA for ; Wed, 20 Mar 2024 11:08:45 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmto5-0000VR-0u; Wed, 20 Mar 2024 07:08:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmtnz-0000Ur-LA for guix-patches@gnu.org; Wed, 20 Mar 2024 07:08:23 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rmtnz-0005zr-7c for guix-patches@gnu.org; Wed, 20 Mar 2024 07:08:23 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rmtoc-0008Sw-82 for guix-patches@gnu.org; Wed, 20 Mar 2024 07:09:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69587] [PATCH v2] doc: Add =?utf-8?b?4oCcU291cmNl?= Tree =?utf-8?b?U3RydWN0dXJl4oCd?= section. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Mar 2024 11:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69587 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69587@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , pelzflorian@pelzflorian.de Received: via spool by 69587-submit@debbugs.gnu.org id=B69587.171093292432502 (code B ref 69587); Wed, 20 Mar 2024 11:09:02 +0000 Received: (at 69587) by debbugs.gnu.org; 20 Mar 2024 11:08:44 +0000 Received: from localhost ([127.0.0.1]:38871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rmtoJ-0008SA-T5 for submit@debbugs.gnu.org; Wed, 20 Mar 2024 07:08:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rmtoH-0008Rn-MH for 69587@debbugs.gnu.org; Wed, 20 Mar 2024 07:08:42 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmtVg-0000Ze-Db; Wed, 20 Mar 2024 06:49:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=i39i4C2lURkJTEJR/wcm6nHckK94Ri4SCOBMHwEQpbM=; b=fbR+uNTM4vfGoAOvZCsd JirsHJ1excHOfYD44+uJ1grGZj+uD6gemB/FPy6PX0NPfnOO8Zpb4B2hM4L67IQb8NipwUWlSHKo0 mPyZRfYZEeLl7yzb9yDqf3+VZ0LK1LaHauHBje273HzrjaHfwE4ReiS+T0o128OvCJj0garNqcby1 2ybPQqEoyldLiPRa8BSr7i+ZJmZDbdcr+nqfkfFeOK+vADOnfbll6hgYNVS9m+LKOiTvIN71mV/W8 0Z1dkMEyqlKttsfec3NgYv4eX+O3Ma6SIsKurCzLQ0lnklXKvHJVDsTw30cIFtUuZijZzTvPjVHy5 3rijpYso1AlidA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 20 Mar 2024 11:49:13 +0100 Message-ID: <4b50aca680226c4eeba9b83f1d82d935aaae382d.1710931512.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <87wmpy2tow.fsf@gnu.org> References: <87wmpy2tow.fsf@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * doc/contributing.texi (Source Tree Structure): New node. * doc/guix.texi (Programming Interface): Add cross-reference. Change-Id: I141a1f4d806ae5f72c7a246e18c14dc63056a607 --- doc/contributing.texi | 252 +++++++++++++++++++++++++++++++++++++++++- doc/guix.texi | 3 +- 2 files changed, 253 insertions(+), 2 deletions(-) Hi! Changes since v1: • Clarify the intended audience upfront. • Mention the nix/ directory. • Explain that .po files are taken from Weblate. • Explain what “core mechanisms” means. • Clarify guix/gnu module name space distinction. Ludo’. base-commit: b7eb1a8116b2caee7acf26fb963ae998fbdb4253 diff --git a/doc/contributing.texi b/doc/contributing.texi index a7d91724fb..17ecf4a04c 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -23,7 +23,8 @@ Contributing * Building from Git:: The latest and greatest. * Running Guix Before It Is Installed:: Hacker tricks. * The Perfect Setup:: The right tools. -* Alternative Setups:: Other posible tools that do the job. +* Alternative Setups:: Other possible tools that do the job. +* Source Tree Structure:: Source code guided tour. * Packaging Guidelines:: Growing the distribution. * Coding Style:: Hygiene of the contributor. * Submitting Patches:: Share your work. @@ -546,6 +547,255 @@ Vim and NeoVim process and inject your code there live (sadly it's not packaged in Guix yet). +@node Source Tree Structure +@section Source Tree Structure + +@cindex structure, of the source tree +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 +@dfn{modules}, each of which can be seen as an independent library +(@pxref{Modules,,, guile, 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@file{guix/packages.scm} is +called @code{(guix packages)}. + +@table @file +@item 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: + +@table @code +@item (guix store) +Connecting to and interacting with the build daemon (@pxref{The Store}). +@item (guix derivations) +Creating derivations (@pxref{Derivations}). +@item (guix gexps) +Writing G-expressions (@pxref{G-Expressions}). +@item (guix packages) +Defining packages and origins (@pxref{package Reference}). +@item (guix download) +@itemx (guix git-download) +The @code{url-fetch} and @code{git-fetch} origin download methods +(@pxref{origin Reference}). +@item (guix swh) +Fetching source code from the +@uref{https://archive.softwareheritage.org,Software Heritage archive}. +@item (guix search-paths) +Implementing search paths (@pxref{Search Paths}). +@item (guix build-system) +The build system interface (@pxref{Build Systems}). +@item (guix profiles) +Implementing profiles. +@end table + +@cindex build system, directory structure +@item guix/build-system +This directory contains specific build system implementations +(@pxref{Build Systems}), such as: + +@table @code +@item (guix build-system gnu) +the GNU build system; +@item (guix build-system cmake) +the CMake build system; +@item (guix build-system pyproject) +The Python ``pyproject'' build system. +@end table + +@item guix/build +This contains code generally used on the ``build side'' +(@pxref{G-Expressions, strata of code}). This includes code used to +build packages or other operating system components, as well as +utilities: + +@table @code +@item (guix build utils) +Utilities for package definitions and more (@pxref{Build Utilities}). +@item (guix build gnu-build-system) +@itemx (guix build cmake-build-system) +@itemx (guix build pyproject-build-system) +Implementation of build systems, and in particular definition of their +build phases (@pxref{Build Phases}). +@item (guix build syscalls) +Interface to the C library and to Linux system calls. +@end table + +@cindex command-line tools, as Guile modules +@cindex command modules +@item guix/scripts +This contains modules corresponding to @command{guix} sub-commands. For +example, the @code{(guix scripts shell)} module exports the +@code{guix-shell} procedure, which directly corresponds to the +@command{guix shell} command (@pxref{Invoking guix shell}). + +@cindex importer modules +@item guix/import +This contains supporting code for the importers and updaters +(@pxref{Invoking guix import}, and @pxref{Invoking guix refresh}). For +example, @code{(guix import pypi)} defines the interface to PyPI, which +is used by the @code{guix import pypi} command. +@end table + +The directories we have seen so far all live under @file{guix/}. The +other important place is the @file{gnu/} directory, which contains +primarily package definitions as well as libraries and tools for Guix +System (@pxref{System Configuration}) and Guix Home (@pxref{Home +Configuration}), all of which build upon functionality provided by +@code{(guix @dots{})} modules@footnote{For this reason, @code{(guix +@dots{})} modules must generally not depend on @code{(gnu @dots{})} +modules, with one notable exception: @code{(guix build-system @dots{})} +modules may look up packages at run time---e.g., @code{(guix +build-system cmake)} needs to access the @code{cmake} variable at run +time.}. + +@table @file +@cindex package modules +@item gnu/packages +This is by far the most crowded directory of the source tree: it +contains @dfn{package modules} that export package definitions +(@pxref{Package Modules}). A few examples: + +@table @code +@item (gnu packages base) +Module providing ``base'' packages: @code{glibc}, @code{coreutils}, +@code{grep}, etc. +@item (gnu packages guile) +Guile and core Guile packages. +@item (gnu packages linux) +The Linux-libre kernel and related packages. +@item (gnu packages python) +Python and core Python packages. +@item (gnu packages python-xyz) +Miscellaneous Python packages (we were not very creative). +@end table + +In any case, you can jump to a package definition using @command{guix +edit} (@pxref{Invoking guix edit}) and view its location with +@command{guix show} (@pxref{Invoking guix package}). + +@findex search-patches +@item gnu/packages/patches +This directory contains patches applied against packages and obtained +using the @code{search-patches} procedure. + +@item gnu/services +This contains service definitions, primarily for Guix System +(@pxref{Services}) but some of them are adapted and reused for Guix Home +as we will see below. Examples: + +@table @code +@item (gnu services) +The service framework itself, which defines the service and service type +data types (@pxref{Service Composition}). +@item (gnu services base) +``Base'' services (@pxref{Base Services}). +@item (gnu services desktop) +``Desktop'' services (@pxref{Desktop Services}). +@item (gnu services shepherd) +Support for Shepherd services (@pxref{Shepherd Services}). +@end table + +You can jump to a service definition using @command{guix system edit} +and view its location with @command{guix system search} (@pxref{Invoking +guix system}). + +@item gnu/system +These are core Guix System modules, such as: + +@table @code +@item (gnu system) +Defines @code{operating-system} (@pxref{operating-system Reference}). +@item (gnu system file-systems) +Defines @code{file-system} (@pxref{File Systems}). +@item (gnu system mapped-devices) +Defines @code{mapped-device} (@pxref{Mapped Devices}). +@end table + +@item 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. + +@table @code +@item (gnu build accounts) +Creating @file{/etc/passwd}, @file{/etc/shadow}, etc. (@pxref{User +Accounts}). +@item (gnu build activation) +Activating an operating system at boot time or reconfiguration time. +@item (gnu build file-systems) +Searching, checking, and mounting file systems. +@item (gnu build linux-boot) +@itemx (gnu build hurd-boot) +Booting GNU/Linux and GNU/Hurd operating systems. +@item (gnu build linux-initrd) +Creating a Linux initial RAM disk (@pxref{Initial RAM Disk}). +@end table + +@item gnu/home +This contains all things Guix Home (@pxref{Home Configuration}); +examples: + +@table @code +@item (gnu home services) +Core services such as @code{home-files-service-type}. +@item (gnu home services ssh) +SSH-related services (@pxref{Secure Shell}). +@end table + +@item gnu/installer +This contains the text-mode graphical system installer (@pxref{Guided +Graphical Installation}). + +@item gnu/machine +These are the @dfn{machine abstractions} used by @command{guix deploy} +(@pxref{Invoking guix deploy}). + +@item gnu/tests +This contains system tests---tests that spawn virtual machines to check +that system services work as expected (@pxref{Running the Test Suite}). +@end table + +Last, there's also a few directories that contain files that are +@emph{not} Guile modules: + +@table @file +@item nix +This is the C++ implementation of @command{guix-daemon}, inherited from +Nix (@pxref{Invoking guix-daemon}). + +@item tests +These are unit tests, each file corresponding more or less to one +module, in particular @code{(guix @dots{})} modules (@pxref{Running the +Test Suite}). + +@item doc +This is the documentation in the form of Texinfo files: this manual and +the Cookbook. @xref{Writing a Texinfo File,,, texinfo, GNU Texinfo}, +for information on Texinfo markup language. + +@item po +This is the location of translations of Guix itself, of package synopses +and descriptions, of the manual, and of the cookbook. Note that +@file{.po} files that live here are pulled directly from Weblate +(@pxref{Translating Guix}).` + +@item etc +Miscellaneous files: shell completions, support for systemd and other +init systems, Git hooks, etc. +@end table + +With all this, a fair chunk of your operating system is at your +fingertips! Beyond @command{grep} and @command{git grep}, @pxref{The +Perfect Setup} on how to navigate code from your editor, and +@pxref{Using Guix Interactively} for information on how to use +interactively use Scheme modules. Enjoy! + @node Packaging Guidelines @section Packaging Guidelines diff --git a/doc/guix.texi b/doc/guix.texi index 20f007b1c0..138d53602f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7680,7 +7680,8 @@ Programming Interface that build results @emph{derive} from them. This chapter describes all these APIs in turn, starting from high-level -package definitions. +package definitions. @xref{Source Tree Structure}, for a more general +overview of the source code. @menu * Package Modules:: Packages from the programmer's viewpoint.