Merge branch 'wip-guix-home'
[jackhill/guix/guix.git] / doc / guix.texi
1 \input texinfo
2 @c -*-texinfo-*-
3
4 @c %**start of header
5 @setfilename guix.info
6 @documentencoding UTF-8
7 @settitle GNU Guix Reference Manual
8 @c %**end of header
9
10 @include version.texi
11
12 @c Identifier of the OpenPGP key used to sign tarballs and such.
13 @set OPENPGP-SIGNING-KEY-ID 27D586A4F8900854329FF09F1260E46482E63562
14 @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=127547
15
16 @c Base URL for downloads.
17 @set BASE-URL https://ftp.gnu.org/gnu/guix
18
19 @c The official substitute server used by default.
20 @set SUBSTITUTE-SERVER-1 ci.guix.gnu.org
21 @set SUBSTITUTE-SERVER-2 bordeaux.guix.gnu.org
22 @set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} https://@value{SUBSTITUTE-SERVER-2}
23
24 @copying
25 Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@*
26 Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
27 Copyright @copyright{} 2013 Nikita Karetnikov@*
28 Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
29 Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
30 Copyright @copyright{} 2014 Pierre-Antoine Rault@*
31 Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
32 Copyright @copyright{} 2015, 2016, 2017, 2019, 2020, 2021 Leo Famulari@*
33 Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus@*
34 Copyright @copyright{} 2016 Ben Woodcroft@*
35 Copyright @copyright{} 2016, 2017, 2018, 2021 Chris Marusich@*
36 Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Efraim Flashner@*
37 Copyright @copyright{} 2016 John Darrington@*
38 Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
39 Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@*
40 Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Julien Lepiller@*
41 Copyright @copyright{} 2016 Alex ter Weele@*
42 Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Christopher Baines@*
43 Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
44 Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@*
45 Copyright @copyright{} 2017 Federico Beffa@*
46 Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
47 Copyright @copyright{} 2017 Thomas Danckaert@*
48 Copyright @copyright{} 2017 humanitiesNerd@*
49 Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@*
50 Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Marius Bakke@*
51 Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
52 Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@*
53 Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Tobias Geerinckx-Rice@*
54 Copyright @copyright{} 2017 George Clemmer@*
55 Copyright @copyright{} 2017 Andy Wingo@*
56 Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
57 Copyright @copyright{} 2017 nee@*
58 Copyright @copyright{} 2018 Rutger Helling@*
59 Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
60 Copyright @copyright{} 2018 Mike Gerwitz@*
61 Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
62 Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
63 Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
64 Copyright @copyright{} 2018 Laura Lazzati@*
65 Copyright @copyright{} 2018 Alex Vong@*
66 Copyright @copyright{} 2019 Josh Holland@*
67 Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
68 Copyright @copyright{} 2019 Ivan Petkov@*
69 Copyright @copyright{} 2019 Jakob L. Kreuze@*
70 Copyright @copyright{} 2019 Kyle Andrews@*
71 Copyright @copyright{} 2019 Alex Griffin@*
72 Copyright @copyright{} 2019, 2020, 2021 Guillaume Le Vaillant@*
73 Copyright @copyright{} 2020 Liliana Marie Prikler@*
74 Copyright @copyright{} 2019, 2020 Simon Tournier@*
75 Copyright @copyright{} 2020 Wiktor Żelazny@*
76 Copyright @copyright{} 2020 Damien Cassou@*
77 Copyright @copyright{} 2020 Jakub Kądziołka@*
78 Copyright @copyright{} 2020 Jack Hill@*
79 Copyright @copyright{} 2020 Naga Malleswari@*
80 Copyright @copyright{} 2020, 2021 Brice Waegeneire@*
81 Copyright @copyright{} 2020 R Veera Kumar@*
82 Copyright @copyright{} 2020 Pierre Langlois@*
83 Copyright @copyright{} 2020 pinoaffe@*
84 Copyright @copyright{} 2020 André Batista@*
85 Copyright @copyright{} 2020, 2021 Alexandru-Sergiu Marton@*
86 Copyright @copyright{} 2020 raingloom@*
87 Copyright @copyright{} 2020 Daniel Brooks@*
88 Copyright @copyright{} 2020 John Soo@*
89 Copyright @copyright{} 2020 Jonathan Brielmaier@*
90 Copyright @copyright{} 2020 Edgar Vincent@*
91 Copyright @copyright{} 2021 Maxime Devos@*
92 Copyright @copyright{} 2021 B. Wilson@*
93 Copyright @copyright{} 2021 Xinglu Chen@*
94 Copyright @copyright{} 2021 Raghav Gururajan@*
95 Copyright @copyright{} 2021 Domagoj Stolfa@*
96 Copyright @copyright{} 2021 Hui Lu@*
97 Copyright @copyright{} 2021 pukkamustard@*
98 Copyright @copyright{} 2021 Alice Brenon@*
99 Copyright @copyright{} 2021 Andrew Tropin@*
100
101 Permission is granted to copy, distribute and/or modify this document
102 under the terms of the GNU Free Documentation License, Version 1.3 or
103 any later version published by the Free Software Foundation; with no
104 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
105 copy of the license is included in the section entitled ``GNU Free
106 Documentation License''.
107 @end copying
108
109 @dircategory System administration
110 @direntry
111 * Guix: (guix). Manage installed software and system configuration.
112 * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
113 * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
114 * guix pull: (guix)Invoking guix pull. Update the list of available packages.
115 * guix system: (guix)Invoking guix system. Manage the operating system configuration.
116 * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
117 @end direntry
118
119 @dircategory Software development
120 @direntry
121 * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
122 * guix build: (guix)Invoking guix build. Building packages.
123 * guix pack: (guix)Invoking guix pack. Creating binary bundles.
124 @end direntry
125
126 @titlepage
127 @title GNU Guix Reference Manual
128 @subtitle Using the GNU Guix Functional Package Manager
129 @author The GNU Guix Developers
130
131 @page
132 @vskip 0pt plus 1filll
133 Edition @value{EDITION} @*
134 @value{UPDATED} @*
135
136 @insertcopying
137 @end titlepage
138
139 @contents
140
141 @c *********************************************************************
142 @node Top
143 @top GNU Guix
144
145 This document describes GNU Guix version @value{VERSION}, a functional
146 package management tool written for the GNU system.
147
148 @c TRANSLATORS: You can replace the following paragraph with information on
149 @c how to join your own translation team and how to report issues with the
150 @c translation.
151 This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
152 GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
153 Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
154 Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
155 Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
156 would like to translate it in your native language, consider joining
157 @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
158 Weblate} (@pxref{Translating Guix}).
159
160 @menu
161 * Introduction:: What is Guix about?
162 * Installation:: Installing Guix.
163 * System Installation:: Installing the whole operating system.
164 * Getting Started:: Your first steps.
165 * Package Management:: Package installation, upgrade, etc.
166 * Channels:: Customizing the package collection.
167 * Development:: Guix-aided software development.
168 * Programming Interface:: Using Guix in Scheme.
169 * Utilities:: Package management commands.
170 * System Configuration:: Configuring the operating system.
171 * Home Configuration:: Configuring the home environment.
172 * Documentation:: Browsing software user manuals.
173 * Installing Debugging Files:: Feeding the debugger.
174 * Security Updates:: Deploying security fixes quickly.
175 * Bootstrapping:: GNU/Linux built from scratch.
176 * Porting:: Targeting another platform or kernel.
177 * Contributing:: Your help needed!
178
179 * Acknowledgments:: Thanks!
180 * GNU Free Documentation License:: The license of this manual.
181 * Concept Index:: Concepts.
182 * Programming Index:: Data types, functions, and variables.
183
184 @detailmenu
185 --- The Detailed Node Listing ---
186
187 Introduction
188
189 * Managing Software the Guix Way:: What's special.
190 * GNU Distribution:: The packages and tools.
191
192 Installation
193
194 * Binary Installation:: Getting Guix running in no time!
195 * Requirements:: Software needed to build and run Guix.
196 * Running the Test Suite:: Testing Guix.
197 * Setting Up the Daemon:: Preparing the build daemon's environment.
198 * Invoking guix-daemon:: Running the build daemon.
199 * Application Setup:: Application-specific setup.
200 * Upgrading Guix:: Upgrading Guix and its build daemon.
201
202 Setting Up the Daemon
203
204 * Build Environment Setup:: Preparing the isolated build environment.
205 * Daemon Offload Setup:: Offloading builds to remote machines.
206 * SELinux Support:: Using an SELinux policy for the daemon.
207
208 System Installation
209
210 * Limitations:: What you can expect.
211 * Hardware Considerations:: Supported hardware.
212 * USB Stick and DVD Installation:: Preparing the installation medium.
213 * Preparing for Installation:: Networking, partitioning, etc.
214 * Guided Graphical Installation:: Easy graphical installation.
215 * Manual Installation:: Manual installation for wizards.
216 * After System Installation:: When installation succeeded.
217 * Installing Guix in a VM:: Guix System playground.
218 * Building the Installation Image:: How this comes to be.
219
220 Manual Installation
221
222 * Keyboard Layout and Networking and Partitioning:: Initial setup.
223 * Proceeding with the Installation:: Installing.
224
225 Package Management
226
227 * Features:: How Guix will make your life brighter.
228 * Invoking guix package:: Package installation, removal, etc.
229 * Substitutes:: Downloading pre-built binaries.
230 * Packages with Multiple Outputs:: Single source package, multiple outputs.
231 * Invoking guix gc:: Running the garbage collector.
232 * Invoking guix pull:: Fetching the latest Guix and distribution.
233 * Invoking guix time-machine:: Running an older revision of Guix.
234 * Inferiors:: Interacting with another revision of Guix.
235 * Invoking guix describe:: Display information about your Guix revision.
236 * Invoking guix archive:: Exporting and importing store files.
237
238 Substitutes
239
240 * Official Substitute Servers:: One particular source of substitutes.
241 * Substitute Server Authorization:: How to enable or disable substitutes.
242 * Getting Substitutes from Other Servers:: Substitute diversity.
243 * Substitute Authentication:: How Guix verifies substitutes.
244 * Proxy Settings:: How to get substitutes via proxy.
245 * Substitution Failure:: What happens when substitution fails.
246 * On Trusting Binaries:: How can you trust that binary blob?
247
248 Channels
249
250 * Specifying Additional Channels:: Extending the package collection.
251 * Using a Custom Guix Channel:: Using a customized Guix.
252 * Replicating Guix:: Running the @emph{exact same} Guix.
253 * Channel Authentication:: How Guix verifies what it fetches.
254 * Channels with Substitutes:: Using channels with available substitutes.
255 * Creating a Channel:: How to write your custom channel.
256 * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
257 * Declaring Channel Dependencies:: How to depend on other channels.
258 * Specifying Channel Authorizations:: Defining channel authors authorizations.
259 * Primary URL:: Distinguishing mirror to original.
260 * Writing Channel News:: Communicating information to channel's users.
261
262 Development
263
264 * Invoking guix environment:: Setting up development environments.
265 * Invoking guix pack:: Creating software bundles.
266 * The GCC toolchain:: Working with languages supported by GCC.
267 * Invoking guix git authenticate:: Authenticating Git repositories.
268
269 Programming Interface
270
271 * Package Modules:: Packages from the programmer's viewpoint.
272 * Defining Packages:: Defining new packages.
273 * Defining Package Variants:: Customizing packages.
274 * Build Systems:: Specifying how packages are built.
275 * Build Phases:: Phases of the build process of a package.
276 * Build Utilities:: Helpers for your package definitions and more.
277 * The Store:: Manipulating the package store.
278 * Derivations:: Low-level interface to package derivations.
279 * The Store Monad:: Purely functional interface to the store.
280 * G-Expressions:: Manipulating build expressions.
281 * Invoking guix repl:: Programming Guix in Guile.
282
283 Defining Packages
284
285 * package Reference:: The package data type.
286 * origin Reference:: The origin data type.
287
288 Utilities
289
290 * Invoking guix build:: Building packages from the command line.
291 * Invoking guix edit:: Editing package definitions.
292 * Invoking guix download:: Downloading a file and printing its hash.
293 * Invoking guix hash:: Computing the cryptographic hash of a file.
294 * Invoking guix import:: Importing package definitions.
295 * Invoking guix refresh:: Updating package definitions.
296 * Invoking guix lint:: Finding errors in package definitions.
297 * Invoking guix size:: Profiling disk usage.
298 * Invoking guix graph:: Visualizing the graph of packages.
299 * Invoking guix publish:: Sharing substitutes.
300 * Invoking guix challenge:: Challenging substitute servers.
301 * Invoking guix copy:: Copying to and from a remote store.
302 * Invoking guix container:: Process isolation.
303 * Invoking guix weather:: Assessing substitute availability.
304 * Invoking guix processes:: Listing client processes.
305
306 Invoking @command{guix build}
307
308 * Common Build Options:: Build options for most commands.
309 * Package Transformation Options:: Creating variants of packages.
310 * Additional Build Options:: Options specific to 'guix build'.
311 * Debugging Build Failures:: Real life packaging experience.
312
313 System Configuration
314
315 * Using the Configuration System:: Customizing your GNU system.
316 * operating-system Reference:: Detail of operating-system declarations.
317 * File Systems:: Configuring file system mounts.
318 * Mapped Devices:: Block device extra processing.
319 * User Accounts:: Specifying user accounts.
320 * Keyboard Layout:: How the system interprets key strokes.
321 * Locales:: Language and cultural convention settings.
322 * Services:: Specifying system services.
323 * Setuid Programs:: Programs running with root privileges.
324 * X.509 Certificates:: Authenticating HTTPS servers.
325 * Name Service Switch:: Configuring libc's name service switch.
326 * Initial RAM Disk:: Linux-Libre bootstrapping.
327 * Bootloader Configuration:: Configuring the boot loader.
328 * Invoking guix system:: Instantiating a system configuration.
329 * Invoking guix deploy:: Deploying a system configuration to a remote host.
330 * Running Guix in a VM:: How to run Guix System in a virtual machine.
331 * Defining Services:: Adding new service definitions.
332
333 Home Environment Configuration
334
335 * Invoking guix home:: Instantiating a home environment configuration.
336
337 Services
338
339 * Base Services:: Essential system services.
340 * Scheduled Job Execution:: The mcron service.
341 * Log Rotation:: The rottlog service.
342 * Networking Services:: Network setup, SSH daemon, etc.
343 * Unattended Upgrades:: Automated system upgrades.
344 * X Window:: Graphical display.
345 * Printing Services:: Local and remote printer support.
346 * Desktop Services:: D-Bus and desktop services.
347 * Sound Services:: ALSA and Pulseaudio services.
348 * Database Services:: SQL databases, key-value stores, etc.
349 * Mail Services:: IMAP, POP3, SMTP, and all that.
350 * Messaging Services:: Messaging services.
351 * Telephony Services:: Telephony services.
352 * Monitoring Services:: Monitoring services.
353 * Kerberos Services:: Kerberos services.
354 * LDAP Services:: LDAP services.
355 * Web Services:: Web servers.
356 * Certificate Services:: TLS certificates via Let's Encrypt.
357 * DNS Services:: DNS daemons.
358 * VPN Services:: VPN daemons.
359 * Network File System:: NFS related services.
360 * Continuous Integration:: Cuirass and Laminar services.
361 * Power Management Services:: Extending battery life.
362 * Audio Services:: The MPD.
363 * Virtualization Services:: Virtualization services.
364 * Version Control Services:: Providing remote access to Git repositories.
365 * Game Services:: Game servers.
366 * PAM Mount Service:: Service to mount volumes when logging in.
367 * Guix Services:: Services relating specifically to Guix.
368 * Linux Services:: Services tied to the Linux kernel.
369 * Hurd Services:: Services specific for a Hurd System.
370 * Miscellaneous Services:: Other services.
371
372 Defining Services
373
374 * Service Composition:: The model for composing services.
375 * Service Types and Services:: Types and services.
376 * Service Reference:: API reference.
377 * Shepherd Services:: A particular type of service.
378
379 Installing Debugging Files
380
381 * Separate Debug Info:: Installing 'debug' outputs.
382 * Rebuilding Debug Info:: Building missing debug info.
383
384 Bootstrapping
385
386 * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
387 * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
388
389 @end detailmenu
390 @end menu
391
392 @c *********************************************************************
393 @node Introduction
394 @chapter Introduction
395
396 @cindex purpose
397 GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
398 using the international phonetic alphabet (IPA).} is a package
399 management tool for and distribution of the GNU system.
400 Guix makes it easy for unprivileged
401 users to install, upgrade, or remove software packages, to roll back to a
402 previous package set, to build packages from source, and generally
403 assists with the creation and maintenance of software environments.
404
405 @cindex Guix System
406 @cindex GuixSD, now Guix System
407 @cindex Guix System Distribution, now Guix System
408 You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
409 complements the available tools without interference (@pxref{Installation}),
410 or you can use it as a standalone operating system distribution,
411 @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
412 System Distribution'' or ``GuixSD''. We now consider it makes more sense to
413 group everything under the ``Guix'' banner since, after all, Guix System is
414 readily available through the @command{guix system} command, even if you're
415 using a different distro underneath!}. @xref{GNU Distribution}.
416
417 @menu
418 * Managing Software the Guix Way:: What's special.
419 * GNU Distribution:: The packages and tools.
420 @end menu
421
422 @node Managing Software the Guix Way
423 @section Managing Software the Guix Way
424
425 @cindex user interfaces
426 Guix provides a command-line package management interface
427 (@pxref{Package Management}), tools to help with software development
428 (@pxref{Development}), command-line utilities for more advanced usage
429 (@pxref{Utilities}), as well as Scheme programming interfaces
430 (@pxref{Programming Interface}).
431 @cindex build daemon
432 Its @dfn{build daemon} is responsible for building packages on behalf of
433 users (@pxref{Setting Up the Daemon}) and for downloading pre-built
434 binaries from authorized sources (@pxref{Substitutes}).
435
436 @cindex extensibility of the distribution
437 @cindex customization, of packages
438 Guix includes package definitions for many GNU and non-GNU packages, all
439 of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
440 user's computing freedom}. It is @emph{extensible}: users can write
441 their own package definitions (@pxref{Defining Packages}) and make them
442 available as independent package modules (@pxref{Package Modules}). It
443 is also @emph{customizable}: users can @emph{derive} specialized package
444 definitions from existing ones, including from the command line
445 (@pxref{Package Transformation Options}).
446
447 @cindex functional package management
448 @cindex isolation
449 Under the hood, Guix implements the @dfn{functional package management}
450 discipline pioneered by Nix (@pxref{Acknowledgments}).
451 In Guix, the package build and installation process is seen
452 as a @emph{function}, in the mathematical sense. That function takes inputs,
453 such as build scripts, a compiler, and libraries, and
454 returns an installed package. As a pure function, its result depends
455 solely on its inputs---for instance, it cannot refer to software or
456 scripts that were not explicitly passed as inputs. A build function
457 always produces the same result when passed a given set of inputs. It
458 cannot alter the environment of the running system in
459 any way; for instance, it cannot create, modify, or delete files outside
460 of its build and installation directories. This is achieved by running
461 build processes in isolated environments (or @dfn{containers}), where only their
462 explicit inputs are visible.
463
464 @cindex store
465 The result of package build functions is @dfn{cached} in the file
466 system, in a special directory called @dfn{the store} (@pxref{The
467 Store}). Each package is installed in a directory of its own in the
468 store---by default under @file{/gnu/store}. The directory name contains
469 a hash of all the inputs used to build that package; thus, changing an
470 input yields a different directory name.
471
472 This approach is the foundation for the salient features of Guix: support
473 for transactional package upgrade and rollback, per-user installation, and
474 garbage collection of packages (@pxref{Features}).
475
476
477 @node GNU Distribution
478 @section GNU Distribution
479
480 @cindex Guix System
481 Guix comes with a distribution of the GNU system consisting entirely of
482 free software@footnote{The term ``free'' here refers to the
483 @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
484 users of that software}.}. The
485 distribution can be installed on its own (@pxref{System Installation}),
486 but it is also possible to install Guix as a package manager on top of
487 an installed GNU/Linux system (@pxref{Installation}). When we need to
488 distinguish between the two, we refer to the standalone distribution as
489 Guix@tie{}System.
490
491 The distribution provides core GNU packages such as GNU libc, GCC, and
492 Binutils, as well as many GNU and non-GNU applications. The complete
493 list of available packages can be browsed
494 @url{https://www.gnu.org/software/guix/packages,on-line} or by
495 running @command{guix package} (@pxref{Invoking guix package}):
496
497 @example
498 guix package --list-available
499 @end example
500
501 Our goal is to provide a practical 100% free software distribution of
502 Linux-based and other variants of GNU, with a focus on the promotion and
503 tight integration of GNU components, and an emphasis on programs and
504 tools that help users exert that freedom.
505
506 Packages are currently available on the following platforms:
507
508 @table @code
509
510 @item x86_64-linux
511 Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
512
513 @item i686-linux
514 Intel 32-bit architecture (IA32), Linux-Libre kernel.
515
516 @item armhf-linux
517 ARMv7-A architecture with hard float, Thumb-2 and NEON,
518 using the EABI hard-float application binary interface (ABI),
519 and Linux-Libre kernel.
520
521 @item aarch64-linux
522 little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
523
524 @item i586-gnu
525 @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
526 (IA32).
527
528 This configuration is experimental and under development. The easiest
529 way for you to give it a try is by setting up an instance of
530 @code{hurd-vm-service-type} on your GNU/Linux machine
531 (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
532 @xref{Contributing}, on how to help!
533
534 @item mips64el-linux (deprecated)
535 little-endian 64-bit MIPS processors, specifically the Loongson series,
536 n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
537 supported; in particular, there is no ongoing work to ensure that this
538 architecture still works. Should someone decide they wish to revive this
539 architecture then the code is still available.
540
541 @item powerpc64le-linux
542 little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
543 includes POWER9 systems such as the
544 @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
545 RYF Talos II mainboard}. This platform is available as a "technology
546 preview": although it is supported, substitutes are not yet available
547 from the build farm (@pxref{Substitutes}), and some packages may fail to
548 build (@pxref{Tracking Bugs and Patches}). That said, the Guix
549 community is actively working on improving this support, and now is a
550 great time to try it and get involved!
551
552 @end table
553
554 With Guix@tie{}System, you @emph{declare} all aspects of the operating system
555 configuration and Guix takes care of instantiating the configuration in a
556 transactional, reproducible, and stateless fashion (@pxref{System
557 Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
558 initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
559 Manual}), the well-known GNU utilities and tool chain, as well as the
560 graphical environment or system services of your choice.
561
562 Guix System is available on all the above platforms except
563 @code{mips64el-linux} and @code{powerpc64le-linux}.
564
565 @noindent
566 For information on porting to other architectures or kernels,
567 @pxref{Porting}.
568
569 Building this distribution is a cooperative effort, and you are invited
570 to join! @xref{Contributing}, for information about how you can help.
571
572
573 @c *********************************************************************
574 @node Installation
575 @chapter Installation
576
577 @cindex installing Guix
578
579 @quotation Note
580 We recommend the use of this
581 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
582 shell installer script} to install Guix on top of a running GNU/Linux system,
583 thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
584 with the installation of the package manager, which can be done on top of a
585 running GNU/Linux system. If, instead, you want to install the complete GNU
586 operating system, @pxref{System Installation}.} The script automates the
587 download, installation, and initial configuration of Guix. It should be run
588 as the root user.
589 @end quotation
590
591 @cindex foreign distro
592 @cindex directories related to foreign distro
593 When installed on a foreign distro, GNU@tie{}Guix complements the available
594 tools without interference. Its data lives exclusively in two directories,
595 usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
596 such as @file{/etc}, are left untouched.
597
598 Once installed, Guix can be updated by running @command{guix pull}
599 (@pxref{Invoking guix pull}).
600
601 If you prefer to perform the installation steps manually or want to tweak
602 them, you may find the following subsections useful. They describe the
603 software requirements of Guix, as well as how to install it manually and get
604 ready to use it.
605
606 @menu
607 * Binary Installation:: Getting Guix running in no time!
608 * Requirements:: Software needed to build and run Guix.
609 * Running the Test Suite:: Testing Guix.
610 * Setting Up the Daemon:: Preparing the build daemon's environment.
611 * Invoking guix-daemon:: Running the build daemon.
612 * Application Setup:: Application-specific setup.
613 * Upgrading Guix:: Upgrading Guix and its build daemon.
614 @end menu
615
616 @node Binary Installation
617 @section Binary Installation
618
619 @cindex installing Guix from binaries
620 @cindex installer script
621 This section describes how to install Guix on an arbitrary system from a
622 self-contained tarball providing binaries for Guix and for all its
623 dependencies. This is often quicker than installing from source, which
624 is described in the next sections. The only requirement is to have
625 GNU@tie{}tar and Xz.
626
627 @c Note duplicated from the ``Installation'' node.
628 @quotation Note
629 We recommend the use of this
630 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
631 shell installer script}. The script automates the download, installation, and
632 initial configuration steps described below. It should be run as the root
633 user. As root, you can thus run this:
634
635 @example
636 cd /tmp
637 wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
638 chmod +x guix-install.sh
639 ./guix-install.sh
640 @end example
641
642 When you're done, @pxref{Application Setup} for extra configuration you
643 might need, and @ref{Getting Started} for your first steps!
644 @end quotation
645
646 Installing goes along these lines:
647
648 @enumerate
649 @item
650 @cindex downloading Guix binary
651 Download the binary tarball from
652 @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
653 where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
654 @code{i686} (32-bits) machine already running the kernel Linux, and so on
655 (@pxref{GNU Distribution}).
656
657 @c The following is somewhat duplicated in ``System Installation''.
658 Make sure to download the associated @file{.sig} file and to verify the
659 authenticity of the tarball against it, along these lines:
660
661 @example
662 $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
663 $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
664 @end example
665
666 If that command fails because you do not have the required public key,
667 then run this command to import it:
668
669 @example
670 $ wget '@value{OPENPGP-SIGNING-KEY-URL}' \
671 -qO - | gpg --import -
672 @end example
673
674 @noindent
675 and rerun the @code{gpg --verify} command.
676
677 Take note that a warning like ``This key is not certified with a trusted
678 signature!'' is normal.
679
680 @c end authentication part
681
682 @item
683 Now, you need to become the @code{root} user. Depending on your distribution,
684 you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
685
686 @example
687 # cd /tmp
688 # tar --warning=no-timestamp -xf \
689 /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
690 # mv var/guix /var/ && mv gnu /
691 @end example
692
693 This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
694 The latter contains a ready-to-use profile for @code{root} (see next
695 step).
696
697 Do @emph{not} unpack the tarball on a working Guix system since that
698 would overwrite its own essential files.
699
700 The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
701 not emit warnings about ``implausibly old time stamps'' (such
702 warnings were triggered by GNU@tie{}tar 1.26 and older; recent
703 versions are fine).
704 They stem from the fact that all the
705 files in the archive have their modification time set to 1 (which
706 means January 1st, 1970). This is done on purpose to make sure the
707 archive content is independent of its creation time, thus making it
708 reproducible.
709
710 @item
711 Make the profile available under @file{~root/.config/guix/current}, which is
712 where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
713
714 @example
715 # mkdir -p ~root/.config/guix
716 # ln -sf /var/guix/profiles/per-user/root/current-guix \
717 ~root/.config/guix/current
718 @end example
719
720 Source @file{etc/profile} to augment @env{PATH} and other relevant
721 environment variables:
722
723 @example
724 # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
725 source $GUIX_PROFILE/etc/profile
726 @end example
727
728 @item
729 Create the group and user accounts for build users as explained below
730 (@pxref{Build Environment Setup}).
731
732 @item
733 Run the daemon, and set it to automatically start on boot.
734
735 If your host distro uses the systemd init system, this can be achieved
736 with these commands:
737
738 @c Versions of systemd that supported symlinked service files are not
739 @c yet widely deployed, so we should suggest that users copy the service
740 @c files into place.
741 @c
742 @c See this thread for more information:
743 @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
744
745 @example
746 # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
747 ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
748 /etc/systemd/system/
749 # systemctl enable --now gnu-store.mount guix-daemon
750 @end example
751
752 You may also want to arrange for @command{guix gc} to run periodically:
753
754 @example
755 # cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
756 ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
757 /etc/systemd/system/
758 # systemctl enable --now guix-gc.timer
759 @end example
760
761 You may want to edit @file{guix-gc.service} to adjust the command line
762 options to fit your needs (@pxref{Invoking guix gc}).
763
764 If your host distro uses the Upstart init system:
765
766 @example
767 # initctl reload-configuration
768 # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
769 /etc/init/
770 # start guix-daemon
771 @end example
772
773 Otherwise, you can still start the daemon manually with:
774
775 @example
776 # ~root/.config/guix/current/bin/guix-daemon \
777 --build-users-group=guixbuild
778 @end example
779
780 @item
781 Make the @command{guix} command available to other users on the machine,
782 for instance with:
783
784 @example
785 # mkdir -p /usr/local/bin
786 # cd /usr/local/bin
787 # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
788 @end example
789
790 It is also a good idea to make the Info version of this manual available
791 there:
792
793 @example
794 # mkdir -p /usr/local/share/info
795 # cd /usr/local/share/info
796 # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
797 do ln -s $i ; done
798 @end example
799
800 That way, assuming @file{/usr/local/share/info} is in the search path,
801 running @command{info guix} will open this manual (@pxref{Other Info
802 Directories,,, texinfo, GNU Texinfo}, for more details on changing the
803 Info search path).
804
805 @item
806 @cindex substitutes, authorization thereof
807 To use substitutes from @code{@value{SUBSTITUTE-SERVER-1}},
808 @code{@value{SUBSTITUTE-SERVER-2}} or a mirror (@pxref{Substitutes}),
809 authorize them:
810
811 @example
812 # guix archive --authorize < \
813 ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
814 # guix archive --authorize < \
815 ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
816 @end example
817
818 @quotation Note
819 If you do not enable substitutes, Guix will end up building
820 @emph{everything} from source on your machine, making each installation
821 and upgrade very expensive. @xref{On Trusting Binaries}, for a
822 discussion of reasons why one might want do disable substitutes.
823 @end quotation
824
825 @item
826 Each user may need to perform a few additional steps to make their Guix
827 environment ready for use, @pxref{Application Setup}.
828 @end enumerate
829
830 Voilà, the installation is complete!
831
832 You can confirm that Guix is working by installing a sample package into
833 the root profile:
834
835 @example
836 # guix install hello
837 @end example
838
839 The binary installation tarball can be (re)produced and verified simply
840 by running the following command in the Guix source tree:
841
842 @example
843 make guix-binary.@var{system}.tar.xz
844 @end example
845
846 @noindent
847 ...@: which, in turn, runs:
848
849 @example
850 guix pack -s @var{system} --localstatedir \
851 --profile-name=current-guix guix
852 @end example
853
854 @xref{Invoking guix pack}, for more info on this handy tool.
855
856 @node Requirements
857 @section Requirements
858
859 This section lists requirements when building Guix from source. The
860 build procedure for Guix is the same as for other GNU software, and is
861 not covered here. Please see the files @file{README} and @file{INSTALL}
862 in the Guix source tree for additional details.
863
864 @cindex official website
865 GNU Guix is available for download from its website at
866 @url{https://www.gnu.org/software/guix/}.
867
868 GNU Guix depends on the following packages:
869
870 @itemize
871 @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x;
872 @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
873 0.1.0 or later;
874 @item
875 @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
876 (@pxref{Guile Preparations, how to install the GnuTLS bindings for
877 Guile,, gnutls-guile, GnuTLS-Guile});
878 @item
879 @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
880 or later;
881 @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
882 version 0.1.0 or later;
883 @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
884 @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
885 @item
886 @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.5.0
887 or later;
888 @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
889 4.3.0 or later;
890 @item @url{https://www.gnu.org/software/make/, GNU Make}.
891 @end itemize
892
893 The following dependencies are optional:
894
895 @itemize
896 @item
897 @c Note: We need at least 0.13.0 for #:nodelay.
898 Support for build offloading (@pxref{Daemon Offload Setup}) and
899 @command{guix copy} (@pxref{Invoking guix copy}) depends on
900 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
901 version 0.13.0 or later.
902
903 @item
904 @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
905 compression and decompression in @command{guix publish} and for
906 substitutes (@pxref{Invoking guix publish}).
907
908 @item
909 @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
910 the @code{crate} importer (@pxref{Invoking guix import}).
911
912 @item
913 @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
914 the @code{go} importer (@pxref{Invoking guix import}) and for some of
915 the ``updaters'' (@pxref{Invoking guix refresh}).
916
917 @item
918 When @url{http://www.bzip.org, libbz2} is available,
919 @command{guix-daemon} can use it to compress build logs.
920 @end itemize
921
922 Unless @option{--disable-daemon} was passed to @command{configure}, the
923 following packages are also needed:
924
925 @itemize
926 @item @url{https://gnupg.org/, GNU libgcrypt};
927 @item @url{https://sqlite.org, SQLite 3};
928 @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
929 C++11 standard.
930 @end itemize
931
932 @cindex state directory
933 When configuring Guix on a system that already has a Guix installation,
934 be sure to specify the same state directory as the existing installation
935 using the @option{--localstatedir} option of the @command{configure}
936 script (@pxref{Directory Variables, @code{localstatedir},, standards,
937 GNU Coding Standards}). Usually, this @var{localstatedir} option is
938 set to the value @file{/var}. The @command{configure} script protects
939 against unintended misconfiguration of @var{localstatedir} so you do not
940 inadvertently corrupt your store (@pxref{The Store}).
941
942 @node Running the Test Suite
943 @section Running the Test Suite
944
945 @cindex test suite
946 After a successful @command{configure} and @code{make} run, it is a good
947 idea to run the test suite. It can help catch issues with the setup or
948 environment, or bugs in Guix itself---and really, reporting test
949 failures is a good way to help improve the software. To run the test
950 suite, type:
951
952 @example
953 make check
954 @end example
955
956 Test cases can run in parallel: you can use the @code{-j} option of
957 GNU@tie{}make to speed things up. The first run may take a few minutes
958 on a recent machine; subsequent runs will be faster because the store
959 that is created for test purposes will already have various things in
960 cache.
961
962 It is also possible to run a subset of the tests by defining the
963 @code{TESTS} makefile variable as in this example:
964
965 @example
966 make check TESTS="tests/store.scm tests/cpio.scm"
967 @end example
968
969 By default, tests results are displayed at a file level. In order to
970 see the details of every individual test cases, it is possible to define
971 the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
972
973 @example
974 make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
975 @end example
976
977 The underlying SRFI 64 custom Automake test driver used for the 'check'
978 test suite (located at @file{build-aux/test-driver.scm}) also allows
979 selecting which test cases to run at a finer level, via its
980 @option{--select} and @option{--exclude} options. Here's an example, to
981 run all the test cases from the @file{tests/packages.scm} test file
982 whose names start with ``transaction-upgrade-entry'':
983
984 @example
985 export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
986 make check TESTS="tests/packages.scm"
987 @end example
988
989 Those wishing to inspect the results of failed tests directly from the
990 command line can add the @option{--errors-only=yes} option to the
991 @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
992 Automake makefile variable, as in:
993
994 @example
995 make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
996 @end example
997
998 The @option{--show-duration=yes} option can be used to print the
999 duration of the individual test cases, when used in combination with
1000 @option{--brief=no}:
1001
1002 @example
1003 make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
1004 @end example
1005
1006 @xref{Parallel Test Harness,,,automake,GNU Automake} for more
1007 information about the Automake Parallel Test Harness.
1008
1009 Upon failure, please email @email{bug-guix@@gnu.org} and attach the
1010 @file{test-suite.log} file. Please specify the Guix version being used
1011 as well as version numbers of the dependencies (@pxref{Requirements}) in
1012 your message.
1013
1014 Guix also comes with a whole-system test suite that tests complete
1015 Guix System instances. It can only run on systems where
1016 Guix is already installed, using:
1017
1018 @example
1019 make check-system
1020 @end example
1021
1022 @noindent
1023 or, again, by defining @code{TESTS} to select a subset of tests to run:
1024
1025 @example
1026 make check-system TESTS="basic mcron"
1027 @end example
1028
1029 These system tests are defined in the @code{(gnu tests @dots{})}
1030 modules. They work by running the operating systems under test with
1031 lightweight instrumentation in a virtual machine (VM). They can be
1032 computationally intensive or rather cheap, depending on whether
1033 substitutes are available for their dependencies (@pxref{Substitutes}).
1034 Some of them require a lot of storage space to hold VM images.
1035
1036 Again in case of test failures, please send @email{bug-guix@@gnu.org}
1037 all the details.
1038
1039 @node Setting Up the Daemon
1040 @section Setting Up the Daemon
1041
1042 @cindex daemon
1043 Operations such as building a package or running the garbage collector
1044 are all performed by a specialized process, the @dfn{build daemon}, on
1045 behalf of clients. Only the daemon may access the store and its
1046 associated database. Thus, any operation that manipulates the store
1047 goes through the daemon. For instance, command-line tools such as
1048 @command{guix package} and @command{guix build} communicate with the
1049 daemon (@i{via} remote procedure calls) to instruct it what to do.
1050
1051 The following sections explain how to prepare the build daemon's
1052 environment. See also @ref{Substitutes}, for information on how to allow
1053 the daemon to download pre-built binaries.
1054
1055 @menu
1056 * Build Environment Setup:: Preparing the isolated build environment.
1057 * Daemon Offload Setup:: Offloading builds to remote machines.
1058 * SELinux Support:: Using an SELinux policy for the daemon.
1059 @end menu
1060
1061 @node Build Environment Setup
1062 @subsection Build Environment Setup
1063
1064 @cindex build environment
1065 In a standard multi-user setup, Guix and its daemon---the
1066 @command{guix-daemon} program---are installed by the system
1067 administrator; @file{/gnu/store} is owned by @code{root} and
1068 @command{guix-daemon} runs as @code{root}. Unprivileged users may use
1069 Guix tools to build packages or otherwise access the store, and the
1070 daemon will do it on their behalf, ensuring that the store is kept in a
1071 consistent state, and allowing built packages to be shared among users.
1072
1073 @cindex build users
1074 When @command{guix-daemon} runs as @code{root}, you may not want package
1075 build processes themselves to run as @code{root} too, for obvious
1076 security reasons. To avoid that, a special pool of @dfn{build users}
1077 should be created for use by build processes started by the daemon.
1078 These build users need not have a shell and a home directory: they will
1079 just be used when the daemon drops @code{root} privileges in build
1080 processes. Having several such users allows the daemon to launch
1081 distinct build processes under separate UIDs, which guarantees that they
1082 do not interfere with each other---an essential feature since builds are
1083 regarded as pure functions (@pxref{Introduction}).
1084
1085 On a GNU/Linux system, a build user pool may be created like this (using
1086 Bash syntax and the @code{shadow} commands):
1087
1088 @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
1089 @c for why `-G' is needed.
1090 @example
1091 # groupadd --system guixbuild
1092 # for i in $(seq -w 1 10);
1093 do
1094 useradd -g guixbuild -G guixbuild \
1095 -d /var/empty -s $(which nologin) \
1096 -c "Guix build user $i" --system \
1097 guixbuilder$i;
1098 done
1099 @end example
1100
1101 @noindent
1102 The number of build users determines how many build jobs may run in
1103 parallel, as specified by the @option{--max-jobs} option
1104 (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
1105 @command{guix system vm} and related commands, you may need to add the
1106 build users to the @code{kvm} group so they can access @file{/dev/kvm},
1107 using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
1108 (@pxref{Invoking guix system}).
1109
1110 The @code{guix-daemon} program may then be run as @code{root} with the
1111 following command@footnote{If your machine uses the systemd init system,
1112 dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
1113 file in @file{/etc/systemd/system} will ensure that
1114 @command{guix-daemon} is automatically started. Similarly, if your
1115 machine uses the Upstart init system, drop the
1116 @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
1117 file in @file{/etc/init}.}:
1118
1119 @example
1120 # guix-daemon --build-users-group=guixbuild
1121 @end example
1122
1123 @cindex chroot
1124 @noindent
1125 This way, the daemon starts build processes in a chroot, under one of
1126 the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
1127 environment contains nothing but:
1128
1129 @c Keep this list in sync with libstore/build.cc! -----------------------
1130 @itemize
1131 @item
1132 a minimal @code{/dev} directory, created mostly independently from the
1133 host @code{/dev}@footnote{``Mostly'', because while the set of files
1134 that appear in the chroot's @code{/dev} is fixed, most of these files
1135 can only be created if the host has them.};
1136
1137 @item
1138 the @code{/proc} directory; it only shows the processes of the container
1139 since a separate PID name space is used;
1140
1141 @item
1142 @file{/etc/passwd} with an entry for the current user and an entry for
1143 user @file{nobody};
1144
1145 @item
1146 @file{/etc/group} with an entry for the user's group;
1147
1148 @item
1149 @file{/etc/hosts} with an entry that maps @code{localhost} to
1150 @code{127.0.0.1};
1151
1152 @item
1153 a writable @file{/tmp} directory.
1154 @end itemize
1155
1156 You can influence the directory where the daemon stores build trees
1157 @i{via} the @env{TMPDIR} environment variable. However, the build tree
1158 within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
1159 where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
1160 This way, the value of @env{TMPDIR} does not leak inside build
1161 environments, which avoids discrepancies in cases where build processes
1162 capture the name of their build tree.
1163
1164 @vindex http_proxy
1165 @vindex https_proxy
1166 The daemon also honors the @env{http_proxy} and @env{https_proxy}
1167 environment variables for HTTP and HTTPS downloads it performs, be it
1168 for fixed-output derivations (@pxref{Derivations}) or for substitutes
1169 (@pxref{Substitutes}).
1170
1171 If you are installing Guix as an unprivileged user, it is still possible
1172 to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
1173 However, build processes will not be isolated from one another, and not
1174 from the rest of the system. Thus, build processes may interfere with
1175 each other, and may access programs, libraries, and other files
1176 available on the system---making it much harder to view them as
1177 @emph{pure} functions.
1178
1179
1180 @node Daemon Offload Setup
1181 @subsection Using the Offload Facility
1182
1183 @cindex offloading
1184 @cindex build hook
1185 When desired, the build daemon can @dfn{offload} derivation builds to
1186 other machines running Guix, using the @code{offload} @dfn{build
1187 hook}@footnote{This feature is available only when
1188 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
1189 present.}. When that feature is enabled, a list of user-specified build
1190 machines is read from @file{/etc/guix/machines.scm}; every time a build
1191 is requested, for instance via @code{guix build}, the daemon attempts to
1192 offload it to one of the machines that satisfy the constraints of the
1193 derivation, in particular its system types---e.g., @code{x86_64-linux}.
1194 A single machine can have multiple system types, either because its
1195 architecture natively supports it, via emulation
1196 (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
1197 or both. Missing prerequisites for the build are
1198 copied over SSH to the target machine, which then proceeds with the
1199 build; upon success the output(s) of the build are copied back to the
1200 initial machine. The offload facility comes with a basic scheduler that
1201 attempts to select the best machine. The best machine is chosen among
1202 the available machines based on criteria such as:
1203
1204 @enumerate
1205 @item
1206 The availability of a build slot. A build machine can have as many
1207 build slots (connections) as the value of the @code{parallel-builds}
1208 field of its @code{build-machine} object.
1209
1210 @item
1211 Its relative speed, as defined via the @code{speed} field of its
1212 @code{build-machine} object.
1213
1214 @item
1215 Its load. The normalized machine load must be lower than a threshold
1216 value, configurable via the @code{overload-threshold} field of its
1217 @code{build-machine} object.
1218
1219 @item
1220 Disk space availability. More than a 100 MiB must be available.
1221 @end enumerate
1222
1223 The @file{/etc/guix/machines.scm} file typically looks like this:
1224
1225 @lisp
1226 (list (build-machine
1227 (name "eightysix.example.org")
1228 (systems (list "x86_64-linux" "i686-linux"))
1229 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
1230 (user "bob")
1231 (speed 2.)) ;incredibly fast!
1232
1233 (build-machine
1234 (name "armeight.example.org")
1235 (systems (list "aarch64-linux"))
1236 (host-key "ssh-rsa AAAAB3Nza@dots{}")
1237 (user "alice")
1238 (private-key
1239 (string-append (getenv "HOME")
1240 "/.ssh/identity-for-guix"))))
1241 @end lisp
1242
1243 @noindent
1244 In the example above we specify a list of two build machines, one for
1245 the @code{x86_64} and @code{i686} architectures and one for the
1246 @code{aarch64} architecture.
1247
1248 In fact, this file is---not surprisingly!---a Scheme file that is
1249 evaluated when the @code{offload} hook is started. Its return value
1250 must be a list of @code{build-machine} objects. While this example
1251 shows a fixed list of build machines, one could imagine, say, using
1252 DNS-SD to return a list of potential build machines discovered in the
1253 local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
1254 Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
1255 detailed below.
1256
1257 @deftp {Data Type} build-machine
1258 This data type represents build machines to which the daemon may offload
1259 builds. The important fields are:
1260
1261 @table @code
1262
1263 @item name
1264 The host name of the remote machine.
1265
1266 @item systems
1267 The system types the remote machine supports---e.g., @code{(list
1268 "x86_64-linux" "i686-linux")}.
1269
1270 @item user
1271 The user account to use when connecting to the remote machine over SSH.
1272 Note that the SSH key pair must @emph{not} be passphrase-protected, to
1273 allow non-interactive logins.
1274
1275 @item host-key
1276 This must be the machine's SSH @dfn{public host key} in OpenSSH format.
1277 This is used to authenticate the machine when we connect to it. It is a
1278 long string that looks like this:
1279
1280 @example
1281 ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
1282 @end example
1283
1284 If the machine is running the OpenSSH daemon, @command{sshd}, the host
1285 key can be found in a file such as
1286 @file{/etc/ssh/ssh_host_ed25519_key.pub}.
1287
1288 If the machine is running the SSH daemon of GNU@tie{}lsh,
1289 @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
1290 similar file. It can be converted to the OpenSSH format using
1291 @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
1292
1293 @example
1294 $ lsh-export-key --openssh < /etc/lsh/host-key.pub
1295 ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
1296 @end example
1297
1298 @end table
1299
1300 A number of optional fields may be specified:
1301
1302 @table @asis
1303
1304 @item @code{port} (default: @code{22})
1305 Port number of SSH server on the machine.
1306
1307 @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
1308 The SSH private key file to use when connecting to the machine, in
1309 OpenSSH format. This key must not be protected with a passphrase.
1310
1311 Note that the default value is the private key @emph{of the root
1312 account}. Make sure it exists if you use the default.
1313
1314 @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
1315 @itemx @code{compression-level} (default: @code{3})
1316 The SSH-level compression methods and compression level requested.
1317
1318 Note that offloading relies on SSH compression to reduce bandwidth usage
1319 when transferring files to and from build machines.
1320
1321 @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
1322 File name of the Unix-domain socket @command{guix-daemon} is listening
1323 to on that machine.
1324
1325 @item @code{overload-threshold} (default: @code{0.6})
1326 The load threshold above which a potential offload machine is
1327 disregarded by the offload scheduler. The value roughly translates to
1328 the total processor usage of the build machine, ranging from 0.0 (0%) to
1329 1.0 (100%). It can also be disabled by setting
1330 @code{overload-threshold} to @code{#f}.
1331
1332 @item @code{parallel-builds} (default: @code{1})
1333 The number of builds that may run in parallel on the machine.
1334
1335 @item @code{speed} (default: @code{1.0})
1336 A ``relative speed factor''. The offload scheduler will tend to prefer
1337 machines with a higher speed factor.
1338
1339 @item @code{features} (default: @code{'()})
1340 A list of strings denoting specific features supported by the machine.
1341 An example is @code{"kvm"} for machines that have the KVM Linux modules
1342 and corresponding hardware support. Derivations can request features by
1343 name, and they will be scheduled on matching build machines.
1344
1345 @end table
1346 @end deftp
1347
1348 The @command{guix} command must be in the search path on the build
1349 machines. You can check whether this is the case by running:
1350
1351 @example
1352 ssh build-machine guix repl --version
1353 @end example
1354
1355 There is one last thing to do once @file{machines.scm} is in place. As
1356 explained above, when offloading, files are transferred back and forth
1357 between the machine stores. For this to work, you first need to
1358 generate a key pair on each machine to allow the daemon to export signed
1359 archives of files from the store (@pxref{Invoking guix archive}):
1360
1361 @example
1362 # guix archive --generate-key
1363 @end example
1364
1365 @noindent
1366 Each build machine must authorize the key of the master machine so that
1367 it accepts store items it receives from the master:
1368
1369 @example
1370 # guix archive --authorize < master-public-key.txt
1371 @end example
1372
1373 @noindent
1374 Likewise, the master machine must authorize the key of each build machine.
1375
1376 All the fuss with keys is here to express pairwise mutual trust
1377 relations between the master and the build machines. Concretely, when
1378 the master receives files from a build machine (and @i{vice versa}), its
1379 build daemon can make sure they are genuine, have not been tampered
1380 with, and that they are signed by an authorized key.
1381
1382 @cindex offload test
1383 To test whether your setup is operational, run this command on the
1384 master node:
1385
1386 @example
1387 # guix offload test
1388 @end example
1389
1390 This will attempt to connect to each of the build machines specified in
1391 @file{/etc/guix/machines.scm}, make sure Guix is
1392 available on each machine, attempt to export to the machine and import
1393 from it, and report any error in the process.
1394
1395 If you want to test a different machine file, just specify it on the
1396 command line:
1397
1398 @example
1399 # guix offload test machines-qualif.scm
1400 @end example
1401
1402 Last, you can test the subset of the machines whose name matches a
1403 regular expression like this:
1404
1405 @example
1406 # guix offload test machines.scm '\.gnu\.org$'
1407 @end example
1408
1409 @cindex offload status
1410 To display the current load of all build hosts, run this command on the
1411 main node:
1412
1413 @example
1414 # guix offload status
1415 @end example
1416
1417
1418 @node SELinux Support
1419 @subsection SELinux Support
1420
1421 @cindex SELinux, daemon policy
1422 @cindex mandatory access control, SELinux
1423 @cindex security, guix-daemon
1424 Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
1425 can be installed on a system where SELinux is enabled, in order to label
1426 Guix files and to specify the expected behavior of the daemon. Since
1427 Guix System does not provide an SELinux base policy, the daemon policy cannot
1428 be used on Guix System.
1429
1430 @subsubsection Installing the SELinux policy
1431 @cindex SELinux, policy installation
1432 To install the policy run this command as root:
1433
1434 @example
1435 semodule -i etc/guix-daemon.cil
1436 @end example
1437
1438 Then relabel the file system with @code{restorecon} or by a different
1439 mechanism provided by your system.
1440
1441 Once the policy is installed, the file system has been relabeled, and
1442 the daemon has been restarted, it should be running in the
1443 @code{guix_daemon_t} context. You can confirm this with the following
1444 command:
1445
1446 @example
1447 ps -Zax | grep guix-daemon
1448 @end example
1449
1450 Monitor the SELinux log files as you run a command like @code{guix build
1451 hello} to convince yourself that SELinux permits all necessary
1452 operations.
1453
1454 @subsubsection Limitations
1455 @cindex SELinux, limitations
1456
1457 This policy is not perfect. Here is a list of limitations or quirks
1458 that should be considered when deploying the provided SELinux policy for
1459 the Guix daemon.
1460
1461 @enumerate
1462 @item
1463 @code{guix_daemon_socket_t} isn’t actually used. None of the socket
1464 operations involve contexts that have anything to do with
1465 @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
1466 but it would be preferable to define socket rules for only this label.
1467
1468 @item
1469 @code{guix gc} cannot access arbitrary links to profiles. By design,
1470 the file label of the destination of a symlink is independent of the
1471 file label of the link itself. Although all profiles under
1472 $localstatedir are labelled, the links to these profiles inherit the
1473 label of the directory they are in. For links in the user’s home
1474 directory this will be @code{user_home_t}. But for links from the root
1475 user’s home directory, or @file{/tmp}, or the HTTP server’s working
1476 directory, etc, this won’t work. @code{guix gc} would be prevented from
1477 reading and following these links.
1478
1479 @item
1480 The daemon’s feature to listen for TCP connections might no longer work.
1481 This might require extra rules, because SELinux treats network sockets
1482 differently from files.
1483
1484 @item
1485 Currently all files with a name matching the regular expression
1486 @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
1487 label @code{guix_daemon_exec_t}; this means that @emph{any} file with
1488 that name in any profile would be permitted to run in the
1489 @code{guix_daemon_t} domain. This is not ideal. An attacker could
1490 build a package that provides this executable and convince a user to
1491 install and run it, which lifts it into the @code{guix_daemon_t} domain.
1492 At that point SELinux could not prevent it from accessing files that are
1493 allowed for processes in that domain.
1494
1495 You will need to relabel the store directory after all upgrades to
1496 @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
1497 store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
1498 or by other means provided by your operating system.
1499
1500 We could generate a much more restrictive policy at installation time,
1501 so that only the @emph{exact} file name of the currently installed
1502 @code{guix-daemon} executable would be labelled with
1503 @code{guix_daemon_exec_t}, instead of using a broad regular expression.
1504 The downside is that root would have to install or upgrade the policy at
1505 installation time whenever the Guix package that provides the
1506 effectively running @code{guix-daemon} executable is upgraded.
1507 @end enumerate
1508
1509 @node Invoking guix-daemon
1510 @section Invoking @command{guix-daemon}
1511
1512 The @command{guix-daemon} program implements all the functionality to
1513 access the store. This includes launching build processes, running the
1514 garbage collector, querying the availability of a build result, etc. It
1515 is normally run as @code{root} like this:
1516
1517 @example
1518 # guix-daemon --build-users-group=guixbuild
1519 @end example
1520
1521 @noindent
1522 For details on how to set it up, @pxref{Setting Up the Daemon}.
1523
1524 @cindex chroot
1525 @cindex container, build environment
1526 @cindex build environment
1527 @cindex reproducible builds
1528 By default, @command{guix-daemon} launches build processes under
1529 different UIDs, taken from the build group specified with
1530 @option{--build-users-group}. In addition, each build process is run in a
1531 chroot environment that only contains the subset of the store that the
1532 build process depends on, as specified by its derivation
1533 (@pxref{Programming Interface, derivation}), plus a set of specific
1534 system directories. By default, the latter contains @file{/dev} and
1535 @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1536 @dfn{container}: in addition to having its own file system tree, it has
1537 a separate mount name space, its own PID name space, network name space,
1538 etc. This helps achieve reproducible builds (@pxref{Features}).
1539
1540 When the daemon performs a build on behalf of the user, it creates a
1541 build directory under @file{/tmp} or under the directory specified by
1542 its @env{TMPDIR} environment variable. This directory is shared with
1543 the container for the duration of the build, though within the container,
1544 the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
1545
1546 The build directory is automatically deleted upon completion, unless the
1547 build failed and the client specified @option{--keep-failed}
1548 (@pxref{Common Build Options, @option{--keep-failed}}).
1549
1550 The daemon listens for connections and spawns one sub-process for each session
1551 started by a client (one of the @command{guix} sub-commands). The
1552 @command{guix processes} command allows you to get an overview of the activity
1553 on your system by viewing each of the active sessions and clients.
1554 @xref{Invoking guix processes}, for more information.
1555
1556 The following command-line options are supported:
1557
1558 @table @code
1559 @item --build-users-group=@var{group}
1560 Take users from @var{group} to run build processes (@pxref{Setting Up
1561 the Daemon, build users}).
1562
1563 @item --no-substitutes
1564 @cindex substitutes
1565 Do not use substitutes for build products. That is, always build things
1566 locally instead of allowing downloads of pre-built binaries
1567 (@pxref{Substitutes}).
1568
1569 When the daemon runs with @option{--no-substitutes}, clients can still
1570 explicitly enable substitution @i{via} the @code{set-build-options}
1571 remote procedure call (@pxref{The Store}).
1572
1573 @anchor{daemon-substitute-urls}
1574 @item --substitute-urls=@var{urls}
1575 Consider @var{urls} the default whitespace-separated list of substitute
1576 source URLs. When this option is omitted,
1577 @indicateurl{@value{SUBSTITUTE-URLS}} is used.
1578
1579 This means that substitutes may be downloaded from @var{urls}, as long
1580 as they are signed by a trusted signature (@pxref{Substitutes}).
1581
1582 @xref{Getting Substitutes from Other Servers}, for more information on
1583 how to configure the daemon to get substitutes from other servers.
1584
1585 @cindex offloading
1586 @item --no-offload
1587 Do not use offload builds to other machines (@pxref{Daemon Offload
1588 Setup}). That is, always build things locally instead of offloading
1589 builds to remote machines.
1590
1591 @item --cache-failures
1592 Cache build failures. By default, only successful builds are cached.
1593
1594 When this option is used, @command{guix gc --list-failures} can be used
1595 to query the set of store items marked as failed; @command{guix gc
1596 --clear-failures} removes store items from the set of cached failures.
1597 @xref{Invoking guix gc}.
1598
1599 @item --cores=@var{n}
1600 @itemx -c @var{n}
1601 Use @var{n} CPU cores to build each derivation; @code{0} means as many
1602 as available.
1603
1604 The default value is @code{0}, but it may be overridden by clients, such
1605 as the @option{--cores} option of @command{guix build} (@pxref{Invoking
1606 guix build}).
1607
1608 The effect is to define the @env{NIX_BUILD_CORES} environment variable
1609 in the build process, which can then use it to exploit internal
1610 parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1611
1612 @item --max-jobs=@var{n}
1613 @itemx -M @var{n}
1614 Allow at most @var{n} build jobs in parallel. The default value is
1615 @code{1}. Setting it to @code{0} means that no builds will be performed
1616 locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1617 Setup}), or simply fail.
1618
1619 @item --max-silent-time=@var{seconds}
1620 When the build or substitution process remains silent for more than
1621 @var{seconds}, terminate it and report a build failure.
1622
1623 The default value is @code{0}, which disables the timeout.
1624
1625 The value specified here can be overridden by clients (@pxref{Common
1626 Build Options, @option{--max-silent-time}}).
1627
1628 @item --timeout=@var{seconds}
1629 Likewise, when the build or substitution process lasts for more than
1630 @var{seconds}, terminate it and report a build failure.
1631
1632 The default value is @code{0}, which disables the timeout.
1633
1634 The value specified here can be overridden by clients (@pxref{Common
1635 Build Options, @option{--timeout}}).
1636
1637 @item --rounds=@var{N}
1638 Build each derivation @var{n} times in a row, and raise an error if
1639 consecutive build results are not bit-for-bit identical. Note that this
1640 setting can be overridden by clients such as @command{guix build}
1641 (@pxref{Invoking guix build}).
1642
1643 When used in conjunction with @option{--keep-failed}, the differing
1644 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1645 This makes it easy to look for differences between the two results.
1646
1647 @item --debug
1648 Produce debugging output.
1649
1650 This is useful to debug daemon start-up issues, but then it may be
1651 overridden by clients, for example the @option{--verbosity} option of
1652 @command{guix build} (@pxref{Invoking guix build}).
1653
1654 @item --chroot-directory=@var{dir}
1655 Add @var{dir} to the build chroot.
1656
1657 Doing this may change the result of build processes---for instance if
1658 they use optional dependencies found in @var{dir} when it is available,
1659 and not otherwise. For that reason, it is not recommended to do so.
1660 Instead, make sure that each derivation declares all the inputs that it
1661 needs.
1662
1663 @item --disable-chroot
1664 Disable chroot builds.
1665
1666 Using this option is not recommended since, again, it would allow build
1667 processes to gain access to undeclared dependencies. It is necessary,
1668 though, when @command{guix-daemon} is running under an unprivileged user
1669 account.
1670
1671 @item --log-compression=@var{type}
1672 Compress build logs according to @var{type}, one of @code{gzip},
1673 @code{bzip2}, or @code{none}.
1674
1675 Unless @option{--lose-logs} is used, all the build logs are kept in the
1676 @var{localstatedir}. To save space, the daemon automatically compresses
1677 them with Bzip2 by default.
1678
1679 @item --discover[=yes|no]
1680 Whether to discover substitute servers on the local network using mDNS
1681 and DNS-SD.
1682
1683 This feature is still experimental. However, here are a few
1684 considerations.
1685
1686 @enumerate
1687 @item
1688 It might be faster/less expensive than fetching from remote servers;
1689 @item
1690 There are no security risks, only genuine substitutes will be used
1691 (@pxref{Substitute Authentication});
1692 @item
1693 An attacker advertising @command{guix publish} on your LAN cannot serve
1694 you malicious binaries, but they can learn what software you’re
1695 installing;
1696 @item
1697 Servers may serve substitute over HTTP, unencrypted, so anyone on the
1698 LAN can see what software you’re installing.
1699 @end enumerate
1700
1701 It is also possible to enable or disable substitute server discovery at
1702 run-time by running:
1703
1704 @example
1705 herd discover guix-daemon on
1706 herd discover guix-daemon off
1707 @end example
1708
1709 @item --disable-deduplication
1710 @cindex deduplication
1711 Disable automatic file ``deduplication'' in the store.
1712
1713 By default, files added to the store are automatically ``deduplicated'':
1714 if a newly added file is identical to another one found in the store,
1715 the daemon makes the new file a hard link to the other file. This can
1716 noticeably reduce disk usage, at the expense of slightly increased
1717 input/output load at the end of a build process. This option disables
1718 this optimization.
1719
1720 @item --gc-keep-outputs[=yes|no]
1721 Tell whether the garbage collector (GC) must keep outputs of live
1722 derivations.
1723
1724 @cindex GC roots
1725 @cindex garbage collector roots
1726 When set to @code{yes}, the GC will keep the outputs of any live
1727 derivation available in the store---the @file{.drv} files. The default
1728 is @code{no}, meaning that derivation outputs are kept only if they are
1729 reachable from a GC root. @xref{Invoking guix gc}, for more on GC
1730 roots.
1731
1732 @item --gc-keep-derivations[=yes|no]
1733 Tell whether the garbage collector (GC) must keep derivations
1734 corresponding to live outputs.
1735
1736 When set to @code{yes}, as is the case by default, the GC keeps
1737 derivations---i.e., @file{.drv} files---as long as at least one of their
1738 outputs is live. This allows users to keep track of the origins of
1739 items in their store. Setting it to @code{no} saves a bit of disk
1740 space.
1741
1742 In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
1743 liveness to flow from outputs to derivations, and setting
1744 @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
1745 derivations to outputs. When both are set to @code{yes}, the effect is
1746 to keep all the build prerequisites (the sources, compiler, libraries,
1747 and other build-time tools) of live objects in the store, regardless of
1748 whether these prerequisites are reachable from a GC root. This is
1749 convenient for developers since it saves rebuilds or downloads.
1750
1751 @item --impersonate-linux-2.6
1752 On Linux-based systems, impersonate Linux 2.6. This means that the
1753 kernel's @command{uname} system call will report 2.6 as the release number.
1754
1755 This might be helpful to build programs that (usually wrongfully) depend
1756 on the kernel version number.
1757
1758 @item --lose-logs
1759 Do not keep build logs. By default they are kept under
1760 @file{@var{localstatedir}/guix/log}.
1761
1762 @item --system=@var{system}
1763 Assume @var{system} as the current system type. By default it is the
1764 architecture/kernel pair found at configure time, such as
1765 @code{x86_64-linux}.
1766
1767 @item --listen=@var{endpoint}
1768 Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
1769 as the file name of a Unix-domain socket if it starts with
1770 @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
1771 host name or host name and port to listen to. Here are a few examples:
1772
1773 @table @code
1774 @item --listen=/gnu/var/daemon
1775 Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
1776 creating it if needed.
1777
1778 @item --listen=localhost
1779 @cindex daemon, remote access
1780 @cindex remote access to the daemon
1781 @cindex daemon, cluster setup
1782 @cindex clusters, daemon setup
1783 Listen for TCP connections on the network interface corresponding to
1784 @code{localhost}, on port 44146.
1785
1786 @item --listen=128.0.0.42:1234
1787 Listen for TCP connections on the network interface corresponding to
1788 @code{128.0.0.42}, on port 1234.
1789 @end table
1790
1791 This option can be repeated multiple times, in which case
1792 @command{guix-daemon} accepts connections on all the specified
1793 endpoints. Users can tell client commands what endpoint to connect to
1794 by setting the @env{GUIX_DAEMON_SOCKET} environment variable
1795 (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
1796
1797 @quotation Note
1798 The daemon protocol is @emph{unauthenticated and unencrypted}. Using
1799 @option{--listen=@var{host}} is suitable on local networks, such as
1800 clusters, where only trusted nodes may connect to the build daemon. In
1801 other cases where remote access to the daemon is needed, we recommend
1802 using Unix-domain sockets along with SSH.
1803 @end quotation
1804
1805 When @option{--listen} is omitted, @command{guix-daemon} listens for
1806 connections on the Unix-domain socket located at
1807 @file{@var{localstatedir}/guix/daemon-socket/socket}.
1808 @end table
1809
1810
1811 @node Application Setup
1812 @section Application Setup
1813
1814 @cindex foreign distro
1815 When using Guix on top of GNU/Linux distribution other than Guix System---a
1816 so-called @dfn{foreign distro}---a few additional steps are needed to
1817 get everything in place. Here are some of them.
1818
1819 @subsection Locales
1820
1821 @anchor{locales-and-locpath}
1822 @cindex locales, when not on Guix System
1823 @vindex LOCPATH
1824 @vindex GUIX_LOCPATH
1825 Packages installed @i{via} Guix will not use the locale data of the
1826 host system. Instead, you must first install one of the locale packages
1827 available with Guix and then define the @env{GUIX_LOCPATH} environment
1828 variable:
1829
1830 @example
1831 $ guix install glibc-locales
1832 $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
1833 @end example
1834
1835 Note that the @code{glibc-locales} package contains data for all the
1836 locales supported by the GNU@tie{}libc and weighs in at around
1837 917@tie{}MiB@. Alternatively, the @code{glibc-utf8-locales} is smaller but
1838 limited to a few UTF-8 locales.
1839
1840 The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
1841 (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
1842 Manual}). There are two important differences though:
1843
1844 @enumerate
1845 @item
1846 @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
1847 provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
1848 to make sure the programs of the foreign distro will not end up loading
1849 incompatible locale data.
1850
1851 @item
1852 libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
1853 @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1854 should your Guix profile contain a mixture of programs linked against
1855 different libc version, each libc version will only try to load locale
1856 data in the right format.
1857 @end enumerate
1858
1859 This is important because the locale data format used by different libc
1860 versions may be incompatible.
1861
1862 @subsection Name Service Switch
1863
1864 @cindex name service switch, glibc
1865 @cindex NSS (name service switch), glibc
1866 @cindex nscd (name service caching daemon)
1867 @cindex name service caching daemon (nscd)
1868 When using Guix on a foreign distro, we @emph{strongly recommend} that
1869 the system run the GNU C library's @dfn{name service cache daemon},
1870 @command{nscd}, which should be listening on the
1871 @file{/var/run/nscd/socket} socket. Failing to do that, applications
1872 installed with Guix may fail to look up host names or user accounts, or
1873 may even crash. The next paragraphs explain why.
1874
1875 @cindex @file{nsswitch.conf}
1876 The GNU C library implements a @dfn{name service switch} (NSS), which is
1877 an extensible mechanism for ``name lookups'' in general: host name
1878 resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1879 The GNU C Library Reference Manual}).
1880
1881 @cindex Network information service (NIS)
1882 @cindex NIS (Network information service)
1883 Being extensible, the NSS supports @dfn{plugins}, which provide new name
1884 lookup implementations: for example, the @code{nss-mdns} plugin allow
1885 resolution of @code{.local} host names, the @code{nis} plugin allows
1886 user account lookup using the Network information service (NIS), and so
1887 on. These extra ``lookup services'' are configured system-wide in
1888 @file{/etc/nsswitch.conf}, and all the programs running on the system
1889 honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1890 Reference Manual}).
1891
1892 When they perform a name lookup---for instance by calling the
1893 @code{getaddrinfo} function in C---applications first try to connect to
1894 the nscd; on success, nscd performs name lookups on their behalf. If
1895 the nscd is not running, then they perform the name lookup by
1896 themselves, by loading the name lookup services into their own address
1897 space and running it. These name lookup services---the
1898 @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1899 the host system's C library, rather than from the C library the
1900 application is linked against (the C library coming from Guix).
1901
1902 And this is where the problem is: if your application is linked against
1903 Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1904 another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1905 likely crash or have its name lookups fail unexpectedly.
1906
1907 Running @command{nscd} on the system, among other advantages, eliminates
1908 this binary incompatibility problem because those @code{libnss_*.so}
1909 files are loaded in the @command{nscd} process, not in applications
1910 themselves.
1911
1912 @subsection X11 Fonts
1913
1914 @cindex fonts
1915 The majority of graphical applications use Fontconfig to locate and
1916 load fonts and perform X11-client-side rendering. The @code{fontconfig}
1917 package in Guix looks for fonts in @file{$HOME/.guix-profile}
1918 by default. Thus, to allow graphical applications installed with Guix
1919 to display fonts, you have to install fonts with Guix as well.
1920 Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
1921 @code{font-gnu-freefont}.
1922
1923 @cindex @code{fc-cache}
1924 @cindex font cache
1925 Once you have installed or removed fonts, or when you notice an
1926 application that does not find fonts, you may need to install Fontconfig
1927 and to force an update of its font cache by running:
1928
1929 @example
1930 guix install fontconfig
1931 fc-cache -rv
1932 @end example
1933
1934 To display text written in Chinese languages, Japanese, or Korean in
1935 graphical applications, consider installing
1936 @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1937 has multiple outputs, one per language family (@pxref{Packages with
1938 Multiple Outputs}). For instance, the following command installs fonts
1939 for Chinese languages:
1940
1941 @example
1942 guix install font-adobe-source-han-sans:cn
1943 @end example
1944
1945 @cindex @code{xterm}
1946 Older programs such as @command{xterm} do not use Fontconfig and instead
1947 rely on server-side font rendering. Such programs require to specify a
1948 full name of a font using XLFD (X Logical Font Description), like this:
1949
1950 @example
1951 -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1952 @end example
1953
1954 To be able to use such full names for the TrueType fonts installed in
1955 your Guix profile, you need to extend the font path of the X server:
1956
1957 @c Note: 'xset' does not accept symlinks so the trick below arranges to
1958 @c get at the real directory. See <https://bugs.gnu.org/30655>.
1959 @example
1960 xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
1961 @end example
1962
1963 @cindex @code{xlsfonts}
1964 After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1965 to make sure your TrueType fonts are listed there.
1966
1967
1968 @subsection X.509 Certificates
1969
1970 @cindex @code{nss-certs}
1971 The @code{nss-certs} package provides X.509 certificates, which allow
1972 programs to authenticate Web servers accessed over HTTPS.
1973
1974 When using Guix on a foreign distro, you can install this package and
1975 define the relevant environment variables so that packages know where to
1976 look for certificates. @xref{X.509 Certificates}, for detailed
1977 information.
1978
1979 @subsection Emacs Packages
1980
1981 @cindex @code{emacs}
1982 When you install Emacs packages with Guix, the Elisp files are placed
1983 under the @file{share/emacs/site-lisp/} directory of the profile in
1984 which they are installed. The Elisp libraries are made available to
1985 Emacs through the @env{EMACSLOADPATH} environment variable, which is
1986 set when installing Emacs itself.
1987
1988 Additionally, autoload definitions are automatically evaluated at the
1989 initialization of Emacs, by the Guix-specific
1990 @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
1991 want to avoid auto-loading the Emacs packages installed with Guix, you
1992 can do so by running Emacs with the @option{--no-site-file} option
1993 (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1994
1995
1996 @node Upgrading Guix
1997 @section Upgrading Guix
1998
1999 @cindex Upgrading Guix, on a foreign distro
2000
2001 To upgrade Guix, run:
2002
2003 @example
2004 guix pull
2005 @end example
2006
2007 @xref{Invoking guix pull}, for more information.
2008
2009 @cindex upgrading Guix for the root user, on a foreign distro
2010 @cindex upgrading the Guix daemon, on a foreign distro
2011 @cindex @command{guix pull} for the root user, on a foreign distro
2012
2013 On a foreign distro, you can upgrade the build daemon by running:
2014
2015 @example
2016 sudo -i guix pull
2017 @end example
2018
2019 @noindent
2020 followed by (assuming your distro uses the systemd service management
2021 tool):
2022
2023 @example
2024 systemctl restart guix-daemon.service
2025 @end example
2026
2027 On Guix System, upgrading the daemon is achieved by reconfiguring the
2028 system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
2029
2030 @c TODO What else?
2031
2032 @c *********************************************************************
2033 @node System Installation
2034 @chapter System Installation
2035
2036 @cindex installing Guix System
2037 @cindex Guix System, installation
2038 This section explains how to install Guix System
2039 on a machine. Guix, as a package manager, can
2040 also be installed on top of a running GNU/Linux system,
2041 @pxref{Installation}.
2042
2043 @ifinfo
2044 @quotation Note
2045 @c This paragraph is for people reading this from tty2 of the
2046 @c installation image.
2047 You are reading this documentation with an Info reader. For details on
2048 how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
2049 link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
2050 Info}. Hit @kbd{l} afterwards to come back here.
2051
2052 Alternatively, run @command{info info} in another tty to keep the manual
2053 available.
2054 @end quotation
2055 @end ifinfo
2056
2057 @menu
2058 * Limitations:: What you can expect.
2059 * Hardware Considerations:: Supported hardware.
2060 * USB Stick and DVD Installation:: Preparing the installation medium.
2061 * Preparing for Installation:: Networking, partitioning, etc.
2062 * Guided Graphical Installation:: Easy graphical installation.
2063 * Manual Installation:: Manual installation for wizards.
2064 * After System Installation:: When installation succeeded.
2065 * Installing Guix in a VM:: Guix System playground.
2066 * Building the Installation Image:: How this comes to be.
2067 @end menu
2068
2069 @node Limitations
2070 @section Limitations
2071
2072 We consider Guix System to be ready for a wide range of ``desktop'' and server
2073 use cases. The reliability guarantees it provides---transactional upgrades
2074 and rollbacks, reproducibility---make it a solid foundation.
2075
2076 Nevertheless, before you proceed with the installation, be aware of the
2077 following noteworthy limitations applicable to version @value{VERSION}:
2078
2079 @itemize
2080 @item
2081 More and more system services are provided (@pxref{Services}), but some
2082 may be missing.
2083
2084 @item
2085 GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
2086 as well as a number of X11 window managers. However, KDE is currently
2087 missing.
2088 @end itemize
2089
2090 More than a disclaimer, this is an invitation to report issues (and success
2091 stories!), and to join us in improving it. @xref{Contributing}, for more
2092 info.
2093
2094
2095 @node Hardware Considerations
2096 @section Hardware Considerations
2097
2098 @cindex hardware support on Guix System
2099 GNU@tie{}Guix focuses on respecting the user's computing freedom. It
2100 builds around the kernel Linux-libre, which means that only hardware for
2101 which free software drivers and firmware exist is supported. Nowadays,
2102 a wide range of off-the-shelf hardware is supported on
2103 GNU/Linux-libre---from keyboards to graphics cards to scanners and
2104 Ethernet controllers. Unfortunately, there are still areas where
2105 hardware vendors deny users control over their own computing, and such
2106 hardware is not supported on Guix System.
2107
2108 @cindex WiFi, hardware support
2109 One of the main areas where free drivers or firmware are lacking is WiFi
2110 devices. WiFi devices known to work include those using Atheros chips
2111 (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
2112 driver, and those using Broadcom/AirForce chips (BCM43xx with
2113 Wireless-Core Revision 5), which corresponds to the @code{b43-open}
2114 Linux-libre driver. Free firmware exists for both and is available
2115 out-of-the-box on Guix System, as part of @code{%base-firmware}
2116 (@pxref{operating-system Reference, @code{firmware}}).
2117
2118 @cindex RYF, Respects Your Freedom
2119 The @uref{https://www.fsf.org/, Free Software Foundation} runs
2120 @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
2121 certification program for hardware products that respect your freedom
2122 and your privacy and ensure that you have control over your device. We
2123 encourage you to check the list of RYF-certified devices.
2124
2125 Another useful resource is the @uref{https://www.h-node.org/, H-Node}
2126 web site. It contains a catalog of hardware devices with information
2127 about their support in GNU/Linux.
2128
2129
2130 @node USB Stick and DVD Installation
2131 @section USB Stick and DVD Installation
2132
2133 An ISO-9660 installation image that can be written to a USB stick or
2134 burnt to a DVD can be downloaded from
2135 @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso},
2136 where you can replace @code{x86_64-linux} with one of:
2137
2138 @table @code
2139 @item x86_64-linux
2140 for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
2141
2142 @item i686-linux
2143 for a 32-bit GNU/Linux system on Intel-compatible CPUs.
2144 @end table
2145
2146 @c start duplication of authentication part from ``Binary Installation''
2147 Make sure to download the associated @file{.sig} file and to verify the
2148 authenticity of the image against it, along these lines:
2149
2150 @example
2151 $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
2152 $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
2153 @end example
2154
2155 If that command fails because you do not have the required public key,
2156 then run this command to import it:
2157
2158 @example
2159 $ wget @value{OPENPGP-SIGNING-KEY-URL} \
2160 -qO - | gpg --import -
2161 @end example
2162
2163 @noindent
2164 and rerun the @code{gpg --verify} command.
2165
2166 Take note that a warning like ``This key is not certified with a trusted
2167 signature!'' is normal.
2168
2169 @c end duplication
2170
2171 This image contains the tools necessary for an installation.
2172 It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
2173
2174 @unnumberedsubsec Copying to a USB Stick
2175
2176 Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
2177 its device name. Assuming that the USB stick is known as @file{/dev/sdX},
2178 copy the image with:
2179
2180 @example
2181 dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
2182 sync
2183 @end example
2184
2185 Access to @file{/dev/sdX} usually requires root privileges.
2186
2187 @unnumberedsubsec Burning on a DVD
2188
2189 Insert a blank DVD into your machine, and determine
2190 its device name. Assuming that the DVD drive is known as @file{/dev/srX},
2191 copy the image with:
2192
2193 @example
2194 growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
2195 @end example
2196
2197 Access to @file{/dev/srX} usually requires root privileges.
2198
2199 @unnumberedsubsec Booting
2200
2201 Once this is done, you should be able to reboot the system and boot from
2202 the USB stick or DVD@. The latter usually requires you to get in the
2203 BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
2204 In order to boot from Libreboot, switch to the command mode by pressing
2205 the @kbd{c} key and type @command{search_grub usb}.
2206
2207 @xref{Installing Guix in a VM}, if, instead, you would like to install
2208 Guix System in a virtual machine (VM).
2209
2210
2211 @node Preparing for Installation
2212 @section Preparing for Installation
2213
2214 Once you have booted, you can use the guided graphical installer, which makes
2215 it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
2216 if you are already familiar with GNU/Linux and if you want more control than
2217 what the graphical installer provides, you can choose the ``manual''
2218 installation process (@pxref{Manual Installation}).
2219
2220 The graphical installer is available on TTY1. You can obtain root shells on
2221 TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
2222 this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
2223 is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
2224 Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
2225 which allows you to select text with the left mouse button and to paste it
2226 with the middle button.
2227
2228 @quotation Note
2229 Installation requires access to the Internet so that any missing
2230 dependencies of your system configuration can be downloaded. See the
2231 ``Networking'' section below.
2232 @end quotation
2233
2234 @node Guided Graphical Installation
2235 @section Guided Graphical Installation
2236
2237 The graphical installer is a text-based user interface. It will guide you,
2238 with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
2239
2240 The first dialog boxes allow you to set up the system as you use it during the
2241 installation: you can choose the language, keyboard layout, and set up
2242 networking, which will be used during the installation. The image below shows
2243 the networking dialog.
2244
2245 @image{images/installer-network,5in,, networking setup with the graphical installer}
2246
2247 Later steps allow you to partition your hard disk, as shown in the image
2248 below, to choose whether or not to use encrypted file systems, to enter the
2249 host name and root password, and to create an additional account, among other
2250 things.
2251
2252 @image{images/installer-partitions,5in,, partitioning with the graphical installer}
2253
2254 Note that, at any time, the installer allows you to exit the current
2255 installation step and resume at a previous step, as show in the image below.
2256
2257 @image{images/installer-resume,5in,, resuming the installation process}
2258
2259 Once you're done, the installer produces an operating system configuration and
2260 displays it (@pxref{Using the Configuration System}). At that point you can
2261 hit ``OK'' and installation will proceed. On success, you can reboot into the
2262 new system and enjoy. @xref{After System Installation}, for what's next!
2263
2264
2265 @node Manual Installation
2266 @section Manual Installation
2267
2268 This section describes how you would ``manually'' install GNU@tie{}Guix System
2269 on your machine. This option requires familiarity with GNU/Linux, with the
2270 shell, and with common administration tools. If you think this is not for
2271 you, consider using the guided graphical installer (@pxref{Guided Graphical
2272 Installation}).
2273
2274 The installation system provides root shells on TTYs 3 to 6; press
2275 @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
2276 many common tools needed to install the system. But it is also a full-blown
2277 Guix System, which means that you can install additional packages, should you
2278 need it, using @command{guix package} (@pxref{Invoking guix package}).
2279
2280 @menu
2281 * Keyboard Layout and Networking and Partitioning:: Initial setup.
2282 * Proceeding with the Installation:: Installing.
2283 @end menu
2284
2285 @node Keyboard Layout and Networking and Partitioning
2286 @subsection Keyboard Layout, Networking, and Partitioning
2287
2288 Before you can install the system, you may want to adjust the keyboard layout,
2289 set up networking, and partition your target hard disk. This section will
2290 guide you through this.
2291
2292 @subsubsection Keyboard Layout
2293
2294 @cindex keyboard layout
2295 The installation image uses the US qwerty keyboard layout. If you want
2296 to change it, you can use the @command{loadkeys} command. For example,
2297 the following command selects the Dvorak keyboard layout:
2298
2299 @example
2300 loadkeys dvorak
2301 @end example
2302
2303 See the files under @file{/run/current-system/profile/share/keymaps} for
2304 a list of available keyboard layouts. Run @command{man loadkeys} for
2305 more information.
2306
2307 @subsubsection Networking
2308
2309 Run the following command to see what your network interfaces are called:
2310
2311 @example
2312 ifconfig -a
2313 @end example
2314
2315 @noindent
2316 @dots{} or, using the GNU/Linux-specific @command{ip} command:
2317
2318 @example
2319 ip address
2320 @end example
2321
2322 @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
2323 Wired interfaces have a name starting with @samp{e}; for example, the
2324 interface corresponding to the first on-board Ethernet controller is
2325 called @samp{eno1}. Wireless interfaces have a name starting with
2326 @samp{w}, like @samp{w1p2s0}.
2327
2328 @table @asis
2329 @item Wired connection
2330 To configure a wired network run the following command, substituting
2331 @var{interface} with the name of the wired interface you want to use.
2332
2333 @example
2334 ifconfig @var{interface} up
2335 @end example
2336
2337 @noindent
2338 @dots{} or, using the GNU/Linux-specific @command{ip} command:
2339
2340 @example
2341 ip link set @var{interface} up
2342 @end example
2343
2344 @item Wireless connection
2345 @cindex wireless
2346 @cindex WiFi
2347 To configure wireless networking, you can create a configuration file
2348 for the @command{wpa_supplicant} configuration tool (its location is not
2349 important) using one of the available text editors such as
2350 @command{nano}:
2351
2352 @example
2353 nano wpa_supplicant.conf
2354 @end example
2355
2356 As an example, the following stanza can go to this file and will work
2357 for many wireless networks, provided you give the actual SSID and
2358 passphrase for the network you are connecting to:
2359
2360 @example
2361 network=@{
2362 ssid="@var{my-ssid}"
2363 key_mgmt=WPA-PSK
2364 psk="the network's secret passphrase"
2365 @}
2366 @end example
2367
2368 Start the wireless service and run it in the background with the
2369 following command (substitute @var{interface} with the name of the
2370 network interface you want to use):
2371
2372 @example
2373 wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
2374 @end example
2375
2376 Run @command{man wpa_supplicant} for more information.
2377 @end table
2378
2379 @cindex DHCP
2380 At this point, you need to acquire an IP address. On a network where IP
2381 addresses are automatically assigned @i{via} DHCP, you can run:
2382
2383 @example
2384 dhclient -v @var{interface}
2385 @end example
2386
2387 Try to ping a server to see if networking is up and running:
2388
2389 @example
2390 ping -c 3 gnu.org
2391 @end example
2392
2393 Setting up network access is almost always a requirement because the
2394 image does not contain all the software and tools that may be needed.
2395
2396 @cindex proxy, during system installation
2397 If you need HTTP and HTTPS access to go through a proxy, run the
2398 following command:
2399
2400 @example
2401 herd set-http-proxy guix-daemon @var{URL}
2402 @end example
2403
2404 @noindent
2405 where @var{URL} is the proxy URL, for example
2406 @code{http://example.org:8118}.
2407
2408 @cindex installing over SSH
2409 If you want to, you can continue the installation remotely by starting
2410 an SSH server:
2411
2412 @example
2413 herd start ssh-daemon
2414 @end example
2415
2416 Make sure to either set a password with @command{passwd}, or configure
2417 OpenSSH public key authentication before logging in.
2418
2419 @subsubsection Disk Partitioning
2420
2421 Unless this has already been done, the next step is to partition, and
2422 then format the target partition(s).
2423
2424 The installation image includes several partitioning tools, including
2425 Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
2426 @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
2427 the partition layout you want:
2428
2429 @example
2430 cfdisk
2431 @end example
2432
2433 If your disk uses the GUID Partition Table (GPT) format and you plan to
2434 install BIOS-based GRUB (which is the default), make sure a BIOS Boot
2435 Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
2436 manual}).
2437
2438 @cindex EFI, installation
2439 @cindex UEFI, installation
2440 @cindex ESP, EFI system partition
2441 If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
2442 (ESP) is required. This partition can be mounted at @file{/boot/efi} for
2443 instance and must have the @code{esp} flag set. E.g., for @command{parted}:
2444
2445 @example
2446 parted /dev/sda set 1 esp on
2447 @end example
2448
2449 @quotation Note
2450 @vindex grub-bootloader
2451 @vindex grub-efi-bootloader
2452 Unsure whether to use EFI- or BIOS-based GRUB? If the directory
2453 @file{/sys/firmware/efi} exists in the installation image, then you should
2454 probably perform an EFI installation, using @code{grub-efi-bootloader}.
2455 Otherwise you should use the BIOS-based GRUB, known as
2456 @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
2457 bootloaders.
2458 @end quotation
2459
2460 Once you are done partitioning the target hard disk drive, you have to
2461 create a file system on the relevant partition(s)@footnote{Currently
2462 Guix System only supports ext4, btrfs, JFS, F2FS, and XFS file systems. In
2463 particular, code that reads file system UUIDs and labels only works for these
2464 file system types.}. For the ESP, if you have one and assuming it is
2465 @file{/dev/sda1}, run:
2466
2467 @example
2468 mkfs.fat -F32 /dev/sda1
2469 @end example
2470
2471 For the root file system, ext4 is the most widely used format. Other
2472 file systems, such as Btrfs, support compression, which is reported to
2473 nicely complement file deduplication that the daemon performs
2474 independently of the file system (@pxref{Invoking guix-daemon,
2475 deduplication}).
2476
2477 Preferably, assign file systems a label so that you can easily and
2478 reliably refer to them in @code{file-system} declarations (@pxref{File
2479 Systems}). This is typically done using the @code{-L} option of
2480 @command{mkfs.ext4} and related commands. So, assuming the target root
2481 partition lives at @file{/dev/sda2}, a file system with the label
2482 @code{my-root} can be created with:
2483
2484 @example
2485 mkfs.ext4 -L my-root /dev/sda2
2486 @end example
2487
2488 @cindex encrypted disk
2489 If you are instead planning to encrypt the root partition, you can use
2490 the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
2491 @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
2492 @code{man cryptsetup}} for more information). Assuming you want to
2493 store the root partition on @file{/dev/sda2}, the command sequence would
2494 be along these lines:
2495
2496 @example
2497 cryptsetup luksFormat /dev/sda2
2498 cryptsetup open --type luks /dev/sda2 my-partition
2499 mkfs.ext4 -L my-root /dev/mapper/my-partition
2500 @end example
2501
2502 Once that is done, mount the target file system under @file{/mnt}
2503 with a command like (again, assuming @code{my-root} is the label of the
2504 root file system):
2505
2506 @example
2507 mount LABEL=my-root /mnt
2508 @end example
2509
2510 Also mount any other file systems you would like to use on the target
2511 system relative to this path. If you have opted for @file{/boot/efi} as an
2512 EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
2513 found by @code{guix system init} afterwards.
2514
2515 Finally, if you plan to use one or more swap partitions (@pxref{Memory
2516 Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
2517 sure to initialize them with @command{mkswap}. Assuming you have one
2518 swap partition on @file{/dev/sda3}, you would run:
2519
2520 @example
2521 mkswap /dev/sda3
2522 swapon /dev/sda3
2523 @end example
2524
2525 Alternatively, you may use a swap file. For example, assuming that in
2526 the new system you want to use the file @file{/swapfile} as a swap file,
2527 you would run@footnote{This example will work for many types of file
2528 systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
2529 btrfs), the required steps may be different. For details, see the
2530 manual pages for @command{mkswap} and @command{swapon}.}:
2531
2532 @example
2533 # This is 10 GiB of swap space. Adjust "count" to change the size.
2534 dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
2535 # For security, make the file readable and writable only by root.
2536 chmod 600 /mnt/swapfile
2537 mkswap /mnt/swapfile
2538 swapon /mnt/swapfile
2539 @end example
2540
2541 Note that if you have encrypted the root partition and created a swap
2542 file in its file system as described above, then the encryption also
2543 protects the swap file, just like any other file in that file system.
2544
2545 @node Proceeding with the Installation
2546 @subsection Proceeding with the Installation
2547
2548 With the target partitions ready and the target root mounted on
2549 @file{/mnt}, we're ready to go. First, run:
2550
2551 @example
2552 herd start cow-store /mnt
2553 @end example
2554
2555 This makes @file{/gnu/store} copy-on-write, such that packages added to it
2556 during the installation phase are written to the target disk on @file{/mnt}
2557 rather than kept in memory. This is necessary because the first phase of
2558 the @command{guix system init} command (see below) entails downloads or
2559 builds to @file{/gnu/store} which, initially, is an in-memory file system.
2560
2561 Next, you have to edit a file and
2562 provide the declaration of the operating system to be installed. To
2563 that end, the installation system comes with three text editors. We
2564 recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
2565 supports syntax highlighting and parentheses matching; other editors
2566 include mg (an Emacs clone), and
2567 nvi (a clone of the original BSD @command{vi} editor).
2568 We strongly recommend storing that file on the target root file system, say,
2569 as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
2570 configuration file once you have rebooted into the newly-installed system.
2571
2572 @xref{Using the Configuration System}, for an overview of the
2573 configuration file. The example configurations discussed in that
2574 section are available under @file{/etc/configuration} in the
2575 installation image. Thus, to get started with a system configuration
2576 providing a graphical display server (a ``desktop'' system), you can run
2577 something along these lines:
2578
2579 @example
2580 # mkdir /mnt/etc
2581 # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
2582 # nano /mnt/etc/config.scm
2583 @end example
2584
2585 You should pay attention to what your configuration file contains, and
2586 in particular:
2587
2588 @itemize
2589 @item
2590 Make sure the @code{bootloader-configuration} form refers to the targets
2591 you want to install GRUB on. It should mention @code{grub-bootloader}
2592 if you are installing GRUB in the legacy way, or
2593 @code{grub-efi-bootloader} for newer UEFI systems. For legacy systems,
2594 the @code{targets} field contain the names of the devices, like
2595 @code{(list "/dev/sda")}; for UEFI systems it names the paths to mounted
2596 EFI partitions, like @code{(list "/boot/efi")}; do make sure the paths
2597 are currently mounted and a @code{file-system} entry is specified in
2598 your configuration.
2599
2600 @item
2601 Be sure that your file system labels match the value of their respective
2602 @code{device} fields in your @code{file-system} configuration, assuming
2603 your @code{file-system} configuration uses the @code{file-system-label}
2604 procedure in its @code{device} field.
2605
2606 @item
2607 If there are encrypted or RAID partitions, make sure to add a
2608 @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
2609 @end itemize
2610
2611 Once you are done preparing the configuration file, the new system must
2612 be initialized (remember that the target root file system is mounted
2613 under @file{/mnt}):
2614
2615 @example
2616 guix system init /mnt/etc/config.scm /mnt
2617 @end example
2618
2619 @noindent
2620 This copies all the necessary files and installs GRUB on
2621 @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
2622 more information, @pxref{Invoking guix system}. This command may trigger
2623 downloads or builds of missing packages, which can take some time.
2624
2625 Once that command has completed---and hopefully succeeded!---you can run
2626 @command{reboot} and boot into the new system. The @code{root} password
2627 in the new system is initially empty; other users' passwords need to be
2628 initialized by running the @command{passwd} command as @code{root},
2629 unless your configuration specifies otherwise
2630 (@pxref{user-account-password, user account passwords}).
2631 @xref{After System Installation}, for what's next!
2632
2633
2634 @node After System Installation
2635 @section After System Installation
2636
2637 Success, you've now booted into Guix System! From then on, you can update the
2638 system whenever you want by running, say:
2639
2640 @example
2641 guix pull
2642 sudo guix system reconfigure /etc/config.scm
2643 @end example
2644
2645 @noindent
2646 This builds a new system generation with the latest packages and services
2647 (@pxref{Invoking guix system}). We recommend doing that regularly so that
2648 your system includes the latest security updates (@pxref{Security Updates}).
2649
2650 @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
2651 @quotation Note
2652 @cindex sudo vs. @command{guix pull}
2653 Note that @command{sudo guix} runs your user's @command{guix} command and
2654 @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
2655 explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
2656
2657 The difference matters here, because @command{guix pull} updates
2658 the @command{guix} command and package definitions only for the user it is run
2659 as. This means that if you choose to use @command{guix system reconfigure} in
2660 root's login shell, you'll need to @command{guix pull} separately.
2661 @end quotation
2662
2663 Now, @pxref{Getting Started}, and
2664 join us on @code{#guix} on the Libera Chat IRC network or on
2665 @email{guix-devel@@gnu.org} to share your experience!
2666
2667
2668 @node Installing Guix in a VM
2669 @section Installing Guix in a Virtual Machine
2670
2671 @cindex virtual machine, Guix System installation
2672 @cindex virtual private server (VPS)
2673 @cindex VPS (virtual private server)
2674 If you'd like to install Guix System in a virtual machine (VM) or on a
2675 virtual private server (VPS) rather than on your beloved machine, this
2676 section is for you.
2677
2678 To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
2679 disk image, follow these steps:
2680
2681 @enumerate
2682 @item
2683 First, retrieve and decompress the Guix system installation image as
2684 described previously (@pxref{USB Stick and DVD Installation}).
2685
2686 @item
2687 Create a disk image that will hold the installed system. To make a
2688 qcow2-formatted disk image, use the @command{qemu-img} command:
2689
2690 @example
2691 qemu-img create -f qcow2 guix-system.img 50G
2692 @end example
2693
2694 The resulting file will be much smaller than 50 GB (typically less than
2695 1 MB), but it will grow as the virtualized storage device is filled up.
2696
2697 @item
2698 Boot the USB installation image in an VM:
2699
2700 @example
2701 qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
2702 -nic user,model=virtio-net-pci -boot menu=on,order=d \
2703 -drive file=guix-system.img \
2704 -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
2705 @end example
2706
2707 @code{-enable-kvm} is optional, but significantly improves performance,
2708 @pxref{Running Guix in a VM}.
2709
2710 @item
2711 You're now root in the VM, proceed with the installation process.
2712 @xref{Preparing for Installation}, and follow the instructions.
2713 @end enumerate
2714
2715 Once installation is complete, you can boot the system that's on your
2716 @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
2717 that.
2718
2719 @node Building the Installation Image
2720 @section Building the Installation Image
2721
2722 @cindex installation image
2723 The installation image described above was built using the @command{guix
2724 system} command, specifically:
2725
2726 @example
2727 guix system image -t iso9660 gnu/system/install.scm
2728 @end example
2729
2730 Have a look at @file{gnu/system/install.scm} in the source tree,
2731 and see also @ref{Invoking guix system} for more information
2732 about the installation image.
2733
2734 @section Building the Installation Image for ARM Boards
2735
2736 Many ARM boards require a specific variant of the
2737 @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
2738
2739 If you build a disk image and the bootloader is not available otherwise
2740 (on another boot drive etc), it's advisable to build an image that
2741 includes the bootloader, specifically:
2742
2743 @example
2744 guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
2745 @end example
2746
2747 @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
2748 board, a list of possible boards will be printed.
2749
2750 @c *********************************************************************
2751 @node Getting Started
2752 @chapter Getting Started
2753
2754 Presumably, you've reached this section because either you have
2755 installed Guix on top of another distribution (@pxref{Installation}), or
2756 you've installed the standalone Guix System (@pxref{System
2757 Installation}). It's time for you to get started using Guix and this
2758 section aims to help you do that and give you a feel of what it's like.
2759
2760 Guix is about installing software, so probably the first thing you'll
2761 want to do is to actually look for software. Let's say you're looking
2762 for a text editor, you can run:
2763
2764 @example
2765 guix search text editor
2766 @end example
2767
2768 This command shows you a number of matching @dfn{packages}, each time
2769 showing the package's name, version, a description, and additional info.
2770 Once you've found out the one you want to use, let's say Emacs (ah ha!),
2771 you can go ahead and install it (run this command as a regular user,
2772 @emph{no need for root privileges}!):
2773
2774 @example
2775 guix install emacs
2776 @end example
2777
2778 @cindex profile
2779 You've installed your first package, congrats! The package is now
2780 visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
2781 profile is a directory containing installed packages.
2782 In the process, you've
2783 probably noticed that Guix downloaded pre-built binaries; or, if you
2784 explicitly chose to @emph{not} use pre-built binaries, then probably
2785 Guix is still building software (@pxref{Substitutes}, for more info).
2786
2787 Unless you're using Guix System, the @command{guix install} command must
2788 have printed this hint:
2789
2790 @example
2791 hint: Consider setting the necessary environment variables by running:
2792
2793 GUIX_PROFILE="$HOME/.guix-profile"
2794 . "$GUIX_PROFILE/etc/profile"
2795
2796 Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
2797 @end example
2798
2799 Indeed, you must now tell your shell where @command{emacs} and other
2800 programs installed with Guix are to be found. Pasting the two lines
2801 above will do just that: it will add
2802 @code{$HOME/.guix-profile/bin}---which is where the installed package
2803 is---to the @code{PATH} environment variable. You can paste these two
2804 lines in your shell so they take effect right away, but more importantly
2805 you should add them to @file{~/.bash_profile} (or equivalent file if you
2806 do not use Bash) so that environment variables are set next time you
2807 spawn a shell. You only need to do this once and other search paths
2808 environment variables will be taken care of similarly---e.g., if you
2809 eventually install @code{python} and Python libraries, @code{PYTHONPATH}
2810 will be defined.
2811
2812 You can go on installing packages at your will. To list installed
2813 packages, run:
2814
2815 @example
2816 guix package --list-installed
2817 @end example
2818
2819 To remove a package, you would unsurprisingly run @command{guix remove}.
2820 A distinguishing feature is the ability to @dfn{roll back} any operation
2821 you made---installation, removal, upgrade---by simply typing:
2822
2823 @example
2824 guix package --roll-back
2825 @end example
2826
2827 This is because each operation is in fact a @dfn{transaction} that
2828 creates a new @dfn{generation}. These generations and the difference
2829 between them can be displayed by running:
2830
2831 @example
2832 guix package --list-generations
2833 @end example
2834
2835 Now you know the basics of package management!
2836
2837 @quotation Going further
2838 @xref{Package Management}, for more about package management. You may
2839 like @dfn{declarative} package management with @command{guix package
2840 --manifest}, managing separate @dfn{profiles} with @option{--profile},
2841 deleting old generations, collecting garbage, and other nifty features
2842 that will come in handy as you become more familiar with Guix. If you
2843 are a developer, @pxref{Development} for additional tools. And if
2844 you're curious, @pxref{Features}, to peek under the hood.
2845 @end quotation
2846
2847 Once you've installed a set of packages, you will want to periodically
2848 @emph{upgrade} them to the latest and greatest version. To do that, you
2849 will first pull the latest revision of Guix and its package collection:
2850
2851 @example
2852 guix pull
2853 @end example
2854
2855 The end result is a new @command{guix} command, under
2856 @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
2857 first time you run @command{guix pull}, be sure to follow the hint that
2858 the command prints and, similar to what we saw above, paste these two
2859 lines in your terminal and @file{.bash_profile}:
2860
2861 @example
2862 GUIX_PROFILE="$HOME/.config/guix/current"
2863 . "$GUIX_PROFILE/etc/profile"
2864 @end example
2865
2866 @noindent
2867 You must also instruct your shell to point to this new @command{guix}:
2868
2869 @example
2870 hash guix
2871 @end example
2872
2873 At this point, you're running a brand new Guix. You can thus go ahead
2874 and actually upgrade all the packages you previously installed:
2875
2876 @example
2877 guix upgrade
2878 @end example
2879
2880 As you run this command, you will see that binaries are downloaded (or
2881 perhaps some packages are built), and eventually you end up with the
2882 upgraded packages. Should one of these upgraded packages not be to your
2883 liking, remember you can always roll back!
2884
2885 You can display the exact revision of Guix you're currently using by
2886 running:
2887
2888 @example
2889 guix describe
2890 @end example
2891
2892 The information it displays is @emph{all it takes to reproduce the exact
2893 same Guix}, be it at a different point in time or on a different
2894 machine.
2895
2896 @quotation Going further
2897 @xref{Invoking guix pull}, for more information. @xref{Channels}, on
2898 how to specify additional @dfn{channels} to pull packages from, how to
2899 replicate Guix, and more. You may also find @command{time-machine}
2900 handy (@pxref{Invoking guix time-machine}).
2901 @end quotation
2902
2903 If you installed Guix System, one of the first things you'll want to do
2904 is to upgrade your system. Once you've run @command{guix pull} to get
2905 the latest Guix, you can upgrade the system like this:
2906
2907 @example
2908 sudo guix system reconfigure /etc/config.scm
2909 @end example
2910
2911 Upon completion, the system runs the latest versions of its software
2912 packages. When you eventually reboot, you'll notice a sub-menu in the
2913 bootloader that reads ``Old system generations'': it's what allows you
2914 to boot @emph{an older generation of your system}, should the latest
2915 generation be ``broken'' or otherwise unsatisfying. Just like for
2916 packages, you can always @emph{roll back} to a previous generation
2917 @emph{of the whole system}:
2918
2919 @example
2920 sudo guix system roll-back
2921 @end example
2922
2923 There are many things you'll probably want to tweak on your system:
2924 adding new user accounts, adding new system services, fiddling with the
2925 configuration of those services, etc. The system configuration is
2926 @emph{entirely} described in the @file{/etc/config.scm} file.
2927 @xref{Using the Configuration System}, to learn how to change it.
2928
2929 Now you know enough to get started!
2930
2931 @quotation Resources
2932 The rest of this manual provides a reference for all things Guix. Here
2933 are some additional resources you may find useful:
2934
2935 @itemize
2936 @item
2937 @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
2938 ``how-to'' style of recipes for a variety of applications.
2939
2940 @item
2941 The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
2942 Card} lists in two pages most of the commands and options you'll ever
2943 need.
2944
2945 @item
2946 The web site contains @uref{https://guix.gnu.org/en/videos/,
2947 instructional videos} covering topics such as everyday use of Guix, how
2948 to get help, and how to become a contributor.
2949
2950 @item
2951 @xref{Documentation}, to learn how to access documentation on your
2952 computer.
2953 @end itemize
2954
2955 We hope you will enjoy Guix as much as the community enjoys building it!
2956 @end quotation
2957
2958 @c *********************************************************************
2959 @node Package Management
2960 @chapter Package Management
2961
2962 @cindex packages
2963 The purpose of GNU Guix is to allow users to easily install, upgrade, and
2964 remove software packages, without having to know about their build
2965 procedures or dependencies. Guix also goes beyond this obvious set of
2966 features.
2967
2968 This chapter describes the main features of Guix, as well as the
2969 package management tools it provides. Along with the command-line
2970 interface described below (@pxref{Invoking guix package, @code{guix
2971 package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
2972 emacs-guix, The Emacs-Guix Reference Manual}), after installing
2973 @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
2974 with it):
2975
2976 @example
2977 guix install emacs-guix
2978 @end example
2979
2980 @menu
2981 * Features:: How Guix will make your life brighter.
2982 * Invoking guix package:: Package installation, removal, etc.
2983 * Substitutes:: Downloading pre-built binaries.
2984 * Packages with Multiple Outputs:: Single source package, multiple outputs.
2985 * Invoking guix gc:: Running the garbage collector.
2986 * Invoking guix pull:: Fetching the latest Guix and distribution.
2987 * Invoking guix time-machine:: Running an older revision of Guix.
2988 * Inferiors:: Interacting with another revision of Guix.
2989 * Invoking guix describe:: Display information about your Guix revision.
2990 * Invoking guix archive:: Exporting and importing store files.
2991 @end menu
2992
2993 @node Features
2994 @section Features
2995
2996 Here we assume you've already made your first steps with Guix
2997 (@pxref{Getting Started}) and would like to get an overview about what's
2998 going on under the hood.
2999
3000 When using Guix, each package ends up in the @dfn{package store}, in its
3001 own directory---something that resembles
3002 @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
3003
3004 Instead of referring to these directories, users have their own
3005 @dfn{profile}, which points to the packages that they actually want to
3006 use. These profiles are stored within each user's home directory, at
3007 @code{$HOME/.guix-profile}.
3008
3009 For example, @code{alice} installs GCC 4.7.2. As a result,
3010 @file{/home/alice/.guix-profile/bin/gcc} points to
3011 @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
3012 @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
3013 simply continues to point to
3014 @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
3015 coexist on the same system without any interference.
3016
3017 The @command{guix package} command is the central tool to manage
3018 packages (@pxref{Invoking guix package}). It operates on the per-user
3019 profiles, and can be used @emph{with normal user privileges}.
3020
3021 @cindex transactions
3022 The command provides the obvious install, remove, and upgrade
3023 operations. Each invocation is actually a @emph{transaction}: either
3024 the specified operation succeeds, or nothing happens. Thus, if the
3025 @command{guix package} process is terminated during the transaction,
3026 or if a power outage occurs during the transaction, then the user's
3027 profile remains in its previous state, and remains usable.
3028
3029 In addition, any package transaction may be @emph{rolled back}. So, if,
3030 for example, an upgrade installs a new version of a package that turns
3031 out to have a serious bug, users may roll back to the previous instance
3032 of their profile, which was known to work well. Similarly, the global
3033 system configuration on Guix is subject to
3034 transactional upgrades and roll-back
3035 (@pxref{Using the Configuration System}).
3036
3037 All packages in the package store may be @emph{garbage-collected}.
3038 Guix can determine which packages are still referenced by user
3039 profiles, and remove those that are provably no longer referenced
3040 (@pxref{Invoking guix gc}). Users may also explicitly remove old
3041 generations of their profile so that the packages they refer to can be
3042 collected.
3043
3044 @cindex reproducibility
3045 @cindex reproducible builds
3046 Guix takes a @dfn{purely functional} approach to package
3047 management, as described in the introduction (@pxref{Introduction}).
3048 Each @file{/gnu/store} package directory name contains a hash of all the
3049 inputs that were used to build that package---compiler, libraries, build
3050 scripts, etc. This direct correspondence allows users to make sure a
3051 given package installation matches the current state of their
3052 distribution. It also helps maximize @dfn{build reproducibility}:
3053 thanks to the isolated build environments that are used, a given build
3054 is likely to yield bit-identical files when performed on different
3055 machines (@pxref{Invoking guix-daemon, container}).
3056
3057 @cindex substitutes
3058 This foundation allows Guix to support @dfn{transparent binary/source
3059 deployment}. When a pre-built binary for a @file{/gnu/store} item is
3060 available from an external source---a @dfn{substitute}, Guix just
3061 downloads it and unpacks it;
3062 otherwise, it builds the package from source, locally
3063 (@pxref{Substitutes}). Because build results are usually bit-for-bit
3064 reproducible, users do not have to trust servers that provide
3065 substitutes: they can force a local build and @emph{challenge} providers
3066 (@pxref{Invoking guix challenge}).
3067
3068 Control over the build environment is a feature that is also useful for
3069 developers. The @command{guix environment} command allows developers of
3070 a package to quickly set up the right development environment for their
3071 package, without having to manually install the dependencies of the
3072 package into their profile (@pxref{Invoking guix environment}).
3073
3074 @cindex replication, of software environments
3075 @cindex provenance tracking, of software artifacts
3076 All of Guix and its package definitions is version-controlled, and
3077 @command{guix pull} allows you to ``travel in time'' on the history of Guix
3078 itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
3079 Guix instance on a different machine or at a later point in time, which in
3080 turn allows you to @emph{replicate complete software environments}, while
3081 retaining precise @dfn{provenance tracking} of the software.
3082
3083 @node Invoking guix package
3084 @section Invoking @command{guix package}
3085
3086 @cindex installing packages
3087 @cindex removing packages
3088 @cindex package installation
3089 @cindex package removal
3090 @cindex profile
3091 The @command{guix package} command is the tool that allows users to
3092 install, upgrade, and remove packages, as well as rolling back to
3093 previous configurations. These operations work on a user
3094 @dfn{profile}---a directory of installed packages. Each user has a
3095 default profile in @file{$HOME/.guix-profile}.
3096 The command operates only on the user's own profile,
3097 and works with normal user privileges (@pxref{Features}). Its syntax
3098 is:
3099
3100 @example
3101 guix package @var{options}
3102 @end example
3103
3104 @cindex transactions
3105 Primarily, @var{options} specifies the operations to be performed during
3106 the transaction. Upon completion, a new profile is created, but
3107 previous @dfn{generations} of the profile remain available, should the user
3108 want to roll back.
3109
3110 For example, to remove @code{lua} and install @code{guile} and
3111 @code{guile-cairo} in a single transaction:
3112
3113 @example
3114 guix package -r lua -i guile guile-cairo
3115 @end example
3116
3117 @cindex aliases, for @command{guix package}
3118 For your convenience, we also provide the following aliases:
3119
3120 @itemize
3121 @item
3122 @command{guix search} is an alias for @command{guix package -s},
3123 @item
3124 @command{guix install} is an alias for @command{guix package -i},
3125 @item
3126 @command{guix remove} is an alias for @command{guix package -r},
3127 @item
3128 @command{guix upgrade} is an alias for @command{guix package -u},
3129 @item
3130 and @command{guix show} is an alias for @command{guix package --show=}.
3131 @end itemize
3132
3133 These aliases are less expressive than @command{guix package} and provide
3134 fewer options, so in some cases you'll probably want to use @command{guix
3135 package} directly.
3136
3137 @command{guix package} also supports a @dfn{declarative approach}
3138 whereby the user specifies the exact set of packages to be available and
3139 passes it @i{via} the @option{--manifest} option
3140 (@pxref{profile-manifest, @option{--manifest}}).
3141
3142 @cindex profile
3143 For each user, a symlink to the user's default profile is automatically
3144 created in @file{$HOME/.guix-profile}. This symlink always points to the
3145 current generation of the user's default profile. Thus, users can add
3146 @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
3147 variable, and so on.
3148 @cindex search paths
3149 If you are not using Guix System, consider adding the
3150 following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
3151 Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
3152 shells get all the right environment variable definitions:
3153
3154 @example
3155 GUIX_PROFILE="$HOME/.guix-profile" ; \
3156 source "$GUIX_PROFILE/etc/profile"
3157 @end example
3158
3159 In a multi-user setup, user profiles are stored in a place registered as
3160 a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
3161 to (@pxref{Invoking guix gc}). That directory is normally
3162 @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
3163 @var{localstatedir} is the value passed to @code{configure} as
3164 @option{--localstatedir}, and @var{user} is the user name. The
3165 @file{per-user} directory is created when @command{guix-daemon} is
3166 started, and the @var{user} sub-directory is created by @command{guix
3167 package}.
3168
3169 The @var{options} can be among the following:
3170
3171 @table @code
3172
3173 @item --install=@var{package} @dots{}
3174 @itemx -i @var{package} @dots{}
3175 Install the specified @var{package}s.
3176
3177 Each @var{package} may specify either a simple package name, such as
3178 @code{guile}, or a package name followed by an at-sign and version number,
3179 such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
3180 case, the newest version prefixed by @code{1.8} is selected).
3181
3182 If no version number is specified, the
3183 newest available version will be selected. In addition, @var{package}
3184 may contain a colon, followed by the name of one of the outputs of the
3185 package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
3186 (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
3187 name (and optionally version) are searched for among the GNU
3188 distribution modules (@pxref{Package Modules}).
3189
3190 @cindex propagated inputs
3191 Sometimes packages have @dfn{propagated inputs}: these are dependencies
3192 that automatically get installed along with the required package
3193 (@pxref{package-propagated-inputs, @code{propagated-inputs} in
3194 @code{package} objects}, for information about propagated inputs in
3195 package definitions).
3196
3197 @anchor{package-cmd-propagated-inputs}
3198 An example is the GNU MPC library: its C header files refer to those of
3199 the GNU MPFR library, which in turn refer to those of the GMP library.
3200 Thus, when installing MPC, the MPFR and GMP libraries also get installed
3201 in the profile; removing MPC also removes MPFR and GMP---unless they had
3202 also been explicitly installed by the user.
3203
3204 Besides, packages sometimes rely on the definition of environment
3205 variables for their search paths (see explanation of
3206 @option{--search-paths} below). Any missing or possibly incorrect
3207 environment variable definitions are reported here.
3208
3209 @item --install-from-expression=@var{exp}
3210 @itemx -e @var{exp}
3211 Install the package @var{exp} evaluates to.
3212
3213 @var{exp} must be a Scheme expression that evaluates to a
3214 @code{<package>} object. This option is notably useful to disambiguate
3215 between same-named variants of a package, with expressions such as
3216 @code{(@@ (gnu packages base) guile-final)}.
3217
3218 Note that this option installs the first output of the specified
3219 package, which may be insufficient when needing a specific output of a
3220 multiple-output package.
3221
3222 @item --install-from-file=@var{file}
3223 @itemx -f @var{file}
3224 Install the package that the code within @var{file} evaluates to.
3225
3226 As an example, @var{file} might contain a definition like this
3227 (@pxref{Defining Packages}):
3228
3229 @lisp
3230 @include package-hello.scm
3231 @end lisp
3232
3233 Developers may find it useful to include such a @file{guix.scm} file
3234 in the root of their project source tree that can be used to test
3235 development snapshots and create reproducible development environments
3236 (@pxref{Invoking guix environment}).
3237
3238 The @var{file} may also contain a JSON representation of one or more
3239 package definitions. Running @code{guix package -f} on
3240 @file{hello.json} with the following contents would result in installing
3241 the package @code{greeter} after building @code{myhello}:
3242
3243 @example
3244 @verbatiminclude package-hello.json
3245 @end example
3246
3247 @item --remove=@var{package} @dots{}
3248 @itemx -r @var{package} @dots{}
3249 Remove the specified @var{package}s.
3250
3251 As for @option{--install}, each @var{package} may specify a version number
3252 and/or output name in addition to the package name. For instance,
3253 @samp{-r glibc:debug} would remove the @code{debug} output of
3254 @code{glibc}.
3255
3256 @item --upgrade[=@var{regexp} @dots{}]
3257 @itemx -u [@var{regexp} @dots{}]
3258 @cindex upgrading packages
3259 Upgrade all the installed packages. If one or more @var{regexp}s are
3260 specified, upgrade only installed packages whose name matches a
3261 @var{regexp}. Also see the @option{--do-not-upgrade} option below.
3262
3263 Note that this upgrades package to the latest version of packages found
3264 in the distribution currently installed. To update your distribution,
3265 you should regularly run @command{guix pull} (@pxref{Invoking guix
3266 pull}).
3267
3268 @cindex package transformations, upgrades
3269 When upgrading, package transformations that were originally applied
3270 when creating the profile are automatically re-applied (@pxref{Package
3271 Transformation Options}). For example, assume you first installed Emacs
3272 from the tip of its development branch with:
3273
3274 @example
3275 guix install emacs-next --with-branch=emacs-next=master
3276 @end example
3277
3278 Next time you run @command{guix upgrade}, Guix will again pull the tip
3279 of the Emacs development branch and build @code{emacs-next} from that
3280 checkout.
3281
3282 Note that transformation options such as @option{--with-branch} and
3283 @option{--with-source} depend on external state; it is up to you to
3284 ensure that they work as expected. You can also discard a
3285 transformations that apply to a package by running:
3286
3287 @example
3288 guix install @var{package}
3289 @end example
3290
3291 @item --do-not-upgrade[=@var{regexp} @dots{}]
3292 When used together with the @option{--upgrade} option, do @emph{not}
3293 upgrade any packages whose name matches a @var{regexp}. For example, to
3294 upgrade all packages in the current profile except those containing the
3295 substring ``emacs'':
3296
3297 @example
3298 $ guix package --upgrade . --do-not-upgrade emacs
3299 @end example
3300
3301 @item @anchor{profile-manifest}--manifest=@var{file}
3302 @itemx -m @var{file}
3303 @cindex profile declaration
3304 @cindex profile manifest
3305 Create a new generation of the profile from the manifest object
3306 returned by the Scheme code in @var{file}. This option can be repeated
3307 several times, in which case the manifests are concatenated.
3308
3309 This allows you to @emph{declare} the profile's contents rather than
3310 constructing it through a sequence of @option{--install} and similar
3311 commands. The advantage is that @var{file} can be put under version
3312 control, copied to different machines to reproduce the same profile, and
3313 so on.
3314
3315 @c FIXME: Add reference to (guix profile) documentation when available.
3316 @var{file} must return a @dfn{manifest} object, which is roughly a list
3317 of packages:
3318
3319 @findex packages->manifest
3320 @lisp
3321 (use-package-modules guile emacs)
3322
3323 (packages->manifest
3324 (list emacs
3325 guile-2.0
3326 ;; Use a specific package output.
3327 (list guile-2.0 "debug")))
3328 @end lisp
3329
3330 @findex specifications->manifest
3331 In this example we have to know which modules define the @code{emacs}
3332 and @code{guile-2.0} variables to provide the right
3333 @code{use-package-modules} line, which can be cumbersome. We can
3334 instead provide regular package specifications and let
3335 @code{specifications->manifest} look up the corresponding package
3336 objects, like this:
3337
3338 @lisp
3339 (specifications->manifest
3340 '("emacs" "guile@@2.2" "guile@@2.2:debug"))
3341 @end lisp
3342
3343 @xref{export-manifest, @option{--export-manifest}}, to learn how to
3344 obtain a manifest file from an existing profile.
3345
3346 @item --roll-back
3347 @cindex rolling back
3348 @cindex undoing transactions
3349 @cindex transactions, undoing
3350 Roll back to the previous @dfn{generation} of the profile---i.e., undo
3351 the last transaction.
3352
3353 When combined with options such as @option{--install}, roll back occurs
3354 before any other actions.
3355
3356 When rolling back from the first generation that actually contains
3357 installed packages, the profile is made to point to the @dfn{zeroth
3358 generation}, which contains no files apart from its own metadata.
3359
3360 After having rolled back, installing, removing, or upgrading packages
3361 overwrites previous future generations. Thus, the history of the
3362 generations in a profile is always linear.
3363
3364 @item --switch-generation=@var{pattern}
3365 @itemx -S @var{pattern}
3366 @cindex generations
3367 Switch to a particular generation defined by @var{pattern}.
3368
3369 @var{pattern} may be either a generation number or a number prefixed
3370 with ``+'' or ``-''. The latter means: move forward/backward by a
3371 specified number of generations. For example, if you want to return to
3372 the latest generation after @option{--roll-back}, use
3373 @option{--switch-generation=+1}.
3374
3375 The difference between @option{--roll-back} and
3376 @option{--switch-generation=-1} is that @option{--switch-generation} will
3377 not make a zeroth generation, so if a specified generation does not
3378 exist, the current generation will not be changed.
3379
3380 @item --search-paths[=@var{kind}]
3381 @cindex search paths
3382 Report environment variable definitions, in Bash syntax, that may be
3383 needed in order to use the set of installed packages. These environment
3384 variables are used to specify @dfn{search paths} for files used by some
3385 of the installed packages.
3386
3387 For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
3388 environment variables to be defined so it can look for headers and
3389 libraries in the user's profile (@pxref{Environment Variables,,, gcc,
3390 Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
3391 library are installed in the profile, then @option{--search-paths} will
3392 suggest setting these variables to @file{@var{profile}/include} and
3393 @file{@var{profile}/lib}, respectively.
3394
3395 The typical use case is to define these environment variables in the
3396 shell:
3397
3398 @example
3399 $ eval `guix package --search-paths`
3400 @end example
3401
3402 @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
3403 meaning that the returned environment variable definitions will either
3404 be exact settings, or prefixes or suffixes of the current value of these
3405 variables. When omitted, @var{kind} defaults to @code{exact}.
3406
3407 This option can also be used to compute the @emph{combined} search paths
3408 of several profiles. Consider this example:
3409
3410 @example
3411 $ guix package -p foo -i guile
3412 $ guix package -p bar -i guile-json
3413 $ guix package -p foo -p bar --search-paths
3414 @end example
3415
3416 The last command above reports about the @env{GUILE_LOAD_PATH}
3417 variable, even though, taken individually, neither @file{foo} nor
3418 @file{bar} would lead to that recommendation.
3419
3420
3421 @cindex profile, choosing
3422 @item --profile=@var{profile}
3423 @itemx -p @var{profile}
3424 Use @var{profile} instead of the user's default profile.
3425
3426 @var{profile} must be the name of a file that will be created upon
3427 completion. Concretely, @var{profile} will be a mere symbolic link
3428 (``symlink'') pointing to the actual profile where packages are
3429 installed:
3430
3431 @example
3432 $ guix install hello -p ~/code/my-profile
3433 @dots{}
3434 $ ~/code/my-profile/bin/hello
3435 Hello, world!
3436 @end example
3437
3438 All it takes to get rid of the profile is to remove this symlink and its
3439 siblings that point to specific generations:
3440
3441 @example
3442 $ rm ~/code/my-profile ~/code/my-profile-*-link
3443 @end example
3444
3445 @item --list-profiles
3446 List all the user's profiles:
3447
3448 @example
3449 $ guix package --list-profiles
3450 /home/charlie/.guix-profile
3451 /home/charlie/code/my-profile
3452 /home/charlie/code/devel-profile
3453 /home/charlie/tmp/test
3454 @end example
3455
3456 When running as root, list all the profiles of all the users.
3457
3458 @cindex collisions, in a profile
3459 @cindex colliding packages in profiles
3460 @cindex profile collisions
3461 @item --allow-collisions
3462 Allow colliding packages in the new profile. Use at your own risk!
3463
3464 By default, @command{guix package} reports as an error @dfn{collisions}
3465 in the profile. Collisions happen when two or more different versions
3466 or variants of a given package end up in the profile.
3467
3468 @item --bootstrap
3469 Use the bootstrap Guile to build the profile. This option is only
3470 useful to distribution developers.
3471
3472 @end table
3473
3474 In addition to these actions, @command{guix package} supports the
3475 following options to query the current state of a profile, or the
3476 availability of packages:
3477
3478 @table @option
3479
3480 @item --search=@var{regexp}
3481 @itemx -s @var{regexp}
3482 @anchor{guix-search}
3483 @cindex searching for packages
3484 List the available packages whose name, synopsis, or description matches
3485 @var{regexp} (in a case-insensitive fashion), sorted by relevance.
3486 Print all the metadata of matching packages in
3487 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
3488 GNU recutils manual}).
3489
3490 This allows specific fields to be extracted using the @command{recsel}
3491 command, for instance:
3492
3493 @example
3494 $ guix package -s malloc | recsel -p name,version,relevance
3495 name: jemalloc
3496 version: 4.5.0
3497 relevance: 6
3498
3499 name: glibc
3500 version: 2.25
3501 relevance: 1
3502
3503 name: libgc
3504 version: 7.6.0
3505 relevance: 1
3506 @end example
3507
3508 Similarly, to show the name of all the packages available under the
3509 terms of the GNU@tie{}LGPL version 3:
3510
3511 @example
3512 $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
3513 name: elfutils
3514
3515 name: gmp
3516 @dots{}
3517 @end example
3518
3519 It is also possible to refine search results using several @code{-s} flags to
3520 @command{guix package}, or several arguments to @command{guix search}. For
3521 example, the following command returns a list of board games (this time using
3522 the @command{guix search} alias):
3523
3524 @example
3525 $ guix search '\<board\>' game | recsel -p name
3526 name: gnubg
3527 @dots{}
3528 @end example
3529
3530 If we were to omit @code{-s game}, we would also get software packages
3531 that deal with printed circuit boards; removing the angle brackets
3532 around @code{board} would further add packages that have to do with
3533 keyboards.
3534
3535 And now for a more elaborate example. The following command searches
3536 for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
3537 libraries, and prints the name and synopsis of the matching packages:
3538
3539 @example
3540 $ guix search crypto library | \
3541 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
3542 @end example
3543
3544 @noindent
3545 @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
3546 information on @dfn{selection expressions} for @code{recsel -e}.
3547
3548 @item --show=@var{package}
3549 Show details about @var{package}, taken from the list of available packages, in
3550 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
3551 recutils manual}).
3552
3553 @example
3554 $ guix package --show=python | recsel -p name,version
3555 name: python
3556 version: 2.7.6
3557
3558 name: python
3559 version: 3.3.5
3560 @end example
3561
3562 You may also specify the full name of a package to only get details about a
3563 specific version of it (this time using the @command{guix show} alias):
3564 @example
3565 $ guix show python@@3.4 | recsel -p name,version
3566 name: python
3567 version: 3.4.3
3568 @end example
3569
3570
3571
3572 @item --list-installed[=@var{regexp}]
3573 @itemx -I [@var{regexp}]
3574 List the currently installed packages in the specified profile, with the
3575 most recently installed packages shown last. When @var{regexp} is
3576 specified, list only installed packages whose name matches @var{regexp}.
3577
3578 For each installed package, print the following items, separated by
3579 tabs: the package name, its version string, the part of the package that
3580 is installed (for instance, @code{out} for the default output,
3581 @code{include} for its headers, etc.), and the path of this package in
3582 the store.
3583
3584 @item --list-available[=@var{regexp}]
3585 @itemx -A [@var{regexp}]
3586 List packages currently available in the distribution for this system
3587 (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
3588 available packages whose name matches @var{regexp}.
3589
3590 For each package, print the following items separated by tabs: its name,
3591 its version string, the parts of the package (@pxref{Packages with
3592 Multiple Outputs}), and the source location of its definition.
3593
3594 @item --list-generations[=@var{pattern}]
3595 @itemx -l [@var{pattern}]
3596 @cindex generations
3597 Return a list of generations along with their creation dates; for each
3598 generation, show the installed packages, with the most recently
3599 installed packages shown last. Note that the zeroth generation is never
3600 shown.
3601
3602 For each installed package, print the following items, separated by
3603 tabs: the name of a package, its version string, the part of the package
3604 that is installed (@pxref{Packages with Multiple Outputs}), and the
3605 location of this package in the store.
3606
3607 When @var{pattern} is used, the command returns only matching
3608 generations. Valid patterns include:
3609
3610 @itemize
3611 @item @emph{Integers and comma-separated integers}. Both patterns denote
3612 generation numbers. For instance, @option{--list-generations=1} returns
3613 the first one.
3614
3615 And @option{--list-generations=1,8,2} outputs three generations in the
3616 specified order. Neither spaces nor trailing commas are allowed.
3617
3618 @item @emph{Ranges}. @option{--list-generations=2..9} prints the
3619 specified generations and everything in between. Note that the start of
3620 a range must be smaller than its end.
3621
3622 It is also possible to omit the endpoint. For example,
3623 @option{--list-generations=2..}, returns all generations starting from the
3624 second one.
3625
3626 @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
3627 or months by passing an integer along with the first letter of the
3628 duration. For example, @option{--list-generations=20d} lists generations
3629 that are up to 20 days old.
3630 @end itemize
3631
3632 @item --delete-generations[=@var{pattern}]
3633 @itemx -d [@var{pattern}]
3634 When @var{pattern} is omitted, delete all generations except the current
3635 one.
3636
3637 This command accepts the same patterns as @option{--list-generations}.
3638 When @var{pattern} is specified, delete the matching generations. When
3639 @var{pattern} specifies a duration, generations @emph{older} than the
3640 specified duration match. For instance, @option{--delete-generations=1m}
3641 deletes generations that are more than one month old.
3642
3643 If the current generation matches, it is @emph{not} deleted. Also, the
3644 zeroth generation is never deleted.
3645
3646 Note that deleting generations prevents rolling back to them.
3647 Consequently, this command must be used with care.
3648
3649 @cindex manifest, exporting
3650 @anchor{export-manifest}
3651 @item --export-manifest
3652 Write to standard output a manifest suitable for @option{--manifest}
3653 corresponding to the chosen profile(s).
3654
3655 This option is meant to help you migrate from the ``imperative''
3656 operating mode---running @command{guix install}, @command{guix upgrade},
3657 etc.---to the declarative mode that @option{--manifest} offers.
3658
3659 Be aware that the resulting manifest @emph{approximates} what your
3660 profile actually contains; for instance, depending on how your profile
3661 was created, it can refer to packages or package versions that are not
3662 exactly what you specified.
3663
3664 Keep in mind that a manifest is purely symbolic: it only contains
3665 package names and possibly versions, and their meaning varies over time.
3666 If you wish to ``pin'' channels to the revisions that were used to build
3667 the profile(s), see @option{--export-channels} below.
3668
3669 @cindex pinning, channel revisions of a profile
3670 @item --export-channels
3671 Write to standard output the list of channels used by the chosen
3672 profile(s), in a format suitable for @command{guix pull --channels} or
3673 @command{guix time-machine --channels} (@pxref{Channels}).
3674
3675 Together with @option{--export-manifest}, this option provides
3676 information allowing you to replicate the current profile
3677 (@pxref{Replicating Guix}).
3678
3679 However, note that the output of this command @emph{approximates} what
3680 was actually used to build this profile. In particular, a single
3681 profile might have been built from several different revisions of the
3682 same channel. In that case, @option{--export-manifest} chooses the last
3683 one and writes the list of other revisions in a comment. If you really
3684 need to pick packages from different channel revisions, you can use
3685 inferiors in your manifest to do so (@pxref{Inferiors}).
3686
3687 Together with @option{--export-manifest}, this is a good starting point
3688 if you are willing to migrate from the ``imperative'' model to the fully
3689 declarative model consisting of a manifest file along with a channels
3690 file pinning the exact channel revision(s) you want.
3691 @end table
3692
3693 Finally, since @command{guix package} may actually start build
3694 processes, it supports all the common build options (@pxref{Common Build
3695 Options}). It also supports package transformation options, such as
3696 @option{--with-source}, and preserves them across upgrades
3697 (@pxref{Package Transformation Options}).
3698
3699 @node Substitutes
3700 @section Substitutes
3701
3702 @cindex substitutes
3703 @cindex pre-built binaries
3704 Guix supports transparent source/binary deployment, which means that it
3705 can either build things locally, or download pre-built items from a
3706 server, or both. We call these pre-built items @dfn{substitutes}---they
3707 are substitutes for local build results. In many cases, downloading a
3708 substitute is much faster than building things locally.
3709
3710 Substitutes can be anything resulting from a derivation build
3711 (@pxref{Derivations}). Of course, in the common case, they are
3712 pre-built package binaries, but source tarballs, for instance, which
3713 also result from derivation builds, can be available as substitutes.
3714
3715 @menu
3716 * Official Substitute Servers:: One particular source of substitutes.
3717 * Substitute Server Authorization:: How to enable or disable substitutes.
3718 * Getting Substitutes from Other Servers:: Substitute diversity.
3719 * Substitute Authentication:: How Guix verifies substitutes.
3720 * Proxy Settings:: How to get substitutes via proxy.
3721 * Substitution Failure:: What happens when substitution fails.
3722 * On Trusting Binaries:: How can you trust that binary blob?
3723 @end menu
3724
3725 @node Official Substitute Servers
3726 @subsection Official Substitute Servers
3727
3728 @cindex build farm
3729 @code{@value{SUBSTITUTE-SERVER-1}} and
3730 @code{@value{SUBSTITUTE-SERVER-2}} are both front-ends to official build
3731 farms that build packages from Guix continuously for some architectures,
3732 and make them available as substitutes. These are the default source of
3733 substitutes; which can be overridden by passing the
3734 @option{--substitute-urls} option either to @command{guix-daemon}
3735 (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
3736 or to client tools such as @command{guix package}
3737 (@pxref{client-substitute-urls,, client @option{--substitute-urls}
3738 option}).
3739
3740 Substitute URLs can be either HTTP or HTTPS.
3741 HTTPS is recommended because communications are encrypted; conversely,
3742 using HTTP makes all communications visible to an eavesdropper, who
3743 could use the information gathered to determine, for instance, whether
3744 your system has unpatched security vulnerabilities.
3745
3746 Substitutes from the official build farms are enabled by default when
3747 using Guix System (@pxref{GNU Distribution}). However,
3748 they are disabled by default when using Guix on a foreign distribution,
3749 unless you have explicitly enabled them via one of the recommended
3750 installation steps (@pxref{Installation}). The following paragraphs
3751 describe how to enable or disable substitutes for the official build
3752 farm; the same procedure can also be used to enable substitutes for any
3753 other substitute server.
3754
3755 @node Substitute Server Authorization
3756 @subsection Substitute Server Authorization
3757
3758 @cindex security
3759 @cindex substitutes, authorization thereof
3760 @cindex access control list (ACL), for substitutes
3761 @cindex ACL (access control list), for substitutes
3762 To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER-1}}, @code{@value{SUBSTITUTE-SERVER-2}} or a mirror, you
3763 must add the relevant public key to the access control list (ACL) of archive
3764 imports, using the @command{guix archive} command (@pxref{Invoking guix
3765 archive}). Doing so implies that you trust the substitute server to not
3766 be compromised and to serve genuine substitutes.
3767
3768 @quotation Note
3769 If you are using Guix System, you can skip this section: Guix System
3770 authorizes substitutes from @code{@value{SUBSTITUTE-SERVER-1}} and
3771 @code{@value{SUBSTITUTE-SERVER-2}} by default.
3772 @end quotation
3773
3774 The public keys for each of the project maintained substitute servers
3775 are installed along with Guix, in @code{@var{prefix}/share/guix/}, where
3776 @var{prefix} is the installation prefix of Guix. If you installed Guix
3777 from source, make sure you checked the GPG signature of
3778 @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
3779 Then, you can run something like this:
3780
3781 @example
3782 # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
3783 # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
3784 @end example
3785
3786 Once this is in place, the output of a command like @code{guix build}
3787 should change from something like:
3788
3789 @example
3790 $ guix build emacs --dry-run
3791 The following derivations would be built:
3792 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
3793 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
3794 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
3795 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
3796 @dots{}
3797 @end example
3798
3799 @noindent
3800 to something like:
3801
3802 @example
3803 $ guix build emacs --dry-run
3804 112.3 MB would be downloaded:
3805 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
3806 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
3807 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
3808 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
3809 @dots{}
3810 @end example
3811
3812 @noindent
3813 The text changed from ``The following derivations would be built'' to
3814 ``112.3 MB would be downloaded''. This indicates that substitutes from
3815 the configured substitute servers are usable and will be downloaded,
3816 when possible, for future builds.
3817
3818 @cindex substitutes, how to disable
3819 The substitute mechanism can be disabled globally by running
3820 @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
3821 guix-daemon}). It can also be disabled temporarily by passing the
3822 @option{--no-substitutes} option to @command{guix package},
3823 @command{guix build}, and other command-line tools.
3824
3825 @node Getting Substitutes from Other Servers
3826 @subsection Getting Substitutes from Other Servers
3827
3828 @cindex substitute servers, adding more
3829 Guix can look up and fetch substitutes from several servers. This is
3830 useful when you are using packages from additional channels for which
3831 the official server does not have substitutes but another server
3832 provides them. Another situation where this is useful is when you would
3833 prefer to download from your organization's substitute server, resorting
3834 to the official server only as a fallback or dismissing it altogether.
3835
3836 You can give Guix a list of substitute server URLs and it will check
3837 them in the specified order. You also need to explicitly authorize the
3838 public keys of substitute servers to instruct Guix to accept the
3839 substitutes they sign.
3840
3841 On Guix System, this is achieved by modifying the configuration of the
3842 @code{guix} service. Since the @code{guix} service is part of the
3843 default lists of services, @code{%base-services} and
3844 @code{%desktop-services}, you can use @code{modify-services} to change
3845 its configuration and add the URLs and substitute keys that you want
3846 (@pxref{Service Reference, @code{modify-services}}).
3847
3848 As an example, suppose you want to fetch substitutes from
3849 @code{guix.example.org} and to authorize the signing key of that server,
3850 in addition to the default @code{@value{SUBSTITUTE-SERVER-1}} and
3851 @code{@value{SUBSTITUTE-SERVER-2}}. The resulting operating system
3852 configuration will look something like:
3853
3854 @lisp
3855 (operating-system
3856 ;; @dots{}
3857 (services
3858 ;; Assume we're starting from '%desktop-services'. Replace it
3859 ;; with the list of services you're actually using.
3860 (modify-services %desktop-services
3861 (guix-service-type config =>
3862 (guix-configuration
3863 (inherit config)
3864 (substitute-urls
3865 (append (list "https://guix.example.org")
3866 %default-substitute-urls))
3867 (authorized-keys
3868 (append (list (local-file "./key.pub"))
3869 %default-authorized-guix-keys)))))))
3870 @end lisp
3871
3872 This assumes that the file @file{key.pub} contains the signing key of
3873 @code{guix.example.org}. With this change in place in your operating
3874 system configuration file (say @file{/etc/config.scm}), you can
3875 reconfigure and restart the @code{guix-daemon} service or reboot so the
3876 changes take effect:
3877
3878 @example
3879 $ sudo guix system reconfigure /etc/config.scm
3880 $ sudo herd restart guix-daemon
3881 @end example
3882
3883 If you're running Guix on a ``foreign distro'', you would instead take
3884 the following steps to get substitutes from additional servers:
3885
3886 @enumerate
3887 @item
3888 Edit the service configuration file for @code{guix-daemon}; when using
3889 systemd, this is normally
3890 @file{/etc/systemd/system/guix-daemon.service}. Add the
3891 @option{--substitute-urls} option on the @command{guix-daemon} command
3892 line and list the URLs of interest (@pxref{daemon-substitute-urls,
3893 @code{guix-daemon --substitute-urls}}):
3894
3895 @example
3896 @dots{} --substitute-urls='https://guix.example.org @value{SUBSTITUTE-URLS}'
3897 @end example
3898
3899 @item
3900 Restart the daemon. For systemd, it goes like this:
3901
3902 @example
3903 systemctl daemon-reload
3904 systemctl restart guix-daemon.service
3905 @end example
3906
3907 @item
3908 Authorize the key of the new server (@pxref{Invoking guix archive}):
3909
3910 @example
3911 guix archive --authorize < key.pub
3912 @end example
3913
3914 Again this assumes @file{key.pub} contains the public key that
3915 @code{guix.example.org} uses to sign substitutes.
3916 @end enumerate
3917
3918 Now you're all set! Substitutes will be preferably taken from
3919 @code{https://guix.example.org}, using
3920 @code{@value{SUBSTITUTE-SERVER-1}} then
3921 @code{@value{SUBSTITUTE-SERVER-2}} as fallback options. Of course you
3922 can list as many substitute servers as you like, with the caveat that
3923 substitute lookup can be slowed down if too many servers need to be
3924 contacted.
3925
3926 Note that there are also situations where one may want to add the URL of
3927 a substitute server @emph{without} authorizing its key.
3928 @xref{Substitute Authentication}, to understand this fine point.
3929
3930 @node Substitute Authentication
3931 @subsection Substitute Authentication
3932
3933 @cindex digital signatures
3934 Guix detects and raises an error when attempting to use a substitute
3935 that has been tampered with. Likewise, it ignores substitutes that are
3936 not signed, or that are not signed by one of the keys listed in the ACL.
3937
3938 There is one exception though: if an unauthorized server provides
3939 substitutes that are @emph{bit-for-bit identical} to those provided by
3940 an authorized server, then the unauthorized server becomes eligible for
3941 downloads. For example, assume we have chosen two substitute servers
3942 with this option:
3943
3944 @example
3945 --substitute-urls="https://a.example.org https://b.example.org"
3946 @end example
3947
3948 @noindent
3949 @cindex reproducible builds
3950 If the ACL contains only the key for @samp{b.example.org}, and if
3951 @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
3952 then Guix will download substitutes from @samp{a.example.org} because it
3953 comes first in the list and can be considered a mirror of
3954 @samp{b.example.org}. In practice, independent build machines usually
3955 produce the same binaries, thanks to bit-reproducible builds (see
3956 below).
3957
3958 When using HTTPS, the server's X.509 certificate is @emph{not} validated
3959 (in other words, the server is not authenticated), contrary to what
3960 HTTPS clients such as Web browsers usually do. This is because Guix
3961 authenticates substitute information itself, as explained above, which
3962 is what we care about (whereas X.509 certificates are about
3963 authenticating bindings between domain names and public keys).
3964
3965 @node Proxy Settings
3966 @subsection Proxy Settings
3967
3968 @vindex http_proxy
3969 @vindex https_proxy
3970 Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
3971 @env{https_proxy} environment variables can be set in the environment of
3972 @command{guix-daemon} and are honored for downloads of substitutes.
3973 Note that the value of those environment variables in the environment
3974 where @command{guix build}, @command{guix package}, and other client
3975 commands are run has @emph{absolutely no effect}.
3976
3977 @node Substitution Failure
3978 @subsection Substitution Failure
3979
3980 Even when a substitute for a derivation is available, sometimes the
3981 substitution attempt will fail. This can happen for a variety of
3982 reasons: the substitute server might be offline, the substitute may
3983 recently have been deleted, the connection might have been interrupted,
3984 etc.
3985
3986 When substitutes are enabled and a substitute for a derivation is
3987 available, but the substitution attempt fails, Guix will attempt to
3988 build the derivation locally depending on whether or not
3989 @option{--fallback} was given (@pxref{fallback-option,, common build
3990 option @option{--fallback}}). Specifically, if @option{--fallback} was
3991 omitted, then no local build will be performed, and the derivation is
3992 considered to have failed. However, if @option{--fallback} was given,
3993 then Guix will attempt to build the derivation locally, and the success
3994 or failure of the derivation depends on the success or failure of the
3995 local build. Note that when substitutes are disabled or no substitute
3996 is available for the derivation in question, a local build will
3997 @emph{always} be performed, regardless of whether or not
3998 @option{--fallback} was given.
3999
4000 To get an idea of how many substitutes are available right now, you can
4001 try running the @command{guix weather} command (@pxref{Invoking guix
4002 weather}). This command provides statistics on the substitutes provided
4003 by a server.
4004
4005 @node On Trusting Binaries
4006 @subsection On Trusting Binaries
4007
4008 @cindex trust, of pre-built binaries
4009 Today, each individual's control over their own computing is at the
4010 mercy of institutions, corporations, and groups with enough power and
4011 determination to subvert the computing infrastructure and exploit its
4012 weaknesses. While using substitutes can be convenient, we encourage
4013 users to also build on their own, or even run their own build farm, such
4014 that the project run substitute servers are less of an interesting
4015 target. One way to help is by publishing the software you build using
4016 @command{guix publish} so that others have one more choice of server to
4017 download substitutes from (@pxref{Invoking guix publish}).
4018
4019 Guix has the foundations to maximize build reproducibility
4020 (@pxref{Features}). In most cases, independent builds of a given
4021 package or derivation should yield bit-identical results. Thus, through
4022 a diverse set of independent package builds, we can strengthen the
4023 integrity of our systems. The @command{guix challenge} command aims to
4024 help users assess substitute servers, and to assist developers in
4025 finding out about non-deterministic package builds (@pxref{Invoking guix
4026 challenge}). Similarly, the @option{--check} option of @command{guix
4027 build} allows users to check whether previously-installed substitutes
4028 are genuine by rebuilding them locally (@pxref{build-check,
4029 @command{guix build --check}}).
4030
4031 In the future, we want Guix to have support to publish and retrieve
4032 binaries to/from other users, in a peer-to-peer fashion. If you would
4033 like to discuss this project, join us on @email{guix-devel@@gnu.org}.
4034
4035 @node Packages with Multiple Outputs
4036 @section Packages with Multiple Outputs
4037
4038 @cindex multiple-output packages
4039 @cindex package outputs
4040 @cindex outputs
4041
4042 Often, packages defined in Guix have a single @dfn{output}---i.e., the
4043 source package leads to exactly one directory in the store. When running
4044 @command{guix install glibc}, one installs the default output of the
4045 GNU libc package; the default output is called @code{out}, but its name
4046 can be omitted as shown in this command. In this particular case, the
4047 default output of @code{glibc} contains all the C header files, shared
4048 libraries, static libraries, Info documentation, and other supporting
4049 files.
4050
4051 Sometimes it is more appropriate to separate the various types of files
4052 produced from a single source package into separate outputs. For
4053 instance, the GLib C library (used by GTK+ and related packages)
4054 installs more than 20 MiB of reference documentation as HTML pages.
4055 To save space for users who do not need it, the documentation goes to a
4056 separate output, called @code{doc}. To install the main GLib output,
4057 which contains everything but the documentation, one would run:
4058
4059 @example
4060 guix install glib
4061 @end example
4062
4063 @cindex documentation
4064 The command to install its documentation is:
4065
4066 @example
4067 guix install glib:doc
4068 @end example
4069
4070 Some packages install programs with different ``dependency footprints''.
4071 For instance, the WordNet package installs both command-line tools and
4072 graphical user interfaces (GUIs). The former depend solely on the C
4073 library, whereas the latter depend on Tcl/Tk and the underlying X
4074 libraries. In this case, we leave the command-line tools in the default
4075 output, whereas the GUIs are in a separate output. This allows users
4076 who do not need the GUIs to save space. The @command{guix size} command
4077 can help find out about such situations (@pxref{Invoking guix size}).
4078 @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
4079
4080 There are several such multiple-output packages in the GNU distribution.
4081 Other conventional output names include @code{lib} for libraries and
4082 possibly header files, @code{bin} for stand-alone programs, and
4083 @code{debug} for debugging information (@pxref{Installing Debugging
4084 Files}). The outputs of a packages are listed in the third column of
4085 the output of @command{guix package --list-available} (@pxref{Invoking
4086 guix package}).
4087
4088
4089 @node Invoking guix gc
4090 @section Invoking @command{guix gc}
4091
4092 @cindex garbage collector
4093 @cindex disk space
4094 Packages that are installed, but not used, may be @dfn{garbage-collected}.
4095 The @command{guix gc} command allows users to explicitly run the garbage
4096 collector to reclaim space from the @file{/gnu/store} directory. It is
4097 the @emph{only} way to remove files from @file{/gnu/store}---removing
4098 files or directories manually may break it beyond repair!
4099
4100 @cindex GC roots
4101 @cindex garbage collector roots
4102 The garbage collector has a set of known @dfn{roots}: any file under
4103 @file{/gnu/store} reachable from a root is considered @dfn{live} and
4104 cannot be deleted; any other file is considered @dfn{dead} and may be
4105 deleted. The set of garbage collector roots (``GC roots'' for short)
4106 includes default user profiles; by default, the symlinks under
4107 @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
4108 added with @command{guix build --root}, for example (@pxref{Invoking
4109 guix build}). The @command{guix gc --list-roots} command lists them.
4110
4111 Prior to running @code{guix gc --collect-garbage} to make space, it is
4112 often useful to remove old generations from user profiles; that way, old
4113 package builds referenced by those generations can be reclaimed. This
4114 is achieved by running @code{guix package --delete-generations}
4115 (@pxref{Invoking guix package}).
4116
4117 Our recommendation is to run a garbage collection periodically, or when
4118 you are short on disk space. For instance, to guarantee that at least
4119 5@tie{}GB are available on your disk, simply run:
4120
4121 @example
4122 guix gc -F 5G
4123 @end example
4124
4125 It is perfectly safe to run as a non-interactive periodic job
4126 (@pxref{Scheduled Job Execution}, for how to set up such a job).
4127 Running @command{guix gc} with no arguments will collect as
4128 much garbage as it can, but that is often inconvenient: you may find
4129 yourself having to rebuild or re-download software that is ``dead'' from
4130 the GC viewpoint but that is necessary to build other pieces of
4131 software---e.g., the compiler tool chain.
4132
4133 The @command{guix gc} command has three modes of operation: it can be
4134 used to garbage-collect any dead files (the default), to delete specific
4135 files (the @option{--delete} option), to print garbage-collector
4136 information, or for more advanced queries. The garbage collection
4137 options are as follows:
4138
4139 @table @code
4140 @item --collect-garbage[=@var{min}]
4141 @itemx -C [@var{min}]
4142 Collect garbage---i.e., unreachable @file{/gnu/store} files and
4143 sub-directories. This is the default operation when no option is
4144 specified.
4145
4146 When @var{min} is given, stop once @var{min} bytes have been collected.
4147 @var{min} may be a number of bytes, or it may include a unit as a
4148 suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
4149 (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
4150
4151 When @var{min} is omitted, collect all the garbage.
4152
4153 @item --free-space=@var{free}
4154 @itemx -F @var{free}
4155 Collect garbage until @var{free} space is available under
4156 @file{/gnu/store}, if possible; @var{free} denotes storage space, such
4157 as @code{500MiB}, as described above.
4158
4159 When @var{free} or more is already available in @file{/gnu/store}, do
4160 nothing and exit immediately.
4161
4162 @item --delete-generations[=@var{duration}]
4163 @itemx -d [@var{duration}]
4164 Before starting the garbage collection process, delete all the generations
4165 older than @var{duration}, for all the user profiles; when run as root, this
4166 applies to all the profiles @emph{of all the users}.
4167
4168 For example, this command deletes all the generations of all your profiles
4169 that are older than 2 months (except generations that are current), and then
4170 proceeds to free space until at least 10 GiB are available:
4171
4172 @example
4173 guix gc -d 2m -F 10G
4174 @end example
4175
4176 @item --delete
4177 @itemx -D
4178 Attempt to delete all the store files and directories specified as
4179 arguments. This fails if some of the files are not in the store, or if
4180 they are still live.
4181
4182 @item --list-failures
4183 List store items corresponding to cached build failures.
4184
4185 This prints nothing unless the daemon was started with
4186 @option{--cache-failures} (@pxref{Invoking guix-daemon,
4187 @option{--cache-failures}}).
4188
4189 @item --list-roots
4190 List the GC roots owned by the user; when run as root, list @emph{all} the GC
4191 roots.
4192
4193 @item --list-busy
4194 List store items in use by currently running processes. These store
4195 items are effectively considered GC roots: they cannot be deleted.
4196
4197 @item --clear-failures
4198 Remove the specified store items from the failed-build cache.
4199
4200 Again, this option only makes sense when the daemon is started with
4201 @option{--cache-failures}. Otherwise, it does nothing.
4202
4203 @item --list-dead
4204 Show the list of dead files and directories still present in the
4205 store---i.e., files and directories no longer reachable from any root.
4206
4207 @item --list-live
4208 Show the list of live store files and directories.
4209
4210 @end table
4211
4212 In addition, the references among existing store files can be queried:
4213
4214 @table @code
4215
4216 @item --references
4217 @itemx --referrers
4218 @cindex package dependencies
4219 List the references (respectively, the referrers) of store files given
4220 as arguments.
4221
4222 @item --requisites
4223 @itemx -R
4224 @cindex closure
4225 List the requisites of the store files passed as arguments. Requisites
4226 include the store files themselves, their references, and the references
4227 of these, recursively. In other words, the returned list is the
4228 @dfn{transitive closure} of the store files.
4229
4230 @xref{Invoking guix size}, for a tool to profile the size of the closure
4231 of an element. @xref{Invoking guix graph}, for a tool to visualize
4232 the graph of references.
4233
4234 @item --derivers
4235 @cindex derivation
4236 Return the derivation(s) leading to the given store items
4237 (@pxref{Derivations}).
4238
4239 For example, this command:
4240
4241 @example
4242 guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
4243 @end example
4244
4245 @noindent
4246 returns the @file{.drv} file(s) leading to the @code{emacs} package
4247 installed in your profile.
4248
4249 Note that there may be zero matching @file{.drv} files, for instance
4250 because these files have been garbage-collected. There can also be more
4251 than one matching @file{.drv} due to fixed-output derivations.
4252 @end table
4253
4254 Lastly, the following options allow you to check the integrity of the
4255 store and to control disk usage.
4256
4257 @table @option
4258
4259 @item --verify[=@var{options}]
4260 @cindex integrity, of the store
4261 @cindex integrity checking
4262 Verify the integrity of the store.
4263
4264 By default, make sure that all the store items marked as valid in the
4265 database of the daemon actually exist in @file{/gnu/store}.
4266
4267 When provided, @var{options} must be a comma-separated list containing one
4268 or more of @code{contents} and @code{repair}.
4269
4270 When passing @option{--verify=contents}, the daemon computes the
4271 content hash of each store item and compares it against its hash in the
4272 database. Hash mismatches are reported as data corruptions. Because it
4273 traverses @emph{all the files in the store}, this command can take a
4274 long time, especially on systems with a slow disk drive.
4275
4276 @cindex repairing the store
4277 @cindex corruption, recovering from
4278 Using @option{--verify=repair} or @option{--verify=contents,repair}
4279 causes the daemon to try to repair corrupt store items by fetching
4280 substitutes for them (@pxref{Substitutes}). Because repairing is not
4281 atomic, and thus potentially dangerous, it is available only to the
4282 system administrator. A lightweight alternative, when you know exactly
4283 which items in the store are corrupt, is @command{guix build --repair}
4284 (@pxref{Invoking guix build}).
4285
4286 @item --optimize
4287 @cindex deduplication
4288 Optimize the store by hard-linking identical files---this is
4289 @dfn{deduplication}.
4290
4291 The daemon performs deduplication after each successful build or archive
4292 import, unless it was started with @option{--disable-deduplication}
4293 (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
4294 this option is primarily useful when the daemon was running with
4295 @option{--disable-deduplication}.
4296
4297 @end table
4298
4299 @node Invoking guix pull
4300 @section Invoking @command{guix pull}
4301
4302 @cindex upgrading Guix
4303 @cindex updating Guix
4304 @cindex @command{guix pull}
4305 @cindex pull
4306 @cindex security, @command{guix pull}
4307 @cindex authenticity, of code obtained with @command{guix pull}
4308 Packages are installed or upgraded to the latest version available in
4309 the distribution currently available on your local machine. To update
4310 that distribution, along with the Guix tools, you must run @command{guix
4311 pull}: the command downloads the latest Guix source code and package
4312 descriptions, and deploys it. Source code is downloaded from a
4313 @uref{https://git-scm.com, Git} repository, by default the official
4314 GNU@tie{}Guix repository, though this can be customized. @command{guix
4315 pull} ensures that the code it downloads is @emph{authentic} by
4316 verifying that commits are signed by Guix developers.
4317
4318 Specifically, @command{guix pull} downloads code from the @dfn{channels}
4319 (@pxref{Channels}) specified by one of the followings, in this order:
4320
4321 @enumerate
4322 @item
4323 the @option{--channels} option;
4324 @item
4325 the user's @file{~/.config/guix/channels.scm} file;
4326 @item
4327 the system-wide @file{/etc/guix/channels.scm} file;
4328 @item
4329 the built-in default channels specified in the @code{%default-channels}
4330 variable.
4331 @end enumerate
4332
4333 On completion, @command{guix package} will use packages and package
4334 versions from this just-retrieved copy of Guix. Not only that, but all
4335 the Guix commands and Scheme modules will also be taken from that latest
4336 version. New @command{guix} sub-commands added by the update also
4337 become available.
4338
4339 Any user can update their Guix copy using @command{guix pull}, and the
4340 effect is limited to the user who ran @command{guix pull}. For
4341 instance, when user @code{root} runs @command{guix pull}, this has no
4342 effect on the version of Guix that user @code{alice} sees, and vice
4343 versa.
4344
4345 The result of running @command{guix pull} is a @dfn{profile} available
4346 under @file{~/.config/guix/current} containing the latest Guix. Thus,
4347 make sure to add it to the beginning of your search path so that you use
4348 the latest version, and similarly for the Info manual
4349 (@pxref{Documentation}):
4350
4351 @example
4352 export PATH="$HOME/.config/guix/current/bin:$PATH"
4353 export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
4354 @end example
4355
4356 The @option{--list-generations} or @option{-l} option lists past generations
4357 produced by @command{guix pull}, along with details about their provenance:
4358
4359 @example
4360 $ guix pull -l
4361 Generation 1 Jun 10 2018 00:18:18
4362 guix 65956ad
4363 repository URL: https://git.savannah.gnu.org/git/guix.git
4364 branch: origin/master
4365 commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
4366
4367 Generation 2 Jun 11 2018 11:02:49
4368 guix e0cc7f6
4369 repository URL: https://git.savannah.gnu.org/git/guix.git
4370 branch: origin/master
4371 commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
4372 2 new packages: keepalived, libnfnetlink
4373 6 packages upgraded: emacs-nix-mode@@2.0.4,
4374 guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
4375 heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
4376
4377 Generation 3 Jun 13 2018 23:31:07 (current)
4378 guix 844cc1c
4379 repository URL: https://git.savannah.gnu.org/git/guix.git
4380 branch: origin/master
4381 commit: 844cc1c8f394f03b404c5bb3aee086922373490c
4382 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
4383 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
4384 @end example
4385
4386 @xref{Invoking guix describe, @command{guix describe}}, for other ways to
4387 describe the current status of Guix.
4388
4389 This @code{~/.config/guix/current} profile works exactly like the profiles
4390 created by @command{guix package} (@pxref{Invoking guix package}). That
4391 is, you can list generations, roll back to the previous
4392 generation---i.e., the previous Guix---and so on:
4393
4394 @example
4395 $ guix pull --roll-back
4396 switched from generation 3 to 2
4397 $ guix pull --delete-generations=1
4398 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
4399 @end example
4400
4401 You can also use @command{guix package} (@pxref{Invoking guix package})
4402 to manage the profile by naming it explicitly:
4403 @example
4404 $ guix package -p ~/.config/guix/current --roll-back
4405 switched from generation 3 to 2
4406 $ guix package -p ~/.config/guix/current --delete-generations=1
4407 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
4408 @end example
4409
4410 The @command{guix pull} command is usually invoked with no arguments,
4411 but it supports the following options:
4412
4413 @table @code
4414 @item --url=@var{url}
4415 @itemx --commit=@var{commit}
4416 @itemx --branch=@var{branch}
4417 Download code for the @code{guix} channel from the specified @var{url}, at the
4418 given @var{commit} (a valid Git commit ID represented as a hexadecimal
4419 string), or @var{branch}.
4420
4421 @cindex @file{channels.scm}, configuration file
4422 @cindex configuration file for channels
4423 These options are provided for convenience, but you can also specify your
4424 configuration in the @file{~/.config/guix/channels.scm} file or using the
4425 @option{--channels} option (see below).
4426
4427 @item --channels=@var{file}
4428 @itemx -C @var{file}
4429 Read the list of channels from @var{file} instead of
4430 @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
4431 @var{file} must contain Scheme code that
4432 evaluates to a list of channel objects. @xref{Channels}, for more
4433 information.
4434
4435 @cindex channel news
4436 @item --news
4437 @itemx -N
4438 Display the list of packages added or upgraded since the previous
4439 generation, as well as, occasionally, news written by channel authors
4440 for their users (@pxref{Channels, Writing Channel News}).
4441
4442 The package information is the same as displayed upon @command{guix
4443 pull} completion, but without ellipses; it is also similar to the output
4444 of @command{guix pull -l} for the last generation (see below).
4445
4446 @item --list-generations[=@var{pattern}]
4447 @itemx -l [@var{pattern}]
4448 List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
4449 is provided, the subset of generations that match @var{pattern}.
4450 The syntax of @var{pattern} is the same as with @code{guix package
4451 --list-generations} (@pxref{Invoking guix package}).
4452
4453 @item --roll-back
4454 @cindex rolling back
4455 @cindex undoing transactions
4456 @cindex transactions, undoing
4457 Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
4458 undo the last transaction.
4459
4460 @item --switch-generation=@var{pattern}
4461 @itemx -S @var{pattern}
4462 @cindex generations
4463 Switch to a particular generation defined by @var{pattern}.
4464
4465 @var{pattern} may be either a generation number or a number prefixed
4466 with ``+'' or ``-''. The latter means: move forward/backward by a
4467 specified number of generations. For example, if you want to return to
4468 the latest generation after @option{--roll-back}, use
4469 @option{--switch-generation=+1}.
4470
4471 @item --delete-generations[=@var{pattern}]
4472 @itemx -d [@var{pattern}]
4473 When @var{pattern} is omitted, delete all generations except the current
4474 one.
4475
4476 This command accepts the same patterns as @option{--list-generations}.
4477 When @var{pattern} is specified, delete the matching generations. When
4478 @var{pattern} specifies a duration, generations @emph{older} than the
4479 specified duration match. For instance, @option{--delete-generations=1m}
4480 deletes generations that are more than one month old.
4481
4482 If the current generation matches, it is @emph{not} deleted.
4483
4484 Note that deleting generations prevents rolling back to them.
4485 Consequently, this command must be used with care.
4486
4487 @xref{Invoking guix describe}, for a way to display information about the
4488 current generation only.
4489
4490 @item --profile=@var{profile}
4491 @itemx -p @var{profile}
4492 Use @var{profile} instead of @file{~/.config/guix/current}.
4493
4494 @item --dry-run
4495 @itemx -n
4496 Show which channel commit(s) would be used and what would be built or
4497 substituted but do not actually do it.
4498
4499 @item --allow-downgrades
4500 Allow pulling older or unrelated revisions of channels than those
4501 currently in use.
4502
4503 @cindex downgrade attacks, protection against
4504 By default, @command{guix pull} protects against so-called ``downgrade
4505 attacks'' whereby the Git repository of a channel would be reset to an
4506 earlier or unrelated revision of itself, potentially leading you to
4507 install older, known-vulnerable versions of software packages.
4508
4509 @quotation Note
4510 Make sure you understand its security implications before using
4511 @option{--allow-downgrades}.
4512 @end quotation
4513
4514 @item --disable-authentication
4515 Allow pulling channel code without authenticating it.
4516
4517 @cindex authentication, of channel code
4518 By default, @command{guix pull} authenticates code downloaded from
4519 channels by verifying that its commits are signed by authorized
4520 developers, and raises an error if this is not the case. This option
4521 instructs it to not perform any such verification.
4522
4523 @quotation Note
4524 Make sure you understand its security implications before using
4525 @option{--disable-authentication}.
4526 @end quotation
4527
4528 @item --system=@var{system}
4529 @itemx -s @var{system}
4530 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
4531 the system type of the build host.
4532
4533 @item --bootstrap
4534 Use the bootstrap Guile to build the latest Guix. This option is only
4535 useful to Guix developers.
4536 @end table
4537
4538 The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
4539 repository and branch to pull from, as well as @emph{additional} repositories
4540 containing package modules that should be deployed. @xref{Channels}, for more
4541 information.
4542
4543 In addition, @command{guix pull} supports all the common build options
4544 (@pxref{Common Build Options}).
4545
4546 @node Invoking guix time-machine
4547 @section Invoking @command{guix time-machine}
4548
4549 @cindex @command{guix time-machine}
4550 @cindex pinning, channels
4551 @cindex replicating Guix
4552 @cindex reproducibility, of Guix
4553
4554 The @command{guix time-machine} command provides access to other
4555 revisions of Guix, for example to install older versions of packages,
4556 or to reproduce a computation in an identical environment. The revision
4557 of Guix to be used is defined by a commit or by a channel
4558 description file created by @command{guix describe}
4559 (@pxref{Invoking guix describe}).
4560
4561 The general syntax is:
4562
4563 @example
4564 guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
4565 @end example
4566
4567 where @var{command} and @var{arg}@dots{} are passed unmodified to the
4568 @command{guix} command of the specified revision. The @var{options} that define
4569 this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
4570
4571 @table @code
4572 @item --url=@var{url}
4573 @itemx --commit=@var{commit}
4574 @itemx --branch=@var{branch}
4575 Use the @code{guix} channel from the specified @var{url}, at the
4576 given @var{commit} (a valid Git commit ID represented as a hexadecimal
4577 string), or @var{branch}.
4578
4579 @item --channels=@var{file}
4580 @itemx -C @var{file}
4581 Read the list of channels from @var{file}. @var{file} must contain
4582 Scheme code that evaluates to a list of channel objects.
4583 @xref{Channels} for more information.
4584 @end table
4585
4586 As for @command{guix pull}, the absence of any options means that the
4587 latest commit on the master branch will be used. The command
4588
4589 @example
4590 guix time-machine -- build hello
4591 @end example
4592
4593 will thus build the package @code{hello} as defined in the master branch,
4594 which is in general a newer revision of Guix than you have installed.
4595 Time travel works in both directions!
4596
4597 Note that @command{guix time-machine} can trigger builds of channels and
4598 their dependencies, and these are controlled by the standard build
4599 options (@pxref{Common Build Options}).
4600
4601 @node Inferiors
4602 @section Inferiors
4603
4604 @c TODO: Remove this once we're more confident about API stability.
4605 @quotation Note
4606 The functionality described here is a ``technology preview'' as of version
4607 @value{VERSION}. As such, the interface is subject to change.
4608 @end quotation
4609
4610 @cindex inferiors
4611 @cindex composition of Guix revisions
4612 Sometimes you might need to mix packages from the revision of Guix you're
4613 currently running with packages available in a different revision of Guix.
4614 Guix @dfn{inferiors} allow you to achieve that by composing different Guix
4615 revisions in arbitrary ways.
4616
4617 @cindex inferior packages
4618 Technically, an ``inferior'' is essentially a separate Guix process connected
4619 to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
4620 @code{(guix inferior)} module allows you to create inferiors and to
4621 communicate with them. It also provides a high-level interface to browse and
4622 manipulate the packages that an inferior provides---@dfn{inferior packages}.
4623
4624 When combined with channels (@pxref{Channels}), inferiors provide a simple way
4625 to interact with a separate revision of Guix. For example, let's assume you
4626 want to install in your profile the current @code{guile} package, along with
4627 the @code{guile-json} as it existed in an older revision of Guix---perhaps
4628 because the newer @code{guile-json} has an incompatible API and you want to
4629 run your code against the old API@. To do that, you could write a manifest for
4630 use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
4631 manifest, you would create an inferior for that old Guix revision you care
4632 about, and you would look up the @code{guile-json} package in the inferior:
4633
4634 @lisp
4635 (use-modules (guix inferior) (guix channels)
4636 (srfi srfi-1)) ;for 'first'
4637
4638 (define channels
4639 ;; This is the old revision from which we want to
4640 ;; extract guile-json.
4641 (list (channel
4642 (name 'guix)
4643 (url "https://git.savannah.gnu.org/git/guix.git")
4644 (commit
4645 "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
4646
4647 (define inferior
4648 ;; An inferior representing the above revision.
4649 (inferior-for-channels channels))
4650
4651 ;; Now create a manifest with the current "guile" package
4652 ;; and the old "guile-json" package.
4653 (packages->manifest
4654 (list (first (lookup-inferior-packages inferior "guile-json"))
4655 (specification->package "guile")))
4656 @end lisp
4657
4658 On its first run, @command{guix package --manifest} might have to build the
4659 channel you specified before it can create the inferior; subsequent runs will
4660 be much faster because the Guix revision will be cached.
4661
4662 The @code{(guix inferior)} module provides the following procedures to open an
4663 inferior:
4664
4665 @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
4666 [#:cache-directory] [#:ttl]
4667 Return an inferior for @var{channels}, a list of channels. Use the cache at
4668 @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
4669 This procedure opens a new connection to the build daemon.
4670
4671 As a side effect, this procedure may build or substitute binaries for
4672 @var{channels}, which can take time.
4673 @end deffn
4674
4675 @deffn {Scheme Procedure} open-inferior @var{directory} @
4676 [#:command "bin/guix"]
4677 Open the inferior Guix in @var{directory}, running
4678 @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
4679 the inferior could not be launched.
4680 @end deffn
4681
4682 @cindex inferior packages
4683 The procedures listed below allow you to obtain and manipulate inferior
4684 packages.
4685
4686 @deffn {Scheme Procedure} inferior-packages @var{inferior}
4687 Return the list of packages known to @var{inferior}.
4688 @end deffn
4689
4690 @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
4691 [@var{version}]
4692 Return the sorted list of inferior packages matching @var{name} in
4693 @var{inferior}, with highest version numbers first. If @var{version} is true,
4694 return only packages with a version number prefixed by @var{version}.
4695 @end deffn
4696
4697 @deffn {Scheme Procedure} inferior-package? @var{obj}
4698 Return true if @var{obj} is an inferior package.
4699 @end deffn
4700
4701 @deffn {Scheme Procedure} inferior-package-name @var{package}
4702 @deffnx {Scheme Procedure} inferior-package-version @var{package}
4703 @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
4704 @deffnx {Scheme Procedure} inferior-package-description @var{package}
4705 @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
4706 @deffnx {Scheme Procedure} inferior-package-location @var{package}
4707 @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
4708 @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
4709 @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
4710 @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
4711 @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
4712 @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
4713 @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
4714 These procedures are the counterpart of package record accessors
4715 (@pxref{package Reference}). Most of them work by querying the inferior
4716 @var{package} comes from, so the inferior must still be live when you call
4717 these procedures.
4718 @end deffn
4719
4720 Inferior packages can be used transparently like any other package or
4721 file-like object in G-expressions (@pxref{G-Expressions}). They are also
4722 transparently handled by the @code{packages->manifest} procedure, which is
4723 commonly used in manifests (@pxref{Invoking guix package, the
4724 @option{--manifest} option of @command{guix package}}). Thus you can insert
4725 an inferior package pretty much anywhere you would insert a regular package:
4726 in manifests, in the @code{packages} field of your @code{operating-system}
4727 declaration, and so on.
4728
4729 @node Invoking guix describe
4730 @section Invoking @command{guix describe}
4731
4732 @cindex reproducibility
4733 @cindex replicating Guix
4734 Often you may want to answer questions like: ``Which revision of Guix am I
4735 using?'' or ``Which channels am I using?'' This is useful information in many
4736 situations: if you want to @emph{replicate} an environment on a different
4737 machine or user account, if you want to report a bug or to determine what
4738 change in the channels you are using caused it, or if you want to record your
4739 system state for reproducibility purposes. The @command{guix describe}
4740 command answers these questions.
4741
4742 When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
4743 displays the channel(s) that it was built from, including their repository URL
4744 and commit IDs (@pxref{Channels}):
4745
4746 @example
4747 $ guix describe
4748 Generation 10 Sep 03 2018 17:32:44 (current)
4749 guix e0fa68c
4750 repository URL: https://git.savannah.gnu.org/git/guix.git
4751 branch: master
4752 commit: e0fa68c7718fffd33d81af415279d6ddb518f727
4753 @end example
4754
4755 If you're familiar with the Git version control system, this is similar in
4756 spirit to @command{git describe}; the output is also similar to that of
4757 @command{guix pull --list-generations}, but limited to the current generation
4758 (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
4759 the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
4760 information is all it takes to describe the revision of Guix you're using, and
4761 also to replicate it.
4762
4763 To make it easier to replicate Guix, @command{guix describe} can also be asked
4764 to return a list of channels instead of the human-readable description above:
4765
4766 @example
4767 $ guix describe -f channels
4768 (list (channel
4769 (name 'guix)
4770 (url "https://git.savannah.gnu.org/git/guix.git")
4771 (commit
4772 "e0fa68c7718fffd33d81af415279d6ddb518f727")
4773 (introduction
4774 (make-channel-introduction
4775 "9edb3f66fd807b096b48283debdcddccfea34bad"
4776 (openpgp-fingerprint
4777 "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
4778 @end example
4779
4780 @noindent
4781 You can save this to a file and feed it to @command{guix pull -C} on some
4782 other machine or at a later point in time, which will instantiate @emph{this
4783 exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
4784 From there on, since you're able to deploy the same revision of Guix, you can
4785 just as well @emph{replicate a complete software environment}. We humbly
4786 think that this is @emph{awesome}, and we hope you'll like it too!
4787
4788 The details of the options supported by @command{guix describe} are as
4789 follows:
4790
4791 @table @code
4792 @item --format=@var{format}
4793 @itemx -f @var{format}
4794 Produce output in the specified @var{format}, one of:
4795
4796 @table @code
4797 @item human
4798 produce human-readable output;
4799 @item channels
4800 produce a list of channel specifications that can be passed to @command{guix
4801 pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
4802 guix pull});
4803 @item channels-sans-intro
4804 like @code{channels}, but omit the @code{introduction} field; use it to
4805 produce a channel specification suitable for Guix version 1.1.0 or
4806 earlier---the @code{introduction} field has to do with channel
4807 authentication (@pxref{Channels, Channel Authentication}) and is not
4808 supported by these older versions;
4809 @item json
4810 @cindex JSON
4811 produce a list of channel specifications in JSON format;
4812 @item recutils
4813 produce a list of channel specifications in Recutils format.
4814 @end table
4815
4816 @item --list-formats
4817 Display available formats for @option{--format} option.
4818
4819 @item --profile=@var{profile}
4820 @itemx -p @var{profile}
4821 Display information about @var{profile}.
4822 @end table
4823
4824 @node Invoking guix archive
4825 @section Invoking @command{guix archive}
4826
4827 @cindex @command{guix archive}
4828 @cindex archive
4829 The @command{guix archive} command allows users to @dfn{export} files
4830 from the store into a single archive, and to later @dfn{import} them on
4831 a machine that runs Guix.
4832 In particular, it allows store files to be transferred from one machine
4833 to the store on another machine.
4834
4835 @quotation Note
4836 If you're looking for a way to produce archives in a format suitable for
4837 tools other than Guix, @pxref{Invoking guix pack}.
4838 @end quotation
4839
4840 @cindex exporting store items
4841 To export store files as an archive to standard output, run:
4842
4843 @example
4844 guix archive --export @var{options} @var{specifications}...
4845 @end example
4846
4847 @var{specifications} may be either store file names or package
4848 specifications, as for @command{guix package} (@pxref{Invoking guix
4849 package}). For instance, the following command creates an archive
4850 containing the @code{gui} output of the @code{git} package and the main
4851 output of @code{emacs}:
4852
4853 @example
4854 guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
4855 @end example
4856
4857 If the specified packages are not built yet, @command{guix archive}
4858 automatically builds them. The build process may be controlled with the
4859 common build options (@pxref{Common Build Options}).
4860
4861 To transfer the @code{emacs} package to a machine connected over SSH,
4862 one would run:
4863
4864 @example
4865 guix archive --export -r emacs | ssh the-machine guix archive --import
4866 @end example
4867
4868 @noindent
4869 Similarly, a complete user profile may be transferred from one machine
4870 to another like this:
4871
4872 @example
4873 guix archive --export -r $(readlink -f ~/.guix-profile) | \
4874 ssh the-machine guix archive --import
4875 @end example
4876
4877 @noindent
4878 However, note that, in both examples, all of @code{emacs} and the
4879 profile as well as all of their dependencies are transferred (due to
4880 @option{-r}), regardless of what is already available in the store on
4881 the target machine. The @option{--missing} option can help figure out
4882 which items are missing from the target store. The @command{guix copy}
4883 command simplifies and optimizes this whole process, so this is probably
4884 what you should use in this case (@pxref{Invoking guix copy}).
4885
4886 @cindex nar, archive format
4887 @cindex normalized archive (nar)
4888 @cindex nar bundle, archive format
4889 Each store item is written in the @dfn{normalized archive} or @dfn{nar}
4890 format (described below), and the output of @command{guix archive
4891 --export} (and input of @command{guix archive --import}) is a @dfn{nar
4892 bundle}.
4893
4894 The nar format is
4895 comparable in spirit to `tar', but with differences
4896 that make it more appropriate for our purposes. First, rather than
4897 recording all Unix metadata for each file, the nar format only mentions
4898 the file type (regular, directory, or symbolic link); Unix permissions
4899 and owner/group are dismissed. Second, the order in which directory
4900 entries are stored always follows the order of file names according to
4901 the C locale collation order. This makes archive production fully
4902 deterministic.
4903
4904 That nar bundle format is essentially the concatenation of zero or more
4905 nars along with metadata for each store item it contains: its file name,
4906 references, corresponding derivation, and a digital signature.
4907
4908 When exporting, the daemon digitally signs the contents of the archive,
4909 and that digital signature is appended. When importing, the daemon
4910 verifies the signature and rejects the import in case of an invalid
4911 signature or if the signing key is not authorized.
4912 @c FIXME: Add xref to daemon doc about signatures.
4913
4914 The main options are:
4915
4916 @table @code
4917 @item --export
4918 Export the specified store files or packages (see below). Write the
4919 resulting archive to the standard output.
4920
4921 Dependencies are @emph{not} included in the output, unless
4922 @option{--recursive} is passed.
4923
4924 @item -r
4925 @itemx --recursive
4926 When combined with @option{--export}, this instructs @command{guix archive}
4927 to include dependencies of the given items in the archive. Thus, the
4928 resulting archive is self-contained: it contains the closure of the
4929 exported store items.
4930
4931 @item --import
4932 Read an archive from the standard input, and import the files listed
4933 therein into the store. Abort if the archive has an invalid digital
4934 signature, or if it is signed by a public key not among the authorized
4935 keys (see @option{--authorize} below).
4936
4937 @item --missing
4938 Read a list of store file names from the standard input, one per line,
4939 and write on the standard output the subset of these files missing from
4940 the store.
4941
4942 @item --generate-key[=@var{parameters}]
4943 @cindex signing, archives
4944 Generate a new key pair for the daemon. This is a prerequisite before
4945 archives can be exported with @option{--export}. This
4946 operation is usually instantaneous but it can take time if the system's
4947 entropy pool needs to be refilled. On Guix System,
4948 @code{guix-service-type} takes care of generating this key pair the
4949 first boot.
4950
4951 The generated key pair is typically stored under @file{/etc/guix}, in
4952 @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
4953 key, which must be kept secret). When @var{parameters} is omitted,
4954 an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
4955 versions before 1.6.0, it is a 4096-bit RSA key.
4956 Alternatively, @var{parameters} can specify
4957 @code{genkey} parameters suitable for Libgcrypt (@pxref{General
4958 public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
4959 Libgcrypt Reference Manual}).
4960
4961 @item --authorize
4962 @cindex authorizing, archives
4963 Authorize imports signed by the public key passed on standard input.
4964 The public key must be in ``s-expression advanced format''---i.e., the
4965 same format as the @file{signing-key.pub} file.
4966
4967 The list of authorized keys is kept in the human-editable file
4968 @file{/etc/guix/acl}. The file contains
4969 @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
4970 s-expressions''} and is structured as an access-control list in the
4971 @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
4972 (SPKI)}.
4973
4974 @item --extract=@var{directory}
4975 @itemx -x @var{directory}
4976 Read a single-item archive as served by substitute servers
4977 (@pxref{Substitutes}) and extract it to @var{directory}. This is a
4978 low-level operation needed in only very narrow use cases; see below.
4979
4980 For example, the following command extracts the substitute for Emacs
4981 served by @code{@value{SUBSTITUTE-SERVER-1}} to @file{/tmp/emacs}:
4982
4983 @example
4984 $ wget -O - \
4985 https://@value{SUBSTITUTE-SERVER-1}/nar/gzip/@dots{}-emacs-24.5 \
4986 | gunzip | guix archive -x /tmp/emacs
4987 @end example
4988
4989 Single-item archives are different from multiple-item archives produced
4990 by @command{guix archive --export}; they contain a single store item,
4991 and they do @emph{not} embed a signature. Thus this operation does
4992 @emph{no} signature verification and its output should be considered
4993 unsafe.
4994
4995 The primary purpose of this operation is to facilitate inspection of
4996 archive contents coming from possibly untrusted substitute servers
4997 (@pxref{Invoking guix challenge}).
4998
4999 @item --list
5000 @itemx -t
5001 Read a single-item archive as served by substitute servers
5002 (@pxref{Substitutes}) and print the list of files it contains, as in
5003 this example:
5004
5005 @example
5006 $ wget -O - \
5007 https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-emacs-26.3 \
5008 | lzip -d | guix archive -t
5009 @end example
5010
5011 @end table
5012
5013 @c *********************************************************************
5014 @node Channels
5015 @chapter Channels
5016
5017 @cindex channels
5018 @cindex @file{channels.scm}, configuration file
5019 @cindex configuration file for channels
5020 @cindex @command{guix pull}, configuration file
5021 @cindex configuration of @command{guix pull}
5022 Guix and its package collection are updated by running @command{guix pull}
5023 (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
5024 deploys Guix itself from the official GNU@tie{}Guix repository. This can be
5025 customized by defining @dfn{channels} in the
5026 @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
5027 of a Git repository to be deployed, and @command{guix pull} can be instructed
5028 to pull from one or more channels. In other words, channels can be used
5029 to @emph{customize} and to @emph{extend} Guix, as we will see below.
5030 Guix is able to take into account security concerns and deal with authenticated
5031 updates.
5032
5033 @menu
5034 * Specifying Additional Channels:: Extending the package collection.
5035 * Using a Custom Guix Channel:: Using a customized Guix.
5036 * Replicating Guix:: Running the @emph{exact same} Guix.
5037 * Channel Authentication:: How Guix verifies what it fetches.
5038 * Channels with Substitutes:: Using channels with available substitutes.
5039 * Creating a Channel:: How to write your custom channel.
5040 * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
5041 * Declaring Channel Dependencies:: How to depend on other channels.
5042 * Specifying Channel Authorizations:: Defining channel authors authorizations.
5043 * Primary URL:: Distinguishing mirror to original.
5044 * Writing Channel News:: Communicating information to channel's users.
5045 @end menu
5046
5047 @node Specifying Additional Channels
5048 @section Specifying Additional Channels
5049
5050 @cindex extending the package collection (channels)
5051 @cindex variant packages (channels)
5052 You can specify @emph{additional channels} to pull from. To use a channel, write
5053 @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
5054 @emph{in addition} to the default Guix channel(s):
5055
5056 @vindex %default-channels
5057 @lisp
5058 ;; Add variant packages to those Guix provides.
5059 (cons (channel
5060 (name 'variant-packages)
5061 (url "https://example.org/variant-packages.git"))
5062 %default-channels)
5063 @end lisp
5064
5065 @noindent
5066 Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
5067 add a channel the list of channels that the variable @code{%default-channels}
5068 is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
5069 Manual}). With this file in place, @command{guix pull} builds not only Guix
5070 but also the package modules from your own repository. The result in
5071 @file{~/.config/guix/current} is the union of Guix with your own package
5072 modules:
5073
5074 @example
5075 $ guix pull --list-generations
5076 @dots{}
5077 Generation 19 Aug 27 2018 16:20:48
5078 guix d894ab8
5079 repository URL: https://git.savannah.gnu.org/git/guix.git
5080 branch: master
5081 commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
5082 variant-packages dd3df5e
5083 repository URL: https://example.org/variant-packages.git
5084 branch: master
5085 commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
5086 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
5087 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
5088 @end example
5089
5090 @noindent
5091 The output of @command{guix pull} above shows that Generation@tie{}19 includes
5092 both Guix and packages from the @code{variant-personal-packages} channel. Among
5093 the new and upgraded packages that are listed, some like @code{variant-gimp} and
5094 @code{variant-emacs-with-cool-features} might come from
5095 @code{variant-packages}, while others come from the Guix default channel.
5096
5097 @node Using a Custom Guix Channel
5098 @section Using a Custom Guix Channel
5099
5100 The channel called @code{guix} specifies where Guix itself---its command-line
5101 tools as well as its package collection---should be downloaded. For instance,
5102 suppose you want to update from another copy of the Guix repository at
5103 @code{example.org}, and specifically the @code{super-hacks} branch, you can
5104 write in @code{~/.config/guix/channels.scm} this specification:
5105
5106 @lisp
5107 ;; Tell 'guix pull' to use another repo.
5108 (list (channel
5109 (name 'guix)
5110 (url "https://example.org/another-guix.git")
5111 (branch "super-hacks")))
5112 @end lisp
5113
5114 @noindent
5115 From there on, @command{guix pull} will fetch code from the @code{super-hacks}
5116 branch of the repository at @code{example.org}. The authentication concern is
5117 addressed below ((@pxref{Channel Authentication}).
5118
5119 @node Replicating Guix
5120 @section Replicating Guix
5121
5122 @cindex pinning, channels
5123 @cindex replicating Guix
5124 @cindex reproducibility, of Guix
5125 The @command{guix pull --list-generations} output above shows precisely which
5126 commits were used to build this instance of Guix. We can thus replicate it,
5127 say, on another machine, by providing a channel specification in
5128 @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
5129
5130 @lisp
5131 ;; Deploy specific commits of my channels of interest.
5132 (list (channel
5133 (name 'guix)
5134 (url "https://git.savannah.gnu.org/git/guix.git")
5135 (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
5136 (channel
5137 (name 'variant-packages)
5138 (url "https://example.org/variant-packages.git")
5139 (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
5140 @end lisp
5141
5142 The @command{guix describe --format=channels} command can even generate this
5143 list of channels directly (@pxref{Invoking guix describe}). The resulting
5144 file can be used with the -C options of @command{guix pull}
5145 (@pxref{Invoking guix pull}) or @command{guix time-machine}
5146 (@pxref{Invoking guix time-machine}).
5147
5148 At this point the two machines run the @emph{exact same Guix}, with access to
5149 the @emph{exact same packages}. The output of @command{guix build gimp} on
5150 one machine will be exactly the same, bit for bit, as the output of the same
5151 command on the other machine. It also means both machines have access to all
5152 the source code of Guix and, transitively, to all the source code of every
5153 package it defines.
5154
5155 This gives you super powers, allowing you to track the provenance of binary
5156 artifacts with very fine grain, and to reproduce software environments at
5157 will---some sort of ``meta reproducibility'' capabilities, if you will.
5158 @xref{Inferiors}, for another way to take advantage of these super powers.
5159
5160 @node Channel Authentication
5161 @section Channel Authentication
5162
5163 @anchor{channel-authentication}
5164 @cindex authentication, of channel code
5165 The @command{guix pull} and @command{guix time-machine} commands
5166 @dfn{authenticate} the code retrieved from channels: they make sure each
5167 commit that is fetched is signed by an authorized developer. The goal
5168 is to protect from unauthorized modifications to the channel that would
5169 lead users to run malicious code.
5170
5171 As a user, you must provide a @dfn{channel introduction} in your
5172 channels file so that Guix knows how to authenticate its first commit.
5173 A channel specification, including its introduction, looks something
5174 along these lines:
5175
5176 @lisp
5177 (channel
5178 (name 'some-channel)
5179 (url "https://example.org/some-channel.git")
5180 (introduction
5181 (make-channel-introduction
5182 "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
5183 (openpgp-fingerprint
5184 "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
5185 @end lisp
5186
5187 The specification above shows the name and URL of the channel. The call
5188 to @code{make-channel-introduction} above specifies that authentication
5189 of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
5190 by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
5191
5192 For the main channel, called @code{guix}, you automatically get that
5193 information from your Guix installation. For other channels, include
5194 the channel introduction provided by the channel authors in your
5195 @file{channels.scm} file. Make sure you retrieve the channel
5196 introduction from a trusted source since that is the root of your trust.
5197
5198 If you're curious about the authentication mechanics, read on!
5199
5200 @node Channels with Substitutes
5201 @section Channels with Substitutes
5202
5203 When running @command{guix pull}, Guix will first compile the
5204 definitions of every available package. This is an expensive operation
5205 for which substitutes (@pxref{Substitutes}) may be available. The
5206 following snippet in @file{channels.scm} will ensure that @command{guix
5207 pull} uses the latest commit with available substitutes for the package
5208 definitions: this is done by querying the continuous integration
5209 server at @url{https://ci.guix.gnu.org}.
5210
5211 @lisp
5212 (use-modules (guix ci))
5213
5214 (list (channel-with-substitutes-available
5215 %default-guix-channel
5216 "https://ci.guix.gnu.org"))
5217 @end lisp
5218
5219 Note that this does not mean that all the packages that you will
5220 install after running @command{guix pull} will have available
5221 substitutes. It only ensures that @command{guix pull} will not try to
5222 compile package definitions. This is particularly useful when using
5223 machines with limited resources.
5224
5225 @node Creating a Channel
5226 @section Creating a Channel
5227
5228 @cindex personal packages (channels)
5229 @cindex channels, for personal packages
5230 Let's say you have a bunch of custom package variants or personal packages
5231 that you think would make little sense to contribute to the Guix project, but
5232 would like to have these packages transparently available to you at the
5233 command line. You would first write modules containing those package
5234 definitions (@pxref{Package Modules}), maintain them in a Git repository, and
5235 then you and anyone else can use it as an additional channel to get packages
5236 from. Neat, no?
5237
5238 @c What follows stems from discussions at
5239 @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
5240 @c earlier discussions on guix-devel@gnu.org.
5241 @quotation Warning
5242 Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
5243 publish your personal channel to the world, we would like to share a few words
5244 of caution:
5245
5246 @itemize
5247 @item
5248 Before publishing a channel, please consider contributing your package
5249 definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
5250 to free software of all sorts, and packages in Guix proper are readily
5251 available to all Guix users and benefit from the project's quality assurance
5252 process.
5253
5254 @item
5255 When you maintain package definitions outside Guix, we, Guix developers,
5256 consider that @emph{the compatibility burden is on you}. Remember that
5257 package modules and package definitions are just Scheme code that uses various
5258 programming interfaces (APIs). We want to remain free to change these APIs to
5259 keep improving Guix, possibly in ways that break your channel. We never
5260 change APIs gratuitously, but we will @emph{not} commit to freezing APIs
5261 either.
5262
5263 @item
5264 Corollary: if you're using an external channel and that channel breaks, please
5265 @emph{report the issue to the channel authors}, not to the Guix project.
5266 @end itemize
5267
5268 You've been warned! Having said this, we believe external channels are a
5269 practical way to exert your freedom to augment Guix' package collection and to
5270 share your improvements, which are basic tenets of
5271 @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
5272 email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
5273 @end quotation
5274
5275 To create a channel, create a Git repository containing your own package
5276 modules and make it available. The repository can contain anything, but a
5277 useful channel will contain Guile modules that export packages. Once you
5278 start using a channel, Guix will behave as if the root directory of that
5279 channel's Git repository has been added to the Guile load path (@pxref{Load
5280 Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
5281 contains a file at @file{my-packages/my-tools.scm} that defines a Guile
5282 module, then the module will be available under the name @code{(my-packages
5283 my-tools)}, and you will be able to use it like any other module
5284 (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
5285
5286 As a channel author, consider bundling authentication material with your
5287 channel so that users can authenticate it. @xref{Channel
5288 Authentication}, and @ref{Specifying Channel Authorizations}, for info
5289 on how to do it.
5290
5291
5292 @node Package Modules in a Sub-directory
5293 @section Package Modules in a Sub-directory
5294
5295 @cindex subdirectory, channels
5296 As a channel author, you may want to keep your channel modules in a
5297 sub-directory. If your modules are in the sub-directory @file{guix}, you must
5298 add a meta-data file @file{.guix-channel} that contains:
5299
5300 @lisp
5301 (channel
5302 (version 0)
5303 (directory "guix"))
5304 @end lisp
5305
5306 @node Declaring Channel Dependencies
5307 @section Declaring Channel Dependencies
5308
5309 @cindex dependencies, channels
5310 @cindex meta-data, channels
5311 Channel authors may decide to augment a package collection provided by other
5312 channels. They can declare their channel to be dependent on other channels in
5313 a meta-data file @file{.guix-channel}, which is to be placed in the root of
5314 the channel repository.
5315
5316 The meta-data file should contain a simple S-expression like this:
5317
5318 @lisp
5319 (channel
5320 (version 0)
5321 (dependencies
5322 (channel
5323 (name some-collection)
5324 (url "https://example.org/first-collection.git")
5325
5326 ;; The 'introduction' bit below is optional: you would
5327 ;; provide it for dependencies that can be authenticated.
5328 (introduction
5329 (channel-introduction
5330 (version 0)
5331 (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
5332 (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
5333 (channel
5334 (name some-other-collection)
5335 (url "https://example.org/second-collection.git")
5336 (branch "testing"))))
5337 @end lisp
5338
5339 In the above example this channel is declared to depend on two other channels,
5340 which will both be fetched automatically. The modules provided by the channel
5341 will be compiled in an environment where the modules of all these declared
5342 channels are available.
5343
5344 For the sake of reliability and maintainability, you should avoid dependencies
5345 on channels that you don't control, and you should aim to keep the number of
5346 dependencies to a minimum.
5347
5348 @node Specifying Channel Authorizations
5349 @section Specifying Channel Authorizations
5350
5351 @cindex channel authorizations
5352 @anchor{channel-authorizations}
5353 As we saw above, Guix ensures the source code it pulls from channels
5354 comes from authorized developers. As a channel author, you need to
5355 specify the list of authorized developers in the
5356 @file{.guix-authorizations} file in the channel's Git repository. The
5357 authentication rule is simple: each commit must be signed by a key
5358 listed in the @file{.guix-authorizations} file of its parent
5359 commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
5360 (DAG). Each commit can have zero or more parents; ``regular'' commits
5361 have one parent and merge commits have two parent commits. Read
5362 @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
5363 for Computer Scientists}} for a great overview.} The
5364 @file{.guix-authorizations} file looks like this:
5365
5366 @lisp
5367 ;; Example '.guix-authorizations' file.
5368
5369 (authorizations
5370 (version 0) ;current file format version
5371
5372 (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
5373 (name "alice"))
5374 ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
5375 (name "bob"))
5376 ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
5377 (name "charlie"))))
5378 @end lisp
5379
5380 Each fingerprint is followed by optional key/value pairs, as in the
5381 example above. Currently these key/value pairs are ignored.
5382
5383 This authentication rule creates a chicken-and-egg issue: how do we
5384 authenticate the first commit? Related to that: how do we deal with
5385 channels whose repository history contains unsigned commits and lack
5386 @file{.guix-authorizations}? And how do we fork existing channels?
5387
5388 @cindex channel introduction
5389 Channel introductions answer these questions by describing the first
5390 commit of a channel that should be authenticated. The first time a
5391 channel is fetched with @command{guix pull} or @command{guix
5392 time-machine}, the command looks up the introductory commit and verifies
5393 that it is signed by the specified OpenPGP key. From then on, it
5394 authenticates commits according to the rule above.
5395
5396 Additionally, your channel must provide all the OpenPGP keys that were
5397 ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
5398 files, which can be either binary or ``ASCII-armored''. By default,
5399 those @file{.key} files are searched for in the branch named
5400 @code{keyring} but you can specify a different branch name in
5401 @code{.guix-channel} like so:
5402
5403 @lisp
5404 (channel
5405 (version 0)
5406 (keyring-reference "my-keyring-branch"))
5407 @end lisp
5408
5409 To summarize, as the author of a channel, there are three things you have
5410 to do to allow users to authenticate your code:
5411
5412 @enumerate
5413 @item
5414 Export the OpenPGP keys of past and present committers with @command{gpg
5415 --export} and store them in @file{.key} files, by default in a branch
5416 named @code{keyring} (we recommend making it an @dfn{orphan branch}).
5417
5418 @item
5419 Introduce an initial @file{.guix-authorizations} in the channel's
5420 repository. Do that in a signed commit (@pxref{Commit Access}, for
5421 information on how to sign Git commits.)
5422
5423 @item
5424 Advertise the channel introduction, for instance on your channel's web
5425 page. The channel introduction, as we saw above, is the commit/key
5426 pair---i.e., the commit that introduced @file{.guix-authorizations}, and
5427 the fingerprint of the OpenPGP used to sign it.
5428 @end enumerate
5429
5430 Before pushing to your public Git repository, you can run @command{guix
5431 git-authenticate} to verify that you did sign all the commits you are
5432 about to push with an authorized key:
5433
5434 @example
5435 guix git authenticate @var{commit} @var{signer}
5436 @end example
5437
5438 @noindent
5439 where @var{commit} and @var{signer} are your channel introduction.
5440 @xref{Invoking guix git authenticate}, for details.
5441
5442 Publishing a signed channel requires discipline: any mistake, such as an
5443 unsigned commit or a commit signed by an unauthorized key, will prevent
5444 users from pulling from your channel---well, that's the whole point of
5445 authentication! Pay attention to merges in particular: merge commits
5446 are considered authentic if and only if they are signed by a key present
5447 in the @file{.guix-authorizations} file of @emph{both} branches.
5448
5449 @node Primary URL
5450 @section Primary URL
5451
5452 @cindex primary URL, channels
5453 Channel authors can indicate the primary URL of their channel's Git
5454 repository in the @file{.guix-channel} file, like so:
5455
5456 @lisp
5457 (channel
5458 (version 0)
5459 (url "https://example.org/guix.git"))
5460 @end lisp
5461
5462 This allows @command{guix pull} to determine whether it is pulling code
5463 from a mirror of the channel; when that is the case, it warns the user
5464 that the mirror might be stale and displays the primary URL@. That way,
5465 users cannot be tricked into fetching code from a stale mirror that does
5466 not receive security updates.
5467
5468 This feature only makes sense for authenticated repositories, such as
5469 the official @code{guix} channel, for which @command{guix pull} ensures
5470 the code it fetches is authentic.
5471
5472 @node Writing Channel News
5473 @section Writing Channel News
5474
5475 @cindex news, for channels
5476 Channel authors may occasionally want to communicate to their users
5477 information about important changes in the channel. You'd send them all
5478 an email, but that's not convenient.
5479
5480 Instead, channels can provide a @dfn{news file}; when the channel users
5481 run @command{guix pull}, that news file is automatically read and
5482 @command{guix pull --news} can display the announcements that correspond
5483 to the new commits that have been pulled, if any.
5484
5485 To do that, channel authors must first declare the name of the news file
5486 in their @file{.guix-channel} file:
5487
5488 @lisp
5489 (channel
5490 (version 0)
5491 (news-file "etc/news.txt"))
5492 @end lisp
5493
5494 The news file itself, @file{etc/news.txt} in this example, must look
5495 something like this:
5496
5497 @lisp
5498 (channel-news
5499 (version 0)
5500 (entry (tag "the-bug-fix")
5501 (title (en "Fixed terrible bug")
5502 (fr "Oh la la"))
5503 (body (en "@@emph@{Good news@}! It's fixed!")
5504 (eo "Certe ĝi pli bone funkcias nun!")))
5505 (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
5506 (title (en "Added a great package")
5507 (ca "Què vol dir guix?"))
5508 (body (en "Don't miss the @@code@{hello@} package!"))))
5509 @end lisp
5510
5511 While the news file is using the Scheme syntax, avoid naming it with a
5512 @file{.scm} extension or else it will get picked up when building the
5513 channel and yield an error since it is not a valid module.
5514 Alternatively, you can move the channel module to a subdirectory and
5515 store the news file in another directory.
5516
5517 The file consists of a list of @dfn{news entries}. Each entry is
5518 associated with a commit or tag: it describes changes made in this
5519 commit, possibly in preceding commits as well. Users see entries only
5520 the first time they obtain the commit the entry refers to.
5521
5522 The @code{title} field should be a one-line summary while @code{body}
5523 can be arbitrarily long, and both can contain Texinfo markup
5524 (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
5525 a list of language tag/message tuples, which allows @command{guix pull}
5526 to display news in the language that corresponds to the user's locale.
5527
5528 If you want to translate news using a gettext-based workflow, you can
5529 extract translatable strings with @command{xgettext} (@pxref{xgettext
5530 Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
5531 you write news entries in English first, the command below creates a PO
5532 file containing the strings to translate:
5533
5534 @example
5535 xgettext -o news.po -l scheme -ken etc/news.txt
5536 @end example
5537
5538 To sum up, yes, you could use your channel as a blog. But beware, this
5539 is @emph{not quite} what your users might expect.
5540
5541 @c *********************************************************************
5542 @node Development
5543 @chapter Development
5544
5545 @cindex software development
5546 If you are a software developer, Guix provides tools that you should find
5547 helpful---independently of the language you're developing in. This is what
5548 this chapter is about.
5549
5550 The @command{guix environment} command provides a convenient way to set up
5551 @dfn{development environments} containing all the dependencies and tools
5552 necessary to work on the software package of your choice. The @command{guix
5553 pack} command allows you to create @dfn{application bundles} that can be
5554 easily distributed to users who do not run Guix.
5555
5556 @menu
5557 * Invoking guix environment:: Setting up development environments.
5558 * Invoking guix pack:: Creating software bundles.
5559 * The GCC toolchain:: Working with languages supported by GCC.
5560 * Invoking guix git authenticate:: Authenticating Git repositories.
5561 @end menu
5562
5563 @node Invoking guix environment
5564 @section Invoking @command{guix environment}
5565
5566 @cindex reproducible build environments
5567 @cindex development environments
5568 @cindex @command{guix environment}
5569 @cindex environment, package build environment
5570 The purpose of @command{guix environment} is to assist hackers in
5571 creating reproducible development environments without polluting their
5572 package profile. The @command{guix environment} tool takes one or more
5573 packages, builds all of their inputs, and creates a shell
5574 environment to use them.
5575
5576 The general syntax is:
5577
5578 @example
5579 guix environment @var{options} @var{package}@dots{}
5580 @end example
5581
5582 The following example spawns a new shell set up for the development of
5583 GNU@tie{}Guile:
5584
5585 @example
5586 guix environment guile
5587 @end example
5588
5589 If the needed dependencies are not built yet, @command{guix environment}
5590 automatically builds them. The environment of the new shell is an
5591 augmented version of the environment that @command{guix environment} was
5592 run in. It contains the necessary search paths for building the given
5593 package added to the existing environment variables. To create
5594 a ``pure'' environment, in which the original environment variables have
5595 been unset, use the @option{--pure} option@footnote{Users sometimes
5596 wrongfully augment environment variables such as @env{PATH} in their
5597 @file{~/.bashrc} file. As a consequence, when @command{guix
5598 environment} launches it, Bash may read @file{~/.bashrc}, thereby
5599 introducing ``impurities'' in these environment variables. It is an
5600 error to define such environment variables in @file{.bashrc}; instead,
5601 they should be defined in @file{.bash_profile}, which is sourced only by
5602 log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
5603 Manual}, for details on Bash start-up files.}.
5604
5605 Exiting from a Guix environment is the same as exiting from the shell,
5606 and will place the user back in the old environment before @command{guix
5607 environment} was invoked. The next garbage collection (@pxref{Invoking
5608 guix gc}) will clean up packages that were installed from within the
5609 environment and are no longer used outside of it.
5610
5611 @vindex GUIX_ENVIRONMENT
5612 @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
5613 variable in the shell it spawns; its value is the file name of the
5614 profile of this environment. This allows users to, say, define a
5615 specific prompt for development environments in their @file{.bashrc}
5616 (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
5617
5618 @example
5619 if [ -n "$GUIX_ENVIRONMENT" ]
5620 then
5621 export PS1="\u@@\h \w [dev]\$ "
5622 fi
5623 @end example
5624
5625 @noindent
5626 ...@: or to browse the profile:
5627
5628 @example
5629 $ ls "$GUIX_ENVIRONMENT/bin"
5630 @end example
5631
5632 Additionally, more than one package may be specified, in which case the
5633 union of the inputs for the given packages are used. For example, the
5634 command below spawns a shell where all of the dependencies of both Guile
5635 and Emacs are available:
5636
5637 @example
5638 guix environment guile emacs
5639 @end example
5640
5641 Sometimes an interactive shell session is not desired. An arbitrary
5642 command may be invoked by placing the @code{--} token to separate the
5643 command from the rest of the arguments:
5644
5645 @example
5646 guix environment guile -- make -j4
5647 @end example
5648
5649 In other situations, it is more convenient to specify the list of
5650 packages needed in the environment. For example, the following command
5651 runs @command{python} from an environment containing Python@tie{}2.7 and
5652 NumPy:
5653
5654 @example
5655 guix environment --ad-hoc python2-numpy python-2.7 -- python
5656 @end example
5657
5658 Furthermore, one might want the dependencies of a package and also some
5659 additional packages that are not build-time or runtime dependencies, but
5660 are useful when developing nonetheless. Because of this, the
5661 @option{--ad-hoc} flag is positional. Packages appearing before
5662 @option{--ad-hoc} are interpreted as packages whose dependencies will be
5663 added to the environment. Packages appearing after are interpreted as
5664 packages that will be added to the environment directly. For example,
5665 the following command creates a Guix development environment that
5666 additionally includes Git and strace:
5667
5668 @example
5669 guix environment --pure guix --ad-hoc git strace
5670 @end example
5671
5672 @cindex container
5673 Sometimes it is desirable to isolate the environment as much as
5674 possible, for maximal purity and reproducibility. In particular, when
5675 using Guix on a host distro that is not Guix System, it is desirable to
5676 prevent access to @file{/usr/bin} and other system-wide resources from
5677 the development environment. For example, the following command spawns
5678 a Guile REPL in a ``container'' where only the store and the current
5679 working directory are mounted:
5680
5681 @example
5682 guix environment --ad-hoc --container guile -- guile
5683 @end example
5684
5685 @quotation Note
5686 The @option{--container} option requires Linux-libre 3.19 or newer.
5687 @end quotation
5688
5689 @cindex certificates
5690 Another typical use case for containers is to run security-sensitive
5691 applications such as a web browser. To run Eolie, we must expose and
5692 share some files and directories; we include @code{nss-certs} and expose
5693 @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
5694 @env{DISPLAY} environment variable since containerized graphical
5695 applications won't display without it.
5696
5697 @example
5698 guix environment --preserve='^DISPLAY$' --container --network \
5699 --expose=/etc/machine-id \
5700 --expose=/etc/ssl/certs/ \
5701 --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
5702 --ad-hoc eolie nss-certs dbus -- eolie
5703 @end example
5704
5705 The available options are summarized below.
5706
5707 @table @code
5708 @item --root=@var{file}
5709 @itemx -r @var{file}
5710 @cindex persistent environment
5711 @cindex garbage collector root, for environments
5712 Make @var{file} a symlink to the profile for this environment, and
5713 register it as a garbage collector root.
5714
5715 This is useful if you want to protect your environment from garbage
5716 collection, to make it ``persistent''.
5717
5718 When this option is omitted, the environment is protected from garbage
5719 collection only for the duration of the @command{guix environment}
5720 session. This means that next time you recreate the same environment,
5721 you could have to rebuild or re-download packages. @xref{Invoking guix
5722 gc}, for more on GC roots.
5723
5724 @item --expression=@var{expr}
5725 @itemx -e @var{expr}
5726 Create an environment for the package or list of packages that
5727 @var{expr} evaluates to.
5728
5729 For example, running:
5730
5731 @example
5732 guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
5733 @end example
5734
5735 starts a shell with the environment for this specific variant of the
5736 PETSc package.
5737
5738 Running:
5739
5740 @example
5741 guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
5742 @end example
5743
5744 starts a shell with all the base system packages available.
5745
5746 The above commands only use the default output of the given packages.
5747 To select other outputs, two element tuples can be specified:
5748
5749 @example
5750 guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
5751 @end example
5752
5753 @item --load=@var{file}
5754 @itemx -l @var{file}
5755 Create an environment for the package or list of packages that the code
5756 within @var{file} evaluates to.
5757
5758 As an example, @var{file} might contain a definition like this
5759 (@pxref{Defining Packages}):
5760
5761 @lisp
5762 @verbatiminclude environment-gdb.scm
5763 @end lisp
5764
5765 @item --manifest=@var{file}
5766 @itemx -m @var{file}
5767 Create an environment for the packages contained in the manifest object
5768 returned by the Scheme code in @var{file}. This option can be repeated
5769 several times, in which case the manifests are concatenated.
5770
5771 This is similar to the same-named option in @command{guix package}
5772 (@pxref{profile-manifest, @option{--manifest}}) and uses the same
5773 manifest files.
5774
5775 @item --ad-hoc
5776 Include all specified packages in the resulting environment, as if an
5777 @i{ad hoc} package were defined with them as inputs. This option is
5778 useful for quickly creating an environment without having to write a
5779 package expression to contain the desired inputs.
5780
5781 For instance, the command:
5782
5783 @example
5784 guix environment --ad-hoc guile guile-sdl -- guile
5785 @end example
5786
5787 runs @command{guile} in an environment where Guile and Guile-SDL are
5788 available.
5789
5790 Note that this example implicitly asks for the default output of
5791 @code{guile} and @code{guile-sdl}, but it is possible to ask for a
5792 specific output---e.g., @code{glib:bin} asks for the @code{bin} output
5793 of @code{glib} (@pxref{Packages with Multiple Outputs}).
5794
5795 This option may be composed with the default behavior of @command{guix
5796 environment}. Packages appearing before @option{--ad-hoc} are
5797 interpreted as packages whose dependencies will be added to the
5798 environment, the default behavior. Packages appearing after are
5799 interpreted as packages that will be added to the environment directly.
5800
5801 @item --pure
5802 Unset existing environment variables when building the new environment, except
5803 those specified with @option{--preserve} (see below). This has the effect of
5804 creating an environment in which search paths only contain package inputs.
5805
5806 @item --preserve=@var{regexp}
5807 @itemx -E @var{regexp}
5808 When used alongside @option{--pure}, preserve the environment variables
5809 matching @var{regexp}---in other words, put them on a ``white list'' of
5810 environment variables that must be preserved. This option can be repeated
5811 several times.
5812
5813 @example
5814 guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
5815 -- mpirun @dots{}
5816 @end example
5817
5818 This example runs @command{mpirun} in a context where the only environment
5819 variables defined are @env{PATH}, environment variables whose name starts
5820 with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
5821 @env{USER}, etc.).
5822
5823 @item --search-paths
5824 Display the environment variable definitions that make up the
5825 environment.
5826
5827 @item --system=@var{system}
5828 @itemx -s @var{system}
5829 Attempt to build for @var{system}---e.g., @code{i686-linux}.
5830
5831 @item --container
5832 @itemx -C
5833 @cindex container
5834 Run @var{command} within an isolated container. The current working
5835 directory outside the container is mapped inside the container.
5836 Additionally, unless overridden with @option{--user}, a dummy home
5837 directory is created that matches the current user's home directory, and
5838 @file{/etc/passwd} is configured accordingly.
5839
5840 The spawned process runs as the current user outside the container. Inside
5841 the container, it has the same UID and GID as the current user, unless
5842 @option{--user} is passed (see below).
5843
5844 @item --network
5845 @itemx -N
5846 For containers, share the network namespace with the host system.
5847 Containers created without this flag only have access to the loopback
5848 device.
5849
5850 @item --link-profile
5851 @itemx -P
5852 For containers, link the environment profile to @file{~/.guix-profile}
5853 within the container and set @code{GUIX_ENVIRONMENT} to that.
5854 This is equivalent to making @file{~/.guix-profile} a symlink to the
5855 actual profile within the container.
5856 Linking will fail and abort the environment if the directory already
5857 exists, which will certainly be the case if @command{guix environment}
5858 was invoked in the user's home directory.
5859
5860 Certain packages are configured to look in @file{~/.guix-profile} for
5861 configuration files and data;@footnote{For example, the
5862 @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
5863 for additional fonts.} @option{--link-profile} allows these programs to
5864 behave as expected within the environment.
5865
5866 @item --user=@var{user}
5867 @itemx -u @var{user}
5868 For containers, use the username @var{user} in place of the current
5869 user. The generated @file{/etc/passwd} entry within the container will
5870 contain the name @var{user}, the home directory will be
5871 @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
5872 the UID and GID inside the container are 1000. @var{user}
5873 need not exist on the system.
5874
5875 Additionally, any shared or exposed path (see @option{--share} and
5876 @option{--expose} respectively) whose target is within the current user's
5877 home directory will be remapped relative to @file{/home/USER}; this
5878 includes the automatic mapping of the current working directory.
5879
5880 @example
5881 # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
5882 cd $HOME/wd
5883 guix environment --container --user=foo \
5884 --expose=$HOME/test \
5885 --expose=/tmp/target=$HOME/target
5886 @end example
5887
5888 While this will limit the leaking of user identity through home paths
5889 and each of the user fields, this is only one useful component of a
5890 broader privacy/anonymity solution---not one in and of itself.
5891
5892 @item --no-cwd
5893 For containers, the default behavior is to share the current working
5894 directory with the isolated container and immediately change to that
5895 directory within the container. If this is undesirable,
5896 @option{--no-cwd} will cause the current working directory to @emph{not}
5897 be automatically shared and will change to the user's home directory
5898 within the container instead. See also @option{--user}.
5899
5900 @item --expose=@var{source}[=@var{target}]
5901 @itemx --share=@var{source}[=@var{target}]
5902 For containers, @option{--expose} (resp. @option{--share}) exposes the
5903 file system @var{source} from the host system as the read-only
5904 (resp. writable) file system @var{target} within the container. If
5905 @var{target} is not specified, @var{source} is used as the target mount
5906 point in the container.
5907
5908 The example below spawns a Guile REPL in a container in which the user's
5909 home directory is accessible read-only via the @file{/exchange}
5910 directory:
5911
5912 @example
5913 guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
5914 @end example
5915
5916 @end table
5917
5918 @command{guix environment}
5919 also supports all of the common build options that @command{guix
5920 build} supports (@pxref{Common Build Options}) as well as package
5921 transformation options (@pxref{Package Transformation Options}).
5922
5923 @node Invoking guix pack
5924 @section Invoking @command{guix pack}
5925
5926 Occasionally you want to pass software to people who are not (yet!)
5927 lucky enough to be using Guix. You'd tell them to run @command{guix
5928 package -i @var{something}}, but that's not possible in this case. This
5929 is where @command{guix pack} comes in.
5930
5931 @quotation Note
5932 If you are looking for ways to exchange binaries among machines that
5933 already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
5934 publish}, and @ref{Invoking guix archive}.
5935 @end quotation
5936
5937 @cindex pack
5938 @cindex bundle
5939 @cindex application bundle
5940 @cindex software bundle
5941 The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
5942 @dfn{software bundle}: it creates a tarball or some other archive
5943 containing the binaries of the software you're interested in, and all
5944 its dependencies. The resulting archive can be used on any machine that
5945 does not have Guix, and people can run the exact same binaries as those
5946 you have with Guix. The pack itself is created in a bit-reproducible
5947 fashion, so anyone can verify that it really contains the build results
5948 that you pretend to be shipping.
5949
5950 For example, to create a bundle containing Guile, Emacs, Geiser, and all
5951 their dependencies, you can run:
5952
5953 @example
5954 $ guix pack guile emacs emacs-geiser
5955 @dots{}
5956 /gnu/store/@dots{}-pack.tar.gz
5957 @end example
5958
5959 The result here is a tarball containing a @file{/gnu/store} directory
5960 with all the relevant packages. The resulting tarball contains a
5961 @dfn{profile} with the three packages of interest; the profile is the
5962 same as would be created by @command{guix package -i}. It is this
5963 mechanism that is used to create Guix's own standalone binary tarball
5964 (@pxref{Binary Installation}).
5965
5966 Users of this pack would have to run
5967 @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
5968 find inconvenient. To work around it, you can create, say, a
5969 @file{/opt/gnu/bin} symlink to the profile:
5970
5971 @example
5972 guix pack -S /opt/gnu/bin=bin guile emacs emacs-geiser
5973 @end example
5974
5975 @noindent
5976 That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
5977
5978 @cindex relocatable binaries, with @command{guix pack}
5979 What if the recipient of your pack does not have root privileges on
5980 their machine, and thus cannot unpack it in the root file system? In
5981 that case, you will want to use the @option{--relocatable} option (see
5982 below). This option produces @dfn{relocatable binaries}, meaning they
5983 they can be placed anywhere in the file system hierarchy: in the example
5984 above, users can unpack your tarball in their home directory and
5985 directly run @file{./opt/gnu/bin/guile}.
5986
5987 @cindex Docker, build an image with guix pack
5988 Alternatively, you can produce a pack in the Docker image format using
5989 the following command:
5990
5991 @example
5992 guix pack -f docker -S /bin=bin guile guile-readline
5993 @end example
5994
5995 @noindent
5996 The result is a tarball that can be passed to the @command{docker load}
5997 command, followed by @code{docker run}:
5998
5999 @example
6000 docker load < @var{file}
6001 docker run -ti guile-guile-readline /bin/guile
6002 @end example
6003
6004 @noindent
6005 where @var{file} is the image returned by @var{guix pack}, and
6006 @code{guile-guile-readline} is its ``image tag''. See the
6007 @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
6008 documentation} for more information.
6009
6010 @cindex Singularity, build an image with guix pack
6011 @cindex SquashFS, build an image with guix pack
6012 Yet another option is to produce a SquashFS image with the following
6013 command:
6014
6015 @example
6016 guix pack -f squashfs bash guile emacs emacs-geiser
6017 @end example
6018
6019 @noindent
6020 The result is a SquashFS file system image that can either be mounted or
6021 directly be used as a file system container image with the
6022 @uref{https://www.sylabs.io/docs/, Singularity container execution
6023 environment}, using commands like @command{singularity shell} or
6024 @command{singularity exec}.
6025
6026 Several command-line options allow you to customize your pack:
6027
6028 @table @code
6029 @item --format=@var{format}
6030 @itemx -f @var{format}
6031 Produce a pack in the given @var{format}.
6032
6033 The available formats are:
6034
6035 @table @code
6036 @item tarball
6037 This is the default format. It produces a tarball containing all the
6038 specified binaries and symlinks.
6039
6040 @item docker
6041 This produces a tarball that follows the
6042 @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
6043 Docker Image Specification}. The ``repository name'' as it appears in
6044 the output of the @command{docker images} command is computed from
6045 package names passed on the command line or in the manifest file.
6046
6047 @item squashfs
6048 This produces a SquashFS image containing all the specified binaries and
6049 symlinks, as well as empty mount points for virtual file systems like
6050 procfs.
6051
6052 @quotation Note
6053 Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
6054 For that reason, @command{guix pack -f squashfs} always implies @code{-S
6055 /bin=bin}. Thus, your @command{guix pack} invocation must always start
6056 with something like:
6057
6058 @example
6059 guix pack -f squashfs bash @dots{}
6060 @end example
6061
6062 If you forget the @code{bash} (or similar) package, @command{singularity
6063 run} and @command{singularity exec} will fail with an unhelpful ``no
6064 such file or directory'' message.
6065 @end quotation
6066
6067 @item deb
6068 This produces a Debian archive (a package with the @samp{.deb} file
6069 extension) containing all the specified binaries and symbolic links,
6070 that can be installed on top of any dpkg-based GNU(/Linux) distribution.
6071 Advanced options can be revealed via the @option{--help-deb-format}
6072 option. They allow embedding control files for more fine-grained
6073 control, such as activating specific triggers or providing a maintainer
6074 configure script to run arbitrary setup code upon installation.
6075
6076 @example
6077 guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello
6078 @end example
6079
6080 @quotation Note
6081 Because archives produced with @command{guix pack} contain a collection
6082 of store items and because each @command{dpkg} package must not have
6083 conflicting files, in practice that means you likely won't be able to
6084 install more than one such archive on a given system.
6085 @end quotation
6086
6087 @quotation Warning
6088 @command{dpkg} will assume ownership of any files contained in the pack
6089 that it does @emph{not} know about. It is unwise to install
6090 Guix-produced @samp{.deb} files on a system where @file{/gnu/store} is
6091 shared by other software, such as a Guix installation or other, non-deb
6092 packs.
6093 @end quotation
6094
6095 @end table
6096
6097 @cindex relocatable binaries
6098 @item --relocatable
6099 @itemx -R
6100 Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
6101 anywhere in the file system hierarchy and run from there.
6102
6103 When this option is passed once, the resulting binaries require support for
6104 @dfn{user namespaces} in the kernel Linux; when passed
6105 @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
6106 PRoot support, can be thought of as the abbreviation of ``Really
6107 Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
6108 other techniques if user namespaces are unavailable, and essentially
6109 work anywhere---see below for the implications.
6110
6111 For example, if you create a pack containing Bash with:
6112
6113 @example
6114 guix pack -RR -S /mybin=bin bash
6115 @end example
6116
6117 @noindent
6118 ...@: you can copy that pack to a machine that lacks Guix, and from your
6119 home directory as a normal user, run:
6120
6121 @example
6122 tar xf pack.tar.gz
6123 ./mybin/sh
6124 @end example
6125
6126 @noindent
6127 In that shell, if you type @code{ls /gnu/store}, you'll notice that
6128 @file{/gnu/store} shows up and contains all the dependencies of
6129 @code{bash}, even though the machine actually lacks @file{/gnu/store}
6130 altogether! That is probably the simplest way to deploy Guix-built
6131 software on a non-Guix machine.
6132
6133 @quotation Note
6134 By default, relocatable binaries rely on the @dfn{user namespace} feature of
6135 the kernel Linux, which allows unprivileged users to mount or change root.
6136 Old versions of Linux did not support it, and some GNU/Linux distributions
6137 turn it off.
6138
6139 To produce relocatable binaries that work even in the absence of user
6140 namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
6141 case, binaries will try user namespace support and fall back to another
6142 @dfn{execution engine} if user namespaces are not supported. The
6143 following execution engines are supported:
6144
6145 @table @code
6146 @item default
6147 Try user namespaces and fall back to PRoot if user namespaces are not
6148 supported (see below).
6149
6150 @item performance
6151 Try user namespaces and fall back to Fakechroot if user namespaces are
6152 not supported (see below).
6153
6154 @item userns
6155 Run the program through user namespaces and abort if they are not
6156 supported.
6157
6158 @item proot
6159 Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
6160 provides the necessary
6161 support for file system virtualization. It achieves that by using the
6162 @code{ptrace} system call on the running program. This approach has the
6163 advantage to work without requiring special kernel support, but it incurs
6164 run-time overhead every time a system call is made.
6165
6166 @item fakechroot
6167 Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
6168 Fakechroot} virtualizes file system accesses by intercepting calls to C
6169 library functions such as @code{open}, @code{stat}, @code{exec}, and so
6170 on. Unlike PRoot, it incurs very little overhead. However, it does not
6171 always work: for example, some file system accesses made from within the
6172 C library are not intercepted, and file system accesses made @i{via}
6173 direct syscalls are not intercepted either, leading to erratic behavior.
6174 @end table
6175
6176 @vindex GUIX_EXECUTION_ENGINE
6177 When running a wrapped program, you can explicitly request one of the
6178 execution engines listed above by setting the
6179 @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
6180 @end quotation
6181
6182 @cindex entry point, for Docker images
6183 @item --entry-point=@var{command}
6184 Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
6185 format supports it---currently @code{docker} and @code{squashfs} (Singularity)
6186 support it. @var{command} must be relative to the profile contained in the
6187 pack.
6188
6189 The entry point specifies the command that tools like @code{docker run} or
6190 @code{singularity run} automatically start by default. For example, you can
6191 do:
6192
6193 @example
6194 guix pack -f docker --entry-point=bin/guile guile
6195 @end example
6196
6197 The resulting pack can easily be loaded and @code{docker run} with no extra
6198 arguments will spawn @code{bin/guile}:
6199
6200 @example
6201 docker load -i pack.tar.gz
6202 docker run @var{image-id}
6203 @end example
6204
6205 @item --expression=@var{expr}
6206 @itemx -e @var{expr}
6207 Consider the package @var{expr} evaluates to.
6208
6209 This has the same purpose as the same-named option in @command{guix
6210 build} (@pxref{Additional Build Options, @option{--expression} in
6211 @command{guix build}}).
6212
6213 @item --manifest=@var{file}
6214 @itemx -m @var{file}
6215 Use the packages contained in the manifest object returned by the Scheme
6216 code in @var{file}. This option can be repeated several times, in which
6217 case the manifests are concatenated.
6218
6219 This has a similar purpose as the same-named option in @command{guix
6220 package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
6221 same manifest files. It allows you to define a collection of packages
6222 once and use it both for creating profiles and for creating archives
6223 for use on machines that do not have Guix installed. Note that you can
6224 specify @emph{either} a manifest file @emph{or} a list of packages,
6225 but not both.
6226
6227 @item --system=@var{system}
6228 @itemx -s @var{system}
6229 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
6230 the system type of the build host.
6231
6232 @item --target=@var{triplet}
6233 @cindex cross-compilation
6234 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
6235 as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
6236 configuration triplets,, autoconf, Autoconf}).
6237
6238 @item --compression=@var{tool}
6239 @itemx -C @var{tool}
6240 Compress the resulting tarball using @var{tool}---one of @code{gzip},
6241 @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
6242 compression.
6243
6244 @item --symlink=@var{spec}
6245 @itemx -S @var{spec}
6246 Add the symlinks specified by @var{spec} to the pack. This option can
6247 appear several times.
6248
6249 @var{spec} has the form @code{@var{source}=@var{target}}, where
6250 @var{source} is the symlink that will be created and @var{target} is the
6251 symlink target.
6252
6253 For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
6254 symlink pointing to the @file{bin} sub-directory of the profile.
6255
6256 @item --save-provenance
6257 Save provenance information for the packages passed on the command line.
6258 Provenance information includes the URL and commit of the channels in use
6259 (@pxref{Channels}).
6260
6261 Provenance information is saved in the
6262 @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
6263 usual package metadata---the name and version of each package, their
6264 propagated inputs, and so on. It is useful information to the recipient of
6265 the pack, who then knows how the pack was (supposedly) obtained.
6266
6267 This option is not enabled by default because, like timestamps, provenance
6268 information contributes nothing to the build process. In other words, there
6269 is an infinity of channel URLs and commit IDs that can lead to the same pack.
6270 Recording such ``silent'' metadata in the output thus potentially breaks the
6271 source-to-binary bitwise reproducibility property.
6272
6273 @item --root=@var{file}
6274 @itemx -r @var{file}
6275 @cindex garbage collector root, for packs
6276 Make @var{file} a symlink to the resulting pack, and register it as a garbage
6277 collector root.
6278
6279 @item --localstatedir
6280 @itemx --profile-name=@var{name}
6281 Include the ``local state directory'', @file{/var/guix}, in the resulting
6282 pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
6283 profile---by default @var{name} is @code{guix-profile}, which corresponds to
6284 @file{~root/.guix-profile}.
6285
6286 @file{/var/guix} contains the store database (@pxref{The Store}) as well
6287 as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
6288 the pack means that the store is ``complete'' and manageable by Guix;
6289 not providing it pack means that the store is ``dead'': items cannot be
6290 added to it or removed from it after extraction of the pack.
6291
6292 One use case for this is the Guix self-contained binary tarball
6293 (@pxref{Binary Installation}).
6294
6295 @item --derivation
6296 @itemx -d
6297 Print the name of the derivation that builds the pack.
6298
6299 @item --bootstrap
6300 Use the bootstrap binaries to build the pack. This option is only
6301 useful to Guix developers.
6302 @end table
6303
6304 In addition, @command{guix pack} supports all the common build options
6305 (@pxref{Common Build Options}) and all the package transformation
6306 options (@pxref{Package Transformation Options}).
6307
6308
6309 @node The GCC toolchain
6310 @section The GCC toolchain
6311
6312 @cindex GCC
6313 @cindex ld-wrapper
6314 @cindex linker wrapper
6315 @cindex toolchain, for C development
6316 @cindex toolchain, for Fortran development
6317
6318 If you need a complete toolchain for compiling and linking C or C++
6319 source code, use the @code{gcc-toolchain} package. This package
6320 provides a complete GCC toolchain for C/C++ development, including GCC
6321 itself, the GNU C Library (headers and binaries, plus debugging symbols
6322 in the @code{debug} output), Binutils, and a linker wrapper.
6323
6324 The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
6325 passed to the linker, add corresponding @code{-rpath} arguments, and
6326 invoke the actual linker with this new set of arguments. You can instruct the
6327 wrapper to refuse to link against libraries not in the store by setting the
6328 @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
6329
6330 The package @code{gfortran-toolchain} provides a complete GCC toolchain
6331 for Fortran development. For other languages, please use
6332 @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
6333
6334
6335 @node Invoking guix git authenticate
6336 @section Invoking @command{guix git authenticate}
6337
6338 The @command{guix git authenticate} command authenticates a Git checkout
6339 following the same rule as for channels (@pxref{channel-authentication,
6340 channel authentication}). That is, starting from a given commit, it
6341 ensures that all subsequent commits are signed by an OpenPGP key whose
6342 fingerprint appears in the @file{.guix-authorizations} file of its
6343 parent commit(s).
6344
6345 You will find this command useful if you maintain a channel. But in
6346 fact, this authentication mechanism is useful in a broader context, so
6347 you might want to use it for Git repositories that have nothing to do
6348 with Guix.
6349
6350 The general syntax is:
6351
6352 @example
6353 guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
6354 @end example
6355
6356 By default, this command authenticates the Git checkout in the current
6357 directory; it outputs nothing and exits with exit code zero on success
6358 and non-zero on failure. @var{commit} above denotes the first commit
6359 where authentication takes place, and @var{signer} is the OpenPGP
6360 fingerprint of public key used to sign @var{commit}. Together, they
6361 form a ``channel introduction'' (@pxref{channel-authentication, channel
6362 introduction}). The options below allow you to fine-tune the process.
6363
6364 @table @code
6365 @item --repository=@var{directory}
6366 @itemx -r @var{directory}
6367 Open the Git repository in @var{directory} instead of the current
6368 directory.
6369
6370 @item --keyring=@var{reference}
6371 @itemx -k @var{reference}
6372 Load OpenPGP keyring from @var{reference}, the reference of a branch
6373 such as @code{origin/keyring} or @code{my-keyring}. The branch must
6374 contain OpenPGP public keys in @file{.key} files, either in binary form
6375 or ``ASCII-armored''. By default the keyring is loaded from the branch
6376 named @code{keyring}.
6377
6378 @item --stats
6379 Display commit signing statistics upon completion.
6380
6381 @item --cache-key=@var{key}
6382 Previously-authenticated commits are cached in a file under
6383 @file{~/.cache/guix/authentication}. This option forces the cache to be
6384 stored in file @var{key} in that directory.
6385
6386 @item --historical-authorizations=@var{file}
6387 By default, any commit whose parent commit(s) lack the
6388 @file{.guix-authorizations} file is considered inauthentic. In
6389 contrast, this option considers the authorizations in @var{file} for any
6390 commit that lacks @file{.guix-authorizations}. The format of @var{file}
6391 is the same as that of @file{.guix-authorizations}
6392 (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
6393 @end table
6394
6395
6396 @c *********************************************************************
6397 @node Programming Interface
6398 @chapter Programming Interface
6399
6400 GNU Guix provides several Scheme programming interfaces (APIs) to
6401 define, build, and query packages. The first interface allows users to
6402 write high-level package definitions. These definitions refer to
6403 familiar packaging concepts, such as the name and version of a package,
6404 its build system, and its dependencies. These definitions can then be
6405 turned into concrete build actions.
6406
6407 Build actions are performed by the Guix daemon, on behalf of users. In a
6408 standard setup, the daemon has write access to the store---the
6409 @file{/gnu/store} directory---whereas users do not. The recommended
6410 setup also has the daemon perform builds in chroots, under specific
6411 build users, to minimize interference with the rest of the system.
6412
6413 @cindex derivation
6414 Lower-level APIs are available to interact with the daemon and the
6415 store. To instruct the daemon to perform a build action, users actually
6416 provide it with a @dfn{derivation}. A derivation is a low-level
6417 representation of the build actions to be taken, and the environment in
6418 which they should occur---derivations are to package definitions what
6419 assembly is to C programs. The term ``derivation'' comes from the fact
6420 that build results @emph{derive} from them.
6421
6422 This chapter describes all these APIs in turn, starting from high-level
6423 package definitions.
6424
6425 @menu
6426 * Package Modules:: Packages from the programmer's viewpoint.
6427 * Defining Packages:: Defining new packages.
6428 * Defining Package Variants:: Customizing packages.
6429 * Build Systems:: Specifying how packages are built.
6430 * Build Phases:: Phases of the build process of a package.
6431 * Build Utilities:: Helpers for your package definitions and more.
6432 * The Store:: Manipulating the package store.
6433 * Derivations:: Low-level interface to package derivations.
6434 * The Store Monad:: Purely functional interface to the store.
6435 * G-Expressions:: Manipulating build expressions.
6436 * Invoking guix repl:: Programming Guix in Guile
6437 @end menu
6438
6439 @node Package Modules
6440 @section Package Modules
6441
6442 From a programming viewpoint, the package definitions of the
6443 GNU distribution are provided by Guile modules in the @code{(gnu packages
6444 @dots{})} name space@footnote{Note that packages under the @code{(gnu
6445 packages @dots{})} module name space are not necessarily ``GNU
6446 packages''. This module naming scheme follows the usual Guile module
6447 naming convention: @code{gnu} means that these modules are distributed
6448 as part of the GNU system, and @code{packages} identifies modules that
6449 define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
6450 Reference Manual}). For instance, the @code{(gnu packages emacs)}
6451 module exports a variable named @code{emacs}, which is bound to a
6452 @code{<package>} object (@pxref{Defining Packages}).
6453
6454 The @code{(gnu packages @dots{})} module name space is
6455 automatically scanned for packages by the command-line tools. For
6456 instance, when running @code{guix install emacs}, all the @code{(gnu
6457 packages @dots{})} modules are scanned until one that exports a package
6458 object whose name is @code{emacs} is found. This package search
6459 facility is implemented in the @code{(gnu packages)} module.
6460
6461 @cindex customization, of packages
6462 @cindex package module search path
6463 Users can store package definitions in modules with different
6464 names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
6465 name and module name must match. For instance, the @code{(my-packages
6466 emacs)} module must be stored in a @file{my-packages/emacs.scm} file
6467 relative to the load path specified with @option{--load-path} or
6468 @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
6469 guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
6470 these package definitions visible to the user interfaces:
6471
6472 @enumerate
6473 @item
6474 By adding the directory containing your package modules to the search path
6475 with the @code{-L} flag of @command{guix package} and other commands
6476 (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
6477 environment variable described below.
6478
6479 @item
6480 By defining a @dfn{channel} and configuring @command{guix pull} so that it
6481 pulls from it. A channel is essentially a Git repository containing package
6482 modules. @xref{Channels}, for more information on how to define and use
6483 channels.
6484 @end enumerate
6485
6486 @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
6487
6488 @defvr {Environment Variable} GUIX_PACKAGE_PATH
6489 This is a colon-separated list of directories to search for additional
6490 package modules. Directories listed in this variable take precedence
6491 over the own modules of the distribution.
6492 @end defvr
6493
6494 The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
6495 each package is built based solely on other packages in the
6496 distribution. The root of this dependency graph is a small set of
6497 @dfn{bootstrap binaries}, provided by the @code{(gnu packages
6498 bootstrap)} module. For more information on bootstrapping,
6499 @pxref{Bootstrapping}.
6500
6501 @node Defining Packages
6502 @section Defining Packages
6503
6504 The high-level interface to package definitions is implemented in the
6505 @code{(guix packages)} and @code{(guix build-system)} modules. As an
6506 example, the package definition, or @dfn{recipe}, for the GNU Hello
6507 package looks like this:
6508
6509 @lisp
6510 (define-module (gnu packages hello)
6511 #:use-module (guix packages)
6512 #:use-module (guix download)
6513 #:use-module (guix build-system gnu)
6514 #:use-module (guix licenses)
6515 #:use-module (gnu packages gawk))
6516
6517 (define-public hello
6518 (package
6519 (name "hello")
6520 (version "2.10")
6521 (source (origin
6522 (method url-fetch)
6523 (uri (string-append "mirror://gnu/hello/hello-" version
6524 ".tar.gz"))
6525 (sha256
6526 (base32
6527 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
6528 (build-system gnu-build-system)
6529 (arguments '(#:configure-flags '("--enable-silent-rules")))
6530 (inputs `(("gawk" ,gawk)))
6531 (synopsis "Hello, GNU world: An example GNU package")
6532 (description "Guess what GNU Hello prints!")
6533 (home-page "https://www.gnu.org/software/hello/")
6534 (license gpl3+)))
6535 @end lisp
6536
6537 @noindent
6538 Without being a Scheme expert, the reader may have guessed the meaning
6539 of the various fields here. This expression binds the variable
6540 @code{hello} to a @code{<package>} object, which is essentially a record
6541 (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
6542 This package object can be inspected using procedures found in the
6543 @code{(guix packages)} module; for instance, @code{(package-name hello)}
6544 returns---surprise!---@code{"hello"}.
6545
6546 With luck, you may be able to import part or all of the definition of
6547 the package you are interested in from another repository, using the
6548 @code{guix import} command (@pxref{Invoking guix import}).
6549
6550 In the example above, @code{hello} is defined in a module of its own,
6551 @code{(gnu packages hello)}. Technically, this is not strictly
6552 necessary, but it is convenient to do so: all the packages defined in
6553 modules under @code{(gnu packages @dots{})} are automatically known to
6554 the command-line tools (@pxref{Package Modules}).
6555
6556 There are a few points worth noting in the above package definition:
6557
6558 @itemize
6559 @item
6560 The @code{source} field of the package is an @code{<origin>} object
6561 (@pxref{origin Reference}, for the complete reference).
6562 Here, the @code{url-fetch} method from @code{(guix download)} is used,
6563 meaning that the source is a file to be downloaded over FTP or HTTP.
6564
6565 The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
6566 the GNU mirrors defined in @code{(guix download)}.
6567
6568 The @code{sha256} field specifies the expected SHA256 hash of the file
6569 being downloaded. It is mandatory, and allows Guix to check the
6570 integrity of the file. The @code{(base32 @dots{})} form introduces the
6571 base32 representation of the hash. You can obtain this information with
6572 @code{guix download} (@pxref{Invoking guix download}) and @code{guix
6573 hash} (@pxref{Invoking guix hash}).
6574
6575 @cindex patches
6576 When needed, the @code{origin} form can also have a @code{patches} field
6577 listing patches to be applied, and a @code{snippet} field giving a
6578 Scheme expression to modify the source code.
6579
6580 @item
6581 @cindex GNU Build System
6582 The @code{build-system} field specifies the procedure to build the
6583 package (@pxref{Build Systems}). Here, @code{gnu-build-system}
6584 represents the familiar GNU Build System, where packages may be
6585 configured, built, and installed with the usual @code{./configure &&
6586 make && make check && make install} command sequence.
6587
6588 When you start packaging non-trivial software, you may need tools to
6589 manipulate those build phases, manipulate files, and so on. @xref{Build
6590 Utilities}, for more on this.
6591
6592 @item
6593 The @code{arguments} field specifies options for the build system
6594 (@pxref{Build Systems}). Here it is interpreted by
6595 @code{gnu-build-system} as a request run @file{configure} with the
6596 @option{--enable-silent-rules} flag.
6597
6598 @cindex quote
6599 @cindex quoting
6600 @findex '
6601 @findex quote
6602 What about these quote (@code{'}) characters? They are Scheme syntax to
6603 introduce a literal list; @code{'} is synonymous with @code{quote}.
6604 @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
6605 for details. Here the value of the @code{arguments} field is a list of
6606 arguments passed to the build system down the road, as with @code{apply}
6607 (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
6608 Manual}).
6609
6610 The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
6611 (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
6612 @code{#:configure-flags} is a keyword used to pass a keyword argument
6613 to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
6614 Reference Manual}).
6615
6616 @item
6617 The @code{inputs} field specifies inputs to the build process---i.e.,
6618 build-time or run-time dependencies of the package. Here, we define an
6619 input called @code{"gawk"} whose value is that of the @code{gawk}
6620 variable; @code{gawk} is itself bound to a @code{<package>} object.
6621
6622 @cindex backquote (quasiquote)
6623 @findex `
6624 @findex quasiquote
6625 @cindex comma (unquote)
6626 @findex ,
6627 @findex unquote
6628 @findex ,@@
6629 @findex unquote-splicing
6630 Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
6631 us to introduce a literal list in the @code{inputs} field, while
6632 @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
6633 value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
6634 Reference Manual}).
6635
6636 Note that GCC, Coreutils, Bash, and other essential tools do not need to
6637 be specified as inputs here. Instead, @code{gnu-build-system} takes care
6638 of ensuring that they are present (@pxref{Build Systems}).
6639
6640 However, any other dependencies need to be specified in the
6641 @code{inputs} field. Any dependency not specified here will simply be
6642 unavailable to the build process, possibly leading to a build failure.
6643 @end itemize
6644
6645 @xref{package Reference}, for a full description of possible fields.
6646
6647 Once a package definition is in place, the
6648 package may actually be built using the @code{guix build} command-line
6649 tool (@pxref{Invoking guix build}), troubleshooting any build failures
6650 you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
6651 package definition using the @command{guix edit} command
6652 (@pxref{Invoking guix edit}).
6653 @xref{Packaging Guidelines}, for
6654 more information on how to test package definitions, and
6655 @ref{Invoking guix lint}, for information on how to check a definition
6656 for style conformance.
6657 @vindex GUIX_PACKAGE_PATH
6658 Lastly, @pxref{Channels}, for information
6659 on how to extend the distribution by adding your own package definitions
6660 in a ``channel''.
6661
6662 Finally, updating the package definition to a new upstream version
6663 can be partly automated by the @command{guix refresh} command
6664 (@pxref{Invoking guix refresh}).
6665
6666 Behind the scenes, a derivation corresponding to the @code{<package>}
6667 object is first computed by the @code{package-derivation} procedure.
6668 That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
6669 The build actions it prescribes may then be realized by using the
6670 @code{build-derivations} procedure (@pxref{The Store}).
6671
6672 @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
6673 Return the @code{<derivation>} object of @var{package} for @var{system}
6674 (@pxref{Derivations}).
6675
6676 @var{package} must be a valid @code{<package>} object, and @var{system}
6677 must be a string denoting the target system type---e.g.,
6678 @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
6679 must be a connection to the daemon, which operates on the store
6680 (@pxref{The Store}).
6681 @end deffn
6682
6683 @noindent
6684 @cindex cross-compilation
6685 Similarly, it is possible to compute a derivation that cross-builds a
6686 package for some other system:
6687
6688 @deffn {Scheme Procedure} package-cross-derivation @var{store} @
6689 @var{package} @var{target} [@var{system}]
6690 Return the @code{<derivation>} object of @var{package} cross-built from
6691 @var{system} to @var{target}.
6692
6693 @var{target} must be a valid GNU triplet denoting the target hardware
6694 and operating system, such as @code{"aarch64-linux-gnu"}
6695 (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
6696 @end deffn
6697
6698 Once you have package definitions, you can easily define @emph{variants}
6699 of those packages. @xref{Defining Package Variants}, for more on that.
6700
6701 @menu
6702 * package Reference:: The package data type.
6703 * origin Reference:: The origin data type.
6704 @end menu
6705
6706
6707 @node package Reference
6708 @subsection @code{package} Reference
6709
6710 This section summarizes all the options available in @code{package}
6711 declarations (@pxref{Defining Packages}).
6712
6713 @deftp {Data Type} package
6714 This is the data type representing a package recipe.
6715
6716 @table @asis
6717 @item @code{name}
6718 The name of the package, as a string.
6719
6720 @item @code{version}
6721 The version of the package, as a string. @xref{Version Numbers}, for
6722 guidelines.
6723
6724 @item @code{source}
6725 An object telling how the source code for the package should be
6726 acquired. Most of the time, this is an @code{origin} object, which
6727 denotes a file fetched from the Internet (@pxref{origin Reference}). It
6728 can also be any other ``file-like'' object such as a @code{local-file},
6729 which denotes a file from the local file system (@pxref{G-Expressions,
6730 @code{local-file}}).
6731
6732 @item @code{build-system}
6733 The build system that should be used to build the package (@pxref{Build
6734 Systems}).
6735
6736 @item @code{arguments} (default: @code{'()})
6737 The arguments that should be passed to the build system. This is a
6738 list, typically containing sequential keyword-value pairs.
6739
6740 @item @code{inputs} (default: @code{'()})
6741 @itemx @code{native-inputs} (default: @code{'()})
6742 @itemx @code{propagated-inputs} (default: @code{'()})
6743 @cindex inputs, of packages
6744 These fields list dependencies of the package. Each one is a list of
6745 tuples, where each tuple has a label for the input (a string) as its
6746 first element, a package, origin, or derivation as its second element,
6747 and optionally the name of the output thereof that should be used, which
6748 defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
6749 more on package outputs). For example, the list below specifies three
6750 inputs:
6751
6752 @lisp
6753 `(("libffi" ,libffi)
6754 ("libunistring" ,libunistring)
6755 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
6756 @end lisp
6757
6758 @cindex cross compilation, package dependencies
6759 The distinction between @code{native-inputs} and @code{inputs} is
6760 necessary when considering cross-compilation. When cross-compiling,
6761 dependencies listed in @code{inputs} are built for the @emph{target}
6762 architecture; conversely, dependencies listed in @code{native-inputs}
6763 are built for the architecture of the @emph{build} machine.
6764
6765 @code{native-inputs} is typically used to list tools needed at
6766 build time, but not at run time, such as Autoconf, Automake, pkg-config,
6767 Gettext, or Bison. @command{guix lint} can report likely mistakes in
6768 this area (@pxref{Invoking guix lint}).
6769
6770 @anchor{package-propagated-inputs}
6771 Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
6772 specified packages will be automatically installed to profiles
6773 (@pxref{Features, the role of profiles in Guix}) alongside the package
6774 they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
6775 package}}, for information on how @command{guix package} deals with
6776 propagated inputs).
6777
6778 For example this is necessary when packaging a C/C++ library that needs
6779 headers of another library to compile, or when a pkg-config file refers
6780 to another one @i{via} its @code{Requires} field.
6781
6782 Another example where @code{propagated-inputs} is useful is for languages
6783 that lack a facility to record the run-time search path akin to the
6784 @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
6785 more. When packaging libraries written in those languages, ensure they
6786 can find library code they depend on at run time by listing run-time
6787 dependencies in @code{propagated-inputs} rather than @code{inputs}.
6788
6789 @item @code{outputs} (default: @code{'("out")})
6790 The list of output names of the package. @xref{Packages with Multiple
6791 Outputs}, for typical uses of additional outputs.
6792
6793 @item @code{native-search-paths} (default: @code{'()})
6794 @itemx @code{search-paths} (default: @code{'()})
6795 A list of @code{search-path-specification} objects describing
6796 search-path environment variables honored by the package.
6797
6798 @item @code{replacement} (default: @code{#f})
6799 This must be either @code{#f} or a package object that will be used as a
6800 @dfn{replacement} for this package. @xref{Security Updates, grafts},
6801 for details.
6802
6803 @item @code{synopsis}
6804 A one-line description of the package.
6805
6806 @item @code{description}
6807 A more elaborate description of the package.
6808
6809 @item @code{license}
6810 @cindex license, of packages
6811 The license of the package; a value from @code{(guix licenses)},
6812 or a list of such values.
6813
6814 @item @code{home-page}
6815 The URL to the home-page of the package, as a string.
6816
6817 @item @code{supported-systems} (default: @code{%supported-systems})
6818 The list of systems supported by the package, as strings of the form
6819 @code{architecture-kernel}, for example @code{"x86_64-linux"}.
6820
6821 @item @code{location} (default: source location of the @code{package} form)
6822 The source location of the package. It is useful to override this when
6823 inheriting from another package, in which case this field is not
6824 automatically corrected.
6825 @end table
6826 @end deftp
6827
6828 @deffn {Scheme Syntax} this-package
6829 When used in the @emph{lexical scope} of a package field definition, this
6830 identifier resolves to the package being defined.
6831
6832 The example below shows how to add a package as a native input of itself when
6833 cross-compiling:
6834
6835 @lisp
6836 (package
6837 (name "guile")
6838 ;; ...
6839
6840 ;; When cross-compiled, Guile, for example, depends on
6841 ;; a native version of itself. Add it here.
6842 (native-inputs (if (%current-target-system)
6843 `(("self" ,this-package))
6844 '())))
6845 @end lisp
6846
6847 It is an error to refer to @code{this-package} outside a package definition.
6848 @end deffn
6849
6850 Because packages are regular Scheme objects that capture a complete
6851 dependency graph and associated build procedures, it is often useful to
6852 write procedures that take a package and return a modified version
6853 thereof according to some parameters. Below are a few examples.
6854
6855 @cindex tool chain, choosing a package's tool chain
6856 @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
6857 Return a variant of @var{package} that uses @var{toolchain} instead of
6858 the default GNU C/C++ toolchain. @var{toolchain} must be a list of
6859 inputs (label/package tuples) providing equivalent functionality, such
6860 as the @code{gcc-toolchain} package.
6861
6862 The example below returns a variant of the @code{hello} package built
6863 with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
6864 GNU C Library) instead of the default tool chain:
6865
6866 @lisp
6867 (let ((toolchain (specification->package "gcc-toolchain@@10")))
6868 (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
6869 @end lisp
6870
6871 The build tool chain is part of the @dfn{implicit inputs} of
6872 packages---it's usually not listed as part of the various ``inputs''
6873 fields and is instead pulled in by the build system. Consequently, this
6874 procedure works by changing the build system of @var{package} so that it
6875 pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
6876 for more on build systems.
6877 @end deffn
6878
6879 @node origin Reference
6880 @subsection @code{origin} Reference
6881
6882 This section documents @dfn{origins}. An @code{origin} declaration
6883 specifies data that must be ``produced''---downloaded, usually---and
6884 whose content hash is known in advance. Origins are primarily used to
6885 represent the source code of packages (@pxref{Defining Packages}). For
6886 that reason, the @code{origin} form allows you to declare patches to
6887 apply to the original source code as well as code snippets to modify it.
6888
6889 @deftp {Data Type} origin
6890 This is the data type representing a source code origin.
6891
6892 @table @asis
6893 @item @code{uri}
6894 An object containing the URI of the source. The object type depends on
6895 the @code{method} (see below). For example, when using the
6896 @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
6897 values are: a URL represented as a string, or a list thereof.
6898
6899 @cindex fixed-output derivations, for download
6900 @item @code{method}
6901 A monadic procedure that handles the given URI@. The procedure must
6902 accept at least three arguments: the value of the @code{uri} field and
6903 the hash algorithm and hash value specified by the @code{hash} field.
6904 It must return a store item or a derivation in the store monad
6905 (@pxref{The Store Monad}); most methods return a fixed-output derivation
6906 (@pxref{Derivations}).
6907
6908 Commonly used methods include @code{url-fetch}, which fetches data from
6909 a URL, and @code{git-fetch}, which fetches data from a Git repository
6910 (see below).
6911
6912 @item @code{sha256}
6913 A bytevector containing the SHA-256 hash of the source. This is
6914 equivalent to providing a @code{content-hash} SHA256 object in the
6915 @code{hash} field described below.
6916
6917 @item @code{hash}
6918 The @code{content-hash} object of the source---see below for how to use
6919 @code{content-hash}.
6920
6921 You can obtain this information using @code{guix download}
6922 (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
6923 guix hash}).
6924
6925 @item @code{file-name} (default: @code{#f})
6926 The file name under which the source code should be saved. When this is
6927 @code{#f}, a sensible default value will be used in most cases. In case
6928 the source is fetched from a URL, the file name from the URL will be
6929 used. For version control checkouts, it is recommended to provide the
6930 file name explicitly because the default is not very descriptive.
6931
6932 @item @code{patches} (default: @code{'()})
6933 A list of file names, origins, or file-like objects (@pxref{G-Expressions,
6934 file-like objects}) pointing to patches to be applied to the source.
6935
6936 This list of patches must be unconditional. In particular, it cannot
6937 depend on the value of @code{%current-system} or
6938 @code{%current-target-system}.
6939
6940 @item @code{snippet} (default: @code{#f})
6941 A G-expression (@pxref{G-Expressions}) or S-expression that will be run
6942 in the source directory. This is a convenient way to modify the source,
6943 sometimes more convenient than a patch.
6944
6945 @item @code{patch-flags} (default: @code{'("-p1")})
6946 A list of command-line flags that should be passed to the @code{patch}
6947 command.
6948
6949 @item @code{patch-inputs} (default: @code{#f})
6950 Input packages or derivations to the patching process. When this is
6951 @code{#f}, the usual set of inputs necessary for patching are provided,
6952 such as GNU@tie{}Patch.
6953
6954 @item @code{modules} (default: @code{'()})
6955 A list of Guile modules that should be loaded during the patching
6956 process and while running the code in the @code{snippet} field.
6957
6958 @item @code{patch-guile} (default: @code{#f})
6959 The Guile package that should be used in the patching process. When
6960 this is @code{#f}, a sensible default is used.
6961 @end table
6962 @end deftp
6963
6964 @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
6965 Construct a content hash object for the given @var{algorithm}, and with
6966 @var{value} as its hash value. When @var{algorithm} is omitted, assume
6967 it is @code{sha256}.
6968
6969 @var{value} can be a literal string, in which case it is base32-decoded,
6970 or it can be a bytevector.
6971
6972 The following forms are all equivalent:
6973
6974 @lisp
6975 (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
6976 (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
6977 sha256)
6978 (content-hash (base32
6979 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
6980 (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
6981 sha256)
6982 @end lisp
6983
6984 Technically, @code{content-hash} is currently implemented as a macro.
6985 It performs sanity checks at macro-expansion time, when possible, such
6986 as ensuring that @var{value} has the right size for @var{algorithm}.
6987 @end deftp
6988
6989 As we have seen above, how exactly the data an origin refers to is
6990 retrieved is determined by its @code{method} field. The @code{(guix
6991 download)} module provides the most common method, @code{url-fetch},
6992 described below.
6993
6994 @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
6995 [name] [#:executable? #f]
6996 Return a fixed-output derivation that fetches data from @var{url} (a
6997 string, or a list of strings denoting alternate URLs), which is expected
6998 to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
6999 the file name is the base name of URL; optionally, @var{name} can
7000 specify a different file name. When @var{executable?} is true, make the
7001 downloaded file executable.
7002
7003 When one of the URL starts with @code{mirror://}, then its host part is
7004 interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
7005
7006 Alternatively, when URL starts with @code{file://}, return the
7007 corresponding file name in the store.
7008 @end deffn
7009
7010 Likewise, the @code{(guix git-download)} module defines the
7011 @code{git-fetch} origin method, which fetches data from a Git version
7012 control repository, and the @code{git-reference} data type to describe
7013 the repository and revision to fetch.
7014
7015 @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
7016 Return a fixed-output derivation that fetches @var{ref}, a
7017 @code{<git-reference>} object. The output is expected to have recursive
7018 hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
7019 the file name, or a generic name if @code{#f}.
7020 @end deffn
7021
7022 @deftp {Data Type} git-reference
7023 This data type represents a Git reference for @code{git-fetch} to
7024 retrieve.
7025
7026 @table @asis
7027 @item @code{url}
7028 The URL of the Git repository to clone.
7029
7030 @item @code{commit}
7031 This string denotes either the commit to fetch (a hexadecimal string),
7032 or the tag to fetch. You can also use a ``short'' commit ID or a
7033 @command{git describe} style identifier such as
7034 @code{v1.0.1-10-g58d7909c97}.
7035
7036 @item @code{recursive?} (default: @code{#f})
7037 This Boolean indicates whether to recursively fetch Git sub-modules.
7038 @end table
7039
7040 The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
7041 repository:
7042
7043 @lisp
7044 (git-reference
7045 (url "https://git.savannah.gnu.org/git/hello.git")
7046 (commit "v2.10"))
7047 @end lisp
7048
7049 This is equivalent to the reference below, which explicitly names the
7050 commit:
7051
7052 @lisp
7053 (git-reference
7054 (url "https://git.savannah.gnu.org/git/hello.git")
7055 (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
7056 @end lisp
7057 @end deftp
7058
7059 For Mercurial repositories, the module @code{(guix hg-download)} defines
7060 the @code{hg-fetch} origin method and @code{hg-reference} data type for
7061 support of the Mercurial version control system.
7062
7063 @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
7064 [name]
7065 Return a fixed-output derivation that fetches @var{ref}, a
7066 @code{<hg-reference>} object. The output is expected to have recursive
7067 hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
7068 the file name, or a generic name if @code{#false}.
7069 @end deffn
7070
7071 @node Defining Package Variants
7072 @section Defining Package Variants
7073
7074 @cindex customizing packages
7075 @cindex variants, of packages
7076 One of the nice things with Guix is that, given a package definition,
7077 you can easily @emph{derive} variants of that package---for a different
7078 upstream version, with different dependencies, different compilation
7079 options, and so on. Some of these custom packages can be defined
7080 straight from the command line (@pxref{Package Transformation Options}).
7081 This section describes how to define package variants in code. This can
7082 be useful in ``manifests'' (@pxref{profile-manifest,
7083 @option{--manifest}}) and in your own package collection
7084 (@pxref{Creating a Channel}), among others!
7085
7086 @cindex inherit, for package definitions
7087 As discussed earlier, packages are first-class objects in the Scheme
7088 language. The @code{(guix packages)} module provides the @code{package}
7089 construct to define new package objects (@pxref{package Reference}).
7090 The easiest way to define a package variant is using the @code{inherit}
7091 keyword together with @code{package}. This allows you to inherit from a
7092 package definition while overriding the fields you want.
7093
7094 For example, given the @code{hello} variable, which contains a
7095 definition for the current version of GNU@tie{}Hello, here's how you
7096 would define a variant for version 2.2 (released in 2006, it's
7097 vintage!):
7098
7099 @lisp
7100 (use-modules (gnu packages base)) ;for 'hello'
7101
7102 (define hello-2.2
7103 (package
7104 (inherit hello)
7105 (version "2.2")
7106 (source (origin
7107 (method url-fetch)
7108 (uri (string-append "mirror://gnu/hello/hello-" version
7109 ".tar.gz"))
7110 (sha256
7111 (base32
7112 "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
7113 @end lisp
7114
7115 The example above corresponds to what the @option{--with-source} package
7116 transformation option does. Essentially @code{hello-2.2} preserves all
7117 the fields of @code{hello}, except @code{version} and @code{source},
7118 which it overrides. Note that the original @code{hello} variable is
7119 still there, in the @code{(gnu packages base)} module, unchanged. When
7120 you define a custom package like this, you are really @emph{adding} a
7121 new package definition; the original one remains available.
7122
7123 You can just as well define variants with a different set of
7124 dependencies than the original package. For example, the default
7125 @code{gdb} package depends on @code{guile}, but since that is an
7126 optional dependency, you can define a variant that removes that
7127 dependency like so:
7128
7129 @lisp
7130 (use-modules (gnu packages gdb) ;for 'gdb'
7131 (srfi srfi-1)) ;for 'alist-delete'
7132
7133 (define gdb-sans-guile
7134 (package
7135 (inherit gdb)
7136 (inputs (alist-delete "guile"
7137 (package-inputs gdb)))))
7138 @end lisp
7139
7140 The @code{alist-delete} call above removes the tuple from the
7141 @code{inputs} field that has @code{"guile"} as its first element
7142 (@pxref{SRFI-1 Association Lists,,, guile, GNU Guile Reference
7143 Manual}).
7144
7145 In some cases, you may find it useful to write functions
7146 (``procedures'', in Scheme parlance) that return a package based on some
7147 parameters. For example, consider the @code{luasocket} library for the
7148 Lua programming language. We want to create @code{luasocket} packages
7149 for major versions of Lua. One way to do that is to define a procedure
7150 that takes a Lua package and returns a @code{luasocket} package that
7151 depends on it:
7152
7153 @lisp
7154 (define (make-lua-socket name lua)
7155 ;; Return a luasocket package built with LUA.
7156 (package
7157 (name name)
7158 (version "3.0")
7159 ;; several fields omitted
7160 (inputs
7161 `(("lua" ,lua)))
7162 (synopsis "Socket library for Lua")))
7163
7164 (define-public lua5.1-socket
7165 (make-lua-socket "lua5.1-socket" lua-5.1))
7166
7167 (define-public lua5.2-socket
7168 (make-lua-socket "lua5.2-socket" lua-5.2))
7169 @end lisp
7170
7171 Here we have defined packages @code{lua5.1-socket} and
7172 @code{lua5.2-socket} by calling @code{make-lua-socket} with different
7173 arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
7174 more info on procedures. Having top-level public definitions for these
7175 two packages means that they can be referred to from the command line
7176 (@pxref{Package Modules}).
7177
7178 @cindex package transformations
7179 These are pretty simple package variants. As a convenience, the
7180 @code{(guix transformations)} module provides a high-level interface
7181 that directly maps to the more sophisticated package transformation
7182 options (@pxref{Package Transformation Options}):
7183
7184 @deffn {Scheme Procedure} options->transformation @var{opts}
7185 Return a procedure that, when passed an object to build (package,
7186 derivation, etc.), applies the transformations specified by @var{opts} and returns
7187 the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
7188
7189 @lisp
7190 ((with-branch . "guile-gcrypt=master")
7191 (without-tests . "libgcrypt"))
7192 @end lisp
7193
7194 Each symbol names a transformation and the corresponding string is an argument
7195 to that transformation.
7196 @end deffn
7197
7198 For instance, a manifest equivalent to this command:
7199
7200 @example
7201 guix build guix \
7202 --with-branch=guile-gcrypt=master \
7203 --with-debug-info=zlib
7204 @end example
7205
7206 @noindent
7207 ... would look like this:
7208
7209 @lisp
7210 (use-modules (guix transformations))
7211
7212 (define transform
7213 ;; The package transformation procedure.
7214 (options->transformation
7215 '((with-branch . "guile-gcrypt=master")
7216 (with-debug-info . "zlib"))))
7217
7218 (packages->manifest
7219 (list (transform (specification->package "guix"))))
7220 @end lisp
7221
7222 @cindex input rewriting
7223 @cindex dependency graph rewriting
7224 The @code{options->transformation} procedure is convenient, but it's
7225 perhaps also not as flexible as you may like. How is it implemented?
7226 The astute reader probably noticed that most package transformation
7227 options go beyond the superficial changes shown in the first examples of
7228 this section: they involve @dfn{input rewriting}, whereby the dependency
7229 graph of a package is rewritten by replacing specific inputs by others.
7230
7231 Dependency graph rewriting, for the purposes of swapping packages in the
7232 graph, is what the @code{package-input-rewriting} procedure in
7233 @code{(guix packages)} implements.
7234
7235 @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
7236 [@var{rewrite-name}] [#:deep? #t]
7237 Return a procedure that, when passed a package, replaces its direct and
7238 indirect dependencies, including implicit inputs when @var{deep?} is
7239 true, according to @var{replacements}. @var{replacements} is a list of
7240 package pairs; the first element of each pair is the package to replace,
7241 and the second one is the replacement.
7242
7243 Optionally, @var{rewrite-name} is a one-argument procedure that takes
7244 the name of a package and returns its new name after rewrite.
7245 @end deffn
7246
7247 @noindent
7248 Consider this example:
7249
7250 @lisp
7251 (define libressl-instead-of-openssl
7252 ;; This is a procedure to replace OPENSSL by LIBRESSL,
7253 ;; recursively.
7254 (package-input-rewriting `((,openssl . ,libressl))))
7255
7256 (define git-with-libressl
7257 (libressl-instead-of-openssl git))
7258 @end lisp
7259
7260 @noindent
7261 Here we first define a rewriting procedure that replaces @var{openssl}
7262 with @var{libressl}. Then we use it to define a @dfn{variant} of the
7263 @var{git} package that uses @var{libressl} instead of @var{openssl}.
7264 This is exactly what the @option{--with-input} command-line option does
7265 (@pxref{Package Transformation Options, @option{--with-input}}).
7266
7267 The following variant of @code{package-input-rewriting} can match packages to
7268 be replaced by name rather than by identity.
7269
7270 @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
7271 Return a procedure that, given a package, applies the given
7272 @var{replacements} to all the package graph, including implicit inputs
7273 unless @var{deep?} is false. @var{replacements} is a list of
7274 spec/procedures pair; each spec is a package specification such as
7275 @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
7276 package and returns a replacement for that package.
7277 @end deffn
7278
7279 The example above could be rewritten this way:
7280
7281 @lisp
7282 (define libressl-instead-of-openssl
7283 ;; Replace all the packages called "openssl" with LibreSSL.
7284 (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
7285 @end lisp
7286
7287 The key difference here is that, this time, packages are matched by spec and
7288 not by identity. In other words, any package in the graph that is called
7289 @code{openssl} will be replaced.
7290
7291 A more generic procedure to rewrite a package dependency graph is
7292 @code{package-mapping}: it supports arbitrary changes to nodes in the
7293 graph.
7294
7295 @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
7296 Return a procedure that, given a package, applies @var{proc} to all the packages
7297 depended on and returns the resulting package. The procedure stops recursion
7298 when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
7299 applied to implicit inputs as well.
7300 @end deffn
7301
7302
7303 @node Build Systems
7304 @section Build Systems
7305
7306 @cindex build system
7307 Each package definition specifies a @dfn{build system} and arguments for
7308 that build system (@pxref{Defining Packages}). This @code{build-system}
7309 field represents the build procedure of the package, as well as implicit
7310 dependencies of that build procedure.
7311
7312 Build systems are @code{<build-system>} objects. The interface to
7313 create and manipulate them is provided by the @code{(guix build-system)}
7314 module, and actual build systems are exported by specific modules.
7315
7316 @cindex bag (low-level package representation)
7317 Under the hood, build systems first compile package objects to
7318 @dfn{bags}. A @dfn{bag} is like a package, but with less
7319 ornamentation---in other words, a bag is a lower-level representation of
7320 a package, which includes all the inputs of that package, including some
7321 that were implicitly added by the build system. This intermediate
7322 representation is then compiled to a derivation (@pxref{Derivations}).
7323 The @code{package-with-c-toolchain} is an example of a way to change the
7324 implicit inputs that a package's build system pulls in (@pxref{package
7325 Reference, @code{package-with-c-toolchain}}).
7326
7327 Build systems accept an optional list of @dfn{arguments}. In package
7328 definitions, these are passed @i{via} the @code{arguments} field
7329 (@pxref{Defining Packages}). They are typically keyword arguments
7330 (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
7331 Guile Reference Manual}). The value of these arguments is usually
7332 evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
7333 by the daemon (@pxref{Derivations}).
7334
7335 The main build system is @code{gnu-build-system}, which implements the
7336 standard build procedure for GNU and many other packages. It
7337 is provided by the @code{(guix build-system gnu)} module.
7338
7339 @defvr {Scheme Variable} gnu-build-system
7340 @code{gnu-build-system} represents the GNU Build System, and variants
7341 thereof (@pxref{Configuration, configuration and makefile conventions,,
7342 standards, GNU Coding Standards}).
7343
7344 @cindex build phases
7345 In a nutshell, packages using it are configured, built, and installed with
7346 the usual @code{./configure && make && make check && make install}
7347 command sequence. In practice, a few additional steps are often needed.
7348 All these steps are split up in separate @dfn{phases}.
7349 @xref{Build Phases}, for more info on build phases and ways to customize
7350 them.
7351
7352 In addition, this build system ensures that the ``standard'' environment
7353 for GNU packages is available. This includes tools such as GCC, libc,
7354 Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
7355 build-system gnu)} module for a complete list). We call these the
7356 @dfn{implicit inputs} of a package, because package definitions do not
7357 have to mention them.
7358
7359 This build system supports a number of keyword arguments, which can be
7360 passed @i{via} the @code{arguments} field of a package. Here are some
7361 of the main parameters:
7362
7363 @table @code
7364 @item #:phases
7365 This argument specifies build-side code that evaluates to an alist of
7366 build phases. @xref{Build Phases}, for more information.
7367
7368 @item #:configure-flags
7369 This is a list of flags (strings) passed to the @command{configure}
7370 script. @xref{Defining Packages}, for an example.
7371
7372 @item #:make-flags
7373 This list of strings contains flags passed as arguments to
7374 @command{make} invocations in the @code{build}, @code{check}, and
7375 @code{install} phases.
7376
7377 @item #:out-of-source?
7378 This Boolean, @code{#f} by default, indicates whether to run builds in a
7379 build directory separate from the source tree.
7380
7381 When it is true, the @code{configure} phase creates a separate build
7382 directory, changes to that directory, and runs the @code{configure}
7383 script from there. This is useful for packages that require it, such as
7384 @code{glibc}.
7385
7386 @item #:tests?
7387 This Boolean, @code{#t} by default, indicates whether the @code{check}
7388 phase should run the package's test suite.
7389
7390 @item #:test-target
7391 This string, @code{"check"} by default, gives the name of the makefile
7392 target used by the @code{check} phase.
7393
7394 @item #:parallel-build?
7395 @itemx #:parallel-tests?
7396 These Boolean values specify whether to build, respectively run the test
7397 suite, in parallel, with the @code{-j} flag of @command{make}. When
7398 they are true, @code{make} is passed @code{-j@var{n}}, where @var{n} is
7399 the number specified as the @option{--cores} option of
7400 @command{guix-daemon} or that of the @command{guix} client command
7401 (@pxref{Common Build Options, @option{--cores}}).
7402
7403 @cindex RUNPATH, validation
7404 @item #:validate-runpath?
7405 This Boolean, @code{#t} by default, determines whether to ``validate''
7406 the @code{RUNPATH} of ELF binaries (@code{.so} shared libraries as well
7407 as executables) previously installed by the @code{install} phase.
7408
7409 This validation step consists in making sure that all the shared
7410 libraries needed by an ELF binary, which are listed as
7411 @code{DT_NEEDED} entries in its @code{PT_DYNAMIC} segment, appear in the
7412 @code{DT_RUNPATH} entry of that binary. In other words, it ensures that
7413 running or using those binaries will not result in a ``file not found''
7414 error at run time. @xref{Options, @option{-rpath},, ld, The GNU
7415 Linker}, for more information on @code{RUNPATH}.
7416
7417 @item #:substitutable?
7418 This Boolean, @code{#t} by default, tells whether the package outputs
7419 should be substitutable---i.e., whether users should be able to obtain
7420 substitutes for them instead of building locally (@pxref{Substitutes}).
7421
7422 @item #:allowed-references
7423 @itemx #:disallowed-references
7424 When true, these arguments must be a list of dependencies that must not
7425 appear among the references of the build results. If, upon build
7426 completion, some of these references are retained, the build process
7427 fails.
7428
7429 This is useful to ensure that a package does not erroneously keep a
7430 reference to some of it build-time inputs, in cases where doing so
7431 would, for example, unnecessarily increase its size (@pxref{Invoking
7432 guix size}).
7433 @end table
7434
7435 Most other build systems support these keyword arguments.
7436 @end defvr
7437
7438 Other @code{<build-system>} objects are defined to support other
7439 conventions and tools used by free software packages. They inherit most
7440 of @code{gnu-build-system}, and differ mainly in the set of inputs
7441 implicitly added to the build process, and in the list of phases
7442 executed. Some of these build systems are listed below.
7443
7444 @defvr {Scheme Variable} ant-build-system
7445 This variable is exported by @code{(guix build-system ant)}. It
7446 implements the build procedure for Java packages that can be built with
7447 @url{https://ant.apache.org/, Ant build tool}.
7448
7449 It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
7450 provided by the @code{icedtea} package to the set of inputs. Different
7451 packages can be specified with the @code{#:ant} and @code{#:jdk}
7452 parameters, respectively.
7453
7454 When the original package does not provide a suitable Ant build file,
7455 the parameter @code{#:jar-name} can be used to generate a minimal Ant
7456 build file @file{build.xml} with tasks to build the specified jar
7457 archive. In this case the parameter @code{#:source-dir} can be used to
7458 specify the source sub-directory, defaulting to ``src''.
7459
7460 The @code{#:main-class} parameter can be used with the minimal ant
7461 buildfile to specify the main class of the resulting jar. This makes the
7462 jar file executable. The @code{#:test-include} parameter can be used to
7463 specify the list of junit tests to run. It defaults to
7464 @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
7465 disable some tests. It defaults to @code{(list "**/Abstract*.java")},
7466 because abstract classes cannot be run as tests.
7467
7468 The parameter @code{#:build-target} can be used to specify the Ant task
7469 that should be run during the @code{build} phase. By default the
7470 ``jar'' task will be run.
7471
7472 @end defvr
7473
7474 @defvr {Scheme Variable} android-ndk-build-system
7475 @cindex Android distribution
7476 @cindex Android NDK build system
7477 This variable is exported by @code{(guix build-system android-ndk)}. It
7478 implements a build procedure for Android NDK (native development kit)
7479 packages using a Guix-specific build process.
7480
7481 The build system assumes that packages install their public interface
7482 (header) files to the subdirectory @file{include} of the @code{out} output and
7483 their libraries to the subdirectory @file{lib} the @code{out} output.
7484
7485 It's also assumed that the union of all the dependencies of a package
7486 has no conflicting files.
7487
7488 For the time being, cross-compilation is not supported - so right now
7489 the libraries and header files are assumed to be host tools.
7490
7491 @end defvr
7492
7493 @defvr {Scheme Variable} asdf-build-system/source
7494 @defvrx {Scheme Variable} asdf-build-system/sbcl
7495 @defvrx {Scheme Variable} asdf-build-system/ecl
7496
7497 These variables, exported by @code{(guix build-system asdf)}, implement
7498 build procedures for Common Lisp packages using
7499 @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
7500 definition facility for Common Lisp programs and libraries.
7501
7502 The @code{asdf-build-system/source} system installs the packages in
7503 source form, and can be loaded using any common lisp implementation, via
7504 ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
7505 systems in the format which a particular implementation understands.
7506 These build systems can also be used to produce executable programs, or
7507 lisp images which contain a set of packages pre-loaded.
7508
7509 The build system uses naming conventions. For binary packages, the
7510 package name should be prefixed with the lisp implementation, such as
7511 @code{sbcl-} for @code{asdf-build-system/sbcl}.
7512
7513 Additionally, the corresponding source package should be labeled using
7514 the same convention as python packages (see @ref{Python Modules}), using
7515 the @code{cl-} prefix.
7516
7517 In order to create executable programs and images, the build-side
7518 procedures @code{build-program} and @code{build-image} can be used.
7519 They should be called in a build phase after the
7520 @code{create-asdf-configuration} phase, so that the system which was
7521 just built can be used within the resulting image. @code{build-program}
7522 requires a list of Common Lisp expressions to be passed as the
7523 @code{#:entry-program} argument.
7524
7525 By default, all the @file{.asd} files present in the sources are read to
7526 find system definitions. The @code{#:asd-files} parameter can be used
7527 to specify the list of @file{.asd} files to read. Furthermore, if the
7528 package defines a system for its tests in a separate file, it will be
7529 loaded before the tests are run if it is specified by the
7530 @code{#:test-asd-file} parameter. If it is not set, the files
7531 @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
7532 and @code{test.asd} will be tried if they exist.
7533
7534 If for some reason the package must be named in a different way than the
7535 naming conventions suggest, or if several systems must be compiled, the
7536 @code{#:asd-systems} parameter can be used to specify the list of system
7537 names.
7538
7539 @end defvr
7540
7541 @defvr {Scheme Variable} cargo-build-system
7542 @cindex Rust programming language
7543 @cindex Cargo (Rust build system)
7544 This variable is exported by @code{(guix build-system cargo)}. It
7545 supports builds of packages using Cargo, the build tool of the
7546 @uref{https://www.rust-lang.org, Rust programming language}.
7547
7548 It adds @code{rustc} and @code{cargo} to the set of inputs.
7549 A different Rust package can be specified with the @code{#:rust} parameter.
7550
7551 Regular cargo dependencies should be added to the package definition similarly
7552 to other packages; those needed only at build time to native-inputs, others to
7553 inputs. If you need to add source-only crates then you should add them to via
7554 the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
7555 spec can be a package or a source definition. Note that the spec must
7556 evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
7557 file at its root, or it will be ignored. Similarly, cargo dev-dependencies
7558 should be added to the package definition via the
7559 @code{#:cargo-development-inputs} parameter.
7560
7561 In its @code{configure} phase, this build system will make any source inputs
7562 specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
7563 parameters available to cargo. It will also remove an included
7564 @code{Cargo.lock} file to be recreated by @code{cargo} during the
7565 @code{build} phase. The @code{package} phase will run @code{cargo package}
7566 to create a source crate for future use. The @code{install} phase installs
7567 the binaries defined by the crate. Unless @code{install-source? #f} is
7568 defined it will also install a source crate repository of itself and unpacked
7569 sources, to ease in future hacking on rust packages.
7570 @end defvr
7571
7572 @defvr {Scheme Variable} chicken-build-system
7573 This variable is exported by @code{(guix build-system chicken)}. It
7574 builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
7575 ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
7576 gets compiled by a C compiler, in this case GCC.
7577
7578 This build system adds @code{chicken} to the package inputs, as well as
7579 the packages of @code{gnu-build-system}.
7580
7581 The build system can't (yet) deduce the egg's name automatically, so just like
7582 with @code{go-build-system} and its @code{#:import-path}, you should define
7583 @code{#:egg-name} in the package's @code{arguments} field.
7584
7585 For example, if you are packaging the @code{srfi-1} egg:
7586
7587 @lisp
7588 (arguments '(#:egg-name "srfi-1"))
7589 @end lisp
7590
7591 Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
7592 because CHICKEN doesn't embed absolute references in compiled eggs.
7593 Test dependencies should go to @code{native-inputs}, as usual.
7594 @end defvr
7595
7596 @defvr {Scheme Variable} copy-build-system
7597 This variable is exported by @code{(guix build-system copy)}. It
7598 supports builds of simple packages that don't require much compiling,
7599 mostly just moving files around.
7600
7601 It adds much of the @code{gnu-build-system} packages to the set of
7602 inputs. Because of this, the @code{copy-build-system} does not require
7603 all the boilerplate code often needed for the
7604 @code{trivial-build-system}.
7605
7606 To further simplify the file installation process, an
7607 @code{#:install-plan} argument is exposed to let the packager specify
7608 which files go where. The install plan is a list of @code{(@var{source}
7609 @var{target} [@var{filters}])}. @var{filters} are optional.
7610
7611 @itemize
7612 @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
7613 @itemize
7614 @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
7615 @item Otherwise install @var{source} as @var{target}.
7616 @end itemize
7617
7618 @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
7619 the trailing slash of @var{target} is implied with the same meaning
7620 as above.
7621 @itemize
7622 @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
7623 @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
7624 @code{#:exclude-regexp}, only select files are installed depending on
7625 the filters. Each filters is specified by a list of strings.
7626 @itemize
7627 @item With @code{#:include}, install all the files which the path suffix matches
7628 at least one of the elements in the given list.
7629 @item With @code{#:include-regexp}, install all the files which the
7630 subpaths match at least one of the regular expressions in the given
7631 list.
7632 @item The @code{#:exclude} and @code{#:exclude-regexp} filters
7633 are the complement of their inclusion counterpart. Without @code{#:include} flags,
7634 install all files but those matching the exclusion filters.
7635 If both inclusions and exclusions are specified, the exclusions are done
7636 on top of the inclusions.
7637 @end itemize
7638 @end itemize
7639 In all cases, the paths relative to @var{source} are preserved within
7640 @var{target}.
7641 @end itemize
7642
7643 Examples:
7644
7645 @itemize
7646 @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
7647 @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
7648 @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
7649 e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
7650 @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
7651 @file{share/my-app/sub/file}.
7652 @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
7653 @file{share/my-app/file}.
7654 @end itemize
7655 @end defvr
7656
7657
7658 @cindex Clojure (programming language)
7659 @cindex simple Clojure build system
7660 @defvr {Scheme Variable} clojure-build-system
7661 This variable is exported by @code{(guix build-system clojure)}. It implements
7662 a simple build procedure for @uref{https://clojure.org/, Clojure} packages
7663 using plain old @code{compile} in Clojure. Cross-compilation is not supported
7664 yet.
7665
7666 It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
7667 Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
7668 @code{#:zip} parameters, respectively.
7669
7670 A list of source directories, test directories and jar names can be specified
7671 with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
7672 parameters, respectively. Compile directory and main class can be specified
7673 with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
7674 Other parameters are documented below.
7675
7676 This build system is an extension of @code{ant-build-system}, but with the
7677 following phases changed:
7678
7679 @table @code
7680
7681 @item build
7682 This phase calls @code{compile} in Clojure to compile source files and runs
7683 @command{jar} to create jars from both source files and compiled files
7684 according to the include list and exclude list specified in
7685 @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
7686 has priority over the include list. These lists consist of symbols
7687 representing Clojure libraries or the special keyword @code{#:all} representing
7688 all Clojure libraries found under the source directories. The parameter
7689 @code{#:omit-source?} decides if source should be included into the jars.
7690
7691 @item check
7692 This phase runs tests according to the include list and exclude list specified
7693 in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
7694 meanings are analogous to that of @code{#:aot-include} and
7695 @code{#:aot-exclude}, except that the special keyword @code{#:all} now
7696 stands for all Clojure libraries found under the test directories. The
7697 parameter @code{#:tests?} decides if tests should be run.
7698
7699 @item install
7700 This phase installs all jars built previously.
7701 @end table
7702
7703 Apart from the above, this build system also contains an additional phase:
7704
7705 @table @code
7706
7707 @item install-doc
7708 This phase installs all top-level files with base name matching
7709 @code{%doc-regex}. A different regex can be specified with the
7710 @code{#:doc-regex} parameter. All files (recursively) inside the documentation
7711 directories specified in @code{#:doc-dirs} are installed as well.
7712 @end table
7713 @end defvr
7714
7715 @defvr {Scheme Variable} cmake-build-system
7716 This variable is exported by @code{(guix build-system cmake)}. It
7717 implements the build procedure for packages using the
7718 @url{https://www.cmake.org, CMake build tool}.
7719
7720 It automatically adds the @code{cmake} package to the set of inputs.
7721 Which package is used can be specified with the @code{#:cmake}
7722 parameter.
7723
7724 The @code{#:configure-flags} parameter is taken as a list of flags
7725 passed to the @command{cmake} command. The @code{#:build-type}
7726 parameter specifies in abstract terms the flags passed to the compiler;
7727 it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
7728 debugging information''), which roughly means that code is compiled with
7729 @code{-O2 -g}, as is the case for Autoconf-based packages by default.
7730 @end defvr
7731
7732 @defvr {Scheme Variable} dune-build-system
7733 This variable is exported by @code{(guix build-system dune)}. It
7734 supports builds of packages using @uref{https://dune.build/, Dune}, a build
7735 tool for the OCaml programming language. It is implemented as an extension
7736 of the @code{ocaml-build-system} which is described below. As such, the
7737 @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
7738 system.
7739
7740 It automatically adds the @code{dune} package to the set of inputs.
7741 Which package is used can be specified with the @code{#:dune}
7742 parameter.
7743
7744 There is no @code{configure} phase because dune packages typically don't
7745 need to be configured. The @code{#:build-flags} parameter is taken as a
7746 list of flags passed to the @code{dune} command during the build.
7747
7748 The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
7749 command instead of the more recent @code{dune} command while building
7750 a package. Its default value is @code{#f}.
7751
7752 The @code{#:package} parameter can be passed to specify a package name, which
7753 is useful when a package contains multiple packages and you want to build
7754 only one of them. This is equivalent to passing the @code{-p} argument to
7755 @code{dune}.
7756
7757 @end defvr
7758
7759 @defvr {Scheme Variable} go-build-system
7760 This variable is exported by @code{(guix build-system go)}. It
7761 implements a build procedure for Go packages using the standard
7762 @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
7763 Go build mechanisms}.
7764
7765 The user is expected to provide a value for the key @code{#:import-path}
7766 and, in some cases, @code{#:unpack-path}. The
7767 @url{https://golang.org/doc/code.html#ImportPaths, import path}
7768 corresponds to the file system path expected by the package's build
7769 scripts and any referring packages, and provides a unique way to
7770 refer to a Go package. It is typically based on a combination of the
7771 package source code's remote URI and file system hierarchy structure. In
7772 some cases, you will need to unpack the package's source code to a
7773 different directory structure than the one indicated by the import path,
7774 and @code{#:unpack-path} should be used in such cases.
7775
7776 Packages that provide Go libraries should install their source code into
7777 the built output. The key @code{#:install-source?}, which defaults to
7778 @code{#t}, controls whether or not the source code is installed. It can
7779 be set to @code{#f} for packages that only provide executable files.
7780
7781 Packages can be cross-built, and if a specific architecture or operating
7782 system is desired then the keywords @code{#:goarch} and @code{#:goos}
7783 can be used to force the package to be built for that architecture and
7784 operating system. The combinations known to Go can be found
7785 @url{"https://golang.org/doc/install/source#environment", in their
7786 documentation}.
7787 @end defvr
7788
7789 @defvr {Scheme Variable} glib-or-gtk-build-system
7790 This variable is exported by @code{(guix build-system glib-or-gtk)}. It
7791 is intended for use with packages making use of GLib or GTK+.
7792
7793 This build system adds the following two phases to the ones defined by
7794 @code{gnu-build-system}:
7795
7796 @table @code
7797 @item glib-or-gtk-wrap
7798 The phase @code{glib-or-gtk-wrap} ensures that programs in
7799 @file{bin/} are able to find GLib ``schemas'' and
7800 @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
7801 modules}. This is achieved by wrapping the programs in launch scripts
7802 that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
7803 environment variables.
7804
7805 It is possible to exclude specific package outputs from that wrapping
7806 process by listing their names in the
7807 @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
7808 when an output is known not to contain any GLib or GTK+ binaries, and
7809 where wrapping would gratuitously add a dependency of that output on
7810 GLib and GTK+.
7811
7812 @item glib-or-gtk-compile-schemas
7813 The phase @code{glib-or-gtk-compile-schemas} makes sure that all
7814 @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
7815 GSettings schemas} of GLib are compiled. Compilation is performed by the
7816 @command{glib-compile-schemas} program. It is provided by the package
7817 @code{glib:bin} which is automatically imported by the build system.
7818 The @code{glib} package providing @command{glib-compile-schemas} can be
7819 specified with the @code{#:glib} parameter.
7820 @end table
7821
7822 Both phases are executed after the @code{install} phase.
7823 @end defvr
7824
7825 @defvr {Scheme Variable} guile-build-system
7826 This build system is for Guile packages that consist exclusively of Scheme
7827 code and that are so lean that they don't even have a makefile, let alone a
7828 @file{configure} script. It compiles Scheme code using @command{guild
7829 compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
7830 installs the @file{.scm} and @file{.go} files in the right place. It also
7831 installs documentation.
7832
7833 This build system supports cross-compilation by using the
7834 @option{--target} option of @samp{guild compile}.
7835
7836 Packages built with @code{guile-build-system} must provide a Guile package in
7837 their @code{native-inputs} field.
7838 @end defvr
7839
7840 @defvr {Scheme Variable} julia-build-system
7841 This variable is exported by @code{(guix build-system julia)}. It
7842 implements the build procedure used by @uref{https://julialang.org/,
7843 julia} packages, which essentially is similar to running @samp{julia -e
7844 'using Pkg; Pkg.add(package)'} in an environment where
7845 @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
7846 Tests are run by calling @code{/test/runtests.jl}.
7847
7848 The Julia package name is read from the file @file{Project.toml}. This
7849 value can be overridden by passing the argument @code{#:julia-package-name}
7850 (which must be correctly capitalized).
7851
7852 Julia packages usually manage their binary dependencies via
7853 @code{JLLWrappers.jl}, a Julia package that creates a module (named
7854 after the wrapped library followed by @code{_jll.jl}.
7855
7856 To add the binary path @code{_jll.jl} packages, you need to patch the
7857 files under @file{src/wrappers/}, replacing the call to the macro
7858 @code{JLLWrappers.@@generate_wrapper_header}, adding as a second
7859 argument containing the store path the binary.
7860
7861 As an example, in the MbedTLS Julia package, we add a build phase
7862 (@pxref{Build Phases}) to insert the absolute file name of the wrapped
7863 MbedTLS package:
7864
7865 @lisp
7866 (add-after 'unpack 'override-binary-path
7867 (lambda* (#:key inputs #:allow-other-keys)
7868 (for-each (lambda (wrapper)
7869 (substitute* wrapper
7870 (("generate_wrapper_header.*")
7871 (string-append
7872 "generate_wrapper_header(\"MbedTLS\", \""
7873 (assoc-ref inputs "mbedtls-apache") "\")\n"))))
7874 ;; There's a Julia file for each platform, override them all.
7875 (find-files "src/wrappers/" "\\.jl$"))))
7876 @end lisp
7877
7878 Some older packages that aren't using @file{Package.toml} yet, will require
7879 this file to be created, too. The function @code{julia-create-package-toml}
7880 helps creating the file. You need to pass the outputs and the source of the
7881 package, its name (the same as the @code{file-name} parameter), the package
7882 uuid, the package version, and a list of dependencies specified by their name
7883 and their uuid.
7884 @end defvr
7885
7886 @defvr {Scheme Variable} maven-build-system
7887 This variable is exported by @code{(guix build-system maven)}. It implements
7888 a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
7889 is a dependency and lifecycle management tool for Java. A user of Maven
7890 specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
7891 When Maven does not have one of the dependencies or plugins in its repository,
7892 it will download them and use them to build the package.
7893
7894 The maven build system ensures that maven will not try to download any
7895 dependency by running in offline mode. Maven will fail if a dependency is
7896 missing. Before running Maven, the @file{pom.xml} (and subprojects) are
7897 modified to specify the version of dependencies and plugins that match the
7898 versions available in the guix build environment. Dependencies and plugins
7899 must be installed in the fake maven repository at @file{lib/m2}, and are
7900 symlinked into a proper repository before maven is run. Maven is instructed
7901 to use that repository for the build and installs built artifacts there.
7902 Changed files are copied to the @file{lib/m2} directory of the package output.
7903
7904 You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
7905 or let the build system use the default @file{pom.xml} file in the sources.
7906
7907 In case you need to specify a dependency's version manually, you can use the
7908 @code{#:local-packages} argument. It takes an association list where the key
7909 is the groupId of the package and its value is an association list where the
7910 key is the artifactId of the package and its value is the version you want to
7911 override in the @file{pom.xml}.
7912
7913 Some packages use dependencies or plugins that are not useful at runtime nor
7914 at build time in Guix. You can alter the @file{pom.xml} file to remove them
7915 using the @code{#:exclude} argument. Its value is an association list where
7916 the key is the groupId of the plugin or dependency you want to remove, and
7917 the value is a list of artifactId you want to remove.
7918
7919 You can override the default @code{jdk} and @code{maven} packages with the
7920 corresponding argument, @code{#:jdk} and @code{#:maven}.
7921
7922 The @code{#:maven-plugins} argument is a list of maven plugins used during
7923 the build, with the same format as the @code{inputs} fields of the package
7924 declaration. Its default value is @code{(default-maven-plugins)} which is
7925 also exported.
7926 @end defvr
7927
7928 @defvr {Scheme Variable} minetest-mod-build-system
7929 This variable is exported by @code{(guix build-system minetest)}. It
7930 implements a build procedure for @uref{https://www.minetest.net, Minetest}
7931 mods, which consists of copying Lua code, images and other resources to
7932 the location Minetest searches for mods. The build system also minimises
7933 PNG images and verifies that Minetest can load the mod without errors.
7934 @end defvr
7935
7936 @defvr {Scheme Variable} minify-build-system
7937 This variable is exported by @code{(guix build-system minify)}. It
7938 implements a minification procedure for simple JavaScript packages.
7939
7940 It adds @code{uglify-js} to the set of inputs and uses it to compress
7941 all JavaScript files in the @file{src} directory. A different minifier
7942 package can be specified with the @code{#:uglify-js} parameter, but it
7943 is expected that the package writes the minified code to the standard
7944 output.
7945
7946 When the input JavaScript files are not all located in the @file{src}
7947 directory, the parameter @code{#:javascript-files} can be used to
7948 specify a list of file names to feed to the minifier.
7949 @end defvr
7950
7951 @defvr {Scheme Variable} ocaml-build-system
7952 This variable is exported by @code{(guix build-system ocaml)}. It implements
7953 a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
7954 of choosing the correct set of commands to run for each package. OCaml
7955 packages can expect many different commands to be run. This build system will
7956 try some of them.
7957
7958 When the package has a @file{setup.ml} file present at the top-level, it will
7959 run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
7960 @code{ocaml setup.ml -install}. The build system will assume that this file
7961 was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
7962 care of setting the prefix and enabling tests if they are not disabled. You
7963 can pass configure and build flags with the @code{#:configure-flags} and
7964 @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
7965 set of flags used to enable tests. The @code{#:use-make?} key can be used to
7966 bypass this system in the build and install phases.
7967
7968 When the package has a @file{configure} file, it is assumed that it is a
7969 hand-made configure script that requires a different argument format than
7970 in the @code{gnu-build-system}. You can add more flags with the
7971 @code{#:configure-flags} key.
7972
7973 When the package has a @file{Makefile} file (or @code{#:use-make?} is
7974 @code{#t}), it will be used and more flags can be passed to the build and
7975 install phases with the @code{#:make-flags} key.
7976
7977 Finally, some packages do not have these files and use a somewhat standard
7978 location for its build system. In that case, the build system will run
7979 @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
7980 providing the path to the required findlib module. Additional flags can
7981 be passed via the @code{#:build-flags} key. Install is taken care of by
7982 @command{opam-installer}. In this case, the @code{opam} package must
7983 be added to the @code{native-inputs} field of the package definition.
7984
7985 Note that most OCaml packages assume they will be installed in the same
7986 directory as OCaml, which is not what we want in guix. In particular, they
7987 will install @file{.so} files in their module's directory, which is usually
7988 fine because it is in the OCaml compiler directory. In guix though, these
7989 libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
7990 variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
7991 @file{.so} libraries should be installed.
7992 @end defvr
7993
7994 @defvr {Scheme Variable} python-build-system
7995 This variable is exported by @code{(guix build-system python)}. It
7996 implements the more or less standard build procedure used by Python
7997 packages, which consists in running @code{python setup.py build} and
7998 then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
7999
8000 For packages that install stand-alone Python programs under @code{bin/},
8001 it takes care of wrapping these programs so that their @env{PYTHONPATH}
8002 environment variable points to all the Python libraries they depend on.
8003
8004 Which Python package is used to perform the build can be specified with
8005 the @code{#:python} parameter. This is a useful way to force a package
8006 to be built for a specific version of the Python interpreter, which
8007 might be necessary if the package is only compatible with a single
8008 interpreter version.
8009
8010 By default guix calls @code{setup.py} under control of
8011 @code{setuptools}, much like @command{pip} does. Some packages are not
8012 compatible with setuptools (and pip), thus you can disable this by
8013 setting the @code{#:use-setuptools?} parameter to @code{#f}.
8014 @end defvr
8015
8016 @defvr {Scheme Variable} perl-build-system
8017 This variable is exported by @code{(guix build-system perl)}. It
8018 implements the standard build procedure for Perl packages, which either
8019 consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
8020 followed by @code{Build} and @code{Build install}; or in running
8021 @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
8022 @code{make} and @code{make install}, depending on which of
8023 @code{Build.PL} or @code{Makefile.PL} is present in the package
8024 distribution. Preference is given to the former if both @code{Build.PL}
8025 and @code{Makefile.PL} exist in the package distribution. This
8026 preference can be reversed by specifying @code{#t} for the
8027 @code{#:make-maker?} parameter.
8028
8029 The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
8030 passes flags specified by the @code{#:make-maker-flags} or
8031 @code{#:module-build-flags} parameter, respectively.
8032
8033 Which Perl package is used can be specified with @code{#:perl}.
8034 @end defvr
8035
8036 @defvr {Scheme Variable} renpy-build-system
8037 This variable is exported by @code{(guix build-system renpy)}. It implements
8038 the more or less standard build procedure used by Ren'py games, which consists
8039 of loading @code{#:game} once, thereby creating bytecode for it.
8040
8041 It further creates a wrapper script in @code{bin/} and a desktop entry in
8042 @code{share/applications}, both of which can be used to launch the game.
8043
8044 Which Ren'py package is used can be specified with @code{#:renpy}.
8045 Games can also be installed in outputs other than ``out'' by using
8046 @code{#:output}.
8047 @end defvr
8048
8049 @defvr {Scheme Variable} qt-build-system
8050 This variable is exported by @code{(guix build-system qt)}. It
8051 is intended for use with applications using Qt or KDE.
8052
8053 This build system adds the following two phases to the ones defined by
8054 @code{cmake-build-system}:
8055
8056 @table @code
8057 @item check-setup
8058 The phase @code{check-setup} prepares the environment for running
8059 the checks as commonly used by Qt test programs.
8060 For now this only sets some environment variables:
8061 @code{QT_QPA_PLATFORM=offscreen},
8062 @code{DBUS_FATAL_WARNINGS=0} and
8063 @code{CTEST_OUTPUT_ON_FAILURE=1}.
8064
8065 This phase is added before the @code{check} phase.
8066 It's a separate phase to ease adjusting if necessary.
8067
8068 @item qt-wrap
8069 The phase @code{qt-wrap}
8070 searches for Qt5 plugin paths, QML paths and some XDG in the inputs
8071 and output. In case some path is found, all programs in the output's
8072 @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
8073 are wrapped in scripts defining the necessary environment variables.
8074
8075 It is possible to exclude specific package outputs from that wrapping process
8076 by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
8077 This is useful when an output is known not to contain any Qt binaries, and
8078 where wrapping would gratuitously add a dependency of that output on Qt, KDE,
8079 or such.
8080
8081 This phase is added after the @code{install} phase.
8082 @end table
8083 @end defvr
8084
8085 @defvr {Scheme Variable} r-build-system
8086 This variable is exported by @code{(guix build-system r)}. It
8087 implements the build procedure used by @uref{https://r-project.org, R}
8088 packages, which essentially is little more than running @samp{R CMD
8089 INSTALL --library=/gnu/store/@dots{}} in an environment where
8090 @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
8091 run after installation using the R function
8092 @code{tools::testInstalledPackage}.
8093 @end defvr
8094
8095 @defvr {Scheme Variable} rakudo-build-system
8096 This variable is exported by @code{(guix build-system rakudo)}. It
8097 implements the build procedure used by @uref{https://rakudo.org/,
8098 Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
8099 package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
8100 installs the binaries, library files and the resources, as well as wrap
8101 the files under the @code{bin/} directory. Tests can be skipped by
8102 passing @code{#f} to the @code{tests?} parameter.
8103
8104 Which rakudo package is used can be specified with @code{rakudo}.
8105 Which perl6-tap-harness package used for the tests can be specified with
8106 @code{#:prove6} or removed by passing @code{#f} to the
8107 @code{with-prove6?} parameter.
8108 Which perl6-zef package used for tests and installing can be specified
8109 with @code{#:zef} or removed by passing @code{#f} to the
8110 @code{with-zef?} parameter.
8111 @end defvr
8112
8113 @defvr {Scheme Variable} texlive-build-system
8114 This variable is exported by @code{(guix build-system texlive)}. It is
8115 used to build TeX packages in batch mode with a specified engine. The
8116 build system sets the @env{TEXINPUTS} variable to find all TeX source
8117 files in the inputs.
8118
8119 By default it runs @code{luatex} on all files ending on @code{ins}. A
8120 different engine and format can be specified with the
8121 @code{#:tex-format} argument. Different build targets can be specified
8122 with the @code{#:build-targets} argument, which expects a list of file
8123 names. The build system adds only @code{texlive-bin} and
8124 @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
8125 inputs. Both can be overridden with the arguments @code{#:texlive-bin}
8126 and @code{#:texlive-latex-base}, respectively.
8127
8128 The @code{#:tex-directory} parameter tells the build system where to
8129 install the built files under the texmf tree.
8130 @end defvr
8131
8132 @defvr {Scheme Variable} ruby-build-system
8133 This variable is exported by @code{(guix build-system ruby)}. It
8134 implements the RubyGems build procedure used by Ruby packages, which
8135 involves running @code{gem build} followed by @code{gem install}.
8136
8137 The @code{source} field of a package that uses this build system
8138 typically references a gem archive, since this is the format that Ruby
8139 developers use when releasing their software. The build system unpacks
8140 the gem archive, potentially patches the source, runs the test suite,
8141 repackages the gem, and installs it. Additionally, directories and
8142 tarballs may be referenced to allow building unreleased gems from Git or
8143 a traditional source release tarball.
8144
8145 Which Ruby package is used can be specified with the @code{#:ruby}
8146 parameter. A list of additional flags to be passed to the @command{gem}
8147 command can be specified with the @code{#:gem-flags} parameter.
8148 @end defvr
8149
8150 @defvr {Scheme Variable} waf-build-system
8151 This variable is exported by @code{(guix build-system waf)}. It
8152 implements a build procedure around the @code{waf} script. The common
8153 phases---@code{configure}, @code{build}, and @code{install}---are
8154 implemented by passing their names as arguments to the @code{waf}
8155 script.
8156
8157 The @code{waf} script is executed by the Python interpreter. Which
8158 Python package is used to run the script can be specified with the
8159 @code{#:python} parameter.
8160 @end defvr
8161
8162 @defvr {Scheme Variable} scons-build-system
8163 This variable is exported by @code{(guix build-system scons)}. It
8164 implements the build procedure used by the SCons software construction
8165 tool. This build system runs @code{scons} to build the package,
8166 @code{scons test} to run tests, and then @code{scons install} to install
8167 the package.
8168
8169 Additional flags to be passed to @code{scons} can be specified with the
8170 @code{#:scons-flags} parameter. The default build and install targets
8171 can be overridden with @code{#:build-targets} and
8172 @code{#:install-targets} respectively. The version of Python used to
8173 run SCons can be specified by selecting the appropriate SCons package
8174 with the @code{#:scons} parameter.
8175 @end defvr
8176
8177 @defvr {Scheme Variable} haskell-build-system
8178 This variable is exported by @code{(guix build-system haskell)}. It
8179 implements the Cabal build procedure used by Haskell packages, which
8180 involves running @code{runhaskell Setup.hs configure
8181 --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
8182 Instead of installing the package by running @code{runhaskell Setup.hs
8183 install}, to avoid trying to register libraries in the read-only
8184 compiler store directory, the build system uses @code{runhaskell
8185 Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
8186 addition, the build system generates the package documentation by
8187 running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
8188 is passed. Optional Haddock parameters can be passed with the help of
8189 the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
8190 not found, the build system looks for @code{Setup.lhs} instead.
8191
8192 Which Haskell compiler is used can be specified with the @code{#:haskell}
8193 parameter which defaults to @code{ghc}.
8194 @end defvr
8195
8196 @defvr {Scheme Variable} dub-build-system
8197 This variable is exported by @code{(guix build-system dub)}. It
8198 implements the Dub build procedure used by D packages, which
8199 involves running @code{dub build} and @code{dub run}.
8200 Installation is done by copying the files manually.
8201
8202 Which D compiler is used can be specified with the @code{#:ldc}
8203 parameter which defaults to @code{ldc}.
8204 @end defvr
8205
8206 @anchor{emacs-build-system}
8207 @defvr {Scheme Variable} emacs-build-system
8208 This variable is exported by @code{(guix build-system emacs)}. It
8209 implements an installation procedure similar to the packaging system
8210 of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
8211
8212 It first creates the @code{@code{package}-autoloads.el} file, then it
8213 byte compiles all Emacs Lisp files. Differently from the Emacs
8214 packaging system, the Info documentation files are moved to the standard
8215 documentation directory and the @file{dir} file is deleted. The Elisp
8216 package files are installed directly under @file{share/emacs/site-lisp}.
8217 @end defvr
8218
8219 @defvr {Scheme Variable} font-build-system
8220 This variable is exported by @code{(guix build-system font)}. It
8221 implements an installation procedure for font packages where upstream
8222 provides pre-compiled TrueType, OpenType, etc.@: font files that merely
8223 need to be copied into place. It copies font files to standard
8224 locations in the output directory.
8225 @end defvr
8226
8227 @defvr {Scheme Variable} meson-build-system
8228 This variable is exported by @code{(guix build-system meson)}. It
8229 implements the build procedure for packages that use
8230 @url{https://mesonbuild.com, Meson} as their build system.
8231
8232 It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
8233 of inputs, and they can be changed with the parameters @code{#:meson}
8234 and @code{#:ninja} if needed. The default Meson is
8235 @code{meson-for-build}, which is special because it doesn't clear the
8236 @code{RUNPATH} of binaries and libraries when they are installed.
8237
8238 This build system is an extension of @code{gnu-build-system}, but with the
8239 following phases changed to some specific for Meson:
8240
8241 @table @code
8242
8243 @item configure
8244 The phase runs @code{meson} with the flags specified in
8245 @code{#:configure-flags}. The flag @option{--buildtype} is always set to
8246 @code{debugoptimized} unless something else is specified in
8247 @code{#:build-type}.
8248
8249 @item build
8250 The phase runs @code{ninja} to build the package in parallel by default, but
8251 this can be changed with @code{#:parallel-build?}.
8252
8253 @item check
8254 The phase runs @code{ninja} with the target specified in @code{#:test-target},
8255 which is @code{"test"} by default.
8256
8257 @item install
8258 The phase runs @code{ninja install} and can not be changed.
8259 @end table
8260
8261 Apart from that, the build system also adds the following phases:
8262
8263 @table @code
8264
8265 @item fix-runpath
8266 This phase ensures that all binaries can find the libraries they need.
8267 It searches for required libraries in subdirectories of the package being
8268 built, and adds those to @code{RUNPATH} where needed. It also removes
8269 references to libraries left over from the build phase by
8270 @code{meson-for-build}, such as test dependencies, that aren't actually
8271 required for the program to run.
8272
8273 @item glib-or-gtk-wrap
8274 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
8275 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
8276
8277 @item glib-or-gtk-compile-schemas
8278 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
8279 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
8280 @end table
8281 @end defvr
8282
8283 @defvr {Scheme Variable} linux-module-build-system
8284 @code{linux-module-build-system} allows building Linux kernel modules.
8285
8286 @cindex build phases
8287 This build system is an extension of @code{gnu-build-system}, but with the
8288 following phases changed:
8289
8290 @table @code
8291
8292 @item configure
8293 This phase configures the environment so that the Linux kernel's Makefile
8294 can be used to build the external kernel module.
8295
8296 @item build
8297 This phase uses the Linux kernel's Makefile in order to build the external
8298 kernel module.
8299
8300 @item install
8301 This phase uses the Linux kernel's Makefile in order to install the external
8302 kernel module.
8303 @end table
8304
8305 It is possible and useful to specify the Linux kernel to use for building
8306 the module (in the @code{arguments} form of a package using the
8307 @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
8308 @end defvr
8309
8310 @defvr {Scheme Variable} node-build-system
8311 This variable is exported by @code{(guix build-system node)}. It
8312 implements the build procedure used by @uref{https://nodejs.org,
8313 Node.js}, which implements an approximation of the @code{npm install}
8314 command, followed by an @code{npm test} command.
8315
8316 Which Node.js package is used to interpret the @code{npm} commands can
8317 be specified with the @code{#:node} parameter which defaults to
8318 @code{node}.
8319 @end defvr
8320
8321 Lastly, for packages that do not need anything as sophisticated, a
8322 ``trivial'' build system is provided. It is trivial in the sense that
8323 it provides basically no support: it does not pull any implicit inputs,
8324 and does not have a notion of build phases.
8325
8326 @defvr {Scheme Variable} trivial-build-system
8327 This variable is exported by @code{(guix build-system trivial)}.
8328
8329 This build system requires a @code{#:builder} argument. This argument
8330 must be a Scheme expression that builds the package output(s)---as
8331 with @code{build-expression->derivation} (@pxref{Derivations,
8332 @code{build-expression->derivation}}).
8333 @end defvr
8334
8335 @node Build Phases
8336 @section Build Phases
8337
8338 @cindex build phases, for packages
8339 Almost all package build systems implement a notion @dfn{build phases}:
8340 a sequence of actions that the build system executes, when you build the
8341 package, leading to the installed byproducts in the store. A notable
8342 exception is the ``bare-bones'' @code{trivial-build-system}
8343 (@pxref{Build Systems}).
8344
8345 As discussed in the previous section, those build systems provide a
8346 standard list of phases. For @code{gnu-build-system}, the main build
8347 phases are the following:
8348
8349 @table @code
8350 @item unpack
8351 Unpack the source tarball, and change the current directory to the
8352 extracted source tree. If the source is actually a directory, copy it
8353 to the build tree, and enter that directory.
8354
8355 @item patch-source-shebangs
8356 Patch shebangs encountered in source files so they refer to the right
8357 store file names. For instance, this changes @code{#!/bin/sh} to
8358 @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
8359
8360 @item configure
8361 Run the @file{configure} script with a number of default options, such
8362 as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
8363 by the @code{#:configure-flags} argument.
8364
8365 @item build
8366 Run @code{make} with the list of flags specified with
8367 @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
8368 (the default), build with @code{make -j}.
8369
8370 @item check
8371 Run @code{make check}, or some other target specified with
8372 @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
8373 @code{#:parallel-tests?} argument is true (the default), run @code{make
8374 check -j}.
8375
8376 @item install
8377 Run @code{make install} with the flags listed in @code{#:make-flags}.
8378
8379 @item patch-shebangs
8380 Patch shebangs on the installed executable files.
8381
8382 @item strip
8383 Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
8384 is false), copying them to the @code{debug} output when available
8385 (@pxref{Installing Debugging Files}).
8386 @end table
8387
8388 Other build systems have similar phases, with some variations. For
8389 example, @code{cmake-build-system} has same-named phases but its
8390 @code{configure} phases runs @code{cmake} instead of @code{./configure}.
8391 Others, such as @code{python-build-system}, have a wholly different list
8392 of standard phases. All this code runs on the @dfn{build side}: it is
8393 evaluated when you actually build the package, in a dedicated build
8394 process spawned by the build daemon (@pxref{Invoking guix-daemon}).
8395
8396 Build phases are represented as association lists or ``alists''
8397 (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
8398 each key is a symbol for the name of the phase and the associated value
8399 is a procedure that accepts an arbitrary number of arguments. By
8400 convention, those procedures receive information about the build in the
8401 form of @dfn{keyword parameters}, which they can use or ignore.
8402
8403 @vindex %standard-phases
8404 For example, here is how @code{(guix build gnu-build-system)} defines
8405 @code{%standard-phases}, the variable holding its alist of build
8406 phases@footnote{We present a simplified view of those build phases, but
8407 do take a look at @code{(guix build gnu-build-system)} to see all the
8408 details!}:
8409
8410 @lisp
8411 ;; The build phases of 'gnu-build-system'.
8412
8413 (define* (unpack #:key source #:allow-other-keys)
8414 ;; Extract the source tarball.
8415 (invoke "tar" "xvf" source))
8416
8417 (define* (configure #:key outputs #:allow-other-keys)
8418 ;; Run the 'configure' script. Install to output "out".
8419 (let ((out (assoc-ref outputs "out")))
8420 (invoke "./configure"
8421 (string-append "--prefix=" out))))
8422
8423 (define* (build #:allow-other-keys)
8424 ;; Compile.
8425 (invoke "make"))
8426
8427 (define* (check #:key (test-target "check") (tests? #true)
8428 #:allow-other-keys)
8429 ;; Run the test suite.
8430 (if tests?
8431 (invoke "make" test-target)
8432 (display "test suite not run\n")))
8433
8434 (define* (install #:allow-other-keys)
8435 ;; Install files to the prefix 'configure' specified.
8436 (invoke "make" "install"))
8437
8438 (define %standard-phases
8439 ;; The list of standard phases (quite a few are omitted
8440 ;; for brevity). Each element is a symbol/procedure pair.
8441 (list (cons 'unpack unpack)
8442 (cons 'configure configure)
8443 (cons 'build build)
8444 (cons 'check check)
8445 (cons 'install install)))
8446 @end lisp
8447
8448 This shows how @code{%standard-phases} is defined as a list of
8449 symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
8450 Manual}). The first pair associates the @code{unpack} procedure with
8451 the @code{unpack} symbol---a name; the second pair defines the
8452 @code{configure} phase similarly, and so on. When building a package
8453 that uses @code{gnu-build-system} with its default list of phases, those
8454 phases are executed sequentially. You can see the name of each phase
8455 started and completed in the build log of packages that you build.
8456
8457 Let's now look at the procedures themselves. Each one is defined with
8458 @code{define*}: @code{#:key} lists keyword parameters the procedure
8459 accepts, possibly with a default value, and @code{#:allow-other-keys}
8460 specifies that other keyword parameters are ignored (@pxref{Optional
8461 Arguments,,, guile, GNU Guile Reference Manual}).
8462
8463 The @code{unpack} procedure honors the @code{source} parameter, which
8464 the build system uses to pass the file name of the source tarball (or
8465 version control checkout), and it ignores other parameters. The
8466 @code{configure} phase only cares about the @code{outputs} parameter, an
8467 alist mapping package output names to their store file name
8468 (@pxref{Packages with Multiple Outputs}). It extracts the file name of
8469 for @code{out}, the default output, and passes it to
8470 @command{./configure} as the installation prefix, meaning that
8471 @command{make install} will eventually copy all the files in that
8472 directory (@pxref{Configuration, configuration and makefile
8473 conventions,, standards, GNU Coding Standards}). @code{build} and
8474 @code{install} ignore all their arguments. @code{check} honors the
8475 @code{test-target} argument, which specifies the name of the Makefile
8476 target to run tests; it prints a message and skips tests when
8477 @code{tests?} is false.
8478
8479 @cindex build phases, customizing
8480 The list of phases used for a particular package can be changed with the
8481 @code{#:phases} parameter of the build system. Changing the set of
8482 build phases boils down to building a new alist of phases based on the
8483 @code{%standard-phases} alist described above. This can be done with
8484 standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
8485 Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
8486 more convenient to do so with @code{modify-phases} (@pxref{Build
8487 Utilities, @code{modify-phases}}).
8488
8489 Here is an example of a package definition that removes the
8490 @code{configure} phase of @code{%standard-phases} and inserts a new
8491 phase before the @code{build} phase, called
8492 @code{set-prefix-in-makefile}:
8493
8494 @lisp
8495 (define-public example
8496 (package
8497 (name "example")
8498 ;; other fields omitted
8499 (build-system gnu-build-system)
8500 (arguments
8501 '(#:phases (modify-phases %standard-phases
8502 (delete 'configure)
8503 (add-before 'build 'set-prefix-in-makefile
8504 (lambda* (#:key outputs #:allow-other-keys)
8505 ;; Modify the makefile so that its
8506 ;; 'PREFIX' variable points to "out".
8507 (let ((out (assoc-ref outputs "out")))
8508 (substitute* "Makefile"
8509 (("PREFIX =.*")
8510 (string-append "PREFIX = "
8511 out "\n")))
8512 #true))))))))
8513 @end lisp
8514
8515 The new phase that is inserted is written as an anonymous procedure,
8516 introduced with @code{lambda*}; it honors the @code{outputs} parameter
8517 we have seen before. @xref{Build Utilities}, for more about the helpers
8518 used by this phase, and for more examples of @code{modify-phases}.
8519
8520 @cindex code staging
8521 @cindex staging, of code
8522 Keep in mind that build phases are code evaluated at the time the
8523 package is actually built. This explains why the whole
8524 @code{modify-phases} expression above is quoted (it comes after the
8525 @code{'} or apostrophe): it is @dfn{staged} for later execution.
8526 @xref{G-Expressions}, for an explanation of code staging and the
8527 @dfn{code strata} involved.
8528
8529 @node Build Utilities
8530 @section Build Utilities
8531
8532 As soon as you start writing non-trivial package definitions
8533 (@pxref{Defining Packages}) or other build actions
8534 (@pxref{G-Expressions}), you will likely start looking for helpers for
8535 ``shell-like'' actions---creating directories, copying and deleting
8536 files recursively, manipulating build phases, and so on. The
8537 @code{(guix build utils)} module provides such utility procedures.
8538
8539 Most build systems load @code{(guix build utils)} (@pxref{Build
8540 Systems}). Thus, when writing custom build phases for your package
8541 definitions, you can usually assume those procedures are in scope.
8542
8543 When writing G-expressions, you can import @code{(guix build utils)} on
8544 the ``build side'' using @code{with-imported-modules} and then put it in
8545 scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
8546 guile, GNU Guile Reference Manual}):
8547
8548 @lisp
8549 (with-imported-modules '((guix build utils)) ;import it
8550 (computed-file "empty-tree"
8551 #~(begin
8552 ;; Put it in scope.
8553 (use-modules (guix build utils))
8554
8555 ;; Happily use its 'mkdir-p' procedure.
8556 (mkdir-p (string-append #$output "/a/b/c")))))
8557 @end lisp
8558
8559 The remainder of this section is the reference for most of the utility
8560 procedures provided by @code{(guix build utils)}.
8561
8562 @c TODO Document what's missing.
8563
8564 @subsection Dealing with Store File Names
8565
8566 This section documents procedures that deal with store file names.
8567
8568 @deffn {Scheme Procedure} %store-directory
8569 Return the directory name of the store.
8570 @end deffn
8571
8572 @deffn {Scheme Procedure} store-file-name? @var{file}
8573 Return true if @var{file} is in the store.
8574 @end deffn
8575
8576 @deffn {Scheme Procedure} strip-store-file-name @var{file}
8577 Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
8578 The result is typically a @code{"@var{package}-@var{version}"} string.
8579 @end deffn
8580
8581 @deffn {Scheme Procedure} package-name->name+version @var{name}
8582 Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
8583 values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
8584 unavailable, @var{name} and @code{#f} are returned. The first hyphen
8585 followed by a digit is considered to introduce the version part.
8586 @end deffn
8587
8588 @subsection File Types
8589
8590 The procedures below deal with files and file types.
8591
8592 @deffn {Scheme Procedure} directory-exists? @var{dir}
8593 Return @code{#t} if @var{dir} exists and is a directory.
8594 @end deffn
8595
8596 @deffn {Scheme Procedure} executable-file? @var{file}
8597 Return @code{#t} if @var{file} exists and is executable.
8598 @end deffn
8599
8600 @deffn {Scheme Procedure} symbolic-link? @var{file}
8601 Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
8602 @end deffn
8603
8604 @deffn {Scheme Procedure} elf-file? @var{file}
8605 @deffnx {Scheme Procedure} ar-file? @var{file}
8606 @deffnx {Scheme Procedure} gzip-file? @var{file}
8607 Return @code{#t} if @var{file} is, respectively, an ELF file, an
8608 @code{ar} archive (such as a @file{.a} static library), or a gzip file.
8609 @end deffn
8610
8611 @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
8612 If @var{file} is a gzip file, reset its embedded timestamp (as with
8613 @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
8614 When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
8615 @end deffn
8616
8617 @subsection File Manipulation
8618
8619 The following procedures and macros help create, modify, and delete
8620 files. They provide functionality comparable to common shell utilities
8621 such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
8622 @command{sed}. They complement Guile's extensive, but low-level, file
8623 system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
8624
8625 @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
8626 Run @var{body} with @var{directory} as the process's current directory.
8627
8628 Essentially, this macro changes the current directory to @var{directory}
8629 before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
8630 guile, GNU Guile Reference Manual}). It changes back to the initial
8631 directory when the dynamic extent of @var{body} is left, be it @i{via}
8632 normal procedure return or @i{via} a non-local exit such as an
8633 exception.
8634 @end deffn
8635
8636 @deffn {Scheme Procedure} mkdir-p @var{dir}
8637 Create directory @var{dir} and all its ancestors.
8638 @end deffn
8639
8640 @deffn {Scheme Procedure} install-file @var{file} @var{directory}
8641 Create @var{directory} if it does not exist and copy @var{file} in there
8642 under the same name.
8643 @end deffn
8644
8645 @deffn {Scheme Procedure} make-file-writable @var{file}
8646 Make @var{file} writable for its owner.
8647 @end deffn
8648
8649 @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
8650 [#:log (current-output-port)] [#:follow-symlinks? #f] [#:keep-mtime? #f]
8651 Copy @var{source} directory to @var{destination}. Follow symlinks if
8652 @var{follow-symlinks?} is true; otherwise, just preserve them. When
8653 @var{keep-mtime?} is true, keep the modification time of the files in
8654 @var{source} on those of @var{destination}. Write verbose output to the
8655 @var{log} port.
8656 @end deffn
8657
8658 @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
8659 [#:follow-mounts? #f]
8660 Delete @var{dir} recursively, like @command{rm -rf}, without following
8661 symlinks. Don't follow mount points either, unless @var{follow-mounts?}
8662 is true. Report but ignore errors.
8663 @end deffn
8664
8665 @deffn {Scheme Syntax} substitute* @var{file} @
8666 ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
8667 Substitute @var{regexp} in @var{file} by the string returned by
8668 @var{body}. @var{body} is evaluated with each @var{match-var} bound to
8669 the corresponding positional regexp sub-expression. For example:
8670
8671 @lisp
8672 (substitute* file
8673 (("hello")
8674 "good morning\n")
8675 (("foo([a-z]+)bar(.*)$" all letters end)
8676 (string-append "baz" letter end)))
8677 @end lisp
8678
8679 Here, anytime a line of @var{file} contains @code{hello}, it is replaced
8680 by @code{good morning}. Anytime a line of @var{file} matches the second
8681 regexp, @code{all} is bound to the complete match, @code{letters} is bound
8682 to the first sub-expression, and @code{end} is bound to the last one.
8683
8684 When one of the @var{match-var} is @code{_}, no variable is bound to the
8685 corresponding match substring.
8686
8687 Alternatively, @var{file} may be a list of file names, in which case
8688 they are all subject to the substitutions.
8689
8690 Be careful about using @code{$} to match the end of a line; by itself it
8691 won't match the terminating newline of a line.
8692 @end deffn
8693
8694 @subsection File Search
8695
8696 @cindex file, searching
8697 This section documents procedures to search and filter files.
8698
8699 @deffn {Scheme Procedure} file-name-predicate @var{regexp}
8700 Return a predicate that returns true when passed a file name whose base
8701 name matches @var{regexp}.
8702 @end deffn
8703
8704 @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
8705 [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
8706 Return the lexicographically sorted list of files under @var{dir} for
8707 which @var{pred} returns true. @var{pred} is passed two arguments: the
8708 absolute file name, and its stat buffer; the default predicate always
8709 returns true. @var{pred} can also be a regular expression, in which
8710 case it is equivalent to @code{(file-name-predicate @var{pred})}.
8711 @var{stat} is used to obtain file information; using @code{lstat} means
8712 that symlinks are not followed. If @var{directories?} is true, then
8713 directories will also be included. If @var{fail-on-error?} is true,
8714 raise an exception upon error.
8715 @end deffn
8716
8717 Here are a few examples where we assume that the current directory is
8718 the root of the Guix source tree:
8719
8720 @lisp
8721 ;; List all the regular files in the current directory.
8722 (find-files ".")
8723 @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
8724
8725 ;; List all the .scm files under gnu/services.
8726 (find-files "gnu/services" "\\.scm$")
8727 @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
8728
8729 ;; List ar files in the current directory.
8730 (find-files "." (lambda (file stat) (ar-file? file)))
8731 @result{} ("./libformat.a" "./libstore.a" @dots{})
8732 @end lisp
8733
8734 @deffn {Scheme Procedure} which @var{program}
8735 Return the complete file name for @var{program} as found in
8736 @code{$PATH}, or @code{#f} if @var{program} could not be found.
8737 @end deffn
8738
8739 @subsection Build Phases
8740
8741 @cindex build phases
8742 The @code{(guix build utils)} also contains tools to manipulate build
8743 phases as used by build systems (@pxref{Build Systems}). Build phases
8744 are represented as association lists or ``alists'' (@pxref{Association
8745 Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
8746 naming the phase and the associated value is a procedure (@pxref{Build
8747 Phases}).
8748
8749 Guile core and the @code{(srfi srfi-1)} module both provide tools to
8750 manipulate alists. The @code{(guix build utils)} module complements
8751 those with tools written with build phases in mind.
8752
8753 @cindex build phases, modifying
8754 @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
8755 Modify @var{phases} sequentially as per each @var{clause}, which may
8756 have one of the following forms:
8757
8758 @lisp
8759 (delete @var{old-phase-name})
8760 (replace @var{old-phase-name} @var{new-phase})
8761 (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
8762 (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
8763 @end lisp
8764
8765 Where every @var{phase-name} above is an expression evaluating to a
8766 symbol, and @var{new-phase} an expression evaluating to a procedure.
8767 @end deffn
8768
8769 The example below is taken from the definition of the @code{grep}
8770 package. It adds a phase to run after the @code{install} phase, called
8771 @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
8772 is for anonymous procedures) that takes a @code{#:outputs} keyword
8773 argument and ignores extra keyword arguments (@pxref{Optional
8774 Arguments,,, guile, GNU Guile Reference Manual}, for more on
8775 @code{lambda*} and optional and keyword arguments.) The phase uses
8776 @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
8777 scripts so that they refer to @code{grep} by its absolute file name:
8778
8779 @lisp
8780 (modify-phases %standard-phases
8781 (add-after 'install 'fix-egrep-and-fgrep
8782 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
8783 ;; absolute file name instead of searching for it in $PATH.
8784 (lambda* (#:key outputs #:allow-other-keys)
8785 (let* ((out (assoc-ref outputs "out"))
8786 (bin (string-append out "/bin")))
8787 (substitute* (list (string-append bin "/egrep")
8788 (string-append bin "/fgrep"))
8789 (("^exec grep")
8790 (string-append "exec " bin "/grep")))
8791 #t))))
8792 @end lisp
8793
8794 In the example below, phases are modified in two ways: the standard
8795 @code{configure} phase is deleted, presumably because the package does
8796 not have a @file{configure} script or anything similar, and the default
8797 @code{install} phase is replaced by one that manually copies the
8798 executable files to be installed:
8799
8800 @lisp
8801 (modify-phases %standard-phases
8802 (delete 'configure) ;no 'configure' script
8803 (replace 'install
8804 (lambda* (#:key outputs #:allow-other-keys)
8805 ;; The package's Makefile doesn't provide an "install"
8806 ;; rule so do it by ourselves.
8807 (let ((bin (string-append (assoc-ref outputs "out")
8808 "/bin")))
8809 (install-file "footswitch" bin)
8810 (install-file "scythe" bin)
8811 #t))))
8812 @end lisp
8813
8814 @c TODO: Add more examples.
8815
8816 @node The Store
8817 @section The Store
8818
8819 @cindex store
8820 @cindex store items
8821 @cindex store paths
8822
8823 Conceptually, the @dfn{store} is the place where derivations that have
8824 been built successfully are stored---by default, @file{/gnu/store}.
8825 Sub-directories in the store are referred to as @dfn{store items} or
8826 sometimes @dfn{store paths}. The store has an associated database that
8827 contains information such as the store paths referred to by each store
8828 path, and the list of @emph{valid} store items---results of successful
8829 builds. This database resides in @file{@var{localstatedir}/guix/db},
8830 where @var{localstatedir} is the state directory specified @i{via}
8831 @option{--localstatedir} at configure time, usually @file{/var}.
8832
8833 The store is @emph{always} accessed by the daemon on behalf of its clients
8834 (@pxref{Invoking guix-daemon}). To manipulate the store, clients
8835 connect to the daemon over a Unix-domain socket, send requests to it,
8836 and read the result---these are remote procedure calls, or RPCs.
8837
8838 @quotation Note
8839 Users must @emph{never} modify files under @file{/gnu/store} directly.
8840 This would lead to inconsistencies and break the immutability
8841 assumptions of Guix's functional model (@pxref{Introduction}).
8842
8843 @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
8844 how to check the integrity of the store and attempt recovery from
8845 accidental modifications.
8846 @end quotation
8847
8848 The @code{(guix store)} module provides procedures to connect to the
8849 daemon, and to perform RPCs. These are described below. By default,
8850 @code{open-connection}, and thus all the @command{guix} commands,
8851 connect to the local daemon or to the URI specified by the
8852 @env{GUIX_DAEMON_SOCKET} environment variable.
8853
8854 @defvr {Environment Variable} GUIX_DAEMON_SOCKET
8855 When set, the value of this variable should be a file name or a URI
8856 designating the daemon endpoint. When it is a file name, it denotes a
8857 Unix-domain socket to connect to. In addition to file names, the
8858 supported URI schemes are:
8859
8860 @table @code
8861 @item file
8862 @itemx unix
8863 These are for Unix-domain sockets.
8864 @code{file:///var/guix/daemon-socket/socket} is equivalent to
8865 @file{/var/guix/daemon-socket/socket}.
8866
8867 @item guix
8868 @cindex daemon, remote access
8869 @cindex remote access to the daemon
8870 @cindex daemon, cluster setup
8871 @cindex clusters, daemon setup
8872 These URIs denote connections over TCP/IP, without encryption nor
8873 authentication of the remote host. The URI must specify the host name
8874 and optionally a port number (by default port 44146 is used):
8875
8876 @example
8877 guix://master.guix.example.org:1234
8878 @end example
8879
8880 This setup is suitable on local networks, such as clusters, where only
8881 trusted nodes may connect to the build daemon at
8882 @code{master.guix.example.org}.
8883
8884 The @option{--listen} option of @command{guix-daemon} can be used to
8885 instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
8886 @option{--listen}}).
8887
8888 @item ssh
8889 @cindex SSH access to build daemons
8890 These URIs allow you to connect to a remote daemon over SSH@. This
8891 feature requires Guile-SSH (@pxref{Requirements}) and a working
8892 @command{guile} binary in @env{PATH} on the destination machine. It
8893 supports public key and GSSAPI authentication. A typical URL might look
8894 like this:
8895
8896 @example
8897 ssh://charlie@@guix.example.org:22
8898 @end example
8899
8900 As for @command{guix copy}, the usual OpenSSH client configuration files
8901 are honored (@pxref{Invoking guix copy}).
8902 @end table
8903
8904 Additional URI schemes may be supported in the future.
8905
8906 @c XXX: Remove this note when the protocol incurs fewer round trips
8907 @c and when (guix derivations) no longer relies on file system access.
8908 @quotation Note
8909 The ability to connect to remote build daemons is considered
8910 experimental as of @value{VERSION}. Please get in touch with us to
8911 share any problems or suggestions you may have (@pxref{Contributing}).
8912 @end quotation
8913 @end defvr
8914
8915 @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
8916 Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
8917 @var{reserve-space?} is true, instruct it to reserve a little bit of
8918 extra space on the file system so that the garbage collector can still
8919 operate should the disk become full. Return a server object.
8920
8921 @var{file} defaults to @code{%default-socket-path}, which is the normal
8922 location given the options that were passed to @command{configure}.
8923 @end deffn
8924
8925 @deffn {Scheme Procedure} close-connection @var{server}
8926 Close the connection to @var{server}.
8927 @end deffn
8928
8929 @defvr {Scheme Variable} current-build-output-port
8930 This variable is bound to a SRFI-39 parameter, which refers to the port
8931 where build and error logs sent by the daemon should be written.
8932 @end defvr
8933
8934 Procedures that make RPCs all take a server object as their first
8935 argument.
8936
8937 @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
8938 @cindex invalid store items
8939 Return @code{#t} when @var{path} designates a valid store item and
8940 @code{#f} otherwise (an invalid item may exist on disk but still be
8941 invalid, for instance because it is the result of an aborted or failed
8942 build).
8943
8944 A @code{&store-protocol-error} condition is raised if @var{path} is not
8945 prefixed by the store directory (@file{/gnu/store}).
8946 @end deffn
8947
8948 @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
8949 Add @var{text} under file @var{name} in the store, and return its store
8950 path. @var{references} is the list of store paths referred to by the
8951 resulting store path.
8952 @end deffn
8953
8954 @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
8955 [@var{mode}]
8956 Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
8957 file names, or derivation/output pairs, using the specified
8958 @var{mode}---@code{(build-mode normal)} by default.
8959 @end deffn
8960
8961 Note that the @code{(guix monads)} module provides a monad as well as
8962 monadic versions of the above procedures, with the goal of making it
8963 more convenient to work with code that accesses the store (@pxref{The
8964 Store Monad}).
8965
8966 @c FIXME
8967 @i{This section is currently incomplete.}
8968
8969 @node Derivations
8970 @section Derivations
8971
8972 @cindex derivations
8973 Low-level build actions and the environment in which they are performed
8974 are represented by @dfn{derivations}. A derivation contains the
8975 following pieces of information:
8976
8977 @itemize
8978 @item
8979 The outputs of the derivation---derivations produce at least one file or
8980 directory in the store, but may produce more.
8981
8982 @item
8983 @cindex build-time dependencies
8984 @cindex dependencies, build-time
8985 The inputs of the derivations---i.e., its build-time dependencies---which may
8986 be other derivations or plain files in the store (patches, build scripts,
8987 etc.).
8988
8989 @item
8990 The system type targeted by the derivation---e.g., @code{x86_64-linux}.
8991
8992 @item
8993 The file name of a build script in the store, along with the arguments
8994 to be passed.
8995
8996 @item
8997 A list of environment variables to be defined.
8998
8999 @end itemize
9000
9001 @cindex derivation path
9002 Derivations allow clients of the daemon to communicate build actions to
9003 the store. They exist in two forms: as an in-memory representation,
9004 both on the client- and daemon-side, and as files in the store whose
9005 name end in @file{.drv}---these files are referred to as @dfn{derivation
9006 paths}. Derivations paths can be passed to the @code{build-derivations}
9007 procedure to perform the build actions they prescribe (@pxref{The
9008 Store}).
9009
9010 @cindex fixed-output derivations
9011 Operations such as file downloads and version-control checkouts for
9012 which the expected content hash is known in advance are modeled as
9013 @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
9014 of a fixed-output derivation are independent of its inputs---e.g., a
9015 source code download produces the same result regardless of the download
9016 method and tools being used.
9017
9018 @cindex references
9019 @cindex run-time dependencies
9020 @cindex dependencies, run-time
9021 The outputs of derivations---i.e., the build results---have a set of
9022 @dfn{references}, as reported by the @code{references} RPC or the
9023 @command{guix gc --references} command (@pxref{Invoking guix gc}). References
9024 are the set of run-time dependencies of the build results. References are a
9025 subset of the inputs of the derivation; this subset is automatically computed
9026 by the build daemon by scanning all the files in the outputs.
9027
9028 The @code{(guix derivations)} module provides a representation of
9029 derivations as Scheme objects, along with procedures to create and
9030 otherwise manipulate derivations. The lowest-level primitive to create
9031 a derivation is the @code{derivation} procedure:
9032
9033 @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
9034 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
9035 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
9036 [#:system (%current-system)] [#:references-graphs #f] @
9037 [#:allowed-references #f] [#:disallowed-references #f] @
9038 [#:leaked-env-vars #f] [#:local-build? #f] @
9039 [#:substitutable? #t] [#:properties '()]
9040 Build a derivation with the given arguments, and return the resulting
9041 @code{<derivation>} object.
9042
9043 When @var{hash} and @var{hash-algo} are given, a
9044 @dfn{fixed-output derivation} is created---i.e., one whose result is
9045 known in advance, such as a file download. If, in addition,
9046 @var{recursive?} is true, then that fixed output may be an executable
9047 file or a directory and @var{hash} must be the hash of an archive
9048 containing this output.
9049
9050 When @var{references-graphs} is true, it must be a list of file
9051 name/store path pairs. In that case, the reference graph of each store
9052 path is exported in the build environment in the corresponding file, in
9053 a simple text format.
9054
9055 When @var{allowed-references} is true, it must be a list of store items
9056 or outputs that the derivation's output may refer to. Likewise,
9057 @var{disallowed-references}, if true, must be a list of things the
9058 outputs may @emph{not} refer to.
9059
9060 When @var{leaked-env-vars} is true, it must be a list of strings
9061 denoting environment variables that are allowed to ``leak'' from the
9062 daemon's environment to the build environment. This is only applicable
9063 to fixed-output derivations---i.e., when @var{hash} is true. The main
9064 use is to allow variables such as @code{http_proxy} to be passed to
9065 derivations that download files.
9066
9067 When @var{local-build?} is true, declare that the derivation is not a
9068 good candidate for offloading and should rather be built locally
9069 (@pxref{Daemon Offload Setup}). This is the case for small derivations
9070 where the costs of data transfers would outweigh the benefits.
9071
9072 When @var{substitutable?} is false, declare that substitutes of the
9073 derivation's output should not be used (@pxref{Substitutes}). This is
9074 useful, for instance, when building packages that capture details of the
9075 host CPU instruction set.
9076
9077 @var{properties} must be an association list describing ``properties'' of the
9078 derivation. It is kept as-is, uninterpreted, in the derivation.
9079 @end deffn
9080
9081 @noindent
9082 Here's an example with a shell script as its builder, assuming
9083 @var{store} is an open connection to the daemon, and @var{bash} points
9084 to a Bash executable in the store:
9085
9086 @lisp
9087 (use-modules (guix utils)
9088 (guix store)
9089 (guix derivations))
9090
9091 (let ((builder ; add the Bash script to the store
9092 (add-text-to-store store "my-builder.sh"
9093 "echo hello world > $out\n" '())))
9094 (derivation store "foo"
9095 bash `("-e" ,builder)
9096 #:inputs `((,bash) (,builder))
9097 #:env-vars '(("HOME" . "/homeless"))))
9098 @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
9099 @end lisp
9100
9101 As can be guessed, this primitive is cumbersome to use directly. A
9102 better approach is to write build scripts in Scheme, of course! The
9103 best course of action for that is to write the build code as a
9104 ``G-expression'', and to pass it to @code{gexp->derivation}. For more
9105 information, @pxref{G-Expressions}.
9106
9107 Once upon a time, @code{gexp->derivation} did not exist and constructing
9108 derivations with build code written in Scheme was achieved with
9109 @code{build-expression->derivation}, documented below. This procedure
9110 is now deprecated in favor of the much nicer @code{gexp->derivation}.
9111
9112 @deffn {Scheme Procedure} build-expression->derivation @var{store} @
9113 @var{name} @var{exp} @
9114 [#:system (%current-system)] [#:inputs '()] @
9115 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
9116 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
9117 [#:references-graphs #f] [#:allowed-references #f] @
9118 [#:disallowed-references #f] @
9119 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
9120 Return a derivation that executes Scheme expression @var{exp} as a
9121 builder for derivation @var{name}. @var{inputs} must be a list of
9122 @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
9123 @code{"out"} is assumed. @var{modules} is a list of names of Guile
9124 modules from the current search path to be copied in the store,
9125 compiled, and made available in the load path during the execution of
9126 @var{exp}---e.g., @code{((guix build utils) (guix build
9127 gnu-build-system))}.
9128
9129 @var{exp} is evaluated in an environment where @code{%outputs} is bound
9130 to a list of output/path pairs, and where @code{%build-inputs} is bound
9131 to a list of string/output-path pairs made from @var{inputs}.
9132 Optionally, @var{env-vars} is a list of string pairs specifying the name
9133 and value of environment variables visible to the builder. The builder
9134 terminates by passing the result of @var{exp} to @code{exit}; thus, when
9135 @var{exp} returns @code{#f}, the build is considered to have failed.
9136
9137 @var{exp} is built using @var{guile-for-build} (a derivation). When
9138 @var{guile-for-build} is omitted or is @code{#f}, the value of the
9139 @code{%guile-for-build} fluid is used instead.
9140
9141 See the @code{derivation} procedure for the meaning of
9142 @var{references-graphs}, @var{allowed-references},
9143 @var{disallowed-references}, @var{local-build?}, and
9144 @var{substitutable?}.
9145 @end deffn
9146
9147 @noindent
9148 Here's an example of a single-output derivation that creates a directory
9149 containing one file:
9150
9151 @lisp
9152 (let ((builder '(let ((out (assoc-ref %outputs "out")))
9153 (mkdir out) ; create /gnu/store/@dots{}-goo
9154 (call-with-output-file (string-append out "/test")
9155 (lambda (p)
9156 (display '(hello guix) p))))))
9157 (build-expression->derivation store "goo" builder))
9158
9159 @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
9160 @end lisp
9161
9162
9163 @node The Store Monad
9164 @section The Store Monad
9165
9166 @cindex monad
9167
9168 The procedures that operate on the store described in the previous
9169 sections all take an open connection to the build daemon as their first
9170 argument. Although the underlying model is functional, they either have
9171 side effects or depend on the current state of the store.
9172
9173 The former is inconvenient: the connection to the build daemon has to be
9174 carried around in all those functions, making it impossible to compose
9175 functions that do not take that parameter with functions that do. The
9176 latter can be problematic: since store operations have side effects
9177 and/or depend on external state, they have to be properly sequenced.
9178
9179 @cindex monadic values
9180 @cindex monadic functions
9181 This is where the @code{(guix monads)} module comes in. This module
9182 provides a framework for working with @dfn{monads}, and a particularly
9183 useful monad for our uses, the @dfn{store monad}. Monads are a
9184 construct that allows two things: associating ``context'' with values
9185 (in our case, the context is the store), and building sequences of
9186 computations (here computations include accesses to the store). Values
9187 in a monad---values that carry this additional context---are called
9188 @dfn{monadic values}; procedures that return such values are called
9189 @dfn{monadic procedures}.
9190
9191 Consider this ``normal'' procedure:
9192
9193 @lisp
9194 (define (sh-symlink store)
9195 ;; Return a derivation that symlinks the 'bash' executable.
9196 (let* ((drv (package-derivation store bash))
9197 (out (derivation->output-path drv))
9198 (sh (string-append out "/bin/bash")))
9199 (build-expression->derivation store "sh"
9200 `(symlink ,sh %output))))
9201 @end lisp
9202
9203 Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
9204 as a monadic function:
9205
9206 @lisp
9207 (define (sh-symlink)
9208 ;; Same, but return a monadic value.
9209 (mlet %store-monad ((drv (package->derivation bash)))
9210 (gexp->derivation "sh"
9211 #~(symlink (string-append #$drv "/bin/bash")
9212 #$output))))
9213 @end lisp
9214
9215 There are several things to note in the second version: the @code{store}
9216 parameter is now implicit and is ``threaded'' in the calls to the
9217 @code{package->derivation} and @code{gexp->derivation} monadic
9218 procedures, and the monadic value returned by @code{package->derivation}
9219 is @dfn{bound} using @code{mlet} instead of plain @code{let}.
9220
9221 As it turns out, the call to @code{package->derivation} can even be
9222 omitted since it will take place implicitly, as we will see later
9223 (@pxref{G-Expressions}):
9224
9225 @lisp
9226 (define (sh-symlink)
9227 (gexp->derivation "sh"
9228 #~(symlink (string-append #$bash "/bin/bash")
9229 #$output)))
9230 @end lisp
9231
9232 @c See
9233 @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
9234 @c for the funny quote.
9235 Calling the monadic @code{sh-symlink} has no effect. As someone once
9236 said, ``you exit a monad like you exit a building on fire: by running''.
9237 So, to exit the monad and get the desired effect, one must use
9238 @code{run-with-store}:
9239
9240 @lisp
9241 (run-with-store (open-connection) (sh-symlink))
9242 @result{} /gnu/store/...-sh-symlink
9243 @end lisp
9244
9245 Note that the @code{(guix monad-repl)} module extends the Guile REPL with
9246 new ``meta-commands'' to make it easier to deal with monadic procedures:
9247 @code{run-in-store}, and @code{enter-store-monad}. The former is used
9248 to ``run'' a single monadic value through the store:
9249
9250 @example
9251 scheme@@(guile-user)> ,run-in-store (package->derivation hello)
9252 $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
9253 @end example
9254
9255 The latter enters a recursive REPL, where all the return values are
9256 automatically run through the store:
9257
9258 @example
9259 scheme@@(guile-user)> ,enter-store-monad
9260 store-monad@@(guile-user) [1]> (package->derivation hello)
9261 $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
9262 store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
9263 $3 = "/gnu/store/@dots{}-foo"
9264 store-monad@@(guile-user) [1]> ,q
9265 scheme@@(guile-user)>
9266 @end example
9267
9268 @noindent
9269 Note that non-monadic values cannot be returned in the
9270 @code{store-monad} REPL.
9271
9272 The main syntactic forms to deal with monads in general are provided by
9273 the @code{(guix monads)} module and are described below.
9274
9275 @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
9276 Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
9277 in @var{monad}.
9278 @end deffn
9279
9280 @deffn {Scheme Syntax} return @var{val}
9281 Return a monadic value that encapsulates @var{val}.
9282 @end deffn
9283
9284 @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
9285 @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
9286 procedures @var{mproc}@dots{}@footnote{This operation is commonly
9287 referred to as ``bind'', but that name denotes an unrelated procedure in
9288 Guile. Thus we use this somewhat cryptic symbol inherited from the
9289 Haskell language.}. There can be one @var{mproc} or several of them, as
9290 in this example:
9291
9292 @lisp
9293 (run-with-state
9294 (with-monad %state-monad
9295 (>>= (return 1)
9296 (lambda (x) (return (+ 1 x)))
9297 (lambda (x) (return (* 2 x)))))
9298 'some-state)
9299
9300 @result{} 4
9301 @result{} some-state
9302 @end lisp
9303 @end deffn
9304
9305 @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
9306 @var{body} ...
9307 @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
9308 @var{body} ...
9309 Bind the variables @var{var} to the monadic values @var{mval} in
9310 @var{body}, which is a sequence of expressions. As with the bind
9311 operator, this can be thought of as ``unpacking'' the raw, non-monadic
9312 value ``contained'' in @var{mval} and making @var{var} refer to that
9313 raw, non-monadic value within the scope of the @var{body}. The form
9314 (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
9315 @var{val}, as per @code{let}. The binding operations occur in sequence
9316 from left to right. The last expression of @var{body} must be a monadic
9317 expression, and its result will become the result of the @code{mlet} or
9318 @code{mlet*} when run in the @var{monad}.
9319
9320 @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
9321 (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
9322 @end deffn
9323
9324 @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
9325 Bind @var{mexp} and the following monadic expressions in sequence,
9326 returning the result of the last expression. Every expression in the
9327 sequence must be a monadic expression.
9328
9329 This is akin to @code{mlet}, except that the return values of the
9330 monadic expressions are ignored. In that sense, it is analogous to
9331 @code{begin}, but applied to monadic expressions.
9332 @end deffn
9333
9334 @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
9335 When @var{condition} is true, evaluate the sequence of monadic
9336 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
9337 @var{condition} is false, return @code{*unspecified*} in the current
9338 monad. Every expression in the sequence must be a monadic expression.
9339 @end deffn
9340
9341 @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
9342 When @var{condition} is false, evaluate the sequence of monadic
9343 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
9344 @var{condition} is true, return @code{*unspecified*} in the current
9345 monad. Every expression in the sequence must be a monadic expression.
9346 @end deffn
9347
9348 @cindex state monad
9349 The @code{(guix monads)} module provides the @dfn{state monad}, which
9350 allows an additional value---the state---to be @emph{threaded} through
9351 monadic procedure calls.
9352
9353 @defvr {Scheme Variable} %state-monad
9354 The state monad. Procedures in the state monad can access and change
9355 the state that is threaded.
9356
9357 Consider the example below. The @code{square} procedure returns a value
9358 in the state monad. It returns the square of its argument, but also
9359 increments the current state value:
9360
9361 @lisp
9362 (define (square x)
9363 (mlet %state-monad ((count (current-state)))
9364 (mbegin %state-monad
9365 (set-current-state (+ 1 count))
9366 (return (* x x)))))
9367
9368 (run-with-state (sequence %state-monad (map square (iota 3))) 0)
9369 @result{} (0 1 4)
9370 @result{} 3
9371 @end lisp
9372
9373 When ``run'' through @code{%state-monad}, we obtain that additional state
9374 value, which is the number of @code{square} calls.
9375 @end defvr
9376
9377 @deffn {Monadic Procedure} current-state
9378 Return the current state as a monadic value.
9379 @end deffn
9380
9381 @deffn {Monadic Procedure} set-current-state @var{value}
9382 Set the current state to @var{value} and return the previous state as a
9383 monadic value.
9384 @end deffn
9385
9386 @deffn {Monadic Procedure} state-push @var{value}
9387 Push @var{value} to the current state, which is assumed to be a list,
9388 and return the previous state as a monadic value.
9389 @end deffn
9390
9391 @deffn {Monadic Procedure} state-pop
9392 Pop a value from the current state and return it as a monadic value.
9393 The state is assumed to be a list.
9394 @end deffn
9395
9396 @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
9397 Run monadic value @var{mval} starting with @var{state} as the initial
9398 state. Return two values: the resulting value, and the resulting state.
9399 @end deffn
9400
9401 The main interface to the store monad, provided by the @code{(guix
9402 store)} module, is as follows.
9403
9404 @defvr {Scheme Variable} %store-monad
9405 The store monad---an alias for @code{%state-monad}.
9406
9407 Values in the store monad encapsulate accesses to the store. When its
9408 effect is needed, a value of the store monad must be ``evaluated'' by
9409 passing it to the @code{run-with-store} procedure (see below).
9410 @end defvr
9411
9412 @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
9413 Run @var{mval}, a monadic value in the store monad, in @var{store}, an
9414 open store connection.
9415 @end deffn
9416
9417 @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
9418 Return as a monadic value the absolute file name in the store of the file
9419 containing @var{text}, a string. @var{references} is a list of store items that the
9420 resulting text file refers to; it defaults to the empty list.
9421 @end deffn
9422
9423 @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
9424 Return as a monadic value the absolute file name in the store of the file
9425 containing @var{data}, a bytevector. @var{references} is a list of store
9426 items that the resulting binary file refers to; it defaults to the empty list.
9427 @end deffn
9428
9429 @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
9430 [#:recursive? #t] [#:select? (const #t)]
9431 Return the name of @var{file} once interned in the store. Use
9432 @var{name} as its store name, or the basename of @var{file} if
9433 @var{name} is omitted.
9434
9435 When @var{recursive?} is true, the contents of @var{file} are added
9436 recursively; if @var{file} designates a flat file and @var{recursive?}
9437 is true, its contents are added, and its permission bits are kept.
9438
9439 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
9440 @var{stat})} for each directory entry, where @var{file} is the entry's
9441 absolute file name and @var{stat} is the result of @code{lstat}; exclude
9442 entries for which @var{select?} does not return true.
9443
9444 The example below adds a file to the store, under two different names:
9445
9446 @lisp
9447 (run-with-store (open-connection)
9448 (mlet %store-monad ((a (interned-file "README"))
9449 (b (interned-file "README" "LEGU-MIN")))
9450 (return (list a b))))
9451
9452 @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
9453 @end lisp
9454
9455 @end deffn
9456
9457 The @code{(guix packages)} module exports the following package-related
9458 monadic procedures:
9459
9460 @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
9461 [#:system (%current-system)] [#:target #f] @
9462 [#:output "out"]
9463 Return as a monadic
9464 value in the absolute file name of @var{file} within the @var{output}
9465 directory of @var{package}. When @var{file} is omitted, return the name
9466 of the @var{output} directory of @var{package}. When @var{target} is
9467 true, use it as a cross-compilation target triplet.
9468
9469 Note that this procedure does @emph{not} build @var{package}. Thus, the
9470 result might or might not designate an existing file. We recommend not
9471 using this procedure unless you know what you are doing.
9472 @end deffn
9473
9474 @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
9475 @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
9476 @var{target} [@var{system}]
9477 Monadic version of @code{package-derivation} and
9478 @code{package-cross-derivation} (@pxref{Defining Packages}).
9479 @end deffn
9480
9481
9482 @node G-Expressions
9483 @section G-Expressions
9484
9485 @cindex G-expression
9486 @cindex build code quoting
9487 So we have ``derivations'', which represent a sequence of build actions
9488 to be performed to produce an item in the store (@pxref{Derivations}).
9489 These build actions are performed when asking the daemon to actually
9490 build the derivations; they are run by the daemon in a container
9491 (@pxref{Invoking guix-daemon}).
9492
9493 @cindex code staging
9494 @cindex staging, of code
9495 @cindex strata of code
9496 It should come as no surprise that we like to write these build actions
9497 in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
9498 code@footnote{The term @dfn{stratum} in this context was coined by
9499 Manuel Serrano et al.@: in the context of their work on Hop. Oleg
9500 Kiselyov, who has written insightful
9501 @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
9502 on this topic}, refers to this kind of code generation as
9503 @dfn{staging}.}: the ``host code''---code that defines packages, talks
9504 to the daemon, etc.---and the ``build code''---code that actually
9505 performs build actions, such as making directories, invoking
9506 @command{make}, and so on (@pxref{Build Phases}).
9507
9508 To describe a derivation and its build actions, one typically needs to
9509 embed build code inside host code. It boils down to manipulating build
9510 code as data, and the homoiconicity of Scheme---code has a direct
9511 representation as data---comes in handy for that. But we need more than
9512 the normal @code{quasiquote} mechanism in Scheme to construct build
9513 expressions.
9514
9515 The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
9516 S-expressions adapted to build expressions. G-expressions, or
9517 @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
9518 @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
9519 @code{#$}, and @code{#$@@}), which are comparable to
9520 @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
9521 respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
9522 GNU Guile Reference Manual}). However, there are major differences:
9523
9524 @itemize
9525 @item
9526 Gexps are meant to be written to a file and run or manipulated by other
9527 processes.
9528
9529 @item
9530 When a high-level object such as a package or derivation is unquoted
9531 inside a gexp, the result is as if its output file name had been
9532 introduced.
9533
9534 @item
9535 Gexps carry information about the packages or derivations they refer to,
9536 and these dependencies are automatically added as inputs to the build
9537 processes that use them.
9538 @end itemize
9539
9540 @cindex lowering, of high-level objects in gexps
9541 This mechanism is not limited to package and derivation
9542 objects: @dfn{compilers} able to ``lower'' other high-level objects to
9543 derivations or files in the store can be defined,
9544 such that these objects can also be inserted
9545 into gexps. For example, a useful type of high-level objects that can be
9546 inserted in a gexp is ``file-like objects'', which make it easy to
9547 add files to the store and to refer to them in
9548 derivations and such (see @code{local-file} and @code{plain-file}
9549 below).
9550
9551 To illustrate the idea, here is an example of a gexp:
9552
9553 @lisp
9554 (define build-exp
9555 #~(begin
9556 (mkdir #$output)
9557 (chdir #$output)
9558 (symlink (string-append #$coreutils "/bin/ls")
9559 "list-files")))
9560 @end lisp
9561
9562 This gexp can be passed to @code{gexp->derivation}; we obtain a
9563 derivation that builds a directory containing exactly one symlink to
9564 @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
9565
9566 @lisp
9567 (gexp->derivation "the-thing" build-exp)
9568 @end lisp
9569
9570 As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
9571 substituted to the reference to the @var{coreutils} package in the
9572 actual build code, and @var{coreutils} is automatically made an input to
9573 the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
9574 output)}) is replaced by a string containing the directory name of the
9575 output of the derivation.
9576
9577 @cindex cross compilation
9578 In a cross-compilation context, it is useful to distinguish between
9579 references to the @emph{native} build of a package---that can run on the
9580 host---versus references to cross builds of a package. To that end, the
9581 @code{#+} plays the same role as @code{#$}, but is a reference to a
9582 native package build:
9583
9584 @lisp
9585 (gexp->derivation "vi"
9586 #~(begin
9587 (mkdir #$output)
9588 (mkdir (string-append #$output "/bin"))
9589 (system* (string-append #+coreutils "/bin/ln")
9590 "-s"
9591 (string-append #$emacs "/bin/emacs")
9592 (string-append #$output "/bin/vi")))
9593 #:target "aarch64-linux-gnu")
9594 @end lisp
9595
9596 @noindent
9597 In the example above, the native build of @var{coreutils} is used, so
9598 that @command{ln} can actually run on the host; but then the
9599 cross-compiled build of @var{emacs} is referenced.
9600
9601 @cindex imported modules, for gexps
9602 @findex with-imported-modules
9603 Another gexp feature is @dfn{imported modules}: sometimes you want to be
9604 able to use certain Guile modules from the ``host environment'' in the
9605 gexp, so those modules should be imported in the ``build environment''.
9606 The @code{with-imported-modules} form allows you to express that:
9607
9608 @lisp
9609 (let ((build (with-imported-modules '((guix build utils))
9610 #~(begin
9611 (use-modules (guix build utils))
9612 (mkdir-p (string-append #$output "/bin"))))))
9613 (gexp->derivation "empty-dir"
9614 #~(begin
9615 #$build
9616 (display "success!\n")
9617 #t)))
9618 @end lisp
9619
9620 @noindent
9621 In this example, the @code{(guix build utils)} module is automatically
9622 pulled into the isolated build environment of our gexp, such that
9623 @code{(use-modules (guix build utils))} works as expected.
9624
9625 @cindex module closure
9626 @findex source-module-closure
9627 Usually you want the @emph{closure} of the module to be imported---i.e.,
9628 the module itself and all the modules it depends on---rather than just
9629 the module; failing to do that, attempts to use the module will fail
9630 because of missing dependent modules. The @code{source-module-closure}
9631 procedure computes the closure of a module by looking at its source file
9632 headers, which comes in handy in this case:
9633
9634 @lisp
9635 (use-modules (guix modules)) ;for 'source-module-closure'
9636
9637 (with-imported-modules (source-module-closure
9638 '((guix build utils)
9639 (gnu build vm)))
9640 (gexp->derivation "something-with-vms"
9641 #~(begin
9642 (use-modules (guix build utils)
9643 (gnu build vm))
9644 @dots{})))
9645 @end lisp
9646
9647 @cindex extensions, for gexps
9648 @findex with-extensions
9649 In the same vein, sometimes you want to import not just pure-Scheme
9650 modules, but also ``extensions'' such as Guile bindings to C libraries
9651 or other ``full-blown'' packages. Say you need the @code{guile-json}
9652 package available on the build side, here's how you would do it:
9653
9654 @lisp
9655 (use-modules (gnu packages guile)) ;for 'guile-json'
9656
9657 (with-extensions (list guile-json)
9658 (gexp->derivation "something-with-json"
9659 #~(begin
9660 (use-modules (json))
9661 @dots{})))
9662 @end lisp
9663
9664 The syntactic form to construct gexps is summarized below.
9665
9666 @deffn {Scheme Syntax} #~@var{exp}
9667 @deffnx {Scheme Syntax} (gexp @var{exp})
9668 Return a G-expression containing @var{exp}. @var{exp} may contain one
9669 or more of the following forms:
9670
9671 @table @code
9672 @item #$@var{obj}
9673 @itemx (ungexp @var{obj})
9674 Introduce a reference to @var{obj}. @var{obj} may have one of the
9675 supported types, for example a package or a
9676 derivation, in which case the @code{ungexp} form is replaced by its
9677 output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
9678
9679 If @var{obj} is a list, it is traversed and references to supported
9680 objects are substituted similarly.
9681
9682 If @var{obj} is another gexp, its contents are inserted and its
9683 dependencies are added to those of the containing gexp.
9684
9685 If @var{obj} is another kind of object, it is inserted as is.
9686
9687 @item #$@var{obj}:@var{output}
9688 @itemx (ungexp @var{obj} @var{output})
9689 This is like the form above, but referring explicitly to the
9690 @var{output} of @var{obj}---this is useful when @var{obj} produces
9691 multiple outputs (@pxref{Packages with Multiple Outputs}).
9692
9693 @item #+@var{obj}
9694 @itemx #+@var{obj}:output
9695 @itemx (ungexp-native @var{obj})
9696 @itemx (ungexp-native @var{obj} @var{output})
9697 Same as @code{ungexp}, but produces a reference to the @emph{native}
9698 build of @var{obj} when used in a cross compilation context.
9699
9700 @item #$output[:@var{output}]
9701 @itemx (ungexp output [@var{output}])
9702 Insert a reference to derivation output @var{output}, or to the main
9703 output when @var{output} is omitted.
9704
9705 This only makes sense for gexps passed to @code{gexp->derivation}.
9706
9707 @item #$@@@var{lst}
9708 @itemx (ungexp-splicing @var{lst})
9709 Like the above, but splices the contents of @var{lst} inside the
9710 containing list.
9711
9712 @item #+@@@var{lst}
9713 @itemx (ungexp-native-splicing @var{lst})
9714 Like the above, but refers to native builds of the objects listed in
9715 @var{lst}.
9716
9717 @end table
9718
9719 G-expressions created by @code{gexp} or @code{#~} are run-time objects
9720 of the @code{gexp?} type (see below).
9721 @end deffn
9722
9723 @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
9724 Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
9725 in their execution environment.
9726
9727 Each item in @var{modules} can be the name of a module, such as
9728 @code{(guix build utils)}, or it can be a module name, followed by an
9729 arrow, followed by a file-like object:
9730
9731 @lisp
9732 `((guix build utils)
9733 (guix gcrypt)
9734 ((guix config) => ,(scheme-file "config.scm"
9735 #~(define-module @dots{}))))
9736 @end lisp
9737
9738 @noindent
9739 In the example above, the first two modules are taken from the search
9740 path, and the last one is created from the given file-like object.
9741
9742 This form has @emph{lexical} scope: it has an effect on the gexps
9743 directly defined in @var{body}@dots{}, but not on those defined, say, in
9744 procedures called from @var{body}@dots{}.
9745 @end deffn
9746
9747 @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
9748 Mark the gexps defined in @var{body}@dots{} as requiring
9749 @var{extensions} in their build and execution environment.
9750 @var{extensions} is typically a list of package objects such as those
9751 defined in the @code{(gnu packages guile)} module.
9752
9753 Concretely, the packages listed in @var{extensions} are added to the
9754 load path while compiling imported modules in @var{body}@dots{}; they
9755 are also added to the load path of the gexp returned by
9756 @var{body}@dots{}.
9757 @end deffn
9758
9759 @deffn {Scheme Procedure} gexp? @var{obj}
9760 Return @code{#t} if @var{obj} is a G-expression.
9761 @end deffn
9762
9763 G-expressions are meant to be written to disk, either as code building
9764 some derivation, or as plain files in the store. The monadic procedures
9765 below allow you to do that (@pxref{The Store Monad}, for more
9766 information about monads).
9767
9768 @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
9769 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
9770 [#:hash #f] [#:hash-algo #f] @
9771 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
9772 [#:module-path @code{%load-path}] @
9773 [#:effective-version "2.2"] @
9774 [#:references-graphs #f] [#:allowed-references #f] @
9775 [#:disallowed-references #f] @
9776 [#:leaked-env-vars #f] @
9777 [#:script-name (string-append @var{name} "-builder")] @
9778 [#:deprecation-warnings #f] @
9779 [#:local-build? #f] [#:substitutable? #t] @
9780 [#:properties '()] [#:guile-for-build #f]
9781 Return a derivation @var{name} that runs @var{exp} (a gexp) with
9782 @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
9783 stored in a file called @var{script-name}. When @var{target} is true,
9784 it is used as the cross-compilation target triplet for packages referred
9785 to by @var{exp}.
9786
9787 @var{modules} is deprecated in favor of @code{with-imported-modules}.
9788 Its meaning is to
9789 make @var{modules} available in the evaluation context of @var{exp};
9790 @var{modules} is a list of names of Guile modules searched in
9791 @var{module-path} to be copied in the store, compiled, and made available in
9792 the load path during the execution of @var{exp}---e.g., @code{((guix
9793 build utils) (guix build gnu-build-system))}.
9794
9795 @var{effective-version} determines the string to use when adding extensions of
9796 @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
9797
9798 @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
9799 applicable.
9800
9801 When @var{references-graphs} is true, it must be a list of tuples of one of the
9802 following forms:
9803
9804 @example
9805 (@var{file-name} @var{package})
9806 (@var{file-name} @var{package} @var{output})
9807 (@var{file-name} @var{derivation})
9808 (@var{file-name} @var{derivation} @var{output})
9809 (@var{file-name} @var{store-item})
9810 @end example
9811
9812 The right-hand-side of each element of @var{references-graphs} is automatically made
9813 an input of the build process of @var{exp}. In the build environment, each
9814 @var{file-name} contains the reference graph of the corresponding item, in a simple
9815 text format.
9816
9817 @var{allowed-references} must be either @code{#f} or a list of output names and packages.
9818 In the latter case, the list denotes store items that the result is allowed to
9819 refer to. Any reference to another store item will lead to a build error.
9820 Similarly for @var{disallowed-references}, which can list items that must not be
9821 referenced by the outputs.
9822
9823 @var{deprecation-warnings} determines whether to show deprecation warnings while
9824 compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
9825
9826 The other arguments are as for @code{derivation} (@pxref{Derivations}).
9827 @end deffn
9828
9829 @cindex file-like objects
9830 The @code{local-file}, @code{plain-file}, @code{computed-file},
9831 @code{program-file}, and @code{scheme-file} procedures below return
9832 @dfn{file-like objects}. That is, when unquoted in a G-expression,
9833 these objects lead to a file in the store. Consider this G-expression:
9834
9835 @lisp
9836 #~(system* #$(file-append glibc "/sbin/nscd") "-f"
9837 #$(local-file "/tmp/my-nscd.conf"))
9838 @end lisp
9839
9840 The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
9841 to the store. Once expanded, for instance @i{via}
9842 @code{gexp->derivation}, the G-expression refers to that copy under
9843 @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
9844 does not have any effect on what the G-expression does.
9845 @code{plain-file} can be used similarly; it differs in that the file
9846 content is directly passed as a string.
9847
9848 @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
9849 [#:recursive? #f] [#:select? (const #t)]
9850 Return an object representing local file @var{file} to add to the store;
9851 this object can be used in a gexp. If @var{file} is a literal string
9852 denoting a relative file name, it is looked up relative to the source
9853 file where it appears; if @var{file} is not a literal string, it is
9854 looked up relative to the current working directory at run time.
9855 @var{file} will be added to the store under @var{name}--by default the
9856 base name of @var{file}.
9857
9858 When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
9859 designates a flat file and @var{recursive?} is true, its contents are added, and its
9860 permission bits are kept.
9861
9862 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
9863 @var{stat})} for each directory entry, where @var{file} is the entry's
9864 absolute file name and @var{stat} is the result of @code{lstat}; exclude
9865 entries for which @var{select?} does not return true.
9866
9867 This is the declarative counterpart of the @code{interned-file} monadic
9868 procedure (@pxref{The Store Monad, @code{interned-file}}).
9869 @end deffn
9870
9871 @deffn {Scheme Procedure} plain-file @var{name} @var{content}
9872 Return an object representing a text file called @var{name} with the given
9873 @var{content} (a string or a bytevector) to be added to the store.
9874
9875 This is the declarative counterpart of @code{text-file}.
9876 @end deffn
9877
9878 @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
9879 [#:local-build? #t]
9880 [#:options '()]
9881 Return an object representing the store item @var{name}, a file or
9882 directory computed by @var{gexp}. When @var{local-build?} is true (the
9883 default), the derivation is built locally. @var{options} is a list of
9884 additional arguments to pass to @code{gexp->derivation}.
9885
9886 This is the declarative counterpart of @code{gexp->derivation}.
9887 @end deffn
9888
9889 @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
9890 [#:guile (default-guile)] [#:module-path %load-path] @
9891 [#:system (%current-system)] [#:target #f]
9892 Return an executable script @var{name} that runs @var{exp} using
9893 @var{guile}, with @var{exp}'s imported modules in its search path.
9894 Look up @var{exp}'s modules in @var{module-path}.
9895
9896 The example below builds a script that simply invokes the @command{ls}
9897 command:
9898
9899 @lisp
9900 (use-modules (guix gexp) (gnu packages base))
9901
9902 (gexp->script "list-files"
9903 #~(execl #$(file-append coreutils "/bin/ls")
9904 "ls"))
9905 @end lisp
9906
9907 When ``running'' it through the store (@pxref{The Store Monad,
9908 @code{run-with-store}}), we obtain a derivation that produces an
9909 executable file @file{/gnu/store/@dots{}-list-files} along these lines:
9910
9911 @example
9912 #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
9913 !#
9914 (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
9915 @end example
9916 @end deffn
9917
9918 @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
9919 [#:guile #f] [#:module-path %load-path]
9920 Return an object representing the executable store item @var{name} that
9921 runs @var{gexp}. @var{guile} is the Guile package used to execute that
9922 script. Imported modules of @var{gexp} are looked up in @var{module-path}.
9923
9924 This is the declarative counterpart of @code{gexp->script}.
9925 @end deffn
9926
9927 @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
9928 [#:set-load-path? #t] [#:module-path %load-path] @
9929 [#:splice? #f] @
9930 [#:guile (default-guile)]
9931 Return a derivation that builds a file @var{name} containing @var{exp}.
9932 When @var{splice?} is true, @var{exp} is considered to be a list of
9933 expressions that will be spliced in the resulting file.
9934
9935 When @var{set-load-path?} is true, emit code in the resulting file to
9936 set @code{%load-path} and @code{%load-compiled-path} to honor
9937 @var{exp}'s imported modules. Look up @var{exp}'s modules in
9938 @var{module-path}.
9939
9940 The resulting file holds references to all the dependencies of @var{exp}
9941 or a subset thereof.
9942 @end deffn
9943
9944 @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
9945 [#:splice? #f] [#:set-load-path? #t]
9946 Return an object representing the Scheme file @var{name} that contains
9947 @var{exp}.
9948
9949 This is the declarative counterpart of @code{gexp->file}.
9950 @end deffn
9951
9952 @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
9953 Return as a monadic value a derivation that builds a text file
9954 containing all of @var{text}. @var{text} may list, in addition to
9955 strings, objects of any type that can be used in a gexp: packages,
9956 derivations, local file objects, etc. The resulting store file holds
9957 references to all these.
9958
9959 This variant should be preferred over @code{text-file} anytime the file
9960 to create will reference items from the store. This is typically the
9961 case when building a configuration file that embeds store file names,
9962 like this:
9963
9964 @lisp
9965 (define (profile.sh)
9966 ;; Return the name of a shell script in the store that
9967 ;; initializes the 'PATH' environment variable.
9968 (text-file* "profile.sh"
9969 "export PATH=" coreutils "/bin:"
9970 grep "/bin:" sed "/bin\n"))
9971 @end lisp
9972
9973 In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
9974 will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
9975 preventing them from being garbage-collected during its lifetime.
9976 @end deffn
9977
9978 @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
9979 Return an object representing store file @var{name} containing
9980 @var{text}. @var{text} is a sequence of strings and file-like objects,
9981 as in:
9982
9983 @lisp
9984 (mixed-text-file "profile"
9985 "export PATH=" coreutils "/bin:" grep "/bin")
9986 @end lisp
9987
9988 This is the declarative counterpart of @code{text-file*}.
9989 @end deffn
9990
9991 @deffn {Scheme Procedure} file-union @var{name} @var{files}
9992 Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
9993 Each item in @var{files} must be a two-element list where the first element is the
9994 file name to use in the new directory, and the second element is a gexp
9995 denoting the target file. Here's an example:
9996
9997 @lisp
9998 (file-union "etc"
9999 `(("hosts" ,(plain-file "hosts"
10000 "127.0.0.1 localhost"))
10001 ("bashrc" ,(plain-file "bashrc"
10002 "alias ls='ls --color=auto'"))))
10003 @end lisp
10004
10005 This yields an @code{etc} directory containing these two files.
10006 @end deffn
10007
10008 @deffn {Scheme Procedure} directory-union @var{name} @var{things}
10009 Return a directory that is the union of @var{things}, where @var{things} is a list of
10010 file-like objects denoting directories. For example:
10011
10012 @lisp
10013 (directory-union "guile+emacs" (list guile emacs))
10014 @end lisp
10015
10016 yields a directory that is the union of the @code{guile} and @code{emacs} packages.
10017 @end deffn
10018
10019 @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
10020 Return a file-like object that expands to the concatenation of @var{obj}
10021 and @var{suffix}, where @var{obj} is a lowerable object and each
10022 @var{suffix} is a string.
10023
10024 As an example, consider this gexp:
10025
10026 @lisp
10027 (gexp->script "run-uname"
10028 #~(system* #$(file-append coreutils
10029 "/bin/uname")))
10030 @end lisp
10031
10032 The same effect could be achieved with:
10033
10034 @lisp
10035 (gexp->script "run-uname"
10036 #~(system* (string-append #$coreutils
10037 "/bin/uname")))
10038 @end lisp
10039
10040 There is one difference though: in the @code{file-append} case, the
10041 resulting script contains the absolute file name as a string, whereas in
10042 the second case, the resulting script contains a @code{(string-append
10043 @dots{})} expression to construct the file name @emph{at run time}.
10044 @end deffn
10045
10046 @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
10047 @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
10048 Bind @var{system} to the currently targeted system---e.g.,
10049 @code{"x86_64-linux"}---within @var{body}.
10050
10051 In the second case, additionally bind @var{target} to the current
10052 cross-compilation target---a GNU triplet such as
10053 @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
10054 cross-compiling.
10055
10056 @code{let-system} is useful in the occasional case where the object
10057 spliced into the gexp depends on the target system, as in this example:
10058
10059 @lisp
10060 #~(system*
10061 #+(let-system system
10062 (cond ((string-prefix? "armhf-" system)
10063 (file-append qemu "/bin/qemu-system-arm"))
10064 ((string-prefix? "x86_64-" system)
10065 (file-append qemu "/bin/qemu-system-x86_64"))
10066 (else
10067 (error "dunno!"))))
10068 "-net" "user" #$image)
10069 @end lisp
10070 @end deffn
10071
10072 @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
10073 This macro is similar to the @code{parameterize} form for
10074 dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
10075 Guile Reference Manual}). The key difference is that it takes effect
10076 when the file-like object returned by @var{exp} is lowered to a
10077 derivation or store item.
10078
10079 A typical use of @code{with-parameters} is to force the system in effect
10080 for a given object:
10081
10082 @lisp
10083 (with-parameters ((%current-system "i686-linux"))
10084 coreutils)
10085 @end lisp
10086
10087 The example above returns an object that corresponds to the i686 build
10088 of Coreutils, regardless of the current value of @code{%current-system}.
10089 @end deffn
10090
10091
10092 Of course, in addition to gexps embedded in ``host'' code, there are
10093 also modules containing build tools. To make it clear that they are
10094 meant to be used in the build stratum, these modules are kept in the
10095 @code{(guix build @dots{})} name space.
10096
10097 @cindex lowering, of high-level objects in gexps
10098 Internally, high-level objects are @dfn{lowered}, using their compiler,
10099 to either derivations or store items. For instance, lowering a package
10100 yields a derivation, and lowering a @code{plain-file} yields a store
10101 item. This is achieved using the @code{lower-object} monadic procedure.
10102
10103 @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
10104 [#:target #f]
10105 Return as a value in @code{%store-monad} the derivation or store item
10106 corresponding to @var{obj} for @var{system}, cross-compiling for
10107 @var{target} if @var{target} is true. @var{obj} must be an object that
10108 has an associated gexp compiler, such as a @code{<package>}.
10109 @end deffn
10110
10111 @deffn {Procedure} gexp->approximate-sexp @var{gexp}
10112 Sometimes, it may be useful to convert a G-exp into a S-exp. For
10113 example, some linters (@pxref{Invoking guix lint}) peek into the build
10114 phases of a package to detect potential problems. This conversion can
10115 be achieved with this procedure. However, some information can be lost
10116 in the process. More specifically, lowerable objects will be silently
10117 replaced with some arbitrary object -- currently the list
10118 @code{(*approximate*)}, but this may change.
10119 @end deffn
10120
10121 @node Invoking guix repl
10122 @section Invoking @command{guix repl}
10123
10124 @cindex REPL, read-eval-print loop, script
10125 The @command{guix repl} command makes it easier to program Guix in Guile
10126 by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
10127 programming (@pxref{Using Guile Interactively,,, guile,
10128 GNU Guile Reference Manual}), or by running Guile scripts
10129 (@pxref{Running Guile Scripts,,, guile,
10130 GNU Guile Reference Manual}).
10131 Compared to just launching the @command{guile}
10132 command, @command{guix repl} guarantees that all the Guix modules and all its
10133 dependencies are available in the search path.
10134
10135 The general syntax is:
10136
10137 @example
10138 guix repl @var{options} [@var{file} @var{args}]
10139 @end example
10140
10141 When a @var{file} argument is provided, @var{file} is
10142 executed as a Guile scripts:
10143
10144 @example
10145 guix repl my-script.scm
10146 @end example
10147
10148 To pass arguments to the script, use @code{--} to prevent them from
10149 being interpreted as arguments to @command{guix repl} itself:
10150
10151 @example
10152 guix repl -- my-script.scm --input=foo.txt
10153 @end example
10154
10155 To make a script executable directly from the shell, using the guix
10156 executable that is on the user's search path, add the following two
10157 lines at the top of the script:
10158
10159 @example
10160 @code{#!/usr/bin/env -S guix repl --}
10161 @code{!#}
10162 @end example
10163
10164 Without a file name argument, a Guile REPL is started:
10165
10166 @example
10167 $ guix repl
10168 scheme@@(guile-user)> ,use (gnu packages base)
10169 scheme@@(guile-user)> coreutils
10170 $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
10171 @end example
10172
10173 @cindex inferiors
10174 In addition, @command{guix repl} implements a simple machine-readable REPL
10175 protocol for use by @code{(guix inferior)}, a facility to interact with
10176 @dfn{inferiors}, separate processes running a potentially different revision
10177 of Guix.
10178
10179 The available options are as follows:
10180
10181 @table @code
10182 @item --type=@var{type}
10183 @itemx -t @var{type}
10184 Start a REPL of the given @var{TYPE}, which can be one of the following:
10185
10186 @table @code
10187 @item guile
10188 This is default, and it spawns a standard full-featured Guile REPL.
10189 @item machine
10190 Spawn a REPL that uses the machine-readable protocol. This is the protocol
10191 that the @code{(guix inferior)} module speaks.
10192 @end table
10193
10194 @item --listen=@var{endpoint}
10195 By default, @command{guix repl} reads from standard input and writes to
10196 standard output. When this option is passed, it will instead listen for
10197 connections on @var{endpoint}. Here are examples of valid options:
10198
10199 @table @code
10200 @item --listen=tcp:37146
10201 Accept connections on localhost on port 37146.
10202
10203 @item --listen=unix:/tmp/socket
10204 Accept connections on the Unix-domain socket @file{/tmp/socket}.
10205 @end table
10206
10207 @item --load-path=@var{directory}
10208 @itemx -L @var{directory}
10209 Add @var{directory} to the front of the package module search path
10210 (@pxref{Package Modules}).
10211
10212 This allows users to define their own packages and make them visible to
10213 the script or REPL.
10214
10215 @item -q
10216 Inhibit loading of the @file{~/.guile} file. By default, that
10217 configuration file is loaded when spawning a @code{guile} REPL.
10218 @end table
10219
10220 @c *********************************************************************
10221 @node Utilities
10222 @chapter Utilities
10223
10224 This section describes Guix command-line utilities. Some of them are
10225 primarily targeted at developers and users who write new package
10226 definitions, while others are more generally useful. They complement
10227 the Scheme programming interface of Guix in a convenient way.
10228
10229 @menu
10230 * Invoking guix build:: Building packages from the command line.
10231 * Invoking guix edit:: Editing package definitions.
10232 * Invoking guix download:: Downloading a file and printing its hash.
10233 * Invoking guix hash:: Computing the cryptographic hash of a file.
10234 * Invoking guix import:: Importing package definitions.
10235 * Invoking guix refresh:: Updating package definitions.
10236 * Invoking guix lint:: Finding errors in package definitions.
10237 * Invoking guix size:: Profiling disk usage.
10238 * Invoking guix graph:: Visualizing the graph of packages.
10239 * Invoking guix publish:: Sharing substitutes.
10240 * Invoking guix challenge:: Challenging substitute servers.
10241 * Invoking guix copy:: Copying to and from a remote store.
10242 * Invoking guix container:: Process isolation.
10243 * Invoking guix weather:: Assessing substitute availability.
10244 * Invoking guix processes:: Listing client processes.
10245 @end menu
10246
10247 @node Invoking guix build
10248 @section Invoking @command{guix build}
10249
10250 @cindex package building
10251 @cindex @command{guix build}
10252 The @command{guix build} command builds packages or derivations and
10253 their dependencies, and prints the resulting store paths. Note that it
10254 does not modify the user's profile---this is the job of the
10255 @command{guix package} command (@pxref{Invoking guix package}). Thus,
10256 it is mainly useful for distribution developers.
10257
10258 The general syntax is:
10259
10260 @example
10261 guix build @var{options} @var{package-or-derivation}@dots{}
10262 @end example
10263
10264 As an example, the following command builds the latest versions of Emacs
10265 and of Guile, displays their build logs, and finally displays the
10266 resulting directories:
10267
10268 @example
10269 guix build emacs guile
10270 @end example
10271
10272 Similarly, the following command builds all the available packages:
10273
10274 @example
10275 guix build --quiet --keep-going \
10276 $(guix package -A | awk '@{ print $1 "@@" $2 @}')
10277 @end example
10278
10279 @var{package-or-derivation} may be either the name of a package found in
10280 the software distribution such as @code{coreutils} or
10281 @code{coreutils@@8.20}, or a derivation such as
10282 @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
10283 package with the corresponding name (and optionally version) is searched
10284 for among the GNU distribution modules (@pxref{Package Modules}).
10285
10286 Alternatively, the @option{--expression} option may be used to specify a
10287 Scheme expression that evaluates to a package; this is useful when
10288 disambiguating among several same-named packages or package variants is
10289 needed.
10290
10291 There may be zero or more @var{options}. The available options are
10292 described in the subsections below.
10293
10294 @menu
10295 * Common Build Options:: Build options for most commands.
10296 * Package Transformation Options:: Creating variants of packages.
10297 * Additional Build Options:: Options specific to 'guix build'.
10298 * Debugging Build Failures:: Real life packaging experience.
10299 @end menu
10300
10301 @node Common Build Options
10302 @subsection Common Build Options
10303
10304 A number of options that control the build process are common to
10305 @command{guix build} and other commands that can spawn builds, such as
10306 @command{guix package} or @command{guix archive}. These are the
10307 following:
10308
10309 @table @code
10310
10311 @item --load-path=@var{directory}
10312 @itemx -L @var{directory}
10313 Add @var{directory} to the front of the package module search path
10314 (@pxref{Package Modules}).
10315
10316 This allows users to define their own packages and make them visible to
10317 the command-line tools.
10318
10319 @item --keep-failed
10320 @itemx -K
10321 Keep the build tree of failed builds. Thus, if a build fails, its build
10322 tree is kept under @file{/tmp}, in a directory whose name is shown at
10323 the end of the build log. This is useful when debugging build issues.
10324 @xref{Debugging Build Failures}, for tips and tricks on how to debug
10325 build issues.
10326
10327 This option implies @option{--no-offload}, and it has no effect when
10328 connecting to a remote daemon with a @code{guix://} URI (@pxref{The
10329 Store, the @env{GUIX_DAEMON_SOCKET} variable}).
10330
10331 @item --keep-going
10332 @itemx -k
10333 Keep going when some of the derivations fail to build; return only once
10334 all the builds have either completed or failed.
10335
10336 The default behavior is to stop as soon as one of the specified
10337 derivations has failed.
10338
10339 @item --dry-run
10340 @itemx -n
10341 Do not build the derivations.
10342
10343 @anchor{fallback-option}
10344 @item --fallback
10345 When substituting a pre-built binary fails, fall back to building
10346 packages locally (@pxref{Substitution Failure}).
10347
10348 @item --substitute-urls=@var{urls}
10349 @anchor{client-substitute-urls}
10350 Consider @var{urls} the whitespace-separated list of substitute source
10351 URLs, overriding the default list of URLs of @command{guix-daemon}
10352 (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
10353
10354 This means that substitutes may be downloaded from @var{urls}, provided
10355 they are signed by a key authorized by the system administrator
10356 (@pxref{Substitutes}).
10357
10358 When @var{urls} is the empty string, substitutes are effectively
10359 disabled.
10360
10361 @item --no-substitutes
10362 Do not use substitutes for build products. That is, always build things
10363 locally instead of allowing downloads of pre-built binaries
10364 (@pxref{Substitutes}).
10365
10366 @item --no-grafts
10367 Do not ``graft'' packages. In practice, this means that package updates
10368 available as grafts are not applied. @xref{Security Updates}, for more
10369 information on grafts.
10370
10371 @item --rounds=@var{n}
10372 Build each derivation @var{n} times in a row, and raise an error if
10373 consecutive build results are not bit-for-bit identical.
10374
10375 This is a useful way to detect non-deterministic builds processes.
10376 Non-deterministic build processes are a problem because they make it
10377 practically impossible for users to @emph{verify} whether third-party
10378 binaries are genuine. @xref{Invoking guix challenge}, for more.
10379
10380 When used in conjunction with @option{--keep-failed}, the differing
10381 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
10382 This makes it easy to look for differences between the two results.
10383
10384 @item --no-offload
10385 Do not use offload builds to other machines (@pxref{Daemon Offload
10386 Setup}). That is, always build things locally instead of offloading
10387 builds to remote machines.
10388
10389 @item --max-silent-time=@var{seconds}
10390 When the build or substitution process remains silent for more than
10391 @var{seconds}, terminate it and report a build failure.
10392
10393 By default, the daemon's setting is honored (@pxref{Invoking
10394 guix-daemon, @option{--max-silent-time}}).
10395
10396 @item --timeout=@var{seconds}
10397 Likewise, when the build or substitution process lasts for more than
10398 @var{seconds}, terminate it and report a build failure.
10399
10400 By default, the daemon's setting is honored (@pxref{Invoking
10401 guix-daemon, @option{--timeout}}).
10402
10403 @c Note: This option is actually not part of %standard-build-options but
10404 @c most programs honor it.
10405 @cindex verbosity, of the command-line tools
10406 @cindex build logs, verbosity
10407 @item -v @var{level}
10408 @itemx --verbosity=@var{level}
10409 Use the given verbosity @var{level}, an integer. Choosing 0 means that
10410 no output is produced, 1 is for quiet output; 2 is similar to 1 but it
10411 additionally displays download URLs; 3 shows all the build log output on
10412 standard error.
10413
10414 @item --cores=@var{n}
10415 @itemx -c @var{n}
10416 Allow the use of up to @var{n} CPU cores for the build. The special
10417 value @code{0} means to use as many CPU cores as available.
10418
10419 @item --max-jobs=@var{n}
10420 @itemx -M @var{n}
10421 Allow at most @var{n} build jobs in parallel. @xref{Invoking
10422 guix-daemon, @option{--max-jobs}}, for details about this option and the
10423 equivalent @command{guix-daemon} option.
10424
10425 @item --debug=@var{level}
10426 Produce debugging output coming from the build daemon. @var{level} must be an
10427 integer between 0 and 5; higher means more verbose output. Setting a level of
10428 4 or more may be helpful when debugging setup issues with the build daemon.
10429
10430 @end table
10431
10432 Behind the scenes, @command{guix build} is essentially an interface to
10433 the @code{package-derivation} procedure of the @code{(guix packages)}
10434 module, and to the @code{build-derivations} procedure of the @code{(guix
10435 derivations)} module.
10436
10437 In addition to options explicitly passed on the command line,
10438 @command{guix build} and other @command{guix} commands that support
10439 building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
10440
10441 @defvr {Environment Variable} GUIX_BUILD_OPTIONS
10442 Users can define this variable to a list of command line options that
10443 will automatically be used by @command{guix build} and other
10444 @command{guix} commands that can perform builds, as in the example
10445 below:
10446
10447 @example
10448 $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
10449 @end example
10450
10451 These options are parsed independently, and the result is appended to
10452 the parsed command-line options.
10453 @end defvr
10454
10455
10456 @node Package Transformation Options
10457 @subsection Package Transformation Options
10458
10459 @cindex package variants
10460 Another set of command-line options supported by @command{guix build}
10461 and also @command{guix package} are @dfn{package transformation
10462 options}. These are options that make it possible to define @dfn{package
10463 variants}---for instance, packages built from different source code.
10464 This is a convenient way to create customized packages on the fly
10465 without having to type in the definitions of package variants
10466 (@pxref{Defining Packages}).
10467
10468 Package transformation options are preserved across upgrades:
10469 @command{guix upgrade} attempts to apply transformation options
10470 initially used when creating the profile to the upgraded packages.
10471
10472 The available options are listed below. Most commands support them and
10473 also support a @option{--help-transform} option that lists all the
10474 available options and a synopsis (these options are not shown in the
10475 @option{--help} output for brevity).
10476
10477 @table @code
10478
10479 @item --with-source=@var{source}
10480 @itemx --with-source=@var{package}=@var{source}
10481 @itemx --with-source=@var{package}@@@var{version}=@var{source}
10482 Use @var{source} as the source of @var{package}, and @var{version} as
10483 its version number.
10484 @var{source} must be a file name or a URL, as for @command{guix
10485 download} (@pxref{Invoking guix download}).
10486
10487 When @var{package} is omitted,
10488 it is taken to be the package name specified on the
10489 command line that matches the base of @var{source}---e.g.,
10490 if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
10491 package is @code{guile}.
10492
10493 Likewise, when @var{version} is omitted, the version string is inferred from
10494 @var{source}; in the previous example, it is @code{2.0.10}.
10495
10496 This option allows users to try out versions of packages other than the
10497 one provided by the distribution. The example below downloads
10498 @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
10499 the @code{ed} package:
10500
10501 @example
10502 guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
10503 @end example
10504
10505 As a developer, @option{--with-source} makes it easy to test release
10506 candidates:
10507
10508 @example
10509 guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
10510 @end example
10511
10512 @dots{} or to build from a checkout in a pristine environment:
10513
10514 @example
10515 $ git clone git://git.sv.gnu.org/guix.git
10516 $ guix build guix --with-source=guix@@1.0=./guix
10517 @end example
10518
10519 @item --with-input=@var{package}=@var{replacement}
10520 Replace dependency on @var{package} by a dependency on
10521 @var{replacement}. @var{package} must be a package name, and
10522 @var{replacement} must be a package specification such as @code{guile}
10523 or @code{guile@@1.8}.
10524
10525 For instance, the following command builds Guix, but replaces its
10526 dependency on the current stable version of Guile with a dependency on
10527 the legacy version of Guile, @code{guile@@2.0}:
10528
10529 @example
10530 guix build --with-input=guile=guile@@2.0 guix
10531 @end example
10532
10533 This is a recursive, deep replacement. So in this example, both
10534 @code{guix} and its dependency @code{guile-json} (which also depends on
10535 @code{guile}) get rebuilt against @code{guile@@2.0}.
10536
10537 This is implemented using the @code{package-input-rewriting} Scheme
10538 procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
10539
10540 @item --with-graft=@var{package}=@var{replacement}
10541 This is similar to @option{--with-input} but with an important difference:
10542 instead of rebuilding the whole dependency chain, @var{replacement} is
10543 built and then @dfn{grafted} onto the binaries that were initially
10544 referring to @var{package}. @xref{Security Updates}, for more
10545 information on grafts.
10546
10547 For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
10548 and all its dependencies, replacing references to the version of GnuTLS
10549 they currently refer to:
10550
10551 @example
10552 guix build --with-graft=gnutls=gnutls@@3.5.4 wget
10553 @end example
10554
10555 This has the advantage of being much faster than rebuilding everything.
10556 But there is a caveat: it works if and only if @var{package} and
10557 @var{replacement} are strictly compatible---for example, if they provide
10558 a library, the application binary interface (ABI) of those libraries
10559 must be compatible. If @var{replacement} is somehow incompatible with
10560 @var{package}, then the resulting package may be unusable. Use with
10561 care!
10562
10563 @cindex debugging info, rebuilding
10564 @item --with-debug-info=@var{package}
10565 Build @var{package} in a way that preserves its debugging info and graft
10566 it onto packages that depend on it. This is useful if @var{package}
10567 does not already provide debugging info as a @code{debug} output
10568 (@pxref{Installing Debugging Files}).
10569
10570 For example, suppose you're experiencing a crash in Inkscape and would
10571 like to see what's up in GLib, a library deep down in Inkscape's
10572 dependency graph. GLib lacks a @code{debug} output, so debugging is
10573 tough. Fortunately, you rebuild GLib with debugging info and tack it on
10574 Inkscape:
10575
10576 @example
10577 guix install inkscape --with-debug-info=glib
10578 @end example
10579
10580 Only GLib needs to be recompiled so this takes a reasonable amount of
10581 time. @xref{Installing Debugging Files}, for more info.
10582
10583 @quotation Note
10584 Under the hood, this option works by passing the @samp{#:strip-binaries?
10585 #f} to the build system of the package of interest (@pxref{Build
10586 Systems}). Most build systems support that option but some do not. In
10587 that case, an error is raised.
10588
10589 Likewise, if a C/C++ package is built without @code{-g} (which is rarely
10590 the case), debugging info will remain unavailable even when
10591 @code{#:strip-binaries?} is false.
10592 @end quotation
10593
10594 @cindex tool chain, changing the build tool chain of a package
10595 @item --with-c-toolchain=@var{package}=@var{toolchain}
10596 This option changes the compilation of @var{package} and everything that
10597 depends on it so that they get built with @var{toolchain} instead of the
10598 default GNU tool chain for C/C++.
10599
10600 Consider this example:
10601
10602 @example
10603 guix build octave-cli \
10604 --with-c-toolchain=fftw=gcc-toolchain@@10 \
10605 --with-c-toolchain=fftwf=gcc-toolchain@@10
10606 @end example
10607
10608 The command above builds a variant of the @code{fftw} and @code{fftwf}
10609 packages using version 10 of @code{gcc-toolchain} instead of the default
10610 tool chain, and then builds a variant of the GNU@tie{}Octave
10611 command-line interface using them. GNU@tie{}Octave itself is also built
10612 with @code{gcc-toolchain@@10}.
10613
10614 This other example builds the Hardware Locality (@code{hwloc}) library
10615 and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
10616 compiler:
10617
10618 @example
10619 guix build --with-c-toolchain=hwloc=clang-toolchain \
10620 intel-mpi-benchmarks
10621 @end example
10622
10623 @quotation Note
10624 There can be application binary interface (ABI) incompatibilities among
10625 tool chains. This is particularly true of the C++ standard library and
10626 run-time support libraries such as that of OpenMP@. By rebuilding all
10627 dependents with the same tool chain, @option{--with-c-toolchain} minimizes
10628 the risks of incompatibility but cannot entirely eliminate them. Choose
10629 @var{package} wisely.
10630 @end quotation
10631
10632 @item --with-git-url=@var{package}=@var{url}
10633 @cindex Git, using the latest commit
10634 @cindex latest commit, building
10635 Build @var{package} from the latest commit of the @code{master} branch of the
10636 Git repository at @var{url}. Git sub-modules of the repository are fetched,
10637 recursively.
10638
10639 For example, the following command builds the NumPy Python library against the
10640 latest commit of the master branch of Python itself:
10641
10642 @example
10643 guix build python-numpy \
10644 --with-git-url=python=https://github.com/python/cpython
10645 @end example
10646
10647 This option can also be combined with @option{--with-branch} or
10648 @option{--with-commit} (see below).
10649
10650 @cindex continuous integration
10651 Obviously, since it uses the latest commit of the given branch, the result of
10652 such a command varies over time. Nevertheless it is a convenient way to
10653 rebuild entire software stacks against the latest commit of one or more
10654 packages. This is particularly useful in the context of continuous
10655 integration (CI).
10656
10657 Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
10658 consecutive accesses to the same repository. You may want to clean it up once
10659 in a while to save disk space.
10660
10661 @item --with-branch=@var{package}=@var{branch}
10662 Build @var{package} from the latest commit of @var{branch}. If the
10663 @code{source} field of @var{package} is an origin with the @code{git-fetch}
10664 method (@pxref{origin Reference}) or a @code{git-checkout} object, the
10665 repository URL is taken from that @code{source}. Otherwise you have to use
10666 @option{--with-git-url} to specify the URL of the Git repository.
10667
10668 For instance, the following command builds @code{guile-sqlite3} from the
10669 latest commit of its @code{master} branch, and then builds @code{guix} (which
10670 depends on it) and @code{cuirass} (which depends on @code{guix}) against this
10671 specific @code{guile-sqlite3} build:
10672
10673 @example
10674 guix build --with-branch=guile-sqlite3=master cuirass
10675 @end example
10676
10677 @item --with-commit=@var{package}=@var{commit}
10678 This is similar to @option{--with-branch}, except that it builds from
10679 @var{commit} rather than the tip of a branch. @var{commit} must be a valid
10680 Git commit SHA1 identifier, a tag, or a @command{git describe} style
10681 identifier such as @code{1.0-3-gabc123}.
10682
10683 @item --with-patch=@var{package}=@var{file}
10684 Add @var{file} to the list of patches applied to @var{package}, where
10685 @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
10686 @var{file} must contain a patch; it is applied with the flags specified
10687 in the @code{origin} of @var{package} (@pxref{origin Reference}), which
10688 by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
10689 Comparing and Merging Files}).
10690
10691 As an example, the command below rebuilds Coreutils with the GNU C
10692 Library (glibc) patched with the given patch:
10693
10694 @example
10695 guix build coreutils --with-patch=glibc=./glibc-frob.patch
10696 @end example
10697
10698 In this example, glibc itself as well as everything that leads to
10699 Coreutils in the dependency graph is rebuilt.
10700
10701 @cindex upstream, latest version
10702 @item --with-latest=@var{package}
10703 So you like living on the bleeding edge? This option is for you! It
10704 replaces occurrences of @var{package} in the dependency graph with its
10705 latest upstream version, as reported by @command{guix refresh}
10706 (@pxref{Invoking guix refresh}).
10707
10708 It does so by determining the latest upstream release of @var{package}
10709 (if possible), downloading it, and authenticating it @emph{if} it comes
10710 with an OpenPGP signature.
10711
10712 As an example, the command below builds Guix against the latest version
10713 of Guile-JSON:
10714
10715 @example
10716 guix build guix --with-latest=guile-json
10717 @end example
10718
10719 There are limitations. First, in cases where the tool cannot or does
10720 not know how to authenticate source code, you are at risk of running
10721 malicious code; a warning is emitted in this case. Second, this option
10722 simply changes the source used in the existing package definitions,
10723 which is not always sufficient: there might be additional dependencies
10724 that need to be added, patches to apply, and more generally the quality
10725 assurance work that Guix developers normally do will be missing.
10726
10727 You've been warned! In all the other cases, it's a snappy way to stay
10728 on top. We encourage you to submit patches updating the actual package
10729 definitions once you have successfully tested an upgrade
10730 (@pxref{Contributing}).
10731
10732 @cindex test suite, skipping
10733 @item --without-tests=@var{package}
10734 Build @var{package} without running its tests. This can be useful in
10735 situations where you want to skip the lengthy test suite of a
10736 intermediate package, or if a package's test suite fails in a
10737 non-deterministic fashion. It should be used with care because running
10738 the test suite is a good way to ensure a package is working as intended.
10739
10740 Turning off tests leads to a different store item. Consequently, when
10741 using this option, anything that depends on @var{package} must be
10742 rebuilt, as in this example:
10743
10744 @example
10745 guix install --without-tests=python python-notebook
10746 @end example
10747
10748 The command above installs @code{python-notebook} on top of
10749 @code{python} built without running its test suite. To do so, it also
10750 rebuilds everything that depends on @code{python}, including
10751 @code{python-notebook} itself.
10752
10753 Internally, @option{--without-tests} relies on changing the
10754 @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
10755 Systems}). Note that some packages use a customized @code{check} phase
10756 that does not respect a @code{#:tests? #f} setting. Therefore,
10757 @option{--without-tests} has no effect on these packages.
10758
10759 @end table
10760
10761 Wondering how to achieve the same effect using Scheme code, for example
10762 in your manifest, or how to write your own package transformation?
10763 @xref{Defining Package Variants}, for an overview of the programming
10764 interfaces available.
10765
10766 @node Additional Build Options
10767 @subsection Additional Build Options
10768
10769 The command-line options presented below are specific to @command{guix
10770 build}.
10771
10772 @table @code
10773
10774 @item --quiet
10775 @itemx -q
10776 Build quietly, without displaying the build log; this is equivalent to
10777 @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
10778 (or similar) and can always be retrieved using the @option{--log-file} option.
10779
10780 @item --file=@var{file}
10781 @itemx -f @var{file}
10782 Build the package, derivation, or other file-like object that the code within
10783 @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
10784
10785 As an example, @var{file} might contain a package definition like this
10786 (@pxref{Defining Packages}):
10787
10788 @lisp
10789 @include package-hello.scm
10790 @end lisp
10791
10792 The @var{file} may also contain a JSON representation of one or more
10793 package definitions. Running @code{guix build -f} on @file{hello.json}
10794 with the following contents would result in building the packages
10795 @code{myhello} and @code{greeter}:
10796
10797 @example
10798 @verbatiminclude package-hello.json
10799 @end example
10800
10801 @item --manifest=@var{manifest}
10802 @itemx -m @var{manifest}
10803 Build all packages listed in the given @var{manifest}
10804 (@pxref{profile-manifest, @option{--manifest}}).
10805
10806 @item --expression=@var{expr}
10807 @itemx -e @var{expr}
10808 Build the package or derivation @var{expr} evaluates to.
10809
10810 For example, @var{expr} may be @code{(@@ (gnu packages guile)
10811 guile-1.8)}, which unambiguously designates this specific variant of
10812 version 1.8 of Guile.
10813
10814 Alternatively, @var{expr} may be a G-expression, in which case it is used
10815 as a build program passed to @code{gexp->derivation}
10816 (@pxref{G-Expressions}).
10817
10818 Lastly, @var{expr} may refer to a zero-argument monadic procedure
10819 (@pxref{The Store Monad}). The procedure must return a derivation as a
10820 monadic value, which is then passed through @code{run-with-store}.
10821
10822 @item --source
10823 @itemx -S
10824 Build the source derivations of the packages, rather than the packages
10825 themselves.
10826
10827 For instance, @code{guix build -S gcc} returns something like
10828 @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
10829 source tarball.
10830
10831 The returned source tarball is the result of applying any patches and
10832 code snippets specified in the package @code{origin} (@pxref{Defining
10833 Packages}).
10834
10835 @cindex source, verification
10836 As with other derivations, the result of building a source derivation
10837 can be verified using the @option{--check} option (@pxref{build-check}).
10838 This is useful to validate that a (potentially already built or
10839 substituted, thus cached) package source matches against its declared
10840 hash.
10841
10842 Note that @command{guix build -S} compiles the sources only of the
10843 specified packages. They do not include the sources of statically
10844 linked dependencies and by themselves are insufficient for reproducing
10845 the packages.
10846
10847 @item --sources
10848 Fetch and return the source of @var{package-or-derivation} and all their
10849 dependencies, recursively. This is a handy way to obtain a local copy
10850 of all the source code needed to build @var{packages}, allowing you to
10851 eventually build them even without network access. It is an extension
10852 of the @option{--source} option and can accept one of the following
10853 optional argument values:
10854
10855 @table @code
10856 @item package
10857 This value causes the @option{--sources} option to behave in the same way
10858 as the @option{--source} option.
10859
10860 @item all
10861 Build the source derivations of all packages, including any source that
10862 might be listed as @code{inputs}. This is the default value.
10863
10864 @example
10865 $ guix build --sources tzdata
10866 The following derivations will be built:
10867 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
10868 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
10869 @end example
10870
10871 @item transitive
10872 Build the source derivations of all packages, as well of all transitive
10873 inputs to the packages. This can be used e.g.@: to
10874 prefetch package source for later offline building.
10875
10876 @example
10877 $ guix build --sources=transitive tzdata
10878 The following derivations will be built:
10879 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
10880 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
10881 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
10882 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
10883 /gnu/store/@dots{}-make-4.1.tar.xz.drv
10884 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
10885 @dots{}
10886 @end example
10887
10888 @end table
10889
10890 @item --system=@var{system}
10891 @itemx -s @var{system}
10892 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
10893 the system type of the build host. The @command{guix build} command allows
10894 you to repeat this option several times, in which case it builds for all the
10895 specified systems; other commands ignore extraneous @option{-s} options.
10896
10897 @quotation Note
10898 The @option{--system} flag is for @emph{native} compilation and must not
10899 be confused with cross-compilation. See @option{--target} below for
10900 information on cross-compilation.
10901 @end quotation
10902
10903 An example use of this is on Linux-based systems, which can emulate
10904 different personalities. For instance, passing
10905 @option{--system=i686-linux} on an @code{x86_64-linux} system or
10906 @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
10907 you to build packages in a complete 32-bit environment.
10908
10909 @quotation Note
10910 Building for an @code{armhf-linux} system is unconditionally enabled on
10911 @code{aarch64-linux} machines, although certain aarch64 chipsets do not
10912 allow for this functionality, notably the ThunderX.
10913 @end quotation
10914
10915 Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
10916 is enabled (@pxref{Virtualization Services,
10917 @code{qemu-binfmt-service-type}}), you can build for any system for
10918 which a QEMU @code{binfmt_misc} handler is installed.
10919
10920 Builds for a system other than that of the machine you are using can
10921 also be offloaded to a remote machine of the right architecture.
10922 @xref{Daemon Offload Setup}, for more information on offloading.
10923
10924 @item --target=@var{triplet}
10925 @cindex cross-compilation
10926 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
10927 as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
10928 configuration triplets,, autoconf, Autoconf}).
10929
10930 @anchor{build-check}
10931 @item --check
10932 @cindex determinism, checking
10933 @cindex reproducibility, checking
10934 Rebuild @var{package-or-derivation}, which are already available in the
10935 store, and raise an error if the build results are not bit-for-bit
10936 identical.
10937
10938 This mechanism allows you to check whether previously installed
10939 substitutes are genuine (@pxref{Substitutes}), or whether the build result
10940 of a package is deterministic. @xref{Invoking guix challenge}, for more
10941 background information and tools.
10942
10943 When used in conjunction with @option{--keep-failed}, the differing
10944 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
10945 This makes it easy to look for differences between the two results.
10946
10947 @item --repair
10948 @cindex repairing store items
10949 @cindex corruption, recovering from
10950 Attempt to repair the specified store items, if they are corrupt, by
10951 re-downloading or rebuilding them.
10952
10953 This operation is not atomic and thus restricted to @code{root}.
10954
10955 @item --derivations
10956 @itemx -d
10957 Return the derivation paths, not the output paths, of the given
10958 packages.
10959
10960 @item --root=@var{file}
10961 @itemx -r @var{file}
10962 @cindex GC roots, adding
10963 @cindex garbage collector roots, adding
10964 Make @var{file} a symlink to the result, and register it as a garbage
10965 collector root.
10966
10967 Consequently, the results of this @command{guix build} invocation are
10968 protected from garbage collection until @var{file} is removed. When
10969 that option is omitted, build results are eligible for garbage
10970 collection as soon as the build completes. @xref{Invoking guix gc}, for
10971 more on GC roots.
10972
10973 @item --log-file
10974 @cindex build logs, access
10975 Return the build log file names or URLs for the given
10976 @var{package-or-derivation}, or raise an error if build logs are
10977 missing.
10978
10979 This works regardless of how packages or derivations are specified. For
10980 instance, the following invocations are equivalent:
10981
10982 @example
10983 guix build --log-file $(guix build -d guile)
10984 guix build --log-file $(guix build guile)
10985 guix build --log-file guile
10986 guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
10987 @end example
10988
10989 If a log is unavailable locally, and unless @option{--no-substitutes} is
10990 passed, the command looks for a corresponding log on one of the
10991 substitute servers (as specified with @option{--substitute-urls}).
10992
10993 So for instance, imagine you want to see the build log of GDB on MIPS,
10994 but you are actually on an @code{x86_64} machine:
10995
10996 @example
10997 $ guix build --log-file gdb -s aarch64-linux
10998 https://@value{SUBSTITUTE-SERVER-1}/log/@dots{}-gdb-7.10
10999 @end example
11000
11001 You can freely access a huge library of build logs!
11002 @end table
11003
11004 @node Debugging Build Failures
11005 @subsection Debugging Build Failures
11006
11007 @cindex build failures, debugging
11008 When defining a new package (@pxref{Defining Packages}), you will
11009 probably find yourself spending some time debugging and tweaking the
11010 build until it succeeds. To do that, you need to operate the build
11011 commands yourself in an environment as close as possible to the one the
11012 build daemon uses.
11013
11014 To that end, the first thing to do is to use the @option{--keep-failed}
11015 or @option{-K} option of @command{guix build}, which will keep the
11016 failed build tree in @file{/tmp} or whatever directory you specified as
11017 @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
11018
11019 From there on, you can @command{cd} to the failed build tree and source
11020 the @file{environment-variables} file, which contains all the
11021 environment variable definitions that were in place when the build
11022 failed. So let's say you're debugging a build failure in package
11023 @code{foo}; a typical session would look like this:
11024
11025 @example
11026 $ guix build foo -K
11027 @dots{} @i{build fails}
11028 $ cd /tmp/guix-build-foo.drv-0
11029 $ source ./environment-variables
11030 $ cd foo-1.2
11031 @end example
11032
11033 Now, you can invoke commands as if you were the daemon (almost) and
11034 troubleshoot your build process.
11035
11036 Sometimes it happens that, for example, a package's tests pass when you
11037 run them manually but they fail when the daemon runs them. This can
11038 happen because the daemon runs builds in containers where, unlike in our
11039 environment above, network access is missing, @file{/bin/sh} does not
11040 exist, etc. (@pxref{Build Environment Setup}).
11041
11042 In such cases, you may need to run inspect the build process from within
11043 a container similar to the one the build daemon creates:
11044
11045 @example
11046 $ guix build -K foo
11047 @dots{}
11048 $ cd /tmp/guix-build-foo.drv-0
11049 $ guix environment --no-grafts -C foo --ad-hoc strace gdb
11050 [env]# source ./environment-variables
11051 [env]# cd foo-1.2
11052 @end example
11053
11054 Here, @command{guix environment -C} creates a container and spawns a new
11055 shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
11056 strace gdb} part adds the @command{strace} and @command{gdb} commands to
11057 the container, which you may find handy while debugging. The
11058 @option{--no-grafts} option makes sure we get the exact same
11059 environment, with ungrafted packages (@pxref{Security Updates}, for more
11060 info on grafts).
11061
11062 To get closer to a container like that used by the build daemon, we can
11063 remove @file{/bin/sh}:
11064
11065 @example
11066 [env]# rm /bin/sh
11067 @end example
11068
11069 (Don't worry, this is harmless: this is all happening in the throw-away
11070 container created by @command{guix environment}.)
11071
11072 The @command{strace} command is probably not in the search path, but we
11073 can run:
11074
11075 @example
11076 [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
11077 @end example
11078
11079 In this way, not only you will have reproduced the environment variables
11080 the daemon uses, you will also be running the build process in a container
11081 similar to the one the daemon uses.
11082
11083
11084 @node Invoking guix edit
11085 @section Invoking @command{guix edit}
11086
11087 @cindex @command{guix edit}
11088 @cindex package definition, editing
11089 So many packages, so many source files! The @command{guix edit} command
11090 facilitates the life of users and packagers by pointing their editor at
11091 the source file containing the definition of the specified packages.
11092 For instance:
11093
11094 @example
11095 guix edit gcc@@4.9 vim
11096 @end example
11097
11098 @noindent
11099 launches the program specified in the @env{VISUAL} or in the
11100 @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
11101 and that of Vim.
11102
11103 If you are using a Guix Git checkout (@pxref{Building from Git}), or
11104 have created your own packages on @env{GUIX_PACKAGE_PATH}
11105 (@pxref{Package Modules}), you will be able to edit the package
11106 recipes. In other cases, you will be able to examine the read-only recipes
11107 for packages currently in the store.
11108
11109 Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
11110 @option{--load-path=@var{directory}} (or in short @option{-L
11111 @var{directory}}) allows you to add @var{directory} to the front of the
11112 package module search path and so make your own packages visible.
11113
11114 @node Invoking guix download
11115 @section Invoking @command{guix download}
11116
11117 @cindex @command{guix download}
11118 @cindex downloading package sources
11119 When writing a package definition, developers typically need to download
11120 a source tarball, compute its SHA256 hash, and write that
11121 hash in the package definition (@pxref{Defining Packages}). The
11122 @command{guix download} tool helps with this task: it downloads a file
11123 from the given URI, adds it to the store, and prints both its file name
11124 in the store and its SHA256 hash.
11125
11126 The fact that the downloaded file is added to the store saves bandwidth:
11127 when the developer eventually tries to build the newly defined package
11128 with @command{guix build}, the source tarball will not have to be
11129 downloaded again because it is already in the store. It is also a
11130 convenient way to temporarily stash files, which may be deleted
11131 eventually (@pxref{Invoking guix gc}).
11132
11133 The @command{guix download} command supports the same URIs as used in
11134 package definitions. In particular, it supports @code{mirror://} URIs.
11135 @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
11136 Guile bindings for GnuTLS are available in the user's environment; when
11137 they are not available, an error is raised. @xref{Guile Preparations,
11138 how to install the GnuTLS bindings for Guile,, gnutls-guile,
11139 GnuTLS-Guile}, for more information.
11140
11141 @command{guix download} verifies HTTPS server certificates by loading
11142 the certificates of X.509 authorities from the directory pointed to by
11143 the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
11144 Certificates}), unless @option{--no-check-certificate} is used.
11145
11146 The following options are available:
11147
11148 @table @code
11149 @item --hash=@var{algorithm}
11150 @itemx -H @var{algorithm}
11151 Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
11152 hash}, for more information.
11153
11154 @item --format=@var{fmt}
11155 @itemx -f @var{fmt}
11156 Write the hash in the format specified by @var{fmt}. For more
11157 information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
11158
11159 @item --no-check-certificate
11160 Do not validate the X.509 certificates of HTTPS servers.
11161
11162 When using this option, you have @emph{absolutely no guarantee} that you
11163 are communicating with the authentic server responsible for the given
11164 URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
11165
11166 @item --output=@var{file}
11167 @itemx -o @var{file}
11168 Save the downloaded file to @var{file} instead of adding it to the
11169 store.
11170 @end table
11171
11172 @node Invoking guix hash
11173 @section Invoking @command{guix hash}
11174
11175 @cindex @command{guix hash}
11176 The @command{guix hash} command computes the hash of a file.
11177 It is primarily a convenience tool for anyone contributing to the
11178 distribution: it computes the cryptographic hash of a file, which can be
11179 used in the definition of a package (@pxref{Defining Packages}).
11180
11181 The general syntax is:
11182
11183 @example
11184 guix hash @var{option} @var{file}
11185 @end example
11186
11187 When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
11188 hash of data read from standard input. @command{guix hash} has the
11189 following options:
11190
11191 @table @code
11192
11193 @item --hash=@var{algorithm}
11194 @itemx -H @var{algorithm}
11195 Compute a hash using the specified @var{algorithm}, @code{sha256} by
11196 default.
11197
11198 @var{algorithm} must the name of a cryptographic hash algorithm
11199 supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
11200 @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
11201 Reference Manual}).
11202
11203 @item --format=@var{fmt}
11204 @itemx -f @var{fmt}
11205 Write the hash in the format specified by @var{fmt}.
11206
11207 Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
11208 (@code{hex} and @code{hexadecimal} can be used as well).
11209
11210 If the @option{--format} option is not specified, @command{guix hash}
11211 will output the hash in @code{nix-base32}. This representation is used
11212 in the definitions of packages.
11213
11214 @item --recursive
11215 @itemx -r
11216 Compute the hash on @var{file} recursively.
11217
11218 In this case, the hash is computed on an archive containing @var{file},
11219 including its children if it is a directory. Some of the metadata of
11220 @var{file} is part of the archive; for instance, when @var{file} is a
11221 regular file, the hash is different depending on whether @var{file} is
11222 executable or not. Metadata such as time stamps has no impact on the
11223 hash (@pxref{Invoking guix archive}).
11224 @c FIXME: Replace xref above with xref to an ``Archive'' section when
11225 @c it exists.
11226
11227 @item --exclude-vcs
11228 @itemx -x
11229 When combined with @option{--recursive}, exclude version control system
11230 directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
11231
11232 @vindex git-fetch
11233 As an example, here is how you would compute the hash of a Git checkout,
11234 which is useful when using the @code{git-fetch} method (@pxref{origin
11235 Reference}):
11236
11237 @example
11238 $ git clone http://example.org/foo.git
11239 $ cd foo
11240 $ guix hash -rx .
11241 @end example
11242 @end table
11243
11244 @node Invoking guix import
11245 @section Invoking @command{guix import}
11246
11247 @cindex importing packages
11248 @cindex package import
11249 @cindex package conversion
11250 @cindex Invoking @command{guix import}
11251 The @command{guix import} command is useful for people who would like to
11252 add a package to the distribution with as little work as
11253 possible---a legitimate demand. The command knows of a few
11254 repositories from which it can ``import'' package metadata. The result
11255 is a package definition, or a template thereof, in the format we know
11256 (@pxref{Defining Packages}).
11257
11258 The general syntax is:
11259
11260 @example
11261 guix import @var{importer} @var{options}@dots{}
11262 @end example
11263
11264 @var{importer} specifies the source from which to import package
11265 metadata, and @var{options} specifies a package identifier and other
11266 options specific to @var{importer}.
11267
11268 Some of the importers rely on the ability to run the @command{gpgv} command.
11269 For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
11270 gnupg} if needed.
11271
11272 Currently, the available ``importers'' are:
11273
11274 @table @code
11275 @item gnu
11276 Import metadata for the given GNU package. This provides a template
11277 for the latest version of that GNU package, including the hash of its
11278 source tarball, and its canonical synopsis and description.
11279
11280 Additional information such as the package dependencies and its
11281 license needs to be figured out manually.
11282
11283 For example, the following command returns a package definition for
11284 GNU@tie{}Hello:
11285
11286 @example
11287 guix import gnu hello
11288 @end example
11289
11290 Specific command-line options are:
11291
11292 @table @code
11293 @item --key-download=@var{policy}
11294 As for @command{guix refresh}, specify the policy to handle missing
11295 OpenPGP keys when verifying the package signature. @xref{Invoking guix
11296 refresh, @option{--key-download}}.
11297 @end table
11298
11299 @item pypi
11300 @cindex pypi
11301 Import metadata from the @uref{https://pypi.python.org/, Python Package
11302 Index}. Information is taken from the JSON-formatted description
11303 available at @code{pypi.python.org} and usually includes all the relevant
11304 information, including package dependencies. For maximum efficiency, it
11305 is recommended to install the @command{unzip} utility, so that the
11306 importer can unzip Python wheels and gather data from them.
11307
11308 The command below imports metadata for the @code{itsdangerous} Python
11309 package:
11310
11311 @example
11312 guix import pypi itsdangerous
11313 @end example
11314
11315 @table @code
11316 @item --recursive
11317 @itemx -r
11318 Traverse the dependency graph of the given upstream package recursively
11319 and generate package expressions for all those packages that are not yet
11320 in Guix.
11321 @end table
11322
11323 @item gem
11324 @cindex gem
11325 Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
11326 is taken from the JSON-formatted description available at
11327 @code{rubygems.org} and includes most relevant information, including
11328 runtime dependencies. There are some caveats, however. The metadata
11329 doesn't distinguish between synopses and descriptions, so the same string
11330 is used for both fields. Additionally, the details of non-Ruby
11331 dependencies required to build native extensions is unavailable and left
11332 as an exercise to the packager.
11333
11334 The command below imports metadata for the @code{rails} Ruby package:
11335
11336 @example
11337 guix import gem rails
11338 @end example
11339
11340 @table @code
11341 @item --recursive
11342 @itemx -r
11343 Traverse the dependency graph of the given upstream package recursively
11344 and generate package expressions for all those packages that are not yet
11345 in Guix.
11346 @end table
11347
11348 @item minetest
11349 @cindex minetest
11350 @cindex ContentDB
11351 Import metadata from @uref{https://content.minetest.net, ContentDB}.
11352 Information is taken from the JSON-formatted metadata provided through
11353 @uref{https://content.minetest.net/help/api/, ContentDB's API} and
11354 includes most relevant information, including dependencies. There are
11355 some caveats, however. The license information is often incomplete.
11356 The commit hash is sometimes missing. The descriptions are in the
11357 Markdown format, but Guix uses Texinfo instead. Texture packs and
11358 subgames are unsupported.
11359
11360 The command below imports metadata for the Mesecons mod by Jeija:
11361
11362 @example
11363 guix import minetest Jeija/mesecons
11364 @end example
11365
11366 The author name can also be left out:
11367
11368 @example
11369 guix import minetest mesecons
11370 @end example
11371
11372 @table @code
11373 @item --recursive
11374 @itemx -r
11375 Traverse the dependency graph of the given upstream package recursively
11376 and generate package expressions for all those packages that are not yet
11377 in Guix.
11378 @end table
11379
11380 @item cpan
11381 @cindex CPAN
11382 Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
11383 Information is taken from the JSON-formatted metadata provided through
11384 @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
11385 relevant information, such as module dependencies. License information
11386 should be checked closely. If Perl is available in the store, then the
11387 @code{corelist} utility will be used to filter core modules out of the
11388 list of dependencies.
11389
11390 The command command below imports metadata for the Acme::Boolean Perl
11391 module:
11392
11393 @example
11394 guix import cpan Acme::Boolean
11395 @end example
11396
11397 @item cran
11398 @cindex CRAN
11399 @cindex Bioconductor
11400 Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
11401 central repository for the @uref{https://r-project.org, GNU@tie{}R
11402 statistical and graphical environment}.
11403
11404 Information is extracted from the @file{DESCRIPTION} file of the package.
11405
11406 The command command below imports metadata for the Cairo R package:
11407
11408 @example
11409 guix import cran Cairo
11410 @end example
11411
11412 When @option{--recursive} is added, the importer will traverse the
11413 dependency graph of the given upstream package recursively and generate
11414 package expressions for all those packages that are not yet in Guix.
11415
11416 When @option{--style=specification} is added, the importer will generate
11417 package definitions whose inputs are package specifications instead of
11418 references to package variables. This is useful when generated package
11419 definitions are to be appended to existing user modules, as the list of
11420 used package modules need not be changed. The default is
11421 @option{--style=variable}.
11422
11423 When @option{--archive=bioconductor} is added, metadata is imported from
11424 @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
11425 packages for the analysis and comprehension of high-throughput
11426 genomic data in bioinformatics.
11427
11428 Information is extracted from the @file{DESCRIPTION} file contained in the
11429 package archive.
11430
11431 The command below imports metadata for the GenomicRanges R package:
11432
11433 @example
11434 guix import cran --archive=bioconductor GenomicRanges
11435 @end example
11436
11437 Finally, you can also import R packages that have not yet been published on
11438 CRAN or Bioconductor as long as they are in a git repository. Use
11439 @option{--archive=git} followed by the URL of the git repository:
11440
11441 @example
11442 guix import cran --archive=git https://github.com/immunogenomics/harmony
11443 @end example
11444
11445 @item texlive
11446 @cindex TeX Live
11447 @cindex CTAN
11448 Import metadata from @uref{https://www.ctan.org/, CTAN}, the
11449 comprehensive TeX archive network for TeX packages that are part of the
11450 @uref{https://www.tug.org/texlive/, TeX Live distribution}.
11451
11452 Information about the package is obtained through the XML API provided
11453 by CTAN, while the source code is downloaded from the SVN repository of
11454 the Tex Live project. This is done because the CTAN does not keep
11455 versioned archives.
11456
11457 The command command below imports metadata for the @code{fontspec}
11458 TeX package:
11459
11460 @example
11461 guix import texlive fontspec
11462 @end example
11463
11464 When @option{--archive=@var{directory}} is added, the source code is
11465 downloaded not from the @file{latex} sub-directory of the
11466 @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
11467 the specified sibling @var{directory} under the same root.
11468
11469 The command below imports metadata for the @code{ifxetex} package from
11470 CTAN while fetching the sources from the directory
11471 @file{texmf/source/generic}:
11472
11473 @example
11474 guix import texlive --archive=generic ifxetex
11475 @end example
11476
11477 @item json
11478 @cindex JSON, import
11479 Import package metadata from a local JSON file. Consider the following
11480 example package definition in JSON format:
11481
11482 @example
11483 @{
11484 "name": "hello",
11485 "version": "2.10",
11486 "source": "mirror://gnu/hello/hello-2.10.tar.gz",
11487 "build-system": "gnu",
11488 "home-page": "https://www.gnu.org/software/hello/",
11489 "synopsis": "Hello, GNU world: An example GNU package",
11490 "description": "GNU Hello prints a greeting.",
11491 "license": "GPL-3.0+",
11492 "native-inputs": ["gettext"]
11493 @}
11494 @end example
11495
11496 The field names are the same as for the @code{<package>} record
11497 (@xref{Defining Packages}). References to other packages are provided
11498 as JSON lists of quoted package specification strings such as
11499 @code{guile} or @code{guile@@2.0}.
11500
11501 The importer also supports a more explicit source definition using the
11502 common fields for @code{<origin>} records:
11503
11504 @example
11505 @{
11506 @dots{}
11507 "source": @{
11508 "method": "url-fetch",
11509 "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
11510 "sha256": @{
11511 "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
11512 @}
11513 @}
11514 @dots{}
11515 @}
11516 @end example
11517
11518 The command below reads metadata from the JSON file @code{hello.json}
11519 and outputs a package expression:
11520
11521 @example
11522 guix import json hello.json
11523 @end example
11524
11525 @item hackage
11526 @cindex hackage
11527 Import metadata from the Haskell community's central package archive
11528 @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
11529 Cabal files and includes all the relevant information, including package
11530 dependencies.
11531
11532 Specific command-line options are:
11533
11534 @table @code
11535 @item --stdin
11536 @itemx -s
11537 Read a Cabal file from standard input.
11538 @item --no-test-dependencies
11539 @itemx -t
11540 Do not include dependencies required only by the test suites.
11541 @item --cabal-environment=@var{alist}
11542 @itemx -e @var{alist}
11543 @var{alist} is a Scheme alist defining the environment in which the
11544 Cabal conditionals are evaluated. The accepted keys are: @code{os},
11545 @code{arch}, @code{impl} and a string representing the name of a flag.
11546 The value associated with a flag has to be either the symbol
11547 @code{true} or @code{false}. The value associated with other keys
11548 has to conform to the Cabal file format definition. The default value
11549 associated with the keys @code{os}, @code{arch} and @code{impl} is
11550 @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
11551 @item --recursive
11552 @itemx -r
11553 Traverse the dependency graph of the given upstream package recursively
11554 and generate package expressions for all those packages that are not yet
11555 in Guix.
11556 @end table
11557
11558 The command below imports metadata for the latest version of the
11559 HTTP Haskell package without including test dependencies and
11560 specifying the value of the flag @samp{network-uri} as @code{false}:
11561
11562 @example
11563 guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
11564 @end example
11565
11566 A specific package version may optionally be specified by following the
11567 package name by an at-sign and a version number as in the following example:
11568
11569 @example
11570 guix import hackage mtl@@2.1.3.1
11571 @end example
11572
11573 @item stackage
11574 @cindex stackage
11575 The @code{stackage} importer is a wrapper around the @code{hackage} one.
11576 It takes a package name, looks up the package version included in a
11577 long-term support (LTS) @uref{https://www.stackage.org, Stackage}
11578 release and uses the @code{hackage} importer to retrieve its metadata.
11579 Note that it is up to you to select an LTS release compatible with the
11580 GHC compiler used by Guix.
11581
11582 Specific command-line options are:
11583
11584 @table @code
11585 @item --no-test-dependencies
11586 @itemx -t
11587 Do not include dependencies required only by the test suites.
11588 @item --lts-version=@var{version}
11589 @itemx -l @var{version}
11590 @var{version} is the desired LTS release version. If omitted the latest
11591 release is used.
11592 @item --recursive
11593 @itemx -r
11594 Traverse the dependency graph of the given upstream package recursively
11595 and generate package expressions for all those packages that are not yet
11596 in Guix.
11597 @end table
11598
11599 The command below imports metadata for the HTTP Haskell package
11600 included in the LTS Stackage release version 7.18:
11601
11602 @example
11603 guix import stackage --lts-version=7.18 HTTP
11604 @end example
11605
11606 @item elpa
11607 @cindex elpa
11608 Import metadata from an Emacs Lisp Package Archive (ELPA) package
11609 repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
11610
11611 Specific command-line options are:
11612
11613 @table @code
11614 @item --archive=@var{repo}
11615 @itemx -a @var{repo}
11616 @var{repo} identifies the archive repository from which to retrieve the
11617 information. Currently the supported repositories and their identifiers
11618 are:
11619 @itemize -
11620 @item
11621 @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
11622 identifier. This is the default.
11623
11624 Packages from @code{elpa.gnu.org} are signed with one of the keys
11625 contained in the GnuPG keyring at
11626 @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
11627 @code{emacs} package (@pxref{Package Installation, ELPA package
11628 signatures,, emacs, The GNU Emacs Manual}).
11629
11630 @item
11631 @uref{https://elpa.nongnu.org/nongnu/, NonGNU}, selected by the
11632 @code{nongnu} identifier.
11633
11634 @item
11635 @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
11636 @code{melpa-stable} identifier.
11637
11638 @item
11639 @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
11640 identifier.
11641 @end itemize
11642
11643 @item --recursive
11644 @itemx -r
11645 Traverse the dependency graph of the given upstream package recursively
11646 and generate package expressions for all those packages that are not yet
11647 in Guix.
11648 @end table
11649
11650 @item crate
11651 @cindex crate
11652 Import metadata from the crates.io Rust package repository
11653 @uref{https://crates.io, crates.io}, as in this example:
11654
11655 @example
11656 guix import crate blake2-rfc
11657 @end example
11658
11659 The crate importer also allows you to specify a version string:
11660
11661 @example
11662 guix import crate constant-time-eq@@0.1.0
11663 @end example
11664
11665 Additional options include:
11666
11667 @table @code
11668 @item --recursive
11669 @itemx -r
11670 Traverse the dependency graph of the given upstream package recursively
11671 and generate package expressions for all those packages that are not yet
11672 in Guix.
11673 @end table
11674
11675 @item opam
11676 @cindex OPAM
11677 @cindex OCaml
11678 Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
11679 repository used by the OCaml community.
11680
11681 Additional options include:
11682
11683 @table @code
11684 @item --recursive
11685 @itemx -r
11686 Traverse the dependency graph of the given upstream package recursively
11687 and generate package expressions for all those packages that are not yet
11688 in Guix.
11689 @item --repo
11690 By default, packages are searched in the official OPAM repository. This
11691 option, which can be used more than once, lets you add other repositories
11692 which will be searched for packages. It accepts as valid arguments:
11693
11694 @itemize
11695 @item the name of a known repository - can be one of @code{opam},
11696 @code{coq} (equivalent to @code{coq-released}),
11697 @code{coq-core-dev}, @code{coq-extra-dev} or @code{grew}.
11698 @item the URL of a repository as expected by the
11699 @code{opam repository add} command (for instance, the URL equivalent
11700 of the above @code{opam} name would be
11701 @uref{https://opam.ocaml.org}).
11702 @item the path to a local copy of a repository (a directory containing a
11703 @file{packages/} sub-directory).
11704 @end itemize
11705
11706 Repositories are assumed to be passed to this option by order of
11707 preference. The additional repositories will not replace the default
11708 @code{opam} repository, which is always kept as a fallback.
11709
11710 Also, please note that versions are not compared accross repositories.
11711 The first repository (from left to right) that has at least one version
11712 of a given package will prevail over any others, and the version
11713 imported will be the latest one found @emph{in this repository only}.
11714
11715 @end table
11716
11717 @item go
11718 @cindex go
11719 Import metadata for a Go module using
11720 @uref{https://proxy.golang.org, proxy.golang.org}.
11721
11722 @example
11723 guix import go gopkg.in/yaml.v2
11724 @end example
11725
11726 It is possible to use a package specification with a @code{@@VERSION}
11727 suffix to import a specific version.
11728
11729 Additional options include:
11730
11731 @table @code
11732 @item --recursive
11733 @itemx -r
11734 Traverse the dependency graph of the given upstream package recursively
11735 and generate package expressions for all those packages that are not yet
11736 in Guix.
11737 @item --pin-versions
11738 When using this option, the importer preserves the exact versions of the
11739 Go modules dependencies instead of using their latest available
11740 versions. This can be useful when attempting to import packages that
11741 recursively depend on former versions of themselves to build. When
11742 using this mode, the symbol of the package is made by appending the
11743 version to its name, so that multiple versions of the same package can
11744 coexist.
11745 @end table
11746
11747 @item egg
11748 @cindex egg
11749 Import metadata for @uref{https://wiki.call-cc.org/eggs, CHICKEN eggs}.
11750 The information is taken from @file{PACKAGE.egg} files found in the
11751 @uref{git://code.call-cc.org/eggs-5-latest, eggs-5-latest} Git
11752 repository. However, it does not provide all the information that we
11753 need, there is no ``description'' field, and the licenses used are not
11754 always precise (BSD is often used instead of BSD-N).
11755
11756 @example
11757 guix import egg sourcehut
11758 @end example
11759
11760 Additional options include:
11761 @table @code
11762 @item --recursive
11763 @itemx -r
11764 Traverse the dependency graph of the given upstream package recursively
11765 and generate package expressions for all those packages that are not yet
11766 in Guix.
11767 @end table
11768 @end table
11769
11770 The structure of the @command{guix import} code is modular. It would be
11771 useful to have more importers for other package formats, and your help
11772 is welcome here (@pxref{Contributing}).
11773
11774 @node Invoking guix refresh
11775 @section Invoking @command{guix refresh}
11776
11777 @cindex @command {guix refresh}
11778 The primary audience of the @command{guix refresh} command is packagers.
11779 As a user, you may be interested in the @option{--with-latest} option,
11780 which can bring you package update superpowers built upon @command{guix
11781 refresh} (@pxref{Package Transformation Options,
11782 @option{--with-latest}}). By default, @command{guix refresh} reports
11783 any packages provided by the distribution that are outdated compared to
11784 the latest upstream version, like this:
11785
11786 @example
11787 $ guix refresh
11788 gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
11789 gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
11790 @end example
11791
11792 Alternatively, one can specify packages to consider, in which case a
11793 warning is emitted for packages that lack an updater:
11794
11795 @example
11796 $ guix refresh coreutils guile guile-ssh
11797 gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
11798 gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
11799 @end example
11800
11801 @command{guix refresh} browses the upstream repository of each package and determines
11802 the highest version number of the releases therein. The command
11803 knows how to update specific types of packages: GNU packages, ELPA
11804 packages, etc.---see the documentation for @option{--type} below. There
11805 are many packages, though, for which it lacks a method to determine
11806 whether a new upstream release is available. However, the mechanism is
11807 extensible, so feel free to get in touch with us to add a new method!
11808
11809 @table @code
11810
11811 @item --recursive
11812 Consider the packages specified, and all the packages upon which they depend.
11813
11814 @example
11815 $ guix refresh --recursive coreutils
11816 gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
11817 gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
11818 gnu/packages/xml.scm:68:2: warning: no updater for expat
11819 gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
11820 @dots{}
11821 @end example
11822
11823 @end table
11824
11825 Sometimes the upstream name differs from the package name used in Guix,
11826 and @command{guix refresh} needs a little help. Most updaters honor the
11827 @code{upstream-name} property in package definitions, which can be used
11828 to that effect:
11829
11830 @lisp
11831 (define-public network-manager
11832 (package
11833 (name "network-manager")
11834 ;; @dots{}
11835 (properties '((upstream-name . "NetworkManager")))))
11836 @end lisp
11837
11838 When passed @option{--update}, it modifies distribution source files to
11839 update the version numbers and source tarball hashes of those package
11840 recipes (@pxref{Defining Packages}). This is achieved by downloading
11841 each package's latest source tarball and its associated OpenPGP
11842 signature, authenticating the downloaded tarball against its signature
11843 using @command{gpgv}, and finally computing its hash---note that GnuPG must be
11844 installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
11845
11846 When the public
11847 key used to sign the tarball is missing from the user's keyring, an
11848 attempt is made to automatically retrieve it from a public key server;
11849 when this is successful, the key is added to the user's keyring; otherwise,
11850 @command{guix refresh} reports an error.
11851
11852 The following options are supported:
11853
11854 @table @code
11855
11856 @item --expression=@var{expr}
11857 @itemx -e @var{expr}
11858 Consider the package @var{expr} evaluates to.
11859
11860 This is useful to precisely refer to a package, as in this example:
11861
11862 @example
11863 guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
11864 @end example
11865
11866 This command lists the dependents of the ``final'' libc (essentially all
11867 the packages).
11868
11869 @item --update
11870 @itemx -u
11871 Update distribution source files (package recipes) in place. This is
11872 usually run from a checkout of the Guix source tree (@pxref{Running
11873 Guix Before It Is Installed}):
11874
11875 @example
11876 $ ./pre-inst-env guix refresh -s non-core -u
11877 @end example
11878
11879 @xref{Defining Packages}, for more information on package definitions.
11880
11881 @item --select=[@var{subset}]
11882 @itemx -s @var{subset}
11883 Select all the packages in @var{subset}, one of @code{core} or
11884 @code{non-core}.
11885
11886 The @code{core} subset refers to all the packages at the core of the
11887 distribution---i.e., packages that are used to build ``everything
11888 else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
11889 changing one of these packages in the distribution entails a rebuild of
11890 all the others. Thus, such updates are an inconvenience to users in
11891 terms of build time or bandwidth used to achieve the upgrade.
11892
11893 The @code{non-core} subset refers to the remaining packages. It is
11894 typically useful in cases where an update of the core packages would be
11895 inconvenient.
11896
11897 @item --manifest=@var{file}
11898 @itemx -m @var{file}
11899 Select all the packages from the manifest in @var{file}. This is useful to
11900 check if any packages of the user manifest can be updated.
11901
11902 @item --type=@var{updater}
11903 @itemx -t @var{updater}
11904 Select only packages handled by @var{updater} (may be a comma-separated
11905 list of updaters). Currently, @var{updater} may be one of:
11906
11907 @table @code
11908 @item gnu
11909 the updater for GNU packages;
11910 @item savannah
11911 the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
11912 @item sourceforge
11913 the updater for packages hosted at @uref{https://sourceforge.net, SourceForge};
11914 @item gnome
11915 the updater for GNOME packages;
11916 @item kde
11917 the updater for KDE packages;
11918 @item xorg
11919 the updater for X.org packages;
11920 @item kernel.org
11921 the updater for packages hosted on kernel.org;
11922 @item egg
11923 the updater for @uref{https://wiki.call-cc.org/eggs/, Egg} packages;
11924 @item elpa
11925 the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
11926 @item cran
11927 the updater for @uref{https://cran.r-project.org/, CRAN} packages;
11928 @item bioconductor
11929 the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
11930 @item cpan
11931 the updater for @uref{https://www.cpan.org/, CPAN} packages;
11932 @item pypi
11933 the updater for @uref{https://pypi.python.org, PyPI} packages.
11934 @item gem
11935 the updater for @uref{https://rubygems.org, RubyGems} packages.
11936 @item github
11937 the updater for @uref{https://github.com, GitHub} packages.
11938 @item hackage
11939 the updater for @uref{https://hackage.haskell.org, Hackage} packages.
11940 @item stackage
11941 the updater for @uref{https://www.stackage.org, Stackage} packages.
11942 @item crate
11943 the updater for @uref{https://crates.io, Crates} packages.
11944 @item launchpad
11945 the updater for @uref{https://launchpad.net, Launchpad} packages.
11946 @item generic-html
11947 a generic updater that crawls the HTML page where the source tarball of
11948 the package is hosted, when applicable.
11949
11950 @item generic-git
11951 a generic updater for packages hosted on Git repositories. It tries to
11952 be smart about parsing Git tag names, but if it is not able to parse the
11953 tag name and compare tags correctly, users can define the following
11954 properties for a package.
11955
11956 @itemize
11957 @item @code{release-tag-prefix}: a regular expression for matching a prefix of
11958 the tag name.
11959
11960 @item @code{release-tag-suffix}: a regular expression for matching a suffix of
11961 the tag name.
11962
11963 @item @code{release-tag-version-delimiter}: a string used as the delimiter in
11964 the tag name for separating the numbers of the version.
11965
11966 @item @code{accept-pre-releases}: by default, the updater will ignore
11967 pre-releases; to make it also look for pre-releases, set the this
11968 property to @code{#t}.
11969
11970 @end itemize
11971
11972 @lisp
11973 (package
11974 (name "foo")
11975 ;; ...
11976 (properties
11977 '((release-tag-prefix . "^release0-")
11978 (release-tag-suffix . "[a-z]?$")
11979 (release-tag-version-delimiter . ":"))))
11980 @end lisp
11981
11982
11983 @end table
11984
11985 For instance, the following command only checks for updates of Emacs
11986 packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
11987
11988 @example
11989 $ guix refresh --type=elpa,cran
11990 gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
11991 gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
11992 @end example
11993
11994 @item --list-updaters
11995 @itemx -L
11996 List available updaters and exit (see @option{--type} above).
11997
11998 For each updater, display the fraction of packages it covers; at the
11999 end, display the fraction of packages covered by all these updaters.
12000 @end table
12001
12002 In addition, @command{guix refresh} can be passed one or more package
12003 names, as in this example:
12004
12005 @example
12006 $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
12007 @end example
12008
12009 @noindent
12010 The command above specifically updates the @code{emacs} and
12011 @code{idutils} packages. The @option{--select} option would have no
12012 effect in this case. You might also want to update definitions that
12013 correspond to the packages installed in your profile:
12014
12015 @example
12016 $ ./pre-inst-env guix refresh -u \
12017 $(guix package --list-installed | cut -f1)
12018 @end example
12019
12020 When considering whether to upgrade a package, it is sometimes
12021 convenient to know which packages would be affected by the upgrade and
12022 should be checked for compatibility. For this the following option may
12023 be used when passing @command{guix refresh} one or more package names:
12024
12025 @table @code
12026
12027 @item --list-dependent
12028 @itemx -l
12029 List top-level dependent packages that would need to be rebuilt as a
12030 result of upgrading one or more packages.
12031
12032 @xref{Invoking guix graph, the @code{reverse-package} type of
12033 @command{guix graph}}, for information on how to visualize the list of
12034 dependents of a package.
12035
12036 @end table
12037
12038 Be aware that the @option{--list-dependent} option only
12039 @emph{approximates} the rebuilds that would be required as a result of
12040 an upgrade. More rebuilds might be required under some circumstances.
12041
12042 @example
12043 $ guix refresh --list-dependent flex
12044 Building the following 120 packages would ensure 213 dependent packages are rebuilt:
12045 hop@@2.4.0 emacs-geiser@@0.13 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
12046 @end example
12047
12048 The command above lists a set of packages that could be built to check
12049 for compatibility with an upgraded @code{flex} package.
12050
12051 @table @code
12052
12053 @item --list-transitive
12054 List all the packages which one or more packages depend upon.
12055
12056 @example
12057 $ guix refresh --list-transitive flex
12058 flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
12059 bison@@3.0.5 indent@@2.2.10 tar@@1.30 gzip@@1.9 bzip2@@1.0.6 xz@@5.2.4 file@@5.33 @dots{}
12060 @end example
12061
12062 @end table
12063
12064 The command above lists a set of packages which, when changed, would cause
12065 @code{flex} to be rebuilt.
12066
12067 The following options can be used to customize GnuPG operation:
12068
12069 @table @code
12070
12071 @item --gpg=@var{command}
12072 Use @var{command} as the GnuPG 2.x command. @var{command} is searched
12073 for in @code{$PATH}.
12074
12075 @item --keyring=@var{file}
12076 Use @var{file} as the keyring for upstream keys. @var{file} must be in the
12077 @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
12078 and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
12079 (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
12080 information on a tool to manipulate keybox files).
12081
12082 When this option is omitted, @command{guix refresh} uses
12083 @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
12084 signing keys. OpenPGP signatures are checked against keys from this keyring;
12085 missing keys are downloaded to this keyring as well (see
12086 @option{--key-download} below).
12087
12088 You can export keys from your default GPG keyring into a keybox file using
12089 commands like this one:
12090
12091 @example
12092 gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
12093 @end example
12094
12095 Likewise, you can fetch keys to a specific keybox file like this:
12096
12097 @example
12098 gpg --no-default-keyring --keyring mykeyring.kbx \
12099 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
12100 @end example
12101
12102 @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
12103 Privacy Guard}, for more information on GPG's @option{--keyring} option.
12104
12105 @item --key-download=@var{policy}
12106 Handle missing OpenPGP keys according to @var{policy}, which may be one
12107 of:
12108
12109 @table @code
12110 @item always
12111 Always download missing OpenPGP keys from the key server, and add them
12112 to the user's GnuPG keyring.
12113
12114 @item never
12115 Never try to download missing OpenPGP keys. Instead just bail out.
12116
12117 @item interactive
12118 When a package signed with an unknown OpenPGP key is encountered, ask
12119 the user whether to download it or not. This is the default behavior.
12120 @end table
12121
12122 @item --key-server=@var{host}
12123 Use @var{host} as the OpenPGP key server when importing a public key.
12124
12125 @item --load-path=@var{directory}
12126 Add @var{directory} to the front of the package module search path
12127 (@pxref{Package Modules}).
12128
12129 This allows users to define their own packages and make them visible to
12130 the command-line tools.
12131
12132 @end table
12133
12134 The @code{github} updater uses the
12135 @uref{https://developer.github.com/v3/, GitHub API} to query for new
12136 releases. When used repeatedly e.g.@: when refreshing all packages,
12137 GitHub will eventually refuse to answer any further API requests. By
12138 default 60 API requests per hour are allowed, and a full refresh on all
12139 GitHub packages in Guix requires more than this. Authentication with
12140 GitHub through the use of an API token alleviates these limits. To use
12141 an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
12142 token procured from @uref{https://github.com/settings/tokens} or
12143 otherwise.
12144
12145
12146 @node Invoking guix lint
12147 @section Invoking @command{guix lint}
12148
12149 @cindex @command{guix lint}
12150 @cindex package, checking for errors
12151 The @command{guix lint} command is meant to help package developers avoid
12152 common errors and use a consistent style. It runs a number of checks on
12153 a given set of packages in order to find common mistakes in their
12154 definitions. Available @dfn{checkers} include (see
12155 @option{--list-checkers} for a complete list):
12156
12157 @table @code
12158 @item synopsis
12159 @itemx description
12160 Validate certain typographical and stylistic rules about package
12161 descriptions and synopses.
12162
12163 @item inputs-should-be-native
12164 Identify inputs that should most likely be native inputs.
12165
12166 @item source
12167 @itemx home-page
12168 @itemx mirror-url
12169 @itemx github-url
12170 @itemx source-file-name
12171 Probe @code{home-page} and @code{source} URLs and report those that are
12172 invalid. Suggest a @code{mirror://} URL when applicable. If the
12173 @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
12174 URL@. Check that the source file name is meaningful, e.g.@: is not just a
12175 version number or ``git-checkout'', without a declared @code{file-name}
12176 (@pxref{origin Reference}).
12177
12178 @item source-unstable-tarball
12179 Parse the @code{source} URL to determine if a tarball from GitHub is
12180 autogenerated or if it is a release tarball. Unfortunately GitHub's
12181 autogenerated tarballs are sometimes regenerated.
12182
12183 @item derivation
12184 Check that the derivation of the given packages can be successfully
12185 computed for all the supported systems (@pxref{Derivations}).
12186
12187 @item profile-collisions
12188 Check whether installing the given packages in a profile would lead to
12189 collisions. Collisions occur when several packages with the same name
12190 but a different version or a different store file name are propagated.
12191 @xref{package Reference, @code{propagated-inputs}}, for more information
12192 on propagated inputs.
12193
12194 @item archival
12195 @cindex Software Heritage, source code archive
12196 @cindex archival of source code, Software Heritage
12197 Checks whether the package's source code is archived at
12198 @uref{https://www.softwareheritage.org, Software Heritage}.
12199
12200 When the source code that is not archived comes from a version-control system
12201 (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
12202 ``save'' request so that it eventually archives it. This ensures that the
12203 source will remain available in the long term, and that Guix can fall back to
12204 Software Heritage should the source code disappear from its original host.
12205 The status of recent ``save'' requests can be
12206 @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
12207
12208 When source code is a tarball obtained with @code{url-fetch}, simply print a
12209 message when it is not archived. As of this writing, Software Heritage does
12210 not allow requests to save arbitrary tarballs; we are working on ways to
12211 ensure that non-VCS source code is also archived.
12212
12213 Software Heritage
12214 @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
12215 request rate per IP address}. When the limit is reached, @command{guix lint}
12216 prints a message and the @code{archival} checker stops doing anything until
12217 that limit has been reset.
12218
12219 @item cve
12220 @cindex security vulnerabilities
12221 @cindex CVE, Common Vulnerabilities and Exposures
12222 Report known vulnerabilities found in the Common Vulnerabilities and
12223 Exposures (CVE) databases of the current and past year
12224 @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
12225 NIST}.
12226
12227 To view information about a particular vulnerability, visit pages such as:
12228
12229 @itemize
12230 @item
12231 @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
12232 @item
12233 @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
12234 @end itemize
12235
12236 @noindent
12237 where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
12238 @code{CVE-2015-7554}.
12239
12240 Package developers can specify in package recipes the
12241 @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
12242 name and version of the package when they differ from the name or version
12243 that Guix uses, as in this example:
12244
12245 @lisp
12246 (package
12247 (name "grub")
12248 ;; @dots{}
12249 ;; CPE calls this package "grub2".
12250 (properties '((cpe-name . "grub2")
12251 (cpe-version . "2.3"))))
12252 @end lisp
12253
12254 @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
12255 Some entries in the CVE database do not specify which version of a
12256 package they apply to, and would thus ``stick around'' forever. Package
12257 developers who found CVE alerts and verified they can be ignored can
12258 declare them as in this example:
12259
12260 @lisp
12261 (package
12262 (name "t1lib")
12263 ;; @dots{}
12264 ;; These CVEs no longer apply and can be safely ignored.
12265 (properties `((lint-hidden-cve . ("CVE-2011-0433"
12266 "CVE-2011-1553"
12267 "CVE-2011-1554"
12268 "CVE-2011-5244")))))
12269 @end lisp
12270
12271 @item formatting
12272 Warn about obvious source code formatting issues: trailing white space,
12273 use of tabulations, etc.
12274 @end table
12275
12276 The general syntax is:
12277
12278 @example
12279 guix lint @var{options} @var{package}@dots{}
12280 @end example
12281
12282 If no package is given on the command line, then all packages are checked.
12283 The @var{options} may be zero or more of the following:
12284
12285 @table @code
12286 @item --list-checkers
12287 @itemx -l
12288 List and describe all the available checkers that will be run on packages
12289 and exit.
12290
12291 @item --checkers
12292 @itemx -c
12293 Only enable the checkers specified in a comma-separated list using the
12294 names returned by @option{--list-checkers}.
12295
12296 @item --exclude
12297 @itemx -x
12298 Only disable the checkers specified in a comma-separated list using the
12299 names returned by @option{--list-checkers}.
12300
12301 @item --no-network
12302 @itemx -n
12303 Only enable the checkers that do not depend on Internet access.
12304
12305 @item --load-path=@var{directory}
12306 @itemx -L @var{directory}
12307 Add @var{directory} to the front of the package module search path
12308 (@pxref{Package Modules}).
12309
12310 This allows users to define their own packages and make them visible to
12311 the command-line tools.
12312
12313 @end table
12314
12315 @node Invoking guix size
12316 @section Invoking @command{guix size}
12317
12318 @cindex size
12319 @cindex package size
12320 @cindex closure
12321 @cindex @command{guix size}
12322 The @command{guix size} command helps package developers profile the
12323 disk usage of packages. It is easy to overlook the impact of an
12324 additional dependency added to a package, or the impact of using a
12325 single output for a package that could easily be split (@pxref{Packages
12326 with Multiple Outputs}). Such are the typical issues that
12327 @command{guix size} can highlight.
12328
12329 The command can be passed one or more package specifications
12330 such as @code{gcc@@4.8}
12331 or @code{guile:debug}, or a file name in the store. Consider this
12332 example:
12333
12334 @example
12335 $ guix size coreutils
12336 store item total self
12337 /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
12338 /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
12339 /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
12340 /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
12341 /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
12342 /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
12343 /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
12344 /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
12345 total: 78.9 MiB
12346 @end example
12347
12348 @cindex closure
12349 The store items listed here constitute the @dfn{transitive closure} of
12350 Coreutils---i.e., Coreutils and all its dependencies, recursively---as
12351 would be returned by:
12352
12353 @example
12354 $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
12355 @end example
12356
12357 Here the output shows three columns next to store items. The first column,
12358 labeled ``total'', shows the size in mebibytes (MiB) of the closure of
12359 the store item---that is, its own size plus the size of all its
12360 dependencies. The next column, labeled ``self'', shows the size of the
12361 item itself. The last column shows the ratio of the size of the item
12362 itself to the space occupied by all the items listed here.
12363
12364 In this example, we see that the closure of Coreutils weighs in at
12365 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
12366 libraries. (That libc and GCC's libraries represent a large fraction of
12367 the closure is not a problem @i{per se} because they are always available
12368 on the system anyway.)
12369
12370 Since the command also accepts store file names, assessing the size of
12371 a build result is straightforward:
12372
12373 @example
12374 guix size $(guix system build config.scm)
12375 @end example
12376
12377 When the package(s) passed to @command{guix size} are available in the
12378 store@footnote{More precisely, @command{guix size} looks for the
12379 @emph{ungrafted} variant of the given package(s), as returned by
12380 @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
12381 for information on grafts.}, @command{guix size} queries the daemon to determine its
12382 dependencies, and measures its size in the store, similar to @command{du
12383 -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
12384 Coreutils}).
12385
12386 When the given packages are @emph{not} in the store, @command{guix size}
12387 reports information based on the available substitutes
12388 (@pxref{Substitutes}). This makes it possible it to profile disk usage of
12389 store items that are not even on disk, only available remotely.
12390
12391 You can also specify several package names:
12392
12393 @example
12394 $ guix size coreutils grep sed bash
12395 store item total self
12396 /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
12397 /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
12398 /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
12399 /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
12400 @dots{}
12401 total: 102.3 MiB
12402 @end example
12403
12404 @noindent
12405 In this example we see that the combination of the four packages takes
12406 102.3@tie{}MiB in total, which is much less than the sum of each closure
12407 since they have a lot of dependencies in common.
12408
12409 When looking at the profile returned by @command{guix size}, you may
12410 find yourself wondering why a given package shows up in the profile at
12411 all. To understand it, you can use @command{guix graph --path -t
12412 references} to display the shortest path between the two packages
12413 (@pxref{Invoking guix graph}).
12414
12415 The available options are:
12416
12417 @table @option
12418
12419 @item --substitute-urls=@var{urls}
12420 Use substitute information from @var{urls}.
12421 @xref{client-substitute-urls, the same option for @code{guix build}}.
12422
12423 @item --sort=@var{key}
12424 Sort lines according to @var{key}, one of the following options:
12425
12426 @table @code
12427 @item self
12428 the size of each item (the default);
12429 @item closure
12430 the total size of the item's closure.
12431 @end table
12432
12433 @item --map-file=@var{file}
12434 Write a graphical map of disk usage in PNG format to @var{file}.
12435
12436 For the example above, the map looks like this:
12437
12438 @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
12439 produced by @command{guix size}}
12440
12441 This option requires that
12442 @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
12443 installed and visible in Guile's module search path. When that is not
12444 the case, @command{guix size} fails as it tries to load it.
12445
12446 @item --system=@var{system}
12447 @itemx -s @var{system}
12448 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
12449
12450 @item --load-path=@var{directory}
12451 @itemx -L @var{directory}
12452 Add @var{directory} to the front of the package module search path
12453 (@pxref{Package Modules}).
12454
12455 This allows users to define their own packages and make them visible to
12456 the command-line tools.
12457 @end table
12458
12459 @node Invoking guix graph
12460 @section Invoking @command{guix graph}
12461
12462 @cindex DAG
12463 @cindex @command{guix graph}
12464 @cindex package dependencies
12465 Packages and their dependencies form a @dfn{graph}, specifically a
12466 directed acyclic graph (DAG). It can quickly become difficult to have a
12467 mental model of the package DAG, so the @command{guix graph} command
12468 provides a visual representation of the DAG@. By default,
12469 @command{guix graph} emits a DAG representation in the input format of
12470 @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
12471 directly to the @command{dot} command of Graphviz. It can also emit an
12472 HTML page with embedded JavaScript code to display a ``chord diagram''
12473 in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
12474 emit Cypher queries to construct a graph in a graph database supporting
12475 the @uref{https://www.opencypher.org/, openCypher} query language. With
12476 @option{--path}, it simply displays the shortest path between two
12477 packages. The general syntax is:
12478
12479 @example
12480 guix graph @var{options} @var{package}@dots{}
12481 @end example
12482
12483 For example, the following command generates a PDF file representing the
12484 package DAG for the GNU@tie{}Core Utilities, showing its build-time
12485 dependencies:
12486
12487 @example
12488 guix graph coreutils | dot -Tpdf > dag.pdf
12489 @end example
12490
12491 The output looks like this:
12492
12493 @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
12494
12495 Nice little graph, no?
12496
12497 You may find it more pleasant to navigate the graph interactively with
12498 @command{xdot} (from the @code{xdot} package):
12499
12500 @example
12501 guix graph coreutils | xdot -
12502 @end example
12503
12504 But there is more than one graph! The one above is concise: it is the
12505 graph of package objects, omitting implicit inputs such as GCC, libc,
12506 grep, etc. It is often useful to have such a concise graph, but
12507 sometimes one may want to see more details. @command{guix graph} supports
12508 several types of graphs, allowing you to choose the level of detail:
12509
12510 @table @code
12511 @item package
12512 This is the default type used in the example above. It shows the DAG of
12513 package objects, excluding implicit dependencies. It is concise, but
12514 filters out many details.
12515
12516 @item reverse-package
12517 This shows the @emph{reverse} DAG of packages. For example:
12518
12519 @example
12520 guix graph --type=reverse-package ocaml
12521 @end example
12522
12523 ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
12524 you are also interested in cases where OCaml is an implicit dependency, see
12525 @code{reverse-bag} below).
12526
12527 Note that for core packages this can yield huge graphs. If all you want
12528 is to know the number of packages that depend on a given package, use
12529 @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
12530 @option{--list-dependent}}).
12531
12532 @item bag-emerged
12533 This is the package DAG, @emph{including} implicit inputs.
12534
12535 For instance, the following command:
12536
12537 @example
12538 guix graph --type=bag-emerged coreutils
12539 @end example
12540
12541 ...@: yields this bigger graph:
12542
12543 @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
12544
12545 At the bottom of the graph, we see all the implicit inputs of
12546 @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
12547
12548 Now, note that the dependencies of these implicit inputs---that is, the
12549 @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
12550 here, for conciseness.
12551
12552 @item bag
12553 Similar to @code{bag-emerged}, but this time including all the bootstrap
12554 dependencies.
12555
12556 @item bag-with-origins
12557 Similar to @code{bag}, but also showing origins and their dependencies.
12558
12559 @item reverse-bag
12560 This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
12561 it also takes implicit dependencies into account. For example:
12562
12563 @example
12564 guix graph -t reverse-bag dune
12565 @end example
12566
12567 @noindent
12568 ...@: yields the graph of all packages that depend on Dune, directly or
12569 indirectly. Since Dune is an @emph{implicit} dependency of many packages
12570 @i{via} @code{dune-build-system}, this shows a large number of packages,
12571 whereas @code{reverse-package} would show very few if any.
12572
12573 @item derivation
12574 This is the most detailed representation: It shows the DAG of
12575 derivations (@pxref{Derivations}) and plain store items. Compared to
12576 the above representation, many additional nodes are visible, including
12577 build scripts, patches, Guile modules, etc.
12578
12579 For this type of graph, it is also possible to pass a @file{.drv} file
12580 name instead of a package name, as in:
12581
12582 @example
12583 guix graph -t derivation $(guix system build -d my-config.scm)
12584 @end example
12585
12586 @item module
12587 This is the graph of @dfn{package modules} (@pxref{Package Modules}).
12588 For example, the following command shows the graph for the package
12589 module that defines the @code{guile} package:
12590
12591 @example
12592 guix graph -t module guile | xdot -
12593 @end example
12594 @end table
12595
12596 All the types above correspond to @emph{build-time dependencies}. The
12597 following graph type represents the @emph{run-time dependencies}:
12598
12599 @table @code
12600 @item references
12601 This is the graph of @dfn{references} of a package output, as returned
12602 by @command{guix gc --references} (@pxref{Invoking guix gc}).
12603
12604 If the given package output is not available in the store, @command{guix
12605 graph} attempts to obtain dependency information from substitutes.
12606
12607 Here you can also pass a store file name instead of a package name. For
12608 example, the command below produces the reference graph of your profile
12609 (which can be big!):
12610
12611 @example
12612 guix graph -t references $(readlink -f ~/.guix-profile)
12613 @end example
12614
12615 @item referrers
12616 This is the graph of the @dfn{referrers} of a store item, as returned by
12617 @command{guix gc --referrers} (@pxref{Invoking guix gc}).
12618
12619 This relies exclusively on local information from your store. For
12620 instance, let us suppose that the current Inkscape is available in 10
12621 profiles on your machine; @command{guix graph -t referrers inkscape}
12622 will show a graph rooted at Inkscape and with those 10 profiles linked
12623 to it.
12624
12625 It can help determine what is preventing a store item from being garbage
12626 collected.
12627
12628 @end table
12629
12630 @cindex shortest path, between packages
12631 Often, the graph of the package you are interested in does not fit on
12632 your screen, and anyway all you want to know is @emph{why} that package
12633 actually depends on some seemingly unrelated package. The
12634 @option{--path} option instructs @command{guix graph} to display the
12635 shortest path between two packages (or derivations, or store items,
12636 etc.):
12637
12638 @example
12639 $ guix graph --path emacs libunistring
12640 emacs@@26.3
12641 mailutils@@3.9
12642 libunistring@@0.9.10
12643 $ guix graph --path -t derivation emacs libunistring
12644 /gnu/store/@dots{}-emacs-26.3.drv
12645 /gnu/store/@dots{}-mailutils-3.9.drv
12646 /gnu/store/@dots{}-libunistring-0.9.10.drv
12647 $ guix graph --path -t references emacs libunistring
12648 /gnu/store/@dots{}-emacs-26.3
12649 /gnu/store/@dots{}-libidn2-2.2.0
12650 /gnu/store/@dots{}-libunistring-0.9.10
12651 @end example
12652
12653 Sometimes you still want to visualize the graph but would like to trim
12654 it so it can actually be displayed. One way to do it is via the
12655 @option{--max-depth} (or @option{-M}) option, which lets you specify the
12656 maximum depth of the graph. In the example below, we visualize only
12657 @code{libreoffice} and the nodes whose distance to @code{libreoffice} is
12658 at most 2:
12659
12660 @example
12661 guix graph -M 2 libreoffice | xdot -f fdp -
12662 @end example
12663
12664 Mind you, that's still a big ball of spaghetti, but at least
12665 @command{dot} can render it quickly and it can be browsed somewhat.
12666
12667 The available options are the following:
12668
12669 @table @option
12670 @item --type=@var{type}
12671 @itemx -t @var{type}
12672 Produce a graph output of @var{type}, where @var{type} must be one of
12673 the values listed above.
12674
12675 @item --list-types
12676 List the supported graph types.
12677
12678 @item --backend=@var{backend}
12679 @itemx -b @var{backend}
12680 Produce a graph using the selected @var{backend}.
12681
12682 @item --list-backends
12683 List the supported graph backends.
12684
12685 Currently, the available backends are Graphviz and d3.js.
12686
12687 @item --path
12688 Display the shortest path between two nodes of the type specified by
12689 @option{--type}. The example below shows the shortest path between
12690 @code{libreoffice} and @code{llvm} according to the references of
12691 @code{libreoffice}:
12692
12693 @example
12694 $ guix graph --path -t references libreoffice llvm
12695 /gnu/store/@dots{}-libreoffice-6.4.2.2
12696 /gnu/store/@dots{}-libepoxy-1.5.4
12697 /gnu/store/@dots{}-mesa-19.3.4
12698 /gnu/store/@dots{}-llvm-9.0.1
12699 @end example
12700
12701 @item --expression=@var{expr}
12702 @itemx -e @var{expr}
12703 Consider the package @var{expr} evaluates to.
12704
12705 This is useful to precisely refer to a package, as in this example:
12706
12707 @example
12708 guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
12709 @end example
12710
12711 @item --system=@var{system}
12712 @itemx -s @var{system}
12713 Display the graph for @var{system}---e.g., @code{i686-linux}.
12714
12715 The package dependency graph is largely architecture-independent, but there
12716 are some architecture-dependent bits that this option allows you to visualize.
12717
12718 @item --load-path=@var{directory}
12719 @itemx -L @var{directory}
12720 Add @var{directory} to the front of the package module search path
12721 (@pxref{Package Modules}).
12722
12723 This allows users to define their own packages and make them visible to
12724 the command-line tools.
12725 @end table
12726
12727 On top of that, @command{guix graph} supports all the usual package
12728 transformation options (@pxref{Package Transformation Options}). This
12729 makes it easy to view the effect of a graph-rewriting transformation
12730 such as @option{--with-input}. For example, the command below outputs
12731 the graph of @code{git} once @code{openssl} has been replaced by
12732 @code{libressl} everywhere in the graph:
12733
12734 @example
12735 guix graph git --with-input=openssl=libressl
12736 @end example
12737
12738 So many possibilities, so much fun!
12739
12740 @node Invoking guix publish
12741 @section Invoking @command{guix publish}
12742
12743 @cindex @command{guix publish}
12744 The purpose of @command{guix publish} is to enable users to easily share
12745 their store with others, who can then use it as a substitute server
12746 (@pxref{Substitutes}).
12747
12748 When @command{guix publish} runs, it spawns an HTTP server which allows
12749 anyone with network access to obtain substitutes from it. This means
12750 that any machine running Guix can also act as if it were a build farm,
12751 since the HTTP interface is compatible with Cuirass, the software behind
12752 the @code{@value{SUBSTITUTE-SERVER-1}} build farm.
12753
12754 For security, each substitute is signed, allowing recipients to check
12755 their authenticity and integrity (@pxref{Substitutes}). Because
12756 @command{guix publish} uses the signing key of the system, which is only
12757 readable by the system administrator, it must be started as root; the
12758 @option{--user} option makes it drop root privileges early on.
12759
12760 The signing key pair must be generated before @command{guix publish} is
12761 launched, using @command{guix archive --generate-key} (@pxref{Invoking
12762 guix archive}).
12763
12764 When the @option{--advertise} option is passed, the server advertises
12765 its availability on the local network using multicast DNS (mDNS) and DNS
12766 service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
12767 guile-avahi, Using Avahi in Guile Scheme Programs}).
12768
12769 The general syntax is:
12770
12771 @example
12772 guix publish @var{options}@dots{}
12773 @end example
12774
12775 Running @command{guix publish} without any additional arguments will
12776 spawn an HTTP server on port 8080:
12777
12778 @example
12779 guix publish
12780 @end example
12781
12782 Once a publishing server has been authorized, the daemon may download
12783 substitutes from it. @xref{Getting Substitutes from Other Servers}.
12784
12785 By default, @command{guix publish} compresses archives on the fly as it
12786 serves them. This ``on-the-fly'' mode is convenient in that it requires
12787 no setup and is immediately available. However, when serving lots of
12788 clients, we recommend using the @option{--cache} option, which enables
12789 caching of the archives before they are sent to clients---see below for
12790 details. The @command{guix weather} command provides a handy way to
12791 check what a server provides (@pxref{Invoking guix weather}).
12792
12793 As a bonus, @command{guix publish} also serves as a content-addressed
12794 mirror for source files referenced in @code{origin} records
12795 (@pxref{origin Reference}). For instance, assuming @command{guix
12796 publish} is running on @code{example.org}, the following URL returns the
12797 raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
12798 (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
12799
12800 @example
12801 http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
12802 @end example
12803
12804 Obviously, these URLs only work for files that are in the store; in
12805 other cases, they return 404 (``Not Found'').
12806
12807 @cindex build logs, publication
12808 Build logs are available from @code{/log} URLs like:
12809
12810 @example
12811 http://example.org/log/gwspk@dots{}-guile-2.2.3
12812 @end example
12813
12814 @noindent
12815 When @command{guix-daemon} is configured to save compressed build logs,
12816 as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
12817 URLs return the compressed log as-is, with an appropriate
12818 @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
12819 running @command{guix-daemon} with @option{--log-compression=gzip} since
12820 Web browsers can automatically decompress it, which is not the case with
12821 Bzip2 compression.
12822
12823 The following options are available:
12824
12825 @table @code
12826 @item --port=@var{port}
12827 @itemx -p @var{port}
12828 Listen for HTTP requests on @var{port}.
12829
12830 @item --listen=@var{host}
12831 Listen on the network interface for @var{host}. The default is to
12832 accept connections from any interface.
12833
12834 @item --user=@var{user}
12835 @itemx -u @var{user}
12836 Change privileges to @var{user} as soon as possible---i.e., once the
12837 server socket is open and the signing key has been read.
12838
12839 @item --compression[=@var{method}[:@var{level}]]
12840 @itemx -C [@var{method}[:@var{level}]]
12841 Compress data using the given @var{method} and @var{level}. @var{method} is
12842 one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
12843 omitted, @code{gzip} is used.
12844
12845 When @var{level} is zero, disable compression. The range 1 to 9 corresponds
12846 to different compression levels: 1 is the fastest, and 9 is the best
12847 (CPU-intensive). The default is 3.
12848
12849 Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
12850 small increase in CPU usage; see
12851 @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
12852 Web page}. However, @code{lzip} achieves low decompression throughput
12853 (on the order of 50@tie{}MiB/s on modern hardware), which can be a
12854 bottleneck for someone who downloads over a fast network connection.
12855
12856 The compression ratio of @code{zstd} is between that of @code{lzip} and
12857 that of @code{gzip}; its main advantage is a
12858 @uref{https://facebook.github.io/zstd/,high decompression speed}.
12859
12860 Unless @option{--cache} is used, compression occurs on the fly and
12861 the compressed streams are not
12862 cached. Thus, to reduce load on the machine that runs @command{guix
12863 publish}, it may be a good idea to choose a low compression level, to
12864 run @command{guix publish} behind a caching proxy, or to use
12865 @option{--cache}. Using @option{--cache} has the advantage that it
12866 allows @command{guix publish} to add @code{Content-Length} HTTP header
12867 to its responses.
12868
12869 This option can be repeated, in which case every substitute gets compressed
12870 using all the selected methods, and all of them are advertised. This is
12871 useful when users may not support all the compression methods: they can select
12872 the one they support.
12873
12874 @item --cache=@var{directory}
12875 @itemx -c @var{directory}
12876 Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
12877 and only serve archives that are in cache.
12878
12879 When this option is omitted, archives and meta-data are created
12880 on-the-fly. This can reduce the available bandwidth, especially when
12881 compression is enabled, since this may become CPU-bound. Another
12882 drawback of the default mode is that the length of archives is not known
12883 in advance, so @command{guix publish} does not add a
12884 @code{Content-Length} HTTP header to its responses, which in turn
12885 prevents clients from knowing the amount of data being downloaded.
12886
12887 Conversely, when @option{--cache} is used, the first request for a store
12888 item (@i{via} a @code{.narinfo} URL) triggers a
12889 background process to @dfn{bake} the archive---computing its
12890 @code{.narinfo} and compressing the archive, if needed. Once the
12891 archive is cached in @var{directory}, subsequent requests succeed and
12892 are served directly from the cache, which guarantees that clients get
12893 the best possible bandwidth.
12894
12895 That first @code{.narinfo} request nonetheless returns 200, provided the
12896 requested store item is ``small enough'', below the cache bypass
12897 threshold---see @option{--cache-bypass-threshold} below. That way,
12898 clients do not have to wait until the archive is baked. For larger
12899 store items, the first @code{.narinfo} request returns 404, meaning that
12900 clients have to wait until the archive is baked.
12901
12902 The ``baking'' process is performed by worker threads. By default, one
12903 thread per CPU core is created, but this can be customized. See
12904 @option{--workers} below.
12905
12906 When @option{--ttl} is used, cached entries are automatically deleted
12907 when they have expired.
12908
12909 @item --workers=@var{N}
12910 When @option{--cache} is used, request the allocation of @var{N} worker
12911 threads to ``bake'' archives.
12912
12913 @item --ttl=@var{ttl}
12914 Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
12915 (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
12916 days, @code{1m} means 1 month, and so on.
12917
12918 This allows the user's Guix to keep substitute information in cache for
12919 @var{ttl}. However, note that @code{guix publish} does not itself
12920 guarantee that the store items it provides will indeed remain available
12921 for as long as @var{ttl}.
12922
12923 Additionally, when @option{--cache} is used, cached entries that have
12924 not been accessed for @var{ttl} and that no longer have a corresponding
12925 item in the store, may be deleted.
12926
12927 @item --negative-ttl=@var{ttl}
12928 Similarly produce @code{Cache-Control} HTTP headers to advertise the
12929 time-to-live (TTL) of @emph{negative} lookups---missing store items, for
12930 which the HTTP 404 code is returned. By default, no negative TTL is
12931 advertised.
12932
12933 This parameter can help adjust server load and substitute latency by
12934 instructing cooperating clients to be more or less patient when a store
12935 item is missing.
12936
12937 @item --cache-bypass-threshold=@var{size}
12938 When used in conjunction with @option{--cache}, store items smaller than
12939 @var{size} are immediately available, even when they are not yet in
12940 cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
12941 for megabytes and so on. The default is @code{10M}.
12942
12943 ``Cache bypass'' allows you to reduce the publication delay for clients
12944 at the expense of possibly additional I/O and CPU use on the server
12945 side: depending on the client access patterns, those store items can end
12946 up being baked several times until a copy is available in cache.
12947
12948 Increasing the threshold may be useful for sites that have few users, or
12949 to guarantee that users get substitutes even for store items that are
12950 not popular.
12951
12952 @item --nar-path=@var{path}
12953 Use @var{path} as the prefix for the URLs of ``nar'' files
12954 (@pxref{Invoking guix archive, normalized archives}).
12955
12956 By default, nars are served at a URL such as
12957 @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
12958 change the @code{/nar} part to @var{path}.
12959
12960 @item --public-key=@var{file}
12961 @itemx --private-key=@var{file}
12962 Use the specific @var{file}s as the public/private key pair used to sign
12963 the store items being published.
12964
12965 The files must correspond to the same key pair (the private key is used
12966 for signing and the public key is merely advertised in the signature
12967 metadata). They must contain keys in the canonical s-expression format
12968 as produced by @command{guix archive --generate-key} (@pxref{Invoking
12969 guix archive}). By default, @file{/etc/guix/signing-key.pub} and
12970 @file{/etc/guix/signing-key.sec} are used.
12971
12972 @item --repl[=@var{port}]
12973 @itemx -r [@var{port}]
12974 Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
12975 Reference Manual}) on @var{port} (37146 by default). This is used
12976 primarily for debugging a running @command{guix publish} server.
12977 @end table
12978
12979 Enabling @command{guix publish} on Guix System is a one-liner: just
12980 instantiate a @code{guix-publish-service-type} service in the @code{services} field
12981 of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
12982 @code{guix-publish-service-type}}).
12983
12984 If you are instead running Guix on a ``foreign distro'', follow these
12985 instructions:
12986
12987 @itemize
12988 @item
12989 If your host distro uses the systemd init system:
12990
12991 @example
12992 # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
12993 /etc/systemd/system/
12994 # systemctl start guix-publish && systemctl enable guix-publish
12995 @end example
12996
12997 @item
12998 If your host distro uses the Upstart init system:
12999
13000 @example
13001 # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
13002 # start guix-publish
13003 @end example
13004
13005 @item
13006 Otherwise, proceed similarly with your distro's init system.
13007 @end itemize
13008
13009 @node Invoking guix challenge
13010 @section Invoking @command{guix challenge}
13011
13012 @cindex reproducible builds
13013 @cindex verifiable builds
13014 @cindex @command{guix challenge}
13015 @cindex challenge
13016 Do the binaries provided by this server really correspond to the source
13017 code it claims to build? Is a package build process deterministic?
13018 These are the questions the @command{guix challenge} command attempts to
13019 answer.
13020
13021 The former is obviously an important question: Before using a substitute
13022 server (@pxref{Substitutes}), one had better @emph{verify} that it
13023 provides the right binaries, and thus @emph{challenge} it. The latter
13024 is what enables the former: If package builds are deterministic, then
13025 independent builds of the package should yield the exact same result,
13026 bit for bit; if a server provides a binary different from the one
13027 obtained locally, it may be either corrupt or malicious.
13028
13029 We know that the hash that shows up in @file{/gnu/store} file names is
13030 the hash of all the inputs of the process that built the file or
13031 directory---compilers, libraries, build scripts,
13032 etc. (@pxref{Introduction}). Assuming deterministic build processes,
13033 one store file name should map to exactly one build output.
13034 @command{guix challenge} checks whether there is, indeed, a single
13035 mapping by comparing the build outputs of several independent builds of
13036 any given store item.
13037
13038 The command output looks like this:
13039
13040 @smallexample
13041 $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
13042 updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER-1}'... 100.0%
13043 updating list of substitutes from 'https://guix.example.org'... 100.0%
13044 /gnu/store/@dots{}-openssl-1.0.2d contents differ:
13045 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
13046 https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
13047 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
13048 differing files:
13049 /lib/libcrypto.so.1.1
13050 /lib/libssl.so.1.1
13051
13052 /gnu/store/@dots{}-git-2.5.0 contents differ:
13053 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
13054 https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
13055 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
13056 differing file:
13057 /libexec/git-core/git-fsck
13058
13059 /gnu/store/@dots{}-pius-2.1.1 contents differ:
13060 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
13061 https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
13062 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
13063 differing file:
13064 /share/man/man1/pius.1.gz
13065
13066 @dots{}
13067
13068 6,406 store items were analyzed:
13069 - 4,749 (74.1%) were identical
13070 - 525 (8.2%) differed
13071 - 1,132 (17.7%) were inconclusive
13072 @end smallexample
13073
13074 @noindent
13075 In this example, @command{guix challenge} first scans the store to
13076 determine the set of locally-built derivations---as opposed to store
13077 items that were downloaded from a substitute server---and then queries
13078 all the substitute servers. It then reports those store items for which
13079 the servers obtained a result different from the local build.
13080
13081 @cindex non-determinism, in package builds
13082 As an example, @code{guix.example.org} always gets a different answer.
13083 Conversely, @code{@value{SUBSTITUTE-SERVER-1}} agrees with local builds, except in the
13084 case of Git. This might indicate that the build process of Git is
13085 non-deterministic, meaning that its output varies as a function of
13086 various things that Guix does not fully control, in spite of building
13087 packages in isolated environments (@pxref{Features}). Most common
13088 sources of non-determinism include the addition of timestamps in build
13089 results, the inclusion of random numbers, and directory listings sorted
13090 by inode number. See @uref{https://reproducible-builds.org/docs/}, for
13091 more information.
13092
13093 To find out what is wrong with this Git binary, the easiest approach is
13094 to run:
13095
13096 @example
13097 guix challenge git \
13098 --diff=diffoscope \
13099 --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
13100 @end example
13101
13102 This automatically invokes @command{diffoscope}, which displays detailed
13103 information about files that differ.
13104
13105 Alternatively, we can do something along these lines (@pxref{Invoking guix
13106 archive}):
13107
13108 @example
13109 $ wget -q -O - https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-git-2.5.0 \
13110 | lzip -d | guix archive -x /tmp/git
13111 $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
13112 @end example
13113
13114 This command shows the difference between the files resulting from the
13115 local build, and the files resulting from the build on
13116 @code{@value{SUBSTITUTE-SERVER-1}} (@pxref{Overview, Comparing and Merging Files,,
13117 diffutils, Comparing and Merging Files}). The @command{diff} command
13118 works great for text files. When binary files differ, a better option
13119 is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
13120 visualize differences for all kinds of files.
13121
13122 Once you have done that work, you can tell whether the differences are due
13123 to a non-deterministic build process or to a malicious server. We try
13124 hard to remove sources of non-determinism in packages to make it easier
13125 to verify substitutes, but of course, this is a process that
13126 involves not just Guix, but a large part of the free software community.
13127 In the meantime, @command{guix challenge} is one tool to help address
13128 the problem.
13129
13130 If you are writing packages for Guix, you are encouraged to check
13131 whether @code{@value{SUBSTITUTE-SERVER-1}} and other substitute servers obtain the
13132 same build result as you did with:
13133
13134 @example
13135 $ guix challenge @var{package}
13136 @end example
13137
13138 @noindent
13139 where @var{package} is a package specification such as
13140 @code{guile@@2.0} or @code{glibc:debug}.
13141
13142 The general syntax is:
13143
13144 @example
13145 guix challenge @var{options} [@var{packages}@dots{}]
13146 @end example
13147
13148 When a difference is found between the hash of a locally-built item and
13149 that of a server-provided substitute, or among substitutes provided by
13150 different servers, the command displays it as in the example above and
13151 its exit code is 2 (other non-zero exit codes denote other kinds of
13152 errors).
13153
13154 The one option that matters is:
13155
13156 @table @code
13157
13158 @item --substitute-urls=@var{urls}
13159 Consider @var{urls} the whitespace-separated list of substitute source
13160 URLs to compare to.
13161
13162 @item --diff=@var{mode}
13163 Upon mismatches, show differences according to @var{mode}, one of:
13164
13165 @table @asis
13166 @item @code{simple} (the default)
13167 Show the list of files that differ.
13168
13169 @item @code{diffoscope}
13170 @itemx @var{command}
13171 Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
13172 two directories whose contents do not match.
13173
13174 When @var{command} is an absolute file name, run @var{command} instead
13175 of Diffoscope.
13176
13177 @item @code{none}
13178 Do not show further details about the differences.
13179 @end table
13180
13181 Thus, unless @option{--diff=none} is passed, @command{guix challenge}
13182 downloads the store items from the given substitute servers so that it
13183 can compare them.
13184
13185 @item --verbose
13186 @itemx -v
13187 Show details about matches (identical contents) in addition to
13188 information about mismatches.
13189
13190 @end table
13191
13192 @node Invoking guix copy
13193 @section Invoking @command{guix copy}
13194
13195 @cindex copy, of store items, over SSH
13196 @cindex SSH, copy of store items
13197 @cindex sharing store items across machines
13198 @cindex transferring store items across machines
13199 The @command{guix copy} command copies items from the store of one
13200 machine to that of another machine over a secure shell (SSH)
13201 connection@footnote{This command is available only when Guile-SSH was
13202 found. @xref{Requirements}, for details.}. For example, the following
13203 command copies the @code{coreutils} package, the user's profile, and all
13204 their dependencies over to @var{host}, logged in as @var{user}:
13205
13206 @example
13207 guix copy --to=@var{user}@@@var{host} \
13208 coreutils $(readlink -f ~/.guix-profile)
13209 @end example
13210
13211 If some of the items to be copied are already present on @var{host},
13212 they are not actually sent.
13213
13214 The command below retrieves @code{libreoffice} and @code{gimp} from
13215 @var{host}, assuming they are available there:
13216
13217 @example
13218 guix copy --from=@var{host} libreoffice gimp
13219 @end example
13220
13221 The SSH connection is established using the Guile-SSH client, which is
13222 compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
13223 @file{~/.ssh/config}, and uses the SSH agent for authentication.
13224
13225 The key used to sign items that are sent must be accepted by the remote
13226 machine. Likewise, the key used by the remote machine to sign items you
13227 are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
13228 own daemon. @xref{Invoking guix archive}, for more information about
13229 store item authentication.
13230
13231 The general syntax is:
13232
13233 @example
13234 guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
13235 @end example
13236
13237 You must always specify one of the following options:
13238
13239 @table @code
13240 @item --to=@var{spec}
13241 @itemx --from=@var{spec}
13242 Specify the host to send to or receive from. @var{spec} must be an SSH
13243 spec such as @code{example.org}, @code{charlie@@example.org}, or
13244 @code{charlie@@example.org:2222}.
13245 @end table
13246
13247 The @var{items} can be either package names, such as @code{gimp}, or
13248 store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
13249
13250 When specifying the name of a package to send, it is first built if
13251 needed, unless @option{--dry-run} was specified. Common build options
13252 are supported (@pxref{Common Build Options}).
13253
13254
13255 @node Invoking guix container
13256 @section Invoking @command{guix container}
13257 @cindex container
13258 @cindex @command{guix container}
13259 @quotation Note
13260 As of version @value{VERSION}, this tool is experimental. The interface
13261 is subject to radical change in the future.
13262 @end quotation
13263
13264 The purpose of @command{guix container} is to manipulate processes
13265 running within an isolated environment, commonly known as a
13266 ``container'', typically created by the @command{guix environment}
13267 (@pxref{Invoking guix environment}) and @command{guix system container}
13268 (@pxref{Invoking guix system}) commands.
13269
13270 The general syntax is:
13271
13272 @example
13273 guix container @var{action} @var{options}@dots{}
13274 @end example
13275
13276 @var{action} specifies the operation to perform with a container, and
13277 @var{options} specifies the context-specific arguments for the action.
13278
13279 The following actions are available:
13280
13281 @table @code
13282 @item exec
13283 Execute a command within the context of a running container.
13284
13285 The syntax is:
13286
13287 @example
13288 guix container exec @var{pid} @var{program} @var{arguments}@dots{}
13289 @end example
13290
13291 @var{pid} specifies the process ID of the running container.
13292 @var{program} specifies an executable file name within the root file
13293 system of the container. @var{arguments} are the additional options that
13294 will be passed to @var{program}.
13295
13296 The following command launches an interactive login shell inside a
13297 Guix system container, started by @command{guix system container}, and whose
13298 process ID is 9001:
13299
13300 @example
13301 guix container exec 9001 /run/current-system/profile/bin/bash --login
13302 @end example
13303
13304 Note that the @var{pid} cannot be the parent process of a container. It
13305 must be PID 1 of the container or one of its child processes.
13306
13307 @end table
13308
13309 @node Invoking guix weather
13310 @section Invoking @command{guix weather}
13311
13312 Occasionally you're grumpy because substitutes are lacking and you end
13313 up building packages by yourself (@pxref{Substitutes}). The
13314 @command{guix weather} command reports on substitute availability on the
13315 specified servers so you can have an idea of whether you'll be grumpy
13316 today. It can sometimes be useful info as a user, but it is primarily
13317 useful to people running @command{guix publish} (@pxref{Invoking guix
13318 publish}).
13319
13320 @cindex statistics, for substitutes
13321 @cindex availability of substitutes
13322 @cindex substitute availability
13323 @cindex weather, substitute availability
13324 Here's a sample run:
13325
13326 @example
13327 $ guix weather --substitute-urls=https://guix.example.org
13328 computing 5,872 package derivations for x86_64-linux...
13329 looking for 6,128 store items on https://guix.example.org..
13330 updating list of substitutes from 'https://guix.example.org'... 100.0%
13331 https://guix.example.org
13332 43.4% substitutes available (2,658 out of 6,128)
13333 7,032.5 MiB of nars (compressed)
13334 19,824.2 MiB on disk (uncompressed)
13335 0.030 seconds per request (182.9 seconds in total)
13336 33.5 requests per second
13337
13338 9.8% (342 out of 3,470) of the missing items are queued
13339 867 queued builds
13340 x86_64-linux: 518 (59.7%)
13341 i686-linux: 221 (25.5%)
13342 aarch64-linux: 128 (14.8%)
13343 build rate: 23.41 builds per hour
13344 x86_64-linux: 11.16 builds per hour
13345 i686-linux: 6.03 builds per hour
13346 aarch64-linux: 6.41 builds per hour
13347 @end example
13348
13349 @cindex continuous integration, statistics
13350 As you can see, it reports the fraction of all the packages for which
13351 substitutes are available on the server---regardless of whether
13352 substitutes are enabled, and regardless of whether this server's signing
13353 key is authorized. It also reports the size of the compressed archives
13354 (``nars'') provided by the server, the size the corresponding store
13355 items occupy in the store (assuming deduplication is turned off), and
13356 the server's throughput. The second part gives continuous integration
13357 (CI) statistics, if the server supports it. In addition, using the
13358 @option{--coverage} option, @command{guix weather} can list ``important''
13359 package substitutes missing on the server (see below).
13360
13361 To achieve that, @command{guix weather} queries over HTTP(S) meta-data
13362 (@dfn{narinfos}) for all the relevant store items. Like @command{guix
13363 challenge}, it ignores signatures on those substitutes, which is
13364 innocuous since the command only gathers statistics and cannot install
13365 those substitutes.
13366
13367 The general syntax is:
13368
13369 @example
13370 guix weather @var{options}@dots{} [@var{packages}@dots{}]
13371 @end example
13372
13373 When @var{packages} is omitted, @command{guix weather} checks the availability
13374 of substitutes for @emph{all} the packages, or for those specified with
13375 @option{--manifest}; otherwise it only considers the specified packages. It
13376 is also possible to query specific system types with @option{--system}.
13377 @command{guix weather} exits with a non-zero code when the fraction of
13378 available substitutes is below 100%.
13379
13380 The available options are listed below.
13381
13382 @table @code
13383 @item --substitute-urls=@var{urls}
13384 @var{urls} is the space-separated list of substitute server URLs to
13385 query. When this option is omitted, the default set of substitute
13386 servers is queried.
13387
13388 @item --system=@var{system}
13389 @itemx -s @var{system}
13390 Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
13391 option can be repeated, in which case @command{guix weather} will query
13392 substitutes for several system types.
13393
13394 @item --manifest=@var{file}
13395 Instead of querying substitutes for all the packages, only ask for those
13396 specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
13397 with the @code{-m} option of @command{guix package} (@pxref{Invoking
13398 guix package}).
13399
13400 This option can be repeated several times, in which case the manifests
13401 are concatenated.
13402
13403 @item --coverage[=@var{count}]
13404 @itemx -c [@var{count}]
13405 Report on substitute coverage for packages: list packages with at least
13406 @var{count} dependents (zero by default) for which substitutes are
13407 unavailable. Dependent packages themselves are not listed: if @var{b} depends
13408 on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
13409 @var{b} usually lacks substitutes as well. The result looks like this:
13410
13411 @example
13412 $ guix weather --substitute-urls=@value{SUBSTITUTE-URLS} -c 10
13413 computing 8,983 package derivations for x86_64-linux...
13414 looking for 9,343 store items on @value{SUBSTITUTE-URLS}...
13415 updating substitutes from '@value{SUBSTITUTE-URLS}'... 100.0%
13416 @value{SUBSTITUTE-URLS}
13417 64.7% substitutes available (6,047 out of 9,343)
13418 @dots{}
13419 2502 packages are missing from '@value{SUBSTITUTE-URLS}' for 'x86_64-linux', among which:
13420 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
13421 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
13422 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
13423 @dots{}
13424 @end example
13425
13426 What this example shows is that @code{kcoreaddons} and presumably the 58
13427 packages that depend on it have no substitutes at
13428 @code{@value{SUBSTITUTE-SERVER-1}}; likewise for @code{qgpgme} and the 46
13429 packages that depend on it.
13430
13431 If you are a Guix developer, or if you are taking care of this build farm,
13432 you'll probably want to have a closer look at these packages: they may simply
13433 fail to build.
13434
13435 @item --display-missing
13436 Display the list of store items for which substitutes are missing.
13437 @end table
13438
13439 @node Invoking guix processes
13440 @section Invoking @command{guix processes}
13441
13442 The @command{guix processes} command can be useful to developers and system
13443 administrators, especially on multi-user machines and on build farms: it lists
13444 the current sessions (connections to the daemon), as well as information about
13445 the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
13446 started with @option{--listen} specifying a TCP endpoint, are @emph{not}
13447 listed.}. Here's an example of the information it returns:
13448
13449 @example
13450 $ sudo guix processes
13451 SessionPID: 19002
13452 ClientPID: 19090
13453 ClientCommand: guix environment --ad-hoc python
13454
13455 SessionPID: 19402
13456 ClientPID: 19367
13457 ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
13458
13459 SessionPID: 19444
13460 ClientPID: 19419
13461 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
13462 LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
13463 LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
13464 LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
13465 ChildPID: 20495
13466 ChildCommand: guix offload x86_64-linux 7200 1 28800
13467 ChildPID: 27733
13468 ChildCommand: guix offload x86_64-linux 7200 1 28800
13469 ChildPID: 27793
13470 ChildCommand: guix offload x86_64-linux 7200 1 28800
13471 @end example
13472
13473 In this example we see that @command{guix-daemon} has three clients:
13474 @command{guix environment}, @command{guix publish}, and the Cuirass continuous
13475 integration tool; their process identifier (PID) is given by the
13476 @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
13477 @command{guix-daemon} sub-process of this particular session.
13478
13479 The @code{LockHeld} fields show which store items are currently locked
13480 by this session, which corresponds to store items being built or
13481 substituted (the @code{LockHeld} field is not displayed when
13482 @command{guix processes} is not running as root). Last, by looking at
13483 the @code{ChildPID} and @code{ChildCommand} fields, we understand that
13484 these three builds are being offloaded (@pxref{Daemon Offload Setup}).
13485
13486 The output is in Recutils format so we can use the handy @command{recsel}
13487 command to select sessions of interest (@pxref{Selection Expressions,,,
13488 recutils, GNU recutils manual}). As an example, the command shows the command
13489 line and PID of the client that triggered the build of a Perl package:
13490
13491 @example
13492 $ sudo guix processes | \
13493 recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
13494 ClientPID: 19419
13495 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
13496 @end example
13497
13498 Additional options are listed below.
13499
13500 @table @code
13501 @item --format=@var{format}
13502 @itemx -f @var{format}
13503 Produce output in the specified @var{format}, one of:
13504
13505 @table @code
13506 @item recutils
13507 The default option. It outputs a set of Session recutils records
13508 that include each @code{ChildProcess} as a field.
13509
13510 @item normalized
13511 Normalize the output records into record sets (@pxref{Record Sets,,,
13512 recutils, GNU recutils manual}). Normalizing into record sets allows
13513 joins across record types. The example below lists the PID of each
13514 @code{ChildProcess} and the associated PID for @code{Session} that
13515 spawned the @code{ChildProcess} where the @code{Session} was started
13516 using @command{guix build}.
13517
13518 @example
13519 $ guix processes --format=normalized | \
13520 recsel \
13521 -j Session \
13522 -t ChildProcess \
13523 -p Session.PID,PID \
13524 -e 'Session.ClientCommand ~ "guix build"'
13525 PID: 4435
13526 Session_PID: 4278
13527
13528 PID: 4554
13529 Session_PID: 4278
13530
13531 PID: 4646
13532 Session_PID: 4278
13533 @end example
13534 @end table
13535 @end table
13536
13537 @node System Configuration
13538 @chapter System Configuration
13539
13540 @cindex system configuration
13541 Guix System supports a consistent whole-system configuration
13542 mechanism. By that we mean that all aspects of the global system
13543 configuration---such as the available system services, timezone and
13544 locale settings, user accounts---are declared in a single place. Such
13545 a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
13546
13547 One of the advantages of putting all the system configuration under the
13548 control of Guix is that it supports transactional system upgrades, and
13549 makes it possible to roll back to a previous system instantiation,
13550 should something go wrong with the new one (@pxref{Features}). Another
13551 advantage is that it makes it easy to replicate the exact same configuration
13552 across different machines, or at different points in time, without
13553 having to resort to additional administration tools layered on top of
13554 the own tools of the system.
13555 @c Yes, we're talking of Puppet, Chef, & co. here. ↑
13556
13557 This section describes this mechanism. First we focus on the system
13558 administrator's viewpoint---explaining how the system is configured and
13559 instantiated. Then we show how this mechanism can be extended, for
13560 instance to support new system services.
13561
13562 @menu
13563 * Using the Configuration System:: Customizing your GNU system.
13564 * operating-system Reference:: Detail of operating-system declarations.
13565 * File Systems:: Configuring file system mounts.
13566 * Mapped Devices:: Block device extra processing.
13567 * User Accounts:: Specifying user accounts.
13568 * Keyboard Layout:: How the system interprets key strokes.
13569 * Locales:: Language and cultural convention settings.
13570 * Services:: Specifying system services.
13571 * Setuid Programs:: Programs running with root privileges.
13572 * X.509 Certificates:: Authenticating HTTPS servers.
13573 * Name Service Switch:: Configuring libc's name service switch.
13574 * Initial RAM Disk:: Linux-Libre bootstrapping.
13575 * Bootloader Configuration:: Configuring the boot loader.
13576 * Invoking guix system:: Instantiating a system configuration.
13577 * Invoking guix deploy:: Deploying a system configuration to a remote host.
13578 * Running Guix in a VM:: How to run Guix System in a virtual machine.
13579 * Defining Services:: Adding new service definitions.
13580 @end menu
13581
13582 @node Using the Configuration System
13583 @section Using the Configuration System
13584
13585 The operating system is configured by providing an
13586 @code{operating-system} declaration in a file that can then be passed to
13587 the @command{guix system} command (@pxref{Invoking guix system}). A
13588 simple setup, with the default system services, the default Linux-Libre
13589 kernel, initial RAM disk, and boot loader looks like this:
13590
13591 @findex operating-system
13592 @lisp
13593 @include os-config-bare-bones.texi
13594 @end lisp
13595
13596 This example should be self-describing. Some of the fields defined
13597 above, such as @code{host-name} and @code{bootloader}, are mandatory.
13598 Others, such as @code{packages} and @code{services}, can be omitted, in
13599 which case they get a default value.
13600
13601 Below we discuss the effect of some of the most important fields
13602 (@pxref{operating-system Reference}, for details about all the available
13603 fields), and how to @dfn{instantiate} the operating system using
13604 @command{guix system}.
13605
13606 @unnumberedsubsec Bootloader
13607
13608 @cindex legacy boot, on Intel machines
13609 @cindex BIOS boot, on Intel machines
13610 @cindex UEFI boot
13611 @cindex EFI boot
13612 The @code{bootloader} field describes the method that will be used to boot
13613 your system. Machines based on Intel processors can boot in ``legacy'' BIOS
13614 mode, as in the example above. However, more recent machines rely instead on
13615 the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
13616 the @code{bootloader} field should contain something along these lines:
13617
13618 @lisp
13619 (bootloader-configuration
13620 (bootloader grub-efi-bootloader)
13621 (targets '("/boot/efi")))
13622 @end lisp
13623
13624 @xref{Bootloader Configuration}, for more information on the available
13625 configuration options.
13626
13627 @unnumberedsubsec Globally-Visible Packages
13628
13629 @vindex %base-packages
13630 The @code{packages} field lists packages that will be globally visible
13631 on the system, for all user accounts---i.e., in every user's @env{PATH}
13632 environment variable---in addition to the per-user profiles
13633 (@pxref{Invoking guix package}). The @code{%base-packages} variable
13634 provides all the tools one would expect for basic user and administrator
13635 tasks---including the GNU Core Utilities, the GNU Networking Utilities,
13636 the @command{mg} lightweight text editor, @command{find}, @command{grep},
13637 etc. The example above adds GNU@tie{}Screen to those,
13638 taken from the @code{(gnu packages screen)}
13639 module (@pxref{Package Modules}). The
13640 @code{(list package output)} syntax can be used to add a specific output
13641 of a package:
13642
13643 @lisp
13644 (use-modules (gnu packages))
13645 (use-modules (gnu packages dns))
13646
13647 (operating-system
13648 ;; ...
13649 (packages (cons (list isc-bind "utils")
13650 %base-packages)))
13651 @end lisp
13652
13653 @findex specification->package
13654 Referring to packages by variable name, like @code{isc-bind} above, has
13655 the advantage of being unambiguous; it also allows typos and such to be
13656 diagnosed right away as ``unbound variables''. The downside is that one
13657 needs to know which module defines which package, and to augment the
13658 @code{use-package-modules} line accordingly. To avoid that, one can use
13659 the @code{specification->package} procedure of the @code{(gnu packages)}
13660 module, which returns the best package for a given name or name and
13661 version:
13662
13663 @lisp
13664 (use-modules (gnu packages))
13665
13666 (operating-system
13667 ;; ...
13668 (packages (append (map specification->package
13669 '("tcpdump" "htop" "gnupg@@2.0"))
13670 %base-packages)))
13671 @end lisp
13672
13673 @unnumberedsubsec System Services
13674
13675 @cindex services
13676 @vindex %base-services
13677 The @code{services} field lists @dfn{system services} to be made
13678 available when the system starts (@pxref{Services}).
13679 The @code{operating-system} declaration above specifies that, in
13680 addition to the basic services, we want the OpenSSH secure shell
13681 daemon listening on port 2222 (@pxref{Networking Services,
13682 @code{openssh-service-type}}). Under the hood,
13683 @code{openssh-service-type} arranges so that @command{sshd} is started with the
13684 right command-line options, possibly with supporting configuration files
13685 generated as needed (@pxref{Defining Services}).
13686
13687 @cindex customization, of services
13688 @findex modify-services
13689 Occasionally, instead of using the base services as is, you will want to
13690 customize them. To do this, use @code{modify-services} (@pxref{Service
13691 Reference, @code{modify-services}}) to modify the list.
13692
13693 @anchor{auto-login to TTY} For example, suppose you want to modify
13694 @code{guix-daemon} and Mingetty (the console log-in) in the
13695 @code{%base-services} list (@pxref{Base Services,
13696 @code{%base-services}}). To do that, you can write the following in
13697 your operating system declaration:
13698
13699 @lisp
13700 (define %my-services
13701 ;; My very own list of services.
13702 (modify-services %base-services
13703 (guix-service-type config =>
13704 (guix-configuration
13705 (inherit config)
13706 ;; Fetch substitutes from example.org.
13707 (substitute-urls
13708 (list "https://example.org/guix"
13709 "https://ci.guix.gnu.org"))))
13710 (mingetty-service-type config =>
13711 (mingetty-configuration
13712 (inherit config)
13713 ;; Automatially log in as "guest".
13714 (auto-login "guest")))))
13715
13716 (operating-system
13717 ;; @dots{}
13718 (services %my-services))
13719 @end lisp
13720
13721 This changes the configuration---i.e., the service parameters---of the
13722 @code{guix-service-type} instance, and that of all the
13723 @code{mingetty-service-type} instances in the @code{%base-services} list
13724 (@pxref{Auto-Login to a Specific TTY, see the cookbook for how to
13725 auto-login one user to a specific TTY,, guix-cookbook, GNU Guix Cookbook})).
13726 Observe how this is accomplished: first, we arrange for the original
13727 configuration to be bound to the identifier @code{config} in the
13728 @var{body}, and then we write the @var{body} so that it evaluates to the
13729 desired configuration. In particular, notice how we use @code{inherit}
13730 to create a new configuration which has the same values as the old
13731 configuration, but with a few modifications.
13732
13733 @cindex encrypted disk
13734 The configuration for a typical ``desktop'' usage, with an encrypted
13735 root partition, the X11 display
13736 server, GNOME and Xfce (users can choose which of these desktop
13737 environments to use at the log-in screen by pressing @kbd{F1}), network
13738 management, power management, and more, would look like this:
13739
13740 @lisp
13741 @include os-config-desktop.texi
13742 @end lisp
13743
13744 A graphical system with a choice of lightweight window managers
13745 instead of full-blown desktop environments would look like this:
13746
13747 @lisp
13748 @include os-config-lightweight-desktop.texi
13749 @end lisp
13750
13751 This example refers to the @file{/boot/efi} file system by its UUID,
13752 @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
13753 as returned by the @command{blkid} command.
13754
13755 @xref{Desktop Services}, for the exact list of services provided by
13756 @code{%desktop-services}. @xref{X.509 Certificates}, for background
13757 information about the @code{nss-certs} package that is used here.
13758
13759 Again, @code{%desktop-services} is just a list of service objects. If
13760 you want to remove services from there, you can do so using the
13761 procedures for list filtering (@pxref{SRFI-1 Filtering and
13762 Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
13763 following expression returns a list that contains all the services in
13764 @code{%desktop-services} minus the Avahi service:
13765
13766 @lisp
13767 (remove (lambda (service)
13768 (eq? (service-kind service) avahi-service-type))
13769 %desktop-services)
13770 @end lisp
13771
13772 Alternatively, the @code{modify-services} macro can be used:
13773
13774 @lisp
13775 (modify-services %desktop-services
13776 (delete avahi-service-type))
13777 @end lisp
13778
13779
13780 @unnumberedsubsec Instantiating the System
13781
13782 Assuming the @code{operating-system} declaration
13783 is stored in the @file{my-system-config.scm}
13784 file, the @command{guix system reconfigure my-system-config.scm} command
13785 instantiates that configuration, and makes it the default GRUB boot
13786 entry (@pxref{Invoking guix system}).
13787
13788 The normal way to change the system configuration is by updating this
13789 file and re-running @command{guix system reconfigure}. One should never
13790 have to touch files in @file{/etc} or to run commands that modify the
13791 system state such as @command{useradd} or @command{grub-install}. In
13792 fact, you must avoid that since that would not only void your warranty
13793 but also prevent you from rolling back to previous versions of your
13794 system, should you ever need to.
13795
13796 @cindex roll-back, of the operating system
13797 Speaking of roll-back, each time you run @command{guix system
13798 reconfigure}, a new @dfn{generation} of the system is created---without
13799 modifying or deleting previous generations. Old system generations get
13800 an entry in the bootloader boot menu, allowing you to boot them in case
13801 something went wrong with the latest generation. Reassuring, no? The
13802 @command{guix system list-generations} command lists the system
13803 generations available on disk. It is also possible to roll back the
13804 system via the commands @command{guix system roll-back} and
13805 @command{guix system switch-generation}.
13806
13807 Although the @command{guix system reconfigure} command will not modify
13808 previous generations, you must take care when the current generation is not
13809 the latest (e.g., after invoking @command{guix system roll-back}), since
13810 the operation might overwrite a later generation (@pxref{Invoking guix
13811 system}).
13812
13813 @unnumberedsubsec The Programming Interface
13814
13815 At the Scheme level, the bulk of an @code{operating-system} declaration
13816 is instantiated with the following monadic procedure (@pxref{The Store
13817 Monad}):
13818
13819 @deffn {Monadic Procedure} operating-system-derivation os
13820 Return a derivation that builds @var{os}, an @code{operating-system}
13821 object (@pxref{Derivations}).
13822
13823 The output of the derivation is a single directory that refers to all
13824 the packages, configuration files, and other supporting files needed to
13825 instantiate @var{os}.
13826 @end deffn
13827
13828 This procedure is provided by the @code{(gnu system)} module. Along
13829 with @code{(gnu services)} (@pxref{Services}), this module contains the
13830 guts of Guix System. Make sure to visit it!
13831
13832
13833 @node operating-system Reference
13834 @section @code{operating-system} Reference
13835
13836 This section summarizes all the options available in
13837 @code{operating-system} declarations (@pxref{Using the Configuration
13838 System}).
13839
13840 @deftp {Data Type} operating-system
13841 This is the data type representing an operating system configuration.
13842 By that, we mean all the global system configuration, not per-user
13843 configuration (@pxref{Using the Configuration System}).
13844
13845 @table @asis
13846 @item @code{kernel} (default: @code{linux-libre})
13847 The package object of the operating system kernel to
13848 use@footnote{Currently only the Linux-libre kernel is fully supported.
13849 Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
13850 available when building a virtual machine disk image.}.
13851
13852 @cindex hurd
13853 @item @code{hurd} (default: @code{#f})
13854 The package object of the Hurd to be started by the kernel. When this
13855 field is set, produce a GNU/Hurd operating system. In that case,
13856 @code{kernel} must also be set to the @code{gnumach} package---the
13857 microkernel the Hurd runs on.
13858
13859 @quotation Warning
13860 This feature is experimental and only supported for disk images.
13861 @end quotation
13862
13863 @item @code{kernel-loadable-modules} (default: '())
13864 A list of objects (usually packages) to collect loadable kernel modules
13865 from--e.g. @code{(list ddcci-driver-linux)}.
13866
13867 @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
13868 List of strings or gexps representing additional arguments to pass on
13869 the command-line of the kernel---e.g., @code{("console=ttyS0")}.
13870
13871 @item @code{bootloader}
13872 The system bootloader configuration object. @xref{Bootloader Configuration}.
13873
13874 @item @code{label}
13875 This is the label (a string) as it appears in the bootloader's menu entry.
13876 The default label includes the kernel name and version.
13877
13878 @item @code{keyboard-layout} (default: @code{#f})
13879 This field specifies the keyboard layout to use in the console. It can be
13880 either @code{#f}, in which case the default keyboard layout is used (usually
13881 US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
13882 for more information.
13883
13884 This keyboard layout is in effect as soon as the kernel has booted. For
13885 instance, it is the keyboard layout in effect when you type a passphrase if
13886 your root file system is on a @code{luks-device-mapping} mapped device
13887 (@pxref{Mapped Devices}).
13888
13889 @quotation Note
13890 This does @emph{not} specify the keyboard layout used by the bootloader, nor
13891 that used by the graphical display server. @xref{Bootloader Configuration},
13892 for information on how to specify the bootloader's keyboard layout. @xref{X
13893 Window}, for information on how to specify the keyboard layout used by the X
13894 Window System.
13895 @end quotation
13896
13897 @item @code{initrd-modules} (default: @code{%base-initrd-modules})
13898 @cindex initrd
13899 @cindex initial RAM disk
13900 The list of Linux kernel modules that need to be available in the
13901 initial RAM disk. @xref{Initial RAM Disk}.
13902
13903 @item @code{initrd} (default: @code{base-initrd})
13904 A procedure that returns an initial RAM disk for the Linux
13905 kernel. This field is provided to support low-level customization and
13906 should rarely be needed for casual use. @xref{Initial RAM Disk}.
13907
13908 @item @code{firmware} (default: @code{%base-firmware})
13909 @cindex firmware
13910 List of firmware packages loadable by the operating system kernel.
13911
13912 The default includes firmware needed for Atheros- and Broadcom-based
13913 WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
13914 respectively). @xref{Hardware Considerations}, for more info on
13915 supported hardware.
13916
13917 @item @code{host-name}
13918 The host name.
13919
13920 @item @code{hosts-file}
13921 @cindex hosts file
13922 A file-like object (@pxref{G-Expressions, file-like objects}) for use as
13923 @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
13924 Reference Manual}). The default is a file with entries for
13925 @code{localhost} and @var{host-name}.
13926
13927 @item @code{mapped-devices} (default: @code{'()})
13928 A list of mapped devices. @xref{Mapped Devices}.
13929
13930 @item @code{file-systems}
13931 A list of file systems. @xref{File Systems}.
13932
13933 @cindex swap devices
13934 @cindex swap space
13935 @item @code{swap-devices} (default: @code{'()})
13936 A list of UUIDs, file system labels, or strings identifying devices or
13937 files to be used for ``swap
13938 space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
13939 Manual}). Here are some examples:
13940
13941 @table @code
13942 @item (list (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))
13943 Use the swap partition with the given UUID@. You can learn the UUID of a
13944 Linux swap partition by running @command{swaplabel @var{device}}, where
13945 @var{device} is the @file{/dev} file name of that partition.
13946
13947 @item (list (file-system-label "swap"))
13948 Use the partition with label @code{swap}. Again, the
13949 @command{swaplabel} command allows you to view and change the label of a
13950 Linux swap partition.
13951
13952 @item (list "/swapfile")
13953 Use the file @file{/swapfile} as swap space.
13954
13955 @item (list "/dev/sda3" "/dev/sdb2")
13956 Use the @file{/dev/sda3} and @file{/dev/sdb2} partitions as swap space.
13957 We recommend referring to swap devices by UUIDs or labels as shown above
13958 instead.
13959 @end table
13960
13961 It is possible to specify a swap file in a file system on a mapped
13962 device (under @file{/dev/mapper}), provided that the necessary device
13963 mapping and file system are also specified. @xref{Mapped Devices} and
13964 @ref{File Systems}.
13965
13966 @item @code{users} (default: @code{%base-user-accounts})
13967 @itemx @code{groups} (default: @code{%base-groups})
13968 List of user accounts and groups. @xref{User Accounts}.
13969
13970 If the @code{users} list lacks a user account with UID@tie{}0, a
13971 ``root'' account with UID@tie{}0 is automatically added.
13972
13973 @item @code{skeletons} (default: @code{(default-skeletons)})
13974 A list of target file name/file-like object tuples (@pxref{G-Expressions,
13975 file-like objects}). These are the skeleton files that will be added to
13976 the home directory of newly-created user accounts.
13977
13978 For instance, a valid value may look like this:
13979
13980 @lisp
13981 `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
13982 (".guile" ,(plain-file "guile"
13983 "(use-modules (ice-9 readline))
13984 (activate-readline)")))
13985 @end lisp
13986
13987 @item @code{issue} (default: @code{%default-issue})
13988 A string denoting the contents of the @file{/etc/issue} file, which is
13989 displayed when users log in on a text console.
13990
13991 @item @code{packages} (default: @code{%base-packages})
13992 A list of packages to be installed in the global profile, which is accessible
13993 at @file{/run/current-system/profile}. Each element is either a package
13994 variable or a package/output tuple. Here's a simple example of both:
13995
13996 @lisp
13997 (cons* git ; the default "out" output
13998 (list git "send-email") ; another output of git
13999 %base-packages) ; the default set
14000 @end lisp
14001
14002 The default set includes core utilities and it is good practice to
14003 install non-core utilities in user profiles (@pxref{Invoking guix
14004 package}).
14005
14006 @item @code{timezone}
14007 A timezone identifying string---e.g., @code{"Europe/Paris"}.
14008
14009 You can run the @command{tzselect} command to find out which timezone
14010 string corresponds to your region. Choosing an invalid timezone name
14011 causes @command{guix system} to fail.
14012
14013 @item @code{locale} (default: @code{"en_US.utf8"})
14014 The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
14015 Library Reference Manual}). @xref{Locales}, for more information.
14016
14017 @item @code{locale-definitions} (default: @code{%default-locale-definitions})
14018 The list of locale definitions to be compiled and that may be used at
14019 run time. @xref{Locales}.
14020
14021 @item @code{locale-libcs} (default: @code{(list @var{glibc})})
14022 The list of GNU@tie{}libc packages whose locale data and tools are used
14023 to build the locale definitions. @xref{Locales}, for compatibility
14024 considerations that justify this option.
14025
14026 @item @code{name-service-switch} (default: @code{%default-nss})
14027 Configuration of the libc name service switch (NSS)---a
14028 @code{<name-service-switch>} object. @xref{Name Service Switch}, for
14029 details.
14030
14031 @item @code{services} (default: @code{%base-services})
14032 A list of service objects denoting system services. @xref{Services}.
14033
14034 @cindex essential services
14035 @item @code{essential-services} (default: ...)
14036 The list of ``essential services''---i.e., things like instances of
14037 @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
14038 Reference}), which are derived from the operating system definition itself.
14039 As a user you should @emph{never} need to touch this field.
14040
14041 @item @code{pam-services} (default: @code{(base-pam-services)})
14042 @cindex PAM
14043 @cindex pluggable authentication modules
14044 Linux @dfn{pluggable authentication module} (PAM) services.
14045 @c FIXME: Add xref to PAM services section.
14046
14047 @item @code{setuid-programs} (default: @code{%setuid-programs})
14048 List of @code{<setuid-program>}. @xref{Setuid Programs}, for more
14049 information.
14050
14051 @item @code{sudoers-file} (default: @code{%sudoers-specification})
14052 @cindex sudoers file
14053 The contents of the @file{/etc/sudoers} file as a file-like object
14054 (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
14055
14056 This file specifies which users can use the @command{sudo} command, what
14057 they are allowed to do, and what privileges they may gain. The default
14058 is that only @code{root} and members of the @code{wheel} group may use
14059 @code{sudo}.
14060
14061 @end table
14062
14063 @deffn {Scheme Syntax} this-operating-system
14064 When used in the @emph{lexical scope} of an operating system field definition,
14065 this identifier resolves to the operating system being defined.
14066
14067 The example below shows how to refer to the operating system being defined in
14068 the definition of the @code{label} field:
14069
14070 @lisp
14071 (use-modules (gnu) (guix))
14072
14073 (operating-system
14074 ;; ...
14075 (label (package-full-name
14076 (operating-system-kernel this-operating-system))))
14077 @end lisp
14078
14079 It is an error to refer to @code{this-operating-system} outside an operating
14080 system definition.
14081 @end deffn
14082
14083 @end deftp
14084
14085 @node File Systems
14086 @section File Systems
14087
14088 The list of file systems to be mounted is specified in the
14089 @code{file-systems} field of the operating system declaration
14090 (@pxref{Using the Configuration System}). Each file system is declared
14091 using the @code{file-system} form, like this:
14092
14093 @lisp
14094 (file-system
14095 (mount-point "/home")
14096 (device "/dev/sda3")
14097 (type "ext4"))
14098 @end lisp
14099
14100 As usual, some of the fields are mandatory---those shown in the example
14101 above---while others can be omitted. These are described below.
14102
14103 @deftp {Data Type} file-system
14104 Objects of this type represent file systems to be mounted. They
14105 contain the following members:
14106
14107 @table @asis
14108 @item @code{type}
14109 This is a string specifying the type of the file system---e.g.,
14110 @code{"ext4"}.
14111
14112 @item @code{mount-point}
14113 This designates the place where the file system is to be mounted.
14114
14115 @item @code{device}
14116 This names the ``source'' of the file system. It can be one of three
14117 things: a file system label, a file system UUID, or the name of a
14118 @file{/dev} node. Labels and UUIDs offer a way to refer to file
14119 systems without having to hard-code their actual device
14120 name@footnote{Note that, while it is tempting to use
14121 @file{/dev/disk/by-uuid} and similar device names to achieve the same
14122 result, this is not recommended: These special device nodes are created
14123 by the udev daemon and may be unavailable at the time the device is
14124 mounted.}.
14125
14126 @findex file-system-label
14127 File system labels are created using the @code{file-system-label}
14128 procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
14129 plain strings. Here's an example of a file system referred to by its
14130 label, as shown by the @command{e2label} command:
14131
14132 @lisp
14133 (file-system
14134 (mount-point "/home")
14135 (type "ext4")
14136 (device (file-system-label "my-home")))
14137 @end lisp
14138
14139 @findex uuid
14140 UUIDs are converted from their string representation (as shown by the
14141 @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
14142 @code{uuid} form expects 16-byte UUIDs as defined in
14143 @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
14144 form of UUID used by the ext2 family of file systems and others, but it
14145 is different from ``UUIDs'' found in FAT file systems, for instance.},
14146 like this:
14147
14148 @lisp
14149 (file-system
14150 (mount-point "/home")
14151 (type "ext4")
14152 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
14153 @end lisp
14154
14155 When the source of a file system is a mapped device (@pxref{Mapped
14156 Devices}), its @code{device} field @emph{must} refer to the mapped
14157 device name---e.g., @file{"/dev/mapper/root-partition"}.
14158 This is required so that
14159 the system knows that mounting the file system depends on having the
14160 corresponding device mapping established.
14161
14162 @item @code{flags} (default: @code{'()})
14163 This is a list of symbols denoting mount flags. Recognized flags
14164 include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
14165 access to special files), @code{no-suid} (ignore setuid and setgid
14166 bits), @code{no-atime} (do not update file access times),
14167 @code{strict-atime} (update file access time), @code{lazy-time} (only
14168 update time on the in-memory version of the file inode), and
14169 @code{no-exec} (disallow program execution).
14170 @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
14171 Manual}, for more information on these flags.
14172
14173 @item @code{options} (default: @code{#f})
14174 This is either @code{#f}, or a string denoting mount options passed to
14175 the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
14176 Library Reference Manual}, for details and run @command{man 8 mount} for
14177 options for various file systems. Note that the
14178 @code{file-system-options->alist} and @code{alist->file-system-options}
14179 procedures from @code{(gnu system file-systems)} can be used to convert
14180 file system options given as an association list to the string
14181 representation, and vice-versa.
14182
14183 @item @code{mount?} (default: @code{#t})
14184 This value indicates whether to automatically mount the file system when
14185 the system is brought up. When set to @code{#f}, the file system gets
14186 an entry in @file{/etc/fstab} (read by the @command{mount} command) but
14187 is not automatically mounted.
14188
14189 @item @code{needed-for-boot?} (default: @code{#f})
14190 This Boolean value indicates whether the file system is needed when
14191 booting. If that is true, then the file system is mounted when the
14192 initial RAM disk (initrd) is loaded. This is always the case, for
14193 instance, for the root file system.
14194
14195 @item @code{check?} (default: @code{#t})
14196 This Boolean indicates whether the file system should be checked for
14197 errors before being mounted. How and when this happens can be further
14198 adjusted with the following options.
14199
14200 @item @code{skip-check-if-clean?} (default: @code{#t})
14201 When true, this Boolean indicates that a file system check triggered
14202 by @code{check?} may exit early if the file system is marked as
14203 ``clean'', meaning that it was previously correctly unmounted and
14204 should not contain errors.
14205
14206 Setting this to false will always force a full consistency check when
14207 @code{check?} is true. This may take a very long time and is not
14208 recommended on healthy systems---in fact, it may reduce reliability!
14209
14210 Conversely, some primitive file systems like @code{fat} do not keep
14211 track of clean shutdowns and will perform a full scan regardless of the
14212 value of this option.
14213
14214 @item @code{repair} (default: @code{'preen})
14215 When @code{check?} finds errors, it can (try to) repair them and
14216 continue booting. This option controls when and how to do so.
14217
14218 If false, try not to modify the file system at all. Checking certain
14219 file systems like @code{jfs} may still write to the device to replay
14220 the journal. No repairs will be attempted.
14221
14222 If @code{#t}, try to repair any errors found and assume ``yes'' to
14223 all questions. This will fix the most errors, but may be risky.
14224
14225 If @code{'preen}, repair only errors that are safe to fix without
14226 human interaction. What that means is left up to the developers of
14227 each file system and may be equivalent to ``none'' or ``all''.
14228
14229 @item @code{create-mount-point?} (default: @code{#f})
14230 When true, the mount point is created if it does not exist yet.
14231
14232 @item @code{mount-may-fail?} (default: @code{#f})
14233 When true, this indicates that mounting this file system can fail but
14234 that should not be considered an error. This is useful in unusual
14235 cases; an example of this is @code{efivarfs}, a file system that can
14236 only be mounted on EFI/UEFI systems.
14237
14238 @item @code{dependencies} (default: @code{'()})
14239 This is a list of @code{<file-system>} or @code{<mapped-device>} objects
14240 representing file systems that must be mounted or mapped devices that
14241 must be opened before (and unmounted or closed after) this one.
14242
14243 As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
14244 a dependency of @file{/sys/fs/cgroup/cpu} and
14245 @file{/sys/fs/cgroup/memory}.
14246
14247 Another example is a file system that depends on a mapped device, for
14248 example for an encrypted partition (@pxref{Mapped Devices}).
14249 @end table
14250 @end deftp
14251
14252 @deffn {Scheme Procedure} file-system-label @var{str}
14253 This procedure returns an opaque file system label from @var{str}, a
14254 string:
14255
14256 @lisp
14257 (file-system-label "home")
14258 @result{} #<file-system-label "home">
14259 @end lisp
14260
14261 File system labels are used to refer to file systems by label rather
14262 than by device name. See above for examples.
14263 @end deffn
14264
14265 The @code{(gnu system file-systems)} exports the following useful
14266 variables.
14267
14268 @defvr {Scheme Variable} %base-file-systems
14269 These are essential file systems that are required on normal systems,
14270 such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
14271 below). Operating system declarations should always contain at least
14272 these.
14273 @end defvr
14274
14275 @defvr {Scheme Variable} %pseudo-terminal-file-system
14276 This is the file system to be mounted as @file{/dev/pts}. It supports
14277 @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
14278 functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
14279 Manual}). Pseudo-terminals are used by terminal emulators such as
14280 @command{xterm}.
14281 @end defvr
14282
14283 @defvr {Scheme Variable} %shared-memory-file-system
14284 This file system is mounted as @file{/dev/shm} and is used to support
14285 memory sharing across processes (@pxref{Memory-mapped I/O,
14286 @code{shm_open},, libc, The GNU C Library Reference Manual}).
14287 @end defvr
14288
14289 @defvr {Scheme Variable} %immutable-store
14290 This file system performs a read-only ``bind mount'' of
14291 @file{/gnu/store}, making it read-only for all the users including
14292 @code{root}. This prevents against accidental modification by software
14293 running as @code{root} or by system administrators.
14294
14295 The daemon itself is still able to write to the store: it remounts it
14296 read-write in its own ``name space.''
14297 @end defvr
14298
14299 @defvr {Scheme Variable} %binary-format-file-system
14300 The @code{binfmt_misc} file system, which allows handling of arbitrary
14301 executable file types to be delegated to user space. This requires the
14302 @code{binfmt.ko} kernel module to be loaded.
14303 @end defvr
14304
14305 @defvr {Scheme Variable} %fuse-control-file-system
14306 The @code{fusectl} file system, which allows unprivileged users to mount
14307 and unmount user-space FUSE file systems. This requires the
14308 @code{fuse.ko} kernel module to be loaded.
14309 @end defvr
14310
14311 The @code{(gnu system uuid)} module provides tools to deal with file
14312 system ``unique identifiers'' (UUIDs).
14313
14314 @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
14315 Return an opaque UUID (unique identifier) object of the given @var{type}
14316 (a symbol) by parsing @var{str} (a string):
14317
14318 @lisp
14319 (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
14320 @result{} #<<uuid> type: dce bv: @dots{}>
14321
14322 (uuid "1234-ABCD" 'fat)
14323 @result{} #<<uuid> type: fat bv: @dots{}>
14324 @end lisp
14325
14326 @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
14327 @code{ntfs}, or one of the commonly found synonyms for these.
14328
14329 UUIDs are another way to unambiguously refer to file systems in
14330 operating system configuration. See the examples above.
14331 @end deffn
14332
14333
14334 @node Btrfs file system
14335 @subsection Btrfs file system
14336
14337 The Btrfs has special features, such as subvolumes, that merit being
14338 explained in more details. The following section attempts to cover
14339 basic as well as complex uses of a Btrfs file system with the Guix
14340 System.
14341
14342 In its simplest usage, a Btrfs file system can be described, for
14343 example, by:
14344
14345 @lisp
14346 (file-system
14347 (mount-point "/home")
14348 (type "btrfs")
14349 (device (file-system-label "my-home")))
14350 @end lisp
14351
14352 The example below is more complex, as it makes use of a Btrfs
14353 subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
14354 @code{my-btrfs-pool}, and is located on an encrypted device (hence the
14355 dependency on @code{mapped-devices}):
14356
14357 @lisp
14358 (file-system
14359 (device (file-system-label "my-btrfs-pool"))
14360 (mount-point "/")
14361 (type "btrfs")
14362 (options "subvol=rootfs")
14363 (dependencies mapped-devices))
14364 @end lisp
14365
14366 Some bootloaders, for example GRUB, only mount a Btrfs partition at its
14367 top level during the early boot, and rely on their configuration to
14368 refer to the correct subvolume path within that top level. The
14369 bootloaders operating in this way typically produce their configuration
14370 on a running system where the Btrfs partitions are already mounted and
14371 where the subvolume information is readily available. As an example,
14372 @command{grub-mkconfig}, the configuration generator command shipped
14373 with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
14374 path of a subvolume.
14375
14376 The Guix System produces a bootloader configuration using the operating
14377 system configuration as its sole input; it is therefore necessary to
14378 extract the subvolume name on which @file{/gnu/store} lives (if any)
14379 from that operating system configuration. To better illustrate,
14380 consider a subvolume named 'rootfs' which contains the root file system
14381 data. In such situation, the GRUB bootloader would only see the top
14382 level of the root Btrfs partition, e.g.:
14383
14384 @example
14385 / (top level)
14386 ├── rootfs (subvolume directory)
14387 ├── gnu (normal directory)
14388 ├── store (normal directory)
14389 [...]
14390 @end example
14391
14392 Thus, the subvolume name must be prepended to the @file{/gnu/store} path
14393 of the kernel, initrd binaries and any other files referred to in the
14394 GRUB configuration that must be found during the early boot.
14395
14396 The next example shows a nested hierarchy of subvolumes and
14397 directories:
14398
14399 @example
14400 / (top level)
14401 ├── rootfs (subvolume)
14402 ├── gnu (normal directory)
14403 ├── store (subvolume)
14404 [...]
14405 @end example
14406
14407 This scenario would work without mounting the 'store' subvolume.
14408 Mounting 'rootfs' is sufficient, since the subvolume name matches its
14409 intended mount point in the file system hierarchy. Alternatively, the
14410 'store' subvolume could be referred to by setting the @code{subvol}
14411 option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
14412
14413 Finally, a more contrived example of nested subvolumes:
14414
14415 @example
14416 / (top level)
14417 ├── root-snapshots (subvolume)
14418 ├── root-current (subvolume)
14419 ├── guix-store (subvolume)
14420 [...]
14421 @end example
14422
14423 Here, the 'guix-store' subvolume doesn't match its intended mount point,
14424 so it is necessary to mount it. The subvolume must be fully specified,
14425 by passing its file name to the @code{subvol} option. To illustrate,
14426 the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
14427 a file system declaration such as:
14428
14429 @lisp
14430 (file-system
14431 (device (file-system-label "btrfs-pool-1"))
14432 (mount-point "/gnu/store")
14433 (type "btrfs")
14434 (options "subvol=root-snapshots/root-current/guix-store,\
14435 compress-force=zstd,space_cache=v2"))
14436 @end lisp
14437
14438 @node Mapped Devices
14439 @section Mapped Devices
14440
14441 @cindex device mapping
14442 @cindex mapped devices
14443 The Linux kernel has a notion of @dfn{device mapping}: a block device,
14444 such as a hard disk partition, can be @dfn{mapped} into another device,
14445 usually in @code{/dev/mapper/},
14446 with additional processing over the data that flows through
14447 it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
14448 concept of a ``mapped device'' and that of a file system: both boil down
14449 to @emph{translating} input/output operations made on a file to
14450 operations on its backing store. Thus, the Hurd implements mapped
14451 devices, like file systems, using the generic @dfn{translator} mechanism
14452 (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
14453 typical example is encryption device mapping: all writes to the mapped
14454 device are encrypted, and all reads are deciphered, transparently.
14455 Guix extends this notion by considering any device or set of devices that
14456 are @dfn{transformed} in some way to create a new device; for instance,
14457 RAID devices are obtained by @dfn{assembling} several other devices, such
14458 as hard disks or partitions, into a new one that behaves as one partition.
14459
14460 Mapped devices are declared using the @code{mapped-device} form,
14461 defined as follows; for examples, see below.
14462
14463 @deftp {Data Type} mapped-device
14464 Objects of this type represent device mappings that will be made when
14465 the system boots up.
14466
14467 @table @code
14468 @item source
14469 This is either a string specifying the name of the block device to be mapped,
14470 such as @code{"/dev/sda3"}, or a list of such strings when several devices
14471 need to be assembled for creating a new one. In case of LVM this is a
14472 string specifying name of the volume group to be mapped.
14473
14474 @item target
14475 This string specifies the name of the resulting mapped device. For
14476 kernel mappers such as encrypted devices of type @code{luks-device-mapping},
14477 specifying @code{"my-partition"} leads to the creation of
14478 the @code{"/dev/mapper/my-partition"} device.
14479 For RAID devices of type @code{raid-device-mapping}, the full device name
14480 such as @code{"/dev/md0"} needs to be given.
14481 LVM logical volumes of type @code{lvm-device-mapping} need to
14482 be specified as @code{"VGNAME-LVNAME"}.
14483
14484 @item targets
14485 This list of strings specifies names of the resulting mapped devices in case
14486 there are several. The format is identical to @var{target}.
14487
14488 @item type
14489 This must be a @code{mapped-device-kind} object, which specifies how
14490 @var{source} is mapped to @var{target}.
14491 @end table
14492 @end deftp
14493
14494 @defvr {Scheme Variable} luks-device-mapping
14495 This defines LUKS block device encryption using the @command{cryptsetup}
14496 command from the package with the same name. It relies on the
14497 @code{dm-crypt} Linux kernel module.
14498 @end defvr
14499
14500 @defvr {Scheme Variable} raid-device-mapping
14501 This defines a RAID device, which is assembled using the @code{mdadm}
14502 command from the package with the same name. It requires a Linux kernel
14503 module for the appropriate RAID level to be loaded, such as @code{raid456}
14504 for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
14505 @end defvr
14506
14507 @cindex LVM, logical volume manager
14508 @defvr {Scheme Variable} lvm-device-mapping
14509 This defines one or more logical volumes for the Linux
14510 @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
14511 The volume group is activated by the @command{vgchange} command from the
14512 @code{lvm2} package.
14513 @end defvr
14514
14515 @cindex disk encryption
14516 @cindex LUKS
14517 The following example specifies a mapping from @file{/dev/sda3} to
14518 @file{/dev/mapper/home} using LUKS---the
14519 @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
14520 standard mechanism for disk encryption.
14521 The @file{/dev/mapper/home}
14522 device can then be used as the @code{device} of a @code{file-system}
14523 declaration (@pxref{File Systems}).
14524
14525 @lisp
14526 (mapped-device
14527 (source "/dev/sda3")
14528 (target "home")
14529 (type luks-device-mapping))
14530 @end lisp
14531
14532 Alternatively, to become independent of device numbering, one may obtain
14533 the LUKS UUID (@dfn{unique identifier}) of the source device by a
14534 command like:
14535
14536 @example
14537 cryptsetup luksUUID /dev/sda3
14538 @end example
14539
14540 and use it as follows:
14541
14542 @lisp
14543 (mapped-device
14544 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
14545 (target "home")
14546 (type luks-device-mapping))
14547 @end lisp
14548
14549 @cindex swap encryption
14550 It is also desirable to encrypt swap space, since swap space may contain
14551 sensitive data. One way to accomplish that is to use a swap file in a
14552 file system on a device mapped via LUKS encryption. In this way, the
14553 swap file is encrypted because the entire device is encrypted.
14554 @xref{Preparing for Installation,,Disk Partitioning}, for an example.
14555
14556 A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
14557 may be declared as follows:
14558
14559 @lisp
14560 (mapped-device
14561 (source (list "/dev/sda1" "/dev/sdb1"))
14562 (target "/dev/md0")
14563 (type raid-device-mapping))
14564 @end lisp
14565
14566 The @file{/dev/md0} device can then be used as the @code{device} of a
14567 @code{file-system} declaration (@pxref{File Systems}).
14568 Note that the RAID level need not be given; it is chosen during the
14569 initial creation and formatting of the RAID device and is determined
14570 automatically later.
14571
14572 LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
14573 be declared as follows:
14574
14575 @lisp
14576 (mapped-device
14577 (source "vg0")
14578 (targets (list "vg0-alpha" "vg0-beta"))
14579 (type lvm-device-mapping))
14580 @end lisp
14581
14582 Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
14583 then be used as the @code{device} of a @code{file-system} declaration
14584 (@pxref{File Systems}).
14585
14586 @node User Accounts
14587 @section User Accounts
14588
14589 @cindex users
14590 @cindex accounts
14591 @cindex user accounts
14592 User accounts and groups are entirely managed through the
14593 @code{operating-system} declaration. They are specified with the
14594 @code{user-account} and @code{user-group} forms:
14595
14596 @lisp
14597 (user-account
14598 (name "alice")
14599 (group "users")
14600 (supplementary-groups '("wheel" ;allow use of sudo, etc.
14601 "audio" ;sound card
14602 "video" ;video devices such as webcams
14603 "cdrom")) ;the good ol' CD-ROM
14604 (comment "Bob's sister"))
14605 @end lisp
14606
14607 Here's a user account that uses a different shell and a custom home
14608 directory (the default would be @file{"/home/bob"}):
14609
14610 @lisp
14611 (user-account
14612 (name "bob")
14613 (group "users")
14614 (comment "Alice's bro")
14615 (shell (file-append zsh "/bin/zsh"))
14616 (home-directory "/home/robert"))
14617 @end lisp
14618
14619 When booting or upon completion of @command{guix system reconfigure},
14620 the system ensures that only the user accounts and groups specified in
14621 the @code{operating-system} declaration exist, and with the specified
14622 properties. Thus, account or group creations or modifications made by
14623 directly invoking commands such as @command{useradd} are lost upon
14624 reconfiguration or reboot. This ensures that the system remains exactly
14625 as declared.
14626
14627 @deftp {Data Type} user-account
14628 Objects of this type represent user accounts. The following members may
14629 be specified:
14630
14631 @table @asis
14632 @item @code{name}
14633 The name of the user account.
14634
14635 @item @code{group}
14636 @cindex groups
14637 This is the name (a string) or identifier (a number) of the user group
14638 this account belongs to.
14639
14640 @item @code{supplementary-groups} (default: @code{'()})
14641 Optionally, this can be defined as a list of group names that this
14642 account belongs to.
14643
14644 @item @code{uid} (default: @code{#f})
14645 This is the user ID for this account (a number), or @code{#f}. In the
14646 latter case, a number is automatically chosen by the system when the
14647 account is created.
14648
14649 @item @code{comment} (default: @code{""})
14650 A comment about the account, such as the account owner's full name.
14651
14652 @item @code{home-directory}
14653 This is the name of the home directory for the account.
14654
14655 @item @code{create-home-directory?} (default: @code{#t})
14656 Indicates whether the home directory of this account should be created
14657 if it does not exist yet.
14658
14659 @item @code{shell} (default: Bash)
14660 This is a G-expression denoting the file name of a program to be used as
14661 the shell (@pxref{G-Expressions}). For example, you would refer to the
14662 Bash executable like this:
14663
14664 @lisp
14665 (file-append bash "/bin/bash")
14666 @end lisp
14667
14668 @noindent
14669 ... and to the Zsh executable like that:
14670
14671 @lisp
14672 (file-append zsh "/bin/zsh")
14673 @end lisp
14674
14675 @item @code{system?} (default: @code{#f})
14676 This Boolean value indicates whether the account is a ``system''
14677 account. System accounts are sometimes treated specially; for instance,
14678 graphical login managers do not list them.
14679
14680 @anchor{user-account-password}
14681 @cindex password, for user accounts
14682 @item @code{password} (default: @code{#f})
14683 You would normally leave this field to @code{#f}, initialize user
14684 passwords as @code{root} with the @command{passwd} command, and then let
14685 users change it with @command{passwd}. Passwords set with
14686 @command{passwd} are of course preserved across reboot and
14687 reconfiguration.
14688
14689 If you @emph{do} want to set an initial password for an account, then
14690 this field must contain the encrypted password, as a string. You can use the
14691 @code{crypt} procedure for this purpose:
14692
14693 @lisp
14694 (user-account
14695 (name "charlie")
14696 (group "users")
14697
14698 ;; Specify a SHA-512-hashed initial password.
14699 (password (crypt "InitialPassword!" "$6$abc")))
14700 @end lisp
14701
14702 @quotation Note
14703 The hash of this initial password will be available in a file in
14704 @file{/gnu/store}, readable by all the users, so this method must be used with
14705 care.
14706 @end quotation
14707
14708 @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
14709 more information on password encryption, and @ref{Encryption,,, guile, GNU
14710 Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
14711
14712 @end table
14713 @end deftp
14714
14715 @cindex groups
14716 User group declarations are even simpler:
14717
14718 @lisp
14719 (user-group (name "students"))
14720 @end lisp
14721
14722 @deftp {Data Type} user-group
14723 This type is for, well, user groups. There are just a few fields:
14724
14725 @table @asis
14726 @item @code{name}
14727 The name of the group.
14728
14729 @item @code{id} (default: @code{#f})
14730 The group identifier (a number). If @code{#f}, a new number is
14731 automatically allocated when the group is created.
14732
14733 @item @code{system?} (default: @code{#f})
14734 This Boolean value indicates whether the group is a ``system'' group.
14735 System groups have low numerical IDs.
14736
14737 @item @code{password} (default: @code{#f})
14738 What, user groups can have a password? Well, apparently yes. Unless
14739 @code{#f}, this field specifies the password of the group.
14740
14741 @end table
14742 @end deftp
14743
14744 For convenience, a variable lists all the basic user groups one may
14745 expect:
14746
14747 @defvr {Scheme Variable} %base-groups
14748 This is the list of basic user groups that users and/or packages expect
14749 to be present on the system. This includes groups such as ``root'',
14750 ``wheel'', and ``users'', as well as groups used to control access to
14751 specific devices such as ``audio'', ``disk'', and ``cdrom''.
14752 @end defvr
14753
14754 @defvr {Scheme Variable} %base-user-accounts
14755 This is the list of basic system accounts that programs may expect to
14756 find on a GNU/Linux system, such as the ``nobody'' account.
14757
14758 Note that the ``root'' account is not included here. It is a
14759 special-case and is automatically added whether or not it is specified.
14760 @end defvr
14761
14762 @node Keyboard Layout
14763 @section Keyboard Layout
14764
14765 @cindex keyboard layout
14766 @cindex keymap
14767 To specify what each key of your keyboard does, you need to tell the operating
14768 system what @dfn{keyboard layout} you want to use. The default, when nothing
14769 is specified, is the US English QWERTY layout for 105-key PC keyboards.
14770 However, German speakers will usually prefer the German QWERTZ layout, French
14771 speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
14772 or bépo, and they might even want to further customize the effect of some of
14773 the keys. This section explains how to get that done.
14774
14775 @cindex keyboard layout, definition
14776 There are three components that will want to know about your keyboard layout:
14777
14778 @itemize
14779 @item
14780 The @emph{bootloader} may want to know what keyboard layout you want to use
14781 (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
14782 you want, for instance, to make sure that you can type the passphrase of your
14783 encrypted root partition using the right layout.
14784
14785 @item
14786 The @emph{operating system kernel}, Linux, will need that so that the console
14787 is properly configured (@pxref{operating-system Reference,
14788 @code{keyboard-layout}}).
14789
14790 @item
14791 The @emph{graphical display server}, usually Xorg, also has its own idea of
14792 the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
14793 @end itemize
14794
14795 Guix allows you to configure all three separately but, fortunately, it allows
14796 you to share the same keyboard layout for all three components.
14797
14798 @cindex XKB, keyboard layouts
14799 Keyboard layouts are represented by records created by the
14800 @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
14801 the X Keyboard extension (XKB), each layout has four attributes: a name (often
14802 a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
14803 optional variant name, an optional keyboard model name, and a possibly empty
14804 list of additional options. In most cases the layout name is all you care
14805 about.
14806
14807 @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
14808 [#:model] [#:options '()]
14809 Return a new keyboard layout with the given @var{name} and @var{variant}.
14810
14811 @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
14812 string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
14813 @code{xkeyboard-config} package for valid options.
14814 @end deffn
14815
14816 Here are a few examples:
14817
14818 @lisp
14819 ;; The German QWERTZ layout. Here we assume a standard
14820 ;; "pc105" keyboard model.
14821 (keyboard-layout "de")
14822
14823 ;; The bépo variant of the French layout.
14824 (keyboard-layout "fr" "bepo")
14825
14826 ;; The Catalan layout.
14827 (keyboard-layout "es" "cat")
14828
14829 ;; Arabic layout with "Alt-Shift" to switch to US layout.
14830 (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
14831
14832 ;; The Latin American Spanish layout. In addition, the
14833 ;; "Caps Lock" key is used as an additional "Ctrl" key,
14834 ;; and the "Menu" key is used as a "Compose" key to enter
14835 ;; accented letters.
14836 (keyboard-layout "latam"
14837 #:options '("ctrl:nocaps" "compose:menu"))
14838
14839 ;; The Russian layout for a ThinkPad keyboard.
14840 (keyboard-layout "ru" #:model "thinkpad")
14841
14842 ;; The "US international" layout, which is the US layout plus
14843 ;; dead keys to enter accented characters. This is for an
14844 ;; Apple MacBook keyboard.
14845 (keyboard-layout "us" "intl" #:model "macbook78")
14846 @end lisp
14847
14848 See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
14849 for a complete list of supported layouts, variants, and models.
14850
14851 @cindex keyboard layout, configuration
14852 Let's say you want your system to use the Turkish keyboard layout throughout
14853 your system---bootloader, console, and Xorg. Here's what your system
14854 configuration would look like:
14855
14856 @findex set-xorg-configuration
14857 @lisp
14858 ;; Using the Turkish layout for the bootloader, the console,
14859 ;; and for Xorg.
14860
14861 (operating-system
14862 ;; ...
14863 (keyboard-layout (keyboard-layout "tr")) ;for the console
14864 (bootloader (bootloader-configuration
14865 (bootloader grub-efi-bootloader)
14866 (targets '("/boot/efi"))
14867 (keyboard-layout keyboard-layout))) ;for GRUB
14868 (services (cons (set-xorg-configuration
14869 (xorg-configuration ;for Xorg
14870 (keyboard-layout keyboard-layout)))
14871 %desktop-services)))
14872 @end lisp
14873
14874 In the example above, for GRUB and for Xorg, we just refer to the
14875 @code{keyboard-layout} field defined above, but we could just as well refer to
14876 a different layout. The @code{set-xorg-configuration} procedure communicates
14877 the desired Xorg configuration to the graphical log-in manager, by default
14878 GDM.
14879
14880 We've discussed how to specify the @emph{default} keyboard layout of your
14881 system when it starts, but you can also adjust it at run time:
14882
14883 @itemize
14884 @item
14885 If you're using GNOME, its settings panel has a ``Region & Language'' entry
14886 where you can select one or more keyboard layouts.
14887
14888 @item
14889 Under Xorg, the @command{setxkbmap} command (from the same-named package)
14890 allows you to change the current layout. For example, this is how you would
14891 change the layout to US Dvorak:
14892
14893 @example
14894 setxkbmap us dvorak
14895 @end example
14896
14897 @item
14898 The @code{loadkeys} command changes the keyboard layout in effect in the Linux
14899 console. However, note that @code{loadkeys} does @emph{not} use the XKB
14900 keyboard layout categorization described above. The command below loads the
14901 French bépo layout:
14902
14903 @example
14904 loadkeys fr-bepo
14905 @end example
14906 @end itemize
14907
14908 @node Locales
14909 @section Locales
14910
14911 @cindex locale
14912 A @dfn{locale} defines cultural conventions for a particular language
14913 and region of the world (@pxref{Locales,,, libc, The GNU C Library
14914 Reference Manual}). Each locale has a name that typically has the form
14915 @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
14916 @code{fr_LU.utf8} designates the locale for the French language, with
14917 cultural conventions from Luxembourg, and using the UTF-8 encoding.
14918
14919 @cindex locale definition
14920 Usually, you will want to specify the default locale for the machine
14921 using the @code{locale} field of the @code{operating-system} declaration
14922 (@pxref{operating-system Reference, @code{locale}}).
14923
14924 The selected locale is automatically added to the @dfn{locale
14925 definitions} known to the system if needed, with its codeset inferred
14926 from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
14927 @code{UTF-8} codeset. Additional locale definitions can be specified in
14928 the @code{locale-definitions} slot of @code{operating-system}---this is
14929 useful, for instance, if the codeset could not be inferred from the
14930 locale name. The default set of locale definitions includes some widely
14931 used locales, but not all the available locales, in order to save space.
14932
14933 For instance, to add the North Frisian locale for Germany, the value of
14934 that field may be:
14935
14936 @lisp
14937 (cons (locale-definition
14938 (name "fy_DE.utf8") (source "fy_DE"))
14939 %default-locale-definitions)
14940 @end lisp
14941
14942 Likewise, to save space, one might want @code{locale-definitions} to
14943 list only the locales that are actually used, as in:
14944
14945 @lisp
14946 (list (locale-definition
14947 (name "ja_JP.eucjp") (source "ja_JP")
14948 (charset "EUC-JP")))
14949 @end lisp
14950
14951 @vindex LOCPATH
14952 The compiled locale definitions are available at
14953 @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
14954 version, which is the default location where the GNU@tie{}libc provided
14955 by Guix looks for locale data. This can be overridden using the
14956 @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
14957 @env{LOCPATH} and locale packages}).
14958
14959 The @code{locale-definition} form is provided by the @code{(gnu system
14960 locale)} module. Details are given below.
14961
14962 @deftp {Data Type} locale-definition
14963 This is the data type of a locale definition.
14964
14965 @table @asis
14966
14967 @item @code{name}
14968 The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
14969 Reference Manual}, for more information on locale names.
14970
14971 @item @code{source}
14972 The name of the source for that locale. This is typically the
14973 @code{@var{language}_@var{territory}} part of the locale name.
14974
14975 @item @code{charset} (default: @code{"UTF-8"})
14976 The ``character set'' or ``code set'' for that locale,
14977 @uref{https://www.iana.org/assignments/character-sets, as defined by
14978 IANA}.
14979
14980 @end table
14981 @end deftp
14982
14983 @defvr {Scheme Variable} %default-locale-definitions
14984 A list of commonly used UTF-8 locales, used as the default
14985 value of the @code{locale-definitions} field of @code{operating-system}
14986 declarations.
14987
14988 @cindex locale name
14989 @cindex normalized codeset in locale names
14990 These locale definitions use the @dfn{normalized codeset} for the part
14991 that follows the dot in the name (@pxref{Using gettextized software,
14992 normalized codeset,, libc, The GNU C Library Reference Manual}). So for
14993 instance it has @code{uk_UA.utf8} but @emph{not}, say,
14994 @code{uk_UA.UTF-8}.
14995 @end defvr
14996
14997 @subsection Locale Data Compatibility Considerations
14998
14999 @cindex incompatibility, of locale data
15000 @code{operating-system} declarations provide a @code{locale-libcs} field
15001 to specify the GNU@tie{}libc packages that are used to compile locale
15002 declarations (@pxref{operating-system Reference}). ``Why would I
15003 care?'', you may ask. Well, it turns out that the binary format of
15004 locale data is occasionally incompatible from one libc version to
15005 another.
15006
15007 @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
15008 @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
15009 For instance, a program linked against libc version 2.21 is unable to
15010 read locale data produced with libc 2.22; worse, that program
15011 @emph{aborts} instead of simply ignoring the incompatible locale
15012 data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
15013 the incompatible locale data, which is already an improvement.}.
15014 Similarly, a program linked against libc 2.22 can read most, but not
15015 all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
15016 data is incompatible); thus calls to @code{setlocale} may fail, but
15017 programs will not abort.
15018
15019 The ``problem'' with Guix is that users have a lot of freedom: They can
15020 choose whether and when to upgrade software in their profiles, and might
15021 be using a libc version different from the one the system administrator
15022 used to build the system-wide locale data.
15023
15024 Fortunately, unprivileged users can also install their own locale data
15025 and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
15026 @env{GUIX_LOCPATH} and locale packages}).
15027
15028 Still, it is best if the system-wide locale data at
15029 @file{/run/current-system/locale} is built for all the libc versions
15030 actually in use on the system, so that all the programs can access
15031 it---this is especially crucial on a multi-user system. To do that, the
15032 administrator can specify several libc packages in the
15033 @code{locale-libcs} field of @code{operating-system}:
15034
15035 @lisp
15036 (use-package-modules base)
15037
15038 (operating-system
15039 ;; @dots{}
15040 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
15041 @end lisp
15042
15043 This example would lead to a system containing locale definitions for
15044 both libc 2.21 and the current version of libc in
15045 @file{/run/current-system/locale}.
15046
15047
15048 @node Services
15049 @section Services
15050
15051 @cindex system services
15052 An important part of preparing an @code{operating-system} declaration is
15053 listing @dfn{system services} and their configuration (@pxref{Using the
15054 Configuration System}). System services are typically daemons launched
15055 when the system boots, or other actions needed at that time---e.g.,
15056 configuring network access.
15057
15058 Guix has a broad definition of ``service'' (@pxref{Service
15059 Composition}), but many services are managed by the GNU@tie{}Shepherd
15060 (@pxref{Shepherd Services}). On a running system, the @command{herd}
15061 command allows you to list the available services, show their status,
15062 start and stop them, or do other specific operations (@pxref{Jump
15063 Start,,, shepherd, The GNU Shepherd Manual}). For example:
15064
15065 @example
15066 # herd status
15067 @end example
15068
15069 The above command, run as @code{root}, lists the currently defined
15070 services. The @command{herd doc} command shows a synopsis of the given
15071 service and its associated actions:
15072
15073 @example
15074 # herd doc nscd
15075 Run libc's name service cache daemon (nscd).
15076
15077 # herd doc nscd action invalidate
15078 invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
15079 @end example
15080
15081 The @command{start}, @command{stop}, and @command{restart} sub-commands
15082 have the effect you would expect. For instance, the commands below stop
15083 the nscd service and restart the Xorg display server:
15084
15085 @example
15086 # herd stop nscd
15087 Service nscd has been stopped.
15088 # herd restart xorg-server
15089 Service xorg-server has been stopped.
15090 Service xorg-server has been started.
15091 @end example
15092
15093 The following sections document the available services, starting with
15094 the core services, that may be used in an @code{operating-system}
15095 declaration.
15096
15097 @menu
15098 * Base Services:: Essential system services.
15099 * Scheduled Job Execution:: The mcron service.
15100 * Log Rotation:: The rottlog service.
15101 * Networking Services:: Network setup, SSH daemon, etc.
15102 * Unattended Upgrades:: Automated system upgrades.
15103 * X Window:: Graphical display.
15104 * Printing Services:: Local and remote printer support.
15105 * Desktop Services:: D-Bus and desktop services.
15106 * Sound Services:: ALSA and Pulseaudio services.
15107 * Database Services:: SQL databases, key-value stores, etc.
15108 * Mail Services:: IMAP, POP3, SMTP, and all that.
15109 * Messaging Services:: Messaging services.
15110 * Telephony Services:: Telephony services.
15111 * File-Sharing Services:: File-sharing services.
15112 * Monitoring Services:: Monitoring services.
15113 * Kerberos Services:: Kerberos services.
15114 * LDAP Services:: LDAP services.
15115 * Web Services:: Web servers.
15116 * Certificate Services:: TLS certificates via Let's Encrypt.
15117 * DNS Services:: DNS daemons.
15118 * VPN Services:: VPN daemons.
15119 * Network File System:: NFS related services.
15120 * Continuous Integration:: Cuirass and Laminar services.
15121 * Power Management Services:: Extending battery life.
15122 * Audio Services:: The MPD.
15123 * Virtualization Services:: Virtualization services.
15124 * Version Control Services:: Providing remote access to Git repositories.
15125 * Game Services:: Game servers.
15126 * PAM Mount Service:: Service to mount volumes when logging in.
15127 * Guix Services:: Services relating specifically to Guix.
15128 * Linux Services:: Services tied to the Linux kernel.
15129 * Hurd Services:: Services specific for a Hurd System.
15130 * Miscellaneous Services:: Other services.
15131 @end menu
15132
15133 @node Base Services
15134 @subsection Base Services
15135
15136 The @code{(gnu services base)} module provides definitions for the basic
15137 services that one expects from the system. The services exported by
15138 this module are listed below.
15139
15140 @defvr {Scheme Variable} %base-services
15141 This variable contains a list of basic services (@pxref{Service Types
15142 and Services}, for more information on service objects) one would
15143 expect from the system: a login service (mingetty) on each tty, syslogd,
15144 the libc name service cache daemon (nscd), the udev device manager, and
15145 more.
15146
15147 This is the default value of the @code{services} field of
15148 @code{operating-system} declarations. Usually, when customizing a
15149 system, you will want to append services to @code{%base-services}, like
15150 this:
15151
15152 @lisp
15153 (append (list (service avahi-service-type)
15154 (service openssh-service-type))
15155 %base-services)
15156 @end lisp
15157 @end defvr
15158
15159 @defvr {Scheme Variable} special-files-service-type
15160 This is the service that sets up ``special files'' such as
15161 @file{/bin/sh}; an instance of it is part of @code{%base-services}.
15162
15163 The value associated with @code{special-files-service-type} services
15164 must be a list of tuples where the first element is the ``special file''
15165 and the second element is its target. By default it is:
15166
15167 @cindex @file{/bin/sh}
15168 @cindex @file{sh}, in @file{/bin}
15169 @lisp
15170 `(("/bin/sh" ,(file-append bash "/bin/sh")))
15171 @end lisp
15172
15173 @cindex @file{/usr/bin/env}
15174 @cindex @file{env}, in @file{/usr/bin}
15175 If you want to add, say, @code{/usr/bin/env} to your system, you can
15176 change it to:
15177
15178 @lisp
15179 `(("/bin/sh" ,(file-append bash "/bin/sh"))
15180 ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
15181 @end lisp
15182
15183 Since this is part of @code{%base-services}, you can use
15184 @code{modify-services} to customize the set of special files
15185 (@pxref{Service Reference, @code{modify-services}}). But the simple way
15186 to add a special file is @i{via} the @code{extra-special-file} procedure
15187 (see below).
15188 @end defvr
15189
15190 @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
15191 Use @var{target} as the ``special file'' @var{file}.
15192
15193 For example, adding the following lines to the @code{services} field of
15194 your operating system declaration leads to a @file{/usr/bin/env}
15195 symlink:
15196
15197 @lisp
15198 (extra-special-file "/usr/bin/env"
15199 (file-append coreutils "/bin/env"))
15200 @end lisp
15201 @end deffn
15202
15203 @deffn {Scheme Procedure} host-name-service @var{name}
15204 Return a service that sets the host name to @var{name}.
15205 @end deffn
15206
15207 @defvr {Scheme Variable} console-font-service-type
15208 Install the given fonts on the specified ttys (fonts are per
15209 virtual console on the kernel Linux). The value of this service is a list of
15210 tty/font pairs. The font can be the name of a font provided by the @code{kbd}
15211 package or any valid argument to @command{setfont}, as in this example:
15212
15213 @lisp
15214 `(("tty1" . "LatGrkCyr-8x16")
15215 ("tty2" . ,(file-append
15216 font-tamzen
15217 "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
15218 ("tty3" . ,(file-append
15219 font-terminus
15220 "/share/consolefonts/ter-132n"))) ; for HDPI
15221 @end lisp
15222 @end defvr
15223
15224 @deffn {Scheme Procedure} login-service @var{config}
15225 Return a service to run login according to @var{config}, a
15226 @code{<login-configuration>} object, which specifies the message of the day,
15227 among other things.
15228 @end deffn
15229
15230 @deftp {Data Type} login-configuration
15231 This is the data type representing the configuration of login.
15232
15233 @table @asis
15234
15235 @item @code{motd}
15236 @cindex message of the day
15237 A file-like object containing the ``message of the day''.
15238
15239 @item @code{allow-empty-passwords?} (default: @code{#t})
15240 Allow empty passwords by default so that first-time users can log in when
15241 the 'root' account has just been created.
15242
15243 @end table
15244 @end deftp
15245
15246 @deffn {Scheme Procedure} mingetty-service @var{config}
15247 Return a service to run mingetty according to @var{config}, a
15248 @code{<mingetty-configuration>} object, which specifies the tty to run, among
15249 other things.
15250 @end deffn
15251
15252 @deftp {Data Type} mingetty-configuration
15253 This is the data type representing the configuration of Mingetty, which
15254 provides the default implementation of virtual console log-in.
15255
15256 @table @asis
15257
15258 @item @code{tty}
15259 The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
15260
15261 @item @code{auto-login} (default: @code{#f})
15262 When true, this field must be a string denoting the user name under
15263 which the system automatically logs in. When it is @code{#f}, a
15264 user name and password must be entered to log in.
15265
15266 @item @code{login-program} (default: @code{#f})
15267 This must be either @code{#f}, in which case the default log-in program
15268 is used (@command{login} from the Shadow tool suite), or a gexp denoting
15269 the name of the log-in program.
15270
15271 @item @code{login-pause?} (default: @code{#f})
15272 When set to @code{#t} in conjunction with @var{auto-login}, the user
15273 will have to press a key before the log-in shell is launched.
15274
15275 @item @code{clear-on-logout?} (default: @code{#t})
15276 When set to @code{#t}, the screen will be cleared after logout.
15277
15278 @item @code{mingetty} (default: @var{mingetty})
15279 The Mingetty package to use.
15280
15281 @end table
15282 @end deftp
15283
15284 @deffn {Scheme Procedure} agetty-service @var{config}
15285 Return a service to run agetty according to @var{config}, an
15286 @code{<agetty-configuration>} object, which specifies the tty to run,
15287 among other things.
15288 @end deffn
15289
15290 @deftp {Data Type} agetty-configuration
15291 This is the data type representing the configuration of agetty, which
15292 implements virtual and serial console log-in. See the @code{agetty(8)}
15293 man page for more information.
15294
15295 @table @asis
15296
15297 @item @code{tty}
15298 The name of the console this agetty runs on, as a string---e.g.,
15299 @code{"ttyS0"}. This argument is optional, it will default to
15300 a reasonable default serial port used by the kernel Linux.
15301
15302 For this, if there is a value for an option @code{agetty.tty} in the kernel
15303 command line, agetty will extract the device name of the serial port
15304 from it and use that.
15305
15306 If not and if there is a value for an option @code{console} with a tty in
15307 the Linux command line, agetty will extract the device name of the
15308 serial port from it and use that.
15309
15310 In both cases, agetty will leave the other serial device settings
15311 (baud rate etc.)@: alone---in the hope that Linux pinned them to the
15312 correct values.
15313
15314 @item @code{baud-rate} (default: @code{#f})
15315 A string containing a comma-separated list of one or more baud rates, in
15316 descending order.
15317
15318 @item @code{term} (default: @code{#f})
15319 A string containing the value used for the @env{TERM} environment
15320 variable.
15321
15322 @item @code{eight-bits?} (default: @code{#f})
15323 When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
15324 disabled.
15325
15326 @item @code{auto-login} (default: @code{#f})
15327 When passed a login name, as a string, the specified user will be logged
15328 in automatically without prompting for their login name or password.
15329
15330 @item @code{no-reset?} (default: @code{#f})
15331 When @code{#t}, don't reset terminal cflags (control modes).
15332
15333 @item @code{host} (default: @code{#f})
15334 This accepts a string containing the ``login_host'', which will be written
15335 into the @file{/var/run/utmpx} file.
15336
15337 @item @code{remote?} (default: @code{#f})
15338 When set to @code{#t} in conjunction with @var{host}, this will add an
15339 @code{-r} fakehost option to the command line of the login program
15340 specified in @var{login-program}.
15341
15342 @item @code{flow-control?} (default: @code{#f})
15343 When set to @code{#t}, enable hardware (RTS/CTS) flow control.
15344
15345 @item @code{no-issue?} (default: @code{#f})
15346 When set to @code{#t}, the contents of the @file{/etc/issue} file will
15347 not be displayed before presenting the login prompt.
15348
15349 @item @code{init-string} (default: @code{#f})
15350 This accepts a string that will be sent to the tty or modem before
15351 sending anything else. It can be used to initialize a modem.
15352
15353 @item @code{no-clear?} (default: @code{#f})
15354 When set to @code{#t}, agetty will not clear the screen before showing
15355 the login prompt.
15356
15357 @item @code{login-program} (default: (file-append shadow "/bin/login"))
15358 This must be either a gexp denoting the name of a log-in program, or
15359 unset, in which case the default value is the @command{login} from the
15360 Shadow tool suite.
15361
15362 @item @code{local-line} (default: @code{#f})
15363 Control the CLOCAL line flag. This accepts one of three symbols as
15364 arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
15365 the default value chosen by agetty is @code{'auto}.
15366
15367 @item @code{extract-baud?} (default: @code{#f})
15368 When set to @code{#t}, instruct agetty to try to extract the baud rate
15369 from the status messages produced by certain types of modems.
15370
15371 @item @code{skip-login?} (default: @code{#f})
15372 When set to @code{#t}, do not prompt the user for a login name. This
15373 can be used with @var{login-program} field to use non-standard login
15374 systems.
15375
15376 @item @code{no-newline?} (default: @code{#f})
15377 When set to @code{#t}, do not print a newline before printing the
15378 @file{/etc/issue} file.
15379
15380 @c Is this dangerous only when used with login-program, or always?
15381 @item @code{login-options} (default: @code{#f})
15382 This option accepts a string containing options that are passed to the
15383 login program. When used with the @var{login-program}, be aware that a
15384 malicious user could try to enter a login name containing embedded
15385 options that could be parsed by the login program.
15386
15387 @item @code{login-pause} (default: @code{#f})
15388 When set to @code{#t}, wait for any key before showing the login prompt.
15389 This can be used in conjunction with @var{auto-login} to save memory by
15390 lazily spawning shells.
15391
15392 @item @code{chroot} (default: @code{#f})
15393 Change root to the specified directory. This option accepts a directory
15394 path as a string.
15395
15396 @item @code{hangup?} (default: @code{#f})
15397 Use the Linux system call @code{vhangup} to do a virtual hangup of the
15398 specified terminal.
15399
15400 @item @code{keep-baud?} (default: @code{#f})
15401 When set to @code{#t}, try to keep the existing baud rate. The baud
15402 rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
15403 character.
15404
15405 @item @code{timeout} (default: @code{#f})
15406 When set to an integer value, terminate if no user name could be read
15407 within @var{timeout} seconds.
15408
15409 @item @code{detect-case?} (default: @code{#f})
15410 When set to @code{#t}, turn on support for detecting an uppercase-only
15411 terminal. This setting will detect a login name containing only
15412 uppercase letters as indicating an uppercase-only terminal and turn on
15413 some upper-to-lower case conversions. Note that this will not support
15414 Unicode characters.
15415
15416 @item @code{wait-cr?} (default: @code{#f})
15417 When set to @code{#t}, wait for the user or modem to send a
15418 carriage-return or linefeed character before displaying
15419 @file{/etc/issue} or login prompt. This is typically used with the
15420 @var{init-string} option.
15421
15422 @item @code{no-hints?} (default: @code{#f})
15423 When set to @code{#t}, do not print hints about Num, Caps, and Scroll
15424 locks.
15425
15426 @item @code{no-hostname?} (default: @code{#f})
15427 By default, the hostname is printed. When this option is set to
15428 @code{#t}, no hostname will be shown at all.
15429
15430 @item @code{long-hostname?} (default: @code{#f})
15431 By default, the hostname is only printed until the first dot. When this
15432 option is set to @code{#t}, the fully qualified hostname by
15433 @code{gethostname} or @code{getaddrinfo} is shown.
15434
15435 @item @code{erase-characters} (default: @code{#f})
15436 This option accepts a string of additional characters that should be
15437 interpreted as backspace when the user types their login name.
15438
15439 @item @code{kill-characters} (default: @code{#f})
15440 This option accepts a string that should be interpreted to mean ``ignore
15441 all previous characters'' (also called a ``kill'' character) when the user
15442 types their login name.
15443
15444 @item @code{chdir} (default: @code{#f})
15445 This option accepts, as a string, a directory path that will be changed
15446 to before login.
15447
15448 @item @code{delay} (default: @code{#f})
15449 This options accepts, as an integer, the number of seconds to sleep
15450 before opening the tty and displaying the login prompt.
15451
15452 @item @code{nice} (default: @code{#f})
15453 This option accepts, as an integer, the nice value with which to run the
15454 @command{login} program.
15455
15456 @item @code{extra-options} (default: @code{'()})
15457 This option provides an ``escape hatch'' for the user to provide arbitrary
15458 command-line arguments to @command{agetty} as a list of strings.
15459
15460 @end table
15461 @end deftp
15462
15463 @deffn {Scheme Procedure} kmscon-service-type @var{config}
15464 Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
15465 according to @var{config}, a @code{<kmscon-configuration>} object, which
15466 specifies the tty to run, among other things.
15467 @end deffn
15468
15469 @deftp {Data Type} kmscon-configuration
15470 This is the data type representing the configuration of Kmscon, which
15471 implements virtual console log-in.
15472
15473 @table @asis
15474
15475 @item @code{virtual-terminal}
15476 The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
15477
15478 @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
15479 A gexp denoting the name of the log-in program. The default log-in program is
15480 @command{login} from the Shadow tool suite.
15481
15482 @item @code{login-arguments} (default: @code{'("-p")})
15483 A list of arguments to pass to @command{login}.
15484
15485 @item @code{auto-login} (default: @code{#f})
15486 When passed a login name, as a string, the specified user will be logged
15487 in automatically without prompting for their login name or password.
15488
15489 @item @code{hardware-acceleration?} (default: #f)
15490 Whether to use hardware acceleration.
15491
15492 @item @code{font-engine} (default: @code{"pango"})
15493 Font engine used in Kmscon.
15494
15495 @item @code{font-size} (default: @code{12})
15496 Font size used in Kmscon.
15497
15498 @item @code{keyboard-layout} (default: @code{#f})
15499 If this is @code{#f}, Kmscon uses the default keyboard layout---usually US
15500 English (``qwerty'') for a 105-key PC keyboard.
15501
15502 Otherwise this must be a @code{keyboard-layout} object specifying the
15503 keyboard layout. @xref{Keyboard Layout}, for more information on how to
15504 specify the keyboard layout.
15505
15506 @item @code{kmscon} (default: @var{kmscon})
15507 The Kmscon package to use.
15508
15509 @end table
15510 @end deftp
15511
15512 @cindex name service cache daemon
15513 @cindex nscd
15514 @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
15515 [#:name-services '()]
15516 Return a service that runs the libc name service cache daemon (nscd) with the
15517 given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
15518 Service Switch}, for an example.
15519
15520 For convenience, the Shepherd service for nscd provides the following actions:
15521
15522 @table @code
15523 @item invalidate
15524 @cindex cache invalidation, nscd
15525 @cindex nscd, cache invalidation
15526 This invalidate the given cache. For instance, running:
15527
15528 @example
15529 herd invalidate nscd hosts
15530 @end example
15531
15532 @noindent
15533 invalidates the host name lookup cache of nscd.
15534
15535 @item statistics
15536 Running @command{herd statistics nscd} displays information about nscd usage
15537 and caches.
15538 @end table
15539
15540 @end deffn
15541
15542 @defvr {Scheme Variable} %nscd-default-configuration
15543 This is the default @code{<nscd-configuration>} value (see below) used
15544 by @code{nscd-service}. It uses the caches defined by
15545 @code{%nscd-default-caches}; see below.
15546 @end defvr
15547
15548 @deftp {Data Type} nscd-configuration
15549 This is the data type representing the name service cache daemon (nscd)
15550 configuration.
15551
15552 @table @asis
15553
15554 @item @code{name-services} (default: @code{'()})
15555 List of packages denoting @dfn{name services} that must be visible to
15556 the nscd---e.g., @code{(list @var{nss-mdns})}.
15557
15558 @item @code{glibc} (default: @var{glibc})
15559 Package object denoting the GNU C Library providing the @command{nscd}
15560 command.
15561
15562 @item @code{log-file} (default: @code{"/var/log/nscd.log"})
15563 Name of the nscd log file. This is where debugging output goes when
15564 @code{debug-level} is strictly positive.
15565
15566 @item @code{debug-level} (default: @code{0})
15567 Integer denoting the debugging levels. Higher numbers mean that more
15568 debugging output is logged.
15569
15570 @item @code{caches} (default: @code{%nscd-default-caches})
15571 List of @code{<nscd-cache>} objects denoting things to be cached; see
15572 below.
15573
15574 @end table
15575 @end deftp
15576
15577 @deftp {Data Type} nscd-cache
15578 Data type representing a cache database of nscd and its parameters.
15579
15580 @table @asis
15581
15582 @item @code{database}
15583 This is a symbol representing the name of the database to be cached.
15584 Valid values are @code{passwd}, @code{group}, @code{hosts}, and
15585 @code{services}, which designate the corresponding NSS database
15586 (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
15587
15588 @item @code{positive-time-to-live}
15589 @itemx @code{negative-time-to-live} (default: @code{20})
15590 A number representing the number of seconds during which a positive or
15591 negative lookup result remains in cache.
15592
15593 @item @code{check-files?} (default: @code{#t})
15594 Whether to check for updates of the files corresponding to
15595 @var{database}.
15596
15597 For instance, when @var{database} is @code{hosts}, setting this flag
15598 instructs nscd to check for updates in @file{/etc/hosts} and to take
15599 them into account.
15600
15601 @item @code{persistent?} (default: @code{#t})
15602 Whether the cache should be stored persistently on disk.
15603
15604 @item @code{shared?} (default: @code{#t})
15605 Whether the cache should be shared among users.
15606
15607 @item @code{max-database-size} (default: 32@tie{}MiB)
15608 Maximum size in bytes of the database cache.
15609
15610 @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
15611 @c settings, so leave them out.
15612
15613 @end table
15614 @end deftp
15615
15616 @defvr {Scheme Variable} %nscd-default-caches
15617 List of @code{<nscd-cache>} objects used by default by
15618 @code{nscd-configuration} (see above).
15619
15620 It enables persistent and aggressive caching of service and host name
15621 lookups. The latter provides better host name lookup performance,
15622 resilience in the face of unreliable name servers, and also better
15623 privacy---often the result of host name lookups is in local cache, so
15624 external name servers do not even need to be queried.
15625 @end defvr
15626
15627 @anchor{syslog-configuration-type}
15628 @cindex syslog
15629 @cindex logging
15630 @deftp {Data Type} syslog-configuration
15631 This data type represents the configuration of the syslog daemon.
15632
15633 @table @asis
15634 @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
15635 The syslog daemon to use.
15636
15637 @item @code{config-file} (default: @code{%default-syslog.conf})
15638 The syslog configuration file to use.
15639
15640 @end table
15641 @end deftp
15642
15643 @anchor{syslog-service}
15644 @cindex syslog
15645 @deffn {Scheme Procedure} syslog-service @var{config}
15646 Return a service that runs a syslog daemon according to @var{config}.
15647
15648 @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
15649 information on the configuration file syntax.
15650 @end deffn
15651
15652 @defvr {Scheme Variable} guix-service-type
15653 This is the type of the service that runs the build daemon,
15654 @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
15655 @code{guix-configuration} record as described below.
15656 @end defvr
15657
15658 @anchor{guix-configuration-type}
15659 @deftp {Data Type} guix-configuration
15660 This data type represents the configuration of the Guix build daemon.
15661 @xref{Invoking guix-daemon}, for more information.
15662
15663 @table @asis
15664 @item @code{guix} (default: @var{guix})
15665 The Guix package to use.
15666
15667 @item @code{build-group} (default: @code{"guixbuild"})
15668 Name of the group for build user accounts.
15669
15670 @item @code{build-accounts} (default: @code{10})
15671 Number of build user accounts to create.
15672
15673 @item @code{authorize-key?} (default: @code{#t})
15674 @cindex substitutes, authorization thereof
15675 Whether to authorize the substitute keys listed in
15676 @code{authorized-keys}---by default that of
15677 @code{@value{SUBSTITUTE-SERVER-1}} and
15678 @code{@value{SUBSTITUTE-SERVER-2}}
15679 (@pxref{Substitutes}).
15680
15681 When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
15682 changed by invoking @command{guix archive --authorize}. You must
15683 instead adjust @code{guix-configuration} as you wish and reconfigure the
15684 system. This ensures that your operating system configuration file is
15685 self-contained.
15686
15687 @quotation Note
15688 When booting or reconfiguring to a system where @code{authorize-key?}
15689 is true, the existing @file{/etc/guix/acl} file is backed up as
15690 @file{/etc/guix/acl.bak} if it was determined to be a manually modified
15691 file. This is to facilitate migration from earlier versions, which
15692 allowed for in-place modifications to @file{/etc/guix/acl}.
15693 @end quotation
15694
15695 @vindex %default-authorized-guix-keys
15696 @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
15697 The list of authorized key files for archive imports, as a list of
15698 string-valued gexps (@pxref{Invoking guix archive}). By default, it
15699 contains that of @code{@value{SUBSTITUTE-SERVER-1}} and
15700 @code{@value{SUBSTITUTE-SERVER-2}} (@pxref{Substitutes}). See
15701 @code{substitute-urls} below for an example on how to change it.
15702
15703 @item @code{use-substitutes?} (default: @code{#t})
15704 Whether to use substitutes.
15705
15706 @item @code{substitute-urls} (default: @code{%default-substitute-urls})
15707 The list of URLs where to look for substitutes by default.
15708
15709 Suppose you would like to fetch substitutes from @code{guix.example.org}
15710 in addition to @code{@value{SUBSTITUTE-SERVER-1}}. You will need to do
15711 two things: (1) add @code{guix.example.org} to @code{substitute-urls},
15712 and (2) authorize its signing key, having done appropriate checks
15713 (@pxref{Substitute Server Authorization}). The configuration below does
15714 exactly that:
15715
15716 @lisp
15717 (guix-configuration
15718 (substitute-urls
15719 (append (list "https://guix.example.org")
15720 %default-substitute-urls))
15721 (authorized-keys
15722 (append (list (local-file "./guix.example.org-key.pub"))
15723 %default-authorized-guix-keys)))
15724 @end lisp
15725
15726 This example assumes that the file @file{./guix.example.org-key.pub}
15727 contains the public key that @code{guix.example.org} uses to sign
15728 substitutes.
15729
15730 @item @code{max-silent-time} (default: @code{0})
15731 @itemx @code{timeout} (default: @code{0})
15732 The number of seconds of silence and the number of seconds of activity,
15733 respectively, after which a build process times out. A value of zero
15734 disables the timeout.
15735
15736 @item @code{log-compression} (default: @code{'bzip2})
15737 The type of compression used for build logs---one of @code{gzip},
15738 @code{bzip2}, or @code{none}.
15739
15740 @item @code{discover?} (default: @code{#f})
15741 Whether to discover substitute servers on the local network using mDNS
15742 and DNS-SD.
15743
15744 @item @code{extra-options} (default: @code{'()})
15745 List of extra command-line options for @command{guix-daemon}.
15746
15747 @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
15748 File where @command{guix-daemon}'s standard output and standard error
15749 are written.
15750
15751 @cindex HTTP proxy, for @code{guix-daemon}
15752 @cindex proxy, for @code{guix-daemon} HTTP access
15753 @item @code{http-proxy} (default: @code{#f})
15754 The URL of the HTTP and HTTPS proxy used for downloading fixed-output
15755 derivations and substitutes.
15756
15757 It is also possible to change the daemon's proxy at run time through the
15758 @code{set-http-proxy} action, which restarts it:
15759
15760 @example
15761 herd set-http-proxy guix-daemon http://localhost:8118
15762 @end example
15763
15764 To clear the proxy settings, run:
15765
15766 @example
15767 herd set-http-proxy guix-daemon
15768 @end example
15769
15770 @item @code{tmpdir} (default: @code{#f})
15771 A directory path where the @command{guix-daemon} will perform builds.
15772
15773 @end table
15774 @end deftp
15775
15776 @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
15777 Run @var{udev}, which populates the @file{/dev} directory dynamically.
15778 udev rules can be provided as a list of files through the @var{rules}
15779 variable. The procedures @code{udev-rule}, @code{udev-rules-service}
15780 and @code{file->udev-rule} from @code{(gnu services base)} simplify the
15781 creation of such rule files.
15782
15783 The @command{herd rules udev} command, as root, returns the name of the
15784 directory containing all the active udev rules.
15785 @end deffn
15786
15787 @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
15788 Return a udev-rule file named @var{file-name} containing the rules
15789 defined by the @var{contents} literal.
15790
15791 In the following example, a rule for a USB device is defined to be
15792 stored in the file @file{90-usb-thing.rules}. The rule runs a script
15793 upon detecting a USB device with a given product identifier.
15794
15795 @lisp
15796 (define %example-udev-rule
15797 (udev-rule
15798 "90-usb-thing.rules"
15799 (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
15800 "ATTR@{product@}==\"Example\", "
15801 "RUN+=\"/path/to/script\"")))
15802 @end lisp
15803 @end deffn
15804
15805 @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
15806 [#:groups @var{groups}]
15807 Return a service that extends @code{udev-service-type } with @var{rules}
15808 and @code{account-service-type} with @var{groups} as system groups.
15809 This works by creating a singleton service type
15810 @code{@var{name}-udev-rules}, of which the returned service is an
15811 instance.
15812
15813 Here we show how it can be used to extend @code{udev-service-type} with the
15814 previously defined rule @code{%example-udev-rule}.
15815
15816 @lisp
15817 (operating-system
15818 ;; @dots{}
15819 (services
15820 (cons (udev-rules-service 'usb-thing %example-udev-rule)
15821 %desktop-services)))
15822 @end lisp
15823 @end deffn
15824
15825 @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
15826 Return a udev file named @var{file-name} containing the rules defined
15827 within @var{file}, a file-like object.
15828
15829 The following example showcases how we can use an existing rule file.
15830
15831 @lisp
15832 (use-modules (guix download) ;for url-fetch
15833 (guix packages) ;for origin
15834 @dots{})
15835
15836 (define %android-udev-rules
15837 (file->udev-rule
15838 "51-android-udev.rules"
15839 (let ((version "20170910"))
15840 (origin
15841 (method url-fetch)
15842 (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
15843 "android-udev-rules/" version "/51-android.rules"))
15844 (sha256
15845 (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
15846 @end lisp
15847 @end deffn
15848
15849 Additionally, Guix package definitions can be included in @var{rules} in
15850 order to extend the udev rules with the definitions found under their
15851 @file{lib/udev/rules.d} sub-directory. In lieu of the previous
15852 @var{file->udev-rule} example, we could have used the
15853 @var{android-udev-rules} package which exists in Guix in the @code{(gnu
15854 packages android)} module.
15855
15856 The following example shows how to use the @var{android-udev-rules}
15857 package so that the Android tool @command{adb} can detect devices
15858 without root privileges. It also details how to create the
15859 @code{adbusers} group, which is required for the proper functioning of
15860 the rules defined within the @code{android-udev-rules} package. To
15861 create such a group, we must define it both as part of the
15862 @code{supplementary-groups} of our @code{user-account} declaration, as
15863 well as in the @var{groups} of the @code{udev-rules-service} procedure.
15864
15865 @lisp
15866 (use-modules (gnu packages android) ;for android-udev-rules
15867 (gnu system shadow) ;for user-group
15868 @dots{})
15869
15870 (operating-system
15871 ;; @dots{}
15872 (users (cons (user-account
15873 ;; @dots{}
15874 (supplementary-groups
15875 '("adbusers" ;for adb
15876 "wheel" "netdev" "audio" "video")))))
15877 ;; @dots{}
15878 (services
15879 (cons (udev-rules-service 'android android-udev-rules
15880 #:groups '("adbusers"))
15881 %desktop-services)))
15882 @end lisp
15883
15884 @defvr {Scheme Variable} urandom-seed-service-type
15885 Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
15886 when rebooting. It also tries to seed @file{/dev/urandom} from
15887 @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
15888 readable.
15889 @end defvr
15890
15891 @defvr {Scheme Variable} %random-seed-file
15892 This is the name of the file where some random bytes are saved by
15893 @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
15894 It defaults to @file{/var/lib/random-seed}.
15895 @end defvr
15896
15897 @cindex mouse
15898 @cindex gpm
15899 @defvr {Scheme Variable} gpm-service-type
15900 This is the type of the service that runs GPM, the @dfn{general-purpose
15901 mouse daemon}, which provides mouse support to the Linux console. GPM
15902 allows users to use the mouse in the console, notably to select, copy,
15903 and paste text.
15904
15905 The value for services of this type must be a @code{gpm-configuration}
15906 (see below). This service is not part of @code{%base-services}.
15907 @end defvr
15908
15909 @deftp {Data Type} gpm-configuration
15910 Data type representing the configuration of GPM.
15911
15912 @table @asis
15913 @item @code{options} (default: @code{%default-gpm-options})
15914 Command-line options passed to @command{gpm}. The default set of
15915 options instruct @command{gpm} to listen to mouse events on
15916 @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
15917 more information.
15918
15919 @item @code{gpm} (default: @code{gpm})
15920 The GPM package to use.
15921
15922 @end table
15923 @end deftp
15924
15925 @anchor{guix-publish-service-type}
15926 @deffn {Scheme Variable} guix-publish-service-type
15927 This is the service type for @command{guix publish} (@pxref{Invoking
15928 guix publish}). Its value must be a @code{guix-publish-configuration}
15929 object, as described below.
15930
15931 This assumes that @file{/etc/guix} already contains a signing key pair as
15932 created by @command{guix archive --generate-key} (@pxref{Invoking guix
15933 archive}). If that is not the case, the service will fail to start.
15934 @end deffn
15935
15936 @deftp {Data Type} guix-publish-configuration
15937 Data type representing the configuration of the @code{guix publish}
15938 service.
15939
15940 @table @asis
15941 @item @code{guix} (default: @code{guix})
15942 The Guix package to use.
15943
15944 @item @code{port} (default: @code{80})
15945 The TCP port to listen for connections.
15946
15947 @item @code{host} (default: @code{"localhost"})
15948 The host (and thus, network interface) to listen to. Use
15949 @code{"0.0.0.0"} to listen on all the network interfaces.
15950
15951 @item @code{advertise?} (default: @code{#f})
15952 When true, advertise the service on the local network @i{via} the DNS-SD
15953 protocol, using Avahi.
15954
15955 This allows neighboring Guix devices with discovery on (see
15956 @code{guix-configuration} above) to discover this @command{guix publish}
15957 instance and to automatically download substitutes from it.
15958
15959 @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
15960 This is a list of compression method/level tuple used when compressing
15961 substitutes. For example, to compress all substitutes with @emph{both} lzip
15962 at level 7 and gzip at level 9, write:
15963
15964 @lisp
15965 '(("lzip" 7) ("gzip" 9))
15966 @end lisp
15967
15968 Level 9 achieves the best compression ratio at the expense of increased CPU
15969 usage, whereas level 1 achieves fast compression. @xref{Invoking guix
15970 publish}, for more information on the available compression methods and
15971 the tradeoffs involved.
15972
15973 An empty list disables compression altogether.
15974
15975 @item @code{nar-path} (default: @code{"nar"})
15976 The URL path at which ``nars'' can be fetched. @xref{Invoking guix
15977 publish, @option{--nar-path}}, for details.
15978
15979 @item @code{cache} (default: @code{#f})
15980 When it is @code{#f}, disable caching and instead generate archives on
15981 demand. Otherwise, this should be the name of a directory---e.g.,
15982 @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
15983 archives and meta-data ready to be sent. @xref{Invoking guix publish,
15984 @option{--cache}}, for more information on the tradeoffs involved.
15985
15986 @item @code{workers} (default: @code{#f})
15987 When it is an integer, this is the number of worker threads used for
15988 caching; when @code{#f}, the number of processors is used.
15989 @xref{Invoking guix publish, @option{--workers}}, for more information.
15990
15991 @item @code{cache-bypass-threshold} (default: 10 MiB)
15992 When @code{cache} is true, this is the maximum size in bytes of a store
15993 item for which @command{guix publish} may bypass its cache in case of a
15994 cache miss. @xref{Invoking guix publish,
15995 @option{--cache-bypass-threshold}}, for more information.
15996
15997 @item @code{ttl} (default: @code{#f})
15998 When it is an integer, this denotes the @dfn{time-to-live} in seconds
15999 of the published archives. @xref{Invoking guix publish, @option{--ttl}},
16000 for more information.
16001 @end table
16002 @end deftp
16003
16004 @anchor{rngd-service}
16005 @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
16006 [#:device "/dev/hwrng"]
16007 Return a service that runs the @command{rngd} program from @var{rng-tools}
16008 to add @var{device} to the kernel's entropy pool. The service will fail if
16009 @var{device} does not exist.
16010 @end deffn
16011
16012 @anchor{pam-limits-service}
16013 @cindex session limits
16014 @cindex ulimit
16015 @cindex priority
16016 @cindex realtime
16017 @cindex jackd
16018 @cindex nofile
16019 @cindex open file descriptors
16020 @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
16021
16022 Return a service that installs a configuration file for the
16023 @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
16024 @code{pam_limits} module}. The procedure optionally takes a list of
16025 @code{pam-limits-entry} values, which can be used to specify
16026 @code{ulimit} limits and @code{nice} priority limits to user sessions.
16027
16028 The following limits definition sets two hard and soft limits for all
16029 login sessions of users in the @code{realtime} group:
16030
16031 @lisp
16032 (pam-limits-service
16033 (list
16034 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
16035 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
16036 @end lisp
16037
16038 The first entry increases the maximum realtime priority for
16039 non-privileged processes; the second entry lifts any restriction of the
16040 maximum address space that can be locked in memory. These settings are
16041 commonly used for real-time audio systems.
16042
16043 Another useful example is raising the maximum number of open file
16044 descriptors that can be used:
16045
16046 @lisp
16047 (pam-limits-service
16048 (list
16049 (pam-limits-entry "*" 'both 'nofile 100000)))
16050 @end lisp
16051
16052 In the above example, the asterisk means the limit should apply to any
16053 user. It is important to ensure the chosen value doesn't exceed the
16054 maximum system value visible in the @file{/proc/sys/fs/file-max} file,
16055 else the users would be prevented from login in. For more information
16056 about the Pluggable Authentication Module (PAM) limits, refer to the
16057 @samp{pam_limits} man page from the @code{linux-pam} package.
16058 @end deffn
16059
16060 @node Scheduled Job Execution
16061 @subsection Scheduled Job Execution
16062
16063 @cindex cron
16064 @cindex mcron
16065 @cindex scheduling jobs
16066 The @code{(gnu services mcron)} module provides an interface to
16067 GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
16068 mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
16069 Unix @command{cron} daemon; the main difference is that it is
16070 implemented in Guile Scheme, which provides a lot of flexibility when
16071 specifying the scheduling of jobs and their actions.
16072
16073 The example below defines an operating system that runs the
16074 @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
16075 and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
16076 well as the @command{mkid} command on behalf of an unprivileged user
16077 (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
16078 gexps to introduce job definitions that are passed to mcron
16079 (@pxref{G-Expressions}).
16080
16081 @lisp
16082 (use-modules (guix) (gnu) (gnu services mcron))
16083 (use-package-modules base idutils)
16084
16085 (define updatedb-job
16086 ;; Run 'updatedb' at 3AM every day. Here we write the
16087 ;; job's action as a Scheme procedure.
16088 #~(job '(next-hour '(3))
16089 (lambda ()
16090 (execl (string-append #$findutils "/bin/updatedb")
16091 "updatedb"
16092 "--prunepaths=/tmp /var/tmp /gnu/store"))
16093 "updatedb"))
16094
16095 (define garbage-collector-job
16096 ;; Collect garbage 5 minutes after midnight every day.
16097 ;; The job's action is a shell command.
16098 #~(job "5 0 * * *" ;Vixie cron syntax
16099 "guix gc -F 1G"))
16100
16101 (define idutils-job
16102 ;; Update the index database as user "charlie" at 12:15PM
16103 ;; and 19:15PM. This runs from the user's home directory.
16104 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
16105 (string-append #$idutils "/bin/mkid src")
16106 #:user "charlie"))
16107
16108 (operating-system
16109 ;; @dots{}
16110
16111 ;; %BASE-SERVICES already includes an instance of
16112 ;; 'mcron-service-type', which we extend with additional
16113 ;; jobs using 'simple-service'.
16114 (services (cons (simple-service 'my-cron-jobs
16115 mcron-service-type
16116 (list garbage-collector-job
16117 updatedb-job
16118 idutils-job))
16119 %base-services)))
16120 @end lisp
16121
16122 @quotation Tip
16123 When providing the action of a job specification as a procedure, you
16124 should provide an explicit name for the job via the optional 3rd
16125 argument as done in the @code{updatedb-job} example above. Otherwise,
16126 the job would appear as ``Lambda function'' in the output of
16127 @command{herd schedule mcron}, which is not nearly descriptive enough!
16128 @end quotation
16129
16130 For more complex jobs defined in Scheme where you need control over the top
16131 level, for instance to introduce a @code{use-modules} form, you can move your
16132 code to a separate program using the @code{program-file} procedure of the
16133 @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
16134 illustrates that.
16135
16136 @lisp
16137 (define %battery-alert-job
16138 ;; Beep when the battery percentage falls below %MIN-LEVEL.
16139 #~(job
16140 '(next-minute (range 0 60 1))
16141 #$(program-file
16142 "battery-alert.scm"
16143 (with-imported-modules (source-module-closure
16144 '((guix build utils)))
16145 #~(begin
16146 (use-modules (guix build utils)
16147 (ice-9 popen)
16148 (ice-9 regex)
16149 (ice-9 textual-ports)
16150 (srfi srfi-2))
16151
16152 (define %min-level 20)
16153
16154 (setenv "LC_ALL" "C") ;ensure English output
16155 (and-let* ((input-pipe (open-pipe*
16156 OPEN_READ
16157 #$(file-append acpi "/bin/acpi")))
16158 (output (get-string-all input-pipe))
16159 (m (string-match "Discharging, ([0-9]+)%" output))
16160 (level (string->number (match:substring m 1)))
16161 ((< level %min-level)))
16162 (format #t "warning: Battery level is low (~a%)~%" level)
16163 (invoke #$(file-append beep "/bin/beep") "-r5")))))))
16164 @end lisp
16165
16166 @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
16167 for more information on mcron job specifications. Below is the
16168 reference of the mcron service.
16169
16170 On a running system, you can use the @code{schedule} action of the service to
16171 visualize the mcron jobs that will be executed next:
16172
16173 @example
16174 # herd schedule mcron
16175 @end example
16176
16177 @noindent
16178 The example above lists the next five tasks that will be executed, but you can
16179 also specify the number of tasks to display:
16180
16181 @example
16182 # herd schedule mcron 10
16183 @end example
16184
16185 @defvr {Scheme Variable} mcron-service-type
16186 This is the type of the @code{mcron} service, whose value is an
16187 @code{mcron-configuration} object.
16188
16189 This service type can be the target of a service extension that provides
16190 additional job specifications (@pxref{Service Composition}). In other
16191 words, it is possible to define services that provide additional mcron
16192 jobs to run.
16193 @end defvr
16194
16195 @deftp {Data Type} mcron-configuration
16196 Data type representing the configuration of mcron.
16197
16198 @table @asis
16199 @item @code{mcron} (default: @var{mcron})
16200 The mcron package to use.
16201
16202 @item @code{jobs}
16203 This is a list of gexps (@pxref{G-Expressions}), where each gexp
16204 corresponds to an mcron job specification (@pxref{Syntax, mcron job
16205 specifications,, mcron, GNU@tie{}mcron}).
16206 @end table
16207 @end deftp
16208
16209
16210 @node Log Rotation
16211 @subsection Log Rotation
16212
16213 @cindex rottlog
16214 @cindex log rotation
16215 @cindex logging
16216 Log files such as those found in @file{/var/log} tend to grow endlessly,
16217 so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
16218 their contents in separate files, possibly compressed. The @code{(gnu
16219 services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
16220 log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
16221
16222 This service is part of @code{%base-services}, and thus enabled by
16223 default, with the default settings, for commonly encountered log files.
16224 The example below shows how to extend it with an additional
16225 @dfn{rotation}, should you need to do that (usually, services that
16226 produce log files already take care of that):
16227
16228 @lisp
16229 (use-modules (guix) (gnu))
16230 (use-service-modules admin)
16231
16232 (define my-log-files
16233 ;; Log files that I want to rotate.
16234 '("/var/log/something.log" "/var/log/another.log"))
16235
16236 (operating-system
16237 ;; @dots{}
16238 (services (cons (simple-service 'rotate-my-stuff
16239 rottlog-service-type
16240 (list (log-rotation
16241 (frequency 'daily)
16242 (files my-log-files))))
16243 %base-services)))
16244 @end lisp
16245
16246 @defvr {Scheme Variable} rottlog-service-type
16247 This is the type of the Rottlog service, whose value is a
16248 @code{rottlog-configuration} object.
16249
16250 Other services can extend this one with new @code{log-rotation} objects
16251 (see below), thereby augmenting the set of files to be rotated.
16252
16253 This service type can define mcron jobs (@pxref{Scheduled Job
16254 Execution}) to run the rottlog service.
16255 @end defvr
16256
16257 @deftp {Data Type} rottlog-configuration
16258 Data type representing the configuration of rottlog.
16259
16260 @table @asis
16261 @item @code{rottlog} (default: @code{rottlog})
16262 The Rottlog package to use.
16263
16264 @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
16265 The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
16266 rottlog, GNU Rot[t]log Manual}).
16267
16268 @item @code{rotations} (default: @code{%default-rotations})
16269 A list of @code{log-rotation} objects as defined below.
16270
16271 @item @code{jobs}
16272 This is a list of gexps where each gexp corresponds to an mcron job
16273 specification (@pxref{Scheduled Job Execution}).
16274 @end table
16275 @end deftp
16276
16277 @deftp {Data Type} log-rotation
16278 Data type representing the rotation of a group of log files.
16279
16280 Taking an example from the Rottlog manual (@pxref{Period Related File
16281 Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
16282 defined like this:
16283
16284 @lisp
16285 (log-rotation
16286 (frequency 'daily)
16287 (files '("/var/log/apache/*"))
16288 (options '("storedir apache-archives"
16289 "rotate 6"
16290 "notifempty"
16291 "nocompress")))
16292 @end lisp
16293
16294 The list of fields is as follows:
16295
16296 @table @asis
16297 @item @code{frequency} (default: @code{'weekly})
16298 The log rotation frequency, a symbol.
16299
16300 @item @code{files}
16301 The list of files or file glob patterns to rotate.
16302
16303 @item @code{options} (default: @code{'()})
16304 The list of rottlog options for this rotation (@pxref{Configuration
16305 parameters,,, rottlog, GNU Rot[t]lg Manual}).
16306
16307 @item @code{post-rotate} (default: @code{#f})
16308 Either @code{#f} or a gexp to execute once the rotation has completed.
16309 @end table
16310 @end deftp
16311
16312 @defvr {Scheme Variable} %default-rotations
16313 Specifies weekly rotation of @code{%rotated-files} and of
16314 @file{/var/log/guix-daemon.log}.
16315 @end defvr
16316
16317 @defvr {Scheme Variable} %rotated-files
16318 The list of syslog-controlled files to be rotated. By default it is:
16319 @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
16320 "/var/log/maillog")}.
16321 @end defvr
16322
16323 @node Networking Services
16324 @subsection Networking Services
16325
16326 The @code{(gnu services networking)} module provides services to configure
16327 the network interface.
16328
16329 @cindex DHCP, networking service
16330 @defvr {Scheme Variable} dhcp-client-service-type
16331 This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
16332 Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
16333 is the DHCP client package to use, @code{isc-dhcp} by default.
16334 @end defvr
16335
16336 @deffn {Scheme Procedure} dhcpd-service-type
16337 This type defines a service that runs a DHCP daemon. To create a
16338 service of this type, you must supply a @code{<dhcpd-configuration>}.
16339 For example:
16340
16341 @lisp
16342 (service dhcpd-service-type
16343 (dhcpd-configuration
16344 (config-file (local-file "my-dhcpd.conf"))
16345 (interfaces '("enp0s25"))))
16346 @end lisp
16347 @end deffn
16348
16349 @deftp {Data Type} dhcpd-configuration
16350 @table @asis
16351 @item @code{package} (default: @code{isc-dhcp})
16352 The package that provides the DHCP daemon. This package is expected to
16353 provide the daemon at @file{sbin/dhcpd} relative to its output
16354 directory. The default package is the
16355 @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
16356 @item @code{config-file} (default: @code{#f})
16357 The configuration file to use. This is required. It will be passed to
16358 @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
16359 object (@pxref{G-Expressions, file-like objects}). See @code{man
16360 dhcpd.conf} for details on the configuration file syntax.
16361 @item @code{version} (default: @code{"4"})
16362 The DHCP version to use. The ISC DHCP server supports the values ``4'',
16363 ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
16364 options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
16365 details.
16366 @item @code{run-directory} (default: @code{"/run/dhcpd"})
16367 The run directory to use. At service activation time, this directory
16368 will be created if it does not exist.
16369 @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
16370 The PID file to use. This corresponds to the @code{-pf} option of
16371 @code{dhcpd}. See @code{man dhcpd} for details.
16372 @item @code{interfaces} (default: @code{'()})
16373 The names of the network interfaces on which dhcpd should listen for
16374 broadcasts. If this list is not empty, then its elements (which must be
16375 strings) will be appended to the @code{dhcpd} invocation when starting
16376 the daemon. It may not be necessary to explicitly specify any
16377 interfaces here; see @code{man dhcpd} for details.
16378 @end table
16379 @end deftp
16380
16381 @defvr {Scheme Variable} static-networking-service-type
16382 This is the type for statically-configured network interfaces.
16383 @c TODO Document <static-networking> data structures.
16384 @end defvr
16385
16386 @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
16387 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
16388 [#:requirement @code{'(udev)}]
16389 Return a service that starts @var{interface} with address @var{ip}. If
16390 @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
16391 it must be a string specifying the default network gateway. @var{requirement}
16392 can be used to declare a dependency on another service before configuring the
16393 interface.
16394
16395 This procedure can be called several times, one for each network
16396 interface of interest. Behind the scenes what it does is extend
16397 @code{static-networking-service-type} with additional network interfaces
16398 to handle.
16399
16400 For example:
16401
16402 @lisp
16403 (static-networking-service "eno1" "192.168.1.82"
16404 #:gateway "192.168.1.2"
16405 #:name-servers '("192.168.1.2"))
16406 @end lisp
16407 @end deffn
16408
16409 @cindex wicd
16410 @cindex wireless
16411 @cindex WiFi
16412 @cindex network management
16413 @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
16414 Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
16415 management daemon that aims to simplify wired and wireless networking.
16416
16417 This service adds the @var{wicd} package to the global profile, providing
16418 several commands to interact with the daemon and configure networking:
16419 @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
16420 and @command{wicd-curses} user interfaces.
16421 @end deffn
16422
16423 @cindex ModemManager
16424
16425 @defvr {Scheme Variable} modem-manager-service-type
16426 This is the service type for the
16427 @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
16428 service. The value for this service type is a
16429 @code{modem-manager-configuration} record.
16430
16431 This service is part of @code{%desktop-services} (@pxref{Desktop
16432 Services}).
16433 @end defvr
16434
16435 @deftp {Data Type} modem-manager-configuration
16436 Data type representing the configuration of ModemManager.
16437
16438 @table @asis
16439 @item @code{modem-manager} (default: @code{modem-manager})
16440 The ModemManager package to use.
16441
16442 @end table
16443 @end deftp
16444
16445 @cindex USB_ModeSwitch
16446 @cindex Modeswitching
16447
16448 @defvr {Scheme Variable} usb-modeswitch-service-type
16449 This is the service type for the
16450 @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
16451 service. The value for this service type is
16452 a @code{usb-modeswitch-configuration} record.
16453
16454 When plugged in, some USB modems (and other USB devices) initially present
16455 themselves as a read-only storage medium and not as a modem. They need to be
16456 @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
16457 installs udev rules to automatically modeswitch these devices when they are
16458 plugged in.
16459
16460 This service is part of @code{%desktop-services} (@pxref{Desktop
16461 Services}).
16462 @end defvr
16463
16464 @deftp {Data Type} usb-modeswitch-configuration
16465 Data type representing the configuration of USB_ModeSwitch.
16466
16467 @table @asis
16468 @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
16469 The USB_ModeSwitch package providing the binaries for modeswitching.
16470
16471 @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
16472 The package providing the device data and udev rules file used by
16473 USB_ModeSwitch.
16474
16475 @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
16476 Which config file to use for the USB_ModeSwitch dispatcher. By default the
16477 config file shipped with USB_ModeSwitch is used which disables logging to
16478 @file{/var/log} among other default settings. If set to @code{#f}, no config
16479 file is used.
16480
16481 @end table
16482 @end deftp
16483
16484 @cindex NetworkManager
16485
16486 @defvr {Scheme Variable} network-manager-service-type
16487 This is the service type for the
16488 @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
16489 service. The value for this service type is a
16490 @code{network-manager-configuration} record.
16491
16492 This service is part of @code{%desktop-services} (@pxref{Desktop
16493 Services}).
16494 @end defvr
16495
16496 @deftp {Data Type} network-manager-configuration
16497 Data type representing the configuration of NetworkManager.
16498
16499 @table @asis
16500 @item @code{network-manager} (default: @code{network-manager})
16501 The NetworkManager package to use.
16502
16503 @item @code{dns} (default: @code{"default"})
16504 Processing mode for DNS, which affects how NetworkManager uses the
16505 @code{resolv.conf} configuration file.
16506
16507 @table @samp
16508 @item default
16509 NetworkManager will update @code{resolv.conf} to reflect the nameservers
16510 provided by currently active connections.
16511
16512 @item dnsmasq
16513 NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
16514 @dfn{conditional forwarding} configuration if you are connected to a VPN, and
16515 then update @code{resolv.conf} to point to the local nameserver.
16516
16517 With this setting, you can share your network connection. For example when
16518 you want to share your network connection to another laptop @i{via} an
16519 Ethernet cable, you can open @command{nm-connection-editor} and configure the
16520 Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
16521 and reestablish the connection (or reboot).
16522
16523 You can also set up a @dfn{host-to-guest connection} to QEMU VMs
16524 (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
16525 e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
16526 browser on your host system, or connect to the VM @i{via} SSH
16527 (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
16528 host-to-guest connection, run this command once:
16529
16530 @example
16531 nmcli connection add type tun \
16532 connection.interface-name tap0 \
16533 tun.mode tap tun.owner $(id -u) \
16534 ipv4.method shared \
16535 ipv4.addresses 172.28.112.1/24
16536 @end example
16537
16538 Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
16539 @option{-nic tap,ifname=tap0,script=no,downscript=no} to
16540 @command{qemu-system-...}.
16541
16542 @item none
16543 NetworkManager will not modify @code{resolv.conf}.
16544 @end table
16545
16546 @item @code{vpn-plugins} (default: @code{'()})
16547 This is the list of available plugins for virtual private networks
16548 (VPNs). An example of this is the @code{network-manager-openvpn}
16549 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
16550
16551 @end table
16552 @end deftp
16553
16554 @cindex Connman
16555 @deffn {Scheme Variable} connman-service-type
16556 This is the service type to run @url{https://01.org/connman,Connman},
16557 a network connection manager.
16558
16559 Its value must be an
16560 @code{connman-configuration} record as in this example:
16561
16562 @lisp
16563 (service connman-service-type
16564 (connman-configuration
16565 (disable-vpn? #t)))
16566 @end lisp
16567
16568 See below for details about @code{connman-configuration}.
16569 @end deffn
16570
16571 @deftp {Data Type} connman-configuration
16572 Data Type representing the configuration of connman.
16573
16574 @table @asis
16575 @item @code{connman} (default: @var{connman})
16576 The connman package to use.
16577
16578 @item @code{disable-vpn?} (default: @code{#f})
16579 When true, disable connman's vpn plugin.
16580 @end table
16581 @end deftp
16582
16583 @cindex WPA Supplicant
16584 @defvr {Scheme Variable} wpa-supplicant-service-type
16585 This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
16586 supplicant}, an authentication daemon required to authenticate against
16587 encrypted WiFi or ethernet networks.
16588 @end defvr
16589
16590 @deftp {Data Type} wpa-supplicant-configuration
16591 Data type representing the configuration of WPA Supplicant.
16592
16593 It takes the following parameters:
16594
16595 @table @asis
16596 @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
16597 The WPA Supplicant package to use.
16598
16599 @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
16600 List of services that should be started before WPA Supplicant starts.
16601
16602 @item @code{dbus?} (default: @code{#t})
16603 Whether to listen for requests on D-Bus.
16604
16605 @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
16606 Where to store the PID file.
16607
16608 @item @code{interface} (default: @code{#f})
16609 If this is set, it must specify the name of a network interface that
16610 WPA supplicant will control.
16611
16612 @item @code{config-file} (default: @code{#f})
16613 Optional configuration file to use.
16614
16615 @item @code{extra-options} (default: @code{'()})
16616 List of additional command-line arguments to pass to the daemon.
16617 @end table
16618 @end deftp
16619
16620 @cindex hostapd service, for Wi-Fi access points
16621 @cindex Wi-Fi access points, hostapd service
16622 @defvr {Scheme Variable} hostapd-service-type
16623 This is the service type to run the @uref{https://w1.fi/hostapd/,
16624 hostapd} daemon to set up WiFi (IEEE 802.11) access points and
16625 authentication servers. Its associated value must be a
16626 @code{hostapd-configuration} as shown below:
16627
16628 @lisp
16629 ;; Use wlan1 to run the access point for "My Network".
16630 (service hostapd-service-type
16631 (hostapd-configuration
16632 (interface "wlan1")
16633 (ssid "My Network")
16634 (channel 12)))
16635 @end lisp
16636 @end defvr
16637
16638 @deftp {Data Type} hostapd-configuration
16639 This data type represents the configuration of the hostapd service, with
16640 the following fields:
16641
16642 @table @asis
16643 @item @code{package} (default: @code{hostapd})
16644 The hostapd package to use.
16645
16646 @item @code{interface} (default: @code{"wlan0"})
16647 The network interface to run the WiFi access point.
16648
16649 @item @code{ssid}
16650 The SSID (@dfn{service set identifier}), a string that identifies this
16651 network.
16652
16653 @item @code{broadcast-ssid?} (default: @code{#t})
16654 Whether to broadcast this SSID.
16655
16656 @item @code{channel} (default: @code{1})
16657 The WiFi channel to use.
16658
16659 @item @code{driver} (default: @code{"nl80211"})
16660 The driver interface type. @code{"nl80211"} is used with all Linux
16661 mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
16662 RADIUS server that does # not control any wireless/wired driver.
16663
16664 @item @code{extra-settings} (default: @code{""})
16665 Extra settings to append as-is to the hostapd configuration file. See
16666 @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
16667 configuration file reference.
16668 @end table
16669 @end deftp
16670
16671 @defvr {Scheme Variable} simulated-wifi-service-type
16672 This is the type of a service to simulate WiFi networking, which can be
16673 useful in virtual machines for testing purposes. The service loads the
16674 Linux kernel
16675 @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
16676 @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
16677 network that can be seen on @code{wlan0}, by default.
16678
16679 The service's value is a @code{hostapd-configuration} record.
16680 @end defvr
16681
16682 @cindex iptables
16683 @defvr {Scheme Variable} iptables-service-type
16684 This is the service type to set up an iptables configuration. iptables is a
16685 packet filtering framework supported by the Linux kernel. This service
16686 supports configuring iptables for both IPv4 and IPv6. A simple example
16687 configuration rejecting all incoming connections except those to the ssh port
16688 22 is shown below.
16689
16690 @lisp
16691 (service iptables-service-type
16692 (iptables-configuration
16693 (ipv4-rules (plain-file "iptables.rules" "*filter
16694 :INPUT ACCEPT
16695 :FORWARD ACCEPT
16696 :OUTPUT ACCEPT
16697 -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
16698 -A INPUT -p tcp --dport 22 -j ACCEPT
16699 -A INPUT -j REJECT --reject-with icmp-port-unreachable
16700 COMMIT
16701 "))
16702 (ipv6-rules (plain-file "ip6tables.rules" "*filter
16703 :INPUT ACCEPT
16704 :FORWARD ACCEPT
16705 :OUTPUT ACCEPT
16706 -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
16707 -A INPUT -p tcp --dport 22 -j ACCEPT
16708 -A INPUT -j REJECT --reject-with icmp6-port-unreachable
16709 COMMIT
16710 "))))
16711 @end lisp
16712 @end defvr
16713
16714 @deftp {Data Type} iptables-configuration
16715 The data type representing the configuration of iptables.
16716
16717 @table @asis
16718 @item @code{iptables} (default: @code{iptables})
16719 The iptables package that provides @code{iptables-restore} and
16720 @code{ip6tables-restore}.
16721 @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
16722 The iptables rules to use. It will be passed to @code{iptables-restore}.
16723 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
16724 objects}).
16725 @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
16726 The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
16727 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
16728 objects}).
16729 @end table
16730 @end deftp
16731
16732 @cindex nftables
16733 @defvr {Scheme Variable} nftables-service-type
16734 This is the service type to set up a nftables configuration. nftables is a
16735 netfilter project that aims to replace the existing iptables, ip6tables,
16736 arptables and ebtables framework. It provides a new packet filtering
16737 framework, a new user-space utility @command{nft}, and a compatibility layer
16738 for iptables. This service comes with a default ruleset
16739 @code{%default-nftables-ruleset} that rejecting all incoming connections
16740 except those to the ssh port 22. To use it, simply write:
16741
16742 @lisp
16743 (service nftables-service-type)
16744 @end lisp
16745 @end defvr
16746
16747 @deftp {Data Type} nftables-configuration
16748 The data type representing the configuration of nftables.
16749
16750 @table @asis
16751 @item @code{package} (default: @code{nftables})
16752 The nftables package that provides @command{nft}.
16753 @item @code{ruleset} (default: @code{%default-nftables-ruleset})
16754 The nftables ruleset to use. This may be any ``file-like'' object
16755 (@pxref{G-Expressions, file-like objects}).
16756 @end table
16757 @end deftp
16758
16759 @cindex NTP (Network Time Protocol), service
16760 @cindex ntpd, service for the Network Time Protocol daemon
16761 @cindex real time clock
16762 @defvr {Scheme Variable} ntp-service-type
16763 This is the type of the service running the @uref{https://www.ntp.org,
16764 Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
16765 system clock synchronized with that of the specified NTP servers.
16766
16767 The value of this service is an @code{ntpd-configuration} object, as described
16768 below.
16769 @end defvr
16770
16771 @deftp {Data Type} ntp-configuration
16772 This is the data type for the NTP service configuration.
16773
16774 @table @asis
16775 @item @code{servers} (default: @code{%ntp-servers})
16776 This is the list of servers (@code{<ntp-server>} records) with which
16777 @command{ntpd} will be synchronized. See the @code{ntp-server} data type
16778 definition below.
16779
16780 @item @code{allow-large-adjustment?} (default: @code{#t})
16781 This determines whether @command{ntpd} is allowed to make an initial
16782 adjustment of more than 1,000 seconds.
16783
16784 @item @code{ntp} (default: @code{ntp})
16785 The NTP package to use.
16786 @end table
16787 @end deftp
16788
16789 @defvr {Scheme Variable} %ntp-servers
16790 List of host names used as the default NTP servers. These are servers of the
16791 @uref{https://www.ntppool.org/en/, NTP Pool Project}.
16792 @end defvr
16793
16794 @deftp {Data Type} ntp-server
16795 The data type representing the configuration of a NTP server.
16796
16797 @table @asis
16798 @item @code{type} (default: @code{'server})
16799 The type of the NTP server, given as a symbol. One of @code{'pool},
16800 @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
16801
16802 @item @code{address}
16803 The address of the server, as a string.
16804
16805 @item @code{options}
16806 NTPD options to use with that specific server, given as a list of option names
16807 and/or of option names and values tuples. The following example define a server
16808 to use with the options @option{iburst} and @option{prefer}, as well as
16809 @option{version} 3 and a @option{maxpoll} time of 16 seconds.
16810
16811 @example
16812 (ntp-server
16813 (type 'server)
16814 (address "some.ntp.server.org")
16815 (options `(iburst (version 3) (maxpoll 16) prefer))))
16816 @end example
16817 @end table
16818 @end deftp
16819
16820 @cindex OpenNTPD
16821 @deffn {Scheme Procedure} openntpd-service-type
16822 Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
16823 by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
16824 clock synchronized with that of the given servers.
16825
16826 @lisp
16827 (service
16828 openntpd-service-type
16829 (openntpd-configuration
16830 (listen-on '("127.0.0.1" "::1"))
16831 (sensor '("udcf0 correction 70000"))
16832 (constraint-from '("www.gnu.org"))
16833 (constraints-from '("https://www.google.com/"))))
16834
16835 @end lisp
16836 @end deffn
16837
16838 @defvr {Scheme Variable} %openntpd-servers
16839 This variable is a list of the server addresses defined in
16840 @code{%ntp-servers}.
16841 @end defvr
16842
16843 @deftp {Data Type} openntpd-configuration
16844 @table @asis
16845 @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
16846 The openntpd executable to use.
16847 @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
16848 A list of local IP addresses or hostnames the ntpd daemon should listen on.
16849 @item @code{query-from} (default: @code{'()})
16850 A list of local IP address the ntpd daemon should use for outgoing queries.
16851 @item @code{sensor} (default: @code{'()})
16852 Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
16853 will listen to each sensor that actually exists and ignore non-existent ones.
16854 See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
16855 information.
16856 @item @code{server} (default: @code{'()})
16857 Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
16858 @item @code{servers} (default: @code{%openntp-servers})
16859 Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
16860 @item @code{constraint-from} (default: @code{'()})
16861 @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
16862 This time information is not used for precision but acts as an authenticated
16863 constraint, thereby reducing the impact of unauthenticated NTP
16864 man-in-the-middle attacks.
16865 Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
16866 a constraint.
16867 @item @code{constraints-from} (default: @code{'()})
16868 As with constraint from, specify a list of URLs, IP addresses or hostnames of
16869 HTTPS servers to provide a constraint. Should the hostname resolve to multiple
16870 IP addresses, @code{ntpd} will calculate a median constraint from all of them.
16871 @end table
16872 @end deftp
16873
16874 @cindex inetd
16875 @deffn {Scheme variable} inetd-service-type
16876 This service runs the @command{inetd} (@pxref{inetd invocation,,,
16877 inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
16878 connections on internet sockets, and lazily starts the specified server
16879 program when a connection is made on one of these sockets.
16880
16881 The value of this service is an @code{inetd-configuration} object. The
16882 following example configures the @command{inetd} daemon to provide the
16883 built-in @command{echo} service, as well as an smtp service which
16884 forwards smtp traffic over ssh to a server @code{smtp-server} behind a
16885 gateway @code{hostname}:
16886
16887 @lisp
16888 (service
16889 inetd-service-type
16890 (inetd-configuration
16891 (entries (list
16892 (inetd-entry
16893 (name "echo")
16894 (socket-type 'stream)
16895 (protocol "tcp")
16896 (wait? #f)
16897 (user "root"))
16898 (inetd-entry
16899 (node "127.0.0.1")
16900 (name "smtp")
16901 (socket-type 'stream)
16902 (protocol "tcp")
16903 (wait? #f)
16904 (user "root")
16905 (program (file-append openssh "/bin/ssh"))
16906 (arguments
16907 '("ssh" "-qT" "-i" "/path/to/ssh_key"
16908 "-W" "smtp-server:25" "user@@hostname")))))))
16909 @end lisp
16910
16911 See below for more details about @code{inetd-configuration}.
16912 @end deffn
16913
16914 @deftp {Data Type} inetd-configuration
16915 Data type representing the configuration of @command{inetd}.
16916
16917 @table @asis
16918 @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
16919 The @command{inetd} executable to use.
16920
16921 @item @code{entries} (default: @code{'()})
16922 A list of @command{inetd} service entries. Each entry should be created
16923 by the @code{inetd-entry} constructor.
16924 @end table
16925 @end deftp
16926
16927 @deftp {Data Type} inetd-entry
16928 Data type representing an entry in the @command{inetd} configuration.
16929 Each entry corresponds to a socket where @command{inetd} will listen for
16930 requests.
16931
16932 @table @asis
16933 @item @code{node} (default: @code{#f})
16934 Optional string, a comma-separated list of local addresses
16935 @command{inetd} should use when listening for this service.
16936 @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
16937 description of all options.
16938 @item @code{name}
16939 A string, the name must correspond to an entry in @code{/etc/services}.
16940 @item @code{socket-type}
16941 One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
16942 @code{'seqpacket}.
16943 @item @code{protocol}
16944 A string, must correspond to an entry in @code{/etc/protocols}.
16945 @item @code{wait?} (default: @code{#t})
16946 Whether @command{inetd} should wait for the server to exit before
16947 listening to new service requests.
16948 @item @code{user}
16949 A string containing the user (and, optionally, group) name of the user
16950 as whom the server should run. The group name can be specified in a
16951 suffix, separated by a colon or period, i.e.@: @code{"user"},
16952 @code{"user:group"} or @code{"user.group"}.
16953 @item @code{program} (default: @code{"internal"})
16954 The server program which will serve the requests, or @code{"internal"}
16955 if @command{inetd} should use a built-in service.
16956 @item @code{arguments} (default: @code{'()})
16957 A list strings or file-like objects, which are the server program's
16958 arguments, starting with the zeroth argument, i.e.@: the name of the
16959 program itself. For @command{inetd}'s internal services, this entry
16960 must be @code{'()} or @code{'("internal")}.
16961 @end table
16962
16963 @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
16964 detailed discussion of each configuration field.
16965 @end deftp
16966
16967 @cindex opendht, distributed hash table network service
16968 @cindex dhtproxy, for use with jami
16969 @defvr {Scheme Variable} opendht-service-type
16970 This is the type of the service running a @uref{https://opendht.net,
16971 OpenDHT} node, @command{dhtnode}. The daemon can be used to host your
16972 own proxy service to the distributed hash table (DHT), for example to
16973 connect to with Jami, among other applications.
16974
16975 @quotation Important
16976 When using the OpenDHT proxy server, the IP addresses it ``sees'' from
16977 the clients should be addresses reachable from other peers. In practice
16978 this means that a publicly reachable address is best suited for a proxy
16979 server, outside of your private network. For example, hosting the proxy
16980 server on a IPv4 private local network and exposing it via port
16981 forwarding could work for external peers, but peers local to the proxy
16982 would have their private addresses shared with the external peers,
16983 leading to connectivity problems.
16984 @end quotation
16985
16986 The value of this service is a @code{opendht-configuration} object, as
16987 described below.
16988 @end defvr
16989
16990 @deftp {Data Type} opendht-configuration
16991 This is the data type for the OpenDHT service configuration.
16992
16993 @c The fields documentation has been auto-generated using the
16994 @c configuration->documentation procedure from
16995 @c (gnu services configuration).
16996 Available @code{opendht-configuration} fields are:
16997
16998 @deftypevr {@code{opendht-configuration} parameter} package opendht
16999 The @code{opendht} package to use.
17000
17001 @end deftypevr
17002
17003 @deftypevr {@code{opendht-configuration} parameter} boolean peer-discovery?
17004 Whether to enable the multicast local peer discovery mechanism.
17005
17006 Defaults to @samp{#f}.
17007
17008 @end deftypevr
17009
17010 @deftypevr {@code{opendht-configuration} parameter} boolean enable-logging?
17011 Whether to enable logging messages to syslog. It is disabled by default
17012 as it is rather verbose.
17013
17014 Defaults to @samp{#f}.
17015
17016 @end deftypevr
17017
17018 @deftypevr {@code{opendht-configuration} parameter} boolean debug?
17019 Whether to enable debug-level logging messages. This has no effect if
17020 logging is disabled.
17021
17022 Defaults to @samp{#f}.
17023
17024 @end deftypevr
17025
17026 @deftypevr {@code{opendht-configuration} parameter} maybe-string bootstrap-host
17027 The node host name that is used to make the first connection to the
17028 network. A specific port value can be provided by appending the
17029 @code{:PORT} suffix. By default, it uses the Jami bootstrap nodes, but
17030 any host can be specified here. It's also possible to disable
17031 bootsrapping by setting this to the @code{'disabled} symbol.
17032
17033 Defaults to @samp{"bootstrap.jami.net:4222"}.
17034
17035 @end deftypevr
17036
17037 @deftypevr {@code{opendht-configuration} parameter} maybe-number port
17038 The UDP port to bind to. When set to @code{'disabled}, an available
17039 port is automatically selected.
17040
17041 Defaults to @samp{4222}.
17042
17043 @end deftypevr
17044
17045 @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port
17046 Spawn a proxy server listening on the specified port.
17047
17048 Defaults to @samp{disabled}.
17049
17050 @end deftypevr
17051
17052 @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port-tls
17053 Spawn a proxy server listening to TLS connections on the specified port.
17054
17055 Defaults to @samp{disabled}.
17056
17057 @end deftypevr
17058 @end deftp
17059
17060 @cindex Tor
17061 @defvr {Scheme Variable} tor-service-type
17062 This is the type for a service that runs the @uref{https://torproject.org,
17063 Tor} anonymous networking daemon. The service is configured using a
17064 @code{<tor-configuration>} record. By default, the Tor daemon runs as the
17065 @code{tor} unprivileged user, which is a member of the @code{tor} group.
17066
17067 @end defvr
17068
17069 @deftp {Data Type} tor-configuration
17070 @table @asis
17071 @item @code{tor} (default: @code{tor})
17072 The package that provides the Tor daemon. This package is expected to provide
17073 the daemon at @file{bin/tor} relative to its output directory. The default
17074 package is the @uref{https://www.torproject.org, Tor Project's}
17075 implementation.
17076
17077 @item @code{config-file} (default: @code{(plain-file "empty" "")})
17078 The configuration file to use. It will be appended to a default configuration
17079 file, and the final configuration file will be passed to @code{tor} via its
17080 @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
17081 file-like objects}). See @code{man tor} for details on the configuration file
17082 syntax.
17083
17084 @item @code{hidden-services} (default: @code{'()})
17085 The list of @code{<hidden-service>} records to use. For any hidden service
17086 you include in this list, appropriate configuration to enable the hidden
17087 service will be automatically added to the default configuration file. You
17088 may conveniently create @code{<hidden-service>} records using the
17089 @code{tor-hidden-service} procedure described below.
17090
17091 @item @code{socks-socket-type} (default: @code{'tcp})
17092 The default socket type that Tor should use for its SOCKS socket. This must
17093 be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
17094 Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
17095 If it is @code{'unix}, then Tor will listen on the UNIX domain socket
17096 @file{/var/run/tor/socks-sock}, which will be made writable by members of the
17097 @code{tor} group.
17098
17099 If you want to customize the SOCKS socket in more detail, leave
17100 @code{socks-socket-type} at its default value of @code{'tcp} and use
17101 @code{config-file} to override the default by providing your own
17102 @code{SocksPort} option.
17103
17104 @item @code{control-socket?} (default: @code{#f})
17105 Whether or not to provide a ``control socket'' by which Tor can be
17106 controlled to, for instance, dynamically instantiate tor onion services.
17107 If @code{#t}, Tor will listen for control commands on the UNIX domain socket
17108 @file{/var/run/tor/control-sock}, which will be made writable by members of the
17109 @code{tor} group.
17110
17111 @end table
17112 @end deftp
17113
17114 @cindex hidden service
17115 @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
17116 Define a new Tor @dfn{hidden service} called @var{name} and implementing
17117 @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
17118
17119 @example
17120 '((22 "127.0.0.1:22")
17121 (80 "127.0.0.1:8080"))
17122 @end example
17123
17124 In this example, port 22 of the hidden service is mapped to local port 22, and
17125 port 80 is mapped to local port 8080.
17126
17127 This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
17128 the @file{hostname} file contains the @code{.onion} host name for the hidden
17129 service.
17130
17131 See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
17132 project's documentation} for more information.
17133 @end deffn
17134
17135 The @code{(gnu services rsync)} module provides the following services:
17136
17137 You might want an rsync daemon if you have files that you want available
17138 so anyone (or just yourself) can download existing files or upload new
17139 files.
17140
17141 @deffn {Scheme Variable} rsync-service-type
17142 This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
17143 The value for this service type is a
17144 @command{rsync-configuration} record as in this example:
17145
17146 @lisp
17147 (service rsync-service-type)
17148 @end lisp
17149
17150 See below for details about @code{rsync-configuration}.
17151 @end deffn
17152
17153 @deftp {Data Type} rsync-configuration
17154 Data type representing the configuration for @code{rsync-service}.
17155
17156 @table @asis
17157 @item @code{package} (default: @var{rsync})
17158 @code{rsync} package to use.
17159
17160 @item @code{port-number} (default: @code{873})
17161 TCP port on which @command{rsync} listens for incoming connections. If port
17162 is less than @code{1024} @command{rsync} needs to be started as the
17163 @code{root} user and group.
17164
17165 @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
17166 Name of the file where @command{rsync} writes its PID.
17167
17168 @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
17169 Name of the file where @command{rsync} writes its lock file.
17170
17171 @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
17172 Name of the file where @command{rsync} writes its log file.
17173
17174 @item @code{use-chroot?} (default: @var{#t})
17175 Whether to use chroot for @command{rsync} shared directory.
17176
17177 @item @code{share-path} (default: @file{/srv/rsync})
17178 Location of the @command{rsync} shared directory.
17179
17180 @item @code{share-comment} (default: @code{"Rsync share"})
17181 Comment of the @command{rsync} shared directory.
17182
17183 @item @code{read-only?} (default: @var{#f})
17184 Read-write permissions to shared directory.
17185
17186 @item @code{timeout} (default: @code{300})
17187 I/O timeout in seconds.
17188
17189 @item @code{user} (default: @var{"root"})
17190 Owner of the @code{rsync} process.
17191
17192 @item @code{group} (default: @var{"root"})
17193 Group of the @code{rsync} process.
17194
17195 @item @code{uid} (default: @var{"rsyncd"})
17196 User name or user ID that file transfers to and from that module should take
17197 place as when the daemon was run as @code{root}.
17198
17199 @item @code{gid} (default: @var{"rsyncd"})
17200 Group name or group ID that will be used when accessing the module.
17201
17202 @end table
17203 @end deftp
17204
17205 The @code{(gnu services syncthing)} module provides the following services:
17206 @cindex syncthing
17207
17208 You might want a syncthing daemon if you have files between two or more
17209 computers and want to sync them in real time, safely protected from
17210 prying eyes.
17211
17212 @deffn {Scheme Variable} syncthing-service-type
17213 This is the service type for the @uref{https://syncthing.net/,
17214 syncthing} daemon, The value for this service type is a
17215 @command{syncthing-configuration} record as in this example:
17216
17217 @lisp
17218 (service syncthing-service-type
17219 (syncthing-configuration (user "alice")))
17220 @end lisp
17221
17222 See below for details about @code{syncthing-configuration}.
17223
17224 @deftp {Data Type} syncthing-configuration
17225 Data type representing the configuration for @code{syncthing-service-type}.
17226
17227 @table @asis
17228 @item @code{syncthing} (default: @var{syncthing})
17229 @code{syncthing} package to use.
17230
17231 @item @code{arguments} (default: @var{'()})
17232 List of command-line arguments passing to @code{syncthing} binary.
17233
17234 @item @code{logflags} (default: @var{0})
17235 Sum of logging flags, see
17236 @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
17237
17238 @item @code{user} (default: @var{#f})
17239 The user as which the Syncthing service is to be run.
17240 This assumes that the specified user exists.
17241
17242 @item @code{group} (default: @var{"users"})
17243 The group as which the Syncthing service is to be run.
17244 This assumes that the specified group exists.
17245
17246 @item @code{home} (default: @var{#f})
17247 Common configuration and data directory. The default configuration
17248 directory is @file{$HOME} of the specified Syncthing @code{user}.
17249
17250 @end table
17251 @end deftp
17252 @end deffn
17253
17254 Furthermore, @code{(gnu services ssh)} provides the following services.
17255 @cindex SSH
17256 @cindex SSH server
17257
17258 @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
17259 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
17260 [#:allow-empty-passwords? #f] [#:root-login? #f] @
17261 [#:syslog-output? #t] [#:x11-forwarding? #t] @
17262 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
17263 [#:public-key-authentication? #t] [#:initialize? #t]
17264 Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
17265 @var{host-key} must designate a file containing the host key, and readable
17266 only by root.
17267
17268 When @var{daemonic?} is true, @command{lshd} will detach from the
17269 controlling terminal and log its output to syslogd, unless one sets
17270 @var{syslog-output?} to false. Obviously, it also makes lsh-service
17271 depend on existence of syslogd service. When @var{pid-file?} is true,
17272 @command{lshd} writes its PID to the file called @var{pid-file}.
17273
17274 When @var{initialize?} is true, automatically create the seed and host key
17275 upon service activation if they do not exist yet. This may take long and
17276 require interaction.
17277
17278 When @var{initialize?} is false, it is up to the user to initialize the
17279 randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
17280 a key pair with the private key stored in file @var{host-key} (@pxref{lshd
17281 basics,,, lsh, LSH Manual}).
17282
17283 When @var{interfaces} is empty, lshd listens for connections on all the
17284 network interfaces; otherwise, @var{interfaces} must be a list of host names
17285 or addresses.
17286
17287 @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
17288 passwords, and @var{root-login?} specifies whether to accept log-ins as
17289 root.
17290
17291 The other options should be self-descriptive.
17292 @end deffn
17293
17294 @cindex SSH
17295 @cindex SSH server
17296 @deffn {Scheme Variable} openssh-service-type
17297 This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
17298 shell daemon, @command{sshd}. Its value must be an
17299 @code{openssh-configuration} record as in this example:
17300
17301 @lisp
17302 (service openssh-service-type
17303 (openssh-configuration
17304 (x11-forwarding? #t)
17305 (permit-root-login 'prohibit-password)
17306 (authorized-keys
17307 `(("alice" ,(local-file "alice.pub"))
17308 ("bob" ,(local-file "bob.pub"))))))
17309 @end lisp
17310
17311 See below for details about @code{openssh-configuration}.
17312
17313 This service can be extended with extra authorized keys, as in this
17314 example:
17315
17316 @lisp
17317 (service-extension openssh-service-type
17318 (const `(("charlie"
17319 ,(local-file "charlie.pub")))))
17320 @end lisp
17321 @end deffn
17322
17323 @deftp {Data Type} openssh-configuration
17324 This is the configuration record for OpenSSH's @command{sshd}.
17325
17326 @table @asis
17327 @item @code{openssh} (default @var{openssh})
17328 The Openssh package to use.
17329
17330 @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
17331 Name of the file where @command{sshd} writes its PID.
17332
17333 @item @code{port-number} (default: @code{22})
17334 TCP port on which @command{sshd} listens for incoming connections.
17335
17336 @item @code{permit-root-login} (default: @code{#f})
17337 This field determines whether and when to allow logins as root. If
17338 @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
17339 If it's the symbol @code{'prohibit-password}, then root logins are
17340 permitted but not with password-based authentication.
17341
17342 @item @code{allow-empty-passwords?} (default: @code{#f})
17343 When true, users with empty passwords may log in. When false, they may
17344 not.
17345
17346 @item @code{password-authentication?} (default: @code{#t})
17347 When true, users may log in with their password. When false, they have
17348 other authentication methods.
17349
17350 @item @code{public-key-authentication?} (default: @code{#t})
17351 When true, users may log in using public key authentication. When
17352 false, users have to use other authentication method.
17353
17354 Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
17355 This is used only by protocol version 2.
17356
17357 @item @code{x11-forwarding?} (default: @code{#f})
17358 When true, forwarding of X11 graphical client connections is
17359 enabled---in other words, @command{ssh} options @option{-X} and
17360 @option{-Y} will work.
17361
17362 @item @code{allow-agent-forwarding?} (default: @code{#t})
17363 Whether to allow agent forwarding.
17364
17365 @item @code{allow-tcp-forwarding?} (default: @code{#t})
17366 Whether to allow TCP forwarding.
17367
17368 @item @code{gateway-ports?} (default: @code{#f})
17369 Whether to allow gateway ports.
17370
17371 @item @code{challenge-response-authentication?} (default: @code{#f})
17372 Specifies whether challenge response authentication is allowed (e.g.@: via
17373 PAM).
17374
17375 @item @code{use-pam?} (default: @code{#t})
17376 Enables the Pluggable Authentication Module interface. If set to
17377 @code{#t}, this will enable PAM authentication using
17378 @code{challenge-response-authentication?} and
17379 @code{password-authentication?}, in addition to PAM account and session
17380 module processing for all authentication types.
17381
17382 Because PAM challenge response authentication usually serves an
17383 equivalent role to password authentication, you should disable either
17384 @code{challenge-response-authentication?} or
17385 @code{password-authentication?}.
17386
17387 @item @code{print-last-log?} (default: @code{#t})
17388 Specifies whether @command{sshd} should print the date and time of the
17389 last user login when a user logs in interactively.
17390
17391 @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
17392 Configures external subsystems (e.g.@: file transfer daemon).
17393
17394 This is a list of two-element lists, each of which containing the
17395 subsystem name and a command (with optional arguments) to execute upon
17396 subsystem request.
17397
17398 The command @command{internal-sftp} implements an in-process SFTP
17399 server. Alternatively, one can specify the @command{sftp-server} command:
17400 @lisp
17401 (service openssh-service-type
17402 (openssh-configuration
17403 (subsystems
17404 `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
17405 @end lisp
17406
17407 @item @code{accepted-environment} (default: @code{'()})
17408 List of strings describing which environment variables may be exported.
17409
17410 Each string gets on its own line. See the @code{AcceptEnv} option in
17411 @code{man sshd_config}.
17412
17413 This example allows ssh-clients to export the @env{COLORTERM} variable.
17414 It is set by terminal emulators, which support colors. You can use it in
17415 your shell's resource file to enable colors for the prompt and commands
17416 if this variable is set.
17417
17418 @lisp
17419 (service openssh-service-type
17420 (openssh-configuration
17421 (accepted-environment '("COLORTERM"))))
17422 @end lisp
17423
17424 @item @code{authorized-keys} (default: @code{'()})
17425 @cindex authorized keys, SSH
17426 @cindex SSH authorized keys
17427 This is the list of authorized keys. Each element of the list is a user
17428 name followed by one or more file-like objects that represent SSH public
17429 keys. For example:
17430
17431 @lisp
17432 (openssh-configuration
17433 (authorized-keys
17434 `(("rekado" ,(local-file "rekado.pub"))
17435 ("chris" ,(local-file "chris.pub"))
17436 ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
17437 @end lisp
17438
17439 @noindent
17440 registers the specified public keys for user accounts @code{rekado},
17441 @code{chris}, and @code{root}.
17442
17443 Additional authorized keys can be specified @i{via}
17444 @code{service-extension}.
17445
17446 Note that this does @emph{not} interfere with the use of
17447 @file{~/.ssh/authorized_keys}.
17448
17449 @item @code{log-level} (default: @code{'info})
17450 This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
17451 @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
17452 page for @file{sshd_config} for the full list of level names.
17453
17454 @item @code{extra-content} (default: @code{""})
17455 This field can be used to append arbitrary text to the configuration file. It
17456 is especially useful for elaborate configurations that cannot be expressed
17457 otherwise. This configuration, for example, would generally disable root
17458 logins, but permit them from one specific IP address:
17459
17460 @lisp
17461 (openssh-configuration
17462 (extra-content "\
17463 Match Address 192.168.0.1
17464 PermitRootLogin yes"))
17465 @end lisp
17466
17467 @end table
17468 @end deftp
17469
17470 @deffn {Scheme Procedure} dropbear-service [@var{config}]
17471 Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
17472 daemon} with the given @var{config}, a @code{<dropbear-configuration>}
17473 object.
17474
17475 For example, to specify a Dropbear service listening on port 1234, add
17476 this call to the operating system's @code{services} field:
17477
17478 @lisp
17479 (dropbear-service (dropbear-configuration
17480 (port-number 1234)))
17481 @end lisp
17482 @end deffn
17483
17484 @deftp {Data Type} dropbear-configuration
17485 This data type represents the configuration of a Dropbear SSH daemon.
17486
17487 @table @asis
17488 @item @code{dropbear} (default: @var{dropbear})
17489 The Dropbear package to use.
17490
17491 @item @code{port-number} (default: 22)
17492 The TCP port where the daemon waits for incoming connections.
17493
17494 @item @code{syslog-output?} (default: @code{#t})
17495 Whether to enable syslog output.
17496
17497 @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
17498 File name of the daemon's PID file.
17499
17500 @item @code{root-login?} (default: @code{#f})
17501 Whether to allow @code{root} logins.
17502
17503 @item @code{allow-empty-passwords?} (default: @code{#f})
17504 Whether to allow empty passwords.
17505
17506 @item @code{password-authentication?} (default: @code{#t})
17507 Whether to enable password-based authentication.
17508 @end table
17509 @end deftp
17510
17511 @cindex AutoSSH
17512 @deffn {Scheme Variable} autossh-service-type
17513 This is the type for the @uref{https://www.harding.motd.ca/autossh,
17514 AutoSSH} program that runs a copy of @command{ssh} and monitors it,
17515 restarting it as necessary should it die or stop passing traffic.
17516 AutoSSH can be run manually from the command-line by passing arguments
17517 to the binary @command{autossh} from the package @code{autossh}, but it
17518 can also be run as a Guix service. This latter use case is documented
17519 here.
17520
17521 AutoSSH can be used to forward local traffic to a remote machine using
17522 an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
17523 is run as.
17524
17525 For example, to specify a service running autossh as the user
17526 @code{pino} and forwarding all local connections to port @code{8081} to
17527 @code{remote:8081} using an SSH tunnel, add this call to the operating
17528 system's @code{services} field:
17529
17530 @lisp
17531 (service autossh-service-type
17532 (autossh-configuration
17533 (user "pino")
17534 (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
17535 @end lisp
17536 @end deffn
17537
17538 @deftp {Data Type} autossh-configuration
17539 This data type represents the configuration of an AutoSSH service.
17540
17541 @table @asis
17542
17543 @item @code{user} (default @code{"autossh"})
17544 The user as which the AutoSSH service is to be run.
17545 This assumes that the specified user exists.
17546
17547 @item @code{poll} (default @code{600})
17548 Specifies the connection poll time in seconds.
17549
17550 @item @code{first-poll} (default @code{#f})
17551 Specifies how many seconds AutoSSH waits before the first connection
17552 test. After this first test, polling is resumed at the pace defined in
17553 @code{poll}. When set to @code{#f}, the first poll is not treated
17554 specially and will also use the connection poll specified in
17555 @code{poll}.
17556
17557 @item @code{gate-time} (default @code{30})
17558 Specifies how many seconds an SSH connection must be active before it is
17559 considered successful.
17560
17561 @item @code{log-level} (default @code{1})
17562 The log level, corresponding to the levels used by syslog---so @code{0}
17563 is the most silent while @code{7} is the chattiest.
17564
17565 @item @code{max-start} (default @code{#f})
17566 The maximum number of times SSH may be (re)started before AutoSSH exits.
17567 When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
17568
17569 @item @code{message} (default @code{""})
17570 The message to append to the echo message sent when testing connections.
17571
17572 @item @code{port} (default @code{"0"})
17573 The ports used for monitoring the connection. When set to @code{"0"},
17574 monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
17575 a positive integer, ports @var{n} and @var{n}+1 are used for
17576 monitoring the connection, such that port @var{n} is the base
17577 monitoring port and @code{n+1} is the echo port. When set to
17578 @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
17579 integers, the ports @var{n} and @var{m} are used for monitoring the
17580 connection, such that port @var{n} is the base monitoring port and
17581 @var{m} is the echo port.
17582
17583 @item @code{ssh-options} (default @code{'()})
17584 The list of command-line arguments to pass to @command{ssh} when it is
17585 run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
17586 may cause undefined behaviour.
17587
17588 @end table
17589 @end deftp
17590
17591 @cindex WebSSH
17592 @deffn {Scheme Variable} webssh-service-type
17593 This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
17594 program that runs a web SSH client. WebSSH can be run manually from the
17595 command-line by passing arguments to the binary @command{wssh} from the
17596 package @code{webssh}, but it can also be run as a Guix service. This
17597 latter use case is documented here.
17598
17599 For example, to specify a service running WebSSH on loopback interface
17600 on port @code{8888} with reject policy with a list of allowed to
17601 connection hosts, and NGINX as a reverse-proxy to this service listening
17602 for HTTPS connection, add this call to the operating system's
17603 @code{services} field:
17604
17605 @lisp
17606 (service webssh-service-type
17607 (webssh-configuration (address "127.0.0.1")
17608 (port 8888)
17609 (policy 'reject)
17610 (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
17611 "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
17612
17613 (service nginx-service-type
17614 (nginx-configuration
17615 (server-blocks
17616 (list
17617 (nginx-server-configuration
17618 (inherit %webssh-configuration-nginx)
17619 (server-name '("webssh.example.com"))
17620 (listen '("443 ssl"))
17621 (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
17622 (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
17623 (locations
17624 (cons (nginx-location-configuration
17625 (uri "/.well-known")
17626 (body '("root /var/www;")))
17627 (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
17628 @end lisp
17629 @end deffn
17630
17631 @deftp {Data Type} webssh-configuration
17632 Data type representing the configuration for @code{webssh-service}.
17633
17634 @table @asis
17635 @item @code{package} (default: @var{webssh})
17636 @code{webssh} package to use.
17637
17638 @item @code{user-name} (default: @var{"webssh"})
17639 User name or user ID that file transfers to and from that module should take
17640 place.
17641
17642 @item @code{group-name} (default: @var{"webssh"})
17643 Group name or group ID that will be used when accessing the module.
17644
17645 @item @code{address} (default: @var{#f})
17646 IP address on which @command{webssh} listens for incoming connections.
17647
17648 @item @code{port} (default: @var{8888})
17649 TCP port on which @command{webssh} listens for incoming connections.
17650
17651 @item @code{policy} (default: @var{#f})
17652 Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
17653
17654 @item @code{known-hosts} (default: @var{'()})
17655 List of hosts which allowed for SSH connection from @command{webssh}.
17656
17657 @item @code{log-file} (default: @file{"/var/log/webssh.log"})
17658 Name of the file where @command{webssh} writes its log file.
17659
17660 @item @code{log-level} (default: @var{#f})
17661 Logging level.
17662
17663 @end table
17664 @end deftp
17665
17666 @defvr {Scheme Variable} %facebook-host-aliases
17667 This variable contains a string for use in @file{/etc/hosts}
17668 (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
17669 line contains a entry that maps a known server name of the Facebook
17670 on-line service---e.g., @code{www.facebook.com}---to the local
17671 host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
17672
17673 This variable is typically used in the @code{hosts-file} field of an
17674 @code{operating-system} declaration (@pxref{operating-system Reference,
17675 @file{/etc/hosts}}):
17676
17677 @lisp
17678 (use-modules (gnu) (guix))
17679
17680 (operating-system
17681 (host-name "mymachine")
17682 ;; ...
17683 (hosts-file
17684 ;; Create a /etc/hosts file with aliases for "localhost"
17685 ;; and "mymachine", as well as for Facebook servers.
17686 (plain-file "hosts"
17687 (string-append (local-host-aliases host-name)
17688 %facebook-host-aliases))))
17689 @end lisp
17690
17691 This mechanism can prevent programs running locally, such as Web
17692 browsers, from accessing Facebook.
17693 @end defvr
17694
17695 The @code{(gnu services avahi)} provides the following definition.
17696
17697 @defvr {Scheme Variable} avahi-service-type
17698 This is the service that runs @command{avahi-daemon}, a system-wide
17699 mDNS/DNS-SD responder that allows for service discovery and
17700 ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
17701 Its value must be an @code{avahi-configuration} record---see below.
17702
17703 This service extends the name service cache daemon (nscd) so that it can
17704 resolve @code{.local} host names using
17705 @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
17706 Service Switch}, for information on host name resolution.
17707
17708 Additionally, add the @var{avahi} package to the system profile so that
17709 commands such as @command{avahi-browse} are directly usable.
17710 @end defvr
17711
17712 @deftp {Data Type} avahi-configuration
17713 Data type representation the configuration for Avahi.
17714
17715 @table @asis
17716
17717 @item @code{host-name} (default: @code{#f})
17718 If different from @code{#f}, use that as the host name to
17719 publish for this machine; otherwise, use the machine's actual host name.
17720
17721 @item @code{publish?} (default: @code{#t})
17722 When true, allow host names and services to be published (broadcast) over the
17723 network.
17724
17725 @item @code{publish-workstation?} (default: @code{#t})
17726 When true, @command{avahi-daemon} publishes the machine's host name and IP
17727 address via mDNS on the local network. To view the host names published on
17728 your local network, you can run:
17729
17730 @example
17731 avahi-browse _workstation._tcp
17732 @end example
17733
17734 @item @code{wide-area?} (default: @code{#f})
17735 When true, DNS-SD over unicast DNS is enabled.
17736
17737 @item @code{ipv4?} (default: @code{#t})
17738 @itemx @code{ipv6?} (default: @code{#t})
17739 These fields determine whether to use IPv4/IPv6 sockets.
17740
17741 @item @code{domains-to-browse} (default: @code{'()})
17742 This is a list of domains to browse.
17743 @end table
17744 @end deftp
17745
17746 @deffn {Scheme Variable} openvswitch-service-type
17747 This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
17748 service, whose value should be an @code{openvswitch-configuration}
17749 object.
17750 @end deffn
17751
17752 @deftp {Data Type} openvswitch-configuration
17753 Data type representing the configuration of Open vSwitch, a multilayer
17754 virtual switch which is designed to enable massive network automation
17755 through programmatic extension.
17756
17757 @table @asis
17758 @item @code{package} (default: @var{openvswitch})
17759 Package object of the Open vSwitch.
17760
17761 @end table
17762 @end deftp
17763
17764 @defvr {Scheme Variable} pagekite-service-type
17765 This is the service type for the @uref{https://pagekite.net, PageKite} service,
17766 a tunneling solution for making localhost servers publicly visible, even from
17767 behind restrictive firewalls or NAT without forwarded ports. The value for
17768 this service type is a @code{pagekite-configuration} record.
17769
17770 Here's an example exposing the local HTTP and SSH daemons:
17771
17772 @lisp
17773 (service pagekite-service-type
17774 (pagekite-configuration
17775 (kites '("http:@@kitename:localhost:80:@@kitesecret"
17776 "raw/22:@@kitename:localhost:22:@@kitesecret"))
17777 (extra-file "/etc/pagekite.rc")))
17778 @end lisp
17779 @end defvr
17780
17781 @deftp {Data Type} pagekite-configuration
17782 Data type representing the configuration of PageKite.
17783
17784 @table @asis
17785 @item @code{package} (default: @var{pagekite})
17786 Package object of PageKite.
17787
17788 @item @code{kitename} (default: @code{#f})
17789 PageKite name for authenticating to the frontend server.
17790
17791 @item @code{kitesecret} (default: @code{#f})
17792 Shared secret for authenticating to the frontend server. You should probably
17793 put this inside @code{extra-file} instead.
17794
17795 @item @code{frontend} (default: @code{#f})
17796 Connect to the named PageKite frontend server instead of the
17797 @uref{https://pagekite.net,,pagekite.net} service.
17798
17799 @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
17800 List of service kites to use. Exposes HTTP on port 80 by default. The format
17801 is @code{proto:kitename:host:port:secret}.
17802
17803 @item @code{extra-file} (default: @code{#f})
17804 Extra configuration file to read, which you are expected to create manually.
17805 Use this to add additional options and manage shared secrets out-of-band.
17806
17807 @end table
17808 @end deftp
17809
17810 @defvr {Scheme Variable} yggdrasil-service-type
17811 The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
17812 Yggdrasil network}, an early-stage implementation of a fully end-to-end
17813 encrypted IPv6 network.
17814
17815 @quotation
17816 Yggdrasil provides name-independent routing with cryptographically generated
17817 addresses. Static addressing means you can keep the same address as long as
17818 you want, even if you move to a new location, or generate a new address (by
17819 generating new keys) whenever you want.
17820 @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
17821 @end quotation
17822
17823 Pass it a value of @code{yggdrasil-configuration} to connect it to public
17824 peers and/or local peers.
17825
17826 Here is an example using public peers and a static address. The static
17827 signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
17828 (the default value for @code{config-file}).
17829
17830 @lisp
17831 ;; part of the operating-system declaration
17832 (service yggdrasil-service-type
17833 (yggdrasil-configuration
17834 (autoconf? #f) ;; use only the public peers
17835 (json-config
17836 ;; choose one from
17837 ;; https://github.com/yggdrasil-network/public-peers
17838 '((peers . #("tcp://1.2.3.4:1337"))))
17839 ;; /etc/yggdrasil-private.conf is the default value for config-file
17840 ))
17841 @end lisp
17842 @example
17843 # sample content for /etc/yggdrasil-private.conf
17844 @{
17845 # Your public encryption key. Your peers may ask you for this to put
17846 # into their AllowedEncryptionPublicKeys configuration.
17847 EncryptionPublicKey: 378dc5...
17848
17849 # Your private encryption key. DO NOT share this with anyone!
17850 EncryptionPrivateKey: 0777...
17851
17852 # Your public signing key. You should not ordinarily need to share
17853 # this with anyone.
17854 SigningPublicKey: e1664...
17855
17856 # Your private signing key. DO NOT share this with anyone!
17857 SigningPrivateKey: 0589d...
17858 @}
17859 @end example
17860 @end defvr
17861
17862 @deftp {Data Type} yggdrasil-configuration
17863 Data type representing the configuration of Yggdrasil.
17864
17865 @table @asis
17866 @item @code{package} (default: @code{yggdrasil})
17867 Package object of Yggdrasil.
17868
17869 @item @code{json-config} (default: @code{'()})
17870 Contents of @file{/etc/yggdrasil.conf}. Will be merged with
17871 @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
17872 the Guix store, which is readable to all users. @strong{Do not store your
17873 private keys in it}. See the output of @code{yggdrasil -genconf} for a
17874 quick overview of valid keys and their default values.
17875
17876 @item @code{autoconf?} (default: @code{#f})
17877 Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
17878 and peer with IPv6 neighbors.
17879
17880 @item @code{log-level} (default: @code{'info})
17881 How much detail to include in logs. Use @code{'debug} for more detail.
17882
17883 @item @code{log-to} (default: @code{'stdout})
17884 Where to send logs. By default, the service logs standard output to
17885 @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
17886 sends output to the running syslog service.
17887
17888 @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
17889 What HJSON file to load sensitive data from. This is where private keys
17890 should be stored, which are necessary to specify if you don't want a
17891 randomized address after each restart. Use @code{#f} to disable. Options
17892 defined in this file take precedence over @code{json-config}. Use the output
17893 of @code{yggdrasil -genconf} as a starting point. To configure a static
17894 address, delete everything except these options:
17895
17896 @itemize
17897 @item @code{EncryptionPublicKey}
17898 @item @code{EncryptionPrivateKey}
17899 @item @code{SigningPublicKey}
17900 @item @code{SigningPrivateKey}
17901 @end itemize
17902 @end table
17903 @end deftp
17904
17905 @cindex IPFS
17906 @defvr {Scheme Variable} ipfs-service-type
17907 The service type for connecting to the @uref{https://ipfs.io,IPFS network},
17908 a global, versioned, peer-to-peer file system. Pass it a
17909 @code{ipfs-configuration} to change the ports used for the gateway and API.
17910
17911 Here's an example configuration, using some non-standard ports:
17912
17913 @lisp
17914 (service ipfs-service-type
17915 (ipfs-configuration
17916 (gateway "/ip4/127.0.0.1/tcp/8880")
17917 (api "/ip4/127.0.0.1/tcp/8881")))
17918 @end lisp
17919 @end defvr
17920
17921 @deftp {Data Type} ipfs-configuration
17922 Data type representing the configuration of IPFS.
17923
17924 @table @asis
17925 @item @code{package} (default: @code{go-ipfs})
17926 Package object of IPFS.
17927
17928 @item @code{gateway} (default: @code{"/ip4/127.0.0.1/tcp/8082"})
17929 Address of the gateway, in ‘multiaddress’ format.
17930
17931 @item @code{api} (default: @code{"/ip4/127.0.0.1/tcp/5001"})
17932 Address of the API endpoint, in ‘multiaddress’ format.
17933 @end table
17934 @end deftp
17935
17936 @cindex keepalived
17937 @deffn {Scheme Variable} keepalived-service-type
17938 This is the type for the @uref{https://www.keepalived.org/, Keepalived}
17939 routing software, @command{keepalived}. Its value must be an
17940 @code{keepalived-configuration} record as in this example for master
17941 machine:
17942
17943 @lisp
17944 (service keepalived-service-type
17945 (keepalived-configuration
17946 (config-file (local-file "keepalived-master.conf"))))
17947 @end lisp
17948
17949 where @file{keepalived-master.conf}:
17950
17951 @example
17952 vrrp_instance my-group @{
17953 state MASTER
17954 interface enp9s0
17955 virtual_router_id 100
17956 priority 100
17957 unicast_peer @{ 10.0.0.2 @}
17958 virtual_ipaddress @{
17959 10.0.0.4/24
17960 @}
17961 @}
17962 @end example
17963
17964 and for backup machine:
17965
17966 @lisp
17967 (service keepalived-service-type
17968 (keepalived-configuration
17969 (config-file (local-file "keepalived-backup.conf"))))
17970 @end lisp
17971
17972 where @file{keepalived-backup.conf}:
17973
17974 @example
17975 vrrp_instance my-group @{
17976 state BACKUP
17977 interface enp9s0
17978 virtual_router_id 100
17979 priority 99
17980 unicast_peer @{ 10.0.0.3 @}
17981 virtual_ipaddress @{
17982 10.0.0.4/24
17983 @}
17984 @}
17985 @end example
17986 @end deffn
17987
17988 @node Unattended Upgrades
17989 @subsection Unattended Upgrades
17990
17991 @cindex unattended upgrades
17992 @cindex upgrades, unattended
17993 Guix provides a service to perform @emph{unattended upgrades}:
17994 periodically, the system automatically reconfigures itself from the
17995 latest Guix. Guix System has several properties that make unattended
17996 upgrades safe:
17997
17998 @itemize
17999 @item
18000 upgrades are transactional (either the upgrade succeeds or it fails, but
18001 you cannot end up with an ``in-between'' system state);
18002 @item
18003 the upgrade log is kept---you can view it with @command{guix system
18004 list-generations}---and you can roll back to any previous generation,
18005 should the upgraded system fail to behave as intended;
18006 @item
18007 channel code is authenticated so you know you can only run genuine code
18008 (@pxref{Channels});
18009 @item
18010 @command{guix system reconfigure} prevents downgrades, which makes it
18011 immune to @dfn{downgrade attacks}.
18012 @end itemize
18013
18014 To set up unattended upgrades, add an instance of
18015 @code{unattended-upgrade-service-type} like the one below to the list of
18016 your operating system services:
18017
18018 @lisp
18019 (service unattended-upgrade-service-type)
18020 @end lisp
18021
18022 The defaults above set up weekly upgrades: every Sunday at midnight.
18023 You do not need to provide the operating system configuration file: it
18024 uses @file{/run/current-system/configuration.scm}, which ensures it
18025 always uses your latest configuration---@pxref{provenance-service-type},
18026 for more information about this file.
18027
18028 There are several things that can be configured, in particular the
18029 periodicity and services (daemons) to be restarted upon completion.
18030 When the upgrade is successful, the service takes care of deleting
18031 system generations older that some threshold, as per @command{guix
18032 system delete-generations}. See the reference below for details.
18033
18034 To ensure that upgrades are actually happening, you can run
18035 @command{guix system describe}. To investigate upgrade failures, visit
18036 the unattended upgrade log file (see below).
18037
18038 @defvr {Scheme Variable} unattended-upgrade-service-type
18039 This is the service type for unattended upgrades. It sets up an mcron
18040 job (@pxref{Scheduled Job Execution}) that runs @command{guix system
18041 reconfigure} from the latest version of the specified channels.
18042
18043 Its value must be a @code{unattended-upgrade-configuration} record (see
18044 below).
18045 @end defvr
18046
18047 @deftp {Data Type} unattended-upgrade-configuration
18048 This data type represents the configuration of the unattended upgrade
18049 service. The following fields are available:
18050
18051 @table @asis
18052 @item @code{schedule} (default: @code{"30 01 * * 0"})
18053 This is the schedule of upgrades, expressed as a gexp containing an
18054 mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
18055 mcron, GNU@tie{}mcron}).
18056
18057 @item @code{channels} (default: @code{#~%default-channels})
18058 This gexp specifies the channels to use for the upgrade
18059 (@pxref{Channels}). By default, the tip of the official @code{guix}
18060 channel is used.
18061
18062 @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
18063 This field specifies the operating system configuration file to use.
18064 The default is to reuse the config file of the current configuration.
18065
18066 There are cases, though, where referring to
18067 @file{/run/current-system/configuration.scm} is not enough, for instance
18068 because that file refers to extra files (SSH public keys, extra
18069 configuration files, etc.) @i{via} @code{local-file} and similar
18070 constructs. For those cases, we recommend something along these lines:
18071
18072 @lisp
18073 (unattended-upgrade-configuration
18074 (operating-system-file
18075 (file-append (local-file "." "config-dir" #:recursive? #t)
18076 "/config.scm")))
18077 @end lisp
18078
18079 The effect here is to import all of the current directory into the
18080 store, and to refer to @file{config.scm} within that directory.
18081 Therefore, uses of @code{local-file} within @file{config.scm} will work
18082 as expected. @xref{G-Expressions}, for information about
18083 @code{local-file} and @code{file-append}.
18084
18085 @item @code{services-to-restart} (default: @code{'(mcron)})
18086 This field specifies the Shepherd services to restart when the upgrade
18087 completes.
18088
18089 Those services are restarted right away upon completion, as with
18090 @command{herd restart}, which ensures that the latest version is
18091 running---remember that by default @command{guix system reconfigure}
18092 only restarts services that are not currently running, which is
18093 conservative: it minimizes disruption but leaves outdated services
18094 running.
18095
18096 Use @command{herd status} to find out candidates for restarting.
18097 @xref{Services}, for general information about services. Common
18098 services to restart would include @code{ntpd} and @code{ssh-daemon}.
18099
18100 By default, the @code{mcron} service is restarted. This ensures that
18101 the latest version of the unattended upgrade job will be used next time.
18102
18103 @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
18104 This is the expiration time in seconds for system generations. System
18105 generations older that this amount of time are deleted with
18106 @command{guix system delete-generations} when an upgrade completes.
18107
18108 @quotation Note
18109 The unattended upgrade service does not run the garbage collector. You
18110 will probably want to set up your own mcron job to run @command{guix gc}
18111 periodically.
18112 @end quotation
18113
18114 @item @code{maximum-duration} (default: @code{3600})
18115 Maximum duration in seconds for the upgrade; past that time, the upgrade
18116 aborts.
18117
18118 This is primarily useful to ensure the upgrade does not end up
18119 rebuilding or re-downloading ``the world''.
18120
18121 @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
18122 File where unattended upgrades are logged.
18123 @end table
18124 @end deftp
18125
18126 @node X Window
18127 @subsection X Window
18128
18129 @cindex X11
18130 @cindex X Window System
18131 @cindex login manager
18132 Support for the X Window graphical display system---specifically
18133 Xorg---is provided by the @code{(gnu services xorg)} module. Note that
18134 there is no @code{xorg-service} procedure. Instead, the X server is
18135 started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
18136
18137 @cindex GDM
18138 @cindex GNOME, login manager
18139 GDM of course allows users to log in into window managers and desktop
18140 environments other than GNOME; for those using GNOME, GDM is required for
18141 features such as automatic screen locking.
18142
18143 @cindex window manager
18144 To use X11, you must install at least one @dfn{window manager}---for
18145 example the @code{windowmaker} or @code{openbox} packages---preferably
18146 by adding it to the @code{packages} field of your operating system
18147 definition (@pxref{operating-system Reference, system-wide packages}).
18148
18149 @defvr {Scheme Variable} gdm-service-type
18150 This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
18151 Desktop Manager} (GDM), a program that manages graphical display servers and
18152 handles graphical user logins. Its value must be a @code{gdm-configuration}
18153 (see below).
18154
18155 @cindex session types (X11)
18156 @cindex X11 session types
18157 GDM looks for @dfn{session types} described by the @file{.desktop} files in
18158 @file{/run/current-system/profile/share/xsessions} and allows users to choose
18159 a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
18160 and @code{i3} provide @file{.desktop} files; adding them to the system-wide
18161 set of packages automatically makes them available at the log-in screen.
18162
18163 In addition, @file{~/.xsession} files are honored. When available,
18164 @file{~/.xsession} must be an executable that starts a window manager
18165 and/or other X clients.
18166 @end defvr
18167
18168 @deftp {Data Type} gdm-configuration
18169 @table @asis
18170 @item @code{auto-login?} (default: @code{#f})
18171 @itemx @code{default-user} (default: @code{#f})
18172 When @code{auto-login?} is false, GDM presents a log-in screen.
18173
18174 When @code{auto-login?} is true, GDM logs in directly as
18175 @code{default-user}.
18176
18177 @item @code{debug?} (default: @code{#f})
18178 When true, GDM writes debug messages to its log.
18179
18180 @item @code{gnome-shell-assets} (default: ...)
18181 List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
18182
18183 @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
18184 Configuration of the Xorg graphical server.
18185
18186 @item @code{xsession} (default: @code{(xinitrc)})
18187 Script to run before starting a X session.
18188
18189 @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
18190 File name of the @code{dbus-daemon} executable.
18191
18192 @item @code{gdm} (default: @code{gdm})
18193 The GDM package to use.
18194 @end table
18195 @end deftp
18196
18197 @defvr {Scheme Variable} slim-service-type
18198 This is the type for the SLiM graphical login manager for X11.
18199
18200 Like GDM, SLiM looks for session types described by @file{.desktop} files and
18201 allows users to choose a session from the log-in screen using @kbd{F1}. It
18202 also honors @file{~/.xsession} files.
18203
18204 Unlike GDM, SLiM does not spawn the user session on a different VT after
18205 logging in, which means that you can only start one graphical session. If you
18206 want to be able to run multiple graphical sessions at the same time you have
18207 to add multiple SLiM services to your system services. The following example
18208 shows how to replace the default GDM service with two SLiM services on tty7
18209 and tty8.
18210
18211 @lisp
18212 (use-modules (gnu services)
18213 (gnu services desktop)
18214 (gnu services xorg)
18215 (srfi srfi-1)) ;for 'remove'
18216
18217 (operating-system
18218 ;; ...
18219 (services (cons* (service slim-service-type (slim-configuration
18220 (display ":0")
18221 (vt "vt7")))
18222 (service slim-service-type (slim-configuration
18223 (display ":1")
18224 (vt "vt8")))
18225 (modify-services %desktop-services
18226 (delete gdm-service-type)))))
18227 @end lisp
18228
18229 @end defvr
18230
18231 @deftp {Data Type} slim-configuration
18232 Data type representing the configuration of @code{slim-service-type}.
18233
18234 @table @asis
18235 @item @code{allow-empty-passwords?} (default: @code{#t})
18236 Whether to allow logins with empty passwords.
18237
18238 @item @code{gnupg?} (default: @code{#f})
18239 If enabled, @code{pam-gnupg} will attempt to automatically unlock the
18240 user's GPG keys with the login password via @code{gpg-agent}. The
18241 keygrips of all keys to be unlocked should be written to
18242 @file{~/.pam-gnupg}, and can be queried with @code{gpg -K
18243 --with-keygrip}. Presetting passphrases must be enabled by adding
18244 @code{allow-preset-passphrase} in @file{~/.gnupg/gpg-agent.conf}.
18245
18246 @item @code{auto-login?} (default: @code{#f})
18247 @itemx @code{default-user} (default: @code{""})
18248 When @code{auto-login?} is false, SLiM presents a log-in screen.
18249
18250 When @code{auto-login?} is true, SLiM logs in directly as
18251 @code{default-user}.
18252
18253 @item @code{theme} (default: @code{%default-slim-theme})
18254 @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
18255 The graphical theme to use and its name.
18256
18257 @item @code{auto-login-session} (default: @code{#f})
18258 If true, this must be the name of the executable to start as the default
18259 session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
18260
18261 If false, a session described by one of the available @file{.desktop}
18262 files in @code{/run/current-system/profile} and @code{~/.guix-profile}
18263 will be used.
18264
18265 @quotation Note
18266 You must install at least one window manager in the system profile or in
18267 your user profile. Failing to do that, if @code{auto-login-session} is
18268 false, you will be unable to log in.
18269 @end quotation
18270
18271 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
18272 Configuration of the Xorg graphical server.
18273
18274 @item @code{display} (default @code{":0"})
18275 The display on which to start the Xorg graphical server.
18276
18277 @item @code{vt} (default @code{"vt7"})
18278 The VT on which to start the Xorg graphical server.
18279
18280 @item @code{xauth} (default: @code{xauth})
18281 The XAuth package to use.
18282
18283 @item @code{shepherd} (default: @code{shepherd})
18284 The Shepherd package used when invoking @command{halt} and
18285 @command{reboot}.
18286
18287 @item @code{sessreg} (default: @code{sessreg})
18288 The sessreg package used in order to register the session.
18289
18290 @item @code{slim} (default: @code{slim})
18291 The SLiM package to use.
18292 @end table
18293 @end deftp
18294
18295 @defvr {Scheme Variable} %default-theme
18296 @defvrx {Scheme Variable} %default-theme-name
18297 The default SLiM theme and its name.
18298 @end defvr
18299
18300
18301 @deftp {Data Type} sddm-configuration
18302 This is the data type representing the SDDM service configuration.
18303
18304 @table @asis
18305 @item @code{display-server} (default: "x11")
18306 Select display server to use for the greeter. Valid values are
18307 @samp{"x11"} or @samp{"wayland"}.
18308
18309 @item @code{numlock} (default: "on")
18310 Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
18311
18312 @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
18313 Command to run when halting.
18314
18315 @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
18316 Command to run when rebooting.
18317
18318 @item @code{theme} (default "maldives")
18319 Theme to use. Default themes provided by SDDM are @samp{"elarun"},
18320 @samp{"maldives"} or @samp{"maya"}.
18321
18322 @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
18323 Directory to look for themes.
18324
18325 @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
18326 Directory to look for faces.
18327
18328 @item @code{default-path} (default "/run/current-system/profile/bin")
18329 Default PATH to use.
18330
18331 @item @code{minimum-uid} (default: 1000)
18332 Minimum UID displayed in SDDM and allowed for log-in.
18333
18334 @item @code{maximum-uid} (default: 2000)
18335 Maximum UID to display in SDDM.
18336
18337 @item @code{remember-last-user?} (default #t)
18338 Remember last user.
18339
18340 @item @code{remember-last-session?} (default #t)
18341 Remember last session.
18342
18343 @item @code{hide-users} (default "")
18344 Usernames to hide from SDDM greeter.
18345
18346 @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
18347 Users with shells listed will be hidden from the SDDM greeter.
18348
18349 @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
18350 Script to run before starting a wayland session.
18351
18352 @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
18353 Directory to look for desktop files starting wayland sessions.
18354
18355 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
18356 Configuration of the Xorg graphical server.
18357
18358 @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
18359 Path to xauth.
18360
18361 @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
18362 Path to Xephyr.
18363
18364 @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
18365 Script to run after starting xorg-server.
18366
18367 @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
18368 Script to run before stopping xorg-server.
18369
18370 @item @code{xsession-command} (default: @code{xinitrc})
18371 Script to run before starting a X session.
18372
18373 @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
18374 Directory to look for desktop files starting X sessions.
18375
18376 @item @code{minimum-vt} (default: 7)
18377 Minimum VT to use.
18378
18379 @item @code{auto-login-user} (default "")
18380 User to use for auto-login.
18381
18382 @item @code{auto-login-session} (default "")
18383 Desktop file to use for auto-login.
18384
18385 @item @code{relogin?} (default #f)
18386 Relogin after logout.
18387
18388 @end table
18389 @end deftp
18390
18391 @cindex login manager
18392 @cindex X11 login
18393 @defvr {Scheme Variable} sddm-service-type
18394 This is the type of the service to run the
18395 @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
18396 must be a @code{sddm-configuration} record (see below).
18397
18398 Here's an example use:
18399
18400 @lisp
18401 (service sddm-service-type
18402 (sddm-configuration
18403 (auto-login-user "alice")
18404 (auto-login-session "xfce.desktop")))
18405 @end lisp
18406 @end defvr
18407
18408 @deftp {Data Type} sddm-configuration
18409 This data type represents the configuration of the SDDM login manager.
18410 The available fields are:
18411
18412 @table @asis
18413 @item @code{sddm} (default: @code{sddm})
18414 The SDDM package to use.
18415
18416 @item @code{display-server} (default: @code{"x11"})
18417 This must be either @code{"x11"} or @code{"wayland"}.
18418
18419 @c FIXME: Add more fields.
18420
18421 @item @code{auto-login-user} (default: @code{""})
18422 If non-empty, this is the user account under which to log in
18423 automatically.
18424
18425 @item @code{auto-login-session} (default: @code{""})
18426 If non-empty, this is the @file{.desktop} file name to use as the
18427 auto-login session.
18428 @end table
18429 @end deftp
18430
18431 @cindex Xorg, configuration
18432 @deftp {Data Type} xorg-configuration
18433 This data type represents the configuration of the Xorg graphical display
18434 server. Note that there is no Xorg service; instead, the X server is started
18435 by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
18436 of these display managers aggregates an @code{xorg-configuration} record.
18437
18438 @table @asis
18439 @item @code{modules} (default: @code{%default-xorg-modules})
18440 This is a list of @dfn{module packages} loaded by the Xorg
18441 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
18442
18443 @item @code{fonts} (default: @code{%default-xorg-fonts})
18444 This is a list of font directories to add to the server's @dfn{font path}.
18445
18446 @item @code{drivers} (default: @code{'()})
18447 This must be either the empty list, in which case Xorg chooses a graphics
18448 driver automatically, or a list of driver names that will be tried in this
18449 order---e.g., @code{("modesetting" "vesa")}.
18450
18451 @item @code{resolutions} (default: @code{'()})
18452 When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
18453 resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
18454 768) (640 480))}.
18455
18456 @cindex keyboard layout, for Xorg
18457 @cindex keymap, for Xorg
18458 @item @code{keyboard-layout} (default: @code{#f})
18459 If this is @code{#f}, Xorg uses the default keyboard layout---usually US
18460 English (``qwerty'') for a 105-key PC keyboard.
18461
18462 Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
18463 layout in use when Xorg is running. @xref{Keyboard Layout}, for more
18464 information on how to specify the keyboard layout.
18465
18466 @item @code{extra-config} (default: @code{'()})
18467 This is a list of strings or objects appended to the configuration file. It
18468 is used to pass extra text to be added verbatim to the configuration file.
18469
18470 @item @code{server} (default: @code{xorg-server})
18471 This is the package providing the Xorg server.
18472
18473 @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
18474 This is the list of command-line arguments to pass to the X server. The
18475 default is @code{-nolisten tcp}.
18476 @end table
18477 @end deftp
18478
18479 @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
18480 [@var{login-manager-service-type}]
18481 Tell the log-in manager (of type @var{login-manager-service-type}) to use
18482 @var{config}, an @code{<xorg-configuration>} record.
18483
18484 Since the Xorg configuration is embedded in the log-in manager's
18485 configuration---e.g., @code{gdm-configuration}---this procedure provides a
18486 shorthand to set the Xorg configuration.
18487 @end deffn
18488
18489 @deffn {Scheme Procedure} xorg-start-command [@var{config}]
18490 Return a @code{startx} script in which the modules, fonts, etc. specified
18491 in @var{config}, are available. The result should be used in place of
18492 @code{startx}.
18493
18494 Usually the X server is started by a login manager.
18495 @end deffn
18496
18497
18498 @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
18499 Add @var{package}, a package for a screen locker or screen saver whose
18500 command is @var{program}, to the set of setuid programs and add a PAM entry
18501 for it. For example:
18502
18503 @lisp
18504 (screen-locker-service xlockmore "xlock")
18505 @end lisp
18506
18507 makes the good ol' XlockMore usable.
18508 @end deffn
18509
18510
18511 @node Printing Services
18512 @subsection Printing Services
18513
18514 @cindex printer support with CUPS
18515 The @code{(gnu services cups)} module provides a Guix service definition
18516 for the CUPS printing service. To add printer support to a Guix
18517 system, add a @code{cups-service} to the operating system definition:
18518
18519 @deffn {Scheme Variable} cups-service-type
18520 The service type for the CUPS print server. Its value should be a valid
18521 CUPS configuration (see below). To use the default settings, simply
18522 write:
18523 @lisp
18524 (service cups-service-type)
18525 @end lisp
18526 @end deffn
18527
18528 The CUPS configuration controls the basic things about your CUPS
18529 installation: what interfaces it listens on, what to do if a print job
18530 fails, how much logging to do, and so on. To actually add a printer,
18531 you have to visit the @url{http://localhost:631} URL, or use a tool such
18532 as GNOME's printer configuration services. By default, configuring a
18533 CUPS service will generate a self-signed certificate if needed, for
18534 secure connections to the print server.
18535
18536 Suppose you want to enable the Web interface of CUPS and also add
18537 support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
18538 package and for HP printers @i{via} the @code{hplip-minimal} package.
18539 You can do that directly, like this (you need to use the
18540 @code{(gnu packages cups)} module):
18541
18542 @lisp
18543 (service cups-service-type
18544 (cups-configuration
18545 (web-interface? #t)
18546 (extensions
18547 (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
18548 @end lisp
18549
18550 Note: If you wish to use the Qt5 based GUI which comes with the hplip
18551 package then it is suggested that you install the @code{hplip} package,
18552 either in your OS configuration file or as your user.
18553
18554 The available configuration parameters follow. Each parameter
18555 definition is preceded by its type; for example, @samp{string-list foo}
18556 indicates that the @code{foo} parameter should be specified as a list of
18557 strings. There is also a way to specify the configuration as a string,
18558 if you have an old @code{cupsd.conf} file that you want to port over
18559 from some other system; see the end for more details.
18560
18561 @c The following documentation was initially generated by
18562 @c (generate-documentation) in (gnu services cups). Manually maintained
18563 @c documentation is better, so we shouldn't hesitate to edit below as
18564 @c needed. However if the change you want to make to this documentation
18565 @c can be done in an automated way, it's probably easier to change
18566 @c (generate-documentation) than to make it below and have to deal with
18567 @c the churn as CUPS updates.
18568
18569
18570 Available @code{cups-configuration} fields are:
18571
18572 @deftypevr {@code{cups-configuration} parameter} package cups
18573 The CUPS package.
18574 @end deftypevr
18575
18576 @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
18577 Drivers and other extensions to the CUPS package.
18578 @end deftypevr
18579
18580 @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
18581 Configuration of where to write logs, what directories to use for print
18582 spools, and related privileged configuration parameters.
18583
18584 Available @code{files-configuration} fields are:
18585
18586 @deftypevr {@code{files-configuration} parameter} log-location access-log
18587 Defines the access log filename. Specifying a blank filename disables
18588 access log generation. The value @code{stderr} causes log entries to be
18589 sent to the standard error file when the scheduler is running in the
18590 foreground, or to the system log daemon when run in the background. The
18591 value @code{syslog} causes log entries to be sent to the system log
18592 daemon. The server name may be included in filenames using the string
18593 @code{%s}, as in @code{/var/log/cups/%s-access_log}.
18594
18595 Defaults to @samp{"/var/log/cups/access_log"}.
18596 @end deftypevr
18597
18598 @deftypevr {@code{files-configuration} parameter} file-name cache-dir
18599 Where CUPS should cache data.
18600
18601 Defaults to @samp{"/var/cache/cups"}.
18602 @end deftypevr
18603
18604 @deftypevr {@code{files-configuration} parameter} string config-file-perm
18605 Specifies the permissions for all configuration files that the scheduler
18606 writes.
18607
18608 Note that the permissions for the printers.conf file are currently
18609 masked to only allow access from the scheduler user (typically root).
18610 This is done because printer device URIs sometimes contain sensitive
18611 authentication information that should not be generally known on the
18612 system. There is no way to disable this security feature.
18613
18614 Defaults to @samp{"0640"}.
18615 @end deftypevr
18616
18617 @deftypevr {@code{files-configuration} parameter} log-location error-log
18618 Defines the error log filename. Specifying a blank filename disables
18619 error log generation. The value @code{stderr} causes log entries to be
18620 sent to the standard error file when the scheduler is running in the
18621 foreground, or to the system log daemon when run in the background. The
18622 value @code{syslog} causes log entries to be sent to the system log
18623 daemon. The server name may be included in filenames using the string
18624 @code{%s}, as in @code{/var/log/cups/%s-error_log}.
18625
18626 Defaults to @samp{"/var/log/cups/error_log"}.
18627 @end deftypevr
18628
18629 @deftypevr {@code{files-configuration} parameter} string fatal-errors
18630 Specifies which errors are fatal, causing the scheduler to exit. The
18631 kind strings are:
18632
18633 @table @code
18634 @item none
18635 No errors are fatal.
18636
18637 @item all
18638 All of the errors below are fatal.
18639
18640 @item browse
18641 Browsing initialization errors are fatal, for example failed connections
18642 to the DNS-SD daemon.
18643
18644 @item config
18645 Configuration file syntax errors are fatal.
18646
18647 @item listen
18648 Listen or Port errors are fatal, except for IPv6 failures on the
18649 loopback or @code{any} addresses.
18650
18651 @item log
18652 Log file creation or write errors are fatal.
18653
18654 @item permissions
18655 Bad startup file permissions are fatal, for example shared TLS
18656 certificate and key files with world-read permissions.
18657 @end table
18658
18659 Defaults to @samp{"all -browse"}.
18660 @end deftypevr
18661
18662 @deftypevr {@code{files-configuration} parameter} boolean file-device?
18663 Specifies whether the file pseudo-device can be used for new printer
18664 queues. The URI @uref{file:///dev/null} is always allowed.
18665
18666 Defaults to @samp{#f}.
18667 @end deftypevr
18668
18669 @deftypevr {@code{files-configuration} parameter} string group
18670 Specifies the group name or ID that will be used when executing external
18671 programs.
18672
18673 Defaults to @samp{"lp"}.
18674 @end deftypevr
18675
18676 @deftypevr {@code{files-configuration} parameter} string log-file-perm
18677 Specifies the permissions for all log files that the scheduler writes.
18678
18679 Defaults to @samp{"0644"}.
18680 @end deftypevr
18681
18682 @deftypevr {@code{files-configuration} parameter} log-location page-log
18683 Defines the page log filename. Specifying a blank filename disables
18684 page log generation. The value @code{stderr} causes log entries to be
18685 sent to the standard error file when the scheduler is running in the
18686 foreground, or to the system log daemon when run in the background. The
18687 value @code{syslog} causes log entries to be sent to the system log
18688 daemon. The server name may be included in filenames using the string
18689 @code{%s}, as in @code{/var/log/cups/%s-page_log}.
18690
18691 Defaults to @samp{"/var/log/cups/page_log"}.
18692 @end deftypevr
18693
18694 @deftypevr {@code{files-configuration} parameter} string remote-root
18695 Specifies the username that is associated with unauthenticated accesses
18696 by clients claiming to be the root user. The default is @code{remroot}.
18697
18698 Defaults to @samp{"remroot"}.
18699 @end deftypevr
18700
18701 @deftypevr {@code{files-configuration} parameter} file-name request-root
18702 Specifies the directory that contains print jobs and other HTTP request
18703 data.
18704
18705 Defaults to @samp{"/var/spool/cups"}.
18706 @end deftypevr
18707
18708 @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
18709 Specifies the level of security sandboxing that is applied to print
18710 filters, backends, and other child processes of the scheduler; either
18711 @code{relaxed} or @code{strict}. This directive is currently only
18712 used/supported on macOS.
18713
18714 Defaults to @samp{strict}.
18715 @end deftypevr
18716
18717 @deftypevr {@code{files-configuration} parameter} file-name server-keychain
18718 Specifies the location of TLS certificates and private keys. CUPS will
18719 look for public and private keys in this directory: @file{.crt} files
18720 for PEM-encoded certificates and corresponding @file{.key} files for
18721 PEM-encoded private keys.
18722
18723 Defaults to @samp{"/etc/cups/ssl"}.
18724 @end deftypevr
18725
18726 @deftypevr {@code{files-configuration} parameter} file-name server-root
18727 Specifies the directory containing the server configuration files.
18728
18729 Defaults to @samp{"/etc/cups"}.
18730 @end deftypevr
18731
18732 @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
18733 Specifies whether the scheduler calls fsync(2) after writing
18734 configuration or state files.
18735
18736 Defaults to @samp{#f}.
18737 @end deftypevr
18738
18739 @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
18740 Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
18741 @end deftypevr
18742
18743 @deftypevr {@code{files-configuration} parameter} file-name temp-dir
18744 Specifies the directory where temporary files are stored.
18745
18746 Defaults to @samp{"/var/spool/cups/tmp"}.
18747 @end deftypevr
18748
18749 @deftypevr {@code{files-configuration} parameter} string user
18750 Specifies the user name or ID that is used when running external
18751 programs.
18752
18753 Defaults to @samp{"lp"}.
18754 @end deftypevr
18755
18756 @deftypevr {@code{files-configuration} parameter} string set-env
18757 Set the specified environment variable to be passed to child processes.
18758
18759 Defaults to @samp{"variable value"}.
18760 @end deftypevr
18761 @end deftypevr
18762
18763 @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
18764 Specifies the logging level for the AccessLog file. The @code{config}
18765 level logs when printers and classes are added, deleted, or modified and
18766 when configuration files are accessed or updated. The @code{actions}
18767 level logs when print jobs are submitted, held, released, modified, or
18768 canceled, and any of the conditions for @code{config}. The @code{all}
18769 level logs all requests.
18770
18771 Defaults to @samp{actions}.
18772 @end deftypevr
18773
18774 @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
18775 Specifies whether to purge job history data automatically when it is no
18776 longer required for quotas.
18777
18778 Defaults to @samp{#f}.
18779 @end deftypevr
18780
18781 @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
18782 Specifies a list of DNS-SD sub-types to advertise for each shared printer.
18783 For example, @samp{"_cups" "_print"} will tell network clients that both
18784 CUPS sharing and IPP Everywhere are supported.
18785
18786 Defaults to @samp{"_cups"}.
18787 @end deftypevr
18788
18789 @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
18790 Specifies which protocols to use for local printer sharing.
18791
18792 Defaults to @samp{dnssd}.
18793 @end deftypevr
18794
18795 @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
18796 Specifies whether the CUPS web interface is advertised.
18797
18798 Defaults to @samp{#f}.
18799 @end deftypevr
18800
18801 @deftypevr {@code{cups-configuration} parameter} boolean browsing?
18802 Specifies whether shared printers are advertised.
18803
18804 Defaults to @samp{#f}.
18805 @end deftypevr
18806
18807 @deftypevr {@code{cups-configuration} parameter} string classification
18808 Specifies the security classification of the server. Any valid banner
18809 name can be used, including @samp{"classified"}, @samp{"confidential"},
18810 @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
18811 banner can be omitted to disable secure printing functions.
18812
18813 Defaults to @samp{""}.
18814 @end deftypevr
18815
18816 @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
18817 Specifies whether users may override the classification (cover page) of
18818 individual print jobs using the @code{job-sheets} option.
18819
18820 Defaults to @samp{#f}.
18821 @end deftypevr
18822
18823 @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
18824 Specifies the default type of authentication to use.
18825
18826 Defaults to @samp{Basic}.
18827 @end deftypevr
18828
18829 @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
18830 Specifies whether encryption will be used for authenticated requests.
18831
18832 Defaults to @samp{Required}.
18833 @end deftypevr
18834
18835 @deftypevr {@code{cups-configuration} parameter} string default-language
18836 Specifies the default language to use for text and web content.
18837
18838 Defaults to @samp{"en"}.
18839 @end deftypevr
18840
18841 @deftypevr {@code{cups-configuration} parameter} string default-paper-size
18842 Specifies the default paper size for new print queues. @samp{"Auto"}
18843 uses a locale-specific default, while @samp{"None"} specifies there is
18844 no default paper size. Specific size names are typically
18845 @samp{"Letter"} or @samp{"A4"}.
18846
18847 Defaults to @samp{"Auto"}.
18848 @end deftypevr
18849
18850 @deftypevr {@code{cups-configuration} parameter} string default-policy
18851 Specifies the default access policy to use.
18852
18853 Defaults to @samp{"default"}.
18854 @end deftypevr
18855
18856 @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
18857 Specifies whether local printers are shared by default.
18858
18859 Defaults to @samp{#t}.
18860 @end deftypevr
18861
18862 @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
18863 Specifies the delay for updating of configuration and state files, in
18864 seconds. A value of 0 causes the update to happen as soon as possible,
18865 typically within a few milliseconds.
18866
18867 Defaults to @samp{30}.
18868 @end deftypevr
18869
18870 @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
18871 Specifies what to do when an error occurs. Possible values are
18872 @code{abort-job}, which will discard the failed print job;
18873 @code{retry-job}, which will retry the job at a later time;
18874 @code{retry-current-job}, which retries the failed job immediately; and
18875 @code{stop-printer}, which stops the printer.
18876
18877 Defaults to @samp{stop-printer}.
18878 @end deftypevr
18879
18880 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
18881 Specifies the maximum cost of filters that are run concurrently, which
18882 can be used to minimize disk, memory, and CPU resource problems. A
18883 limit of 0 disables filter limiting. An average print to a
18884 non-PostScript printer needs a filter limit of about 200. A PostScript
18885 printer needs about half that (100). Setting the limit below these
18886 thresholds will effectively limit the scheduler to printing a single job
18887 at any time.
18888
18889 Defaults to @samp{0}.
18890 @end deftypevr
18891
18892 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
18893 Specifies the scheduling priority of filters that are run to print a
18894 job. The nice value ranges from 0, the highest priority, to 19, the
18895 lowest priority.
18896
18897 Defaults to @samp{0}.
18898 @end deftypevr
18899
18900 @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
18901 Specifies whether to do reverse lookups on connecting clients. The
18902 @code{double} setting causes @code{cupsd} to verify that the hostname
18903 resolved from the address matches one of the addresses returned for that
18904 hostname. Double lookups also prevent clients with unregistered
18905 addresses from connecting to your server. Only set this option to
18906 @code{#t} or @code{double} if absolutely required.
18907
18908 Defaults to @samp{#f}.
18909 @end deftypevr
18910
18911 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
18912 Specifies the number of seconds to wait before killing the filters and
18913 backend associated with a canceled or held job.
18914
18915 Defaults to @samp{30}.
18916 @end deftypevr
18917
18918 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
18919 Specifies the interval between retries of jobs in seconds. This is
18920 typically used for fax queues but can also be used with normal print
18921 queues whose error policy is @code{retry-job} or
18922 @code{retry-current-job}.
18923
18924 Defaults to @samp{30}.
18925 @end deftypevr
18926
18927 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
18928 Specifies the number of retries that are done for jobs. This is
18929 typically used for fax queues but can also be used with normal print
18930 queues whose error policy is @code{retry-job} or
18931 @code{retry-current-job}.
18932
18933 Defaults to @samp{5}.
18934 @end deftypevr
18935
18936 @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
18937 Specifies whether to support HTTP keep-alive connections.
18938
18939 Defaults to @samp{#t}.
18940 @end deftypevr
18941
18942 @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
18943 Specifies the maximum size of print files, IPP requests, and HTML form
18944 data. A limit of 0 disables the limit check.
18945
18946 Defaults to @samp{0}.
18947 @end deftypevr
18948
18949 @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
18950 Listens on the specified interfaces for connections. Valid values are
18951 of the form @var{address}:@var{port}, where @var{address} is either an
18952 IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
18953 indicate all addresses. Values can also be file names of local UNIX
18954 domain sockets. The Listen directive is similar to the Port directive
18955 but allows you to restrict access to specific interfaces or networks.
18956 @end deftypevr
18957
18958 @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
18959 Specifies the number of pending connections that will be allowed. This
18960 normally only affects very busy servers that have reached the MaxClients
18961 limit, but can also be triggered by large numbers of simultaneous
18962 connections. When the limit is reached, the operating system will
18963 refuse additional connections until the scheduler can accept the pending
18964 ones.
18965
18966 Defaults to @samp{128}.
18967 @end deftypevr
18968
18969 @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
18970 Specifies a set of additional access controls.
18971
18972 Available @code{location-access-controls} fields are:
18973
18974 @deftypevr {@code{location-access-controls} parameter} file-name path
18975 Specifies the URI path to which the access control applies.
18976 @end deftypevr
18977
18978 @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
18979 Access controls for all access to this path, in the same format as the
18980 @code{access-controls} of @code{operation-access-control}.
18981
18982 Defaults to @samp{()}.
18983 @end deftypevr
18984
18985 @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
18986 Access controls for method-specific access to this path.
18987
18988 Defaults to @samp{()}.
18989
18990 Available @code{method-access-controls} fields are:
18991
18992 @deftypevr {@code{method-access-controls} parameter} boolean reverse?
18993 If @code{#t}, apply access controls to all methods except the listed
18994 methods. Otherwise apply to only the listed methods.
18995
18996 Defaults to @samp{#f}.
18997 @end deftypevr
18998
18999 @deftypevr {@code{method-access-controls} parameter} method-list methods
19000 Methods to which this access control applies.
19001
19002 Defaults to @samp{()}.
19003 @end deftypevr
19004
19005 @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
19006 Access control directives, as a list of strings. Each string should be
19007 one directive, such as @samp{"Order allow,deny"}.
19008
19009 Defaults to @samp{()}.
19010 @end deftypevr
19011 @end deftypevr
19012 @end deftypevr
19013
19014 @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
19015 Specifies the number of debugging messages that are retained for logging
19016 if an error occurs in a print job. Debug messages are logged regardless
19017 of the LogLevel setting.
19018
19019 Defaults to @samp{100}.
19020 @end deftypevr
19021
19022 @deftypevr {@code{cups-configuration} parameter} log-level log-level
19023 Specifies the level of logging for the ErrorLog file. The value
19024 @code{none} stops all logging while @code{debug2} logs everything.
19025
19026 Defaults to @samp{info}.
19027 @end deftypevr
19028
19029 @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
19030 Specifies the format of the date and time in the log files. The value
19031 @code{standard} logs whole seconds while @code{usecs} logs microseconds.
19032
19033 Defaults to @samp{standard}.
19034 @end deftypevr
19035
19036 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
19037 Specifies the maximum number of simultaneous clients that are allowed by
19038 the scheduler.
19039
19040 Defaults to @samp{100}.
19041 @end deftypevr
19042
19043 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
19044 Specifies the maximum number of simultaneous clients that are allowed
19045 from a single address.
19046
19047 Defaults to @samp{100}.
19048 @end deftypevr
19049
19050 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
19051 Specifies the maximum number of copies that a user can print of each
19052 job.
19053
19054 Defaults to @samp{9999}.
19055 @end deftypevr
19056
19057 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
19058 Specifies the maximum time a job may remain in the @code{indefinite}
19059 hold state before it is canceled. A value of 0 disables cancellation of
19060 held jobs.
19061
19062 Defaults to @samp{0}.
19063 @end deftypevr
19064
19065 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
19066 Specifies the maximum number of simultaneous jobs that are allowed. Set
19067 to 0 to allow an unlimited number of jobs.
19068
19069 Defaults to @samp{500}.
19070 @end deftypevr
19071
19072 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
19073 Specifies the maximum number of simultaneous jobs that are allowed per
19074 printer. A value of 0 allows up to MaxJobs jobs per printer.
19075
19076 Defaults to @samp{0}.
19077 @end deftypevr
19078
19079 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
19080 Specifies the maximum number of simultaneous jobs that are allowed per
19081 user. A value of 0 allows up to MaxJobs jobs per user.
19082
19083 Defaults to @samp{0}.
19084 @end deftypevr
19085
19086 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
19087 Specifies the maximum time a job may take to print before it is
19088 canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
19089
19090 Defaults to @samp{10800}.
19091 @end deftypevr
19092
19093 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
19094 Specifies the maximum size of the log files before they are rotated, in
19095 bytes. The value 0 disables log rotation.
19096
19097 Defaults to @samp{1048576}.
19098 @end deftypevr
19099
19100 @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
19101 Specifies the maximum amount of time to allow between files in a
19102 multiple file print job, in seconds.
19103
19104 Defaults to @samp{300}.
19105 @end deftypevr
19106
19107 @deftypevr {@code{cups-configuration} parameter} string page-log-format
19108 Specifies the format of PageLog lines. Sequences beginning with percent
19109 (@samp{%}) characters are replaced with the corresponding information,
19110 while all other characters are copied literally. The following percent
19111 sequences are recognized:
19112
19113 @table @samp
19114 @item %%
19115 insert a single percent character
19116
19117 @item %@{name@}
19118 insert the value of the specified IPP attribute
19119
19120 @item %C
19121 insert the number of copies for the current page
19122
19123 @item %P
19124 insert the current page number
19125
19126 @item %T
19127 insert the current date and time in common log format
19128
19129 @item %j
19130 insert the job ID
19131
19132 @item %p
19133 insert the printer name
19134
19135 @item %u
19136 insert the username
19137 @end table
19138
19139 A value of the empty string disables page logging. The string @code{%p
19140 %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
19141 %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
19142 standard items.
19143
19144 Defaults to @samp{""}.
19145 @end deftypevr
19146
19147 @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
19148 Passes the specified environment variable(s) to child processes; a list
19149 of strings.
19150
19151 Defaults to @samp{()}.
19152 @end deftypevr
19153
19154 @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
19155 Specifies named access control policies.
19156
19157 Available @code{policy-configuration} fields are:
19158
19159 @deftypevr {@code{policy-configuration} parameter} string name
19160 Name of the policy.
19161 @end deftypevr
19162
19163 @deftypevr {@code{policy-configuration} parameter} string job-private-access
19164 Specifies an access list for a job's private values. @code{@@ACL} maps
19165 to the printer's requesting-user-name-allowed or
19166 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
19167 owner. @code{@@SYSTEM} maps to the groups listed for the
19168 @code{system-group} field of the @code{files-configuration},
19169 which is reified into the @code{cups-files.conf(5)} file. Other
19170 possible elements of the access list include specific user names, and
19171 @code{@@@var{group}} to indicate members of a specific group. The
19172 access list may also be simply @code{all} or @code{default}.
19173
19174 Defaults to @samp{"@@OWNER @@SYSTEM"}.
19175 @end deftypevr
19176
19177 @deftypevr {@code{policy-configuration} parameter} string job-private-values
19178 Specifies the list of job values to make private, or @code{all},
19179 @code{default}, or @code{none}.
19180
19181 Defaults to @samp{"job-name job-originating-host-name
19182 job-originating-user-name phone"}.
19183 @end deftypevr
19184
19185 @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
19186 Specifies an access list for a subscription's private values.
19187 @code{@@ACL} maps to the printer's requesting-user-name-allowed or
19188 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
19189 owner. @code{@@SYSTEM} maps to the groups listed for the
19190 @code{system-group} field of the @code{files-configuration},
19191 which is reified into the @code{cups-files.conf(5)} file. Other
19192 possible elements of the access list include specific user names, and
19193 @code{@@@var{group}} to indicate members of a specific group. The
19194 access list may also be simply @code{all} or @code{default}.
19195
19196 Defaults to @samp{"@@OWNER @@SYSTEM"}.
19197 @end deftypevr
19198
19199 @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
19200 Specifies the list of job values to make private, or @code{all},
19201 @code{default}, or @code{none}.
19202
19203 Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
19204 notify-subscriber-user-name notify-user-data"}.
19205 @end deftypevr
19206
19207 @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
19208 Access control by IPP operation.
19209
19210 Defaults to @samp{()}.
19211 @end deftypevr
19212 @end deftypevr
19213
19214 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
19215 Specifies whether job files (documents) are preserved after a job is
19216 printed. If a numeric value is specified, job files are preserved for
19217 the indicated number of seconds after printing. Otherwise a boolean
19218 value applies indefinitely.
19219
19220 Defaults to @samp{86400}.
19221 @end deftypevr
19222
19223 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
19224 Specifies whether the job history is preserved after a job is printed.
19225 If a numeric value is specified, the job history is preserved for the
19226 indicated number of seconds after printing. If @code{#t}, the job
19227 history is preserved until the MaxJobs limit is reached.
19228
19229 Defaults to @samp{#t}.
19230 @end deftypevr
19231
19232 @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
19233 Specifies the amount of time to wait for job completion before
19234 restarting the scheduler.
19235
19236 Defaults to @samp{30}.
19237 @end deftypevr
19238
19239 @deftypevr {@code{cups-configuration} parameter} string rip-cache
19240 Specifies the maximum amount of memory to use when converting documents
19241 into bitmaps for a printer.
19242
19243 Defaults to @samp{"128m"}.
19244 @end deftypevr
19245
19246 @deftypevr {@code{cups-configuration} parameter} string server-admin
19247 Specifies the email address of the server administrator.
19248
19249 Defaults to @samp{"root@@localhost.localdomain"}.
19250 @end deftypevr
19251
19252 @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
19253 The ServerAlias directive is used for HTTP Host header validation when
19254 clients connect to the scheduler from external interfaces. Using the
19255 special name @code{*} can expose your system to known browser-based DNS
19256 rebinding attacks, even when accessing sites through a firewall. If the
19257 auto-discovery of alternate names does not work, we recommend listing
19258 each alternate name with a ServerAlias directive instead of using
19259 @code{*}.
19260
19261 Defaults to @samp{*}.
19262 @end deftypevr
19263
19264 @deftypevr {@code{cups-configuration} parameter} string server-name
19265 Specifies the fully-qualified host name of the server.
19266
19267 Defaults to @samp{"localhost"}.
19268 @end deftypevr
19269
19270 @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
19271 Specifies what information is included in the Server header of HTTP
19272 responses. @code{None} disables the Server header. @code{ProductOnly}
19273 reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
19274 reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
19275 @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
19276 the output of the @code{uname} command. @code{Full} reports @code{CUPS
19277 2.0.0 (@var{uname}) IPP/2.0}.
19278
19279 Defaults to @samp{Minimal}.
19280 @end deftypevr
19281
19282 @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
19283 Listens on the specified interfaces for encrypted connections. Valid
19284 values are of the form @var{address}:@var{port}, where @var{address} is
19285 either an IPv6 address enclosed in brackets, an IPv4 address, or
19286 @code{*} to indicate all addresses.
19287
19288 Defaults to @samp{()}.
19289 @end deftypevr
19290
19291 @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
19292 Sets encryption options. By default, CUPS only supports encryption
19293 using TLS v1.0 or higher using known secure cipher suites. Security is
19294 reduced when @code{Allow} options are used, and enhanced when @code{Deny}
19295 options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
19296 suites, which are required for some older clients. The @code{AllowSSL3} option
19297 enables SSL v3.0, which is required for some older clients that do not support
19298 TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
19299 @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
19300 protocol version to TLS v1.1.
19301
19302 Defaults to @samp{()}.
19303 @end deftypevr
19304
19305 @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
19306 Specifies whether the scheduler requires clients to strictly adhere to
19307 the IPP specifications.
19308
19309 Defaults to @samp{#f}.
19310 @end deftypevr
19311
19312 @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
19313 Specifies the HTTP request timeout, in seconds.
19314
19315 Defaults to @samp{300}.
19316
19317 @end deftypevr
19318
19319 @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
19320 Specifies whether the web interface is enabled.
19321
19322 Defaults to @samp{#f}.
19323 @end deftypevr
19324
19325 At this point you're probably thinking ``oh dear, Guix manual, I like
19326 you but you can stop already with the configuration options''. Indeed.
19327 However, one more point: it could be that you have an existing
19328 @code{cupsd.conf} that you want to use. In that case, you can pass an
19329 @code{opaque-cups-configuration} as the configuration of a
19330 @code{cups-service-type}.
19331
19332 Available @code{opaque-cups-configuration} fields are:
19333
19334 @deftypevr {@code{opaque-cups-configuration} parameter} package cups
19335 The CUPS package.
19336 @end deftypevr
19337
19338 @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
19339 The contents of the @code{cupsd.conf}, as a string.
19340 @end deftypevr
19341
19342 @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
19343 The contents of the @code{cups-files.conf} file, as a string.
19344 @end deftypevr
19345
19346 For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
19347 strings of the same name, you could instantiate a CUPS service like
19348 this:
19349
19350 @lisp
19351 (service cups-service-type
19352 (opaque-cups-configuration
19353 (cupsd.conf cupsd.conf)
19354 (cups-files.conf cups-files.conf)))
19355 @end lisp
19356
19357
19358 @node Desktop Services
19359 @subsection Desktop Services
19360
19361 The @code{(gnu services desktop)} module provides services that are
19362 usually useful in the context of a ``desktop'' setup---that is, on a
19363 machine running a graphical display server, possibly with graphical user
19364 interfaces, etc. It also defines services that provide specific desktop
19365 environments like GNOME, Xfce or MATE.
19366
19367 To simplify things, the module defines a variable containing the set of
19368 services that users typically expect on a machine with a graphical
19369 environment and networking:
19370
19371 @defvr {Scheme Variable} %desktop-services
19372 This is a list of services that builds upon @code{%base-services} and
19373 adds or adjusts services for a typical ``desktop'' setup.
19374
19375 In particular, it adds a graphical login manager (@pxref{X Window,
19376 @code{gdm-service-type}}), screen lockers, a network management tool
19377 (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
19378 support (@pxref{Networking Services, @code{modem-manager-service-type}}),
19379 energy and color management services, the @code{elogind} login and seat
19380 manager, the Polkit privilege service, the GeoClue location service, the
19381 AccountsService daemon that allows authorized users change system passwords,
19382 an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
19383 name service switch service configured to be able to use @code{nss-mdns}
19384 (@pxref{Name Service Switch, mDNS}).
19385 @end defvr
19386
19387 The @code{%desktop-services} variable can be used as the @code{services}
19388 field of an @code{operating-system} declaration (@pxref{operating-system
19389 Reference, @code{services}}).
19390
19391 Additionally, the @code{gnome-desktop-service-type},
19392 @code{xfce-desktop-service}, @code{mate-desktop-service-type},
19393 @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
19394 procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
19395 ``add GNOME'' means that system-level services like the backlight adjustment
19396 helpers and the power management utilities are added to the system, extending
19397 @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
19398 elevated privileges on a limited number of special-purpose system interfaces.
19399 Additionally, adding a service made by @code{gnome-desktop-service-type} adds
19400 the GNOME metapackage to the system profile. Likewise, adding the Xfce
19401 service not only adds the @code{xfce} metapackage to the system profile, but
19402 it also gives the Thunar file manager the ability to open a ``root-mode'' file
19403 management window, if the user authenticates using the administrator's
19404 password via the standard polkit graphical interface. To ``add MATE'' means
19405 that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
19406 to operate with elevated privileges on a limited number of special-purpose
19407 system interfaces. Additionally, adding a service of type
19408 @code{mate-desktop-service-type} adds the MATE metapackage to the system
19409 profile. ``Adding Enlightenment'' means that @code{dbus} is extended
19410 appropriately, and several of Enlightenment's binaries are set as setuid,
19411 allowing Enlightenment's screen locker and other functionality to work as
19412 expected.
19413
19414 The desktop environments in Guix use the Xorg display server by
19415 default. If you'd like to use the newer display server protocol
19416 called Wayland, you need to use the @code{sddm-service} instead of
19417 GDM as the graphical login manager. You should then
19418 select the ``GNOME (Wayland)'' session in SDDM@. Alternatively you can
19419 also try starting GNOME on Wayland manually from a TTY with the
19420 command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
19421 gnome-session``. Currently only GNOME has support for Wayland.
19422
19423 @defvr {Scheme Variable} gnome-desktop-service-type
19424 This is the type of the service that adds the @uref{https://www.gnome.org,
19425 GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
19426 object (see below).
19427
19428 This service adds the @code{gnome} package to the system profile, and extends
19429 polkit with the actions from @code{gnome-settings-daemon}.
19430 @end defvr
19431
19432 @deftp {Data Type} gnome-desktop-configuration
19433 Configuration record for the GNOME desktop environment.
19434
19435 @table @asis
19436 @item @code{gnome} (default: @code{gnome})
19437 The GNOME package to use.
19438 @end table
19439 @end deftp
19440
19441 @defvr {Scheme Variable} xfce-desktop-service-type
19442 This is the type of a service to run the @uref{Xfce, https://xfce.org/}
19443 desktop environment. Its value is an @code{xfce-desktop-configuration} object
19444 (see below).
19445
19446 This service adds the @code{xfce} package to the system profile, and
19447 extends polkit with the ability for @code{thunar} to manipulate the file
19448 system as root from within a user session, after the user has authenticated
19449 with the administrator's password.
19450
19451 Note that @code{xfce4-panel} and its plugin packages should be installed in
19452 the same profile to ensure compatibility. When using this service, you should
19453 add extra plugins (@code{xfce4-whiskermenu-plugin},
19454 @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
19455 @code{operating-system}.
19456 @end defvr
19457
19458 @deftp {Data Type} xfce-desktop-configuration
19459 Configuration record for the Xfce desktop environment.
19460
19461 @table @asis
19462 @item @code{xfce} (default: @code{xfce})
19463 The Xfce package to use.
19464 @end table
19465 @end deftp
19466
19467 @deffn {Scheme Variable} mate-desktop-service-type
19468 This is the type of the service that runs the @uref{https://mate-desktop.org/,
19469 MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
19470 object (see below).
19471
19472 This service adds the @code{mate} package to the system
19473 profile, and extends polkit with the actions from
19474 @code{mate-settings-daemon}.
19475 @end deffn
19476
19477 @deftp {Data Type} mate-desktop-configuration
19478 Configuration record for the MATE desktop environment.
19479
19480 @table @asis
19481 @item @code{mate} (default: @code{mate})
19482 The MATE package to use.
19483 @end table
19484 @end deftp
19485
19486 @deffn {Scheme Variable} lxqt-desktop-service-type
19487 This is the type of the service that runs the @uref{https://lxqt-project.org,
19488 LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
19489 object (see below).
19490
19491 This service adds the @code{lxqt} package to the system
19492 profile.
19493 @end deffn
19494
19495 @deftp {Data Type} lxqt-desktop-configuration
19496 Configuration record for the LXQt desktop environment.
19497
19498 @table @asis
19499 @item @code{lxqt} (default: @code{lxqt})
19500 The LXQT package to use.
19501 @end table
19502 @end deftp
19503
19504 @deffn {Scheme Variable} enlightenment-desktop-service-type
19505 Return a service that adds the @code{enlightenment} package to the system
19506 profile, and extends dbus with actions from @code{efl}.
19507 @end deffn
19508
19509 @deftp {Data Type} enlightenment-desktop-service-configuration
19510 @table @asis
19511 @item @code{enlightenment} (default: @code{enlightenment})
19512 The enlightenment package to use.
19513 @end table
19514 @end deftp
19515
19516 Because the GNOME, Xfce and MATE desktop services pull in so many packages,
19517 the default @code{%desktop-services} variable doesn't include any of
19518 them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
19519 @code{%desktop-services} in the @code{services} field of your
19520 @code{operating-system}:
19521
19522 @lisp
19523 (use-modules (gnu))
19524 (use-service-modules desktop)
19525 (operating-system
19526 ...
19527 ;; cons* adds items to the list given as its last argument.
19528 (services (cons* (service gnome-desktop-service-type)
19529 (service xfce-desktop-service)
19530 %desktop-services))
19531 ...)
19532 @end lisp
19533
19534 These desktop environments will then be available as options in the
19535 graphical login window.
19536
19537 The actual service definitions included in @code{%desktop-services} and
19538 provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
19539 are described below.
19540
19541 @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
19542 Return a service that runs the ``system bus'', using @var{dbus}, with
19543 support for @var{services}.
19544
19545 @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
19546 facility. Its system bus is used to allow system services to communicate
19547 and to be notified of system-wide events.
19548
19549 @var{services} must be a list of packages that provide an
19550 @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
19551 and policy files. For example, to allow avahi-daemon to use the system bus,
19552 @var{services} must be equal to @code{(list avahi)}.
19553 @end deffn
19554
19555 @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
19556 Return a service that runs the @code{elogind} login and
19557 seat management daemon. @uref{https://github.com/elogind/elogind,
19558 Elogind} exposes a D-Bus interface that can be used to know which users
19559 are logged in, know what kind of sessions they have open, suspend the
19560 system, inhibit system suspend, reboot the system, and other tasks.
19561
19562 Elogind handles most system-level power events for a computer, for
19563 example suspending the system when a lid is closed, or shutting it down
19564 when the power button is pressed.
19565
19566 The @var{config} keyword argument specifies the configuration for
19567 elogind, and should be the result of an @code{(elogind-configuration
19568 (@var{parameter} @var{value})...)} invocation. Available parameters and
19569 their default values are:
19570
19571 @table @code
19572 @item kill-user-processes?
19573 @code{#f}
19574 @item kill-only-users
19575 @code{()}
19576 @item kill-exclude-users
19577 @code{("root")}
19578 @item inhibit-delay-max-seconds
19579 @code{5}
19580 @item handle-power-key
19581 @code{poweroff}
19582 @item handle-suspend-key
19583 @code{suspend}
19584 @item handle-hibernate-key
19585 @code{hibernate}
19586 @item handle-lid-switch
19587 @code{suspend}
19588 @item handle-lid-switch-docked
19589 @code{ignore}
19590 @item handle-lid-switch-external-power
19591 @code{ignore}
19592 @item power-key-ignore-inhibited?
19593 @code{#f}
19594 @item suspend-key-ignore-inhibited?
19595 @code{#f}
19596 @item hibernate-key-ignore-inhibited?
19597 @code{#f}
19598 @item lid-switch-ignore-inhibited?
19599 @code{#t}
19600 @item holdoff-timeout-seconds
19601 @code{30}
19602 @item idle-action
19603 @code{ignore}
19604 @item idle-action-seconds
19605 @code{(* 30 60)}
19606 @item runtime-directory-size-percent
19607 @code{10}
19608 @item runtime-directory-size
19609 @code{#f}
19610 @item remove-ipc?
19611 @code{#t}
19612 @item suspend-state
19613 @code{("mem" "standby" "freeze")}
19614 @item suspend-mode
19615 @code{()}
19616 @item hibernate-state
19617 @code{("disk")}
19618 @item hibernate-mode
19619 @code{("platform" "shutdown")}
19620 @item hybrid-sleep-state
19621 @code{("disk")}
19622 @item hybrid-sleep-mode
19623 @code{("suspend" "platform" "shutdown")}
19624 @end table
19625 @end deffn
19626
19627 @deffn {Scheme Procedure} accountsservice-service @
19628 [#:accountsservice @var{accountsservice}]
19629 Return a service that runs AccountsService, a system service that can
19630 list available accounts, change their passwords, and so on.
19631 AccountsService integrates with PolicyKit to enable unprivileged users
19632 to acquire the capability to modify their system configuration.
19633 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
19634 accountsservice web site} for more information.
19635
19636 The @var{accountsservice} keyword argument is the @code{accountsservice}
19637 package to expose as a service.
19638 @end deffn
19639
19640 @deffn {Scheme Procedure} polkit-service @
19641 [#:polkit @var{polkit}]
19642 Return a service that runs the
19643 @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
19644 management service}, which allows system administrators to grant access to
19645 privileged operations in a structured way. By querying the Polkit service, a
19646 privileged system component can know when it should grant additional
19647 capabilities to ordinary users. For example, an ordinary user can be granted
19648 the capability to suspend the system if the user is logged in locally.
19649 @end deffn
19650
19651 @defvr {Scheme Variable} polkit-wheel-service
19652 Service that adds the @code{wheel} group as admins to the Polkit
19653 service. This makes it so that users in the @code{wheel} group are queried
19654 for their own passwords when performing administrative actions instead of
19655 @code{root}'s, similar to the behaviour used by @code{sudo}.
19656 @end defvr
19657
19658 @defvr {Scheme Variable} upower-service-type
19659 Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
19660 system-wide monitor for power consumption and battery levels, with the given
19661 configuration settings.
19662
19663 It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
19664 notably used by GNOME.
19665 @end defvr
19666
19667 @deftp {Data Type} upower-configuration
19668 Data type representation the configuration for UPower.
19669
19670 @table @asis
19671
19672 @item @code{upower} (default: @var{upower})
19673 Package to use for @code{upower}.
19674
19675 @item @code{watts-up-pro?} (default: @code{#f})
19676 Enable the Watts Up Pro device.
19677
19678 @item @code{poll-batteries?} (default: @code{#t})
19679 Enable polling the kernel for battery level changes.
19680
19681 @item @code{ignore-lid?} (default: @code{#f})
19682 Ignore the lid state, this can be useful if it's incorrect on a device.
19683
19684 @item @code{use-percentage-for-policy?} (default: @code{#f})
19685 Whether battery percentage based policy should be used. The default is to use
19686 the time left, change to @code{#t} to use the percentage.
19687
19688 @item @code{percentage-low} (default: @code{10})
19689 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
19690 at which the battery is considered low.
19691
19692 @item @code{percentage-critical} (default: @code{3})
19693 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
19694 at which the battery is considered critical.
19695
19696 @item @code{percentage-action} (default: @code{2})
19697 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
19698 at which action will be taken.
19699
19700 @item @code{time-low} (default: @code{1200})
19701 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
19702 seconds at which the battery is considered low.
19703
19704 @item @code{time-critical} (default: @code{300})
19705 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
19706 seconds at which the battery is considered critical.
19707
19708 @item @code{time-action} (default: @code{120})
19709 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
19710 seconds at which action will be taken.
19711
19712 @item @code{critical-power-action} (default: @code{'hybrid-sleep})
19713 The action taken when @code{percentage-action} or @code{time-action} is
19714 reached (depending on the configuration of @code{use-percentage-for-policy?}).
19715
19716 Possible values are:
19717
19718 @itemize @bullet
19719 @item
19720 @code{'power-off}
19721
19722 @item
19723 @code{'hibernate}
19724
19725 @item
19726 @code{'hybrid-sleep}.
19727 @end itemize
19728
19729 @end table
19730 @end deftp
19731
19732 @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
19733 Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
19734 UDisks}, a @dfn{disk management} daemon that provides user interfaces
19735 with notifications and ways to mount/unmount disks. Programs that talk
19736 to UDisks include the @command{udisksctl} command, part of UDisks, and
19737 GNOME Disks. Note that Udisks relies on the @command{mount} command, so
19738 it will only be able to use the file-system utilities installed in the
19739 system profile. For example if you want to be able to mount NTFS
19740 file-systems in read and write fashion, you'll need to have
19741 @code{ntfs-3g} installed system-wide.
19742 @end deffn
19743
19744 @deffn {Scheme Variable} colord-service-type
19745 This is the type of the service that runs @command{colord}, a system
19746 service with a D-Bus
19747 interface to manage the color profiles of input and output devices such as
19748 screens and scanners. It is notably used by the GNOME Color Manager graphical
19749 tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
19750 site} for more information.
19751 @end deffn
19752
19753 @cindex scanner access
19754 @defvr {Scheme Variable} sane-service-type
19755 This service provides access to scanners @i{via}
19756 @uref{http://www.sane-project.org, SANE} by installing the necessary
19757 udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
19758 Services}) and relies by default on @code{sane-backends-minimal} package
19759 (see below) for hardware support.
19760 @end defvr
19761
19762 @defvr {Scheme Variable} sane-backends-minimal
19763 The default package which the @code{sane-service-type} installs. It
19764 supports many recent scanners.
19765 @end defvr
19766
19767 @defvr {Scheme Variable} sane-backends
19768 This package includes support for all scanners that
19769 @code{sane-backends-minimal} supports, plus older Hewlett-Packard
19770 scanners supported by @code{hplip} package. In order to use this on
19771 a system which relies on @code{%desktop-services}, you may use
19772 @code{modify-services} (@pxref{Service Reference,
19773 @code{modify-services}}) as illustrated below:
19774
19775 @lisp
19776 (use-modules (gnu))
19777 (use-service-modules
19778 @dots{}
19779 desktop)
19780 (use-package-modules
19781 @dots{}
19782 scanner)
19783
19784 (define %my-desktop-services
19785 ;; List of desktop services that supports a broader range of scanners.
19786 (modify-services %desktop-services
19787 (sane-service-type _ => sane-backends)))
19788
19789 (operating-system
19790 @dots{}
19791 (services %my-desktop-services)
19792 @end lisp
19793 @end defvr
19794
19795 @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
19796 Return a configuration allowing an application to access GeoClue
19797 location data. @var{name} is the Desktop ID of the application, without
19798 the @code{.desktop} part. If @var{allowed?} is true, the application
19799 will have access to location information by default. The boolean
19800 @var{system?} value indicates whether an application is a system component
19801 or not. Finally @var{users} is a list of UIDs of all users for which
19802 this application is allowed location info access. An empty users list
19803 means that all users are allowed.
19804 @end deffn
19805
19806 @defvr {Scheme Variable} %standard-geoclue-applications
19807 The standard list of well-known GeoClue application configurations,
19808 granting authority to the GNOME date-and-time utility to ask for the
19809 current location in order to set the time zone, and allowing the
19810 IceCat and Epiphany web browsers to request location information.
19811 IceCat and Epiphany both query the user before allowing a web page to
19812 know the user's location.
19813 @end defvr
19814
19815 @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
19816 [#:whitelist '()] @
19817 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
19818 [#:submit-data? #f]
19819 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
19820 [#:submission-nick "geoclue"] @
19821 [#:applications %standard-geoclue-applications]
19822 Return a service that runs the GeoClue location service. This service
19823 provides a D-Bus interface to allow applications to request access to a
19824 user's physical location, and optionally to add information to online
19825 location databases. See
19826 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
19827 web site} for more information.
19828 @end deffn
19829
19830 @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
19831 [@w{#:auto-enable? #f}]
19832 Return a service that runs the @command{bluetoothd} daemon, which
19833 manages all the Bluetooth devices and provides a number of D-Bus
19834 interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
19835 powered automatically at boot, which can be useful when using a
19836 bluetooth keyboard or mouse.
19837
19838 Users need to be in the @code{lp} group to access the D-Bus service.
19839 @end deffn
19840
19841 @defvr {Scheme Variable} gnome-keyring-service-type
19842 This is the type of the service that adds the
19843 @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
19844 value is a @code{gnome-keyring-configuration} object (see below).
19845
19846 This service adds the @code{gnome-keyring} package to the system profile
19847 and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
19848 a user's login keyring when they log in or setting its password with passwd.
19849 @end defvr
19850
19851 @deftp {Data Type} gnome-keyring-configuration
19852 Configuration record for the GNOME Keyring service.
19853
19854 @table @asis
19855 @item @code{keyring} (default: @code{gnome-keyring})
19856 The GNOME keyring package to use.
19857
19858 @item @code{pam-services}
19859 A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
19860 services to extend, where @var{service} is the name of an existing
19861 service to extend and @var{kind} is one of @code{login} or
19862 @code{passwd}.
19863
19864 If @code{login} is given, it adds an optional
19865 @code{pam_gnome_keyring.so} to the auth block without arguments and to
19866 the session block with @code{auto_start}. If @code{passwd} is given, it
19867 adds an optional @code{pam_gnome_keyring.so} to the password block
19868 without arguments.
19869
19870 By default, this field contains ``gdm-password'' with the value @code{login}
19871 and ``passwd'' is with the value @code{passwd}.
19872 @end table
19873 @end deftp
19874
19875
19876 @node Sound Services
19877 @subsection Sound Services
19878
19879 @cindex sound support
19880 @cindex ALSA
19881 @cindex PulseAudio, sound support
19882
19883 The @code{(gnu services sound)} module provides a service to configure the
19884 Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
19885 preferred ALSA output driver.
19886
19887 @deffn {Scheme Variable} alsa-service-type
19888 This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
19889 Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
19890 configuration file. The value for this type is a @command{alsa-configuration}
19891 record as in this example:
19892
19893 @lisp
19894 (service alsa-service-type)
19895 @end lisp
19896
19897 See below for details about @code{alsa-configuration}.
19898 @end deffn
19899
19900 @deftp {Data Type} alsa-configuration
19901 Data type representing the configuration for @code{alsa-service}.
19902
19903 @table @asis
19904 @item @code{alsa-plugins} (default: @var{alsa-plugins})
19905 @code{alsa-plugins} package to use.
19906
19907 @item @code{pulseaudio?} (default: @var{#t})
19908 Whether ALSA applications should transparently be made to use the
19909 @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
19910
19911 Using PulseAudio allows you to run several sound-producing applications
19912 at the same time and to individual control them @i{via}
19913 @command{pavucontrol}, among other things.
19914
19915 @item @code{extra-options} (default: @var{""})
19916 String to append to the @file{/etc/asound.conf} file.
19917
19918 @end table
19919 @end deftp
19920
19921 Individual users who want to override the system configuration of ALSA can do
19922 it with the @file{~/.asoundrc} file:
19923
19924 @example
19925 # In guix, we have to specify the absolute path for plugins.
19926 pcm_type.jack @{
19927 lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
19928 @}
19929
19930 # Routing ALSA to jack:
19931 # <http://jackaudio.org/faq/routing_alsa.html>.
19932 pcm.rawjack @{
19933 type jack
19934 playback_ports @{
19935 0 system:playback_1
19936 1 system:playback_2
19937 @}
19938
19939 capture_ports @{
19940 0 system:capture_1
19941 1 system:capture_2
19942 @}
19943 @}
19944
19945 pcm.!default @{
19946 type plug
19947 slave @{
19948 pcm "rawjack"
19949 @}
19950 @}
19951 @end example
19952
19953 See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
19954 details.
19955
19956 @deffn {Scheme Variable} pulseaudio-service-type
19957 This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
19958 sound server. It exists to allow system overrides of the default settings
19959 via @code{pulseaudio-configuration}, see below.
19960
19961 @quotation Warning
19962 This service overrides per-user configuration files. If you want
19963 PulseAudio to honor configuration files in @file{~/.config/pulse} you
19964 have to unset the environment variables @env{PULSE_CONFIG} and
19965 @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
19966 @end quotation
19967
19968 @quotation Warning
19969 This service on its own does not ensure, that the @code{pulseaudio} package
19970 exists on your machine. It merely adds configuration files for it, as
19971 detailed below. In the (admittedly unlikely) case, that you find yourself
19972 without a @code{pulseaudio} package, consider enabling it through the
19973 @code{alsa-service-type} above.
19974 @end quotation
19975 @end deffn
19976
19977 @deftp {Data Type} pulseaudio-configuration
19978 Data type representing the configuration for @code{pulseaudio-service}.
19979
19980 @table @asis
19981 @item @code{client-conf} (default: @code{'()})
19982 List of settings to set in @file{client.conf}.
19983 Accepts a list of strings or a symbol-value pairs. A string will be
19984 inserted as-is with a newline added. A pair will be formatted as
19985 ``key = value'', again with a newline added.
19986
19987 @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
19988 List of settings to set in @file{daemon.conf}, formatted just like
19989 @var{client-conf}.
19990
19991 @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
19992 Script file to use as @file{default.pa}.
19993
19994 @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
19995 Script file to use as @file{system.pa}.
19996 @end table
19997 @end deftp
19998
19999 @deffn {Scheme Variable} ladspa-service-type
20000 This service sets the @var{LADSPA_PATH} variable, so that programs, which
20001 respect it, e.g. PulseAudio, can load LADSPA plugins.
20002
20003 The following example will setup the service to enable modules from the
20004 @code{swh-plugins} package:
20005
20006 @lisp
20007 (service ladspa-service-type
20008 (ladspa-configuration (plugins (list swh-plugins))))
20009 @end lisp
20010
20011 See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
20012 details.
20013
20014 @end deffn
20015
20016 @node Database Services
20017 @subsection Database Services
20018
20019 @cindex database
20020 @cindex SQL
20021 The @code{(gnu services databases)} module provides the following services.
20022
20023 @subsubheading PostgreSQL
20024
20025 The following example describes a PostgreSQL service with the default
20026 configuration.
20027
20028 @lisp
20029 (service postgresql-service-type
20030 (postgresql-configuration
20031 (postgresql postgresql-10)))
20032 @end lisp
20033
20034 If the services fails to start, it may be due to an incompatible
20035 cluster already present in @var{data-directory}. Adjust it (or, if you
20036 don't need the cluster anymore, delete @var{data-directory}), then
20037 restart the service.
20038
20039 Peer authentication is used by default and the @code{postgres} user
20040 account has no shell, which prevents the direct execution of @code{psql}
20041 commands as this user. To use @code{psql}, you can temporarily log in
20042 as @code{postgres} using a shell, create a PostgreSQL superuser with the
20043 same name as one of the system users and then create the associated
20044 database.
20045
20046 @example
20047 sudo -u postgres -s /bin/sh
20048 createuser --interactive
20049 createdb $MY_USER_LOGIN # Replace appropriately.
20050 @end example
20051
20052 @deftp {Data Type} postgresql-configuration
20053 Data type representing the configuration for the
20054 @code{postgresql-service-type}.
20055
20056 @table @asis
20057 @item @code{postgresql}
20058 PostgreSQL package to use for the service.
20059
20060 @item @code{port} (default: @code{5432})
20061 Port on which PostgreSQL should listen.
20062
20063 @item @code{locale} (default: @code{"en_US.utf8"})
20064 Locale to use as the default when creating the database cluster.
20065
20066 @item @code{config-file} (default: @code{(postgresql-config-file)})
20067 The configuration file to use when running PostgreSQL@. The default
20068 behaviour uses the postgresql-config-file record with the default values
20069 for the fields.
20070
20071 @item @code{log-directory} (default: @code{"/var/log/postgresql"})
20072 The directory where @command{pg_ctl} output will be written in a file
20073 named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
20074 configuration errors for instance.
20075
20076 @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
20077 Directory in which to store the data.
20078
20079 @item @code{extension-packages} (default: @code{'()})
20080 @cindex postgresql extension-packages
20081 Additional extensions are loaded from packages listed in
20082 @var{extension-packages}. Extensions are available at runtime. For instance,
20083 to create a geographic database using the @code{postgis} extension, a user can
20084 configure the postgresql-service as in this example:
20085
20086 @cindex postgis
20087 @lisp
20088 (use-package-modules databases geo)
20089
20090 (operating-system
20091 ...
20092 ;; postgresql is required to run `psql' but postgis is not required for
20093 ;; proper operation.
20094 (packages (cons* postgresql %base-packages))
20095 (services
20096 (cons*
20097 (service postgresql-service-type
20098 (postgresql-configuration
20099 (postgresql postgresql-10)
20100 (extension-packages (list postgis))))
20101 %base-services)))
20102 @end lisp
20103
20104 Then the extension becomes visible and you can initialise an empty geographic
20105 database in this way:
20106
20107 @example
20108 psql -U postgres
20109 > create database postgistest;
20110 > \connect postgistest;
20111 > create extension postgis;
20112 > create extension postgis_topology;
20113 @end example
20114
20115 There is no need to add this field for contrib extensions such as hstore or
20116 dblink as they are already loadable by postgresql. This field is only
20117 required to add extensions provided by other packages.
20118
20119 @end table
20120 @end deftp
20121
20122 @deftp {Data Type} postgresql-config-file
20123 Data type representing the PostgreSQL configuration file. As shown in
20124 the following example, this can be used to customize the configuration
20125 of PostgreSQL@. Note that you can use any G-expression or filename in
20126 place of this record, if you already have a configuration file you'd
20127 like to use for example.
20128
20129 @lisp
20130 (service postgresql-service-type
20131 (postgresql-configuration
20132 (config-file
20133 (postgresql-config-file
20134 (log-destination "stderr")
20135 (hba-file
20136 (plain-file "pg_hba.conf"
20137 "
20138 local all all trust
20139 host all all 127.0.0.1/32 md5
20140 host all all ::1/128 md5"))
20141 (extra-config
20142 '(("session_preload_libraries" "auto_explain")
20143 ("random_page_cost" 2)
20144 ("auto_explain.log_min_duration" "100 ms")
20145 ("work_mem" "500 MB")
20146 ("logging_collector" #t)
20147 ("log_directory" "/var/log/postgresql")))))))
20148 @end lisp
20149
20150 @table @asis
20151 @item @code{log-destination} (default: @code{"syslog"})
20152 The logging method to use for PostgreSQL@. Multiple values are accepted,
20153 separated by commas.
20154
20155 @item @code{hba-file} (default: @code{%default-postgres-hba})
20156 Filename or G-expression for the host-based authentication
20157 configuration.
20158
20159 @item @code{ident-file} (default: @code{%default-postgres-ident})
20160 Filename or G-expression for the user name mapping configuration.
20161
20162 @item @code{socket-directory} (default: @code{#false})
20163 Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
20164 is to listen for connections from client applications. If set to
20165 @code{""} PostgreSQL does not listen on any Unix-domain sockets, in
20166 which case only TCP/IP sockets can be used to connect to the server.
20167
20168 By default, the @code{#false} value means the PostgreSQL default value
20169 will be used, which is currently @samp{/tmp}.
20170
20171 @item @code{extra-config} (default: @code{'()})
20172 List of additional keys and values to include in the PostgreSQL config
20173 file. Each entry in the list should be a list where the first element
20174 is the key, and the remaining elements are the values.
20175
20176 The values can be numbers, booleans or strings and will be mapped to
20177 PostgreSQL parameters types @code{Boolean}, @code{String},
20178 @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
20179 @uref{https://www.postgresql.org/docs/current/config-setting.html,
20180 here}.
20181
20182 @end table
20183 @end deftp
20184
20185 @deffn {Scheme Variable} postgresql-role-service-type
20186 This service allows to create PostgreSQL roles and databases after
20187 PostgreSQL service start. Here is an example of its use.
20188
20189 @lisp
20190 (service postgresql-role-service-type
20191 (postgresql-role-configuration
20192 (roles
20193 (list (postgresql-role
20194 (name "test")
20195 (create-database? #t))))))
20196 @end lisp
20197
20198 This service can be extended with extra roles, as in this
20199 example:
20200
20201 @lisp
20202 (service-extension postgresql-role-service-type
20203 (const (postgresql-role
20204 (name "alice")
20205 (create-database? #t))))
20206 @end lisp
20207 @end deffn
20208
20209 @deftp {Data Type} postgresql-role
20210 PostgreSQL manages database access permissions using the concept of
20211 roles. A role can be thought of as either a database user, or a group
20212 of database users, depending on how the role is set up. Roles can own
20213 database objects (for example, tables) and can assign privileges on
20214 those objects to other roles to control who has access to which objects.
20215
20216 @table @asis
20217 @item @code{name}
20218 The role name.
20219
20220 @item @code{permissions} (default: @code{'(createdb login)})
20221 The role permissions list. Supported permissions are @code{bypassrls},
20222 @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
20223 @code{superuser}.
20224
20225 @item @code{create-database?} (default: @code{#f})
20226 Whether to create a database with the same name as the role.
20227
20228 @end table
20229 @end deftp
20230
20231 @deftp {Data Type} postgresql-role-configuration
20232 Data type representing the configuration of
20233 @var{postgresql-role-service-type}.
20234
20235 @table @asis
20236 @item @code{host} (default: @code{"/var/run/postgresql"})
20237 The PostgreSQL host to connect to.
20238
20239 @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
20240 File name of the log file.
20241
20242 @item @code{roles} (default: @code{'()})
20243 The initial PostgreSQL roles to create.
20244 @end table
20245 @end deftp
20246
20247 @subsubheading MariaDB/MySQL
20248
20249 @defvr {Scheme Variable} mysql-service-type
20250 This is the service type for a MySQL or MariaDB database server. Its value
20251 is a @code{mysql-configuration} object that specifies which package to use,
20252 as well as various settings for the @command{mysqld} daemon.
20253 @end defvr
20254
20255 @deftp {Data Type} mysql-configuration
20256 Data type representing the configuration of @var{mysql-service-type}.
20257
20258 @table @asis
20259 @item @code{mysql} (default: @var{mariadb})
20260 Package object of the MySQL database server, can be either @var{mariadb}
20261 or @var{mysql}.
20262
20263 For MySQL, a temporary root password will be displayed at activation time.
20264 For MariaDB, the root password is empty.
20265
20266 @item @code{bind-address} (default: @code{"127.0.0.1"})
20267 The IP on which to listen for network connections. Use @code{"0.0.0.0"}
20268 to bind to all available network interfaces.
20269
20270 @item @code{port} (default: @code{3306})
20271 TCP port on which the database server listens for incoming connections.
20272
20273 @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
20274 Socket file to use for local (non-network) connections.
20275
20276 @item @code{extra-content} (default: @code{""})
20277 Additional settings for the @file{my.cnf} configuration file.
20278
20279 @item @code{extra-environment} (default: @code{#~'()})
20280 List of environment variables passed to the @command{mysqld} process.
20281
20282 @item @code{auto-upgrade?} (default: @code{#t})
20283 Whether to automatically run @command{mysql_upgrade} after starting the
20284 service. This is necessary to upgrade the @dfn{system schema} after
20285 ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
20286 be disabled if you would rather do that manually.
20287
20288 @end table
20289 @end deftp
20290
20291 @subsubheading Memcached
20292
20293 @defvr {Scheme Variable} memcached-service-type
20294 This is the service type for the @uref{https://memcached.org/,
20295 Memcached} service, which provides a distributed in memory cache. The
20296 value for the service type is a @code{memcached-configuration} object.
20297 @end defvr
20298
20299 @lisp
20300 (service memcached-service-type)
20301 @end lisp
20302
20303 @deftp {Data Type} memcached-configuration
20304 Data type representing the configuration of memcached.
20305
20306 @table @asis
20307 @item @code{memcached} (default: @code{memcached})
20308 The Memcached package to use.
20309
20310 @item @code{interfaces} (default: @code{'("0.0.0.0")})
20311 Network interfaces on which to listen.
20312
20313 @item @code{tcp-port} (default: @code{11211})
20314 Port on which to accept connections.
20315
20316 @item @code{udp-port} (default: @code{11211})
20317 Port on which to accept UDP connections on, a value of 0 will disable
20318 listening on a UDP socket.
20319
20320 @item @code{additional-options} (default: @code{'()})
20321 Additional command line options to pass to @code{memcached}.
20322 @end table
20323 @end deftp
20324
20325 @subsubheading Redis
20326
20327 @defvr {Scheme Variable} redis-service-type
20328 This is the service type for the @uref{https://redis.io/, Redis}
20329 key/value store, whose value is a @code{redis-configuration} object.
20330 @end defvr
20331
20332 @deftp {Data Type} redis-configuration
20333 Data type representing the configuration of redis.
20334
20335 @table @asis
20336 @item @code{redis} (default: @code{redis})
20337 The Redis package to use.
20338
20339 @item @code{bind} (default: @code{"127.0.0.1"})
20340 Network interface on which to listen.
20341
20342 @item @code{port} (default: @code{6379})
20343 Port on which to accept connections on, a value of 0 will disable
20344 listening on a TCP socket.
20345
20346 @item @code{working-directory} (default: @code{"/var/lib/redis"})
20347 Directory in which to store the database and related files.
20348 @end table
20349 @end deftp
20350
20351 @node Mail Services
20352 @subsection Mail Services
20353
20354 @cindex mail
20355 @cindex email
20356 The @code{(gnu services mail)} module provides Guix service definitions
20357 for email services: IMAP, POP3, and LMTP servers, as well as mail
20358 transport agents (MTAs). Lots of acronyms! These services are detailed
20359 in the subsections below.
20360
20361 @subsubheading Dovecot Service
20362
20363 @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
20364 Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
20365 @end deffn
20366
20367 By default, Dovecot does not need much configuration; the default
20368 configuration object created by @code{(dovecot-configuration)} will
20369 suffice if your mail is delivered to @code{~/Maildir}. A self-signed
20370 certificate will be generated for TLS-protected connections, though
20371 Dovecot will also listen on cleartext ports by default. There are a
20372 number of options, though, which mail administrators might need to change,
20373 and as is the case with other services, Guix allows the system
20374 administrator to specify these parameters via a uniform Scheme interface.
20375
20376 For example, to specify that mail is located at @code{maildir~/.mail},
20377 one would instantiate the Dovecot service like this:
20378
20379 @lisp
20380 (dovecot-service #:config
20381 (dovecot-configuration
20382 (mail-location "maildir:~/.mail")))
20383 @end lisp
20384
20385 The available configuration parameters follow. Each parameter
20386 definition is preceded by its type; for example, @samp{string-list foo}
20387 indicates that the @code{foo} parameter should be specified as a list of
20388 strings. There is also a way to specify the configuration as a string,
20389 if you have an old @code{dovecot.conf} file that you want to port over
20390 from some other system; see the end for more details.
20391
20392 @c The following documentation was initially generated by
20393 @c (generate-documentation) in (gnu services mail). Manually maintained
20394 @c documentation is better, so we shouldn't hesitate to edit below as
20395 @c needed. However if the change you want to make to this documentation
20396 @c can be done in an automated way, it's probably easier to change
20397 @c (generate-documentation) than to make it below and have to deal with
20398 @c the churn as dovecot updates.
20399
20400 Available @code{dovecot-configuration} fields are:
20401
20402 @deftypevr {@code{dovecot-configuration} parameter} package dovecot
20403 The dovecot package.
20404 @end deftypevr
20405
20406 @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
20407 A list of IPs or hosts where to listen for connections. @samp{*}
20408 listens on all IPv4 interfaces, @samp{::} listens on all IPv6
20409 interfaces. If you want to specify non-default ports or anything more
20410 complex, customize the address and port fields of the
20411 @samp{inet-listener} of the specific services you are interested in.
20412 @end deftypevr
20413
20414 @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
20415 List of protocols we want to serve. Available protocols include
20416 @samp{imap}, @samp{pop3}, and @samp{lmtp}.
20417
20418 Available @code{protocol-configuration} fields are:
20419
20420 @deftypevr {@code{protocol-configuration} parameter} string name
20421 The name of the protocol.
20422 @end deftypevr
20423
20424 @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
20425 UNIX socket path to the master authentication server to find users.
20426 This is used by imap (for shared users) and lda.
20427 It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
20428 @end deftypevr
20429
20430 @deftypevr {@code{protocol-configuration} parameter} boolean imap-metadata?
20431 Whether to enable the @code{IMAP METADATA} extension as defined in
20432 @uref{https://tools.ietf.org/html/rfc5464,RFC@tie{}5464}, which provides
20433 a means for clients to set and retrieve per-mailbox, per-user metadata
20434 and annotations over IMAP.
20435
20436 If this is @samp{#t}, you must also specify a dictionary @i{via} the
20437 @code{mail-attribute-dict} setting.
20438
20439 Defaults to @samp{#f}.
20440
20441 @end deftypevr
20442
20443 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-notify-capabilities
20444 Which NOTIFY capabilities to report to clients that first connect to
20445 the ManageSieve service, before authentication. These may differ from the
20446 capabilities offered to authenticated users. If this field is left empty,
20447 report what the Sieve interpreter supports by default.
20448
20449 Defaults to @samp{()}.
20450 @end deftypevr
20451
20452 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-sieve-capability
20453 Which SIEVE capabilities to report to clients that first connect to
20454 the ManageSieve service, before authentication. These may differ from the
20455 capabilities offered to authenticated users. If this field is left empty,
20456 report what the Sieve interpreter supports by default.
20457
20458 Defaults to @samp{()}.
20459
20460 @end deftypevr
20461
20462 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
20463 Space separated list of plugins to load.
20464 @end deftypevr
20465
20466 @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
20467 Maximum number of IMAP connections allowed for a user from each IP
20468 address. NOTE: The username is compared case-sensitively.
20469 Defaults to @samp{10}.
20470 @end deftypevr
20471
20472 @end deftypevr
20473
20474 @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
20475 List of services to enable. Available services include @samp{imap},
20476 @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
20477 @samp{lmtp}.
20478
20479 Available @code{service-configuration} fields are:
20480
20481 @deftypevr {@code{service-configuration} parameter} string kind
20482 The service kind. Valid values include @code{director},
20483 @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
20484 @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
20485 @code{tcpwrap}, @code{quota-warning}, or anything else.
20486 @end deftypevr
20487
20488 @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
20489 Listeners for the service. A listener is either a
20490 @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
20491 an @code{inet-listener-configuration}.
20492 Defaults to @samp{()}.
20493
20494 Available @code{unix-listener-configuration} fields are:
20495
20496 @deftypevr {@code{unix-listener-configuration} parameter} string path
20497 Path to the file, relative to @code{base-dir} field. This is also used as
20498 the section name.
20499 @end deftypevr
20500
20501 @deftypevr {@code{unix-listener-configuration} parameter} string mode
20502 The access mode for the socket.
20503 Defaults to @samp{"0600"}.
20504 @end deftypevr
20505
20506 @deftypevr {@code{unix-listener-configuration} parameter} string user
20507 The user to own the socket.
20508 Defaults to @samp{""}.
20509 @end deftypevr
20510
20511 @deftypevr {@code{unix-listener-configuration} parameter} string group
20512 The group to own the socket.
20513 Defaults to @samp{""}.
20514 @end deftypevr
20515
20516
20517 Available @code{fifo-listener-configuration} fields are:
20518
20519 @deftypevr {@code{fifo-listener-configuration} parameter} string path
20520 Path to the file, relative to @code{base-dir} field. This is also used as
20521 the section name.
20522 @end deftypevr
20523
20524 @deftypevr {@code{fifo-listener-configuration} parameter} string mode
20525 The access mode for the socket.
20526 Defaults to @samp{"0600"}.
20527 @end deftypevr
20528
20529 @deftypevr {@code{fifo-listener-configuration} parameter} string user
20530 The user to own the socket.
20531 Defaults to @samp{""}.
20532 @end deftypevr
20533
20534 @deftypevr {@code{fifo-listener-configuration} parameter} string group
20535 The group to own the socket.
20536 Defaults to @samp{""}.
20537 @end deftypevr
20538
20539
20540 Available @code{inet-listener-configuration} fields are:
20541
20542 @deftypevr {@code{inet-listener-configuration} parameter} string protocol
20543 The protocol to listen for.
20544 @end deftypevr
20545
20546 @deftypevr {@code{inet-listener-configuration} parameter} string address
20547 The address on which to listen, or empty for all addresses.
20548 Defaults to @samp{""}.
20549 @end deftypevr
20550
20551 @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
20552 The port on which to listen.
20553 @end deftypevr
20554
20555 @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
20556 Whether to use SSL for this service; @samp{yes}, @samp{no}, or
20557 @samp{required}.
20558 Defaults to @samp{#t}.
20559 @end deftypevr
20560
20561 @end deftypevr
20562
20563 @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
20564 Maximum number of simultaneous client connections per process. Once
20565 this number of connections is received, the next incoming connection
20566 will prompt Dovecot to spawn another process. If set to 0,
20567 @code{default-client-limit} is used instead.
20568
20569 Defaults to @samp{0}.
20570
20571 @end deftypevr
20572
20573 @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
20574 Number of connections to handle before starting a new process.
20575 Typically the only useful values are 0 (unlimited) or 1. 1 is more
20576 secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
20577 Defaults to @samp{1}.
20578
20579 @end deftypevr
20580
20581 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
20582 Maximum number of processes that can exist for this service. If set to
20583 0, @code{default-process-limit} is used instead.
20584
20585 Defaults to @samp{0}.
20586
20587 @end deftypevr
20588
20589 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
20590 Number of processes to always keep waiting for more connections.
20591 Defaults to @samp{0}.
20592 @end deftypevr
20593
20594 @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
20595 If you set @samp{service-count 0}, you probably need to grow
20596 this.
20597 Defaults to @samp{256000000}.
20598 @end deftypevr
20599
20600 @end deftypevr
20601
20602 @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
20603 Dict configuration, as created by the @code{dict-configuration}
20604 constructor.
20605
20606 Available @code{dict-configuration} fields are:
20607
20608 @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
20609 A list of key-value pairs that this dict should hold.
20610 Defaults to @samp{()}.
20611 @end deftypevr
20612
20613 @end deftypevr
20614
20615 @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
20616 A list of passdb configurations, each one created by the
20617 @code{passdb-configuration} constructor.
20618
20619 Available @code{passdb-configuration} fields are:
20620
20621 @deftypevr {@code{passdb-configuration} parameter} string driver
20622 The driver that the passdb should use. Valid values include
20623 @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
20624 @samp{static}.
20625 Defaults to @samp{"pam"}.
20626 @end deftypevr
20627
20628 @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
20629 Space separated list of arguments to the passdb driver.
20630 Defaults to @samp{""}.
20631 @end deftypevr
20632
20633 @end deftypevr
20634
20635 @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
20636 List of userdb configurations, each one created by the
20637 @code{userdb-configuration} constructor.
20638
20639 Available @code{userdb-configuration} fields are:
20640
20641 @deftypevr {@code{userdb-configuration} parameter} string driver
20642 The driver that the userdb should use. Valid values include
20643 @samp{passwd} and @samp{static}.
20644 Defaults to @samp{"passwd"}.
20645 @end deftypevr
20646
20647 @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
20648 Space separated list of arguments to the userdb driver.
20649 Defaults to @samp{""}.
20650 @end deftypevr
20651
20652 @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
20653 Override fields from passwd.
20654 Defaults to @samp{()}.
20655 @end deftypevr
20656
20657 @end deftypevr
20658
20659 @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
20660 Plug-in configuration, created by the @code{plugin-configuration}
20661 constructor.
20662 @end deftypevr
20663
20664 @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
20665 List of namespaces. Each item in the list is created by the
20666 @code{namespace-configuration} constructor.
20667
20668 Available @code{namespace-configuration} fields are:
20669
20670 @deftypevr {@code{namespace-configuration} parameter} string name
20671 Name for this namespace.
20672 @end deftypevr
20673
20674 @deftypevr {@code{namespace-configuration} parameter} string type
20675 Namespace type: @samp{private}, @samp{shared} or @samp{public}.
20676 Defaults to @samp{"private"}.
20677 @end deftypevr
20678
20679 @deftypevr {@code{namespace-configuration} parameter} string separator
20680 Hierarchy separator to use. You should use the same separator for
20681 all namespaces or some clients get confused. @samp{/} is usually a good
20682 one. The default however depends on the underlying mail storage
20683 format.
20684 Defaults to @samp{""}.
20685 @end deftypevr
20686
20687 @deftypevr {@code{namespace-configuration} parameter} string prefix
20688 Prefix required to access this namespace. This needs to be
20689 different for all namespaces. For example @samp{Public/}.
20690 Defaults to @samp{""}.
20691 @end deftypevr
20692
20693 @deftypevr {@code{namespace-configuration} parameter} string location
20694 Physical location of the mailbox. This is in the same format as
20695 mail_location, which is also the default for it.
20696 Defaults to @samp{""}.
20697 @end deftypevr
20698
20699 @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
20700 There can be only one INBOX, and this setting defines which
20701 namespace has it.
20702 Defaults to @samp{#f}.
20703 @end deftypevr
20704
20705 @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
20706 If namespace is hidden, it's not advertised to clients via NAMESPACE
20707 extension. You'll most likely also want to set @samp{list? #f}. This is mostly
20708 useful when converting from another server with different namespaces
20709 which you want to deprecate but still keep working. For example you can
20710 create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
20711 and @samp{mail/}.
20712 Defaults to @samp{#f}.
20713 @end deftypevr
20714
20715 @deftypevr {@code{namespace-configuration} parameter} boolean list?
20716 Show the mailboxes under this namespace with the LIST command. This
20717 makes the namespace visible for clients that do not support the NAMESPACE
20718 extension. The special @code{children} value lists child mailboxes, but
20719 hides the namespace prefix.
20720 Defaults to @samp{#t}.
20721 @end deftypevr
20722
20723 @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
20724 Namespace handles its own subscriptions. If set to @code{#f}, the
20725 parent namespace handles them. The empty prefix should always have this
20726 as @code{#t}).
20727 Defaults to @samp{#t}.
20728 @end deftypevr
20729
20730 @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
20731 List of predefined mailboxes in this namespace.
20732 Defaults to @samp{()}.
20733
20734 Available @code{mailbox-configuration} fields are:
20735
20736 @deftypevr {@code{mailbox-configuration} parameter} string name
20737 Name for this mailbox.
20738 @end deftypevr
20739
20740 @deftypevr {@code{mailbox-configuration} parameter} string auto
20741 @samp{create} will automatically create this mailbox.
20742 @samp{subscribe} will both create and subscribe to the mailbox.
20743 Defaults to @samp{"no"}.
20744 @end deftypevr
20745
20746 @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
20747 List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
20748 Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
20749 @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
20750 Defaults to @samp{()}.
20751 @end deftypevr
20752
20753 @end deftypevr
20754
20755 @end deftypevr
20756
20757 @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
20758 Base directory where to store runtime data.
20759 Defaults to @samp{"/var/run/dovecot/"}.
20760 @end deftypevr
20761
20762 @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
20763 Greeting message for clients.
20764 Defaults to @samp{"Dovecot ready."}.
20765 @end deftypevr
20766
20767 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
20768 List of trusted network ranges. Connections from these IPs are
20769 allowed to override their IP addresses and ports (for logging and for
20770 authentication checks). @samp{disable-plaintext-auth} is also ignored
20771 for these networks. Typically you would specify your IMAP proxy servers
20772 here.
20773 Defaults to @samp{()}.
20774 @end deftypevr
20775
20776 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
20777 List of login access check sockets (e.g.@: tcpwrap).
20778 Defaults to @samp{()}.
20779 @end deftypevr
20780
20781 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
20782 Show more verbose process titles (in ps). Currently shows user name
20783 and IP address. Useful for seeing who is actually using the IMAP
20784 processes (e.g.@: shared mailboxes or if the same uid is used for multiple
20785 accounts).
20786 Defaults to @samp{#f}.
20787 @end deftypevr
20788
20789 @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
20790 Should all processes be killed when Dovecot master process shuts down.
20791 Setting this to @code{#f} means that Dovecot can be upgraded without
20792 forcing existing client connections to close (although that could also
20793 be a problem if the upgrade is e.g.@: due to a security fix).
20794 Defaults to @samp{#t}.
20795 @end deftypevr
20796
20797 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
20798 If non-zero, run mail commands via this many connections to doveadm
20799 server, instead of running them directly in the same process.
20800 Defaults to @samp{0}.
20801 @end deftypevr
20802
20803 @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
20804 UNIX socket or host:port used for connecting to doveadm server.
20805 Defaults to @samp{"doveadm-server"}.
20806 @end deftypevr
20807
20808 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
20809 List of environment variables that are preserved on Dovecot startup
20810 and passed down to all of its child processes. You can also give
20811 key=value pairs to always set specific settings.
20812 @end deftypevr
20813
20814 @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
20815 Disable LOGIN command and all other plaintext authentications unless
20816 SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
20817 matches the local IP (i.e.@: you're connecting from the same computer),
20818 the connection is considered secure and plaintext authentication is
20819 allowed. See also ssl=required setting.
20820 Defaults to @samp{#t}.
20821 @end deftypevr
20822
20823 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
20824 Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
20825 Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
20826 for caching to be used.
20827 Defaults to @samp{0}.
20828 @end deftypevr
20829
20830 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
20831 Time to live for cached data. After TTL expires the cached record
20832 is no longer used, *except* if the main database lookup returns internal
20833 failure. We also try to handle password changes automatically: If
20834 user's previous authentication was successful, but this one wasn't, the
20835 cache isn't used. For now this works only with plaintext
20836 authentication.
20837 Defaults to @samp{"1 hour"}.
20838 @end deftypevr
20839
20840 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
20841 TTL for negative hits (user not found, password mismatch).
20842 0 disables caching them completely.
20843 Defaults to @samp{"1 hour"}.
20844 @end deftypevr
20845
20846 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
20847 List of realms for SASL authentication mechanisms that need them.
20848 You can leave it empty if you don't want to support multiple realms.
20849 Many clients simply use the first one listed here, so keep the default
20850 realm first.
20851 Defaults to @samp{()}.
20852 @end deftypevr
20853
20854 @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
20855 Default realm/domain to use if none was specified. This is used for
20856 both SASL realms and appending @@domain to username in plaintext
20857 logins.
20858 Defaults to @samp{""}.
20859 @end deftypevr
20860
20861 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
20862 List of allowed characters in username. If the user-given username
20863 contains a character not listed in here, the login automatically fails.
20864 This is just an extra check to make sure user can't exploit any
20865 potential quote escaping vulnerabilities with SQL/LDAP databases. If
20866 you want to allow all characters, set this value to empty.
20867 Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
20868 @end deftypevr
20869
20870 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
20871 Username character translations before it's looked up from
20872 databases. The value contains series of from -> to characters. For
20873 example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
20874 translated to @samp{@@}.
20875 Defaults to @samp{""}.
20876 @end deftypevr
20877
20878 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
20879 Username formatting before it's looked up from databases. You can
20880 use the standard variables here, e.g.@: %Lu would lowercase the username,
20881 %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
20882 change the @samp{@@} into @samp{-AT-}. This translation is done after
20883 @samp{auth-username-translation} changes.
20884 Defaults to @samp{"%Lu"}.
20885 @end deftypevr
20886
20887 @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
20888 If you want to allow master users to log in by specifying the master
20889 username within the normal username string (i.e.@: not using SASL
20890 mechanism's support for it), you can specify the separator character
20891 here. The format is then <username><separator><master username>.
20892 UW-IMAP uses @samp{*} as the separator, so that could be a good
20893 choice.
20894 Defaults to @samp{""}.
20895 @end deftypevr
20896
20897 @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
20898 Username to use for users logging in with ANONYMOUS SASL
20899 mechanism.
20900 Defaults to @samp{"anonymous"}.
20901 @end deftypevr
20902
20903 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
20904 Maximum number of dovecot-auth worker processes. They're used to
20905 execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
20906 They're automatically created and destroyed as needed.
20907 Defaults to @samp{30}.
20908 @end deftypevr
20909
20910 @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
20911 Host name to use in GSSAPI principal names. The default is to use
20912 the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
20913 allow all keytab entries.
20914 Defaults to @samp{""}.
20915 @end deftypevr
20916
20917 @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
20918 Kerberos keytab to use for the GSSAPI mechanism. Will use the
20919 system default (usually @file{/etc/krb5.keytab}) if not specified. You may
20920 need to change the auth service to run as root to be able to read this
20921 file.
20922 Defaults to @samp{""}.
20923 @end deftypevr
20924
20925 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
20926 Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
20927 and @samp{ntlm-auth} helper.
20928 <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
20929 Defaults to @samp{#f}.
20930 @end deftypevr
20931
20932 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
20933 Path for Samba's @samp{ntlm-auth} helper binary.
20934 Defaults to @samp{"/usr/bin/ntlm_auth"}.
20935 @end deftypevr
20936
20937 @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
20938 Time to delay before replying to failed authentications.
20939 Defaults to @samp{"2 secs"}.
20940 @end deftypevr
20941
20942 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
20943 Require a valid SSL client certificate or the authentication
20944 fails.
20945 Defaults to @samp{#f}.
20946 @end deftypevr
20947
20948 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
20949 Take the username from client's SSL certificate, using
20950 @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
20951 CommonName.
20952 Defaults to @samp{#f}.
20953 @end deftypevr
20954
20955 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
20956 List of wanted authentication mechanisms. Supported mechanisms are:
20957 @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
20958 @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
20959 @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
20960 @samp{disable-plaintext-auth} setting.
20961 @end deftypevr
20962
20963 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
20964 List of IPs or hostnames to all director servers, including ourself.
20965 Ports can be specified as ip:port. The default port is the same as what
20966 director service's @samp{inet-listener} is using.
20967 Defaults to @samp{()}.
20968 @end deftypevr
20969
20970 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
20971 List of IPs or hostnames to all backend mail servers. Ranges are
20972 allowed too, like 10.0.0.10-10.0.0.30.
20973 Defaults to @samp{()}.
20974 @end deftypevr
20975
20976 @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
20977 How long to redirect users to a specific server after it no longer
20978 has any connections.
20979 Defaults to @samp{"15 min"}.
20980 @end deftypevr
20981
20982 @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
20983 How the username is translated before being hashed. Useful values
20984 include %Ln if user can log in with or without @@domain, %Ld if mailboxes
20985 are shared within domain.
20986 Defaults to @samp{"%Lu"}.
20987 @end deftypevr
20988
20989 @deftypevr {@code{dovecot-configuration} parameter} string log-path
20990 Log file to use for error messages. @samp{syslog} logs to syslog,
20991 @samp{/dev/stderr} logs to stderr.
20992 Defaults to @samp{"syslog"}.
20993 @end deftypevr
20994
20995 @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
20996 Log file to use for informational messages. Defaults to
20997 @samp{log-path}.
20998 Defaults to @samp{""}.
20999 @end deftypevr
21000
21001 @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
21002 Log file to use for debug messages. Defaults to
21003 @samp{info-log-path}.
21004 Defaults to @samp{""}.
21005 @end deftypevr
21006
21007 @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
21008 Syslog facility to use if you're logging to syslog. Usually if you
21009 don't want to use @samp{mail}, you'll use local0..local7. Also other
21010 standard facilities are supported.
21011 Defaults to @samp{"mail"}.
21012 @end deftypevr
21013
21014 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
21015 Log unsuccessful authentication attempts and the reasons why they
21016 failed.
21017 Defaults to @samp{#f}.
21018 @end deftypevr
21019
21020 @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
21021 In case of password mismatches, log the attempted password. Valid
21022 values are no, plain and sha1. sha1 can be useful for detecting brute
21023 force password attempts vs. user simply trying the same password over
21024 and over again. You can also truncate the value to n chars by appending
21025 ":n" (e.g.@: sha1:6).
21026 Defaults to @samp{"no"}.
21027 @end deftypevr
21028
21029 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
21030 Even more verbose logging for debugging purposes. Shows for example
21031 SQL queries.
21032 Defaults to @samp{#f}.
21033 @end deftypevr
21034
21035 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
21036 In case of password mismatches, log the passwords and used scheme so
21037 the problem can be debugged. Enabling this also enables
21038 @samp{auth-debug}.
21039 Defaults to @samp{#f}.
21040 @end deftypevr
21041
21042 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
21043 Enable mail process debugging. This can help you figure out why
21044 Dovecot isn't finding your mails.
21045 Defaults to @samp{#f}.
21046 @end deftypevr
21047
21048 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
21049 Show protocol level SSL errors.
21050 Defaults to @samp{#f}.
21051 @end deftypevr
21052
21053 @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
21054 Prefix for each line written to log file. % codes are in
21055 strftime(3) format.
21056 Defaults to @samp{"\"%b %d %H:%M:%S \""}.
21057 @end deftypevr
21058
21059 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
21060 List of elements we want to log. The elements which have a
21061 non-empty variable value are joined together to form a comma-separated
21062 string.
21063 @end deftypevr
21064
21065 @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
21066 Login log format. %s contains @samp{login-log-format-elements}
21067 string, %$ contains the data we want to log.
21068 Defaults to @samp{"%$: %s"}.
21069 @end deftypevr
21070
21071 @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
21072 Log prefix for mail processes. See doc/wiki/Variables.txt for list
21073 of possible variables you can use.
21074 Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
21075 @end deftypevr
21076
21077 @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
21078 Format to use for logging mail deliveries. You can use variables:
21079 @table @code
21080 @item %$
21081 Delivery status message (e.g.@: @samp{saved to INBOX})
21082 @item %m
21083 Message-ID
21084 @item %s
21085 Subject
21086 @item %f
21087 From address
21088 @item %p
21089 Physical size
21090 @item %w
21091 Virtual size.
21092 @end table
21093 Defaults to @samp{"msgid=%m: %$"}.
21094 @end deftypevr
21095
21096 @deftypevr {@code{dovecot-configuration} parameter} string mail-location
21097 Location for users' mailboxes. The default is empty, which means
21098 that Dovecot tries to find the mailboxes automatically. This won't work
21099 if the user doesn't yet have any mail, so you should explicitly tell
21100 Dovecot the full location.
21101
21102 If you're using mbox, giving a path to the INBOX
21103 file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
21104 where the other mailboxes are kept. This is called the @emph{root mail
21105 directory}, and it must be the first path given in the
21106 @samp{mail-location} setting.
21107
21108 There are a few special variables you can use, e.g.:
21109
21110 @table @samp
21111 @item %u
21112 username
21113 @item %n
21114 user part in user@@domain, same as %u if there's no domain
21115 @item %d
21116 domain part in user@@domain, empty if there's no domain
21117 @item %h
21118 home director
21119 @end table
21120
21121 See doc/wiki/Variables.txt for full list. Some examples:
21122 @table @samp
21123 @item maildir:~/Maildir
21124 @item mbox:~/mail:INBOX=/var/mail/%u
21125 @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
21126 @end table
21127 Defaults to @samp{""}.
21128 @end deftypevr
21129
21130 @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
21131 System user and group used to access mails. If you use multiple,
21132 userdb can override these by returning uid or gid fields. You can use
21133 either numbers or names. <doc/wiki/UserIds.txt>.
21134 Defaults to @samp{""}.
21135 @end deftypevr
21136
21137 @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
21138
21139 Defaults to @samp{""}.
21140 @end deftypevr
21141
21142 @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
21143 Group to enable temporarily for privileged operations. Currently
21144 this is used only with INBOX when either its initial creation or
21145 dotlocking fails. Typically this is set to @samp{"mail"} to give access to
21146 @file{/var/mail}.
21147 Defaults to @samp{""}.
21148 @end deftypevr
21149
21150 @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
21151 Grant access to these supplementary groups for mail processes.
21152 Typically these are used to set up access to shared mailboxes. Note
21153 that it may be dangerous to set these if users can create symlinks
21154 (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
21155 could allow a user to delete others' mailboxes, or @code{ln -s
21156 /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
21157 @samp{""}.
21158 @end deftypevr
21159
21160 @deftypevr {@code{dovecot-configuration} parameter} string mail-attribute-dict
21161 The location of a dictionary used to store @code{IMAP METADATA}
21162 as defined by @uref{https://tools.ietf.org/html/rfc5464, RFC@tie{}5464}.
21163
21164 The IMAP METADATA commands are available only if the ``imap''
21165 protocol configuration's @code{imap-metadata?} field is @samp{#t}.
21166
21167 Defaults to @samp{""}.
21168
21169 @end deftypevr
21170
21171 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
21172 Allow full file system access to clients. There's no access checks
21173 other than what the operating system does for the active UID/GID@. It
21174 works with both maildir and mboxes, allowing you to prefix mailboxes
21175 names with e.g.@: @file{/path/} or @file{~user/}.
21176 Defaults to @samp{#f}.
21177 @end deftypevr
21178
21179 @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
21180 Don't use @code{mmap()} at all. This is required if you store indexes to
21181 shared file systems (NFS or clustered file system).
21182 Defaults to @samp{#f}.
21183 @end deftypevr
21184
21185 @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
21186 Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
21187 supports @samp{O_EXCL} since version 3, so this should be safe to use
21188 nowadays by default.
21189 Defaults to @samp{#t}.
21190 @end deftypevr
21191
21192 @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
21193 When to use fsync() or fdatasync() calls:
21194 @table @code
21195 @item optimized
21196 Whenever necessary to avoid losing important data
21197 @item always
21198 Useful with e.g.@: NFS when @code{write()}s are delayed
21199 @item never
21200 Never use it (best performance, but crashes can lose data).
21201 @end table
21202 Defaults to @samp{"optimized"}.
21203 @end deftypevr
21204
21205 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
21206 Mail storage exists in NFS@. Set this to yes to make Dovecot flush
21207 NFS caches whenever needed. If you're using only a single mail server
21208 this isn't needed.
21209 Defaults to @samp{#f}.
21210 @end deftypevr
21211
21212 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
21213 Mail index files also exist in NFS@. Setting this to yes requires
21214 @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
21215 Defaults to @samp{#f}.
21216 @end deftypevr
21217
21218 @deftypevr {@code{dovecot-configuration} parameter} string lock-method
21219 Locking method for index files. Alternatives are fcntl, flock and
21220 dotlock. Dotlocking uses some tricks which may create more disk I/O
21221 than other locking methods. NFS users: flock doesn't work, remember to
21222 change @samp{mmap-disable}.
21223 Defaults to @samp{"fcntl"}.
21224 @end deftypevr
21225
21226 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
21227 Directory in which LDA/LMTP temporarily stores incoming mails >128
21228 kB.
21229 Defaults to @samp{"/tmp"}.
21230 @end deftypevr
21231
21232 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
21233 Valid UID range for users. This is mostly to make sure that users can't
21234 log in as daemons or other system users. Note that denying root logins is
21235 hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
21236 is set to 0.
21237 Defaults to @samp{500}.
21238 @end deftypevr
21239
21240 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
21241
21242 Defaults to @samp{0}.
21243 @end deftypevr
21244
21245 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
21246 Valid GID range for users. Users having non-valid GID as primary group ID
21247 aren't allowed to log in. If user belongs to supplementary groups with
21248 non-valid GIDs, those groups are not set.
21249 Defaults to @samp{1}.
21250 @end deftypevr
21251
21252 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
21253
21254 Defaults to @samp{0}.
21255 @end deftypevr
21256
21257 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
21258 Maximum allowed length for mail keyword name. It's only forced when
21259 trying to create new keywords.
21260 Defaults to @samp{50}.
21261 @end deftypevr
21262
21263 @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
21264 List of directories under which chrooting is allowed for mail
21265 processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
21266 too). This setting doesn't affect @samp{login-chroot}
21267 @samp{mail-chroot} or auth chroot settings. If this setting is empty,
21268 @samp{/./} in home dirs are ignored. WARNING: Never add directories here
21269 which local users can modify, that may lead to root exploit. Usually
21270 this should be done only if you don't allow shell access for users.
21271 <doc/wiki/Chrooting.txt>.
21272 Defaults to @samp{()}.
21273 @end deftypevr
21274
21275 @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
21276 Default chroot directory for mail processes. This can be overridden
21277 for specific users in user database by giving @samp{/./} in user's home
21278 directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
21279 there is no real need to do chrooting, Dovecot doesn't allow users to
21280 access files outside their mail directory anyway. If your home
21281 directories are prefixed with the chroot directory, append @samp{/.} to
21282 @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
21283 Defaults to @samp{""}.
21284 @end deftypevr
21285
21286 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
21287 UNIX socket path to master authentication server to find users.
21288 This is used by imap (for shared users) and lda.
21289 Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
21290 @end deftypevr
21291
21292 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
21293 Directory where to look up mail plugins.
21294 Defaults to @samp{"/usr/lib/dovecot"}.
21295 @end deftypevr
21296
21297 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
21298 List of plugins to load for all services. Plugins specific to IMAP,
21299 LDA, etc.@: are added to this list in their own .conf files.
21300 Defaults to @samp{()}.
21301 @end deftypevr
21302
21303 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
21304 The minimum number of mails in a mailbox before updates are done to
21305 cache file. This allows optimizing Dovecot's behavior to do less disk
21306 writes at the cost of more disk reads.
21307 Defaults to @samp{0}.
21308 @end deftypevr
21309
21310 @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
21311 When IDLE command is running, mailbox is checked once in a while to
21312 see if there are any new mails or other changes. This setting defines
21313 the minimum time to wait between those checks. Dovecot can also use
21314 dnotify, inotify and kqueue to find out immediately when changes
21315 occur.
21316 Defaults to @samp{"30 secs"}.
21317 @end deftypevr
21318
21319 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
21320 Save mails with CR+LF instead of plain LF@. This makes sending those
21321 mails take less CPU, especially with sendfile() syscall with Linux and
21322 FreeBSD@. But it also creates a bit more disk I/O which may just make it
21323 slower. Also note that if other software reads the mboxes/maildirs,
21324 they may handle the extra CRs wrong and cause problems.
21325 Defaults to @samp{#f}.
21326 @end deftypevr
21327
21328 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
21329 By default LIST command returns all entries in maildir beginning
21330 with a dot. Enabling this option makes Dovecot return only entries
21331 which are directories. This is done by stat()ing each entry, so it
21332 causes more disk I/O.
21333 (For systems setting struct @samp{dirent->d_type} this check is free
21334 and it's done always regardless of this setting).
21335 Defaults to @samp{#f}.
21336 @end deftypevr
21337
21338 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
21339 When copying a message, do it with hard links whenever possible.
21340 This makes the performance much better, and it's unlikely to have any
21341 side effects.
21342 Defaults to @samp{#t}.
21343 @end deftypevr
21344
21345 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
21346 Assume Dovecot is the only MUA accessing Maildir: Scan cur/
21347 directory only when its mtime changes unexpectedly or when we can't find
21348 the mail otherwise.
21349 Defaults to @samp{#f}.
21350 @end deftypevr
21351
21352 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
21353 Which locking methods to use for locking mbox. There are four
21354 available:
21355
21356 @table @code
21357 @item dotlock
21358 Create <mailbox>.lock file. This is the oldest and most NFS-safe
21359 solution. If you want to use /var/mail/ like directory, the users will
21360 need write access to that directory.
21361 @item dotlock-try
21362 Same as dotlock, but if it fails because of permissions or because there
21363 isn't enough disk space, just skip it.
21364 @item fcntl
21365 Use this if possible. Works with NFS too if lockd is used.
21366 @item flock
21367 May not exist in all systems. Doesn't work with NFS.
21368 @item lockf
21369 May not exist in all systems. Doesn't work with NFS.
21370 @end table
21371
21372 You can use multiple locking methods; if you do the order they're declared
21373 in is important to avoid deadlocks if other MTAs/MUAs are using multiple
21374 locking methods as well. Some operating systems don't allow using some of
21375 them simultaneously.
21376 @end deftypevr
21377
21378 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
21379
21380 @end deftypevr
21381
21382 @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
21383 Maximum time to wait for lock (all of them) before aborting.
21384 Defaults to @samp{"5 mins"}.
21385 @end deftypevr
21386
21387 @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
21388 If dotlock exists but the mailbox isn't modified in any way,
21389 override the lock file after this much time.
21390 Defaults to @samp{"2 mins"}.
21391 @end deftypevr
21392
21393 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
21394 When mbox changes unexpectedly we have to fully read it to find out
21395 what changed. If the mbox is large this can take a long time. Since
21396 the change is usually just a newly appended mail, it'd be faster to
21397 simply read the new mails. If this setting is enabled, Dovecot does
21398 this but still safely fallbacks to re-reading the whole mbox file
21399 whenever something in mbox isn't how it's expected to be. The only real
21400 downside to this setting is that if some other MUA changes message
21401 flags, Dovecot doesn't notice it immediately. Note that a full sync is
21402 done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
21403 Defaults to @samp{#t}.
21404 @end deftypevr
21405
21406 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
21407 Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
21408 EXAMINE, EXPUNGE or CHECK commands. If this is set,
21409 @samp{mbox-dirty-syncs} is ignored.
21410 Defaults to @samp{#f}.
21411 @end deftypevr
21412
21413 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
21414 Delay writing mbox headers until doing a full write sync (EXPUNGE
21415 and CHECK commands and when closing the mailbox). This is especially
21416 useful for POP3 where clients often delete all mails. The downside is
21417 that our changes aren't immediately visible to other MUAs.
21418 Defaults to @samp{#t}.
21419 @end deftypevr
21420
21421 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
21422 If mbox size is smaller than this (e.g.@: 100k), don't write index
21423 files. If an index file already exists it's still read, just not
21424 updated.
21425 Defaults to @samp{0}.
21426 @end deftypevr
21427
21428 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
21429 Maximum dbox file size until it's rotated.
21430 Defaults to @samp{10000000}.
21431 @end deftypevr
21432
21433 @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
21434 Maximum dbox file age until it's rotated. Typically in days. Day
21435 begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
21436 disabled.
21437 Defaults to @samp{"1d"}.
21438 @end deftypevr
21439
21440 @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
21441 When creating new mdbox files, immediately preallocate their size to
21442 @samp{mdbox-rotate-size}. This setting currently works only in Linux
21443 with some file systems (ext4, xfs).
21444 Defaults to @samp{#f}.
21445 @end deftypevr
21446
21447 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
21448 sdbox and mdbox support saving mail attachments to external files,
21449 which also allows single instance storage for them. Other backends
21450 don't support this for now.
21451
21452 WARNING: This feature hasn't been tested much yet. Use at your own risk.
21453
21454 Directory root where to store mail attachments. Disabled, if empty.
21455 Defaults to @samp{""}.
21456 @end deftypevr
21457
21458 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
21459 Attachments smaller than this aren't saved externally. It's also
21460 possible to write a plugin to disable saving specific attachments
21461 externally.
21462 Defaults to @samp{128000}.
21463 @end deftypevr
21464
21465 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
21466 File system backend to use for saving attachments:
21467 @table @code
21468 @item posix
21469 No SiS done by Dovecot (but this might help FS's own deduplication)
21470 @item sis posix
21471 SiS with immediate byte-by-byte comparison during saving
21472 @item sis-queue posix
21473 SiS with delayed comparison and deduplication.
21474 @end table
21475 Defaults to @samp{"sis posix"}.
21476 @end deftypevr
21477
21478 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
21479 Hash format to use in attachment filenames. You can add any text and
21480 variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
21481 @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
21482 truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
21483 Defaults to @samp{"%@{sha1@}"}.
21484 @end deftypevr
21485
21486 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
21487
21488 Defaults to @samp{100}.
21489 @end deftypevr
21490
21491 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
21492
21493 Defaults to @samp{1000}.
21494 @end deftypevr
21495
21496 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
21497 Default VSZ (virtual memory size) limit for service processes.
21498 This is mainly intended to catch and kill processes that leak memory
21499 before they eat up everything.
21500 Defaults to @samp{256000000}.
21501 @end deftypevr
21502
21503 @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
21504 Login user is internally used by login processes. This is the most
21505 untrusted user in Dovecot system. It shouldn't have access to anything
21506 at all.
21507 Defaults to @samp{"dovenull"}.
21508 @end deftypevr
21509
21510 @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
21511 Internal user is used by unprivileged processes. It should be
21512 separate from login user, so that login processes can't disturb other
21513 processes.
21514 Defaults to @samp{"dovecot"}.
21515 @end deftypevr
21516
21517 @deftypevr {@code{dovecot-configuration} parameter} string ssl?
21518 SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
21519 Defaults to @samp{"required"}.
21520 @end deftypevr
21521
21522 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
21523 PEM encoded X.509 SSL/TLS certificate (public key).
21524 Defaults to @samp{"</etc/dovecot/default.pem"}.
21525 @end deftypevr
21526
21527 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
21528 PEM encoded SSL/TLS private key. The key is opened before
21529 dropping root privileges, so keep the key file unreadable by anyone but
21530 root.
21531 Defaults to @samp{"</etc/dovecot/private/default.pem"}.
21532 @end deftypevr
21533
21534 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
21535 If key file is password protected, give the password here.
21536 Alternatively give it when starting dovecot with -p parameter. Since
21537 this file is often world-readable, you may want to place this setting
21538 instead to a different.
21539 Defaults to @samp{""}.
21540 @end deftypevr
21541
21542 @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
21543 PEM encoded trusted certificate authority. Set this only if you
21544 intend to use @samp{ssl-verify-client-cert? #t}. The file should
21545 contain the CA certificate(s) followed by the matching
21546 CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
21547 Defaults to @samp{""}.
21548 @end deftypevr
21549
21550 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
21551 Require that CRL check succeeds for client certificates.
21552 Defaults to @samp{#t}.
21553 @end deftypevr
21554
21555 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
21556 Request client to send a certificate. If you also want to require
21557 it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
21558 Defaults to @samp{#f}.
21559 @end deftypevr
21560
21561 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
21562 Which field from certificate to use for username. commonName and
21563 x500UniqueIdentifier are the usual choices. You'll also need to set
21564 @samp{auth-ssl-username-from-cert? #t}.
21565 Defaults to @samp{"commonName"}.
21566 @end deftypevr
21567
21568 @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
21569 Minimum SSL protocol version to accept.
21570 Defaults to @samp{"TLSv1"}.
21571 @end deftypevr
21572
21573 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
21574 SSL ciphers to use.
21575 Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
21576 @end deftypevr
21577
21578 @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
21579 SSL crypto device to use, for valid values run "openssl engine".
21580 Defaults to @samp{""}.
21581 @end deftypevr
21582
21583 @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
21584 Address to use when sending rejection mails.
21585 %d expands to recipient domain.
21586 Defaults to @samp{"postmaster@@%d"}.
21587 @end deftypevr
21588
21589 @deftypevr {@code{dovecot-configuration} parameter} string hostname
21590 Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
21591 and in LMTP replies. Default is the system's real hostname@@domain.
21592 Defaults to @samp{""}.
21593 @end deftypevr
21594
21595 @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
21596 If user is over quota, return with temporary failure instead of
21597 bouncing the mail.
21598 Defaults to @samp{#f}.
21599 @end deftypevr
21600
21601 @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
21602 Binary to use for sending mails.
21603 Defaults to @samp{"/usr/sbin/sendmail"}.
21604 @end deftypevr
21605
21606 @deftypevr {@code{dovecot-configuration} parameter} string submission-host
21607 If non-empty, send mails via this SMTP host[:port] instead of
21608 sendmail.
21609 Defaults to @samp{""}.
21610 @end deftypevr
21611
21612 @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
21613 Subject: header to use for rejection mails. You can use the same
21614 variables as for @samp{rejection-reason} below.
21615 Defaults to @samp{"Rejected: %s"}.
21616 @end deftypevr
21617
21618 @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
21619 Human readable error message for rejection mails. You can use
21620 variables:
21621
21622 @table @code
21623 @item %n
21624 CRLF
21625 @item %r
21626 reason
21627 @item %s
21628 original subject
21629 @item %t
21630 recipient
21631 @end table
21632 Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
21633 @end deftypevr
21634
21635 @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
21636 Delimiter character between local-part and detail in email
21637 address.
21638 Defaults to @samp{"+"}.
21639 @end deftypevr
21640
21641 @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
21642 Header where the original recipient address (SMTP's RCPT TO:
21643 address) is taken from if not available elsewhere. With dovecot-lda -a
21644 parameter overrides this. A commonly used header for this is
21645 X-Original-To.
21646 Defaults to @samp{""}.
21647 @end deftypevr
21648
21649 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
21650 Should saving a mail to a nonexistent mailbox automatically create
21651 it?.
21652 Defaults to @samp{#f}.
21653 @end deftypevr
21654
21655 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
21656 Should automatically created mailboxes be also automatically
21657 subscribed?.
21658 Defaults to @samp{#f}.
21659 @end deftypevr
21660
21661 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
21662 Maximum IMAP command line length. Some clients generate very long
21663 command lines with huge mailboxes, so you may need to raise this if you
21664 get "Too long argument" or "IMAP command line too large" errors
21665 often.
21666 Defaults to @samp{64000}.
21667 @end deftypevr
21668
21669 @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
21670 IMAP logout format string:
21671 @table @code
21672 @item %i
21673 total number of bytes read from client
21674 @item %o
21675 total number of bytes sent to client.
21676 @end table
21677 See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
21678 Defaults to @samp{"in=%i out=%o deleted=%@{deleted@} expunged=%@{expunged@} trashed=%@{trashed@} hdr_count=%@{fetch_hdr_count@} hdr_bytes=%@{fetch_hdr_bytes@} body_count=%@{fetch_body_count@} body_bytes=%@{fetch_body_bytes@}"}.
21679 @end deftypevr
21680
21681 @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
21682 Override the IMAP CAPABILITY response. If the value begins with '+',
21683 add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
21684 Defaults to @samp{""}.
21685 @end deftypevr
21686
21687 @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
21688 How long to wait between "OK Still here" notifications when client
21689 is IDLEing.
21690 Defaults to @samp{"2 mins"}.
21691 @end deftypevr
21692
21693 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
21694 ID field names and values to send to clients. Using * as the value
21695 makes Dovecot use the default value. The following fields have default
21696 values currently: name, version, os, os-version, support-url,
21697 support-email.
21698 Defaults to @samp{""}.
21699 @end deftypevr
21700
21701 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
21702 ID fields sent by client to log. * means everything.
21703 Defaults to @samp{""}.
21704 @end deftypevr
21705
21706 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
21707 Workarounds for various client bugs:
21708
21709 @table @code
21710 @item delay-newmail
21711 Send EXISTS/RECENT new mail notifications only when replying to NOOP and
21712 CHECK commands. Some clients ignore them otherwise, for example OSX
21713 Mail (<v2.1). Outlook Express breaks more badly though, without this it
21714 may show user "Message no longer in server" errors. Note that OE6
21715 still breaks even with this workaround if synchronization is set to
21716 "Headers Only".
21717
21718 @item tb-extra-mailbox-sep
21719 Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
21720 adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
21721 ignore the extra @samp{/} instead of treating it as invalid mailbox name.
21722
21723 @item tb-lsub-flags
21724 Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
21725 This makes Thunderbird realize they aren't selectable and show them
21726 greyed out, instead of only later giving "not selectable" popup error.
21727 @end table
21728 Defaults to @samp{()}.
21729 @end deftypevr
21730
21731 @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
21732 Host allowed in URLAUTH URLs sent by client. "*" allows all.
21733 Defaults to @samp{""}.
21734 @end deftypevr
21735
21736
21737 Whew! Lots of configuration options. The nice thing about it though is
21738 that Guix has a complete interface to Dovecot's configuration
21739 language. This allows not only a nice way to declare configurations,
21740 but also offers reflective capabilities as well: users can write code to
21741 inspect and transform configurations from within Scheme.
21742
21743 However, it could be that you just want to get a @code{dovecot.conf} up
21744 and running. In that case, you can pass an
21745 @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
21746 @code{dovecot-service}. As its name indicates, an opaque configuration
21747 does not have easy reflective capabilities.
21748
21749 Available @code{opaque-dovecot-configuration} fields are:
21750
21751 @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
21752 The dovecot package.
21753 @end deftypevr
21754
21755 @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
21756 The contents of the @code{dovecot.conf}, as a string.
21757 @end deftypevr
21758
21759 For example, if your @code{dovecot.conf} is just the empty string, you
21760 could instantiate a dovecot service like this:
21761
21762 @lisp
21763 (dovecot-service #:config
21764 (opaque-dovecot-configuration
21765 (string "")))
21766 @end lisp
21767
21768 @subsubheading OpenSMTPD Service
21769
21770 @deffn {Scheme Variable} opensmtpd-service-type
21771 This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
21772 service, whose value should be an @code{opensmtpd-configuration} object
21773 as in this example:
21774
21775 @lisp
21776 (service opensmtpd-service-type
21777 (opensmtpd-configuration
21778 (config-file (local-file "./my-smtpd.conf"))))
21779 @end lisp
21780 @end deffn
21781
21782 @deftp {Data Type} opensmtpd-configuration
21783 Data type representing the configuration of opensmtpd.
21784
21785 @table @asis
21786 @item @code{package} (default: @var{opensmtpd})
21787 Package object of the OpenSMTPD SMTP server.
21788
21789 @item @code{config-file} (default: @code{%default-opensmtpd-file})
21790 File-like object of the OpenSMTPD configuration file to use. By default
21791 it listens on the loopback network interface, and allows for mail from
21792 users and daemons on the local machine, as well as permitting email to
21793 remote servers. Run @command{man smtpd.conf} for more information.
21794
21795 @end table
21796 @end deftp
21797
21798 @subsubheading Exim Service
21799
21800 @cindex mail transfer agent (MTA)
21801 @cindex MTA (mail transfer agent)
21802 @cindex SMTP
21803
21804 @deffn {Scheme Variable} exim-service-type
21805 This is the type of the @uref{https://exim.org, Exim} mail transfer
21806 agent (MTA), whose value should be an @code{exim-configuration} object
21807 as in this example:
21808
21809 @lisp
21810 (service exim-service-type
21811 (exim-configuration
21812 (config-file (local-file "./my-exim.conf"))))
21813 @end lisp
21814 @end deffn
21815
21816 In order to use an @code{exim-service-type} service you must also have a
21817 @code{mail-aliases-service-type} service present in your
21818 @code{operating-system} (even if it has no aliases).
21819
21820 @deftp {Data Type} exim-configuration
21821 Data type representing the configuration of exim.
21822
21823 @table @asis
21824 @item @code{package} (default: @var{exim})
21825 Package object of the Exim server.
21826
21827 @item @code{config-file} (default: @code{#f})
21828 File-like object of the Exim configuration file to use. If its value is
21829 @code{#f} then use the default configuration file from the package
21830 provided in @code{package}. The resulting configuration file is loaded
21831 after setting the @code{exim_user} and @code{exim_group} configuration
21832 variables.
21833
21834 @end table
21835 @end deftp
21836
21837 @subsubheading Getmail service
21838
21839 @cindex IMAP
21840 @cindex POP
21841
21842 @deffn {Scheme Variable} getmail-service-type
21843 This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
21844 mail retriever, whose value should be an @code{getmail-configuration}.
21845 @end deffn
21846
21847 Available @code{getmail-configuration} fields are:
21848
21849 @deftypevr {@code{getmail-configuration} parameter} symbol name
21850 A symbol to identify the getmail service.
21851
21852 Defaults to @samp{"unset"}.
21853
21854 @end deftypevr
21855
21856 @deftypevr {@code{getmail-configuration} parameter} package package
21857 The getmail package to use.
21858
21859 @end deftypevr
21860
21861 @deftypevr {@code{getmail-configuration} parameter} string user
21862 The user to run getmail as.
21863
21864 Defaults to @samp{"getmail"}.
21865
21866 @end deftypevr
21867
21868 @deftypevr {@code{getmail-configuration} parameter} string group
21869 The group to run getmail as.
21870
21871 Defaults to @samp{"getmail"}.
21872
21873 @end deftypevr
21874
21875 @deftypevr {@code{getmail-configuration} parameter} string directory
21876 The getmail directory to use.
21877
21878 Defaults to @samp{"/var/lib/getmail/default"}.
21879
21880 @end deftypevr
21881
21882 @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
21883 The getmail configuration file to use.
21884
21885 Available @code{getmail-configuration-file} fields are:
21886
21887 @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
21888 What mail account to retrieve mail from, and how to access that account.
21889
21890 Available @code{getmail-retriever-configuration} fields are:
21891
21892 @deftypevr {@code{getmail-retriever-configuration} parameter} string type
21893 The type of mail retriever to use. Valid values include @samp{passwd}
21894 and @samp{static}.
21895
21896 Defaults to @samp{"SimpleIMAPSSLRetriever"}.
21897
21898 @end deftypevr
21899
21900 @deftypevr {@code{getmail-retriever-configuration} parameter} string server
21901 Username to login to the mail server with.
21902
21903 Defaults to @samp{unset}.
21904
21905 @end deftypevr
21906
21907 @deftypevr {@code{getmail-retriever-configuration} parameter} string username
21908 Username to login to the mail server with.
21909
21910 Defaults to @samp{unset}.
21911
21912 @end deftypevr
21913
21914 @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
21915 Port number to connect to.
21916
21917 Defaults to @samp{#f}.
21918
21919 @end deftypevr
21920
21921 @deftypevr {@code{getmail-retriever-configuration} parameter} string password
21922 Override fields from passwd.
21923
21924 Defaults to @samp{""}.
21925
21926 @end deftypevr
21927
21928 @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
21929 Override fields from passwd.
21930
21931 Defaults to @samp{()}.
21932
21933 @end deftypevr
21934
21935 @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
21936 PEM-formatted key file to use for the TLS negotiation.
21937
21938 Defaults to @samp{""}.
21939
21940 @end deftypevr
21941
21942 @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
21943 PEM-formatted certificate file to use for the TLS negotiation.
21944
21945 Defaults to @samp{""}.
21946
21947 @end deftypevr
21948
21949 @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
21950 CA certificates to use.
21951
21952 Defaults to @samp{""}.
21953
21954 @end deftypevr
21955
21956 @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
21957 Extra retriever parameters.
21958
21959 Defaults to @samp{()}.
21960
21961 @end deftypevr
21962
21963 @end deftypevr
21964
21965 @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
21966 What to do with retrieved messages.
21967
21968 Available @code{getmail-destination-configuration} fields are:
21969
21970 @deftypevr {@code{getmail-destination-configuration} parameter} string type
21971 The type of mail destination. Valid values include @samp{Maildir},
21972 @samp{Mboxrd} and @samp{MDA_external}.
21973
21974 Defaults to @samp{unset}.
21975
21976 @end deftypevr
21977
21978 @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
21979 The path option for the mail destination. The behaviour depends on the
21980 chosen type.
21981
21982 Defaults to @samp{""}.
21983
21984 @end deftypevr
21985
21986 @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
21987 Extra destination parameters
21988
21989 Defaults to @samp{()}.
21990
21991 @end deftypevr
21992
21993 @end deftypevr
21994
21995 @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
21996 Configure getmail.
21997
21998 Available @code{getmail-options-configuration} fields are:
21999
22000 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
22001 If set to @samp{0}, getmail will only print warnings and errors. A
22002 value of @samp{1} means that messages will be printed about retrieving
22003 and deleting messages. If set to @samp{2}, getmail will print messages
22004 about each of its actions.
22005
22006 Defaults to @samp{1}.
22007
22008 @end deftypevr
22009
22010 @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
22011 If true, getmail will retrieve all available messages. Otherwise it
22012 will only retrieve messages it hasn't seen previously.
22013
22014 Defaults to @samp{#t}.
22015
22016 @end deftypevr
22017
22018 @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
22019 If set to true, messages will be deleted from the server after
22020 retrieving and successfully delivering them. Otherwise, messages will
22021 be left on the server.
22022
22023 Defaults to @samp{#f}.
22024
22025 @end deftypevr
22026
22027 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
22028 Getmail will delete messages this number of days after seeing them, if
22029 they have been delivered. This means messages will be left on the
22030 server this number of days after delivering them. A value of @samp{0}
22031 disabled this feature.
22032
22033 Defaults to @samp{0}.
22034
22035 @end deftypevr
22036
22037 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
22038 Delete messages larger than this of bytes after retrieving them, even if
22039 the delete and delete-after options are disabled. A value of @samp{0}
22040 disables this feature.
22041
22042 Defaults to @samp{0}.
22043
22044 @end deftypevr
22045
22046 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
22047 Retrieve messages totalling up to this number of bytes before closing
22048 the session with the server. A value of @samp{0} disables this feature.
22049
22050 Defaults to @samp{0}.
22051
22052 @end deftypevr
22053
22054 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
22055 Don't retrieve messages larger than this number of bytes. A value of
22056 @samp{0} disables this feature.
22057
22058 Defaults to @samp{0}.
22059
22060 @end deftypevr
22061
22062 @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
22063 If true, getmail will add a Delivered-To header to messages.
22064
22065 Defaults to @samp{#t}.
22066
22067 @end deftypevr
22068
22069 @deftypevr {@code{getmail-options-configuration} parameter} boolean received
22070 If set, getmail adds a Received header to the messages.
22071
22072 Defaults to @samp{#t}.
22073
22074 @end deftypevr
22075
22076 @deftypevr {@code{getmail-options-configuration} parameter} string message-log
22077 Getmail will record a log of its actions to the named file. A value of
22078 @samp{""} disables this feature.
22079
22080 Defaults to @samp{""}.
22081
22082 @end deftypevr
22083
22084 @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
22085 If true, getmail will record a log of its actions using the system
22086 logger.
22087
22088 Defaults to @samp{#f}.
22089
22090 @end deftypevr
22091
22092 @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
22093 If true, getmail will log information about messages not retrieved and
22094 the reason for not retrieving them, as well as starting and ending
22095 information lines.
22096
22097 Defaults to @samp{#f}.
22098
22099 @end deftypevr
22100
22101 @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
22102 Extra options to include.
22103
22104 Defaults to @samp{()}.
22105
22106 @end deftypevr
22107
22108 @end deftypevr
22109
22110 @end deftypevr
22111
22112 @deftypevr {@code{getmail-configuration} parameter} list idle
22113 A list of mailboxes that getmail should wait on the server for new mail
22114 notifications. This depends on the server supporting the IDLE
22115 extension.
22116
22117 Defaults to @samp{()}.
22118
22119 @end deftypevr
22120
22121 @deftypevr {@code{getmail-configuration} parameter} list environment-variables
22122 Environment variables to set for getmail.
22123
22124 Defaults to @samp{()}.
22125
22126 @end deftypevr
22127
22128 @subsubheading Mail Aliases Service
22129
22130 @cindex email aliases
22131 @cindex aliases, for email addresses
22132
22133 @deffn {Scheme Variable} mail-aliases-service-type
22134 This is the type of the service which provides @code{/etc/aliases},
22135 specifying how to deliver mail to users on this system.
22136
22137 @lisp
22138 (service mail-aliases-service-type
22139 '(("postmaster" "bob")
22140 ("bob" "bob@@example.com" "bob@@example2.com")))
22141 @end lisp
22142 @end deffn
22143
22144 The configuration for a @code{mail-aliases-service-type} service is an
22145 association list denoting how to deliver mail that comes to this
22146 system. Each entry is of the form @code{(alias addresses ...)}, with
22147 @code{alias} specifying the local alias and @code{addresses} specifying
22148 where to deliver this user's mail.
22149
22150 The aliases aren't required to exist as users on the local system. In
22151 the above example, there doesn't need to be a @code{postmaster} entry in
22152 the @code{operating-system}'s @code{user-accounts} in order to deliver
22153 the @code{postmaster} mail to @code{bob} (which subsequently would
22154 deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
22155
22156 @subsubheading GNU Mailutils IMAP4 Daemon
22157 @cindex GNU Mailutils IMAP4 Daemon
22158
22159 @deffn {Scheme Variable} imap4d-service-type
22160 This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
22161 mailutils, GNU Mailutils Manual}), whose value should be an
22162 @code{imap4d-configuration} object as in this example:
22163
22164 @lisp
22165 (service imap4d-service-type
22166 (imap4d-configuration
22167 (config-file (local-file "imap4d.conf"))))
22168 @end lisp
22169 @end deffn
22170
22171 @deftp {Data Type} imap4d-configuration
22172 Data type representing the configuration of @command{imap4d}.
22173
22174 @table @asis
22175 @item @code{package} (default: @code{mailutils})
22176 The package that provides @command{imap4d}.
22177
22178 @item @code{config-file} (default: @code{%default-imap4d-config-file})
22179 File-like object of the configuration file to use, by default it will listen
22180 on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
22181 Mailutils Manual}, for details.
22182
22183 @end table
22184 @end deftp
22185
22186 @subsubheading Radicale Service
22187 @cindex CalDAV
22188 @cindex CardDAV
22189
22190 @deffn {Scheme Variable} radicale-service-type
22191 This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
22192 server whose value should be a @code{radicale-configuration}.
22193 @end deffn
22194
22195 @deftp {Data Type} radicale-configuration
22196 Data type representing the configuration of @command{radicale}.
22197
22198 @table @asis
22199 @item @code{package} (default: @code{radicale})
22200 The package that provides @command{radicale}.
22201
22202 @item @code{config-file} (default: @code{%default-radicale-config-file})
22203 File-like object of the configuration file to use, by default it will listen
22204 on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
22205 @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
22206
22207 @end table
22208 @end deftp
22209
22210 @node Messaging Services
22211 @subsection Messaging Services
22212
22213 @cindex messaging
22214 @cindex jabber
22215 @cindex XMPP
22216 The @code{(gnu services messaging)} module provides Guix service
22217 definitions for messaging services. Currently it provides the following
22218 services:
22219
22220 @subsubheading Prosody Service
22221
22222 @deffn {Scheme Variable} prosody-service-type
22223 This is the type for the @uref{https://prosody.im, Prosody XMPP
22224 communication server}. Its value must be a @code{prosody-configuration}
22225 record as in this example:
22226
22227 @lisp
22228 (service prosody-service-type
22229 (prosody-configuration
22230 (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
22231 (int-components
22232 (list
22233 (int-component-configuration
22234 (hostname "conference.example.net")
22235 (plugin "muc")
22236 (mod-muc (mod-muc-configuration)))))
22237 (virtualhosts
22238 (list
22239 (virtualhost-configuration
22240 (domain "example.net"))))))
22241 @end lisp
22242
22243 See below for details about @code{prosody-configuration}.
22244
22245 @end deffn
22246
22247 By default, Prosody does not need much configuration. Only one
22248 @code{virtualhosts} field is needed: it specifies the domain you wish
22249 Prosody to serve.
22250
22251 You can perform various sanity checks on the generated configuration
22252 with the @code{prosodyctl check} command.
22253
22254 Prosodyctl will also help you to import certificates from the
22255 @code{letsencrypt} directory so that the @code{prosody} user can access
22256 them. See @url{https://prosody.im/doc/letsencrypt}.
22257
22258 @example
22259 prosodyctl --root cert import /etc/letsencrypt/live
22260 @end example
22261
22262 The available configuration parameters follow. Each parameter
22263 definition is preceded by its type; for example, @samp{string-list foo}
22264 indicates that the @code{foo} parameter should be specified as a list of
22265 strings. Types starting with @code{maybe-} denote parameters that won't
22266 show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
22267
22268 There is also a way to specify the configuration as a string, if you
22269 have an old @code{prosody.cfg.lua} file that you want to port over from
22270 some other system; see the end for more details.
22271
22272 The @code{file-object} type designates either a file-like object
22273 (@pxref{G-Expressions, file-like objects}) or a file name.
22274
22275 @c The following documentation was initially generated by
22276 @c (generate-documentation) in (gnu services messaging). Manually maintained
22277 @c documentation is better, so we shouldn't hesitate to edit below as
22278 @c needed. However if the change you want to make to this documentation
22279 @c can be done in an automated way, it's probably easier to change
22280 @c (generate-documentation) than to make it below and have to deal with
22281 @c the churn as Prosody updates.
22282
22283 Available @code{prosody-configuration} fields are:
22284
22285 @deftypevr {@code{prosody-configuration} parameter} package prosody
22286 The Prosody package.
22287 @end deftypevr
22288
22289 @deftypevr {@code{prosody-configuration} parameter} file-name data-path
22290 Location of the Prosody data storage directory. See
22291 @url{https://prosody.im/doc/configure}.
22292 Defaults to @samp{"/var/lib/prosody"}.
22293 @end deftypevr
22294
22295 @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
22296 Additional plugin directories. They are searched in all the specified
22297 paths in order. See @url{https://prosody.im/doc/plugins_directory}.
22298 Defaults to @samp{()}.
22299 @end deftypevr
22300
22301 @deftypevr {@code{prosody-configuration} parameter} file-name certificates
22302 Every virtual host and component needs a certificate so that clients and
22303 servers can securely verify its identity. Prosody will automatically load
22304 certificates/keys from the directory specified here.
22305 Defaults to @samp{"/etc/prosody/certs"}.
22306 @end deftypevr
22307
22308 @deftypevr {@code{prosody-configuration} parameter} string-list admins
22309 This is a list of accounts that are admins for the server. Note that you
22310 must create the accounts separately. See @url{https://prosody.im/doc/admins} and
22311 @url{https://prosody.im/doc/creating_accounts}.
22312 Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
22313 Defaults to @samp{()}.
22314 @end deftypevr
22315
22316 @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
22317 Enable use of libevent for better performance under high load. See
22318 @url{https://prosody.im/doc/libevent}.
22319 Defaults to @samp{#f}.
22320 @end deftypevr
22321
22322 @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
22323 This is the list of modules Prosody will load on startup. It looks for
22324 @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
22325 Documentation on modules can be found at:
22326 @url{https://prosody.im/doc/modules}.
22327 Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
22328 @end deftypevr
22329
22330 @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
22331 @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
22332 should you want to disable them then add them to this list.
22333 Defaults to @samp{()}.
22334 @end deftypevr
22335
22336 @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
22337 Path to a text file where the shared groups are defined. If this path is
22338 empty then @samp{mod_groups} does nothing. See
22339 @url{https://prosody.im/doc/modules/mod_groups}.
22340 Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
22341 @end deftypevr
22342
22343 @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
22344 Disable account creation by default, for security. See
22345 @url{https://prosody.im/doc/creating_accounts}.
22346 Defaults to @samp{#f}.
22347 @end deftypevr
22348
22349 @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
22350 These are the SSL/TLS-related settings. Most of them are disabled so to
22351 use Prosody's defaults. If you do not completely understand these options, do
22352 not add them to your config, it is easy to lower the security of your server
22353 using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
22354
22355 Available @code{ssl-configuration} fields are:
22356
22357 @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
22358 This determines what handshake to use.
22359 @end deftypevr
22360
22361 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
22362 Path to your private key file.
22363 @end deftypevr
22364
22365 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
22366 Path to your certificate file.
22367 @end deftypevr
22368
22369 @deftypevr {@code{ssl-configuration} parameter} file-object capath
22370 Path to directory containing root certificates that you wish Prosody to
22371 trust when verifying the certificates of remote servers.
22372 Defaults to @samp{"/etc/ssl/certs"}.
22373 @end deftypevr
22374
22375 @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
22376 Path to a file containing root certificates that you wish Prosody to trust.
22377 Similar to @code{capath} but with all certificates concatenated together.
22378 @end deftypevr
22379
22380 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
22381 A list of verification options (these mostly map to OpenSSL's
22382 @code{set_verify()} flags).
22383 @end deftypevr
22384
22385 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
22386 A list of general options relating to SSL/TLS@. These map to OpenSSL's
22387 @code{set_options()}. For a full list of options available in LuaSec, see the
22388 LuaSec source.
22389 @end deftypevr
22390
22391 @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
22392 How long a chain of certificate authorities to check when looking for a
22393 trusted root certificate.
22394 @end deftypevr
22395
22396 @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
22397 An OpenSSL cipher string. This selects what ciphers Prosody will offer to
22398 clients, and in what order.
22399 @end deftypevr
22400
22401 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
22402 A path to a file containing parameters for Diffie-Hellman key exchange. You
22403 can create such a file with:
22404 @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
22405 @end deftypevr
22406
22407 @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
22408 Curve for Elliptic curve Diffie-Hellman. Prosody's default is
22409 @samp{"secp384r1"}.
22410 @end deftypevr
22411
22412 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
22413 A list of ``extra'' verification options.
22414 @end deftypevr
22415
22416 @deftypevr {@code{ssl-configuration} parameter} maybe-string password
22417 Password for encrypted private keys.
22418 @end deftypevr
22419
22420 @end deftypevr
22421
22422 @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
22423 Whether to force all client-to-server connections to be encrypted or not.
22424 See @url{https://prosody.im/doc/modules/mod_tls}.
22425 Defaults to @samp{#f}.
22426 @end deftypevr
22427
22428 @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
22429 Set of mechanisms that will never be offered. See
22430 @url{https://prosody.im/doc/modules/mod_saslauth}.
22431 Defaults to @samp{("DIGEST-MD5")}.
22432 @end deftypevr
22433
22434 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
22435 Whether to force all server-to-server connections to be encrypted or not.
22436 See @url{https://prosody.im/doc/modules/mod_tls}.
22437 Defaults to @samp{#f}.
22438 @end deftypevr
22439
22440 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
22441 Whether to require encryption and certificate authentication. This
22442 provides ideal security, but requires servers you communicate with to support
22443 encryption AND present valid, trusted certificates. See
22444 @url{https://prosody.im/doc/s2s#security}.
22445 Defaults to @samp{#f}.
22446 @end deftypevr
22447
22448 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
22449 Many servers don't support encryption or have invalid or self-signed
22450 certificates. You can list domains here that will not be required to
22451 authenticate using certificates. They will be authenticated using DNS@. See
22452 @url{https://prosody.im/doc/s2s#security}.
22453 Defaults to @samp{()}.
22454 @end deftypevr
22455
22456 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
22457 Even if you leave @code{s2s-secure-auth?} disabled, you can still require
22458 valid certificates for some domains by specifying a list here. See
22459 @url{https://prosody.im/doc/s2s#security}.
22460 Defaults to @samp{()}.
22461 @end deftypevr
22462
22463 @deftypevr {@code{prosody-configuration} parameter} string authentication
22464 Select the authentication backend to use. The default provider stores
22465 passwords in plaintext and uses Prosody's configured data storage to store the
22466 authentication data. If you do not trust your server please see
22467 @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
22468 about using the hashed backend. See also
22469 @url{https://prosody.im/doc/authentication}
22470 Defaults to @samp{"internal_plain"}.
22471 @end deftypevr
22472
22473 @deftypevr {@code{prosody-configuration} parameter} maybe-string log
22474 Set logging options. Advanced logging configuration is not yet supported
22475 by the Prosody service. See @url{https://prosody.im/doc/logging}.
22476 Defaults to @samp{"*syslog"}.
22477 @end deftypevr
22478
22479 @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
22480 File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
22481 Defaults to @samp{"/var/run/prosody/prosody.pid"}.
22482 @end deftypevr
22483
22484 @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
22485 Maximum allowed size of the HTTP body (in bytes).
22486 @end deftypevr
22487
22488 @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
22489 Some modules expose their own URL in various ways. This URL is built
22490 from the protocol, host and port used. If Prosody sits behind a proxy, the
22491 public URL will be @code{http-external-url} instead. See
22492 @url{https://prosody.im/doc/http#external_url}.
22493 @end deftypevr
22494
22495 @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
22496 A host in Prosody is a domain on which user accounts can be created. For
22497 example if you want your users to have addresses like
22498 @samp{"john.smith@@example.com"} then you need to add a host
22499 @samp{"example.com"}. All options in this list will apply only to this host.
22500
22501 Note: the name @emph{virtual} host is used in configuration to avoid confusion with
22502 the actual physical host that Prosody is installed on. A single Prosody
22503 instance can serve many domains, each one defined as a VirtualHost entry in
22504 Prosody's configuration. Conversely a server that hosts a single domain would
22505 have just one VirtualHost entry.
22506
22507 See @url{https://prosody.im/doc/configure#virtual_host_settings}.
22508
22509 Available @code{virtualhost-configuration} fields are:
22510
22511 all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
22512 @deftypevr {@code{virtualhost-configuration} parameter} string domain
22513 Domain you wish Prosody to serve.
22514 @end deftypevr
22515
22516 @end deftypevr
22517
22518 @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
22519 Components are extra services on a server which are available to clients,
22520 usually on a subdomain of the main server (such as
22521 @samp{"mycomponent.example.com"}). Example components might be chatroom
22522 servers, user directories, or gateways to other protocols.
22523
22524 Internal components are implemented with Prosody-specific plugins. To add an
22525 internal component, you simply fill the hostname field, and the plugin you wish
22526 to use for the component.
22527
22528 See @url{https://prosody.im/doc/components}.
22529 Defaults to @samp{()}.
22530
22531 Available @code{int-component-configuration} fields are:
22532
22533 all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
22534 @deftypevr {@code{int-component-configuration} parameter} string hostname
22535 Hostname of the component.
22536 @end deftypevr
22537
22538 @deftypevr {@code{int-component-configuration} parameter} string plugin
22539 Plugin you wish to use for the component.
22540 @end deftypevr
22541
22542 @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
22543 Multi-user chat (MUC) is Prosody's module for allowing you to create
22544 hosted chatrooms/conferences for XMPP users.
22545
22546 General information on setting up and using multi-user chatrooms can be found
22547 in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
22548 which you should read if you are new to XMPP chatrooms.
22549
22550 See also @url{https://prosody.im/doc/modules/mod_muc}.
22551
22552 Available @code{mod-muc-configuration} fields are:
22553
22554 @deftypevr {@code{mod-muc-configuration} parameter} string name
22555 The name to return in service discovery responses.
22556 Defaults to @samp{"Prosody Chatrooms"}.
22557 @end deftypevr
22558
22559 @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
22560 If @samp{#t}, this will only allow admins to create new chatrooms.
22561 Otherwise anyone can create a room. The value @samp{"local"} restricts room
22562 creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
22563 can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
22564 restricts to service administrators only.
22565 Defaults to @samp{#f}.
22566 @end deftypevr
22567
22568 @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
22569 Maximum number of history messages that will be sent to the member that has
22570 just joined the room.
22571 Defaults to @samp{20}.
22572 @end deftypevr
22573
22574 @end deftypevr
22575
22576 @end deftypevr
22577
22578 @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
22579 External components use XEP-0114, which most standalone components
22580 support. To add an external component, you simply fill the hostname field. See
22581 @url{https://prosody.im/doc/components}.
22582 Defaults to @samp{()}.
22583
22584 Available @code{ext-component-configuration} fields are:
22585
22586 all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
22587 @deftypevr {@code{ext-component-configuration} parameter} string component-secret
22588 Password which the component will use to log in.
22589 @end deftypevr
22590
22591 @deftypevr {@code{ext-component-configuration} parameter} string hostname
22592 Hostname of the component.
22593 @end deftypevr
22594
22595 @end deftypevr
22596
22597 @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
22598 Port(s) Prosody listens on for component connections.
22599 Defaults to @samp{(5347)}.
22600 @end deftypevr
22601
22602 @deftypevr {@code{prosody-configuration} parameter} string component-interface
22603 Interface Prosody listens on for component connections.
22604 Defaults to @samp{"127.0.0.1"}.
22605 @end deftypevr
22606
22607 @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
22608 Raw content that will be added to the configuration file.
22609 @end deftypevr
22610
22611 It could be that you just want to get a @code{prosody.cfg.lua}
22612 up and running. In that case, you can pass an
22613 @code{opaque-prosody-configuration} record as the value of
22614 @code{prosody-service-type}. As its name indicates, an opaque configuration
22615 does not have easy reflective capabilities.
22616 Available @code{opaque-prosody-configuration} fields are:
22617
22618 @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
22619 The prosody package.
22620 @end deftypevr
22621
22622 @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
22623 The contents of the @code{prosody.cfg.lua} to use.
22624 @end deftypevr
22625
22626 For example, if your @code{prosody.cfg.lua} is just the empty
22627 string, you could instantiate a prosody service like this:
22628
22629 @lisp
22630 (service prosody-service-type
22631 (opaque-prosody-configuration
22632 (prosody.cfg.lua "")))
22633 @end lisp
22634
22635 @c end of Prosody auto-generated documentation
22636
22637 @subsubheading BitlBee Service
22638
22639 @cindex IRC (Internet Relay Chat)
22640 @cindex IRC gateway
22641 @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
22642 interface to a variety of messaging protocols such as XMPP.
22643
22644 @defvr {Scheme Variable} bitlbee-service-type
22645 This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
22646 gateway daemon. Its value is a @code{bitlbee-configuration} (see
22647 below).
22648
22649 To have BitlBee listen on port 6667 on localhost, add this line to your
22650 services:
22651
22652 @lisp
22653 (service bitlbee-service-type)
22654 @end lisp
22655 @end defvr
22656
22657 @deftp {Data Type} bitlbee-configuration
22658 This is the configuration for BitlBee, with the following fields:
22659
22660 @table @asis
22661 @item @code{interface} (default: @code{"127.0.0.1"})
22662 @itemx @code{port} (default: @code{6667})
22663 Listen on the network interface corresponding to the IP address
22664 specified in @var{interface}, on @var{port}.
22665
22666 When @var{interface} is @code{127.0.0.1}, only local clients can
22667 connect; when it is @code{0.0.0.0}, connections can come from any
22668 networking interface.
22669
22670 @item @code{bitlbee} (default: @code{bitlbee})
22671 The BitlBee package to use.
22672
22673 @item @code{plugins} (default: @code{'()})
22674 List of plugin packages to use---e.g., @code{bitlbee-discord}.
22675
22676 @item @code{extra-settings} (default: @code{""})
22677 Configuration snippet added as-is to the BitlBee configuration file.
22678 @end table
22679 @end deftp
22680
22681 @subsubheading Quassel Service
22682
22683 @cindex IRC (Internet Relay Chat)
22684 @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
22685 meaning that one or more clients can attach to and detach from the
22686 central core.
22687
22688 @defvr {Scheme Variable} quassel-service-type
22689 This is the service type for the @url{https://quassel-irc.org/,Quassel}
22690 IRC backend daemon. Its value is a @code{quassel-configuration}
22691 (see below).
22692 @end defvr
22693
22694 @deftp {Data Type} quassel-configuration
22695 This is the configuration for Quassel, with the following fields:
22696
22697 @table @asis
22698 @item @code{quassel} (default: @code{quassel})
22699 The Quassel package to use.
22700
22701 @item @code{interface} (default: @code{"::,0.0.0.0"})
22702 @item @code{port} (default: @code{4242})
22703 Listen on the network interface(s) corresponding to the IPv4 or IPv6
22704 interfaces specified in the comma delimited @var{interface}, on
22705 @var{port}.
22706
22707 @item @code{loglevel} (default: @code{"Info"})
22708 The level of logging desired. Accepted values are Debug, Info, Warning
22709 and Error.
22710 @end table
22711 @end deftp
22712
22713 @node Telephony Services
22714 @subsection Telephony Services
22715
22716 @cindex telephony, services
22717 The @code{(gnu services telephony)} module contains Guix service
22718 definitions for telephony services. Currently it provides the following
22719 services:
22720
22721 @subsubheading Jami
22722
22723 @cindex jami, service
22724
22725 This section describes how to configure a Jami server that can be used
22726 to host video (or audio) conferences, among other uses. The following
22727 example demonstrates how to specify Jami account archives (backups) to
22728 be provisioned automatically:
22729
22730 @lisp
22731 (service jami-service-type
22732 (jami-configuration
22733 (accounts
22734 (list (jami-account
22735 (archive "/etc/jami/unencrypted-account-1.gz"))
22736 (jami-account
22737 (archive "/etc/jami/unencrypted-account-2.gz"))))))
22738 @end lisp
22739
22740 When the accounts field is specified, the Jami account files of the
22741 service found under @file{/var/lib/jami} are recreated every time the
22742 service starts.
22743
22744 Jami accounts and their corresponding backup archives can be generated
22745 using either the @code{jami-qt} or @code{jami-gnome} Jami clients. The
22746 accounts should not be password-protected, but it is wise to ensure
22747 their files are only readable by @samp{root}.
22748
22749 The next example shows how to declare that only some contacts should be
22750 allowed to communicate with a given account:
22751
22752 @lisp
22753 (service jami-service-type
22754 (jami-configuration
22755 (accounts
22756 (list (jami-account
22757 (archive "/etc/jami/unencrypted-account-1.gz")
22758 (peer-discovery? #t)
22759 (rendezvous-point? #t)
22760 (allowed-contacts
22761 '("1dbcb0f5f37324228235564b79f2b9737e9a008f"
22762 "2dbcb0f5f37324228235564b79f2b9737e9a008f")))))))
22763 @end lisp
22764
22765 In this mode, only the declared @code{allowed-contacts} can initiate
22766 communication with the Jami account. This can be used, for example,
22767 with rendezvous point accounts to create a private video conferencing
22768 space.
22769
22770 To put the system administrator in full control of the conferences
22771 hosted on their system, the Jami service supports the following actions:
22772
22773 @example sh
22774 # herd doc jami list-actions
22775 (list-accounts
22776 list-account-details
22777 list-banned-contacts
22778 list-contacts
22779 list-moderators
22780 add-moderator
22781 ban-contact
22782 enable-account
22783 disable-account)
22784 @end example
22785
22786 The above actions aim to provide the most valuable actions for
22787 moderation purposes, not to cover the whole Jami API. Users wanting to
22788 interact with the Jami daemon from Guile may be interested in
22789 experimenting with the @code{(gnu build jami-service)} module, which
22790 powers the above Shepherd actions.
22791
22792 @c TODO: This should be auto-generated from the doc already defined on
22793 @c the shepherd-actions themselves in (gnu services telephony).
22794 The @code{add-moderator} and @code{ban-contact} actions accept a contact
22795 @emph{fingerprint} (40 characters long hash) as first argument and an
22796 account fingerprint or username as second argument:
22797
22798 @example sh
22799 # herd add-moderator jami 1dbcb0f5f37324228235564b79f2b9737e9a008f \
22800 f3345f2775ddfe07a4b0d95daea111d15fbc1199
22801
22802 # herd list-moderators jami
22803 Moderators for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
22804 - 1dbcb0f5f37324228235564b79f2b9737e9a008f
22805
22806 @end example
22807
22808 In the case of @code{ban-contact}, the second username argument is
22809 optional; when omitted, the account is banned from all Jami accounts:
22810
22811 @example sh
22812 # herd ban-contact jami 1dbcb0f5f37324228235564b79f2b9737e9a008f
22813
22814 # herd list-banned-contacts jami
22815 Banned contacts for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
22816 - 1dbcb0f5f37324228235564b79f2b9737e9a008f
22817
22818 @end example
22819
22820 Banned contacts are also stripped from their moderation privileges.
22821
22822 The @code{disable-account} action allows to completely disconnect an
22823 account from the network, making it unreachable, while
22824 @code{enable-account} does the inverse. They accept a single account
22825 username or fingerprint as first argument:
22826
22827 @example sh
22828 # herd disable-account jami f3345f2775ddfe07a4b0d95daea111d15fbc1199
22829
22830 # herd list-accounts jami
22831 The following Jami accounts are available:
22832 - f3345f2775ddfe07a4b0d95daea111d15fbc1199 (dummy) [disabled]
22833
22834 @end example
22835
22836 The @code{list-account-details} action prints the detailed parameters of
22837 each accounts in the Recutils format, which means the @command{recsel}
22838 command can be used to select accounts of interest (@pxref{Selection
22839 Expressions,,,recutils, GNU recutils manual}). Note that period
22840 characters (@samp{.}) found in the account parameter keys are mapped to
22841 underscores (@samp{_}) in the output, to meet the requirements of the
22842 Recutils format. The following example shows how to print the account
22843 fingerprints for all accounts operating in the rendezvous point mode:
22844
22845 @example sh
22846 # herd list-account-details jami | \
22847 recsel -p Account.username -e 'Account.rendezVous ~ "true"'
22848 Account_username: f3345f2775ddfe07a4b0d95daea111d15fbc1199
22849 @end example
22850
22851 The remaining actions should be self-explanatory.
22852
22853 The complete set of available configuration options is detailed below.
22854
22855 @c TODO: Ideally, the following fragments would be auto-generated at
22856 @c build time, so that they needn't be manually duplicated.
22857 @c Auto-generated via (configuration->documentation 'jami-configuration)
22858 @deftp {Data Type} jami-configuration
22859 Available @code{jami-configuration} fields are:
22860
22861 @table @asis
22862 @item @code{jamid} (default: @code{libring}) (type: package)
22863 The Jami daemon package to use.
22864
22865 @item @code{dbus} (default: @code{dbus}) (type: package)
22866 The D-Bus package to use to start the required D-Bus session.
22867
22868 @item @code{nss-certs} (default: @code{nss-certs}) (type: package)
22869 The nss-certs package to use to provide TLS certificates.
22870
22871 @item @code{enable-logging?} (default: @code{#t}) (type: boolean)
22872 Whether to enable logging to syslog.
22873
22874 @item @code{debug?} (default: @code{#f}) (type: boolean)
22875 Whether to enable debug level messages.
22876
22877 @item @code{auto-answer?} (default: @code{#f}) (type: boolean)
22878 Whether to force automatic answer to incoming calls.
22879
22880 @item @code{accounts} (default: @code{disabled}) (type: maybe-jami-account-list)
22881 A list of Jami accounts to be (re-)provisioned every time the Jami
22882 daemon service starts. When providing this field, the account
22883 directories under @file{/var/lib/jami/} are recreated every time the
22884 service starts, ensuring a consistent state.
22885
22886 @end table
22887
22888 @end deftp
22889
22890 @c Auto-generated via (configuration->documentation 'jami-account)
22891 @deftp {Data Type} jami-account
22892 Available @code{jami-account} fields are:
22893
22894 @table @asis
22895 @item @code{archive} (type: string-or-computed-file)
22896 The account archive (backup) file name of the account. This is used to
22897 provision the account when the service starts. The account archive
22898 should @emph{not} be encrypted. It is highly recommended to make it
22899 readable only to the @samp{root} user (i.e., not in the store), to guard
22900 against leaking the secret key material of the Jami account it contains.
22901
22902 @item @code{allowed-contacts} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
22903 The list of allowed contacts for the account, entered as their 40
22904 characters long fingerprint. Messages or calls from accounts not in
22905 that list will be rejected. When unspecified, the configuration of the
22906 account archive is used as-is with respect to contacts and public
22907 inbound calls/messaging allowance, which typically defaults to allow any
22908 contact to communicate with the account.
22909
22910 @item @code{moderators} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
22911 The list of contacts that should have moderation privileges (to ban,
22912 mute, etc. other users) in rendezvous conferences, entered as their 40
22913 characters long fingerprint. When unspecified, the configuration of the
22914 account archive is used as-is with respect to moderation, which
22915 typically defaults to allow anyone to moderate.
22916
22917 @item @code{rendezvous-point?} (default: @code{disabled}) (type: maybe-boolean)
22918 Whether the account should operate in the rendezvous mode. In this
22919 mode, all the incoming audio/video calls are mixed into a conference.
22920 When left unspecified, the value from the account archive prevails.
22921
22922 @item @code{peer-discovery?} (default: @code{disabled}) (type: maybe-boolean)
22923 Whether peer discovery should be enabled. Peer discovery is used to
22924 discover other OpenDHT nodes on the local network, which can be useful
22925 to maintain communication between devices on such network even when the
22926 connection to the the Internet has been lost. When left unspecified,
22927 the value from the account archive prevails.
22928
22929 @item @code{bootstrap-hostnames} (default: @code{disabled}) (type: maybe-string-list)
22930 A list of hostnames or IPs pointing to OpenDHT nodes, that should be
22931 used to initially join the OpenDHT network. When left unspecified, the
22932 value from the account archive prevails.
22933
22934 @item @code{name-server-uri} (default: @code{disabled}) (type: maybe-string)
22935 The URI of the name server to use, that can be used to retrieve the
22936 account fingerprint for a registered username.
22937
22938 @end table
22939
22940 @end deftp
22941
22942 @subsubheading Murmur (VoIP server)
22943
22944 @cindex Murmur (VoIP server)
22945 @cindex VoIP server
22946 This section describes how to set up and run a Murmur server. Murmur is
22947 the server of the @uref{https://mumble.info, Mumble} voice-over-IP
22948 (VoIP) suite.
22949
22950 @deftp {Data Type} murmur-configuration
22951 The service type for the Murmur server. An example configuration can
22952 look like this:
22953
22954 @lisp
22955 (service murmur-service-type
22956 (murmur-configuration
22957 (welcome-text
22958 "Welcome to this Mumble server running on Guix!")
22959 (cert-required? #t) ;disallow text password logins
22960 (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
22961 (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
22962 @end lisp
22963
22964 After reconfiguring your system, you can manually set the murmur @code{SuperUser}
22965 password with the command that is printed during the activation phase.
22966
22967 It is recommended to register a normal Mumble user account
22968 and grant it admin or moderator rights.
22969 You can use the @code{mumble} client to
22970 login as new normal user, register yourself, and log out.
22971 For the next step login with the name @code{SuperUser} use
22972 the @code{SuperUser} password that you set previously,
22973 and grant your newly registered mumble user administrator or moderator
22974 rights and create some channels.
22975
22976 Available @code{murmur-configuration} fields are:
22977
22978 @table @asis
22979 @item @code{package} (default: @code{mumble})
22980 Package that contains @code{bin/murmurd}.
22981
22982 @item @code{user} (default: @code{"murmur"})
22983 User who will run the Murmur server.
22984
22985 @item @code{group} (default: @code{"murmur"})
22986 Group of the user who will run the murmur server.
22987
22988 @item @code{port} (default: @code{64738})
22989 Port on which the server will listen.
22990
22991 @item @code{welcome-text} (default: @code{""})
22992 Welcome text sent to clients when they connect.
22993
22994 @item @code{server-password} (default: @code{""})
22995 Password the clients have to enter in order to connect.
22996
22997 @item @code{max-users} (default: @code{100})
22998 Maximum of users that can be connected to the server at once.
22999
23000 @item @code{max-user-bandwidth} (default: @code{#f})
23001 Maximum voice traffic a user can send per second.
23002
23003 @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
23004 File name of the sqlite database.
23005 The service's user will become the owner of the directory.
23006
23007 @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
23008 File name of the log file.
23009 The service's user will become the owner of the directory.
23010
23011 @item @code{autoban-attempts} (default: @code{10})
23012 Maximum number of logins a user can make in @code{autoban-timeframe}
23013 without getting auto banned for @code{autoban-time}.
23014
23015 @item @code{autoban-timeframe} (default: @code{120})
23016 Timeframe for autoban in seconds.
23017
23018 @item @code{autoban-time} (default: @code{300})
23019 Amount of time in seconds for which a client gets banned
23020 when violating the autoban limits.
23021
23022 @item @code{opus-threshold} (default: @code{100})
23023 Percentage of clients that need to support opus
23024 before switching over to opus audio codec.
23025
23026 @item @code{channel-nesting-limit} (default: @code{10})
23027 How deep channels can be nested at maximum.
23028
23029 @item @code{channelname-regex} (default: @code{#f})
23030 A string in form of a Qt regular expression that channel names must conform to.
23031
23032 @item @code{username-regex} (default: @code{#f})
23033 A string in form of a Qt regular expression that user names must conform to.
23034
23035 @item @code{text-message-length} (default: @code{5000})
23036 Maximum size in bytes that a user can send in one text chat message.
23037
23038 @item @code{image-message-length} (default: @code{(* 128 1024)})
23039 Maximum size in bytes that a user can send in one image message.
23040
23041 @item @code{cert-required?} (default: @code{#f})
23042 If it is set to @code{#t} clients that use weak password authentication
23043 will not be accepted. Users must have completed the certificate wizard to join.
23044
23045 @item @code{remember-channel?} (default: @code{#f})
23046 Should murmur remember the last channel each user was in when they disconnected
23047 and put them into the remembered channel when they rejoin.
23048
23049 @item @code{allow-html?} (default: @code{#f})
23050 Should html be allowed in text messages, user comments, and channel descriptions.
23051
23052 @item @code{allow-ping?} (default: @code{#f})
23053 Setting to true exposes the current user count, the maximum user count, and
23054 the server's maximum bandwidth per client to unauthenticated users. In the
23055 Mumble client, this information is shown in the Connect dialog.
23056
23057 Disabling this setting will prevent public listing of the server.
23058
23059 @item @code{bonjour?} (default: @code{#f})
23060 Should the server advertise itself in the local network through the bonjour protocol.
23061
23062 @item @code{send-version?} (default: @code{#f})
23063 Should the murmur server version be exposed in ping requests.
23064
23065 @item @code{log-days} (default: @code{31})
23066 Murmur also stores logs in the database, which are accessible via RPC.
23067 The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
23068 or -1 to disable logging to the database.
23069
23070 @item @code{obfuscate-ips?} (default: @code{#t})
23071 Should logged ips be obfuscated to protect the privacy of users.
23072
23073 @item @code{ssl-cert} (default: @code{#f})
23074 File name of the SSL/TLS certificate used for encrypted connections.
23075
23076 @lisp
23077 (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
23078 @end lisp
23079 @item @code{ssl-key} (default: @code{#f})
23080 Filepath to the ssl private key used for encrypted connections.
23081 @lisp
23082 (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
23083 @end lisp
23084
23085 @item @code{ssl-dh-params} (default: @code{#f})
23086 File name of a PEM-encoded file with Diffie-Hellman parameters
23087 for the SSL/TLS encryption. Alternatively you set it to
23088 @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
23089 or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
23090
23091 @item @code{ssl-ciphers} (default: @code{#f})
23092 The @code{ssl-ciphers} option chooses the cipher suites to make available for use
23093 in SSL/TLS.
23094
23095 This option is specified using
23096 @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
23097 OpenSSL cipher list notation}.
23098
23099 It is recommended that you try your cipher string using 'openssl ciphers <string>'
23100 before setting it here, to get a feel for which cipher suites you will get.
23101 After setting this option, it is recommend that you inspect your Murmur log
23102 to ensure that Murmur is using the cipher suites that you expected it to.
23103
23104 Note: Changing this option may impact the backwards compatibility of your
23105 Murmur server, and can remove the ability for older Mumble clients to be able
23106 to connect to it.
23107
23108 @item @code{public-registration} (default: @code{#f})
23109 Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
23110
23111 You can optionally register your server in the public server list that the
23112 @code{mumble} client shows on startup.
23113 You cannot register your server if you have set a @code{server-password},
23114 or set @code{allow-ping} to @code{#f}.
23115
23116 It might take a few hours until it shows up in the public list.
23117
23118 @item @code{file} (default: @code{#f})
23119 Optional alternative override for this configuration.
23120 @end table
23121 @end deftp
23122
23123 @deftp {Data Type} murmur-public-registration-configuration
23124 Configuration for public registration of a murmur service.
23125
23126 @table @asis
23127 @item @code{name}
23128 This is a display name for your server. Not to be confused with the hostname.
23129
23130 @item @code{password}
23131 A password to identify your registration.
23132 Subsequent updates will need the same password. Don't lose your password.
23133
23134 @item @code{url}
23135 This should be a @code{http://} or @code{https://} link to your web
23136 site.
23137
23138 @item @code{hostname} (default: @code{#f})
23139 By default your server will be listed by its IP address.
23140 If it is set your server will be linked by this host name instead.
23141 @end table
23142 @end deftp
23143
23144
23145
23146 @node File-Sharing Services
23147 @subsection File-Sharing Services
23148
23149 The @code{(gnu services file-sharing)} module provides services that
23150 assist with transferring files over peer-to-peer file-sharing networks.
23151
23152 @subsubheading Transmission Daemon Service
23153
23154 @uref{https://transmissionbt.com/, Transmission} is a flexible
23155 BitTorrent client that offers a variety of graphical and command-line
23156 interfaces. A @code{transmission-daemon-service-type} service provides
23157 Transmission's headless variant, @command{transmission-daemon}, as a
23158 system service, allowing users to share files via BitTorrent even when
23159 they are not logged in.
23160
23161 @deffn {Scheme Variable} transmission-daemon-service-type
23162 The service type for the Transmission Daemon BitTorrent client. Its
23163 value must be a @code{transmission-daemon-configuration} object as in
23164 this example:
23165
23166 @lisp
23167 (service transmission-daemon-service-type
23168 (transmission-daemon-configuration
23169 ;; Restrict access to the RPC ("control") interface
23170 (rpc-authentication-required? #t)
23171 (rpc-username "transmission")
23172 (rpc-password
23173 (transmission-password-hash
23174 "transmission" ; desired password
23175 "uKd1uMs9")) ; arbitrary salt value
23176
23177 ;; Accept requests from this and other hosts on the
23178 ;; local network
23179 (rpc-whitelist-enabled? #t)
23180 (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
23181
23182 ;; Limit bandwidth use during work hours
23183 (alt-speed-down (* 1024 2)) ; 2 MB/s
23184 (alt-speed-up 512) ; 512 kB/s
23185
23186 (alt-speed-time-enabled? #t)
23187 (alt-speed-time-day 'weekdays)
23188 (alt-speed-time-begin
23189 (+ (* 60 8) 30)) ; 8:30 am
23190 (alt-speed-time-end
23191 (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
23192 @end lisp
23193 @end deffn
23194
23195 Once the service is started, users can interact with the daemon through
23196 its Web interface (at @code{http://localhost:9091/}) or by using the
23197 @command{transmission-remote} command-line tool, available in the
23198 @code{transmission} package. (Emacs users may want to also consider the
23199 @code{emacs-transmission} package.) Both communicate with the daemon
23200 through its remote procedure call (RPC) interface, which by default is
23201 available to all users on the system; you may wish to change this by
23202 assigning values to the @code{rpc-authentication-required?},
23203 @code{rpc-username} and @code{rpc-password} settings, as shown in the
23204 example above and documented further below.
23205
23206 The value for @code{rpc-password} must be a password hash of the type
23207 generated and used by Transmission clients. This can be copied verbatim
23208 from an existing @file{settings.json} file, if another Transmission
23209 client is already being used. Otherwise, the
23210 @code{transmission-password-hash} and @code{transmission-random-salt}
23211 procedures provided by this module can be used to obtain a suitable hash
23212 value.
23213
23214 @deffn {Scheme Procedure} transmission-password-hash @var{password} @var{salt}
23215 Returns a string containing the result of hashing @var{password}
23216 together with @var{salt}, in the format recognized by Transmission
23217 clients for their @code{rpc-password} configuration setting.
23218
23219 @var{salt} must be an eight-character string. The
23220 @code{transmission-random-salt} procedure can be used to generate a
23221 suitable salt value at random.
23222 @end deffn
23223
23224 @deffn {Scheme Procedure} transmission-random-salt
23225 Returns a string containing a random, eight-character salt value of the
23226 type generated and used by Transmission clients, suitable for passing to
23227 the @code{transmission-password-hash} procedure.
23228 @end deffn
23229
23230 These procedures are accessible from within a Guile REPL started with
23231 the @command{guix repl} command (@pxref{Invoking guix repl}). This is
23232 useful for obtaining a random salt value to provide as the second
23233 parameter to `transmission-password-hash`, as in this example session:
23234
23235 @example
23236 $ guix repl
23237 scheme@@(guix-user)> ,use (gnu services file-sharing)
23238 scheme@@(guix-user)> (transmission-random-salt)
23239 $1 = "uKd1uMs9"
23240 @end example
23241
23242 Alternatively, a complete password hash can generated in a single step:
23243
23244 @example
23245 scheme@@(guix-user)> (transmission-password-hash "transmission"
23246 (transmission-random-salt))
23247 $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
23248 @end example
23249
23250 The resulting string can be used as-is for the value of
23251 @code{rpc-password}, allowing the password to be kept hidden even in the
23252 operating-system configuration.
23253
23254 Torrent files downloaded by the daemon are directly accessible only to
23255 users in the ``transmission'' user group, who receive read-only access
23256 to the directory specified by the @code{download-dir} configuration
23257 setting (and also the directory specified by @code{incomplete-dir}, if
23258 @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
23259 moved to another directory or deleted altogether using
23260 @command{transmission-remote} with its @code{--move} and
23261 @code{--remove-and-delete} options.
23262
23263 If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
23264 the ``transmission'' group are able also to place @file{.torrent} files
23265 in the directory specified by @code{watch-dir} to have the corresponding
23266 torrents added by the daemon. (The @code{trash-original-torrent-files?}
23267 setting controls whether the daemon deletes these files after processing
23268 them.)
23269
23270 Some of the daemon's configuration settings can be changed temporarily
23271 by @command{transmission-remote} and similar tools. To undo these
23272 changes, use the service's @code{reload} action to have the daemon
23273 reload its settings from disk:
23274
23275 @example
23276 # herd reload transmission-daemon
23277 @end example
23278
23279 The full set of available configuration settings is defined by the
23280 @code{transmission-daemon-configuration} data type.
23281
23282 @deftp {Data Type} transmission-daemon-configuration
23283 The data type representing configuration settings for Transmission
23284 Daemon. These correspond directly to the settings recognized by
23285 Transmission clients in their @file{settings.json} file.
23286 @end deftp
23287
23288 @c The following documentation was initially generated by
23289 @c (generate-transmission-daemon-documentation) in (gnu services
23290 @c file-sharing). Manually maintained documentation is better, so we
23291 @c shouldn't hesitate to edit below as needed. However if the change
23292 @c you want to make to this documentation can be done in an automated
23293 @c way, it's probably easier to change (generate-documentation) than to
23294 @c make it below and have to deal with the churn as Transmission Daemon
23295 @c updates.
23296
23297 @c %start of fragment
23298
23299 Available @code{transmission-daemon-configuration} fields are:
23300
23301 @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
23302 The Transmission package to use.
23303
23304 @end deftypevr
23305
23306 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
23307 The period, in seconds, to wait when stopping the service for
23308 @command{transmission-daemon} to exit before killing its process. This
23309 allows the daemon time to complete its housekeeping and send a final
23310 update to trackers as it shuts down. On slow hosts, or hosts with a
23311 slow network connection, this value may need to be increased.
23312
23313 Defaults to @samp{10}.
23314
23315 @end deftypevr
23316
23317 @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
23318 The directory to which torrent files are downloaded.
23319
23320 Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
23321
23322 @end deftypevr
23323
23324 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
23325 If @code{#t}, files will be held in @code{incomplete-dir} while their
23326 torrent is being downloaded, then moved to @code{download-dir} once the
23327 torrent is complete. Otherwise, files for all torrents (including those
23328 still being downloaded) will be placed in @code{download-dir}.
23329
23330 Defaults to @samp{#f}.
23331
23332 @end deftypevr
23333
23334 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
23335 The directory in which files from incompletely downloaded torrents will
23336 be held when @code{incomplete-dir-enabled?} is @code{#t}.
23337
23338 Defaults to @samp{disabled}.
23339
23340 @end deftypevr
23341
23342 @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
23343 The file mode creation mask used for downloaded files. (See the
23344 @command{umask} man page for more information.)
23345
23346 Defaults to @samp{18}.
23347
23348 @end deftypevr
23349
23350 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
23351 When @code{#t}, ``.part'' is appended to the name of partially
23352 downloaded files.
23353
23354 Defaults to @samp{#t}.
23355
23356 @end deftypevr
23357
23358 @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
23359 The mode by which space should be preallocated for downloaded files, one
23360 of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
23361 Specifying @code{full} will minimize disk fragmentation at a cost to
23362 file-creation speed.
23363
23364 Defaults to @samp{fast}.
23365
23366 @end deftypevr
23367
23368 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
23369 If @code{#t}, the directory specified by @code{watch-dir} will be
23370 watched for new @file{.torrent} files and the torrents they describe
23371 added automatically (and the original files removed, if
23372 @code{trash-original-torrent-files?} is @code{#t}).
23373
23374 Defaults to @samp{#f}.
23375
23376 @end deftypevr
23377
23378 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
23379 The directory to be watched for @file{.torrent} files indicating new
23380 torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
23381
23382 Defaults to @samp{disabled}.
23383
23384 @end deftypevr
23385
23386 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
23387 When @code{#t}, @file{.torrent} files will be deleted from the watch
23388 directory once their torrent has been added (see
23389 @code{watch-directory-enabled?}).
23390
23391 Defaults to @samp{#f}.
23392
23393 @end deftypevr
23394
23395 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
23396 When @code{#t}, the daemon's download speed will be limited to the rate
23397 specified by @code{speed-limit-down}.
23398
23399 Defaults to @samp{#f}.
23400
23401 @end deftypevr
23402
23403 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
23404 The default global-maximum download speed, in kilobytes per second.
23405
23406 Defaults to @samp{100}.
23407
23408 @end deftypevr
23409
23410 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
23411 When @code{#t}, the daemon's upload speed will be limited to the rate
23412 specified by @code{speed-limit-up}.
23413
23414 Defaults to @samp{#f}.
23415
23416 @end deftypevr
23417
23418 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
23419 The default global-maximum upload speed, in kilobytes per second.
23420
23421 Defaults to @samp{100}.
23422
23423 @end deftypevr
23424
23425 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
23426 When @code{#t}, the alternate speed limits @code{alt-speed-down} and
23427 @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
23428 @code{speed-limit-up}, if they are enabled) to constrain the daemon's
23429 bandwidth usage. This can be scheduled to occur automatically at
23430 certain times during the week; see @code{alt-speed-time-enabled?}.
23431
23432 Defaults to @samp{#f}.
23433
23434 @end deftypevr
23435
23436 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
23437 The alternate global-maximum download speed, in kilobytes per second.
23438
23439 Defaults to @samp{50}.
23440
23441 @end deftypevr
23442
23443 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
23444 The alternate global-maximum upload speed, in kilobytes per second.
23445
23446 Defaults to @samp{50}.
23447
23448 @end deftypevr
23449
23450 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
23451 When @code{#t}, the alternate speed limits @code{alt-speed-down} and
23452 @code{alt-speed-up} will be enabled automatically during the periods
23453 specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
23454 @code{alt-time-speed-end}.
23455
23456 Defaults to @samp{#f}.
23457
23458 @end deftypevr
23459
23460 @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
23461 The days of the week on which the alternate-speed schedule should be
23462 used, specified either as a list of days (@code{sunday}, @code{monday},
23463 and so on) or using one of the symbols @code{weekdays}, @code{weekends}
23464 or @code{all}.
23465
23466 Defaults to @samp{all}.
23467
23468 @end deftypevr
23469
23470 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
23471 The time of day at which to enable the alternate speed limits, expressed
23472 as a number of minutes since midnight.
23473
23474 Defaults to @samp{540}.
23475
23476 @end deftypevr
23477
23478 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
23479 The time of day at which to disable the alternate speed limits,
23480 expressed as a number of minutes since midnight.
23481
23482 Defaults to @samp{1020}.
23483
23484 @end deftypevr
23485
23486 @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
23487 The IP address at which to listen for peer connections, or ``0.0.0.0''
23488 to listen at all available IP addresses.
23489
23490 Defaults to @samp{"0.0.0.0"}.
23491
23492 @end deftypevr
23493
23494 @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
23495 The IPv6 address at which to listen for peer connections, or ``::'' to
23496 listen at all available IPv6 addresses.
23497
23498 Defaults to @samp{"::"}.
23499
23500 @end deftypevr
23501
23502 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
23503 If @code{#t}, when the daemon starts it will select a port at random on
23504 which to listen for peer connections, from the range specified
23505 (inclusively) by @code{peer-port-random-low} and
23506 @code{peer-port-random-high}. Otherwise, it listens on the port
23507 specified by @code{peer-port}.
23508
23509 Defaults to @samp{#f}.
23510
23511 @end deftypevr
23512
23513 @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
23514 The lowest selectable port number when @code{peer-port-random-on-start?}
23515 is @code{#t}.
23516
23517 Defaults to @samp{49152}.
23518
23519 @end deftypevr
23520
23521 @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
23522 The highest selectable port number when @code{peer-port-random-on-start}
23523 is @code{#t}.
23524
23525 Defaults to @samp{65535}.
23526
23527 @end deftypevr
23528
23529 @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
23530 The port on which to listen for peer connections when
23531 @code{peer-port-random-on-start?} is @code{#f}.
23532
23533 Defaults to @samp{51413}.
23534
23535 @end deftypevr
23536
23537 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
23538 If @code{#t}, the daemon will attempt to configure port-forwarding on an
23539 upstream gateway automatically using @acronym{UPnP} and
23540 @acronym{NAT-PMP}.
23541
23542 Defaults to @samp{#t}.
23543
23544 @end deftypevr
23545
23546 @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
23547 The encryption preference for peer connections, one of
23548 @code{prefer-unencrypted-connections},
23549 @code{prefer-encrypted-connections} or
23550 @code{require-encrypted-connections}.
23551
23552 Defaults to @samp{prefer-encrypted-connections}.
23553
23554 @end deftypevr
23555
23556 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
23557 The TCP congestion-control algorithm to use for peer connections,
23558 specified using a string recognized by the operating system in calls to
23559 @code{setsockopt} (or set to @code{disabled}, in which case the
23560 operating-system default is used).
23561
23562 Note that on GNU/Linux systems, the kernel must be configured to allow
23563 processes to use a congestion-control algorithm not in the default set;
23564 otherwise, it will deny these requests with ``Operation not permitted''.
23565 To see which algorithms are available on your system and which are
23566 currently permitted for use, look at the contents of the files
23567 @file{tcp_available_congestion_control} and
23568 @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
23569 directory.
23570
23571 As an example, to have Transmission Daemon use
23572 @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
23573 congestion-control algorithm}, you'll need to modify your kernel
23574 configuration to build in support for the algorithm, then update your
23575 operating-system configuration to allow its use by adding a
23576 @code{sysctl-service-type} service (or updating the existing one's
23577 configuration) with lines like the following:
23578
23579 @lisp
23580 (service sysctl-service-type
23581 (sysctl-configuration
23582 (settings
23583 ("net.ipv4.tcp_allowed_congestion_control" .
23584 "reno cubic lp"))))
23585 @end lisp
23586
23587 The Transmission Daemon configuration can then be updated with
23588
23589 @lisp
23590 (peer-congestion-algorithm "lp")
23591 @end lisp
23592
23593 and the system reconfigured to have the changes take effect.
23594
23595 Defaults to @samp{disabled}.
23596
23597 @end deftypevr
23598
23599 @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
23600 The type of service to request in outgoing @acronym{TCP} packets, one of
23601 @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
23602 @code{reliability}.
23603
23604 Defaults to @samp{default}.
23605
23606 @end deftypevr
23607
23608 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
23609 The global limit on the number of connected peers.
23610
23611 Defaults to @samp{200}.
23612
23613 @end deftypevr
23614
23615 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
23616 The per-torrent limit on the number of connected peers.
23617
23618 Defaults to @samp{50}.
23619
23620 @end deftypevr
23621
23622 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
23623 The maximum number of peers to which the daemon will upload data
23624 simultaneously for each torrent.
23625
23626 Defaults to @samp{14}.
23627
23628 @end deftypevr
23629
23630 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
23631 The maximum lifespan, in hours, of the peer ID associated with each
23632 public torrent before it is regenerated.
23633
23634 Defaults to @samp{6}.
23635
23636 @end deftypevr
23637
23638 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
23639 When @code{#t}, the daemon will ignore peers mentioned in the blocklist
23640 it has most recently downloaded from @code{blocklist-url}.
23641
23642 Defaults to @samp{#f}.
23643
23644 @end deftypevr
23645
23646 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
23647 The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
23648 @file{.dat} format) to be periodically downloaded and applied when
23649 @code{blocklist-enabled?} is @code{#t}.
23650
23651 Defaults to @samp{disabled}.
23652
23653 @end deftypevr
23654
23655 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
23656 If @code{#t}, the daemon will be limited to downloading at most
23657 @code{download-queue-size} non-stalled torrents simultaneously.
23658
23659 Defaults to @samp{#t}.
23660
23661 @end deftypevr
23662
23663 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
23664 The size of the daemon's download queue, which limits the number of
23665 non-stalled torrents it will download at any one time when
23666 @code{download-queue-enabled?} is @code{#t}.
23667
23668 Defaults to @samp{5}.
23669
23670 @end deftypevr
23671
23672 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
23673 If @code{#t}, the daemon will be limited to seeding at most
23674 @code{seed-queue-size} non-stalled torrents simultaneously.
23675
23676 Defaults to @samp{#f}.
23677
23678 @end deftypevr
23679
23680 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
23681 The size of the daemon's seed queue, which limits the number of
23682 non-stalled torrents it will seed at any one time when
23683 @code{seed-queue-enabled?} is @code{#t}.
23684
23685 Defaults to @samp{10}.
23686
23687 @end deftypevr
23688
23689 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
23690 When @code{#t}, the daemon will consider torrents for which it has not
23691 shared data in the past @code{queue-stalled-minutes} minutes to be
23692 stalled and not count them against its @code{download-queue-size} and
23693 @code{seed-queue-size} limits.
23694
23695 Defaults to @samp{#t}.
23696
23697 @end deftypevr
23698
23699 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
23700 The maximum period, in minutes, a torrent may be idle before it is
23701 considered to be stalled, when @code{queue-stalled-enabled?} is
23702 @code{#t}.
23703
23704 Defaults to @samp{30}.
23705
23706 @end deftypevr
23707
23708 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
23709 When @code{#t}, a torrent being seeded will automatically be paused once
23710 it reaches the ratio specified by @code{ratio-limit}.
23711
23712 Defaults to @samp{#f}.
23713
23714 @end deftypevr
23715
23716 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
23717 The ratio at which a torrent being seeded will be paused, when
23718 @code{ratio-limit-enabled?} is @code{#t}.
23719
23720 Defaults to @samp{2.0}.
23721
23722 @end deftypevr
23723
23724 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
23725 When @code{#t}, a torrent being seeded will automatically be paused once
23726 it has been idle for @code{idle-seeding-limit} minutes.
23727
23728 Defaults to @samp{#f}.
23729
23730 @end deftypevr
23731
23732 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
23733 The maximum period, in minutes, a torrent being seeded may be idle
23734 before it is paused, when @code{idle-seeding-limit-enabled?} is
23735 @code{#t}.
23736
23737 Defaults to @samp{30}.
23738
23739 @end deftypevr
23740
23741 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
23742 Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
23743 hash table (@acronym{DHT}) protocol}, which supports the use of
23744 trackerless torrents.
23745
23746 Defaults to @samp{#t}.
23747
23748 @end deftypevr
23749
23750 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
23751 Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
23752 peer discovery} (@acronym{LPD}), which allows the discovery of peers on
23753 the local network and may reduce the amount of data sent over the public
23754 Internet.
23755
23756 Defaults to @samp{#f}.
23757
23758 @end deftypevr
23759
23760 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
23761 Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
23762 (@acronym{PEX}), which reduces the daemon's reliance on external
23763 trackers and may improve its performance.
23764
23765 Defaults to @samp{#t}.
23766
23767 @end deftypevr
23768
23769 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
23770 Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
23771 transport protocol} (@acronym{uTP}), which aims to reduce the impact of
23772 BitTorrent traffic on other users of the local network while maintaining
23773 full utilization of the available bandwidth.
23774
23775 Defaults to @samp{#t}.
23776
23777 @end deftypevr
23778
23779 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
23780 If @code{#t}, enable the remote procedure call (@acronym{RPC})
23781 interface, which allows remote control of the daemon via its Web
23782 interface, the @command{transmission-remote} command-line client, and
23783 similar tools.
23784
23785 Defaults to @samp{#t}.
23786
23787 @end deftypevr
23788
23789 @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
23790 The IP address at which to listen for @acronym{RPC} connections, or
23791 ``0.0.0.0'' to listen at all available IP addresses.
23792
23793 Defaults to @samp{"0.0.0.0"}.
23794
23795 @end deftypevr
23796
23797 @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
23798 The port on which to listen for @acronym{RPC} connections.
23799
23800 Defaults to @samp{9091}.
23801
23802 @end deftypevr
23803
23804 @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
23805 The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
23806
23807 Defaults to @samp{"/transmission/"}.
23808
23809 @end deftypevr
23810
23811 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
23812 When @code{#t}, clients must authenticate (see @code{rpc-username} and
23813 @code{rpc-password}) when using the @acronym{RPC} interface. Note this
23814 has the side effect of disabling host-name whitelisting (see
23815 @code{rpc-host-whitelist-enabled?}.
23816
23817 Defaults to @samp{#f}.
23818
23819 @end deftypevr
23820
23821 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
23822 The username required by clients to access the @acronym{RPC} interface
23823 when @code{rpc-authentication-required?} is @code{#t}.
23824
23825 Defaults to @samp{disabled}.
23826
23827 @end deftypevr
23828
23829 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
23830 The password required by clients to access the @acronym{RPC} interface
23831 when @code{rpc-authentication-required?} is @code{#t}. This must be
23832 specified using a password hash in the format recognized by Transmission
23833 clients, either copied from an existing @file{settings.json} file or
23834 generated using the @code{transmission-password-hash} procedure.
23835
23836 Defaults to @samp{disabled}.
23837
23838 @end deftypevr
23839
23840 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
23841 When @code{#t}, @acronym{RPC} requests will be accepted only when they
23842 originate from an address specified in @code{rpc-whitelist}.
23843
23844 Defaults to @samp{#t}.
23845
23846 @end deftypevr
23847
23848 @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
23849 The list of IP and IPv6 addresses from which @acronym{RPC} requests will
23850 be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
23851 may be specified using @samp{*}.
23852
23853 Defaults to @samp{("127.0.0.1" "::1")}.
23854
23855 @end deftypevr
23856
23857 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
23858 When @code{#t}, @acronym{RPC} requests will be accepted only when they
23859 are addressed to a host named in @code{rpc-host-whitelist}. Note that
23860 requests to ``localhost'' or ``localhost.'', or to a numeric address,
23861 are always accepted regardless of these settings.
23862
23863 Note also this functionality is disabled when
23864 @code{rpc-authentication-required?} is @code{#t}.
23865
23866 Defaults to @samp{#t}.
23867
23868 @end deftypevr
23869
23870 @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
23871 The list of host names recognized by the @acronym{RPC} server when
23872 @code{rpc-host-whitelist-enabled?} is @code{#t}.
23873
23874 Defaults to @samp{()}.
23875
23876 @end deftypevr
23877
23878 @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
23879 The minimum severity level of messages to be logged (to
23880 @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
23881 logging), @code{error}, @code{info} and @code{debug}.
23882
23883 Defaults to @samp{info}.
23884
23885 @end deftypevr
23886
23887 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
23888 When @code{#t}, torrents are started as soon as they are added;
23889 otherwise, they are added in ``paused'' state.
23890
23891 Defaults to @samp{#t}.
23892
23893 @end deftypevr
23894
23895 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
23896 When @code{#t}, the script specified by
23897 @code{script-torrent-done-filename} will be invoked each time a torrent
23898 completes.
23899
23900 Defaults to @samp{#f}.
23901
23902 @end deftypevr
23903
23904 @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
23905 A file name or file-like object specifying a script to run each time a
23906 torrent completes, when @code{script-torrent-done-enabled?} is
23907 @code{#t}.
23908
23909 Defaults to @samp{disabled}.
23910
23911 @end deftypevr
23912
23913 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
23914 When @code{#t}, the daemon will scrape trackers for a torrent even when
23915 the torrent is paused.
23916
23917 Defaults to @samp{#t}.
23918
23919 @end deftypevr
23920
23921 @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
23922 The amount of memory, in megabytes, to allocate for the daemon's
23923 in-memory cache. A larger value may increase performance by reducing
23924 the frequency of disk I/O.
23925
23926 Defaults to @samp{4}.
23927
23928 @end deftypevr
23929
23930 @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
23931 When @code{#t}, the daemon will try to improve I/O performance by
23932 hinting to the operating system which data is likely to be read next
23933 from disk to satisfy requests from peers.
23934
23935 Defaults to @samp{#t}.
23936
23937 @end deftypevr
23938
23939
23940 @c %end of fragment
23941
23942
23943
23944 @node Monitoring Services
23945 @subsection Monitoring Services
23946
23947 @subsubheading Tailon Service
23948
23949 @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
23950 viewing and searching log files.
23951
23952 The following example will configure the service with default values.
23953 By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
23954
23955 @lisp
23956 (service tailon-service-type)
23957 @end lisp
23958
23959 The following example customises more of the Tailon configuration,
23960 adding @command{sed} to the list of allowed commands.
23961
23962 @lisp
23963 (service tailon-service-type
23964 (tailon-configuration
23965 (config-file
23966 (tailon-configuration-file
23967 (allowed-commands '("tail" "grep" "awk" "sed"))))))
23968 @end lisp
23969
23970
23971 @deftp {Data Type} tailon-configuration
23972 Data type representing the configuration of Tailon.
23973 This type has the following parameters:
23974
23975 @table @asis
23976 @item @code{config-file} (default: @code{(tailon-configuration-file)})
23977 The configuration file to use for Tailon. This can be set to a
23978 @dfn{tailon-configuration-file} record value, or any gexp
23979 (@pxref{G-Expressions}).
23980
23981 For example, to instead use a local file, the @code{local-file} function
23982 can be used:
23983
23984 @lisp
23985 (service tailon-service-type
23986 (tailon-configuration
23987 (config-file (local-file "./my-tailon.conf"))))
23988 @end lisp
23989
23990 @item @code{package} (default: @code{tailon})
23991 The tailon package to use.
23992
23993 @end table
23994 @end deftp
23995
23996 @deftp {Data Type} tailon-configuration-file
23997 Data type representing the configuration options for Tailon.
23998 This type has the following parameters:
23999
24000 @table @asis
24001 @item @code{files} (default: @code{(list "/var/log")})
24002 List of files to display. The list can include strings for a single file
24003 or directory, or a list, where the first item is the name of a
24004 subsection, and the remaining items are the files or directories in that
24005 subsection.
24006
24007 @item @code{bind} (default: @code{"localhost:8080"})
24008 Address and port to which Tailon should bind on.
24009
24010 @item @code{relative-root} (default: @code{#f})
24011 URL path to use for Tailon, set to @code{#f} to not use a path.
24012
24013 @item @code{allow-transfers?} (default: @code{#t})
24014 Allow downloading the log files in the web interface.
24015
24016 @item @code{follow-names?} (default: @code{#t})
24017 Allow tailing of not-yet existent files.
24018
24019 @item @code{tail-lines} (default: @code{200})
24020 Number of lines to read initially from each file.
24021
24022 @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
24023 Commands to allow running. By default, @code{sed} is disabled.
24024
24025 @item @code{debug?} (default: @code{#f})
24026 Set @code{debug?} to @code{#t} to show debug messages.
24027
24028 @item @code{wrap-lines} (default: @code{#t})
24029 Initial line wrapping state in the web interface. Set to @code{#t} to
24030 initially wrap lines (the default), or to @code{#f} to initially not
24031 wrap lines.
24032
24033 @item @code{http-auth} (default: @code{#f})
24034 HTTP authentication type to use. Set to @code{#f} to disable
24035 authentication (the default). Supported values are @code{"digest"} or
24036 @code{"basic"}.
24037
24038 @item @code{users} (default: @code{#f})
24039 If HTTP authentication is enabled (see @code{http-auth}), access will be
24040 restricted to the credentials provided here. To configure users, use a
24041 list of pairs, where the first element of the pair is the username, and
24042 the 2nd element of the pair is the password.
24043
24044 @lisp
24045 (tailon-configuration-file
24046 (http-auth "basic")
24047 (users '(("user1" . "password1")
24048 ("user2" . "password2"))))
24049 @end lisp
24050
24051 @end table
24052 @end deftp
24053
24054
24055 @subsubheading Darkstat Service
24056 @cindex darkstat
24057 Darkstat is a packet sniffer that captures network traffic, calculates
24058 statistics about usage, and serves reports over HTTP.
24059
24060 @defvar {Scheme Variable} darkstat-service-type
24061 This is the service type for the
24062 @uref{https://unix4lyfe.org/darkstat/, darkstat}
24063 service, its value must be a @code{darkstat-configuration} record as in
24064 this example:
24065
24066 @lisp
24067 (service darkstat-service-type
24068 (darkstat-configuration
24069 (interface "eno1")))
24070 @end lisp
24071 @end defvar
24072
24073 @deftp {Data Type} darkstat-configuration
24074 Data type representing the configuration of @command{darkstat}.
24075
24076 @table @asis
24077 @item @code{package} (default: @code{darkstat})
24078 The darkstat package to use.
24079
24080 @item @code{interface}
24081 Capture traffic on the specified network interface.
24082
24083 @item @code{port} (default: @code{"667"})
24084 Bind the web interface to the specified port.
24085
24086 @item @code{bind-address} (default: @code{"127.0.0.1"})
24087 Bind the web interface to the specified address.
24088
24089 @item @code{base} (default: @code{"/"})
24090 Specify the path of the base URL@. This can be useful if
24091 @command{darkstat} is accessed via a reverse proxy.
24092
24093 @end table
24094 @end deftp
24095
24096 @subsubheading Prometheus Node Exporter Service
24097
24098 @cindex prometheus-node-exporter
24099 The Prometheus ``node exporter'' makes hardware and operating system statistics
24100 provided by the Linux kernel available for the Prometheus monitoring system.
24101 This service should be deployed on all physical nodes and virtual machines,
24102 where monitoring these statistics is desirable.
24103
24104 @defvar {Scheme variable} prometheus-node-exporter-service-type
24105 This is the service type for the
24106 @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
24107 service, its value must be a @code{prometheus-node-exporter-configuration}.
24108
24109 @lisp
24110 (service prometheus-node-exporter-service-type)
24111 @end lisp
24112 @end defvar
24113
24114 @deftp {Data Type} prometheus-node-exporter-configuration
24115 Data type representing the configuration of @command{node_exporter}.
24116
24117 @table @asis
24118 @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
24119 The prometheus-node-exporter package to use.
24120
24121 @item @code{web-listen-address} (default: @code{":9100"})
24122 Bind the web interface to the specified address.
24123
24124 @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
24125 This directory can be used to export metrics specific to this machine.
24126 Files containing metrics in the text format, with the filename ending in
24127 @code{.prom} should be placed in this directory.
24128
24129 @item @code{extra-options} (default: @code{'()})
24130 Extra options to pass to the Prometheus node exporter.
24131
24132 @end table
24133 @end deftp
24134
24135 @subsubheading Zabbix server
24136 @cindex zabbix zabbix-server
24137 Zabbix provides monitoring metrics, among others network utilization, CPU load
24138 and disk space consumption:
24139
24140 @itemize
24141 @item High performance, high capacity (able to monitor hundreds of thousands of devices).
24142 @item Auto-discovery of servers and network devices and interfaces.
24143 @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
24144 @item Distributed monitoring with centralized web administration.
24145 @item Native high performance agents.
24146 @item SLA, and ITIL KPI metrics on reporting.
24147 @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
24148 @item Remote command execution through Zabbix proxies.
24149 @end itemize
24150
24151 @c %start of fragment
24152
24153 Available @code{zabbix-server-configuration} fields are:
24154
24155 @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
24156 The zabbix-server package.
24157
24158 @end deftypevr
24159
24160 @deftypevr {@code{zabbix-server-configuration} parameter} string user
24161 User who will run the Zabbix server.
24162
24163 Defaults to @samp{"zabbix"}.
24164
24165 @end deftypevr
24166
24167 @deftypevr {@code{zabbix-server-configuration} parameter} group group
24168 Group who will run the Zabbix server.
24169
24170 Defaults to @samp{"zabbix"}.
24171
24172 @end deftypevr
24173
24174 @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
24175 Database host name.
24176
24177 Defaults to @samp{"127.0.0.1"}.
24178
24179 @end deftypevr
24180
24181 @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
24182 Database name.
24183
24184 Defaults to @samp{"zabbix"}.
24185
24186 @end deftypevr
24187
24188 @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
24189 Database user.
24190
24191 Defaults to @samp{"zabbix"}.
24192
24193 @end deftypevr
24194
24195 @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
24196 Database password. Please, use @code{include-files} with
24197 @code{DBPassword=SECRET} inside a specified file instead.
24198
24199 Defaults to @samp{""}.
24200
24201 @end deftypevr
24202
24203 @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
24204 Database port.
24205
24206 Defaults to @samp{5432}.
24207
24208 @end deftypevr
24209
24210 @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
24211 Specifies where log messages are written to:
24212
24213 @itemize @bullet
24214 @item
24215 @code{system} - syslog.
24216
24217 @item
24218 @code{file} - file specified with @code{log-file} parameter.
24219
24220 @item
24221 @code{console} - standard output.
24222
24223 @end itemize
24224
24225 Defaults to @samp{""}.
24226
24227 @end deftypevr
24228
24229 @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
24230 Log file name for @code{log-type} @code{file} parameter.
24231
24232 Defaults to @samp{"/var/log/zabbix/server.log"}.
24233
24234 @end deftypevr
24235
24236 @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
24237 Name of PID file.
24238
24239 Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
24240
24241 @end deftypevr
24242
24243 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
24244 The location of certificate authority (CA) files for SSL server
24245 certificate verification.
24246
24247 Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
24248
24249 @end deftypevr
24250
24251 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
24252 Location of SSL client certificates.
24253
24254 Defaults to @samp{"/etc/ssl/certs"}.
24255
24256 @end deftypevr
24257
24258 @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
24259 Extra options will be appended to Zabbix server configuration file.
24260
24261 Defaults to @samp{""}.
24262
24263 @end deftypevr
24264
24265 @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
24266 You may include individual files or all files in a directory in the
24267 configuration file.
24268
24269 Defaults to @samp{()}.
24270
24271 @end deftypevr
24272
24273 @c %end of fragment
24274
24275 @subsubheading Zabbix agent
24276 @cindex zabbix zabbix-agent
24277
24278 Zabbix agent gathers information for Zabbix server.
24279
24280 @c %start of fragment
24281
24282 Available @code{zabbix-agent-configuration} fields are:
24283
24284 @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
24285 The zabbix-agent package.
24286
24287 @end deftypevr
24288
24289 @deftypevr {@code{zabbix-agent-configuration} parameter} string user
24290 User who will run the Zabbix agent.
24291
24292 Defaults to @samp{"zabbix"}.
24293
24294 @end deftypevr
24295
24296 @deftypevr {@code{zabbix-agent-configuration} parameter} group group
24297 Group who will run the Zabbix agent.
24298
24299 Defaults to @samp{"zabbix"}.
24300
24301 @end deftypevr
24302
24303 @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
24304 Unique, case sensitive hostname which is required for active checks and
24305 must match hostname as configured on the server.
24306
24307 Defaults to @samp{""}.
24308
24309 @end deftypevr
24310
24311 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
24312 Specifies where log messages are written to:
24313
24314 @itemize @bullet
24315 @item
24316 @code{system} - syslog.
24317
24318 @item
24319 @code{file} - file specified with @code{log-file} parameter.
24320
24321 @item
24322 @code{console} - standard output.
24323
24324 @end itemize
24325
24326 Defaults to @samp{""}.
24327
24328 @end deftypevr
24329
24330 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
24331 Log file name for @code{log-type} @code{file} parameter.
24332
24333 Defaults to @samp{"/var/log/zabbix/agent.log"}.
24334
24335 @end deftypevr
24336
24337 @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
24338 Name of PID file.
24339
24340 Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
24341
24342 @end deftypevr
24343
24344 @deftypevr {@code{zabbix-agent-configuration} parameter} list server
24345 List of IP addresses, optionally in CIDR notation, or hostnames of
24346 Zabbix servers and Zabbix proxies. Incoming connections will be
24347 accepted only from the hosts listed here.
24348
24349 Defaults to @samp{("127.0.0.1")}.
24350
24351 @end deftypevr
24352
24353 @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
24354 List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
24355 proxies for active checks. If port is not specified, default port is
24356 used. If this parameter is not specified, active checks are disabled.
24357
24358 Defaults to @samp{("127.0.0.1")}.
24359
24360 @end deftypevr
24361
24362 @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
24363 Extra options will be appended to Zabbix server configuration file.
24364
24365 Defaults to @samp{""}.
24366
24367 @end deftypevr
24368
24369 @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
24370 You may include individual files or all files in a directory in the
24371 configuration file.
24372
24373 Defaults to @samp{()}.
24374
24375 @end deftypevr
24376
24377 @c %end of fragment
24378
24379 @subsubheading Zabbix front-end
24380 @cindex zabbix zabbix-front-end
24381
24382 This service provides a WEB interface to Zabbix server.
24383
24384 @c %start of fragment
24385
24386 Available @code{zabbix-front-end-configuration} fields are:
24387
24388 @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
24389 NGINX configuration.
24390
24391 @end deftypevr
24392
24393 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
24394 Database host name.
24395
24396 Defaults to @samp{"localhost"}.
24397
24398 @end deftypevr
24399
24400 @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
24401 Database port.
24402
24403 Defaults to @samp{5432}.
24404
24405 @end deftypevr
24406
24407 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
24408 Database name.
24409
24410 Defaults to @samp{"zabbix"}.
24411
24412 @end deftypevr
24413
24414 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
24415 Database user.
24416
24417 Defaults to @samp{"zabbix"}.
24418
24419 @end deftypevr
24420
24421 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
24422 Database password. Please, use @code{db-secret-file} instead.
24423
24424 Defaults to @samp{""}.
24425
24426 @end deftypevr
24427
24428 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
24429 Secret file containing the credentials for the Zabbix front-end. The value
24430 must be a local file name, not a G-expression. You are expected to create
24431 this file manually. Its contents will be copied into @file{zabbix.conf.php}
24432 as the value of @code{$DB['PASSWORD']}.
24433
24434 Defaults to @samp{""}.
24435
24436 @end deftypevr
24437
24438 @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
24439 Zabbix server hostname.
24440
24441 Defaults to @samp{"localhost"}.
24442
24443 @end deftypevr
24444
24445 @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
24446 Zabbix server port.
24447
24448 Defaults to @samp{10051}.
24449
24450 @end deftypevr
24451
24452
24453 @c %end of fragment
24454
24455 @node Kerberos Services
24456 @subsection Kerberos Services
24457 @cindex Kerberos
24458
24459 The @code{(gnu services kerberos)} module provides services relating to
24460 the authentication protocol @dfn{Kerberos}.
24461
24462 @subsubheading Krb5 Service
24463
24464 Programs using a Kerberos client library normally
24465 expect a configuration file in @file{/etc/krb5.conf}.
24466 This service generates such a file from a definition provided in the
24467 operating system declaration.
24468 It does not cause any daemon to be started.
24469
24470 No ``keytab'' files are provided by this service---you must explicitly create them.
24471 This service is known to work with the MIT client library, @code{mit-krb5}.
24472 Other implementations have not been tested.
24473
24474 @defvr {Scheme Variable} krb5-service-type
24475 A service type for Kerberos 5 clients.
24476 @end defvr
24477
24478 @noindent
24479 Here is an example of its use:
24480 @lisp
24481 (service krb5-service-type
24482 (krb5-configuration
24483 (default-realm "EXAMPLE.COM")
24484 (allow-weak-crypto? #t)
24485 (realms (list
24486 (krb5-realm
24487 (name "EXAMPLE.COM")
24488 (admin-server "groucho.example.com")
24489 (kdc "karl.example.com"))
24490 (krb5-realm
24491 (name "ARGRX.EDU")
24492 (admin-server "kerb-admin.argrx.edu")
24493 (kdc "keys.argrx.edu"))))))
24494 @end lisp
24495
24496 @noindent
24497 This example provides a Kerberos@tie{}5 client configuration which:
24498 @itemize
24499 @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
24500 of which have distinct administration servers and key distribution centers;
24501 @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
24502 specified by clients;
24503 @item Accepts services which only support encryption types known to be weak.
24504 @end itemize
24505
24506 The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
24507 Only the most commonly used ones are described here.
24508 For a full list, and more detailed explanation of each, see the MIT
24509 @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
24510 documentation.
24511
24512
24513 @deftp {Data Type} krb5-realm
24514 @cindex realm, kerberos
24515 @table @asis
24516 @item @code{name}
24517 This field is a string identifying the name of the realm.
24518 A common convention is to use the fully qualified DNS name of your organization,
24519 converted to upper case.
24520
24521 @item @code{admin-server}
24522 This field is a string identifying the host where the administration server is
24523 running.
24524
24525 @item @code{kdc}
24526 This field is a string identifying the key distribution center
24527 for the realm.
24528 @end table
24529 @end deftp
24530
24531 @deftp {Data Type} krb5-configuration
24532
24533 @table @asis
24534 @item @code{allow-weak-crypto?} (default: @code{#f})
24535 If this flag is @code{#t} then services which only offer encryption algorithms
24536 known to be weak will be accepted.
24537
24538 @item @code{default-realm} (default: @code{#f})
24539 This field should be a string identifying the default Kerberos
24540 realm for the client.
24541 You should set this field to the name of your Kerberos realm.
24542 If this value is @code{#f}
24543 then a realm must be specified with every Kerberos principal when invoking programs
24544 such as @command{kinit}.
24545
24546 @item @code{realms}
24547 This should be a non-empty list of @code{krb5-realm} objects, which clients may
24548 access.
24549 Normally, one of them will have a @code{name} field matching the @code{default-realm}
24550 field.
24551 @end table
24552 @end deftp
24553
24554
24555 @subsubheading PAM krb5 Service
24556 @cindex pam-krb5
24557
24558 The @code{pam-krb5} service allows for login authentication and password
24559 management via Kerberos.
24560 You will need this service if you want PAM enabled applications to authenticate
24561 users using Kerberos.
24562
24563 @defvr {Scheme Variable} pam-krb5-service-type
24564 A service type for the Kerberos 5 PAM module.
24565 @end defvr
24566
24567 @deftp {Data Type} pam-krb5-configuration
24568 Data type representing the configuration of the Kerberos 5 PAM module.
24569 This type has the following parameters:
24570 @table @asis
24571 @item @code{pam-krb5} (default: @code{pam-krb5})
24572 The pam-krb5 package to use.
24573
24574 @item @code{minimum-uid} (default: @code{1000})
24575 The smallest user ID for which Kerberos authentications should be attempted.
24576 Local accounts with lower values will silently fail to authenticate.
24577 @end table
24578 @end deftp
24579
24580
24581 @node LDAP Services
24582 @subsection LDAP Services
24583 @cindex LDAP
24584 @cindex nslcd, LDAP service
24585
24586 The @code{(gnu services authentication)} module provides the
24587 @code{nslcd-service-type}, which can be used to authenticate against an LDAP
24588 server. In addition to configuring the service itself, you may want to add
24589 @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
24590 Switch} for detailed information.
24591
24592 Here is a simple operating system declaration with a default configuration of
24593 the @code{nslcd-service-type} and a Name Service Switch configuration that
24594 consults the @code{ldap} name service last:
24595
24596 @lisp
24597 (use-service-modules authentication)
24598 (use-modules (gnu system nss))
24599 ...
24600 (operating-system
24601 ...
24602 (services
24603 (cons*
24604 (service nslcd-service-type)
24605 (service dhcp-client-service-type)
24606 %base-services))
24607 (name-service-switch
24608 (let ((services (list (name-service (name "db"))
24609 (name-service (name "files"))
24610 (name-service (name "ldap")))))
24611 (name-service-switch
24612 (inherit %mdns-host-lookup-nss)
24613 (password services)
24614 (shadow services)
24615 (group services)
24616 (netgroup services)
24617 (gshadow services)))))
24618 @end lisp
24619
24620 @c %start of generated documentation for nslcd-configuration
24621
24622 Available @code{nslcd-configuration} fields are:
24623
24624 @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
24625 The @code{nss-pam-ldapd} package to use.
24626
24627 @end deftypevr
24628
24629 @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
24630 The number of threads to start that can handle requests and perform LDAP
24631 queries. Each thread opens a separate connection to the LDAP server.
24632 The default is to start 5 threads.
24633
24634 Defaults to @samp{disabled}.
24635
24636 @end deftypevr
24637
24638 @deftypevr {@code{nslcd-configuration} parameter} string uid
24639 This specifies the user id with which the daemon should be run.
24640
24641 Defaults to @samp{"nslcd"}.
24642
24643 @end deftypevr
24644
24645 @deftypevr {@code{nslcd-configuration} parameter} string gid
24646 This specifies the group id with which the daemon should be run.
24647
24648 Defaults to @samp{"nslcd"}.
24649
24650 @end deftypevr
24651
24652 @deftypevr {@code{nslcd-configuration} parameter} log-option log
24653 This option controls the way logging is done via a list containing
24654 SCHEME and LEVEL@. The SCHEME argument may either be the symbols
24655 @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
24656 argument is optional and specifies the log level. The log level may be
24657 one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
24658 @samp{notice}, @samp{info} or @samp{debug}. All messages with the
24659 specified log level or higher are logged.
24660
24661 Defaults to @samp{("/var/log/nslcd" info)}.
24662
24663 @end deftypevr
24664
24665 @deftypevr {@code{nslcd-configuration} parameter} list uri
24666 The list of LDAP server URIs. Normally, only the first server will be
24667 used with the following servers as fall-back.
24668
24669 Defaults to @samp{("ldap://localhost:389/")}.
24670
24671 @end deftypevr
24672
24673 @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
24674 The version of the LDAP protocol to use. The default is to use the
24675 maximum version supported by the LDAP library.
24676
24677 Defaults to @samp{disabled}.
24678
24679 @end deftypevr
24680
24681 @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
24682 Specifies the distinguished name with which to bind to the directory
24683 server for lookups. The default is to bind anonymously.
24684
24685 Defaults to @samp{disabled}.
24686
24687 @end deftypevr
24688
24689 @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
24690 Specifies the credentials with which to bind. This option is only
24691 applicable when used with binddn.
24692
24693 Defaults to @samp{disabled}.
24694
24695 @end deftypevr
24696
24697 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
24698 Specifies the distinguished name to use when the root user tries to
24699 modify a user's password using the PAM module.
24700
24701 Defaults to @samp{disabled}.
24702
24703 @end deftypevr
24704
24705 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
24706 Specifies the credentials with which to bind if the root user tries to
24707 change a user's password. This option is only applicable when used with
24708 rootpwmoddn
24709
24710 Defaults to @samp{disabled}.
24711
24712 @end deftypevr
24713
24714 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
24715 Specifies the SASL mechanism to be used when performing SASL
24716 authentication.
24717
24718 Defaults to @samp{disabled}.
24719
24720 @end deftypevr
24721
24722 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
24723 Specifies the SASL realm to be used when performing SASL authentication.
24724
24725 Defaults to @samp{disabled}.
24726
24727 @end deftypevr
24728
24729 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
24730 Specifies the authentication identity to be used when performing SASL
24731 authentication.
24732
24733 Defaults to @samp{disabled}.
24734
24735 @end deftypevr
24736
24737 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
24738 Specifies the authorization identity to be used when performing SASL
24739 authentication.
24740
24741 Defaults to @samp{disabled}.
24742
24743 @end deftypevr
24744
24745 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
24746 Determines whether the LDAP server host name should be canonicalised. If
24747 this is enabled the LDAP library will do a reverse host name lookup. By
24748 default, it is left up to the LDAP library whether this check is
24749 performed or not.
24750
24751 Defaults to @samp{disabled}.
24752
24753 @end deftypevr
24754
24755 @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
24756 Set the name for the GSS-API Kerberos credentials cache.
24757
24758 Defaults to @samp{disabled}.
24759
24760 @end deftypevr
24761
24762 @deftypevr {@code{nslcd-configuration} parameter} string base
24763 The directory search base.
24764
24765 Defaults to @samp{"dc=example,dc=com"}.
24766
24767 @end deftypevr
24768
24769 @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
24770 Specifies the search scope (subtree, onelevel, base or children). The
24771 default scope is subtree; base scope is almost never useful for name
24772 service lookups; children scope is not supported on all servers.
24773
24774 Defaults to @samp{(subtree)}.
24775
24776 @end deftypevr
24777
24778 @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
24779 Specifies the policy for dereferencing aliases. The default policy is
24780 to never dereference aliases.
24781
24782 Defaults to @samp{disabled}.
24783
24784 @end deftypevr
24785
24786 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
24787 Specifies whether automatic referral chasing should be enabled. The
24788 default behaviour is to chase referrals.
24789
24790 Defaults to @samp{disabled}.
24791
24792 @end deftypevr
24793
24794 @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
24795 This option allows for custom attributes to be looked up instead of the
24796 default RFC 2307 attributes. It is a list of maps, each consisting of
24797 the name of a map, the RFC 2307 attribute to match and the query
24798 expression for the attribute as it is available in the directory.
24799
24800 Defaults to @samp{()}.
24801
24802 @end deftypevr
24803
24804 @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
24805 A list of filters consisting of the name of a map to which the filter
24806 applies and an LDAP search filter expression.
24807
24808 Defaults to @samp{()}.
24809
24810 @end deftypevr
24811
24812 @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
24813 Specifies the time limit in seconds to use when connecting to the
24814 directory server. The default value is 10 seconds.
24815
24816 Defaults to @samp{disabled}.
24817
24818 @end deftypevr
24819
24820 @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
24821 Specifies the time limit (in seconds) to wait for a response from the
24822 LDAP server. A value of zero, which is the default, is to wait
24823 indefinitely for searches to be completed.
24824
24825 Defaults to @samp{disabled}.
24826
24827 @end deftypevr
24828
24829 @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
24830 Specifies the period if inactivity (in seconds) after which the con‐
24831 nection to the LDAP server will be closed. The default is not to time
24832 out connections.
24833
24834 Defaults to @samp{disabled}.
24835
24836 @end deftypevr
24837
24838 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
24839 Specifies the number of seconds to sleep when connecting to all LDAP
24840 servers fails. By default one second is waited between the first
24841 failure and the first retry.
24842
24843 Defaults to @samp{disabled}.
24844
24845 @end deftypevr
24846
24847 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
24848 Specifies the time after which the LDAP server is considered to be
24849 permanently unavailable. Once this time is reached retries will be done
24850 only once per this time period. The default value is 10 seconds.
24851
24852 Defaults to @samp{disabled}.
24853
24854 @end deftypevr
24855
24856 @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
24857 Specifies whether to use SSL/TLS or not (the default is not to). If
24858 'start-tls is specified then StartTLS is used rather than raw LDAP over
24859 SSL.
24860
24861 Defaults to @samp{disabled}.
24862
24863 @end deftypevr
24864
24865 @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
24866 Specifies what checks to perform on a server-supplied certificate. The
24867 meaning of the values is described in the ldap.conf(5) manual page.
24868
24869 Defaults to @samp{disabled}.
24870
24871 @end deftypevr
24872
24873 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
24874 Specifies the directory containing X.509 certificates for peer authen‐
24875 tication. This parameter is ignored when using GnuTLS.
24876
24877 Defaults to @samp{disabled}.
24878
24879 @end deftypevr
24880
24881 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
24882 Specifies the path to the X.509 certificate for peer authentication.
24883
24884 Defaults to @samp{disabled}.
24885
24886 @end deftypevr
24887
24888 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
24889 Specifies the path to an entropy source. This parameter is ignored when
24890 using GnuTLS.
24891
24892 Defaults to @samp{disabled}.
24893
24894 @end deftypevr
24895
24896 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
24897 Specifies the ciphers to use for TLS as a string.
24898
24899 Defaults to @samp{disabled}.
24900
24901 @end deftypevr
24902
24903 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
24904 Specifies the path to the file containing the local certificate for
24905 client TLS authentication.
24906
24907 Defaults to @samp{disabled}.
24908
24909 @end deftypevr
24910
24911 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
24912 Specifies the path to the file containing the private key for client TLS
24913 authentication.
24914
24915 Defaults to @samp{disabled}.
24916
24917 @end deftypevr
24918
24919 @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
24920 Set this to a number greater than 0 to request paged results from the
24921 LDAP server in accordance with RFC2696. The default (0) is to not
24922 request paged results.
24923
24924 Defaults to @samp{disabled}.
24925
24926 @end deftypevr
24927
24928 @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
24929 This option prevents group membership lookups through LDAP for the
24930 specified users. Alternatively, the value 'all-local may be used. With
24931 that value nslcd builds a full list of non-LDAP users on startup.
24932
24933 Defaults to @samp{disabled}.
24934
24935 @end deftypevr
24936
24937 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
24938 This option ensures that LDAP users with a numeric user id lower than
24939 the specified value are ignored.
24940
24941 Defaults to @samp{disabled}.
24942
24943 @end deftypevr
24944
24945 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
24946 This option specifies an offset that is added to all LDAP numeric user
24947 ids. This can be used to avoid user id collisions with local users.
24948
24949 Defaults to @samp{disabled}.
24950
24951 @end deftypevr
24952
24953 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
24954 This option specifies an offset that is added to all LDAP numeric group
24955 ids. This can be used to avoid user id collisions with local groups.
24956
24957 Defaults to @samp{disabled}.
24958
24959 @end deftypevr
24960
24961 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
24962 If this option is set, the member attribute of a group may point to
24963 another group. Members of nested groups are also returned in the higher
24964 level group and parent groups are returned when finding groups for a
24965 specific user. The default is not to perform extra searches for nested
24966 groups.
24967
24968 Defaults to @samp{disabled}.
24969
24970 @end deftypevr
24971
24972 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
24973 If this option is set, the group member list is not retrieved when
24974 looking up groups. Lookups for finding which groups a user belongs to
24975 will remain functional so the user will likely still get the correct
24976 groups assigned on login.
24977
24978 Defaults to @samp{disabled}.
24979
24980 @end deftypevr
24981
24982 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
24983 If this option is set, functions which cause all user/group entries to
24984 be loaded from the directory will not succeed in doing so. This can
24985 dramatically reduce LDAP server load in situations where there are a
24986 great number of users and/or groups. This option is not recommended for
24987 most configurations.
24988
24989 Defaults to @samp{disabled}.
24990
24991 @end deftypevr
24992
24993 @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
24994 This option can be used to specify how user and group names are verified
24995 within the system. This pattern is used to check all user and group
24996 names that are requested and returned from LDAP.
24997
24998 Defaults to @samp{disabled}.
24999
25000 @end deftypevr
25001
25002 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
25003 This specifies whether or not to perform searches using case-insensitive
25004 matching. Enabling this could open up the system to authorization
25005 bypass vulnerabilities and introduce nscd cache poisoning
25006 vulnerabilities which allow denial of service.
25007
25008 Defaults to @samp{disabled}.
25009
25010 @end deftypevr
25011
25012 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
25013 This option specifies whether password policy controls are requested and
25014 handled from the LDAP server when performing user authentication.
25015
25016 Defaults to @samp{disabled}.
25017
25018 @end deftypevr
25019
25020 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
25021 By default nslcd performs an LDAP search with the user's credentials
25022 after BIND (authentication) to ensure that the BIND operation was
25023 successful. The default search is a simple check to see if the user's
25024 DN exists. A search filter can be specified that will be used instead.
25025 It should return at least one entry.
25026
25027 Defaults to @samp{disabled}.
25028
25029 @end deftypevr
25030
25031 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
25032 This option allows flexible fine tuning of the authorisation check that
25033 should be performed. The search filter specified is executed and if any
25034 entries match, access is granted, otherwise access is denied.
25035
25036 Defaults to @samp{disabled}.
25037
25038 @end deftypevr
25039
25040 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
25041 If this option is set password modification using pam_ldap will be
25042 denied and the specified message will be presented to the user instead.
25043 The message can be used to direct the user to an alternative means of
25044 changing their password.
25045
25046 Defaults to @samp{disabled}.
25047
25048 @end deftypevr
25049
25050 @deftypevr {@code{nslcd-configuration} parameter} list pam-services
25051 List of pam service names for which LDAP authentication should suffice.
25052
25053 Defaults to @samp{()}.
25054
25055 @end deftypevr
25056
25057 @c %end of generated documentation for nslcd-configuration
25058
25059
25060 @node Web Services
25061 @subsection Web Services
25062
25063 @cindex web
25064 @cindex www
25065 @cindex HTTP
25066 The @code{(gnu services web)} module provides the Apache HTTP Server,
25067 the nginx web server, and also a fastcgi wrapper daemon.
25068
25069 @subsubheading Apache HTTP Server
25070
25071 @deffn {Scheme Variable} httpd-service-type
25072 Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
25073 (@dfn{httpd}). The value for this service type is a
25074 @code{httpd-configuration} record.
25075
25076 A simple example configuration is given below.
25077
25078 @lisp
25079 (service httpd-service-type
25080 (httpd-configuration
25081 (config
25082 (httpd-config-file
25083 (server-name "www.example.com")
25084 (document-root "/srv/http/www.example.com")))))
25085 @end lisp
25086
25087 Other services can also extend the @code{httpd-service-type} to add to
25088 the configuration.
25089
25090 @lisp
25091 (simple-service 'www.example.com-server httpd-service-type
25092 (list
25093 (httpd-virtualhost
25094 "*:80"
25095 (list (string-join '("ServerName www.example.com"
25096 "DocumentRoot /srv/http/www.example.com")
25097 "\n")))))
25098 @end lisp
25099 @end deffn
25100
25101 The details for the @code{httpd-configuration}, @code{httpd-module},
25102 @code{httpd-config-file} and @code{httpd-virtualhost} record types are
25103 given below.
25104
25105 @deffn {Data Type} httpd-configuration
25106 This data type represents the configuration for the httpd service.
25107
25108 @table @asis
25109 @item @code{package} (default: @code{httpd})
25110 The httpd package to use.
25111
25112 @item @code{pid-file} (default: @code{"/var/run/httpd"})
25113 The pid file used by the shepherd-service.
25114
25115 @item @code{config} (default: @code{(httpd-config-file)})
25116 The configuration file to use with the httpd service. The default value
25117 is a @code{httpd-config-file} record, but this can also be a different
25118 G-expression that generates a file, for example a @code{plain-file}. A
25119 file outside of the store can also be specified through a string.
25120
25121 @end table
25122 @end deffn
25123
25124 @deffn {Data Type} httpd-module
25125 This data type represents a module for the httpd service.
25126
25127 @table @asis
25128 @item @code{name}
25129 The name of the module.
25130
25131 @item @code{file}
25132 The file for the module. This can be relative to the httpd package being
25133 used, the absolute location of a file, or a G-expression for a file
25134 within the store, for example @code{(file-append mod-wsgi
25135 "/modules/mod_wsgi.so")}.
25136
25137 @end table
25138 @end deffn
25139
25140 @defvr {Scheme Variable} %default-httpd-modules
25141 A default list of @code{httpd-module} objects.
25142 @end defvr
25143
25144 @deffn {Data Type} httpd-config-file
25145 This data type represents a configuration file for the httpd service.
25146
25147 @table @asis
25148 @item @code{modules} (default: @code{%default-httpd-modules})
25149 The modules to load. Additional modules can be added here, or loaded by
25150 additional configuration.
25151
25152 For example, in order to handle requests for PHP files, you can use Apache’s
25153 @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
25154
25155 @lisp
25156 (service httpd-service-type
25157 (httpd-configuration
25158 (config
25159 (httpd-config-file
25160 (modules (cons*
25161 (httpd-module
25162 (name "proxy_module")
25163 (file "modules/mod_proxy.so"))
25164 (httpd-module
25165 (name "proxy_fcgi_module")
25166 (file "modules/mod_proxy_fcgi.so"))
25167 %default-httpd-modules))
25168 (extra-config (list "\
25169 <FilesMatch \\.php$>
25170 SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
25171 </FilesMatch>"))))))
25172 (service php-fpm-service-type
25173 (php-fpm-configuration
25174 (socket "/var/run/php-fpm.sock")
25175 (socket-group "httpd")))
25176 @end lisp
25177
25178 @item @code{server-root} (default: @code{httpd})
25179 The @code{ServerRoot} in the configuration file, defaults to the httpd
25180 package. Directives including @code{Include} and @code{LoadModule} are
25181 taken as relative to the server root.
25182
25183 @item @code{server-name} (default: @code{#f})
25184 The @code{ServerName} in the configuration file, used to specify the
25185 request scheme, hostname and port that the server uses to identify
25186 itself.
25187
25188 This doesn't need to be set in the server config, and can be specified
25189 in virtual hosts. The default is @code{#f} to not specify a
25190 @code{ServerName}.
25191
25192 @item @code{document-root} (default: @code{"/srv/http"})
25193 The @code{DocumentRoot} from which files will be served.
25194
25195 @item @code{listen} (default: @code{'("80")})
25196 The list of values for the @code{Listen} directives in the config
25197 file. The value should be a list of strings, when each string can
25198 specify the port number to listen on, and optionally the IP address and
25199 protocol to use.
25200
25201 @item @code{pid-file} (default: @code{"/var/run/httpd"})
25202 The @code{PidFile} to use. This should match the @code{pid-file} set in
25203 the @code{httpd-configuration} so that the Shepherd service is
25204 configured correctly.
25205
25206 @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
25207 The @code{ErrorLog} to which the server will log errors.
25208
25209 @item @code{user} (default: @code{"httpd"})
25210 The @code{User} which the server will answer requests as.
25211
25212 @item @code{group} (default: @code{"httpd"})
25213 The @code{Group} which the server will answer requests as.
25214
25215 @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
25216 A flat list of strings and G-expressions which will be added to the end
25217 of the configuration file.
25218
25219 Any values which the service is extended with will be appended to this
25220 list.
25221
25222 @end table
25223 @end deffn
25224
25225 @deffn {Data Type} httpd-virtualhost
25226 This data type represents a virtualhost configuration block for the httpd service.
25227
25228 These should be added to the extra-config for the httpd-service.
25229
25230 @lisp
25231 (simple-service 'www.example.com-server httpd-service-type
25232 (list
25233 (httpd-virtualhost
25234 "*:80"
25235 (list (string-join '("ServerName www.example.com"
25236 "DocumentRoot /srv/http/www.example.com")
25237 "\n")))))
25238 @end lisp
25239
25240 @table @asis
25241 @item @code{addresses-and-ports}
25242 The addresses and ports for the @code{VirtualHost} directive.
25243
25244 @item @code{contents}
25245 The contents of the @code{VirtualHost} directive, this should be a list
25246 of strings and G-expressions.
25247
25248 @end table
25249 @end deffn
25250
25251 @anchor{NGINX}
25252 @subsubheading NGINX
25253
25254 @deffn {Scheme Variable} nginx-service-type
25255 Service type for the @uref{https://nginx.org/,NGinx} web server. The
25256 value for this service type is a @code{<nginx-configuration>} record.
25257
25258 A simple example configuration is given below.
25259
25260 @lisp
25261 (service nginx-service-type
25262 (nginx-configuration
25263 (server-blocks
25264 (list (nginx-server-configuration
25265 (server-name '("www.example.com"))
25266 (root "/srv/http/www.example.com"))))))
25267 @end lisp
25268
25269 In addition to adding server blocks to the service configuration
25270 directly, this service can be extended by other services to add server
25271 blocks, as in this example:
25272
25273 @lisp
25274 (simple-service 'my-extra-server nginx-service-type
25275 (list (nginx-server-configuration
25276 (root "/srv/http/extra-website")
25277 (try-files (list "$uri" "$uri/index.html")))))
25278 @end lisp
25279 @end deffn
25280
25281 At startup, @command{nginx} has not yet read its configuration file, so
25282 it uses a default file to log error messages. If it fails to load its
25283 configuration file, that is where error messages are logged. After the
25284 configuration file is loaded, the default error log file changes as per
25285 configuration. In our case, startup error messages can be found in
25286 @file{/var/run/nginx/logs/error.log}, and after configuration in
25287 @file{/var/log/nginx/error.log}. The second location can be changed
25288 with the @var{log-directory} configuration option.
25289
25290 @deffn {Data Type} nginx-configuration
25291 This data type represents the configuration for NGinx. Some
25292 configuration can be done through this and the other provided record
25293 types, or alternatively, a config file can be provided.
25294
25295 @table @asis
25296 @item @code{nginx} (default: @code{nginx})
25297 The nginx package to use.
25298
25299 @item @code{log-directory} (default: @code{"/var/log/nginx"})
25300 The directory to which NGinx will write log files.
25301
25302 @item @code{run-directory} (default: @code{"/var/run/nginx"})
25303 The directory in which NGinx will create a pid file, and write temporary
25304 files.
25305
25306 @item @code{server-blocks} (default: @code{'()})
25307 A list of @dfn{server blocks} to create in the generated configuration
25308 file, the elements should be of type
25309 @code{<nginx-server-configuration>}.
25310
25311 The following example would setup NGinx to serve @code{www.example.com}
25312 from the @code{/srv/http/www.example.com} directory, without using
25313 HTTPS.
25314 @lisp
25315 (service nginx-service-type
25316 (nginx-configuration
25317 (server-blocks
25318 (list (nginx-server-configuration
25319 (server-name '("www.example.com"))
25320 (root "/srv/http/www.example.com"))))))
25321 @end lisp
25322
25323 @item @code{upstream-blocks} (default: @code{'()})
25324 A list of @dfn{upstream blocks} to create in the generated configuration
25325 file, the elements should be of type
25326 @code{<nginx-upstream-configuration>}.
25327
25328 Configuring upstreams through the @code{upstream-blocks} can be useful
25329 when combined with @code{locations} in the
25330 @code{<nginx-server-configuration>} records. The following example
25331 creates a server configuration with one location configuration, that
25332 will proxy requests to a upstream configuration, which will handle
25333 requests with two servers.
25334
25335 @lisp
25336 (service
25337 nginx-service-type
25338 (nginx-configuration
25339 (server-blocks
25340 (list (nginx-server-configuration
25341 (server-name '("www.example.com"))
25342 (root "/srv/http/www.example.com")
25343 (locations
25344 (list
25345 (nginx-location-configuration
25346 (uri "/path1")
25347 (body '("proxy_pass http://server-proxy;"))))))))
25348 (upstream-blocks
25349 (list (nginx-upstream-configuration
25350 (name "server-proxy")
25351 (servers (list "server1.example.com"
25352 "server2.example.com")))))))
25353 @end lisp
25354
25355 @item @code{file} (default: @code{#f})
25356 If a configuration @var{file} is provided, this will be used, rather than
25357 generating a configuration file from the provided @code{log-directory},
25358 @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
25359 proper operation, these arguments should match what is in @var{file} to ensure
25360 that the directories are created when the service is activated.
25361
25362 This can be useful if you have an existing configuration file, or it's
25363 not possible to do what is required through the other parts of the
25364 nginx-configuration record.
25365
25366 @item @code{server-names-hash-bucket-size} (default: @code{#f})
25367 Bucket size for the server names hash tables, defaults to @code{#f} to
25368 use the size of the processors cache line.
25369
25370 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
25371 Maximum bucket size for the server names hash tables.
25372
25373 @item @code{modules} (default: @code{'()})
25374 List of nginx dynamic modules to load. This should be a list of file
25375 names of loadable modules, as in this example:
25376
25377 @lisp
25378 (modules
25379 (list
25380 (file-append nginx-accept-language-module "\
25381 /etc/nginx/modules/ngx_http_accept_language_module.so")
25382 (file-append nginx-lua-module "\
25383 /etc/nginx/modules/ngx_http_lua_module.so")))
25384 @end lisp
25385
25386 @item @code{lua-package-path} (default: @code{'()})
25387 List of nginx lua packages to load. This should be a list of package
25388 names of loadable lua modules, as in this example:
25389
25390 @lisp
25391 (lua-package-path (list lua-resty-core
25392 lua-resty-lrucache
25393 lua-resty-signal
25394 lua-tablepool
25395 lua-resty-shell))
25396 @end lisp
25397
25398 @item @code{lua-package-cpath} (default: @code{'()})
25399 List of nginx lua C packages to load. This should be a list of package
25400 names of loadable lua C modules, as in this example:
25401
25402 @lisp
25403 (lua-package-cpath (list lua-resty-signal))
25404 @end lisp
25405
25406 @item @code{global-directives} (default: @code{'((events . ()))})
25407 Association list of global directives for the top level of the nginx
25408 configuration. Values may themselves be association lists.
25409
25410 @lisp
25411 (global-directives
25412 `((worker_processes . 16)
25413 (pcre_jit . on)
25414 (events . ((worker_connections . 1024)))))
25415 @end lisp
25416
25417 @item @code{extra-content} (default: @code{""})
25418 Extra content for the @code{http} block. Should be string or a string
25419 valued G-expression.
25420
25421 @end table
25422 @end deffn
25423
25424 @deftp {Data Type} nginx-server-configuration
25425 Data type representing the configuration of an nginx server block.
25426 This type has the following parameters:
25427
25428 @table @asis
25429 @item @code{listen} (default: @code{'("80" "443 ssl")})
25430 Each @code{listen} directive sets the address and port for IP, or the
25431 path for a UNIX-domain socket on which the server will accept requests.
25432 Both address and port, or only address or only port can be specified.
25433 An address may also be a hostname, for example:
25434
25435 @lisp
25436 '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
25437 @end lisp
25438
25439 @item @code{server-name} (default: @code{(list 'default)})
25440 A list of server names this server represents. @code{'default} represents the
25441 default server for connections matching no other server.
25442
25443 @item @code{root} (default: @code{"/srv/http"})
25444 Root of the website nginx will serve.
25445
25446 @item @code{locations} (default: @code{'()})
25447 A list of @dfn{nginx-location-configuration} or
25448 @dfn{nginx-named-location-configuration} records to use within this
25449 server block.
25450
25451 @item @code{index} (default: @code{(list "index.html")})
25452 Index files to look for when clients ask for a directory. If it cannot be found,
25453 Nginx will send the list of files in the directory.
25454
25455 @item @code{try-files} (default: @code{'()})
25456 A list of files whose existence is checked in the specified order.
25457 @code{nginx} will use the first file it finds to process the request.
25458
25459 @item @code{ssl-certificate} (default: @code{#f})
25460 Where to find the certificate for secure connections. Set it to @code{#f} if
25461 you don't have a certificate or you don't want to use HTTPS.
25462
25463 @item @code{ssl-certificate-key} (default: @code{#f})
25464 Where to find the private key for secure connections. Set it to @code{#f} if
25465 you don't have a key or you don't want to use HTTPS.
25466
25467 @item @code{server-tokens?} (default: @code{#f})
25468 Whether the server should add its configuration to response.
25469
25470 @item @code{raw-content} (default: @code{'()})
25471 A list of raw lines added to the server block.
25472
25473 @end table
25474 @end deftp
25475
25476 @deftp {Data Type} nginx-upstream-configuration
25477 Data type representing the configuration of an nginx @code{upstream}
25478 block. This type has the following parameters:
25479
25480 @table @asis
25481 @item @code{name}
25482 Name for this group of servers.
25483
25484 @item @code{servers}
25485 Specify the addresses of the servers in the group. The address can be
25486 specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
25487 (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
25488 prefix @samp{unix:}. For addresses using an IP address or domain name,
25489 the default port is 80, and a different port can be specified
25490 explicitly.
25491
25492 @end table
25493 @end deftp
25494
25495 @deftp {Data Type} nginx-location-configuration
25496 Data type representing the configuration of an nginx @code{location}
25497 block. This type has the following parameters:
25498
25499 @table @asis
25500 @item @code{uri}
25501 URI which this location block matches.
25502
25503 @anchor{nginx-location-configuration body}
25504 @item @code{body}
25505 Body of the location block, specified as a list of strings. This can contain
25506 many
25507 configuration directives. For example, to pass requests to a upstream
25508 server group defined using an @code{nginx-upstream-configuration} block,
25509 the following directive would be specified in the body @samp{(list "proxy_pass
25510 http://upstream-name;")}.
25511
25512 @end table
25513 @end deftp
25514
25515 @deftp {Data Type} nginx-named-location-configuration
25516 Data type representing the configuration of an nginx named location
25517 block. Named location blocks are used for request redirection, and not
25518 used for regular request processing. This type has the following
25519 parameters:
25520
25521 @table @asis
25522 @item @code{name}
25523 Name to identify this location block.
25524
25525 @item @code{body}
25526 @xref{nginx-location-configuration body}, as the body for named location
25527 blocks can be used in a similar way to the
25528 @code{nginx-location-configuration body}. One restriction is that the
25529 body of a named location block cannot contain location blocks.
25530
25531 @end table
25532 @end deftp
25533
25534 @subsubheading Varnish Cache
25535 @cindex Varnish
25536 Varnish is a fast cache server that sits in between web applications
25537 and end users. It proxies requests from clients and caches the
25538 accessed URLs such that multiple requests for the same resource only
25539 creates one request to the back-end.
25540
25541 @defvr {Scheme Variable} varnish-service-type
25542 Service type for the Varnish daemon.
25543 @end defvr
25544
25545 @deftp {Data Type} varnish-configuration
25546 Data type representing the @code{varnish} service configuration.
25547 This type has the following parameters:
25548
25549 @table @asis
25550 @item @code{package} (default: @code{varnish})
25551 The Varnish package to use.
25552
25553 @item @code{name} (default: @code{"default"})
25554 A name for this Varnish instance. Varnish will create a directory in
25555 @file{/var/varnish/} with this name and keep temporary files there. If
25556 the name starts with a forward slash, it is interpreted as an absolute
25557 directory name.
25558
25559 Pass the @code{-n} argument to other Varnish programs to connect to the
25560 named instance, e.g.@: @command{varnishncsa -n default}.
25561
25562 @item @code{backend} (default: @code{"localhost:8080"})
25563 The backend to use. This option has no effect if @code{vcl} is set.
25564
25565 @item @code{vcl} (default: #f)
25566 The @dfn{VCL} (Varnish Configuration Language) program to run. If this
25567 is @code{#f}, Varnish will proxy @code{backend} using the default
25568 configuration. Otherwise this must be a file-like object with valid
25569 VCL syntax.
25570
25571 @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
25572 For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
25573 can do something along these lines:
25574
25575 @lisp
25576 (define %gnu-mirror
25577 (plain-file "gnu.vcl"
25578 "vcl 4.1;
25579 backend gnu @{ .host = \"www.gnu.org\"; @}"))
25580
25581 (operating-system
25582 ;; @dots{}
25583 (services (cons (service varnish-service-type
25584 (varnish-configuration
25585 (listen '(":80"))
25586 (vcl %gnu-mirror)))
25587 %base-services)))
25588 @end lisp
25589
25590 The configuration of an already running Varnish instance can be inspected
25591 and changed using the @command{varnishadm} program.
25592
25593 Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
25594 @url{https://book.varnish-software.com/4.0/,Varnish Book} for
25595 comprehensive documentation on Varnish and its configuration language.
25596
25597 @item @code{listen} (default: @code{'("localhost:80")})
25598 List of addresses Varnish will listen on.
25599
25600 @item @code{storage} (default: @code{'("malloc,128m")})
25601 List of storage backends that will be available in VCL.
25602
25603 @item @code{parameters} (default: @code{'()})
25604 List of run-time parameters in the form @code{'(("parameter" . "value"))}.
25605
25606 @item @code{extra-options} (default: @code{'()})
25607 Additional arguments to pass to the @command{varnishd} process.
25608
25609 @end table
25610 @end deftp
25611
25612 @subsubheading Patchwork
25613 @cindex Patchwork
25614 Patchwork is a patch tracking system. It can collect patches sent to a
25615 mailing list, and display them in a web interface.
25616
25617 @defvr {Scheme Variable} patchwork-service-type
25618 Service type for Patchwork.
25619 @end defvr
25620
25621 The following example is an example of a minimal service for Patchwork, for
25622 the @code{patchwork.example.com} domain.
25623
25624 @lisp
25625 (service patchwork-service-type
25626 (patchwork-configuration
25627 (domain "patchwork.example.com")
25628 (settings-module
25629 (patchwork-settings-module
25630 (allowed-hosts (list domain))
25631 (default-from-email "patchwork@@patchwork.example.com")))
25632 (getmail-retriever-config
25633 (getmail-retriever-configuration
25634 (type "SimpleIMAPSSLRetriever")
25635 (server "imap.example.com")
25636 (port 993)
25637 (username "patchwork")
25638 (password-command
25639 (list (file-append coreutils "/bin/cat")
25640 "/etc/getmail-patchwork-imap-password"))
25641 (extra-parameters
25642 '((mailboxes . ("Patches"))))))))
25643
25644 @end lisp
25645
25646 There are three records for configuring the Patchwork service. The
25647 @code{<patchwork-configuration>} relates to the configuration for Patchwork
25648 within the HTTPD service.
25649
25650 The @code{settings-module} field within the @code{<patchwork-configuration>}
25651 record can be populated with the @code{<patchwork-settings-module>} record,
25652 which describes a settings module that is generated within the Guix store.
25653
25654 For the @code{database-configuration} field within the
25655 @code{<patchwork-settings-module>}, the
25656 @code{<patchwork-database-configuration>} must be used.
25657
25658 @deftp {Data Type} patchwork-configuration
25659 Data type representing the Patchwork service configuration. This type has the
25660 following parameters:
25661
25662 @table @asis
25663 @item @code{patchwork} (default: @code{patchwork})
25664 The Patchwork package to use.
25665
25666 @item @code{domain}
25667 The domain to use for Patchwork, this is used in the HTTPD service virtual
25668 host.
25669
25670 @item @code{settings-module}
25671 The settings module to use for Patchwork. As a Django application, Patchwork
25672 is configured with a Python module containing the settings. This can either be
25673 an instance of the @code{<patchwork-settings-module>} record, any other record
25674 that represents the settings in the store, or a directory outside of the
25675 store.
25676
25677 @item @code{static-path} (default: @code{"/static/"})
25678 The path under which the HTTPD service should serve the static files.
25679
25680 @item @code{getmail-retriever-config}
25681 The getmail-retriever-configuration record value to use with
25682 Patchwork. Getmail will be configured with this value, the messages will be
25683 delivered to Patchwork.
25684
25685 @end table
25686 @end deftp
25687
25688 @deftp {Data Type} patchwork-settings-module
25689 Data type representing a settings module for Patchwork. Some of these
25690 settings relate directly to Patchwork, but others relate to Django, the web
25691 framework used by Patchwork, or the Django Rest Framework library. This type
25692 has the following parameters:
25693
25694 @table @asis
25695 @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
25696 The database connection settings used for Patchwork. See the
25697 @code{<patchwork-database-configuration>} record type for more information.
25698
25699 @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
25700 Patchwork, as a Django web application uses a secret key for cryptographically
25701 signing values. This file should contain a unique unpredictable value.
25702
25703 If this file does not exist, it will be created and populated with a random
25704 value by the patchwork-setup shepherd service.
25705
25706 This setting relates to Django.
25707
25708 @item @code{allowed-hosts}
25709 A list of valid hosts for this Patchwork service. This should at least include
25710 the domain specified in the @code{<patchwork-configuration>} record.
25711
25712 This is a Django setting.
25713
25714 @item @code{default-from-email}
25715 The email address from which Patchwork should send email by default.
25716
25717 This is a Patchwork setting.
25718
25719 @item @code{static-url} (default: @code{#f})
25720 The URL to use when serving static assets. It can be part of a URL, or a full
25721 URL, but must end in a @code{/}.
25722
25723 If the default value is used, the @code{static-path} value from the
25724 @code{<patchwork-configuration>} record will be used.
25725
25726 This is a Django setting.
25727
25728 @item @code{admins} (default: @code{'()})
25729 Email addresses to send the details of errors that occur. Each value should
25730 be a list containing two elements, the name and then the email address.
25731
25732 This is a Django setting.
25733
25734 @item @code{debug?} (default: @code{#f})
25735 Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
25736 messages will be shown.
25737
25738 This is a Django setting.
25739
25740 @item @code{enable-rest-api?} (default: @code{#t})
25741 Whether to enable the Patchwork REST API.
25742
25743 This is a Patchwork setting.
25744
25745 @item @code{enable-xmlrpc?} (default: @code{#t})
25746 Whether to enable the XML RPC API.
25747
25748 This is a Patchwork setting.
25749
25750 @item @code{force-https-links?} (default: @code{#t})
25751 Whether to use HTTPS links on Patchwork pages.
25752
25753 This is a Patchwork setting.
25754
25755 @item @code{extra-settings} (default: @code{""})
25756 Extra code to place at the end of the Patchwork settings module.
25757
25758 @end table
25759 @end deftp
25760
25761 @deftp {Data Type} patchwork-database-configuration
25762 Data type representing the database configuration for Patchwork.
25763
25764 @table @asis
25765 @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
25766 The database engine to use.
25767
25768 @item @code{name} (default: @code{"patchwork"})
25769 The name of the database to use.
25770
25771 @item @code{user} (default: @code{"httpd"})
25772 The user to connect to the database as.
25773
25774 @item @code{password} (default: @code{""})
25775 The password to use when connecting to the database.
25776
25777 @item @code{host} (default: @code{""})
25778 The host to make the database connection to.
25779
25780 @item @code{port} (default: @code{""})
25781 The port on which to connect to the database.
25782
25783 @end table
25784 @end deftp
25785
25786 @subsubheading Mumi
25787
25788 @cindex Mumi, Debbugs Web interface
25789 @cindex Debbugs, Mumi Web interface
25790 @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
25791 Web interface to the Debbugs bug tracker, by default for
25792 @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
25793 but it also fetches and indexes mail retrieved from Debbugs.
25794
25795 @defvr {Scheme Variable} mumi-service-type
25796 This is the service type for Mumi.
25797 @end defvr
25798
25799 @deftp {Data Type} mumi-configuration
25800 Data type representing the Mumi service configuration. This type has the
25801 following fields:
25802
25803 @table @asis
25804 @item @code{mumi} (default: @code{mumi})
25805 The Mumi package to use.
25806
25807 @item @code{mailer?} (default: @code{#true})
25808 Whether to enable or disable the mailer component.
25809
25810 @item @code{mumi-configuration-sender}
25811 The email address used as the sender for comments.
25812
25813 @item @code{mumi-configuration-smtp}
25814 A URI to configure the SMTP settings for Mailutils. This could be
25815 something like @code{sendmail:///path/to/bin/msmtp} or any other URI
25816 supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
25817 mailutils, GNU@tie{}Mailutils}.
25818
25819 @end table
25820 @end deftp
25821
25822
25823 @subsubheading FastCGI
25824 @cindex fastcgi
25825 @cindex fcgiwrap
25826 FastCGI is an interface between the front-end and the back-end of a web
25827 service. It is a somewhat legacy facility; new web services should
25828 generally just talk HTTP between the front-end and the back-end.
25829 However there are a number of back-end services such as PHP or the
25830 optimized HTTP Git repository access that use FastCGI, so we have
25831 support for it in Guix.
25832
25833 To use FastCGI, you configure the front-end web server (e.g., nginx) to
25834 dispatch some subset of its requests to the fastcgi backend, which
25835 listens on a local TCP or UNIX socket. There is an intermediary
25836 @code{fcgiwrap} program that sits between the actual backend process and
25837 the web server. The front-end indicates which backend program to run,
25838 passing that information to the @code{fcgiwrap} process.
25839
25840 @defvr {Scheme Variable} fcgiwrap-service-type
25841 A service type for the @code{fcgiwrap} FastCGI proxy.
25842 @end defvr
25843
25844 @deftp {Data Type} fcgiwrap-configuration
25845 Data type representing the configuration of the @code{fcgiwrap} service.
25846 This type has the following parameters:
25847 @table @asis
25848 @item @code{package} (default: @code{fcgiwrap})
25849 The fcgiwrap package to use.
25850
25851 @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
25852 The socket on which the @code{fcgiwrap} process should listen, as a
25853 string. Valid @var{socket} values include
25854 @code{unix:@var{/path/to/unix/socket}},
25855 @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
25856 @code{tcp6:[@var{ipv6_addr}]:port}.
25857
25858 @item @code{user} (default: @code{fcgiwrap})
25859 @itemx @code{group} (default: @code{fcgiwrap})
25860 The user and group names, as strings, under which to run the
25861 @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
25862 the user asks for the specific user or group names @code{fcgiwrap} that
25863 the corresponding user and/or group is present on the system.
25864
25865 It is possible to configure a FastCGI-backed web service to pass HTTP
25866 authentication information from the front-end to the back-end, and to
25867 allow @code{fcgiwrap} to run the back-end process as a corresponding
25868 local user. To enable this capability on the back-end, run
25869 @code{fcgiwrap} as the @code{root} user and group. Note that this
25870 capability also has to be configured on the front-end as well.
25871 @end table
25872 @end deftp
25873
25874 @cindex php-fpm
25875 PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
25876 with some additional features useful for sites of any size.
25877
25878 These features include:
25879 @itemize @bullet
25880 @item Adaptive process spawning
25881 @item Basic statistics (similar to Apache's mod_status)
25882 @item Advanced process management with graceful stop/start
25883 @item Ability to start workers with different uid/gid/chroot/environment
25884 and different php.ini (replaces safe_mode)
25885 @item Stdout & stderr logging
25886 @item Emergency restart in case of accidental opcode cache destruction
25887 @item Accelerated upload support
25888 @item Support for a "slowlog"
25889 @item Enhancements to FastCGI, such as fastcgi_finish_request() -
25890 a special function to finish request & flush all data while continuing to do
25891 something time-consuming (video converting, stats processing, etc.)
25892 @end itemize
25893 ...@: and much more.
25894
25895 @defvr {Scheme Variable} php-fpm-service-type
25896 A Service type for @code{php-fpm}.
25897 @end defvr
25898
25899 @deftp {Data Type} php-fpm-configuration
25900 Data Type for php-fpm service configuration.
25901 @table @asis
25902 @item @code{php} (default: @code{php})
25903 The php package to use.
25904 @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
25905 The address on which to accept FastCGI requests. Valid syntaxes are:
25906 @table @asis
25907 @item @code{"ip.add.re.ss:port"}
25908 Listen on a TCP socket to a specific address on a specific port.
25909 @item @code{"port"}
25910 Listen on a TCP socket to all addresses on a specific port.
25911 @item @code{"/path/to/unix/socket"}
25912 Listen on a unix socket.
25913 @end table
25914
25915 @item @code{user} (default: @code{php-fpm})
25916 User who will own the php worker processes.
25917 @item @code{group} (default: @code{php-fpm})
25918 Group of the worker processes.
25919 @item @code{socket-user} (default: @code{php-fpm})
25920 User who can speak to the php-fpm socket.
25921 @item @code{socket-group} (default: @code{nginx})
25922 Group that can speak to the php-fpm socket.
25923 @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
25924 The process id of the php-fpm process is written to this file
25925 once the service has started.
25926 @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
25927 Log for the php-fpm master process.
25928 @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
25929 Detailed settings for the php-fpm process manager.
25930 Must be one of:
25931 @table @asis
25932 @item @code{<php-fpm-dynamic-process-manager-configuration>}
25933 @item @code{<php-fpm-static-process-manager-configuration>}
25934 @item @code{<php-fpm-on-demand-process-manager-configuration>}
25935 @end table
25936 @item @code{display-errors} (default @code{#f})
25937 Determines whether php errors and warning should be sent to clients
25938 and displayed in their browsers.
25939 This is useful for local php development, but a security risk for public sites,
25940 as error messages can reveal passwords and personal data.
25941 @item @code{timezone} (default @code{#f})
25942 Specifies @code{php_admin_value[date.timezone]} parameter.
25943 @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
25944 This file will log the @code{stderr} outputs of php worker processes.
25945 Can be set to @code{#f} to disable logging.
25946 @item @code{file} (default @code{#f})
25947 An optional override of the whole configuration.
25948 You can use the @code{mixed-text-file} function or an absolute filepath for it.
25949 @item @code{php-ini-file} (default @code{#f})
25950 An optional override of the default php settings.
25951 It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
25952 You can use the @code{mixed-text-file} function or an absolute filepath for it.
25953
25954 For local development it is useful to set a higher timeout and memory
25955 limit for spawned php processes. This be accomplished with the
25956 following operating system configuration snippet:
25957 @lisp
25958 (define %local-php-ini
25959 (plain-file "php.ini"
25960 "memory_limit = 2G
25961 max_execution_time = 1800"))
25962
25963 (operating-system
25964 ;; @dots{}
25965 (services (cons (service php-fpm-service-type
25966 (php-fpm-configuration
25967 (php-ini-file %local-php-ini)))
25968 %base-services)))
25969 @end lisp
25970
25971 Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
25972 directives} for comprehensive documentation on the acceptable
25973 @file{php.ini} directives.
25974 @end table
25975 @end deftp
25976
25977 @deftp {Data type} php-fpm-dynamic-process-manager-configuration
25978 Data Type for the @code{dynamic} php-fpm process manager. With the
25979 @code{dynamic} process manager, spare worker processes are kept around
25980 based on its configured limits.
25981 @table @asis
25982 @item @code{max-children} (default: @code{5})
25983 Maximum of worker processes.
25984 @item @code{start-servers} (default: @code{2})
25985 How many worker processes should be started on start-up.
25986 @item @code{min-spare-servers} (default: @code{1})
25987 How many spare worker processes should be kept around at minimum.
25988 @item @code{max-spare-servers} (default: @code{3})
25989 How many spare worker processes should be kept around at maximum.
25990 @end table
25991 @end deftp
25992
25993 @deftp {Data type} php-fpm-static-process-manager-configuration
25994 Data Type for the @code{static} php-fpm process manager. With the
25995 @code{static} process manager, an unchanging number of worker processes
25996 are created.
25997 @table @asis
25998 @item @code{max-children} (default: @code{5})
25999 Maximum of worker processes.
26000 @end table
26001 @end deftp
26002
26003 @deftp {Data type} php-fpm-on-demand-process-manager-configuration
26004 Data Type for the @code{on-demand} php-fpm process manager. With the
26005 @code{on-demand} process manager, worker processes are only created as
26006 requests arrive.
26007 @table @asis
26008 @item @code{max-children} (default: @code{5})
26009 Maximum of worker processes.
26010 @item @code{process-idle-timeout} (default: @code{10})
26011 The time in seconds after which a process with no requests is killed.
26012 @end table
26013 @end deftp
26014
26015
26016 @deffn {Scheme Procedure} nginx-php-location @
26017 [#:nginx-package nginx] @
26018 [socket (string-append "/var/run/php" @
26019 (version-major (package-version php)) @
26020 "-fpm.sock")]
26021 A helper function to quickly add php to an @code{nginx-server-configuration}.
26022 @end deffn
26023
26024 A simple services setup for nginx with php can look like this:
26025 @lisp
26026 (services (cons* (service dhcp-client-service-type)
26027 (service php-fpm-service-type)
26028 (service nginx-service-type
26029 (nginx-server-configuration
26030 (server-name '("example.com"))
26031 (root "/srv/http/")
26032 (locations
26033 (list (nginx-php-location)))
26034 (listen '("80"))
26035 (ssl-certificate #f)
26036 (ssl-certificate-key #f)))
26037 %base-services))
26038 @end lisp
26039
26040 @cindex cat-avatar-generator
26041 The cat avatar generator is a simple service to demonstrate the use of php-fpm
26042 in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
26043 the hash of a user's email address.
26044
26045 @deffn {Scheme Procedure} cat-avatar-generator-service @
26046 [#:cache-dir "/var/cache/cat-avatar-generator"] @
26047 [#:package cat-avatar-generator] @
26048 [#:configuration (nginx-server-configuration)]
26049 Returns an nginx-server-configuration that inherits @code{configuration}. It
26050 extends the nginx configuration to add a server block that serves @code{package},
26051 a version of cat-avatar-generator. During execution, cat-avatar-generator will
26052 be able to use @code{cache-dir} as its cache directory.
26053 @end deffn
26054
26055 A simple setup for cat-avatar-generator can look like this:
26056 @lisp
26057 (services (cons* (cat-avatar-generator-service
26058 #:configuration
26059 (nginx-server-configuration
26060 (server-name '("example.com"))))
26061 ...
26062 %base-services))
26063 @end lisp
26064
26065 @subsubheading Hpcguix-web
26066
26067 @cindex hpcguix-web
26068 The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
26069 program is a customizable web interface to browse Guix packages,
26070 initially designed for users of high-performance computing (HPC)
26071 clusters.
26072
26073 @defvr {Scheme Variable} hpcguix-web-service-type
26074 The service type for @code{hpcguix-web}.
26075 @end defvr
26076
26077 @deftp {Data Type} hpcguix-web-configuration
26078 Data type for the hpcguix-web service configuration.
26079
26080 @table @asis
26081 @item @code{specs}
26082 A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
26083 configuration. The main items available in this spec are:
26084
26085 @table @asis
26086 @item @code{title-prefix} (default: @code{"hpcguix | "})
26087 The page title prefix.
26088
26089 @item @code{guix-command} (default: @code{"guix"})
26090 The @command{guix} command.
26091
26092 @item @code{package-filter-proc} (default: @code{(const #t)})
26093 A procedure specifying how to filter packages that are displayed.
26094
26095 @item @code{package-page-extension-proc} (default: @code{(const '())})
26096 Extension package for @code{hpcguix-web}.
26097
26098 @item @code{menu} (default: @code{'()})
26099 Additional entry in page @code{menu}.
26100
26101 @item @code{channels} (default: @code{%default-channels})
26102 List of channels from which the package list is built (@pxref{Channels}).
26103
26104 @item @code{package-list-expiration} (default: @code{(* 12 3600)})
26105 The expiration time, in seconds, after which the package list is rebuilt from
26106 the latest instances of the given channels.
26107 @end table
26108
26109 See the hpcguix-web repository for a
26110 @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
26111 complete example}.
26112
26113 @item @code{package} (default: @code{hpcguix-web})
26114 The hpcguix-web package to use.
26115 @end table
26116 @end deftp
26117
26118 A typical hpcguix-web service declaration looks like this:
26119
26120 @lisp
26121 (service hpcguix-web-service-type
26122 (hpcguix-web-configuration
26123 (specs
26124 #~(define site-config
26125 (hpcweb-configuration
26126 (title-prefix "Guix-HPC - ")
26127 (menu '(("/about" "ABOUT"))))))))
26128 @end lisp
26129
26130 @quotation Note
26131 The hpcguix-web service periodically updates the package list it publishes by
26132 pulling channels from Git. To that end, it needs to access X.509 certificates
26133 so that it can authenticate Git servers when communicating over HTTPS, and it
26134 assumes that @file{/etc/ssl/certs} contains those certificates.
26135
26136 Thus, make sure to add @code{nss-certs} or another certificate package to the
26137 @code{packages} field of your configuration. @ref{X.509 Certificates}, for
26138 more information on X.509 certificates.
26139 @end quotation
26140
26141 @subsubheading gmnisrv
26142
26143 @cindex gmnisrv
26144 The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
26145 simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
26146
26147 @deffn {Scheme Variable} gmnisrv-service-type
26148 This is the type of the gmnisrv service, whose value should be a
26149 @code{gmnisrv-configuration} object, as in this example:
26150
26151 @lisp
26152 (service gmnisrv-service-type
26153 (gmnisrv-configuration
26154 (config-file (local-file "./my-gmnisrv.ini"))))
26155 @end lisp
26156 @end deffn
26157
26158 @deftp {Data Type} gmnisrv-configuration
26159 Data type representing the configuration of gmnisrv.
26160
26161 @table @asis
26162 @item @code{package} (default: @var{gmnisrv})
26163 Package object of the gmnisrv server.
26164
26165 @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
26166 File-like object of the gmnisrv configuration file to use. The default
26167 configuration listens on port 1965 and serves files from
26168 @file{/srv/gemini}. Certificates are stored in
26169 @file{/var/lib/gemini/certs}. For more information, run @command{man
26170 gmnisrv} and @command{man gmnisrv.ini}.
26171
26172 @end table
26173 @end deftp
26174
26175 @subsubheading Agate
26176
26177 @cindex agate
26178 The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
26179 (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
26180 program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
26181 protocol server written in Rust.
26182
26183 @deffn {Scheme Variable} agate-service-type
26184 This is the type of the agate service, whose value should be an
26185 @code{agate-service-type} object, as in this example:
26186
26187 @lisp
26188 (service agate-service-type
26189 (agate-configuration
26190 (content "/srv/gemini")
26191 (cert "/srv/cert.pem")
26192 (key "/srv/key.rsa")))
26193 @end lisp
26194
26195 The example above represents the minimal tweaking necessary to get Agate
26196 up and running. Specifying the path to the certificate and key is
26197 always necessary, as the Gemini protocol requires TLS by default.
26198
26199 To obtain a certificate and a key, you could, for example, use OpenSSL,
26200 running a command similar to the following example:
26201
26202 @example
26203 openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
26204 -days 3650 -nodes -subj "/CN=example.com"
26205 @end example
26206
26207 Of course, you'll have to replace @i{example.com} with your own domain
26208 name, and then point the Agate configuration towards the path of the
26209 generated key and certificate.
26210
26211 @end deffn
26212
26213 @deftp {Data Type} agate-configuration
26214 Data type representing the configuration of Agate.
26215
26216 @table @asis
26217 @item @code{package} (default: @code{agate})
26218 The package object of the Agate server.
26219
26220 @item @code{content} (default: @file{"/srv/gemini"})
26221 The directory from which Agate will serve files.
26222
26223 @item @code{cert} (default: @code{#f})
26224 The path to the TLS certificate PEM file to be used for encrypted
26225 connections. Must be filled in with a value from the user.
26226
26227 @item @code{key} (default: @code{#f})
26228 The path to the PKCS8 private key file to be used for encrypted
26229 connections. Must be filled in with a value from the user.
26230
26231 @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
26232 A list of the addresses to listen on.
26233
26234 @item @code{hostname} (default: @code{#f})
26235 The domain name of this Gemini server. Optional.
26236
26237 @item @code{lang} (default: @code{#f})
26238 RFC 4646 language code(s) for text/gemini documents. Optional.
26239
26240 @item @code{silent?} (default: @code{#f})
26241 Set to @code{#t} to disable logging output.
26242
26243 @item @code{serve-secret?} (default: @code{#f})
26244 Set to @code{#t} to serve secret files (files/directories starting with
26245 a dot).
26246
26247 @item @code{log-ip?} (default: @code{#t})
26248 Whether or not to output IP addresses when logging.
26249
26250 @item @code{user} (default: @code{"agate"})
26251 Owner of the @code{agate} process.
26252
26253 @item @code{group} (default: @code{"agate"})
26254 Owner's group of the @code{agate} process.
26255
26256 @item @code{log-file} (default: @file{"/var/log/agate.log"})
26257 The file which should store the logging output of Agate.
26258
26259 @end table
26260 @end deftp
26261
26262 @node Certificate Services
26263 @subsection Certificate Services
26264
26265 @cindex Web
26266 @cindex HTTP, HTTPS
26267 @cindex Let's Encrypt
26268 @cindex TLS certificates
26269 The @code{(gnu services certbot)} module provides a service to
26270 automatically obtain a valid TLS certificate from the Let's Encrypt
26271 certificate authority. These certificates can then be used to serve
26272 content securely over HTTPS or other TLS-based protocols, with the
26273 knowledge that the client will be able to verify the server's
26274 authenticity.
26275
26276 @url{https://letsencrypt.org/, Let's Encrypt} provides the
26277 @code{certbot} tool to automate the certification process. This tool
26278 first securely generates a key on the server. It then makes a request
26279 to the Let's Encrypt certificate authority (CA) to sign the key. The CA
26280 checks that the request originates from the host in question by using a
26281 challenge-response protocol, requiring the server to provide its
26282 response over HTTP@. If that protocol completes successfully, the CA
26283 signs the key, resulting in a certificate. That certificate is valid
26284 for a limited period of time, and therefore to continue to provide TLS
26285 services, the server needs to periodically ask the CA to renew its
26286 signature.
26287
26288 The certbot service automates this process: the initial key
26289 generation, the initial certification request to the Let's Encrypt
26290 service, the web server challenge/response integration, writing the
26291 certificate to disk, the automated periodic renewals, and the deployment
26292 tasks associated with the renewal (e.g.@: reloading services, copying keys
26293 with different permissions).
26294
26295 Certbot is run twice a day, at a random minute within the hour. It
26296 won't do anything until your certificates are due for renewal or
26297 revoked, but running it regularly would give your service a chance of
26298 staying online in case a Let's Encrypt-initiated revocation happened for
26299 some reason.
26300
26301 By using this service, you agree to the ACME Subscriber Agreement, which
26302 can be found there:
26303 @url{https://acme-v01.api.letsencrypt.org/directory}.
26304
26305 @defvr {Scheme Variable} certbot-service-type
26306 A service type for the @code{certbot} Let's Encrypt client. Its value
26307 must be a @code{certbot-configuration} record as in this example:
26308
26309 @lisp
26310 (define %nginx-deploy-hook
26311 (program-file
26312 "nginx-deploy-hook"
26313 #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
26314 (kill pid SIGHUP))))
26315
26316 (service certbot-service-type
26317 (certbot-configuration
26318 (email "foo@@example.net")
26319 (certificates
26320 (list
26321 (certificate-configuration
26322 (domains '("example.net" "www.example.net"))
26323 (deploy-hook %nginx-deploy-hook))
26324 (certificate-configuration
26325 (domains '("bar.example.net")))))))
26326 @end lisp
26327
26328 See below for details about @code{certbot-configuration}.
26329 @end defvr
26330
26331 @deftp {Data Type} certbot-configuration
26332 Data type representing the configuration of the @code{certbot} service.
26333 This type has the following parameters:
26334
26335 @table @asis
26336 @item @code{package} (default: @code{certbot})
26337 The certbot package to use.
26338
26339 @item @code{webroot} (default: @code{/var/www})
26340 The directory from which to serve the Let's Encrypt challenge/response
26341 files.
26342
26343 @item @code{certificates} (default: @code{()})
26344 A list of @code{certificates-configuration}s for which to generate
26345 certificates and request signatures. Each certificate has a @code{name}
26346 and several @code{domains}.
26347
26348 @item @code{email} (default: @code{#f})
26349 Optional email address used for registration and recovery contact.
26350 Setting this is encouraged as it allows you to receive important
26351 notifications about the account and issued certificates.
26352
26353 @item @code{server} (default: @code{#f})
26354 Optional URL of ACME server. Setting this overrides certbot's default,
26355 which is the Let's Encrypt server.
26356
26357 @item @code{rsa-key-size} (default: @code{2048})
26358 Size of the RSA key.
26359
26360 @item @code{default-location} (default: @i{see below})
26361 The default @code{nginx-location-configuration}. Because @code{certbot}
26362 needs to be able to serve challenges and responses, it needs to be able
26363 to run a web server. It does so by extending the @code{nginx} web
26364 service with an @code{nginx-server-configuration} listening on the
26365 @var{domains} on port 80, and which has a
26366 @code{nginx-location-configuration} for the @code{/.well-known/} URI
26367 path subspace used by Let's Encrypt. @xref{Web Services}, for more on
26368 these nginx configuration data types.
26369
26370 Requests to other URL paths will be matched by the
26371 @code{default-location}, which if present is added to all
26372 @code{nginx-server-configuration}s.
26373
26374 By default, the @code{default-location} will issue a redirect from
26375 @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
26376 you to define what to serve on your site via @code{https}.
26377
26378 Pass @code{#f} to not issue a default location.
26379 @end table
26380 @end deftp
26381
26382 @deftp {Data Type} certificate-configuration
26383 Data type representing the configuration of a certificate.
26384 This type has the following parameters:
26385
26386 @table @asis
26387 @item @code{name} (default: @i{see below})
26388 This name is used by Certbot for housekeeping and in file paths; it
26389 doesn't affect the content of the certificate itself. To see
26390 certificate names, run @code{certbot certificates}.
26391
26392 Its default is the first provided domain.
26393
26394 @item @code{domains} (default: @code{()})
26395 The first domain provided will be the subject CN of the certificate, and
26396 all domains will be Subject Alternative Names on the certificate.
26397
26398 @item @code{challenge} (default: @code{#f})
26399 The challenge type that has to be run by certbot. If @code{#f} is specified,
26400 default to the HTTP challenge. If a value is specified, defaults to the
26401 manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
26402 the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
26403 and gives Let's Encrypt permission to log the public IP address of the
26404 requesting machine.
26405
26406 @item @code{csr} (default: @code{#f})
26407 File name of Certificate Signing Request (CSR) in DER or PEM format.
26408 If @code{#f} is specified, this argument will not be passed to certbot.
26409 If a value is specified, certbot will use it to obtain a certificate, instead of
26410 using a self-generated CSR.
26411 The domain-name(s) mentioned in @code{domains}, must be consistent with the
26412 domain-name(s) mentioned in CSR file.
26413
26414 @item @code{authentication-hook} (default: @code{#f})
26415 Command to be run in a shell once for each certificate challenge to be
26416 answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
26417 will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
26418 contains the validation string and @code{$CERTBOT_TOKEN} contains the
26419 file name of the resource requested when performing an HTTP-01 challenge.
26420
26421 @item @code{cleanup-hook} (default: @code{#f})
26422 Command to be run in a shell once for each certificate challenge that
26423 have been answered by the @code{auth-hook}. For this command, the shell
26424 variables available in the @code{auth-hook} script are still available, and
26425 additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
26426 of the @code{auth-hook} script.
26427
26428 @item @code{deploy-hook} (default: @code{#f})
26429 Command to be run in a shell once for each successfully issued
26430 certificate. For this command, the shell variable
26431 @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
26432 example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
26433 certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
26434 contain a space-delimited list of renewed certificate domains (for
26435 example, @samp{"example.com www.example.com"}.
26436
26437 @end table
26438 @end deftp
26439
26440 For each @code{certificate-configuration}, the certificate is saved to
26441 @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
26442 saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
26443 @node DNS Services
26444 @subsection DNS Services
26445 @cindex DNS (domain name system)
26446 @cindex domain name system (DNS)
26447
26448 The @code{(gnu services dns)} module provides services related to the
26449 @dfn{domain name system} (DNS). It provides a server service for hosting
26450 an @emph{authoritative} DNS server for multiple zones, slave or master.
26451 This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
26452 caching and forwarding DNS server for the LAN, which uses
26453 @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
26454
26455 @subsubheading Knot Service
26456
26457 An example configuration of an authoritative server for two zones, one master
26458 and one slave, is:
26459
26460 @lisp
26461 (define-zone-entries example.org.zone
26462 ;; Name TTL Class Type Data
26463 ("@@" "" "IN" "A" "127.0.0.1")
26464 ("@@" "" "IN" "NS" "ns")
26465 ("ns" "" "IN" "A" "127.0.0.1"))
26466
26467 (define master-zone
26468 (knot-zone-configuration
26469 (domain "example.org")
26470 (zone (zone-file
26471 (origin "example.org")
26472 (entries example.org.zone)))))
26473
26474 (define slave-zone
26475 (knot-zone-configuration
26476 (domain "plop.org")
26477 (dnssec-policy "default")
26478 (master (list "plop-master"))))
26479
26480 (define plop-master
26481 (knot-remote-configuration
26482 (id "plop-master")
26483 (address (list "208.76.58.171"))))
26484
26485 (operating-system
26486 ;; ...
26487 (services (cons* (service knot-service-type
26488 (knot-configuration
26489 (remotes (list plop-master))
26490 (zones (list master-zone slave-zone))))
26491 ;; ...
26492 %base-services)))
26493 @end lisp
26494
26495 @deffn {Scheme Variable} knot-service-type
26496 This is the type for the Knot DNS server.
26497
26498 Knot DNS is an authoritative DNS server, meaning that it can serve multiple
26499 zones, that is to say domain names you would buy from a registrar. This server
26500 is not a resolver, meaning that it can only resolve names for which it is
26501 authoritative. This server can be configured to serve zones as a master server
26502 or a slave server as a per-zone basis. Slave zones will get their data from
26503 masters, and will serve it as an authoritative server. From the point of view
26504 of a resolver, there is no difference between master and slave.
26505
26506 The following data types are used to configure the Knot DNS server:
26507 @end deffn
26508
26509 @deftp {Data Type} knot-key-configuration
26510 Data type representing a key.
26511 This type has the following parameters:
26512
26513 @table @asis
26514 @item @code{id} (default: @code{""})
26515 An identifier for other configuration fields to refer to this key. IDs must
26516 be unique and must not be empty.
26517
26518 @item @code{algorithm} (default: @code{#f})
26519 The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
26520 @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
26521 and @code{'hmac-sha512}.
26522
26523 @item @code{secret} (default: @code{""})
26524 The secret key itself.
26525
26526 @end table
26527 @end deftp
26528
26529 @deftp {Data Type} knot-acl-configuration
26530 Data type representing an Access Control List (ACL) configuration.
26531 This type has the following parameters:
26532
26533 @table @asis
26534 @item @code{id} (default: @code{""})
26535 An identifier for other configuration fields to refer to this key. IDs must be
26536 unique and must not be empty.
26537
26538 @item @code{address} (default: @code{'()})
26539 An ordered list of IP addresses, network subnets, or network ranges represented
26540 with strings. The query must match one of them. Empty value means that
26541 address match is not required.
26542
26543 @item @code{key} (default: @code{'()})
26544 An ordered list of references to keys represented with strings. The string
26545 must match a key ID defined in a @code{knot-key-configuration}. No key means
26546 that a key is not require to match that ACL.
26547
26548 @item @code{action} (default: @code{'()})
26549 An ordered list of actions that are permitted or forbidden by this ACL@. Possible
26550 values are lists of zero or more elements from @code{'transfer}, @code{'notify}
26551 and @code{'update}.
26552
26553 @item @code{deny?} (default: @code{#f})
26554 When true, the ACL defines restrictions. Listed actions are forbidden. When
26555 false, listed actions are allowed.
26556
26557 @end table
26558 @end deftp
26559
26560 @deftp {Data Type} zone-entry
26561 Data type representing a record entry in a zone file.
26562 This type has the following parameters:
26563
26564 @table @asis
26565 @item @code{name} (default: @code{"@@"})
26566 The name of the record. @code{"@@"} refers to the origin of the zone. Names
26567 are relative to the origin of the zone. For example, in the @code{example.org}
26568 zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
26569 Names ending with a dot are absolute, which means that @code{"ns.example.org."}
26570 refers to @code{ns.example.org}.
26571
26572 @item @code{ttl} (default: @code{""})
26573 The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
26574
26575 @item @code{class} (default: @code{"IN"})
26576 The class of the record. Knot currently supports only @code{"IN"} and
26577 partially @code{"CH"}.
26578
26579 @item @code{type} (default: @code{"A"})
26580 The type of the record. Common types include A (IPv4 address), AAAA (IPv6
26581 address), NS (Name Server) and MX (Mail eXchange). Many other types are
26582 defined.
26583
26584 @item @code{data} (default: @code{""})
26585 The data contained in the record. For instance an IP address associated with
26586 an A record, or a domain name associated with an NS record. Remember that
26587 domain names are relative to the origin unless they end with a dot.
26588
26589 @end table
26590 @end deftp
26591
26592 @deftp {Data Type} zone-file
26593 Data type representing the content of a zone file.
26594 This type has the following parameters:
26595
26596 @table @asis
26597 @item @code{entries} (default: @code{'()})
26598 The list of entries. The SOA record is taken care of, so you don't need to
26599 put it in the list of entries. This list should probably contain an entry
26600 for your primary authoritative DNS server. Other than using a list of entries
26601 directly, you can use @code{define-zone-entries} to define a object containing
26602 the list of entries more easily, that you can later pass to the @code{entries}
26603 field of the @code{zone-file}.
26604
26605 @item @code{origin} (default: @code{""})
26606 The name of your zone. This parameter cannot be empty.
26607
26608 @item @code{ns} (default: @code{"ns"})
26609 The domain of your primary authoritative DNS server. The name is relative to
26610 the origin, unless it ends with a dot. It is mandatory that this primary
26611 DNS server corresponds to an NS record in the zone and that it is associated
26612 to an IP address in the list of entries.
26613
26614 @item @code{mail} (default: @code{"hostmaster"})
26615 An email address people can contact you at, as the owner of the zone. This
26616 is translated as @code{<mail>@@<origin>}.
26617
26618 @item @code{serial} (default: @code{1})
26619 The serial number of the zone. As this is used to keep track of changes by
26620 both slaves and resolvers, it is mandatory that it @emph{never} decreases.
26621 Always increment it when you make a change in your zone.
26622
26623 @item @code{refresh} (default: @code{(* 2 24 3600)})
26624 The frequency at which slaves will do a zone transfer. This value is a number
26625 of seconds. It can be computed by multiplications or with
26626 @code{(string->duration)}.
26627
26628 @item @code{retry} (default: @code{(* 15 60)})
26629 The period after which a slave will retry to contact its master when it fails
26630 to do so a first time.
26631
26632 @item @code{expiry} (default: @code{(* 14 24 3600)})
26633 Default TTL of records. Existing records are considered correct for at most
26634 this amount of time. After this period, resolvers will invalidate their cache
26635 and check again that it still exists.
26636
26637 @item @code{nx} (default: @code{3600})
26638 Default TTL of inexistent records. This delay is usually short because you want
26639 your new domains to reach everyone quickly.
26640
26641 @end table
26642 @end deftp
26643
26644 @deftp {Data Type} knot-remote-configuration
26645 Data type representing a remote configuration.
26646 This type has the following parameters:
26647
26648 @table @asis
26649 @item @code{id} (default: @code{""})
26650 An identifier for other configuration fields to refer to this remote. IDs must
26651 be unique and must not be empty.
26652
26653 @item @code{address} (default: @code{'()})
26654 An ordered list of destination IP addresses. Addresses are tried in sequence.
26655 An optional port can be given with the @@ separator. For instance:
26656 @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
26657
26658 @item @code{via} (default: @code{'()})
26659 An ordered list of source IP addresses. An empty list will have Knot choose
26660 an appropriate source IP@. An optional port can be given with the @@ separator.
26661 The default is to choose at random.
26662
26663 @item @code{key} (default: @code{#f})
26664 A reference to a key, that is a string containing the identifier of a key
26665 defined in a @code{knot-key-configuration} field.
26666
26667 @end table
26668 @end deftp
26669
26670 @deftp {Data Type} knot-keystore-configuration
26671 Data type representing a keystore to hold dnssec keys.
26672 This type has the following parameters:
26673
26674 @table @asis
26675 @item @code{id} (default: @code{""})
26676 The id of the keystore. It must not be empty.
26677
26678 @item @code{backend} (default: @code{'pem})
26679 The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
26680
26681 @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
26682 The configuration string of the backend. An example for the PKCS#11 is:
26683 @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
26684 For the pem backend, the string represents a path in the file system.
26685
26686 @end table
26687 @end deftp
26688
26689 @deftp {Data Type} knot-policy-configuration
26690 Data type representing a dnssec policy. Knot DNS is able to automatically
26691 sign your zones. It can either generate and manage your keys automatically or
26692 use keys that you generate.
26693
26694 Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
26695 used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
26696 zone. In order to be trusted, the KSK needs to be present in the parent zone
26697 (usually a top-level domain). If your registrar supports dnssec, you will
26698 have to send them your KSK's hash so they can add a DS record in their zone.
26699 This is not automated and need to be done each time you change your KSK.
26700
26701 The policy also defines the lifetime of keys. Usually, ZSK can be changed
26702 easily and use weaker cryptographic functions (they use lower parameters) in
26703 order to sign records quickly, so they are changed often. The KSK however
26704 requires manual interaction with the registrar, so they are changed less often
26705 and use stronger parameters because they sign only one record.
26706
26707 This type has the following parameters:
26708
26709 @table @asis
26710 @item @code{id} (default: @code{""})
26711 The id of the policy. It must not be empty.
26712
26713 @item @code{keystore} (default: @code{"default"})
26714 A reference to a keystore, that is a string containing the identifier of a
26715 keystore defined in a @code{knot-keystore-configuration} field. The
26716 @code{"default"} identifier means the default keystore (a kasp database that
26717 was setup by this service).
26718
26719 @item @code{manual?} (default: @code{#f})
26720 Whether the key management is manual or automatic.
26721
26722 @item @code{single-type-signing?} (default: @code{#f})
26723 When @code{#t}, use the Single-Type Signing Scheme.
26724
26725 @item @code{algorithm} (default: @code{"ecdsap256sha256"})
26726 An algorithm of signing keys and issued signatures.
26727
26728 @item @code{ksk-size} (default: @code{256})
26729 The length of the KSK@. Note that this value is correct for the default
26730 algorithm, but would be unsecure for other algorithms.
26731
26732 @item @code{zsk-size} (default: @code{256})
26733 The length of the ZSK@. Note that this value is correct for the default
26734 algorithm, but would be unsecure for other algorithms.
26735
26736 @item @code{dnskey-ttl} (default: @code{'default})
26737 The TTL value for DNSKEY records added into zone apex. The special
26738 @code{'default} value means same as the zone SOA TTL.
26739
26740 @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
26741 The period between ZSK publication and the next rollover initiation.
26742
26743 @item @code{propagation-delay} (default: @code{(* 24 3600)})
26744 An extra delay added for each key rollover step. This value should be high
26745 enough to cover propagation of data from the master server to all slaves.
26746
26747 @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
26748 A validity period of newly issued signatures.
26749
26750 @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
26751 A period how long before a signature expiration the signature will be refreshed.
26752
26753 @item @code{nsec3?} (default: @code{#f})
26754 When @code{#t}, NSEC3 will be used instead of NSEC.
26755
26756 @item @code{nsec3-iterations} (default: @code{5})
26757 The number of additional times the hashing is performed.
26758
26759 @item @code{nsec3-salt-length} (default: @code{8})
26760 The length of a salt field in octets, which is appended to the original owner
26761 name before hashing.
26762
26763 @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
26764 The validity period of newly issued salt field.
26765
26766 @end table
26767 @end deftp
26768
26769 @deftp {Data Type} knot-zone-configuration
26770 Data type representing a zone served by Knot.
26771 This type has the following parameters:
26772
26773 @table @asis
26774 @item @code{domain} (default: @code{""})
26775 The domain served by this configuration. It must not be empty.
26776
26777 @item @code{file} (default: @code{""})
26778 The file where this zone is saved. This parameter is ignored by master zones.
26779 Empty means default location that depends on the domain name.
26780
26781 @item @code{zone} (default: @code{(zone-file)})
26782 The content of the zone file. This parameter is ignored by slave zones. It
26783 must contain a zone-file record.
26784
26785 @item @code{master} (default: @code{'()})
26786 A list of master remotes. When empty, this zone is a master. When set, this
26787 zone is a slave. This is a list of remotes identifiers.
26788
26789 @item @code{ddns-master} (default: @code{#f})
26790 The main master. When empty, it defaults to the first master in the list of
26791 masters.
26792
26793 @item @code{notify} (default: @code{'()})
26794 A list of slave remote identifiers.
26795
26796 @item @code{acl} (default: @code{'()})
26797 A list of acl identifiers.
26798
26799 @item @code{semantic-checks?} (default: @code{#f})
26800 When set, this adds more semantic checks to the zone.
26801
26802 @item @code{disable-any?} (default: @code{#f})
26803 When set, this forbids queries of the ANY type.
26804
26805 @item @code{zonefile-sync} (default: @code{0})
26806 The delay between a modification in memory and on disk. 0 means immediate
26807 synchronization.
26808
26809 @item @code{zonefile-load} (default: @code{#f})
26810 The way the zone file contents are applied during zone load. Possible values
26811 are:
26812
26813 @itemize
26814 @item @code{#f} for using the default value from Knot,
26815 @item @code{'none} for not using the zone file at all,
26816 @item @code{'difference} for computing the difference between already available
26817 contents and zone contents and applying it to the current zone contents,
26818 @item @code{'difference-no-serial} for the same as @code{'difference}, but
26819 ignoring the SOA serial in the zone file, while the server takes care of it
26820 automatically.
26821 @item @code{'whole} for loading zone contents from the zone file.
26822 @end itemize
26823
26824 @item @code{journal-content} (default: @code{#f})
26825 The way the journal is used to store zone and its changes. Possible values
26826 are @code{'none} to not use it at all, @code{'changes} to store changes and
26827 @code{'all} to store contents. @code{#f} does not set this option, so the
26828 default value from Knot is used.
26829
26830 @item @code{max-journal-usage} (default: @code{#f})
26831 The maximum size for the journal on disk. @code{#f} does not set this option,
26832 so the default value from Knot is used.
26833
26834 @item @code{max-journal-depth} (default: @code{#f})
26835 The maximum size of the history. @code{#f} does not set this option, so the
26836 default value from Knot is used.
26837
26838 @item @code{max-zone-size} (default: @code{#f})
26839 The maximum size of the zone file. This limit is enforced for incoming
26840 transfer and updates. @code{#f} does not set this option, so the default
26841 value from Knot is used.
26842
26843 @item @code{dnssec-policy} (default: @code{#f})
26844 A reference to a @code{knot-policy-configuration} record, or the special
26845 name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
26846 on this zone.
26847
26848 @item @code{serial-policy} (default: @code{'increment})
26849 A policy between @code{'increment} and @code{'unixtime}.
26850
26851 @end table
26852 @end deftp
26853
26854 @deftp {Data Type} knot-configuration
26855 Data type representing the Knot configuration.
26856 This type has the following parameters:
26857
26858 @table @asis
26859 @item @code{knot} (default: @code{knot})
26860 The Knot package.
26861
26862 @item @code{run-directory} (default: @code{"/var/run/knot"})
26863 The run directory. This directory will be used for pid file and sockets.
26864
26865 @item @code{includes} (default: @code{'()})
26866 A list of strings or file-like objects denoting other files that must be
26867 included at the top of the configuration file.
26868
26869 @cindex secrets, Knot service
26870 This can be used to manage secrets out-of-band. For example, secret
26871 keys may be stored in an out-of-band file not managed by Guix, and
26872 thus not visible in @file{/gnu/store}---e.g., you could store secret
26873 key configuration in @file{/etc/knot/secrets.conf} and add this file
26874 to the @code{includes} list.
26875
26876 One can generate a secret tsig key (for nsupdate and zone transfers with the
26877 keymgr command from the knot package. Note that the package is not automatically
26878 installed by the service. The following example shows how to generate a new
26879 tsig key:
26880
26881 @example
26882 keymgr -t mysecret > /etc/knot/secrets.conf
26883 chmod 600 /etc/knot/secrets.conf
26884 @end example
26885
26886 Also note that the generated key will be named @var{mysecret}, so it is the
26887 name that needs to be used in the @var{key} field of the
26888 @code{knot-acl-configuration} record and in other places that need to refer
26889 to that key.
26890
26891 It can also be used to add configuration not supported by this interface.
26892
26893 @item @code{listen-v4} (default: @code{"0.0.0.0"})
26894 An ip address on which to listen.
26895
26896 @item @code{listen-v6} (default: @code{"::"})
26897 An ip address on which to listen.
26898
26899 @item @code{listen-port} (default: @code{53})
26900 A port on which to listen.
26901
26902 @item @code{keys} (default: @code{'()})
26903 The list of knot-key-configuration used by this configuration.
26904
26905 @item @code{acls} (default: @code{'()})
26906 The list of knot-acl-configuration used by this configuration.
26907
26908 @item @code{remotes} (default: @code{'()})
26909 The list of knot-remote-configuration used by this configuration.
26910
26911 @item @code{zones} (default: @code{'()})
26912 The list of knot-zone-configuration used by this configuration.
26913
26914 @end table
26915 @end deftp
26916
26917 @subsubheading Knot Resolver Service
26918
26919 @deffn {Scheme Variable} knot-resolver-service-type
26920 This is the type of the knot resolver service, whose value should be
26921 an @code{knot-resolver-configuration} object as in this example:
26922
26923 @lisp
26924 (service knot-resolver-service-type
26925 (knot-resolver-configuration
26926 (kresd-config-file (plain-file "kresd.conf" "
26927 net.listen('192.168.0.1', 5353)
26928 user('knot-resolver', 'knot-resolver')
26929 modules = @{ 'hints > iterate', 'stats', 'predict' @}
26930 cache.size = 100 * MB
26931 "))))
26932 @end lisp
26933
26934 For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
26935 @end deffn
26936
26937 @deftp {Data Type} knot-resolver-configuration
26938 Data type representing the configuration of knot-resolver.
26939
26940 @table @asis
26941 @item @code{package} (default: @var{knot-resolver})
26942 Package object of the knot DNS resolver.
26943
26944 @item @code{kresd-config-file} (default: %kresd.conf)
26945 File-like object of the kresd configuration file to use, by default it
26946 will listen on @code{127.0.0.1} and @code{::1}.
26947
26948 @item @code{garbage-collection-interval} (default: 1000)
26949 Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
26950
26951 @end table
26952 @end deftp
26953
26954
26955 @subsubheading Dnsmasq Service
26956
26957 @deffn {Scheme Variable} dnsmasq-service-type
26958 This is the type of the dnsmasq service, whose value should be an
26959 @code{dnsmasq-configuration} object as in this example:
26960
26961 @lisp
26962 (service dnsmasq-service-type
26963 (dnsmasq-configuration
26964 (no-resolv? #t)
26965 (servers '("192.168.1.1"))))
26966 @end lisp
26967 @end deffn
26968
26969 @deftp {Data Type} dnsmasq-configuration
26970 Data type representing the configuration of dnsmasq.
26971
26972 @table @asis
26973 @item @code{package} (default: @var{dnsmasq})
26974 Package object of the dnsmasq server.
26975
26976 @item @code{no-hosts?} (default: @code{#f})
26977 When true, don't read the hostnames in /etc/hosts.
26978
26979 @item @code{port} (default: @code{53})
26980 The port to listen on. Setting this to zero completely disables DNS
26981 responses, leaving only DHCP and/or TFTP functions.
26982
26983 @item @code{local-service?} (default: @code{#t})
26984 Accept DNS queries only from hosts whose address is on a local subnet,
26985 ie a subnet for which an interface exists on the server.
26986
26987 @item @code{listen-addresses} (default: @code{'()})
26988 Listen on the given IP addresses.
26989
26990 @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
26991 The file to read the IP address of the upstream nameservers from.
26992
26993 @item @code{no-resolv?} (default: @code{#f})
26994 When true, don't read @var{resolv-file}.
26995
26996 @item @code{servers} (default: @code{'()})
26997 Specify IP address of upstream servers directly.
26998
26999 @item @code{addresses} (default: @code{'()})
27000 For each entry, specify an IP address to return for any host in the
27001 given domains. Queries in the domains are never forwarded and always
27002 replied to with the specified IP address.
27003
27004 This is useful for redirecting hosts locally, for example:
27005
27006 @lisp
27007 (service dnsmasq-service-type
27008 (dnsmasq-configuration
27009 (addresses
27010 '(; Redirect to a local web-server.
27011 "/example.org/127.0.0.1"
27012 ; Redirect subdomain to a specific IP.
27013 "/subdomain.example.org/192.168.1.42"))))
27014 @end lisp
27015
27016 Note that rules in @file{/etc/hosts} take precedence over this.
27017
27018 @item @code{cache-size} (default: @code{150})
27019 Set the size of dnsmasq's cache. Setting the cache size to zero
27020 disables caching.
27021
27022 @item @code{negative-cache?} (default: @code{#t})
27023 When false, disable negative caching.
27024
27025 @item @code{tftp-enable?} (default: @code{#f})
27026 Whether to enable the built-in TFTP server.
27027
27028 @item @code{tftp-no-fail?} (default: @code{#f})
27029 If true, does not fail dnsmasq if the TFTP server could not start up.
27030
27031 @item @code{tftp-single-port?} (default: @code{#f})
27032 Whether to use only one single port for TFTP.
27033
27034 @item @code{tftp-secure?} (default: @code{#f})
27035 If true, only files owned by the user running the dnsmasq process are accessible.
27036
27037 If dnsmasq is being run as root, different rules apply:
27038 @code{tftp-secure?} has no effect, but only files which have the
27039 world-readable bit set are accessible.
27040
27041 @item @code{tftp-max} (default: @code{#f})
27042 If set, sets the maximal number of concurrent connections allowed.
27043
27044 @item @code{tftp-mtu} (default: @code{#f})
27045 If set, sets the MTU for TFTP packets to that value.
27046
27047 @item @code{tftp-no-blocksize?} (default: @code{#f})
27048 If true, stops the TFTP server from negotiating the blocksize with a client.
27049
27050 @item @code{tftp-lowercase?} (default: @code{#f})
27051 Whether to convert all filenames in TFTP requests to lowercase.
27052
27053 @item @code{tftp-port-range} (default: @code{#f})
27054 If set, fixes the dynamical ports (one per client) to the given range
27055 (@code{"<start>,<end>"}).
27056
27057 @item @code{tftp-root} (default: @code{/var/empty,lo})
27058 Look for files to transfer using TFTP relative to the given directory.
27059 When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
27060 getting outside the specified root. Absolute paths (starting with @samp{/}) are
27061 allowed, but they must be within the TFTP-root. If the optional interface
27062 argument is given, the directory is only used for TFTP requests via that
27063 interface.
27064
27065 @item @code{tftp-unique-root} (default: @code{#f})
27066 If set, add the IP or hardware address of the TFTP client as a path component
27067 on the end of the TFTP-root. Only valid if a TFTP root is set and the
27068 directory exists. Defaults to adding IP address (in standard dotted-quad
27069 format).
27070
27071 For instance, if @option{--tftp-root} is @samp{/tftp} and client
27072 @samp{1.2.3.4} requests file @file{myfile} then the effective path will
27073 be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
27074 @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
27075 append the MAC address instead, using lowercase zero padded digits
27076 separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
27077 resolving MAC addresses is only possible if the client is in the local
27078 network or obtained a DHCP lease from dnsmasq.
27079
27080 @end table
27081 @end deftp
27082
27083 @subsubheading ddclient Service
27084
27085 @cindex ddclient
27086 The ddclient service described below runs the ddclient daemon, which takes
27087 care of automatically updating DNS entries for service providers such as
27088 @uref{https://dyn.com/dns/, Dyn}.
27089
27090 The following example show instantiates the service with its default
27091 configuration:
27092
27093 @lisp
27094 (service ddclient-service-type)
27095 @end lisp
27096
27097 Note that ddclient needs to access credentials that are stored in a
27098 @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
27099 @code{secret-file} below). You are expected to create this file manually, in
27100 an ``out-of-band'' fashion (you @emph{could} make this file part of the
27101 service configuration, for instance by using @code{plain-file}, but it will be
27102 world-readable @i{via} @file{/gnu/store}). See the examples in the
27103 @file{share/ddclient} directory of the @code{ddclient} package.
27104
27105 @c %start of fragment
27106
27107 Available @code{ddclient-configuration} fields are:
27108
27109 @deftypevr {@code{ddclient-configuration} parameter} package ddclient
27110 The ddclient package.
27111
27112 @end deftypevr
27113
27114 @deftypevr {@code{ddclient-configuration} parameter} integer daemon
27115 The period after which ddclient will retry to check IP and domain name.
27116
27117 Defaults to @samp{300}.
27118
27119 @end deftypevr
27120
27121 @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
27122 Use syslog for the output.
27123
27124 Defaults to @samp{#t}.
27125
27126 @end deftypevr
27127
27128 @deftypevr {@code{ddclient-configuration} parameter} string mail
27129 Mail to user.
27130
27131 Defaults to @samp{"root"}.
27132
27133 @end deftypevr
27134
27135 @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
27136 Mail failed update to user.
27137
27138 Defaults to @samp{"root"}.
27139
27140 @end deftypevr
27141
27142 @deftypevr {@code{ddclient-configuration} parameter} string pid
27143 The ddclient PID file.
27144
27145 Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
27146
27147 @end deftypevr
27148
27149 @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
27150 Enable SSL support.
27151
27152 Defaults to @samp{#t}.
27153
27154 @end deftypevr
27155
27156 @deftypevr {@code{ddclient-configuration} parameter} string user
27157 Specifies the user name or ID that is used when running ddclient
27158 program.
27159
27160 Defaults to @samp{"ddclient"}.
27161
27162 @end deftypevr
27163
27164 @deftypevr {@code{ddclient-configuration} parameter} string group
27165 Group of the user who will run the ddclient program.
27166
27167 Defaults to @samp{"ddclient"}.
27168
27169 @end deftypevr
27170
27171 @deftypevr {@code{ddclient-configuration} parameter} string secret-file
27172 Secret file which will be appended to @file{ddclient.conf} file. This
27173 file contains credentials for use by ddclient. You are expected to
27174 create it manually.
27175
27176 Defaults to @samp{"/etc/ddclient/secrets.conf"}.
27177
27178 @end deftypevr
27179
27180 @deftypevr {@code{ddclient-configuration} parameter} list extra-options
27181 Extra options will be appended to @file{ddclient.conf} file.
27182
27183 Defaults to @samp{()}.
27184
27185 @end deftypevr
27186
27187
27188 @c %end of fragment
27189
27190
27191 @node VPN Services
27192 @subsection VPN Services
27193 @cindex VPN (virtual private network)
27194 @cindex virtual private network (VPN)
27195
27196 The @code{(gnu services vpn)} module provides services related to
27197 @dfn{virtual private networks} (VPNs).
27198
27199 @subsubheading Bitmask
27200
27201 @defvr {Scheme Variable} bitmask-service-type
27202 A service type for the @uref{https://bitmask.net, Bitmask} VPN client. It makes
27203 the client available in the system and loads its polkit policy. Please note that
27204 the client expects an active polkit-agent, which is either run by your
27205 desktop-environment or should be run manually.
27206 @end defvr
27207
27208 @subsubheading OpenVPN
27209
27210 It provides a @emph{client} service for your machine to connect to a
27211 VPN, and a @emph{server} service for your machine to host a VPN@.
27212
27213 @deffn {Scheme Procedure} openvpn-client-service @
27214 [#:config (openvpn-client-configuration)]
27215
27216 Return a service that runs @command{openvpn}, a VPN daemon, as a client.
27217 @end deffn
27218
27219 @deffn {Scheme Procedure} openvpn-server-service @
27220 [#:config (openvpn-server-configuration)]
27221
27222 Return a service that runs @command{openvpn}, a VPN daemon, as a server.
27223
27224 Both can be run simultaneously.
27225 @end deffn
27226
27227 @c %automatically generated documentation
27228
27229 Available @code{openvpn-client-configuration} fields are:
27230
27231 @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
27232 The OpenVPN package.
27233
27234 @end deftypevr
27235
27236 @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
27237 The OpenVPN pid file.
27238
27239 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
27240
27241 @end deftypevr
27242
27243 @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
27244 The protocol (UDP or TCP) used to open a channel between clients and
27245 servers.
27246
27247 Defaults to @samp{udp}.
27248
27249 @end deftypevr
27250
27251 @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
27252 The device type used to represent the VPN connection.
27253
27254 Defaults to @samp{tun}.
27255
27256 @end deftypevr
27257
27258 If you do not have some of these files (eg.@: you use a username and
27259 password), you can disable any of the following three fields by setting
27260 it to @code{'disabled}.
27261
27262 @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
27263 The certificate authority to check connections against.
27264
27265 Defaults to @samp{"/etc/openvpn/ca.crt"}.
27266
27267 @end deftypevr
27268
27269 @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
27270 The certificate of the machine the daemon is running on. It should be
27271 signed by the authority given in @code{ca}.
27272
27273 Defaults to @samp{"/etc/openvpn/client.crt"}.
27274
27275 @end deftypevr
27276
27277 @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
27278 The key of the machine the daemon is running on. It must be the key whose
27279 certificate is @code{cert}.
27280
27281 Defaults to @samp{"/etc/openvpn/client.key"}.
27282
27283 @end deftypevr
27284
27285 @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
27286 Whether to use the lzo compression algorithm.
27287
27288 Defaults to @samp{#t}.
27289
27290 @end deftypevr
27291
27292 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
27293 Don't re-read key files across SIGUSR1 or --ping-restart.
27294
27295 Defaults to @samp{#t}.
27296
27297 @end deftypevr
27298
27299 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
27300 Don't close and reopen TUN/TAP device or run up/down scripts across
27301 SIGUSR1 or --ping-restart restarts.
27302
27303 Defaults to @samp{#t}.
27304
27305 @end deftypevr
27306
27307 @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
27308 (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
27309 poll/epoll/select prior to the write operation.
27310
27311 Defaults to @samp{#f}.
27312 @end deftypevr
27313
27314 @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
27315 Verbosity level.
27316
27317 Defaults to @samp{3}.
27318
27319 @end deftypevr
27320
27321 @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
27322 Add an additional layer of HMAC authentication on top of the TLS control
27323 channel to protect against DoS attacks.
27324
27325 Defaults to @samp{#f}.
27326
27327 @end deftypevr
27328
27329 @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
27330 Authenticate with server using username/password. The option is a file
27331 containing username/password on 2 lines. Do not use a file-like object as it
27332 would be added to the store and readable by any user.
27333
27334 Defaults to @samp{'disabled}.
27335 @end deftypevr
27336
27337 @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
27338 Whether to check the server certificate has server usage extension.
27339
27340 Defaults to @samp{#t}.
27341
27342 @end deftypevr
27343
27344 @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
27345 Bind to a specific local port number.
27346
27347 Defaults to @samp{#f}.
27348
27349 @end deftypevr
27350
27351 @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
27352 Retry resolving server address.
27353
27354 Defaults to @samp{#t}.
27355
27356 @end deftypevr
27357
27358 @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
27359 A list of remote servers to connect to.
27360
27361 Defaults to @samp{()}.
27362
27363 Available @code{openvpn-remote-configuration} fields are:
27364
27365 @deftypevr {@code{openvpn-remote-configuration} parameter} string name
27366 Server name.
27367
27368 Defaults to @samp{"my-server"}.
27369
27370 @end deftypevr
27371
27372 @deftypevr {@code{openvpn-remote-configuration} parameter} number port
27373 Port number the server listens to.
27374
27375 Defaults to @samp{1194}.
27376
27377 @end deftypevr
27378
27379 @end deftypevr
27380 @c %end of automatic openvpn-client documentation
27381
27382 @c %automatically generated documentation
27383
27384 Available @code{openvpn-server-configuration} fields are:
27385
27386 @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
27387 The OpenVPN package.
27388
27389 @end deftypevr
27390
27391 @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
27392 The OpenVPN pid file.
27393
27394 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
27395
27396 @end deftypevr
27397
27398 @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
27399 The protocol (UDP or TCP) used to open a channel between clients and
27400 servers.
27401
27402 Defaults to @samp{udp}.
27403
27404 @end deftypevr
27405
27406 @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
27407 The device type used to represent the VPN connection.
27408
27409 Defaults to @samp{tun}.
27410
27411 @end deftypevr
27412
27413 If you do not have some of these files (eg.@: you use a username and
27414 password), you can disable any of the following three fields by setting
27415 it to @code{'disabled}.
27416
27417 @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
27418 The certificate authority to check connections against.
27419
27420 Defaults to @samp{"/etc/openvpn/ca.crt"}.
27421
27422 @end deftypevr
27423
27424 @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
27425 The certificate of the machine the daemon is running on. It should be
27426 signed by the authority given in @code{ca}.
27427
27428 Defaults to @samp{"/etc/openvpn/client.crt"}.
27429
27430 @end deftypevr
27431
27432 @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
27433 The key of the machine the daemon is running on. It must be the key whose
27434 certificate is @code{cert}.
27435
27436 Defaults to @samp{"/etc/openvpn/client.key"}.
27437
27438 @end deftypevr
27439
27440 @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
27441 Whether to use the lzo compression algorithm.
27442
27443 Defaults to @samp{#t}.
27444
27445 @end deftypevr
27446
27447 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
27448 Don't re-read key files across SIGUSR1 or --ping-restart.
27449
27450 Defaults to @samp{#t}.
27451
27452 @end deftypevr
27453
27454 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
27455 Don't close and reopen TUN/TAP device or run up/down scripts across
27456 SIGUSR1 or --ping-restart restarts.
27457
27458 Defaults to @samp{#t}.
27459
27460 @end deftypevr
27461
27462 @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
27463 (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
27464 poll/epoll/select prior to the write operation.
27465
27466 Defaults to @samp{#f}.
27467 @end deftypevr
27468
27469 @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
27470 Verbosity level.
27471
27472 Defaults to @samp{3}.
27473
27474 @end deftypevr
27475
27476 @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
27477 Add an additional layer of HMAC authentication on top of the TLS control
27478 channel to protect against DoS attacks.
27479
27480 Defaults to @samp{#f}.
27481
27482 @end deftypevr
27483
27484 @deftypevr {@code{openvpn-server-configuration} parameter} number port
27485 Specifies the port number on which the server listens.
27486
27487 Defaults to @samp{1194}.
27488
27489 @end deftypevr
27490
27491 @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
27492 An ip and mask specifying the subnet inside the virtual network.
27493
27494 Defaults to @samp{"10.8.0.0 255.255.255.0"}.
27495
27496 @end deftypevr
27497
27498 @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
27499 A CIDR notation specifying the IPv6 subnet inside the virtual network.
27500
27501 Defaults to @samp{#f}.
27502
27503 @end deftypevr
27504
27505 @deftypevr {@code{openvpn-server-configuration} parameter} string dh
27506 The Diffie-Hellman parameters file.
27507
27508 Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
27509
27510 @end deftypevr
27511
27512 @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
27513 The file that records client IPs.
27514
27515 Defaults to @samp{"/etc/openvpn/ipp.txt"}.
27516
27517 @end deftypevr
27518
27519 @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
27520 When true, the server will act as a gateway for its clients.
27521
27522 Defaults to @samp{#f}.
27523
27524 @end deftypevr
27525
27526 @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
27527 When true, clients are allowed to talk to each other inside the VPN.
27528
27529 Defaults to @samp{#f}.
27530
27531 @end deftypevr
27532
27533 @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
27534 Causes ping-like messages to be sent back and forth over the link so
27535 that each side knows when the other side has gone down. @code{keepalive}
27536 requires a pair. The first element is the period of the ping sending,
27537 and the second element is the timeout before considering the other side
27538 down.
27539
27540 @end deftypevr
27541
27542 @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
27543 The maximum number of clients.
27544
27545 Defaults to @samp{100}.
27546
27547 @end deftypevr
27548
27549 @deftypevr {@code{openvpn-server-configuration} parameter} string status
27550 The status file. This file shows a small report on current connection.
27551 It is truncated and rewritten every minute.
27552
27553 Defaults to @samp{"/var/run/openvpn/status"}.
27554
27555 @end deftypevr
27556
27557 @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
27558 The list of configuration for some clients.
27559
27560 Defaults to @samp{()}.
27561
27562 Available @code{openvpn-ccd-configuration} fields are:
27563
27564 @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
27565 Client name.
27566
27567 Defaults to @samp{"client"}.
27568
27569 @end deftypevr
27570
27571 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
27572 Client own network
27573
27574 Defaults to @samp{#f}.
27575
27576 @end deftypevr
27577
27578 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
27579 Client VPN IP.
27580
27581 Defaults to @samp{#f}.
27582
27583 @end deftypevr
27584
27585 @end deftypevr
27586
27587 @c %end of automatic openvpn-server documentation
27588
27589 @subheading strongSwan
27590
27591 Currently, the strongSwan service only provides legacy-style configuration with
27592 @file{ipsec.conf} and @file{ipsec.secrets} files.
27593
27594 @defvr {Scheme Variable} strongswan-service-type
27595 A service type for configuring strongSwan for IPsec @acronym{VPN,
27596 Virtual Private Networking}. Its value must be a
27597 @code{strongswan-configuration} record as in this example:
27598
27599 @lisp
27600 (service strongswan-service-type
27601 (strongswan-configuration
27602 (ipsec-conf "/etc/ipsec.conf")
27603 (ipsec-secrets "/etc/ipsec.secrets")))
27604 @end lisp
27605
27606 @end defvr
27607
27608 @deftp {Data Type} strongswan-configuration
27609 Data type representing the configuration of the StrongSwan service.
27610
27611 @table @asis
27612 @item @code{strongswan}
27613 The strongSwan package to use for this service.
27614
27615 @item @code{ipsec-conf} (default: @code{#f})
27616 The file name of your @file{ipsec.conf}. If not @code{#f}, then this and
27617 @code{ipsec-secrets} must both be strings.
27618
27619 @item @code{ipsec-secrets} (default @code{#f})
27620 The file name of your @file{ipsec.secrets}. If not @code{#f}, then this and
27621 @code{ipsec-conf} must both be strings.
27622
27623 @end table
27624 @end deftp
27625
27626 @subsubheading Wireguard
27627
27628 @defvr {Scheme Variable} wireguard-service-type
27629 A service type for a Wireguard tunnel interface. Its value must be a
27630 @code{wireguard-configuration} record as in this example:
27631
27632 @lisp
27633 (service wireguard-service-type
27634 (wireguard-configuration
27635 (peers
27636 (list
27637 (wireguard-peer
27638 (name "my-peer")
27639 (endpoint "my.wireguard.com:51820")
27640 (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
27641 (allowed-ips '("10.0.0.2/32")))))))
27642 @end lisp
27643
27644 @end defvr
27645
27646 @deftp {Data Type} wireguard-configuration
27647 Data type representing the configuration of the Wireguard service.
27648
27649 @table @asis
27650 @item @code{wireguard}
27651 The wireguard package to use for this service.
27652
27653 @item @code{interface} (default: @code{"wg0"})
27654 The interface name for the VPN.
27655
27656 @item @code{addresses} (default: @code{'("10.0.0.1/32")})
27657 The IP addresses to be assigned to the above interface.
27658
27659 @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
27660 The private key file for the interface. It is automatically generated if
27661 the file does not exist.
27662
27663 @item @code{peers} (default: @code{'()})
27664 The authorized peers on this interface. This is a list of
27665 @var{wireguard-peer} records.
27666
27667 @end table
27668 @end deftp
27669
27670 @deftp {Data Type} wireguard-peer
27671 Data type representing a Wireguard peer attached to a given interface.
27672
27673 @table @asis
27674 @item @code{name}
27675 The peer name.
27676
27677 @item @code{endpoint} (default: @code{#f})
27678 The optional endpoint for the peer, such as
27679 @code{"demo.wireguard.com:51820"}.
27680
27681 @item @code{public-key}
27682 The peer public-key represented as a base64 string.
27683
27684 @item @code{allowed-ips}
27685 A list of IP addresses from which incoming traffic for this peer is
27686 allowed and to which incoming traffic for this peer is directed.
27687
27688 @item @code{keep-alive} (default: @code{#f})
27689 An optional time interval in seconds. A packet will be sent to the
27690 server endpoint once per time interval. This helps receiving
27691 incoming connections from this peer when you are behind a NAT or
27692 a firewall.
27693
27694 @end table
27695 @end deftp
27696
27697 @node Network File System
27698 @subsection Network File System
27699 @cindex NFS
27700
27701 The @code{(gnu services nfs)} module provides the following services,
27702 which are most commonly used in relation to mounting or exporting
27703 directory trees as @dfn{network file systems} (NFS).
27704
27705 While it is possible to use the individual components that together make
27706 up a Network File System service, we recommended to configure an NFS
27707 server with the @code{nfs-service-type}.
27708
27709 @subsubheading NFS Service
27710 @cindex NFS, server
27711
27712 The NFS service takes care of setting up all NFS component services,
27713 kernel configuration file systems, and installs configuration files in
27714 the locations that NFS expects.
27715
27716 @defvr {Scheme Variable} nfs-service-type
27717 A service type for a complete NFS server.
27718 @end defvr
27719
27720 @deftp {Data Type} nfs-configuration
27721 This data type represents the configuration of the NFS service and all
27722 of its subsystems.
27723
27724 It has the following parameters:
27725 @table @asis
27726 @item @code{nfs-utils} (default: @code{nfs-utils})
27727 The nfs-utils package to use.
27728
27729 @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
27730 If a list of string values is provided, the @command{rpc.nfsd} daemon
27731 will be limited to supporting the given versions of the NFS protocol.
27732
27733 @item @code{exports} (default: @code{'()})
27734 This is a list of directories the NFS server should export. Each entry
27735 is a list consisting of two elements: a directory name and a string
27736 containing all options. This is an example in which the directory
27737 @file{/export} is served to all NFS clients as a read-only share:
27738
27739 @lisp
27740 (nfs-configuration
27741 (exports
27742 '(("/export"
27743 "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
27744 @end lisp
27745
27746 @item @code{rpcmountd-port} (default: @code{#f})
27747 The network port that the @command{rpc.mountd} daemon should use.
27748
27749 @item @code{rpcstatd-port} (default: @code{#f})
27750 The network port that the @command{rpc.statd} daemon should use.
27751
27752 @item @code{rpcbind} (default: @code{rpcbind})
27753 The rpcbind package to use.
27754
27755 @item @code{idmap-domain} (default: @code{"localdomain"})
27756 The local NFSv4 domain name.
27757
27758 @item @code{nfsd-port} (default: @code{2049})
27759 The network port that the @command{nfsd} daemon should use.
27760
27761 @item @code{nfsd-threads} (default: @code{8})
27762 The number of threads used by the @command{nfsd} daemon.
27763
27764 @item @code{nfsd-tcp?} (default: @code{#t})
27765 Whether the @command{nfsd} daemon should listen on a TCP socket.
27766
27767 @item @code{nfsd-udp?} (default: @code{#f})
27768 Whether the @command{nfsd} daemon should listen on a UDP socket.
27769
27770 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
27771 The directory where the pipefs file system is mounted.
27772
27773 @item @code{debug} (default: @code{'()"})
27774 A list of subsystems for which debugging output should be enabled. This
27775 is a list of symbols. Any of these symbols are valid: @code{nfsd},
27776 @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
27777 @end table
27778 @end deftp
27779
27780 If you don't need a complete NFS service or prefer to build it yourself
27781 you can use the individual component services that are documented below.
27782
27783 @subsubheading RPC Bind Service
27784 @cindex rpcbind
27785
27786 The RPC Bind service provides a facility to map program numbers into
27787 universal addresses.
27788 Many NFS related services use this facility. Hence it is automatically
27789 started when a dependent service starts.
27790
27791 @defvr {Scheme Variable} rpcbind-service-type
27792 A service type for the RPC portmapper daemon.
27793 @end defvr
27794
27795
27796 @deftp {Data Type} rpcbind-configuration
27797 Data type representing the configuration of the RPC Bind Service.
27798 This type has the following parameters:
27799 @table @asis
27800 @item @code{rpcbind} (default: @code{rpcbind})
27801 The rpcbind package to use.
27802
27803 @item @code{warm-start?} (default: @code{#t})
27804 If this parameter is @code{#t}, then the daemon will read a
27805 state file on startup thus reloading state information saved by a previous
27806 instance.
27807 @end table
27808 @end deftp
27809
27810
27811 @subsubheading Pipefs Pseudo File System
27812 @cindex pipefs
27813 @cindex rpc_pipefs
27814
27815 The pipefs file system is used to transfer NFS related data
27816 between the kernel and user space programs.
27817
27818 @defvr {Scheme Variable} pipefs-service-type
27819 A service type for the pipefs pseudo file system.
27820 @end defvr
27821
27822 @deftp {Data Type} pipefs-configuration
27823 Data type representing the configuration of the pipefs pseudo file system service.
27824 This type has the following parameters:
27825 @table @asis
27826 @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
27827 The directory to which the file system is to be attached.
27828 @end table
27829 @end deftp
27830
27831
27832 @subsubheading GSS Daemon Service
27833 @cindex GSSD
27834 @cindex GSS
27835 @cindex global security system
27836
27837 The @dfn{global security system} (GSS) daemon provides strong security for RPC
27838 based protocols.
27839 Before exchanging RPC requests an RPC client must establish a security
27840 context. Typically this is done using the Kerberos command @command{kinit}
27841 or automatically at login time using PAM services (@pxref{Kerberos Services}).
27842
27843 @defvr {Scheme Variable} gss-service-type
27844 A service type for the Global Security System (GSS) daemon.
27845 @end defvr
27846
27847 @deftp {Data Type} gss-configuration
27848 Data type representing the configuration of the GSS daemon service.
27849 This type has the following parameters:
27850 @table @asis
27851 @item @code{nfs-utils} (default: @code{nfs-utils})
27852 The package in which the @command{rpc.gssd} command is to be found.
27853
27854 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
27855 The directory where the pipefs file system is mounted.
27856
27857 @end table
27858 @end deftp
27859
27860
27861 @subsubheading IDMAP Daemon Service
27862 @cindex idmapd
27863 @cindex name mapper
27864
27865 The idmap daemon service provides mapping between user IDs and user names.
27866 Typically it is required in order to access file systems mounted via NFSv4.
27867
27868 @defvr {Scheme Variable} idmap-service-type
27869 A service type for the Identity Mapper (IDMAP) daemon.
27870 @end defvr
27871
27872 @deftp {Data Type} idmap-configuration
27873 Data type representing the configuration of the IDMAP daemon service.
27874 This type has the following parameters:
27875 @table @asis
27876 @item @code{nfs-utils} (default: @code{nfs-utils})
27877 The package in which the @command{rpc.idmapd} command is to be found.
27878
27879 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
27880 The directory where the pipefs file system is mounted.
27881
27882 @item @code{domain} (default: @code{#f})
27883 The local NFSv4 domain name.
27884 This must be a string or @code{#f}.
27885 If it is @code{#f} then the daemon will use the host's fully qualified domain name.
27886
27887 @item @code{verbosity} (default: @code{0})
27888 The verbosity level of the daemon.
27889
27890 @end table
27891 @end deftp
27892
27893 @node Continuous Integration
27894 @subsection Continuous Integration
27895
27896 @cindex continuous integration
27897 @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
27898 integration tool for Guix. It can be used both for development and for
27899 providing substitutes to others (@pxref{Substitutes}).
27900
27901 The @code{(gnu services cuirass)} module provides the following service.
27902
27903 @defvr {Scheme Procedure} cuirass-service-type
27904 The type of the Cuirass service. Its value must be a
27905 @code{cuirass-configuration} object, as described below.
27906 @end defvr
27907
27908 To add build jobs, you have to set the @code{specifications} field of
27909 the configuration. For instance, the following example will build all
27910 the packages provided by the @code{my-channel} channel.
27911
27912 @lisp
27913 (define %cuirass-specs
27914 #~(list (specification
27915 (name "my-channel")
27916 (build '(channels my-channel))
27917 (channels
27918 (cons (channel
27919 (name 'my-channel)
27920 (url "https://my-channel.git"))
27921 %default-channels)))))
27922
27923 (service cuirass-service-type
27924 (cuirass-configuration
27925 (specifications %cuirass-specs)))
27926 @end lisp
27927
27928 To build the @code{linux-libre} package defined by the default Guix
27929 channel, one can use the following configuration.
27930
27931 @lisp
27932 (define %cuirass-specs
27933 #~(list (specification
27934 (name "my-linux")
27935 (build '(packages "linux-libre")))))
27936
27937 (service cuirass-service-type
27938 (cuirass-configuration
27939 (specifications %cuirass-specs)))
27940 @end lisp
27941
27942 The other configuration possibilities, as well as the specification
27943 record itself are described in the Cuirass manual
27944 (@pxref{Specifications,,, cuirass, Cuirass}).
27945
27946 While information related to build jobs is located directly in the
27947 specifications, global settings for the @command{cuirass} process are
27948 accessible in other @code{cuirass-configuration} fields.
27949
27950 @deftp {Data Type} cuirass-configuration
27951 Data type representing the configuration of Cuirass.
27952
27953 @table @asis
27954 @item @code{cuirass} (default: @code{cuirass})
27955 The Cuirass package to use.
27956
27957 @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
27958 Location of the log file.
27959
27960 @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
27961 Location of the log file used by the web interface.
27962
27963 @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
27964 Location of the repository cache.
27965
27966 @item @code{user} (default: @code{"cuirass"})
27967 Owner of the @code{cuirass} process.
27968
27969 @item @code{group} (default: @code{"cuirass"})
27970 Owner's group of the @code{cuirass} process.
27971
27972 @item @code{interval} (default: @code{60})
27973 Number of seconds between the poll of the repositories followed by the
27974 Cuirass jobs.
27975
27976 @item @code{parameters} (default: @code{#f})
27977 Read parameters from the given @var{parameters} file. The supported
27978 parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
27979
27980 @item @code{remote-server} (default: @code{#f})
27981 A @code{cuirass-remote-server-configuration} record to use the build
27982 remote mechanism or @code{#f} to use the default build mechanism.
27983
27984 @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
27985 Use @var{database} as the database containing the jobs and the past
27986 build results. Since Cuirass uses PostgreSQL as a database engine,
27987 @var{database} must be a string such as @code{"dbname=cuirass
27988 host=localhost"}.
27989
27990 @item @code{port} (default: @code{8081})
27991 Port number used by the HTTP server.
27992
27993 @item @code{host} (default: @code{"localhost"})
27994 Listen on the network interface for @var{host}. The default is to
27995 accept connections from localhost.
27996
27997 @item @code{specifications} (default: @code{#~'()})
27998 A gexp (@pxref{G-Expressions}) that evaluates to a list of
27999 specifications records. The specification record is described in the
28000 Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
28001
28002 @item @code{use-substitutes?} (default: @code{#f})
28003 This allows using substitutes to avoid building every dependencies of a job
28004 from source.
28005
28006 @item @code{one-shot?} (default: @code{#f})
28007 Only evaluate specifications and build derivations once.
28008
28009 @item @code{fallback?} (default: @code{#f})
28010 When substituting a pre-built binary fails, fall back to building
28011 packages locally.
28012
28013 @item @code{extra-options} (default: @code{'()})
28014 Extra options to pass when running the Cuirass processes.
28015
28016 @end table
28017 @end deftp
28018
28019 @cindex remote build
28020 @subsubheading Cuirass remote building
28021
28022 Cuirass supports two mechanisms to build derivations.
28023
28024 @itemize
28025 @item Using the local Guix daemon.
28026 This is the default build mechanism. Once the build jobs are
28027 evaluated, they are sent to the local Guix daemon. Cuirass then
28028 listens to the Guix daemon output to detect the various build events.
28029
28030 @item Using the remote build mechanism.
28031 The build jobs are not submitted to the local Guix daemon. Instead, a
28032 remote server dispatches build requests to the connect remote workers,
28033 according to the build priorities.
28034
28035 @end itemize
28036
28037 To enable this build mode a @code{cuirass-remote-server-configuration}
28038 record must be passed as @code{remote-server} argument of the
28039 @code{cuirass-configuration} record. The
28040 @code{cuirass-remote-server-configuration} record is described below.
28041
28042 This build mode scales way better than the default build mode. This is
28043 the build mode that is used on the GNU Guix build farm at
28044 @url{https://ci.guix.gnu.org}. It should be preferred when using
28045 Cuirass to build large amount of packages.
28046
28047 @deftp {Data Type} cuirass-remote-server-configuration
28048 Data type representing the configuration of the Cuirass remote-server.
28049
28050 @table @asis
28051 @item @code{backend-port} (default: @code{5555})
28052 The TCP port for communicating with @code{remote-worker} processes
28053 using ZMQ. It defaults to @code{5555}.
28054
28055 @item @code{log-port} (default: @code{5556})
28056 The TCP port of the log server. It defaults to @code{5556}.
28057
28058 @item @code{publish-port} (default: @code{5557})
28059 The TCP port of the publish server. It defaults to @code{5557}.
28060
28061 @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
28062 Location of the log file.
28063
28064 @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
28065 Use @var{cache} directory to cache build log files.
28066
28067 @item @code{trigger-url} (default: @code{#f})
28068 Once a substitute is successfully fetched, trigger substitute baking at
28069 @var{trigger-url}.
28070
28071 @item @code{publish?} (default: @code{#t})
28072 If set to false, do not start a publish server and ignore the
28073 @code{publish-port} argument. This can be useful if there is already a
28074 standalone publish server standing next to the remote server.
28075
28076 @item @code{public-key}
28077 @item @code{private-key}
28078 Use the specific @var{file}s as the public/private key pair used to sign
28079 the store items being published.
28080
28081 @end table
28082 @end deftp
28083
28084 At least one remote worker must also be started on any machine of the
28085 local network to actually perform the builds and report their status.
28086
28087 @deftp {Data Type} cuirass-remote-worker-configuration
28088 Data type representing the configuration of the Cuirass remote-worker.
28089
28090 @table @asis
28091 @item @code{cuirass} (default: @code{cuirass})
28092 The Cuirass package to use.
28093
28094 @item @code{workers} (default: @code{1})
28095 Start @var{workers} parallel workers.
28096
28097 @item @code{server} (default: @code{#f})
28098 Do not use Avahi discovery and connect to the given @code{server} IP
28099 address instead.
28100
28101 @item @code{systems} (default: @code{(list (%current-system))})
28102 Only request builds for the given @var{systems}.
28103
28104 @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
28105 Location of the log file.
28106
28107 @item @code{publish-port} (default: @code{5558})
28108 The TCP port of the publish server. It defaults to @code{5558}.
28109
28110 @item @code{substitute-urls} (default: @code{%default-substitute-urls})
28111 The list of URLs where to look for substitutes by default.
28112
28113 @item @code{public-key}
28114 @item @code{private-key}
28115 Use the specific @var{file}s as the public/private key pair used to sign
28116 the store items being published.
28117
28118 @end table
28119 @end deftp
28120
28121 @subsubheading Laminar
28122
28123 @uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular
28124 Continuous Integration service. It doesn't have a configuration web UI
28125 instead uses version-controllable configuration files and scripts.
28126
28127 Laminar encourages the use of existing tools such as bash and cron
28128 instead of reinventing them.
28129
28130 @defvr {Scheme Procedure} laminar-service-type
28131 The type of the Laminar service. Its value must be a
28132 @code{laminar-configuration} object, as described below.
28133
28134 All configuration values have defaults, a minimal configuration to get
28135 Laminar running is shown below. By default, the web interface is
28136 available on port 8080.
28137
28138 @lisp
28139 (service laminar-service-type)
28140 @end lisp
28141 @end defvr
28142
28143 @deftp {Data Type} laminar-configuration
28144 Data type representing the configuration of Laminar.
28145
28146 @table @asis
28147 @item @code{laminar} (default: @code{laminar})
28148 The Laminar package to use.
28149
28150 @item @code{home-directory} (default: @code{"/var/lib/laminar"})
28151 The directory for job configurations and run directories.
28152
28153 @item @code{bind-http} (default: @code{"*:8080"})
28154 The interface/port or unix socket on which laminard should listen for
28155 incoming connections to the web frontend.
28156
28157 @item @code{bind-rpc} (default: @code{"unix-abstract:laminar"})
28158 The interface/port or unix socket on which laminard should listen for
28159 incoming commands such as build triggers.
28160
28161 @item @code{title} (default: @code{"Laminar"})
28162 The page title to show in the web frontend.
28163
28164 @item @code{keep-rundirs} (default: @code{0})
28165 Set to an integer defining how many rundirs to keep per job. The
28166 lowest-numbered ones will be deleted. The default is 0, meaning all run
28167 dirs will be immediately deleted.
28168
28169 @item @code{archive-url} (default: @code{#f})
28170 The web frontend served by laminard will use this URL to form links to
28171 artefacts archived jobs.
28172
28173 @item @code{base-url} (default: @code{#f})
28174 Base URL to use for links to laminar itself.
28175
28176 @end table
28177 @end deftp
28178
28179 @node Power Management Services
28180 @subsection Power Management Services
28181
28182 @cindex tlp
28183 @cindex power management with TLP
28184 @subsubheading TLP daemon
28185
28186 The @code{(gnu services pm)} module provides a Guix service definition
28187 for the Linux power management tool TLP.
28188
28189 TLP enables various powersaving modes in userspace and kernel.
28190 Contrary to @code{upower-service}, it is not a passive,
28191 monitoring tool, as it will apply custom settings each time a new power
28192 source is detected. More information can be found at
28193 @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
28194
28195 @deffn {Scheme Variable} tlp-service-type
28196 The service type for the TLP tool. The default settings are optimised
28197 for battery life on most systems, but you can tweak them to your heart's
28198 content by adding a valid @code{tlp-configuration}:
28199 @lisp
28200 (service tlp-service-type
28201 (tlp-configuration
28202 (cpu-scaling-governor-on-ac (list "performance"))
28203 (sched-powersave-on-bat? #t)))
28204 @end lisp
28205 @end deffn
28206
28207 Each parameter definition is preceded by its type; for example,
28208 @samp{boolean foo} indicates that the @code{foo} parameter
28209 should be specified as a boolean. Types starting with
28210 @code{maybe-} denote parameters that won't show up in TLP config file
28211 when their value is @code{'disabled}.
28212
28213 @c The following documentation was initially generated by
28214 @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
28215 @c documentation is better, so we shouldn't hesitate to edit below as
28216 @c needed. However if the change you want to make to this documentation
28217 @c can be done in an automated way, it's probably easier to change
28218 @c (generate-documentation) than to make it below and have to deal with
28219 @c the churn as TLP updates.
28220
28221 Available @code{tlp-configuration} fields are:
28222
28223 @deftypevr {@code{tlp-configuration} parameter} package tlp
28224 The TLP package.
28225
28226 @end deftypevr
28227
28228 @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
28229 Set to true if you wish to enable TLP.
28230
28231 Defaults to @samp{#t}.
28232
28233 @end deftypevr
28234
28235 @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
28236 Default mode when no power supply can be detected. Alternatives are AC
28237 and BAT.
28238
28239 Defaults to @samp{"AC"}.
28240
28241 @end deftypevr
28242
28243 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
28244 Number of seconds Linux kernel has to wait after the disk goes idle,
28245 before syncing on AC.
28246
28247 Defaults to @samp{0}.
28248
28249 @end deftypevr
28250
28251 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
28252 Same as @code{disk-idle-ac} but on BAT mode.
28253
28254 Defaults to @samp{2}.
28255
28256 @end deftypevr
28257
28258 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
28259 Dirty pages flushing periodicity, expressed in seconds.
28260
28261 Defaults to @samp{15}.
28262
28263 @end deftypevr
28264
28265 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
28266 Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
28267
28268 Defaults to @samp{60}.
28269
28270 @end deftypevr
28271
28272 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
28273 CPU frequency scaling governor on AC mode. With intel_pstate driver,
28274 alternatives are powersave and performance. With acpi-cpufreq driver,
28275 alternatives are ondemand, powersave, performance and conservative.
28276
28277 Defaults to @samp{disabled}.
28278
28279 @end deftypevr
28280
28281 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
28282 Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
28283
28284 Defaults to @samp{disabled}.
28285
28286 @end deftypevr
28287
28288 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
28289 Set the min available frequency for the scaling governor on AC.
28290
28291 Defaults to @samp{disabled}.
28292
28293 @end deftypevr
28294
28295 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
28296 Set the max available frequency for the scaling governor on AC.
28297
28298 Defaults to @samp{disabled}.
28299
28300 @end deftypevr
28301
28302 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
28303 Set the min available frequency for the scaling governor on BAT.
28304
28305 Defaults to @samp{disabled}.
28306
28307 @end deftypevr
28308
28309 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
28310 Set the max available frequency for the scaling governor on BAT.
28311
28312 Defaults to @samp{disabled}.
28313
28314 @end deftypevr
28315
28316 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
28317 Limit the min P-state to control the power dissipation of the CPU, in AC
28318 mode. Values are stated as a percentage of the available performance.
28319
28320 Defaults to @samp{disabled}.
28321
28322 @end deftypevr
28323
28324 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
28325 Limit the max P-state to control the power dissipation of the CPU, in AC
28326 mode. Values are stated as a percentage of the available performance.
28327
28328 Defaults to @samp{disabled}.
28329
28330 @end deftypevr
28331
28332 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
28333 Same as @code{cpu-min-perf-on-ac} on BAT mode.
28334
28335 Defaults to @samp{disabled}.
28336
28337 @end deftypevr
28338
28339 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
28340 Same as @code{cpu-max-perf-on-ac} on BAT mode.
28341
28342 Defaults to @samp{disabled}.
28343
28344 @end deftypevr
28345
28346 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
28347 Enable CPU turbo boost feature on AC mode.
28348
28349 Defaults to @samp{disabled}.
28350
28351 @end deftypevr
28352
28353 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
28354 Same as @code{cpu-boost-on-ac?} on BAT mode.
28355
28356 Defaults to @samp{disabled}.
28357
28358 @end deftypevr
28359
28360 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
28361 Allow Linux kernel to minimize the number of CPU cores/hyper-threads
28362 used under light load conditions.
28363
28364 Defaults to @samp{#f}.
28365
28366 @end deftypevr
28367
28368 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
28369 Same as @code{sched-powersave-on-ac?} but on BAT mode.
28370
28371 Defaults to @samp{#t}.
28372
28373 @end deftypevr
28374
28375 @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
28376 Enable Linux kernel NMI watchdog.
28377
28378 Defaults to @samp{#f}.
28379
28380 @end deftypevr
28381
28382 @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
28383 For Linux kernels with PHC patch applied, change CPU voltages. An
28384 example value would be @samp{"F:V F:V F:V F:V"}.
28385
28386 Defaults to @samp{disabled}.
28387
28388 @end deftypevr
28389
28390 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
28391 Set CPU performance versus energy saving policy on AC@. Alternatives are
28392 performance, normal, powersave.
28393
28394 Defaults to @samp{"performance"}.
28395
28396 @end deftypevr
28397
28398 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
28399 Same as @code{energy-perf-policy-ac} but on BAT mode.
28400
28401 Defaults to @samp{"powersave"}.
28402
28403 @end deftypevr
28404
28405 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
28406 Hard disk devices.
28407
28408 @end deftypevr
28409
28410 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
28411 Hard disk advanced power management level.
28412
28413 @end deftypevr
28414
28415 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
28416 Same as @code{disk-apm-bat} but on BAT mode.
28417
28418 @end deftypevr
28419
28420 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
28421 Hard disk spin down timeout. One value has to be specified for each
28422 declared hard disk.
28423
28424 Defaults to @samp{disabled}.
28425
28426 @end deftypevr
28427
28428 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
28429 Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
28430
28431 Defaults to @samp{disabled}.
28432
28433 @end deftypevr
28434
28435 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
28436 Select IO scheduler for disk devices. One value has to be specified for
28437 each declared hard disk. Example alternatives are cfq, deadline and
28438 noop.
28439
28440 Defaults to @samp{disabled}.
28441
28442 @end deftypevr
28443
28444 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
28445 SATA aggressive link power management (ALPM) level. Alternatives are
28446 min_power, medium_power, max_performance.
28447
28448 Defaults to @samp{"max_performance"}.
28449
28450 @end deftypevr
28451
28452 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
28453 Same as @code{sata-linkpwr-ac} but on BAT mode.
28454
28455 Defaults to @samp{"min_power"}.
28456
28457 @end deftypevr
28458
28459 @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
28460 Exclude specified SATA host devices for link power management.
28461
28462 Defaults to @samp{disabled}.
28463
28464 @end deftypevr
28465
28466 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
28467 Enable Runtime Power Management for AHCI controller and disks on AC
28468 mode.
28469
28470 Defaults to @samp{disabled}.
28471
28472 @end deftypevr
28473
28474 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
28475 Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
28476
28477 Defaults to @samp{disabled}.
28478
28479 @end deftypevr
28480
28481 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
28482 Seconds of inactivity before disk is suspended.
28483
28484 Defaults to @samp{15}.
28485
28486 @end deftypevr
28487
28488 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
28489 PCI Express Active State Power Management level. Alternatives are
28490 default, performance, powersave.
28491
28492 Defaults to @samp{"performance"}.
28493
28494 @end deftypevr
28495
28496 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
28497 Same as @code{pcie-aspm-ac} but on BAT mode.
28498
28499 Defaults to @samp{"powersave"}.
28500
28501 @end deftypevr
28502
28503 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
28504 Radeon graphics clock speed level. Alternatives are low, mid, high,
28505 auto, default.
28506
28507 Defaults to @samp{"high"}.
28508
28509 @end deftypevr
28510
28511 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
28512 Same as @code{radeon-power-ac} but on BAT mode.
28513
28514 Defaults to @samp{"low"}.
28515
28516 @end deftypevr
28517
28518 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
28519 Radeon dynamic power management method (DPM). Alternatives are battery,
28520 performance.
28521
28522 Defaults to @samp{"performance"}.
28523
28524 @end deftypevr
28525
28526 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
28527 Same as @code{radeon-dpm-state-ac} but on BAT mode.
28528
28529 Defaults to @samp{"battery"}.
28530
28531 @end deftypevr
28532
28533 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
28534 Radeon DPM performance level. Alternatives are auto, low, high.
28535
28536 Defaults to @samp{"auto"}.
28537
28538 @end deftypevr
28539
28540 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
28541 Same as @code{radeon-dpm-perf-ac} but on BAT mode.
28542
28543 Defaults to @samp{"auto"}.
28544
28545 @end deftypevr
28546
28547 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
28548 Wifi power saving mode.
28549
28550 Defaults to @samp{#f}.
28551
28552 @end deftypevr
28553
28554 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
28555 Same as @code{wifi-power-ac?} but on BAT mode.
28556
28557 Defaults to @samp{#t}.
28558
28559 @end deftypevr
28560
28561 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
28562 Disable wake on LAN.
28563
28564 Defaults to @samp{#t}.
28565
28566 @end deftypevr
28567
28568 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
28569 Timeout duration in seconds before activating audio power saving on
28570 Intel HDA and AC97 devices. A value of 0 disables power saving.
28571
28572 Defaults to @samp{0}.
28573
28574 @end deftypevr
28575
28576 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
28577 Same as @code{sound-powersave-ac} but on BAT mode.
28578
28579 Defaults to @samp{1}.
28580
28581 @end deftypevr
28582
28583 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
28584 Disable controller in powersaving mode on Intel HDA devices.
28585
28586 Defaults to @samp{#t}.
28587
28588 @end deftypevr
28589
28590 @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
28591 Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
28592 powered on again by releasing (and reinserting) the eject lever or by
28593 pressing the disc eject button on newer models.
28594
28595 Defaults to @samp{#f}.
28596
28597 @end deftypevr
28598
28599 @deftypevr {@code{tlp-configuration} parameter} string bay-device
28600 Name of the optical drive device to power off.
28601
28602 Defaults to @samp{"sr0"}.
28603
28604 @end deftypevr
28605
28606 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
28607 Runtime Power Management for PCI(e) bus devices. Alternatives are on
28608 and auto.
28609
28610 Defaults to @samp{"on"}.
28611
28612 @end deftypevr
28613
28614 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
28615 Same as @code{runtime-pm-ac} but on BAT mode.
28616
28617 Defaults to @samp{"auto"}.
28618
28619 @end deftypevr
28620
28621 @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
28622 Runtime Power Management for all PCI(e) bus devices, except blacklisted
28623 ones.
28624
28625 Defaults to @samp{#t}.
28626
28627 @end deftypevr
28628
28629 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
28630 Exclude specified PCI(e) device addresses from Runtime Power Management.
28631
28632 Defaults to @samp{disabled}.
28633
28634 @end deftypevr
28635
28636 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
28637 Exclude PCI(e) devices assigned to the specified drivers from Runtime
28638 Power Management.
28639
28640 @end deftypevr
28641
28642 @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
28643 Enable USB autosuspend feature.
28644
28645 Defaults to @samp{#t}.
28646
28647 @end deftypevr
28648
28649 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
28650 Exclude specified devices from USB autosuspend.
28651
28652 Defaults to @samp{disabled}.
28653
28654 @end deftypevr
28655
28656 @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
28657 Exclude WWAN devices from USB autosuspend.
28658
28659 Defaults to @samp{#t}.
28660
28661 @end deftypevr
28662
28663 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
28664 Include specified devices into USB autosuspend, even if they are already
28665 excluded by the driver or via @code{usb-blacklist-wwan?}.
28666
28667 Defaults to @samp{disabled}.
28668
28669 @end deftypevr
28670
28671 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
28672 Enable USB autosuspend before shutdown.
28673
28674 Defaults to @samp{disabled}.
28675
28676 @end deftypevr
28677
28678 @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
28679 Restore radio device state (bluetooth, wifi, wwan) from previous
28680 shutdown on system startup.
28681
28682 Defaults to @samp{#f}.
28683
28684 @end deftypevr
28685
28686 @cindex thermald
28687 @cindex CPU frequency scaling with thermald
28688 @subsubheading Thermald daemon
28689
28690 The @code{(gnu services pm)} module provides an interface to
28691 thermald, a CPU frequency scaling service which helps prevent overheating.
28692
28693 @defvr {Scheme Variable} thermald-service-type
28694 This is the service type for
28695 @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
28696 Thermal Daemon, which is responsible for controlling the thermal state
28697 of processors and preventing overheating.
28698 @end defvr
28699
28700 @deftp {Data Type} thermald-configuration
28701 Data type representing the configuration of @code{thermald-service-type}.
28702
28703 @table @asis
28704 @item @code{ignore-cpuid-check?} (default: @code{#f})
28705 Ignore cpuid check for supported CPU models.
28706
28707 @item @code{thermald} (default: @var{thermald})
28708 Package object of thermald.
28709
28710 @end table
28711 @end deftp
28712
28713 @node Audio Services
28714 @subsection Audio Services
28715
28716 The @code{(gnu services audio)} module provides a service to start MPD
28717 (the Music Player Daemon).
28718
28719 @cindex mpd
28720 @subsubheading Music Player Daemon
28721
28722 The Music Player Daemon (MPD) is a service that can play music while
28723 being controlled from the local machine or over the network by a variety
28724 of clients.
28725
28726 The following example shows how one might run @code{mpd} as user
28727 @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
28728
28729 @lisp
28730 (service mpd-service-type
28731 (mpd-configuration
28732 (user "bob")
28733 (port "6666")))
28734 @end lisp
28735
28736 @defvr {Scheme Variable} mpd-service-type
28737 The service type for @command{mpd}
28738 @end defvr
28739
28740 @deftp {Data Type} mpd-configuration
28741 Data type representing the configuration of @command{mpd}.
28742
28743 @table @asis
28744 @item @code{user} (default: @code{"mpd"})
28745 The user to run mpd as.
28746
28747 @item @code{music-dir} (default: @code{"~/Music"})
28748 The directory to scan for music files.
28749
28750 @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
28751 The directory to store playlists.
28752
28753 @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
28754 The location of the music database.
28755
28756 @item @code{state-file} (default: @code{"~/.mpd/state"})
28757 The location of the file that stores current MPD's state.
28758
28759 @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
28760 The location of the sticker database.
28761
28762 @item @code{port} (default: @code{"6600"})
28763 The port to run mpd on.
28764
28765 @item @code{address} (default: @code{"any"})
28766 The address that mpd will bind to. To use a Unix domain socket,
28767 an absolute path can be specified here.
28768
28769 @item @code{outputs} (default: @code{"(list (mpd-output))"})
28770 The audio outputs that MPD can use. By default this is a single output using pulseaudio.
28771
28772 @end table
28773 @end deftp
28774
28775 @deftp {Data Type} mpd-output
28776 Data type representing an @command{mpd} audio output.
28777
28778 @table @asis
28779 @item @code{name} (default: @code{"MPD"})
28780 The name of the audio output.
28781
28782 @item @code{type} (default: @code{"pulse"})
28783 The type of audio output.
28784
28785 @item @code{enabled?} (default: @code{#t})
28786 Specifies whether this audio output is enabled when MPD is started. By
28787 default, all audio outputs are enabled. This is just the default
28788 setting when there is no state file; with a state file, the previous
28789 state is restored.
28790
28791 @item @code{tags?} (default: @code{#t})
28792 If set to @code{#f}, then MPD will not send tags to this output. This
28793 is only useful for output plugins that can receive tags, for example the
28794 @code{httpd} output plugin.
28795
28796 @item @code{always-on?} (default: @code{#f})
28797 If set to @code{#t}, then MPD attempts to keep this audio output always
28798 open. This may be useful for streaming servers, when you don’t want to
28799 disconnect all listeners even when playback is accidentally stopped.
28800
28801 @item @code{mixer-type}
28802 This field accepts a symbol that specifies which mixer should be used
28803 for this audio output: the @code{hardware} mixer, the @code{software}
28804 mixer, the @code{null} mixer (allows setting the volume, but with no
28805 effect; this can be used as a trick to implement an external mixer
28806 External Mixer) or no mixer (@code{none}).
28807
28808 @item @code{extra-options} (default: @code{'()})
28809 An association list of option symbols to string values to be appended to
28810 the audio output configuration.
28811
28812 @end table
28813 @end deftp
28814
28815 The following example shows a configuration of @code{mpd} that provides
28816 an HTTP audio streaming output.
28817
28818 @lisp
28819 (service mpd-service-type
28820 (mpd-configuration
28821 (outputs
28822 (list (mpd-output
28823 (name "streaming")
28824 (type "httpd")
28825 (mixer-type 'null)
28826 (extra-options
28827 `((encoder . "vorbis")
28828 (port . "8080"))))))))
28829 @end lisp
28830
28831
28832 @node Virtualization Services
28833 @subsection Virtualization Services
28834
28835 The @code{(gnu services virtualization)} module provides services for
28836 the libvirt and virtlog daemons, as well as other virtualization-related
28837 services.
28838
28839 @subsubheading Libvirt daemon
28840
28841 @code{libvirtd} is the server side daemon component of the libvirt
28842 virtualization management system. This daemon runs on host servers
28843 and performs required management tasks for virtualized guests.
28844
28845 @deffn {Scheme Variable} libvirt-service-type
28846 This is the type of the @uref{https://libvirt.org, libvirt daemon}.
28847 Its value must be a @code{libvirt-configuration}.
28848
28849 @lisp
28850 (service libvirt-service-type
28851 (libvirt-configuration
28852 (unix-sock-group "libvirt")
28853 (tls-port "16555")))
28854 @end lisp
28855 @end deffn
28856
28857 @c Auto-generated with (generate-libvirt-documentation)
28858 Available @code{libvirt-configuration} fields are:
28859
28860 @deftypevr {@code{libvirt-configuration} parameter} package libvirt
28861 Libvirt package.
28862
28863 @end deftypevr
28864
28865 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
28866 Flag listening for secure TLS connections on the public TCP/IP port.
28867 You must set @code{listen} for this to have any effect.
28868
28869 It is necessary to setup a CA and issue server certificates before using
28870 this capability.
28871
28872 Defaults to @samp{#t}.
28873
28874 @end deftypevr
28875
28876 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
28877 Listen for unencrypted TCP connections on the public TCP/IP port. You must
28878 set @code{listen} for this to have any effect.
28879
28880 Using the TCP socket requires SASL authentication by default. Only SASL
28881 mechanisms which support data encryption are allowed. This is
28882 DIGEST_MD5 and GSSAPI (Kerberos5).
28883
28884 Defaults to @samp{#f}.
28885
28886 @end deftypevr
28887
28888 @deftypevr {@code{libvirt-configuration} parameter} string tls-port
28889 Port for accepting secure TLS connections. This can be a port number,
28890 or service name.
28891
28892 Defaults to @samp{"16514"}.
28893
28894 @end deftypevr
28895
28896 @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
28897 Port for accepting insecure TCP connections. This can be a port number,
28898 or service name.
28899
28900 Defaults to @samp{"16509"}.
28901
28902 @end deftypevr
28903
28904 @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
28905 IP address or hostname used for client connections.
28906
28907 Defaults to @samp{"0.0.0.0"}.
28908
28909 @end deftypevr
28910
28911 @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
28912 Flag toggling mDNS advertisement of the libvirt service.
28913
28914 Alternatively can disable for all services on a host by stopping the
28915 Avahi daemon.
28916
28917 Defaults to @samp{#f}.
28918
28919 @end deftypevr
28920
28921 @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
28922 Default mDNS advertisement name. This must be unique on the immediate
28923 broadcast network.
28924
28925 Defaults to @samp{"Virtualization Host <hostname>"}.
28926
28927 @end deftypevr
28928
28929 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
28930 UNIX domain socket group ownership. This can be used to allow a
28931 'trusted' set of users access to management capabilities without
28932 becoming root.
28933
28934 Defaults to @samp{"root"}.
28935
28936 @end deftypevr
28937
28938 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
28939 UNIX socket permissions for the R/O socket. This is used for monitoring
28940 VM status only.
28941
28942 Defaults to @samp{"0777"}.
28943
28944 @end deftypevr
28945
28946 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
28947 UNIX socket permissions for the R/W socket. Default allows only root.
28948 If PolicyKit is enabled on the socket, the default will change to allow
28949 everyone (eg, 0777)
28950
28951 Defaults to @samp{"0770"}.
28952
28953 @end deftypevr
28954
28955 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
28956 UNIX socket permissions for the admin socket. Default allows only owner
28957 (root), do not change it unless you are sure to whom you are exposing
28958 the access to.
28959
28960 Defaults to @samp{"0777"}.
28961
28962 @end deftypevr
28963
28964 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
28965 The directory in which sockets will be found/created.
28966
28967 Defaults to @samp{"/var/run/libvirt"}.
28968
28969 @end deftypevr
28970
28971 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
28972 Authentication scheme for UNIX read-only sockets. By default socket
28973 permissions allow anyone to connect
28974
28975 Defaults to @samp{"polkit"}.
28976
28977 @end deftypevr
28978
28979 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
28980 Authentication scheme for UNIX read-write sockets. By default socket
28981 permissions only allow root. If PolicyKit support was compiled into
28982 libvirt, the default will be to use 'polkit' auth.
28983
28984 Defaults to @samp{"polkit"}.
28985
28986 @end deftypevr
28987
28988 @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
28989 Authentication scheme for TCP sockets. If you don't enable SASL, then
28990 all TCP traffic is cleartext. Don't do this outside of a dev/test
28991 scenario.
28992
28993 Defaults to @samp{"sasl"}.
28994
28995 @end deftypevr
28996
28997 @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
28998 Authentication scheme for TLS sockets. TLS sockets already have
28999 encryption provided by the TLS layer, and limited authentication is done
29000 by certificates.
29001
29002 It is possible to make use of any SASL authentication mechanism as well,
29003 by using 'sasl' for this option
29004
29005 Defaults to @samp{"none"}.
29006
29007 @end deftypevr
29008
29009 @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
29010 API access control scheme.
29011
29012 By default an authenticated user is allowed access to all APIs. Access
29013 drivers can place restrictions on this.
29014
29015 Defaults to @samp{()}.
29016
29017 @end deftypevr
29018
29019 @deftypevr {@code{libvirt-configuration} parameter} string key-file
29020 Server key file path. If set to an empty string, then no private key is
29021 loaded.
29022
29023 Defaults to @samp{""}.
29024
29025 @end deftypevr
29026
29027 @deftypevr {@code{libvirt-configuration} parameter} string cert-file
29028 Server key file path. If set to an empty string, then no certificate is
29029 loaded.
29030
29031 Defaults to @samp{""}.
29032
29033 @end deftypevr
29034
29035 @deftypevr {@code{libvirt-configuration} parameter} string ca-file
29036 Server key file path. If set to an empty string, then no CA certificate
29037 is loaded.
29038
29039 Defaults to @samp{""}.
29040
29041 @end deftypevr
29042
29043 @deftypevr {@code{libvirt-configuration} parameter} string crl-file
29044 Certificate revocation list path. If set to an empty string, then no
29045 CRL is loaded.
29046
29047 Defaults to @samp{""}.
29048
29049 @end deftypevr
29050
29051 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
29052 Disable verification of our own server certificates.
29053
29054 When libvirtd starts it performs some sanity checks against its own
29055 certificates.
29056
29057 Defaults to @samp{#f}.
29058
29059 @end deftypevr
29060
29061 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
29062 Disable verification of client certificates.
29063
29064 Client certificate verification is the primary authentication mechanism.
29065 Any client which does not present a certificate signed by the CA will be
29066 rejected.
29067
29068 Defaults to @samp{#f}.
29069
29070 @end deftypevr
29071
29072 @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
29073 Whitelist of allowed x509 Distinguished Name.
29074
29075 Defaults to @samp{()}.
29076
29077 @end deftypevr
29078
29079 @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
29080 Whitelist of allowed SASL usernames. The format for username depends on
29081 the SASL authentication mechanism.
29082
29083 Defaults to @samp{()}.
29084
29085 @end deftypevr
29086
29087 @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
29088 Override the compile time default TLS priority string. The default is
29089 usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
29090 is desired for libvirt to deviate from the global default settings.
29091
29092 Defaults to @samp{"NORMAL"}.
29093
29094 @end deftypevr
29095
29096 @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
29097 Maximum number of concurrent client connections to allow over all
29098 sockets combined.
29099
29100 Defaults to @samp{5000}.
29101
29102 @end deftypevr
29103
29104 @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
29105 Maximum length of queue of connections waiting to be accepted by the
29106 daemon. Note, that some protocols supporting retransmission may obey
29107 this so that a later reattempt at connection succeeds.
29108
29109 Defaults to @samp{1000}.
29110
29111 @end deftypevr
29112
29113 @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
29114 Maximum length of queue of accepted but not yet authenticated clients.
29115 Set this to zero to turn this feature off
29116
29117 Defaults to @samp{20}.
29118
29119 @end deftypevr
29120
29121 @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
29122 Number of workers to start up initially.
29123
29124 Defaults to @samp{5}.
29125
29126 @end deftypevr
29127
29128 @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
29129 Maximum number of worker threads.
29130
29131 If the number of active clients exceeds @code{min-workers}, then more
29132 threads are spawned, up to max_workers limit. Typically you'd want
29133 max_workers to equal maximum number of clients allowed.
29134
29135 Defaults to @samp{20}.
29136
29137 @end deftypevr
29138
29139 @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
29140 Number of priority workers. If all workers from above pool are stuck,
29141 some calls marked as high priority (notably domainDestroy) can be
29142 executed in this pool.
29143
29144 Defaults to @samp{5}.
29145
29146 @end deftypevr
29147
29148 @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
29149 Total global limit on concurrent RPC calls.
29150
29151 Defaults to @samp{20}.
29152
29153 @end deftypevr
29154
29155 @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
29156 Limit on concurrent requests from a single client connection. To avoid
29157 one client monopolizing the server this should be a small fraction of
29158 the global max_requests and max_workers parameter.
29159
29160 Defaults to @samp{5}.
29161
29162 @end deftypevr
29163
29164 @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
29165 Same as @code{min-workers} but for the admin interface.
29166
29167 Defaults to @samp{1}.
29168
29169 @end deftypevr
29170
29171 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
29172 Same as @code{max-workers} but for the admin interface.
29173
29174 Defaults to @samp{5}.
29175
29176 @end deftypevr
29177
29178 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
29179 Same as @code{max-clients} but for the admin interface.
29180
29181 Defaults to @samp{5}.
29182
29183 @end deftypevr
29184
29185 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
29186 Same as @code{max-queued-clients} but for the admin interface.
29187
29188 Defaults to @samp{5}.
29189
29190 @end deftypevr
29191
29192 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
29193 Same as @code{max-client-requests} but for the admin interface.
29194
29195 Defaults to @samp{5}.
29196
29197 @end deftypevr
29198
29199 @deftypevr {@code{libvirt-configuration} parameter} integer log-level
29200 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
29201
29202 Defaults to @samp{3}.
29203
29204 @end deftypevr
29205
29206 @deftypevr {@code{libvirt-configuration} parameter} string log-filters
29207 Logging filters.
29208
29209 A filter allows to select a different logging level for a given category
29210 of logs. The format for a filter is one of:
29211
29212 @itemize @bullet
29213 @item
29214 x:name
29215
29216 @item
29217 x:+name
29218
29219 @end itemize
29220
29221 where @code{name} is a string which is matched against the category
29222 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
29223 file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
29224 name in the filter can be a substring of the full category name, in
29225 order to match multiple similar categories), the optional @samp{"+"}
29226 prefix tells libvirt to log stack trace for each message matching name,
29227 and @code{x} is the minimal level where matching messages should be
29228 logged:
29229
29230 @itemize @bullet
29231 @item
29232 1: DEBUG
29233
29234 @item
29235 2: INFO
29236
29237 @item
29238 3: WARNING
29239
29240 @item
29241 4: ERROR
29242
29243 @end itemize
29244
29245 Multiple filters can be defined in a single filters statement, they just
29246 need to be separated by spaces.
29247
29248 Defaults to @samp{"3:remote 4:event"}.
29249
29250 @end deftypevr
29251
29252 @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
29253 Logging outputs.
29254
29255 An output is one of the places to save logging information. The format
29256 for an output can be:
29257
29258 @table @code
29259 @item x:stderr
29260 output goes to stderr
29261
29262 @item x:syslog:name
29263 use syslog for the output and use the given name as the ident
29264
29265 @item x:file:file_path
29266 output to a file, with the given filepath
29267
29268 @item x:journald
29269 output to journald logging system
29270
29271 @end table
29272
29273 In all case the x prefix is the minimal level, acting as a filter
29274
29275 @itemize @bullet
29276 @item
29277 1: DEBUG
29278
29279 @item
29280 2: INFO
29281
29282 @item
29283 3: WARNING
29284
29285 @item
29286 4: ERROR
29287
29288 @end itemize
29289
29290 Multiple outputs can be defined, they just need to be separated by
29291 spaces.
29292
29293 Defaults to @samp{"3:stderr"}.
29294
29295 @end deftypevr
29296
29297 @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
29298 Allows usage of the auditing subsystem to be altered
29299
29300 @itemize @bullet
29301 @item
29302 0: disable all auditing
29303
29304 @item
29305 1: enable auditing, only if enabled on host
29306
29307 @item
29308 2: enable auditing, and exit if disabled on host.
29309
29310 @end itemize
29311
29312 Defaults to @samp{1}.
29313
29314 @end deftypevr
29315
29316 @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
29317 Send audit messages via libvirt logging infrastructure.
29318
29319 Defaults to @samp{#f}.
29320
29321 @end deftypevr
29322
29323 @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
29324 Host UUID@. UUID must not have all digits be the same.
29325
29326 Defaults to @samp{""}.
29327
29328 @end deftypevr
29329
29330 @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
29331 Source to read host UUID.
29332
29333 @itemize @bullet
29334 @item
29335 @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
29336
29337 @item
29338 @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
29339
29340 @end itemize
29341
29342 If @code{dmidecode} does not provide a valid UUID a temporary UUID will
29343 be generated.
29344
29345 Defaults to @samp{"smbios"}.
29346
29347 @end deftypevr
29348
29349 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
29350 A keepalive message is sent to a client after @code{keepalive_interval}
29351 seconds of inactivity to check if the client is still responding. If
29352 set to -1, libvirtd will never send keepalive requests; however clients
29353 can still send them and the daemon will send responses.
29354
29355 Defaults to @samp{5}.
29356
29357 @end deftypevr
29358
29359 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
29360 Maximum number of keepalive messages that are allowed to be sent to the
29361 client without getting any response before the connection is considered
29362 broken.
29363
29364 In other words, the connection is automatically closed approximately
29365 after @code{keepalive_interval * (keepalive_count + 1)} seconds since
29366 the last message received from the client. When @code{keepalive-count}
29367 is set to 0, connections will be automatically closed after
29368 @code{keepalive-interval} seconds of inactivity without sending any
29369 keepalive messages.
29370
29371 Defaults to @samp{5}.
29372
29373 @end deftypevr
29374
29375 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
29376 Same as above but for admin interface.
29377
29378 Defaults to @samp{5}.
29379
29380 @end deftypevr
29381
29382 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
29383 Same as above but for admin interface.
29384
29385 Defaults to @samp{5}.
29386
29387 @end deftypevr
29388
29389 @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
29390 Timeout for Open vSwitch calls.
29391
29392 The @code{ovs-vsctl} utility is used for the configuration and its
29393 timeout option is set by default to 5 seconds to avoid potential
29394 infinite waits blocking libvirt.
29395
29396 Defaults to @samp{5}.
29397
29398 @end deftypevr
29399
29400 @c %end of autogenerated docs
29401
29402 @subsubheading Virtlog daemon
29403 The virtlogd service is a server side daemon component of libvirt that is
29404 used to manage logs from virtual machine consoles.
29405
29406 This daemon is not used directly by libvirt client applications, rather it
29407 is called on their behalf by @code{libvirtd}. By maintaining the logs in a
29408 standalone daemon, the main @code{libvirtd} daemon can be restarted without
29409 risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
29410 itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
29411
29412 @deffn {Scheme Variable} virtlog-service-type
29413 This is the type of the virtlog daemon.
29414 Its value must be a @code{virtlog-configuration}.
29415
29416 @lisp
29417 (service virtlog-service-type
29418 (virtlog-configuration
29419 (max-clients 1000)))
29420 @end lisp
29421 @end deffn
29422
29423 @deftypevr {@code{virtlog-configuration} parameter} integer log-level
29424 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
29425
29426 Defaults to @samp{3}.
29427
29428 @end deftypevr
29429
29430 @deftypevr {@code{virtlog-configuration} parameter} string log-filters
29431 Logging filters.
29432
29433 A filter allows to select a different logging level for a given category
29434 of logs The format for a filter is one of:
29435
29436 @itemize @bullet
29437 @item
29438 x:name
29439
29440 @item
29441 x:+name
29442
29443 @end itemize
29444
29445 where @code{name} is a string which is matched against the category
29446 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
29447 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
29448 be a substring of the full category name, in order to match multiple
29449 similar categories), the optional "+" prefix tells libvirt to log stack
29450 trace for each message matching name, and @code{x} is the minimal level
29451 where matching messages should be logged:
29452
29453 @itemize @bullet
29454 @item
29455 1: DEBUG
29456
29457 @item
29458 2: INFO
29459
29460 @item
29461 3: WARNING
29462
29463 @item
29464 4: ERROR
29465
29466 @end itemize
29467
29468 Multiple filters can be defined in a single filters statement, they just
29469 need to be separated by spaces.
29470
29471 Defaults to @samp{"3:remote 4:event"}.
29472
29473 @end deftypevr
29474
29475 @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
29476 Logging outputs.
29477
29478 An output is one of the places to save logging information The format
29479 for an output can be:
29480
29481 @table @code
29482 @item x:stderr
29483 output goes to stderr
29484
29485 @item x:syslog:name
29486 use syslog for the output and use the given name as the ident
29487
29488 @item x:file:file_path
29489 output to a file, with the given filepath
29490
29491 @item x:journald
29492 output to journald logging system
29493
29494 @end table
29495
29496 In all case the x prefix is the minimal level, acting as a filter
29497
29498 @itemize @bullet
29499 @item
29500 1: DEBUG
29501
29502 @item
29503 2: INFO
29504
29505 @item
29506 3: WARNING
29507
29508 @item
29509 4: ERROR
29510
29511 @end itemize
29512
29513 Multiple outputs can be defined, they just need to be separated by
29514 spaces.
29515
29516 Defaults to @samp{"3:stderr"}.
29517
29518 @end deftypevr
29519
29520 @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
29521 Maximum number of concurrent client connections to allow over all
29522 sockets combined.
29523
29524 Defaults to @samp{1024}.
29525
29526 @end deftypevr
29527
29528 @deftypevr {@code{virtlog-configuration} parameter} integer max-size
29529 Maximum file size before rolling over.
29530
29531 Defaults to @samp{2MB}
29532
29533 @end deftypevr
29534
29535 @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
29536 Maximum number of backup files to keep.
29537
29538 Defaults to @samp{3}
29539
29540 @end deftypevr
29541
29542 @anchor{transparent-emulation-qemu}
29543 @subsubheading Transparent Emulation with QEMU
29544
29545 @cindex emulation
29546 @cindex @code{binfmt_misc}
29547 @code{qemu-binfmt-service-type} provides support for transparent
29548 emulation of program binaries built for different architectures---e.g.,
29549 it allows you to transparently execute an ARMv7 program on an x86_64
29550 machine. It achieves this by combining the @uref{https://www.qemu.org,
29551 QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
29552 This feature only allows you to emulate GNU/Linux on a different
29553 architecture, but see below for GNU/Hurd support.
29554
29555 @defvr {Scheme Variable} qemu-binfmt-service-type
29556 This is the type of the QEMU/binfmt service for transparent emulation.
29557 Its value must be a @code{qemu-binfmt-configuration} object, which
29558 specifies the QEMU package to use as well as the architecture we want to
29559 emulated:
29560
29561 @lisp
29562 (service qemu-binfmt-service-type
29563 (qemu-binfmt-configuration
29564 (platforms (lookup-qemu-platforms "arm" "aarch64"))))
29565 @end lisp
29566
29567 In this example, we enable transparent emulation for the ARM and aarch64
29568 platforms. Running @code{herd stop qemu-binfmt} turns it off, and
29569 running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
29570 herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
29571 @end defvr
29572
29573 @deftp {Data Type} qemu-binfmt-configuration
29574 This is the configuration for the @code{qemu-binfmt} service.
29575
29576 @table @asis
29577 @item @code{platforms} (default: @code{'()})
29578 The list of emulated QEMU platforms. Each item must be a @dfn{platform
29579 object} as returned by @code{lookup-qemu-platforms} (see below).
29580
29581 For example, let's suppose you're on an x86_64 machine and you have this
29582 service:
29583
29584 @lisp
29585 (service qemu-binfmt-service-type
29586 (qemu-binfmt-configuration
29587 (platforms (lookup-qemu-platforms "arm"))))
29588 @end lisp
29589
29590 You can run:
29591
29592 @example
29593 guix build -s armhf-linux inkscape
29594 @end example
29595
29596 @noindent
29597 and it will build Inkscape for ARMv7 @emph{as if it were a native
29598 build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
29599 if you'd like to test a package build for an architecture you don't have
29600 access to!
29601
29602 @item @code{qemu} (default: @code{qemu})
29603 The QEMU package to use.
29604 @end table
29605 @end deftp
29606
29607 @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
29608 Return the list of QEMU platform objects corresponding to
29609 @var{platforms}@dots{}. @var{platforms} must be a list of strings
29610 corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
29611 @code{"mips64el"}, and so on.
29612 @end deffn
29613
29614 @deffn {Scheme Procedure} qemu-platform? @var{obj}
29615 Return true if @var{obj} is a platform object.
29616 @end deffn
29617
29618 @deffn {Scheme Procedure} qemu-platform-name @var{platform}
29619 Return the name of @var{platform}---a string such as @code{"arm"}.
29620 @end deffn
29621
29622
29623 @subsubheading The Hurd in a Virtual Machine
29624
29625 @cindex @code{hurd}
29626 @cindex the Hurd
29627 @cindex childhurd
29628
29629 Service @code{hurd-vm} provides support for running GNU/Hurd in a
29630 virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
29631 to be used on GNU/Linux and the given GNU/Hurd operating system
29632 configuration is cross-compiled. The virtual machine is a Shepherd
29633 service that can be referred to by the names @code{hurd-vm} and
29634 @code{childhurd} and be controlled with commands such as:
29635
29636 @example
29637 herd start hurd-vm
29638 herd stop childhurd
29639 @end example
29640
29641 When the service is running, you can view its console by connecting to
29642 it with a VNC client, for example with:
29643
29644 @example
29645 guix environment --ad-hoc tigervnc-client -- \
29646 vncviewer localhost:5900
29647 @end example
29648
29649 The default configuration (see @code{hurd-vm-configuration} below)
29650 spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
29651 (the virtual machine emulator) redirects to port 10222 on the host.
29652 Thus, you can connect over SSH to the childhurd with:
29653
29654 @example
29655 ssh root@@localhost -p 10022
29656 @end example
29657
29658 The childhurd is volatile and stateless: it starts with a fresh root
29659 file system every time you restart it. By default though, all the files
29660 under @file{/etc/childhurd} on the host are copied as is to the root
29661 file system of the childhurd when it boots. This allows you to
29662 initialize ``secrets'' inside the VM: SSH host keys, authorized
29663 substitute keys, and so on---see the explanation of @code{secret-root}
29664 below.
29665
29666 @defvr {Scheme Variable} hurd-vm-service-type
29667 This is the type of the Hurd in a Virtual Machine service. Its value
29668 must be a @code{hurd-vm-configuration} object, which specifies the
29669 operating system (@pxref{operating-system Reference}) and the disk size
29670 for the Hurd Virtual Machine, the QEMU package to use as well as the
29671 options for running it.
29672
29673 For example:
29674
29675 @lisp
29676 (service hurd-vm-service-type
29677 (hurd-vm-configuration
29678 (disk-size (* 5000 (expt 2 20))) ;5G
29679 (memory-size 1024))) ;1024MiB
29680 @end lisp
29681
29682 would create a disk image big enough to build GNU@tie{}Hello, with some
29683 extra memory.
29684 @end defvr
29685
29686 @deftp {Data Type} hurd-vm-configuration
29687 The data type representing the configuration for
29688 @code{hurd-vm-service-type}.
29689
29690 @table @asis
29691 @item @code{os} (default: @var{%hurd-vm-operating-system})
29692 The operating system to instantiate. This default is bare-bones with a
29693 permissive OpenSSH secure shell daemon listening on port 2222
29694 (@pxref{Networking Services, @code{openssh-service-type}}).
29695
29696 @item @code{qemu} (default: @code{qemu-minimal})
29697 The QEMU package to use.
29698
29699 @item @code{image} (default: @var{hurd-vm-disk-image})
29700 The procedure used to build the disk-image built from this
29701 configuration.
29702
29703 @item @code{disk-size} (default: @code{'guess})
29704 The size of the disk image.
29705
29706 @item @code{memory-size} (default: @code{512})
29707 The memory size of the Virtual Machine in mebibytes.
29708
29709 @item @code{options} (default: @code{'("--snapshot")})
29710 The extra options for running QEMU.
29711
29712 @item @code{id} (default: @code{#f})
29713 If set, a non-zero positive integer used to parameterize Childhurd
29714 instances. It is appended to the service's name,
29715 e.g. @code{childhurd1}.
29716
29717 @item @code{net-options} (default: @var{hurd-vm-net-options})
29718 The procedure used to produce the list of QEMU networking options.
29719
29720 By default, it produces
29721
29722 @lisp
29723 '("--device" "rtl8139,netdev=net0"
29724 "--netdev" (string-append
29725 "user,id=net0,"
29726 "hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004,"
29727 "hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222,"
29728 "hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900"))
29729 @end lisp
29730
29731 with forwarded ports:
29732
29733 @example
29734 @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
29735 @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
29736 @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
29737 @end example
29738
29739 @item @code{secret-root} (default: @file{/etc/childhurd})
29740 The root directory with out-of-band secrets to be installed into the
29741 childhurd once it runs. Childhurds are volatile which means that on
29742 every startup, secrets such as the SSH host keys and Guix signing key
29743 are recreated.
29744
29745 If the @file{/etc/childhurd} directory does not exist, the
29746 @code{secret-service} running in the Childhurd will be sent an empty
29747 list of secrets.
29748
29749 By default, the service automatically populates @file{/etc/childhurd}
29750 with the following non-volatile secrets, unless they already exist:
29751
29752 @example
29753 /etc/childhurd/etc/guix/acl
29754 /etc/childhurd/etc/guix/signing-key.pub
29755 /etc/childhurd/etc/guix/signing-key.sec
29756 /etc/childhurd/etc/ssh/ssh_host_ed25519_key
29757 /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
29758 /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
29759 /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
29760 @end example
29761
29762 These files are automatically sent to the guest Hurd VM when it boots,
29763 including permissions.
29764
29765 @cindex childhurd, offloading
29766 @cindex Hurd, offloading
29767 Having these files in place means that only a couple of things are
29768 missing to allow the host to offload @code{i586-gnu} builds to the
29769 childhurd:
29770
29771 @enumerate
29772 @item
29773 Authorizing the childhurd's key on the host so that the host accepts
29774 build results coming from the childhurd, which can be done like so:
29775
29776 @example
29777 guix archive --authorize < \
29778 /etc/childhurd/etc/guix/signing-key.pub
29779 @end example
29780
29781 @item
29782 Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
29783 Offload Setup}).
29784 @end enumerate
29785
29786 We're working towards making that happen automatically---get in touch
29787 with us at @email{guix-devel@@gnu.org} to discuss it!
29788 @end table
29789 @end deftp
29790
29791 Note that by default the VM image is volatile, i.e., once stopped the
29792 contents are lost. If you want a stateful image instead, override the
29793 configuration's @code{image} and @code{options} without
29794 the @code{--snapshot} flag using something along these lines:
29795
29796 @lisp
29797 (service hurd-vm-service-type
29798 (hurd-vm-configuration
29799 (image (const "/out/of/store/writable/hurd.img"))
29800 (options '())))
29801 @end lisp
29802
29803 @subsubheading Ganeti
29804
29805 @cindex ganeti
29806
29807 @quotation Note
29808 This service is considered experimental. Configuration options may be changed
29809 in a backwards-incompatible manner, and not all features have been thorougly
29810 tested. Users of this service are encouraged to share their experience at
29811 @email{guix-devel@@gnu.org}.
29812 @end quotation
29813
29814 Ganeti is a virtual machine management system. It is designed to keep virtual
29815 machines running on a cluster of servers even in the event of hardware failures,
29816 and to make maintenance and recovery tasks easy. It consists of multiple
29817 services which are described later in this section. In addition to the Ganeti
29818 service, you will need the OpenSSH service (@pxref{Networking Services,
29819 @code{openssh-service-type}}), and update the @file{/etc/hosts} file
29820 (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
29821 and address (or use a DNS server).
29822
29823 All nodes participating in a Ganeti cluster should have the same Ganeti and
29824 @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
29825 cluster node that supports multiple storage backends, and installs the
29826 @code{debootstrap} and @code{guix} @dfn{OS providers}:
29827
29828 @lisp
29829 (use-package-modules virtualization)
29830 (use-service-modules base ganeti networking ssh)
29831 (operating-system
29832 ;; @dots{}
29833 (host-name "node1")
29834 (hosts-file (plain-file "hosts" (format #f "
29835 127.0.0.1 localhost
29836 ::1 localhost
29837
29838 192.168.1.200 ganeti.example.com
29839 192.168.1.201 node1.example.com node1
29840 192.168.1.202 node2.example.com node2
29841 ")))
29842
29843 ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
29844 ;; in order to use the "plain", "drbd" and "rbd" storage backends.
29845 (packages (append (map specification->package
29846 '("qemu" "lvm2" "drbd-utils" "ceph"
29847 ;; Add the debootstrap and guix OS providers.
29848 "ganeti-instance-guix" "ganeti-instance-debootstrap"))
29849 %base-packages))
29850 (services
29851 (append (list (static-networking-service "eth0" "192.168.1.201"
29852 #:netmask "255.255.255.0"
29853 #:gateway "192.168.1.254"
29854 #:name-servers '("192.168.1.252"
29855 "192.168.1.253"))
29856
29857 ;; Ganeti uses SSH to communicate between nodes.
29858 (service openssh-service-type
29859 (openssh-configuration
29860 (permit-root-login 'prohibit-password)))
29861
29862 (service ganeti-service-type
29863 (ganeti-configuration
29864 ;; This list specifies allowed file system paths
29865 ;; for storing virtual machine images.
29866 (file-storage-paths '("/srv/ganeti/file-storage"))
29867 ;; This variable configures a single "variant" for
29868 ;; both Debootstrap and Guix that works with KVM.
29869 (os %default-ganeti-os))))
29870 %base-services)))
29871 @end lisp
29872
29873 Users are advised to read the
29874 @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
29875 administrators guide} to learn about the various cluster options and
29876 day-to-day operations. There is also a
29877 @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
29878 describing how to configure and initialize a small cluster.
29879
29880 @defvr {Scheme Variable} ganeti-service-type
29881 This is a service type that includes all the various services that Ganeti
29882 nodes should run.
29883
29884 Its value is a @code{ganeti-configuration} object that defines the package
29885 to use for CLI operations, as well as configuration for the various daemons.
29886 Allowed file storage paths and available guest operating systems are also
29887 configured through this data type.
29888 @end defvr
29889
29890 @deftp {Data Type} ganeti-configuration
29891 The @code{ganeti} service takes the following configuration options:
29892
29893 @table @asis
29894 @item @code{ganeti} (default: @code{ganeti})
29895 The @code{ganeti} package to use. It will be installed to the system profile
29896 and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
29897 that the value specified here does not affect the other services as each refer
29898 to a specific @code{ganeti} package (see below).
29899
29900 @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
29901 @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
29902 @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
29903 @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
29904 @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
29905 @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
29906 @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
29907 @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
29908 @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
29909 @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
29910
29911 These options control the various daemons and cron jobs that are distributed
29912 with Ganeti. The possible values for these are described in detail below.
29913 To override a setting, you must use the configuration type for that service:
29914
29915 @lisp
29916 (service ganeti-service-type
29917 (ganeti-configuration
29918 (rapi-configuration
29919 (ganeti-rapi-configuration
29920 (interface "eth1"))))
29921 (watcher-configuration
29922 (ganeti-watcher-configuration
29923 (rapi-ip "10.0.0.1"))))
29924 @end lisp
29925
29926 @item @code{file-storage-paths} (default: @code{'()})
29927 List of allowed directories for file storage backend.
29928
29929 @item @code{os} (default: @code{%default-ganeti-os})
29930 List of @code{<ganeti-os>} records.
29931 @end table
29932
29933 In essence @code{ganeti-service-type} is shorthand for declaring each service
29934 individually:
29935
29936 @lisp
29937 (service ganeti-noded-service-type)
29938 (service ganeti-confd-service-type)
29939 (service ganeti-wconfd-service-type)
29940 (service ganeti-luxid-service-type)
29941 (service ganeti-kvmd-service-type)
29942 (service ganeti-mond-service-type)
29943 (service ganeti-metad-service-type)
29944 (service ganeti-watcher-service-type)
29945 (service ganeti-cleaner-service-type)
29946 @end lisp
29947
29948 Plus a service extension for @code{etc-service-type} that configures the file
29949 storage backend and OS variants.
29950
29951 @end deftp
29952
29953 @deftp {Data Type} ganeti-os
29954 This data type is suitable for passing to the @code{os} parameter of
29955 @code{ganeti-configuration}. It takes the following parameters:
29956
29957 @table @asis
29958 @item @code{name}
29959 The name for this OS provider. It is only used to specify where the
29960 configuration ends up. Setting it to ``debootstrap'' will create
29961 @file{/etc/ganeti/instance-debootstrap}.
29962
29963 @item @code{extension}
29964 The file extension for variants of this OS type. For example
29965 @file{.conf} or @file{.scm}.
29966
29967 @item @code{variants} (default: @code{'()})
29968 List of @code{ganeti-os-variant} objects for this OS.
29969
29970 @end table
29971 @end deftp
29972
29973 @deftp {Data Type} ganeti-os-variant
29974 This is the data type for a Ganeti OS variant. It takes the following
29975 parameters:
29976
29977 @table @asis
29978 @item @code{name}
29979 The name of this variant.
29980
29981 @item @code{configuration}
29982 A configuration file for this variant.
29983 @end table
29984 @end deftp
29985
29986 @defvr {Scheme Variable} %default-debootstrap-hooks
29987 This variable contains hooks to configure networking and the GRUB bootloader.
29988 @end defvr
29989
29990 @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
29991 This variable contains a list of packages suitable for a fully-virtualized guest.
29992 @end defvr
29993
29994 @deftp {Data Type} debootstrap-configuration
29995
29996 This data type creates configuration files suitable for the debootstrap OS provider.
29997
29998 @table @asis
29999 @item @code{hooks} (default: @code{%default-debootstrap-hooks})
30000 When not @code{#f}, this must be a G-expression that specifies a directory with
30001 scripts that will run when the OS is installed. It can also be a list of
30002 @code{(name . file-like)} pairs. For example:
30003
30004 @lisp
30005 `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
30006 @end lisp
30007
30008 That will create a directory with one executable named @code{99-hello-world}
30009 and run it every time this variant is installed. If set to @code{#f}, hooks
30010 in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
30011 @item @code{proxy} (default: @code{#f})
30012 Optional HTTP proxy to use.
30013 @item @code{mirror} (default: @code{#f})
30014 The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
30015 The default varies depending on the distribution.
30016 @item @code{arch} (default: @code{#f})
30017 The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
30018 on an AArch64 host. Default is to use the current system architecture.
30019 @item @code{suite} (default: @code{"stable"})
30020 When set, this must be a Debian distribution ``suite'' such as @code{buster}
30021 or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
30022 @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
30023 List of extra packages that will get installed by dpkg in addition
30024 to the minimal system.
30025 @item @code{components} (default: @code{#f})
30026 When set, must be a list of Debian repository ``components''. For example
30027 @code{'("main" "contrib")}.
30028 @item @code{generate-cache?} (default: @code{#t})
30029 Whether to automatically cache the generated debootstrap archive.
30030 @item @code{clean-cache} (default: @code{14})
30031 Discard the cache after this amount of days. Use @code{#f} to never
30032 clear the cache.
30033 @item @code{partition-style} (default: @code{'msdos})
30034 The type of partition to create. When set, it must be one of
30035 @code{'msdos}, @code{'none} or a string.
30036 @item @code{partition-alignment} (default: @code{2048})
30037 Alignment of the partition in sectors.
30038 @end table
30039 @end deftp
30040
30041 @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
30042 This is a helper procedure that creates a @code{ganeti-os-variant} record. It
30043 takes two parameters: a name and a @code{debootstrap-configuration} object.
30044 @end deffn
30045
30046 @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
30047 This is a helper procedure that creates a @code{ganeti-os} record. It takes
30048 a list of variants created with @code{debootstrap-variant}.
30049 @end deffn
30050
30051 @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
30052 This is a helper procedure that creates a @code{ganeti-os-variant} record for
30053 use with the Guix OS provider. It takes a name and a G-expression that returns
30054 a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
30055 Guix System configuration.
30056 @end deffn
30057
30058 @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
30059 This is a helper procedure that creates a @code{ganeti-os} record. It
30060 takes a list of variants produced by @code{guix-variant}.
30061 @end deffn
30062
30063 @defvr {Scheme Variable} %default-debootstrap-variants
30064 This is a convenience variable to make the debootstrap provider work
30065 ``out of the box'' without users having to declare variants manually. It
30066 contains a single debootstrap variant with the default configuration:
30067
30068 @lisp
30069 (list (debootstrap-variant
30070 "default"
30071 (debootstrap-configuration)))
30072 @end lisp
30073 @end defvr
30074
30075 @defvr {Scheme Variable} %default-guix-variants
30076 This is a convenience variable to make the Guix OS provider work without
30077 additional configuration. It creates a virtual machine that has an SSH
30078 server, a serial console, and authorizes the Ganeti hosts SSH keys.
30079
30080 @lisp
30081 (list (guix-variant
30082 "default"
30083 (file-append ganeti-instance-guix
30084 "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
30085 @end lisp
30086 @end defvr
30087
30088 Users can implement support for OS providers unbeknownst to Guix by extending
30089 the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
30090 For example:
30091
30092 @lisp
30093 (ganeti-os
30094 (name "custom")
30095 (extension ".conf")
30096 (variants
30097 (list (ganeti-os-variant
30098 (name "foo")
30099 (configuration (plain-file "bar" "this is fine"))))))
30100 @end lisp
30101
30102 That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
30103 to a file in the store with contents @code{this is fine}. It also creates
30104 @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
30105
30106 Obviously this may not work for all OS providers out there. If you find the
30107 interface limiting, please reach out to @email{guix-devel@@gnu.org}.
30108
30109 The rest of this section documents the various services that are included by
30110 @code{ganeti-service-type}.
30111
30112 @defvr {Scheme Variable} ganeti-noded-service-type
30113 @command{ganeti-noded} is the daemon responsible for node-specific functions
30114 within the Ganeti system. The value of this service must be a
30115 @code{ganeti-noded-configuration} object.
30116 @end defvr
30117
30118 @deftp {Data Type} ganeti-noded-configuration
30119 This is the configuration for the @code{ganeti-noded} service.
30120
30121 @table @asis
30122 @item @code{ganeti} (default: @code{ganeti})
30123 The @code{ganeti} package to use for this service.
30124
30125 @item @code{port} (default: @code{1811})
30126 The TCP port on which the node daemon listens for network requests.
30127
30128 @item @code{address} (default: @code{"0.0.0.0"})
30129 The network address that the daemon will bind to. The default address means
30130 bind to all available addresses.
30131
30132 @item @code{interface} (default: @code{#f})
30133 When this is set, it must be a specific network interface (e.g.@: @code{eth0})
30134 that the daemon will bind to.
30135
30136 @item @code{max-clients} (default: @code{20})
30137 This sets a limit on the maximum number of simultaneous client connections
30138 that the daemon will handle. Connections above this count are accepted, but
30139 no responses will be sent until enough connections have closed.
30140
30141 @item @code{ssl?} (default: @code{#t})
30142 Whether to use SSL/TLS to encrypt network communications. The certificate
30143 is automatically provisioned by the cluster and can be rotated with
30144 @command{gnt-cluster renew-crypto}.
30145
30146 @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
30147 This can be used to provide a specific encryption key for TLS communications.
30148
30149 @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
30150 This can be used to provide a specific certificate for TLS communications.
30151
30152 @item @code{debug?} (default: @code{#f})
30153 When true, the daemon performs additional logging for debugging purposes.
30154 Note that this will leak encryption details to the log files, use with caution.
30155
30156 @end table
30157 @end deftp
30158
30159 @defvr {Scheme Variable} ganeti-confd-service-type
30160 @command{ganeti-confd} answers queries related to the configuration of a
30161 Ganeti cluster. The purpose of this daemon is to have a highly available
30162 and fast way to query cluster configuration values. It is automatically
30163 active on all @dfn{master candidates}. The value of this service must be a
30164 @code{ganeti-confd-configuration} object.
30165
30166 @end defvr
30167
30168 @deftp {Data Type} ganeti-confd-configuration
30169 This is the configuration for the @code{ganeti-confd} service.
30170
30171 @table @asis
30172 @item @code{ganeti} (default: @code{ganeti})
30173 The @code{ganeti} package to use for this service.
30174
30175 @item @code{port} (default: @code{1814})
30176 The UDP port on which to listen for network requests.
30177
30178 @item @code{address} (default: @code{"0.0.0.0"})
30179 Network address that the daemon will bind to.
30180
30181 @item @code{debug?} (default: @code{#f})
30182 When true, the daemon performs additional logging for debugging purposes.
30183
30184 @end table
30185 @end deftp
30186
30187 @defvr {Scheme Variable} ganeti-wconfd-service-type
30188 @command{ganeti-wconfd} is the daemon that has authoritative knowledge
30189 about the cluster configuration and is the only entity that can accept
30190 changes to it. All jobs that need to modify the configuration will do so
30191 by sending appropriate requests to this daemon. It only runs on the
30192 @dfn{master node} and will automatically disable itself on other nodes.
30193
30194 The value of this service must be a
30195 @code{ganeti-wconfd-configuration} object.
30196 @end defvr
30197
30198 @deftp {Data Type} ganeti-wconfd-configuration
30199 This is the configuration for the @code{ganeti-wconfd} service.
30200
30201 @table @asis
30202 @item @code{ganeti} (default: @code{ganeti})
30203 The @code{ganeti} package to use for this service.
30204
30205 @item @code{no-voting?} (default: @code{#f})
30206 The daemon will refuse to start if the majority of cluster nodes does not
30207 agree that it is running on the master node. Set to @code{#t} to start
30208 even if a quorum can not be reached (dangerous, use with caution).
30209
30210 @item @code{debug?} (default: @code{#f})
30211 When true, the daemon performs additional logging for debugging purposes.
30212
30213 @end table
30214 @end deftp
30215
30216 @defvr {Scheme Variable} ganeti-luxid-service-type
30217 @command{ganeti-luxid} is a daemon used to answer queries related to the
30218 configuration and the current live state of a Ganeti cluster. Additionally,
30219 it is the authoritative daemon for the Ganeti job queue. Jobs can be
30220 submitted via this daemon and it schedules and starts them.
30221
30222 It takes a @code{ganeti-luxid-configuration} object.
30223 @end defvr
30224
30225 @deftp {Data Type} ganeti-luxid-configuration
30226 This is the configuration for the @code{ganeti-wconfd} service.
30227
30228 @table @asis
30229 @item @code{ganeti} (default: @code{ganeti})
30230 The @code{ganeti} package to use for this service.
30231
30232 @item @code{no-voting?} (default: @code{#f})
30233 The daemon will refuse to start if it cannot verify that the majority of
30234 cluster nodes believes that it is running on the master node. Set to
30235 @code{#t} to ignore such checks and start anyway (this can be dangerous).
30236
30237 @item @code{debug?} (default: @code{#f})
30238 When true, the daemon performs additional logging for debugging purposes.
30239
30240 @end table
30241 @end deftp
30242
30243 @defvr {Scheme Variable} ganeti-rapi-service-type
30244 @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
30245 the master node and can be used to perform cluster actions programmatically
30246 via a JSON-based RPC protocol.
30247
30248 Most query operations are allowed without authentication (unless
30249 @var{require-authentication?} is set), whereas write operations require
30250 explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
30251 the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
30252 API documentation} for more information.
30253
30254 The value of this service must be a @code{ganeti-rapi-configuration} object.
30255 @end defvr
30256
30257 @deftp {Data Type} ganeti-rapi-configuration
30258 This is the configuration for the @code{ganeti-rapi} service.
30259
30260 @table @asis
30261 @item @code{ganeti} (default: @code{ganeti})
30262 The @code{ganeti} package to use for this service.
30263
30264 @item @code{require-authentication?} (default: @code{#f})
30265 Whether to require authentication even for read-only operations.
30266
30267 @item @code{port} (default: @code{5080})
30268 The TCP port on which to listen to API requests.
30269
30270 @item @code{address} (default: @code{"0.0.0.0"})
30271 The network address that the service will bind to. By default it listens
30272 on all configured addresses.
30273
30274 @item @code{interface} (default: @code{#f})
30275 When set, it must specify a specific network interface such as @code{eth0}
30276 that the daemon will bind to.
30277
30278 @item @code{max-clients} (default: @code{20})
30279 The maximum number of simultaneous client requests to handle. Further
30280 connections are allowed, but no responses are sent until enough connections
30281 have closed.
30282
30283 @item @code{ssl?} (default: @code{#t})
30284 Whether to use SSL/TLS encryption on the RAPI port.
30285
30286 @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
30287 This can be used to provide a specific encryption key for TLS communications.
30288
30289 @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
30290 This can be used to provide a specific certificate for TLS communications.
30291
30292 @item @code{debug?} (default: @code{#f})
30293 When true, the daemon performs additional logging for debugging purposes.
30294 Note that this will leak encryption details to the log files, use with caution.
30295
30296 @end table
30297 @end deftp
30298
30299 @defvr {Scheme Variable} ganeti-kvmd-service-type
30300 @command{ganeti-kvmd} is responsible for determining whether a given KVM
30301 instance was shut down by an administrator or a user. Normally Ganeti will
30302 restart an instance that was not stopped through Ganeti itself. If the
30303 cluster option @code{user_shutdown} is true, this daemon monitors the
30304 @code{QMP} socket provided by QEMU and listens for shutdown events, and
30305 marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
30306 it shuts down gracefully by itself.
30307
30308 It takes a @code{ganeti-kvmd-configuration} object.
30309 @end defvr
30310
30311 @deftp {Data Type} ganeti-kvmd-configuration
30312
30313 @table @asis
30314 @item @code{ganeti} (default: @code{ganeti})
30315 The @code{ganeti} package to use for this service.
30316
30317 @item @code{debug?} (default: @code{#f})
30318 When true, the daemon performs additional logging for debugging purposes.
30319
30320 @end table
30321 @end deftp
30322
30323 @defvr {Scheme Variable} ganeti-mond-service-type
30324 @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
30325 functionality. It is responsible for running data collectors and publish the
30326 collected information through a HTTP interface.
30327
30328 It takes a @code{ganeti-mond-configuration} object.
30329 @end defvr
30330
30331 @deftp {Data Type} ganeti-mond-configuration
30332
30333 @table @asis
30334 @item @code{ganeti} (default: @code{ganeti})
30335 The @code{ganeti} package to use for this service.
30336
30337 @item @code{port} (default: @code{1815})
30338 The port on which the daemon will listen.
30339
30340 @item @code{address} (default: @code{"0.0.0.0"})
30341 The network address that the daemon will bind to. By default it binds to all
30342 available interfaces.
30343
30344 @item @code{debug?} (default: @code{#f})
30345 When true, the daemon performs additional logging for debugging purposes.
30346
30347 @end table
30348 @end deftp
30349
30350 @defvr {Scheme Variable} ganeti-metad-service-type
30351 @command{ganeti-metad} is an optional daemon that can be used to provide
30352 information about the cluster to instances or OS install scripts.
30353
30354 It takes a @code{ganeti-metad-configuration} object.
30355 @end defvr
30356
30357 @deftp {Data Type} ganeti-metad-configuration
30358
30359 @table @asis
30360 @item @code{ganeti} (default: @code{ganeti})
30361 The @code{ganeti} package to use for this service.
30362
30363 @item @code{port} (default: @code{80})
30364 The port on which the daemon will listen.
30365
30366 @item @code{address} (default: @code{#f})
30367 If set, the daemon will bind to this address only. If left unset, the behavior
30368 depends on the cluster configuration.
30369
30370 @item @code{debug?} (default: @code{#f})
30371 When true, the daemon performs additional logging for debugging purposes.
30372
30373 @end table
30374 @end deftp
30375
30376 @defvr {Scheme Variable} ganeti-watcher-service-type
30377 @command{ganeti-watcher} is a script designed to run periodically and ensure
30378 the health of a cluster. It will automatically restart instances that have
30379 stopped without Ganeti's consent, and repairs DRBD links in case a node has
30380 rebooted. It also archives old cluster jobs and restarts Ganeti daemons
30381 that are not running. If the cluster parameter @code{ensure_node_health}
30382 is set, the watcher will also shutdown instances and DRBD devices if the
30383 node it is running on is declared offline by known master candidates.
30384
30385 It can be paused on all nodes with @command{gnt-cluster watcher pause}.
30386
30387 The service takes a @code{ganeti-watcher-configuration} object.
30388 @end defvr
30389
30390 @deftp {Data Type} ganeti-watcher-configuration
30391
30392 @table @asis
30393 @item @code{ganeti} (default: @code{ganeti})
30394 The @code{ganeti} package to use for this service.
30395
30396 @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
30397 How often to run the script. The default is every five minutes.
30398
30399 @item @code{rapi-ip} (default: @code{#f})
30400 This option needs to be specified only if the RAPI daemon is configured to use
30401 a particular interface or address. By default the cluster address is used.
30402
30403 @item @code{job-age} (default: @code{(* 6 3600)})
30404 Archive cluster jobs older than this age, specified in seconds. The default
30405 is 6 hours. This keeps @command{gnt-job list} manageable.
30406
30407 @item @code{verify-disks?} (default: @code{#t})
30408 If this is @code{#f}, the watcher will not try to repair broken DRBD links
30409 automatically. Administrators will need to use @command{gnt-cluster verify-disks}
30410 manually instead.
30411
30412 @item @code{debug?} (default: @code{#f})
30413 When @code{#t}, the script performs additional logging for debugging purposes.
30414
30415 @end table
30416 @end deftp
30417
30418 @defvr {Scheme Variable} ganeti-cleaner-service-type
30419 @command{ganeti-cleaner} is a script designed to run periodically and remove
30420 old files from the cluster. This service type controls two @dfn{cron jobs}:
30421 one intended for the master node that permanently purges old cluster jobs,
30422 and one intended for every node that removes expired X509 certificates, keys,
30423 and outdated @command{ganeti-watcher} information. Like all Ganeti services,
30424 it is safe to include even on non-master nodes as it will disable itself as
30425 necessary.
30426
30427 It takes a @code{ganeti-cleaner-configuration} object.
30428 @end defvr
30429
30430 @deftp {Data Type} ganeti-cleaner-configuration
30431
30432 @table @asis
30433 @item @code{ganeti} (default: @code{ganeti})
30434 The @code{ganeti} package to use for the @command{gnt-cleaner} command.
30435
30436 @item @code{master-schedule} (default: @code{"45 1 * * *"})
30437 How often to run the master cleaning job. The default is once per day, at
30438 01:45:00.
30439
30440 @item @code{node-schedule} (default: @code{"45 2 * * *"})
30441 How often to run the node cleaning job. The default is once per day, at
30442 02:45:00.
30443
30444 @end table
30445 @end deftp
30446
30447 @node Version Control Services
30448 @subsection Version Control Services
30449
30450 The @code{(gnu services version-control)} module provides a service to
30451 allow remote access to local Git repositories. There are three options:
30452 the @code{git-daemon-service}, which provides access to repositories via
30453 the @code{git://} unsecured TCP-based protocol, extending the
30454 @code{nginx} web server to proxy some requests to
30455 @code{git-http-backend}, or providing a web interface with
30456 @code{cgit-service-type}.
30457
30458 @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
30459
30460 Return a service that runs @command{git daemon}, a simple TCP server to
30461 expose repositories over the Git protocol for anonymous access.
30462
30463 The optional @var{config} argument should be a
30464 @code{<git-daemon-configuration>} object, by default it allows read-only
30465 access to exported@footnote{By creating the magic file
30466 @file{git-daemon-export-ok} in the repository directory.} repositories under
30467 @file{/srv/git}.
30468
30469 @end deffn
30470
30471 @deftp {Data Type} git-daemon-configuration
30472 Data type representing the configuration for @code{git-daemon-service}.
30473
30474 @table @asis
30475 @item @code{package} (default: @code{git})
30476 Package object of the Git distributed version control system.
30477
30478 @item @code{export-all?} (default: @code{#f})
30479 Whether to allow access for all Git repositories, even if they do not
30480 have the @file{git-daemon-export-ok} file.
30481
30482 @item @code{base-path} (default: @file{/srv/git})
30483 Whether to remap all the path requests as relative to the given path.
30484 If you run @command{git daemon} with @code{(base-path "/srv/git")} on
30485 @samp{example.com}, then if you later try to pull
30486 @indicateurl{git://example.com/hello.git}, git daemon will interpret the
30487 path as @file{/srv/git/hello.git}.
30488
30489 @item @code{user-path} (default: @code{#f})
30490 Whether to allow @code{~user} notation to be used in requests. When
30491 specified with empty string, requests to
30492 @indicateurl{git://host/~alice/foo} is taken as a request to access
30493 @code{foo} repository in the home directory of user @code{alice}. If
30494 @code{(user-path "@var{path}")} is specified, the same request is taken
30495 as a request to access @file{@var{path}/foo} repository in the home
30496 directory of user @code{alice}.
30497
30498 @item @code{listen} (default: @code{'()})
30499 Whether to listen on specific IP addresses or hostnames, defaults to
30500 all.
30501
30502 @item @code{port} (default: @code{#f})
30503 Whether to listen on an alternative port, which defaults to 9418.
30504
30505 @item @code{whitelist} (default: @code{'()})
30506 If not empty, only allow access to this list of directories.
30507
30508 @item @code{extra-options} (default: @code{'()})
30509 Extra options will be passed to @command{git daemon}, please run
30510 @command{man git-daemon} for more information.
30511
30512 @end table
30513 @end deftp
30514
30515 The @code{git://} protocol lacks authentication. When you pull from a
30516 repository fetched via @code{git://}, you don't know whether the data you
30517 receive was modified or is even coming from the specified host, and your
30518 connection is subject to eavesdropping. It's better to use an authenticated
30519 and encrypted transport, such as @code{https}. Although Git allows you
30520 to serve repositories using unsophisticated file-based web servers,
30521 there is a faster protocol implemented by the @code{git-http-backend}
30522 program. This program is the back-end of a proper Git web service. It
30523 is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
30524 on running the necessary @code{fcgiwrap} daemon.
30525
30526 Guix has a separate configuration data type for serving Git repositories
30527 over HTTP.
30528
30529 @deftp {Data Type} git-http-configuration
30530 Data type representing the configuration for a future
30531 @code{git-http-service-type}; can currently be used to configure Nginx
30532 through @code{git-http-nginx-location-configuration}.
30533
30534 @table @asis
30535 @item @code{package} (default: @var{git})
30536 Package object of the Git distributed version control system.
30537
30538 @item @code{git-root} (default: @file{/srv/git})
30539 Directory containing the Git repositories to expose to the world.
30540
30541 @item @code{export-all?} (default: @code{#f})
30542 Whether to expose access for all Git repositories in @var{git-root},
30543 even if they do not have the @file{git-daemon-export-ok} file.
30544
30545 @item @code{uri-path} (default: @samp{/git/})
30546 Path prefix for Git access. With the default @samp{/git/} prefix, this
30547 will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
30548 @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
30549 with this prefix are not passed on to this Git instance.
30550
30551 @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
30552 The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
30553 Services}.
30554 @end table
30555 @end deftp
30556
30557 There is no @code{git-http-service-type}, currently; instead you can
30558 create an @code{nginx-location-configuration} from a
30559 @code{git-http-configuration} and then add that location to a web
30560 server.
30561
30562 @deffn {Scheme Procedure} git-http-nginx-location-configuration @
30563 [config=(git-http-configuration)]
30564 Compute an @code{nginx-location-configuration} that corresponds to the
30565 given Git http configuration. An example nginx service definition to
30566 serve the default @file{/srv/git} over HTTPS might be:
30567
30568 @lisp
30569 (service nginx-service-type
30570 (nginx-configuration
30571 (server-blocks
30572 (list
30573 (nginx-server-configuration
30574 (listen '("443 ssl"))
30575 (server-name "git.my-host.org")
30576 (ssl-certificate
30577 "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
30578 (ssl-certificate-key
30579 "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
30580 (locations
30581 (list
30582 (git-http-nginx-location-configuration
30583 (git-http-configuration (uri-path "/"))))))))))
30584 @end lisp
30585
30586 This example assumes that you are using Let's Encrypt to get your TLS
30587 certificate. @xref{Certificate Services}. The default @code{certbot}
30588 service will redirect all HTTP traffic on @code{git.my-host.org} to
30589 HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
30590 system services. @xref{Web Services}.
30591 @end deffn
30592
30593 @subsubheading Cgit Service
30594
30595 @cindex Cgit service
30596 @cindex Git, web interface
30597 @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
30598 repositories written in C.
30599
30600 The following example will configure the service with default values.
30601 By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
30602
30603 @lisp
30604 (service cgit-service-type)
30605 @end lisp
30606
30607 The @code{file-object} type designates either a file-like object
30608 (@pxref{G-Expressions, file-like objects}) or a string.
30609
30610 @c %start of fragment
30611
30612 Available @code{cgit-configuration} fields are:
30613
30614 @deftypevr {@code{cgit-configuration} parameter} package package
30615 The CGIT package.
30616
30617 @end deftypevr
30618
30619 @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
30620 NGINX configuration.
30621
30622 @end deftypevr
30623
30624 @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
30625 Specifies a command which will be invoked to format the content of about
30626 pages (both top-level and for each repository).
30627
30628 Defaults to @samp{""}.
30629
30630 @end deftypevr
30631
30632 @deftypevr {@code{cgit-configuration} parameter} string agefile
30633 Specifies a path, relative to each repository path, which can be used to
30634 specify the date and time of the youngest commit in the repository.
30635
30636 Defaults to @samp{""}.
30637
30638 @end deftypevr
30639
30640 @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
30641 Specifies a command that will be invoked for authenticating repository
30642 access.
30643
30644 Defaults to @samp{""}.
30645
30646 @end deftypevr
30647
30648 @deftypevr {@code{cgit-configuration} parameter} string branch-sort
30649 Flag which, when set to @samp{age}, enables date ordering in the branch
30650 ref list, and when set @samp{name} enables ordering by branch name.
30651
30652 Defaults to @samp{"name"}.
30653
30654 @end deftypevr
30655
30656 @deftypevr {@code{cgit-configuration} parameter} string cache-root
30657 Path used to store the cgit cache entries.
30658
30659 Defaults to @samp{"/var/cache/cgit"}.
30660
30661 @end deftypevr
30662
30663 @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
30664 Number which specifies the time-to-live, in minutes, for the cached
30665 version of repository pages accessed with a fixed SHA1.
30666
30667 Defaults to @samp{-1}.
30668
30669 @end deftypevr
30670
30671 @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
30672 Number which specifies the time-to-live, in minutes, for the cached
30673 version of repository pages accessed without a fixed SHA1.
30674
30675 Defaults to @samp{5}.
30676
30677 @end deftypevr
30678
30679 @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
30680 Number which specifies the time-to-live, in minutes, for the cached
30681 version of the repository summary page.
30682
30683 Defaults to @samp{5}.
30684
30685 @end deftypevr
30686
30687 @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
30688 Number which specifies the time-to-live, in minutes, for the cached
30689 version of the repository index page.
30690
30691 Defaults to @samp{5}.
30692
30693 @end deftypevr
30694
30695 @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
30696 Number which specifies the time-to-live, in minutes, for the result of
30697 scanning a path for Git repositories.
30698
30699 Defaults to @samp{15}.
30700
30701 @end deftypevr
30702
30703 @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
30704 Number which specifies the time-to-live, in minutes, for the cached
30705 version of the repository about page.
30706
30707 Defaults to @samp{15}.
30708
30709 @end deftypevr
30710
30711 @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
30712 Number which specifies the time-to-live, in minutes, for the cached
30713 version of snapshots.
30714
30715 Defaults to @samp{5}.
30716
30717 @end deftypevr
30718
30719 @deftypevr {@code{cgit-configuration} parameter} integer cache-size
30720 The maximum number of entries in the cgit cache. When set to @samp{0},
30721 caching is disabled.
30722
30723 Defaults to @samp{0}.
30724
30725 @end deftypevr
30726
30727 @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
30728 Sort items in the repo list case sensitively.
30729
30730 Defaults to @samp{#t}.
30731
30732 @end deftypevr
30733
30734 @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
30735 List of common prefixes which, when combined with a repository URL,
30736 generates valid clone URLs for the repository.
30737
30738 Defaults to @samp{()}.
30739
30740 @end deftypevr
30741
30742 @deftypevr {@code{cgit-configuration} parameter} list clone-url
30743 List of @code{clone-url} templates.
30744
30745 Defaults to @samp{()}.
30746
30747 @end deftypevr
30748
30749 @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
30750 Command which will be invoked to format commit messages.
30751
30752 Defaults to @samp{""}.
30753
30754 @end deftypevr
30755
30756 @deftypevr {@code{cgit-configuration} parameter} string commit-sort
30757 Flag which, when set to @samp{date}, enables strict date ordering in the
30758 commit log, and when set to @samp{topo} enables strict topological
30759 ordering.
30760
30761 Defaults to @samp{"git log"}.
30762
30763 @end deftypevr
30764
30765 @deftypevr {@code{cgit-configuration} parameter} file-object css
30766 URL which specifies the css document to include in all cgit pages.
30767
30768 Defaults to @samp{"/share/cgit/cgit.css"}.
30769
30770 @end deftypevr
30771
30772 @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
30773 Specifies a command which will be invoked to format names and email
30774 address of committers, authors, and taggers, as represented in various
30775 places throughout the cgit interface.
30776
30777 Defaults to @samp{""}.
30778
30779 @end deftypevr
30780
30781 @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
30782 Flag which, when set to @samp{#t}, will make cgit generate a HTML
30783 fragment suitable for embedding in other HTML pages.
30784
30785 Defaults to @samp{#f}.
30786
30787 @end deftypevr
30788
30789 @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
30790 Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
30791 commit history graph to the left of the commit messages in the
30792 repository log page.
30793
30794 Defaults to @samp{#f}.
30795
30796 @end deftypevr
30797
30798 @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
30799 Flag which, when set to @samp{#t}, allows all filter settings to be
30800 overridden in repository-specific cgitrc files.
30801
30802 Defaults to @samp{#f}.
30803
30804 @end deftypevr
30805
30806 @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
30807 Flag which, when set to @samp{#t}, allows users to follow a file in the
30808 log view.
30809
30810 Defaults to @samp{#f}.
30811
30812 @end deftypevr
30813
30814 @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
30815 If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
30816 clones.
30817
30818 Defaults to @samp{#t}.
30819
30820 @end deftypevr
30821
30822 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
30823 Flag which, when set to @samp{#t}, will make cgit generate extra links
30824 "summary", "commit", "tree" for each repo in the repository index.
30825
30826 Defaults to @samp{#f}.
30827
30828 @end deftypevr
30829
30830 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
30831 Flag which, when set to @samp{#t}, will make cgit display the owner of
30832 each repo in the repository index.
30833
30834 Defaults to @samp{#t}.
30835
30836 @end deftypevr
30837
30838 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
30839 Flag which, when set to @samp{#t}, will make cgit print the number of
30840 modified files for each commit on the repository log page.
30841
30842 Defaults to @samp{#f}.
30843
30844 @end deftypevr
30845
30846 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
30847 Flag which, when set to @samp{#t}, will make cgit print the number of
30848 added and removed lines for each commit on the repository log page.
30849
30850 Defaults to @samp{#f}.
30851
30852 @end deftypevr
30853
30854 @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
30855 Flag which, when set to @code{#t}, will make cgit display remote
30856 branches in the summary and refs views.
30857
30858 Defaults to @samp{#f}.
30859
30860 @end deftypevr
30861
30862 @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
30863 Flag which, when set to @code{1}, will make cgit use the subject of the
30864 parent commit as link text when generating links to parent commits in
30865 commit view.
30866
30867 Defaults to @samp{#f}.
30868
30869 @end deftypevr
30870
30871 @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
30872 Flag which, when set to @samp{#t}, will make cgit use the subject of the
30873 parent commit as link text when generating links to parent commits in
30874 commit view.
30875
30876 Defaults to @samp{#f}.
30877
30878 @end deftypevr
30879
30880 @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
30881 Flag which, when set to @samp{#t}, will make cgit generate linenumber
30882 links for plaintext blobs printed in the tree view.
30883
30884 Defaults to @samp{#t}.
30885
30886 @end deftypevr
30887
30888 @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
30889 Flag which, when set to @samp{#f}, will allow cgit to use Git config to
30890 set any repo specific settings.
30891
30892 Defaults to @samp{#f}.
30893
30894 @end deftypevr
30895
30896 @deftypevr {@code{cgit-configuration} parameter} file-object favicon
30897 URL used as link to a shortcut icon for cgit.
30898
30899 Defaults to @samp{"/favicon.ico"}.
30900
30901 @end deftypevr
30902
30903 @deftypevr {@code{cgit-configuration} parameter} string footer
30904 The content of the file specified with this option will be included
30905 verbatim at the bottom of all pages (i.e.@: it replaces the standard
30906 "generated by..."@: message).
30907
30908 Defaults to @samp{""}.
30909
30910 @end deftypevr
30911
30912 @deftypevr {@code{cgit-configuration} parameter} string head-include
30913 The content of the file specified with this option will be included
30914 verbatim in the HTML HEAD section on all pages.
30915
30916 Defaults to @samp{""}.
30917
30918 @end deftypevr
30919
30920 @deftypevr {@code{cgit-configuration} parameter} string header
30921 The content of the file specified with this option will be included
30922 verbatim at the top of all pages.
30923
30924 Defaults to @samp{""}.
30925
30926 @end deftypevr
30927
30928 @deftypevr {@code{cgit-configuration} parameter} file-object include
30929 Name of a configfile to include before the rest of the current config-
30930 file is parsed.
30931
30932 Defaults to @samp{""}.
30933
30934 @end deftypevr
30935
30936 @deftypevr {@code{cgit-configuration} parameter} string index-header
30937 The content of the file specified with this option will be included
30938 verbatim above the repository index.
30939
30940 Defaults to @samp{""}.
30941
30942 @end deftypevr
30943
30944 @deftypevr {@code{cgit-configuration} parameter} string index-info
30945 The content of the file specified with this option will be included
30946 verbatim below the heading on the repository index page.
30947
30948 Defaults to @samp{""}.
30949
30950 @end deftypevr
30951
30952 @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
30953 Flag which, if set to @samp{#t}, makes cgit print commit and tag times
30954 in the servers timezone.
30955
30956 Defaults to @samp{#f}.
30957
30958 @end deftypevr
30959
30960 @deftypevr {@code{cgit-configuration} parameter} file-object logo
30961 URL which specifies the source of an image which will be used as a logo
30962 on all cgit pages.
30963
30964 Defaults to @samp{"/share/cgit/cgit.png"}.
30965
30966 @end deftypevr
30967
30968 @deftypevr {@code{cgit-configuration} parameter} string logo-link
30969 URL loaded when clicking on the cgit logo image.
30970
30971 Defaults to @samp{""}.
30972
30973 @end deftypevr
30974
30975 @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
30976 Command which will be invoked to format the Owner column of the main
30977 page.
30978
30979 Defaults to @samp{""}.
30980
30981 @end deftypevr
30982
30983 @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
30984 Number of items to display in atom feeds view.
30985
30986 Defaults to @samp{10}.
30987
30988 @end deftypevr
30989
30990 @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
30991 Number of entries to list per page in "log" view.
30992
30993 Defaults to @samp{50}.
30994
30995 @end deftypevr
30996
30997 @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
30998 Number of commit message characters to display in "log" view.
30999
31000 Defaults to @samp{80}.
31001
31002 @end deftypevr
31003
31004 @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
31005 Specifies the number of entries to list per page on the repository index
31006 page.
31007
31008 Defaults to @samp{50}.
31009
31010 @end deftypevr
31011
31012 @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
31013 Specifies the maximum number of repo description characters to display
31014 on the repository index page.
31015
31016 Defaults to @samp{80}.
31017
31018 @end deftypevr
31019
31020 @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
31021 Specifies the maximum size of a blob to display HTML for in KBytes.
31022
31023 Defaults to @samp{0}.
31024
31025 @end deftypevr
31026
31027 @deftypevr {@code{cgit-configuration} parameter} string max-stats
31028 Maximum statistics period. Valid values are @samp{week},@samp{month},
31029 @samp{quarter} and @samp{year}.
31030
31031 Defaults to @samp{""}.
31032
31033 @end deftypevr
31034
31035 @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
31036 Mimetype for the specified filename extension.
31037
31038 Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
31039 "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
31040 "image/png") (svg "image/svg+xml"))}.
31041
31042 @end deftypevr
31043
31044 @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
31045 Specifies the file to use for automatic mimetype lookup.
31046
31047 Defaults to @samp{""}.
31048
31049 @end deftypevr
31050
31051 @deftypevr {@code{cgit-configuration} parameter} string module-link
31052 Text which will be used as the formatstring for a hyperlink when a
31053 submodule is printed in a directory listing.
31054
31055 Defaults to @samp{""}.
31056
31057 @end deftypevr
31058
31059 @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
31060 If set to the value @samp{#t} caching will be disabled.
31061
31062 Defaults to @samp{#f}.
31063
31064 @end deftypevr
31065
31066 @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
31067 If set to @samp{#t} showing full author email addresses will be
31068 disabled.
31069
31070 Defaults to @samp{#f}.
31071
31072 @end deftypevr
31073
31074 @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
31075 Flag which, when set to @samp{#t}, will make cgit omit the standard
31076 header on all pages.
31077
31078 Defaults to @samp{#f}.
31079
31080 @end deftypevr
31081
31082 @deftypevr {@code{cgit-configuration} parameter} project-list project-list
31083 A list of subdirectories inside of @code{repository-directory}, relative
31084 to it, that should loaded as Git repositories. An empty list means that
31085 all subdirectories will be loaded.
31086
31087 Defaults to @samp{()}.
31088
31089 @end deftypevr
31090
31091 @deftypevr {@code{cgit-configuration} parameter} file-object readme
31092 Text which will be used as default value for @code{cgit-repo-readme}.
31093
31094 Defaults to @samp{""}.
31095
31096 @end deftypevr
31097
31098 @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
31099 If set to @code{#t} and @code{repository-directory} is enabled, if any
31100 repositories are found with a suffix of @code{.git}, this suffix will be
31101 removed for the URL and name.
31102
31103 Defaults to @samp{#f}.
31104
31105 @end deftypevr
31106
31107 @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
31108 Maximum number of files to consider when detecting renames.
31109
31110 Defaults to @samp{-1}.
31111
31112 @end deftypevr
31113
31114 @deftypevr {@code{cgit-configuration} parameter} string repository-sort
31115 The way in which repositories in each section are sorted.
31116
31117 Defaults to @samp{""}.
31118
31119 @end deftypevr
31120
31121 @deftypevr {@code{cgit-configuration} parameter} robots-list robots
31122 Text used as content for the @code{robots} meta-tag.
31123
31124 Defaults to @samp{("noindex" "nofollow")}.
31125
31126 @end deftypevr
31127
31128 @deftypevr {@code{cgit-configuration} parameter} string root-desc
31129 Text printed below the heading on the repository index page.
31130
31131 Defaults to @samp{"a fast webinterface for the git dscm"}.
31132
31133 @end deftypevr
31134
31135 @deftypevr {@code{cgit-configuration} parameter} string root-readme
31136 The content of the file specified with this option will be included
31137 verbatim below the ``about'' link on the repository index page.
31138
31139 Defaults to @samp{""}.
31140
31141 @end deftypevr
31142
31143 @deftypevr {@code{cgit-configuration} parameter} string root-title
31144 Text printed as heading on the repository index page.
31145
31146 Defaults to @samp{""}.
31147
31148 @end deftypevr
31149
31150 @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
31151 If set to @samp{#t} and repository-directory is enabled,
31152 repository-directory will recurse into directories whose name starts
31153 with a period. Otherwise, repository-directory will stay away from such
31154 directories, considered as ``hidden''. Note that this does not apply to
31155 the @file{.git} directory in non-bare repos.
31156
31157 Defaults to @samp{#f}.
31158
31159 @end deftypevr
31160
31161 @deftypevr {@code{cgit-configuration} parameter} list snapshots
31162 Text which specifies the default set of snapshot formats that cgit
31163 generates links for.
31164
31165 Defaults to @samp{()}.
31166
31167 @end deftypevr
31168
31169 @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
31170 Name of the directory to scan for repositories (represents
31171 @code{scan-path}).
31172
31173 Defaults to @samp{"/srv/git"}.
31174
31175 @end deftypevr
31176
31177 @deftypevr {@code{cgit-configuration} parameter} string section
31178 The name of the current repository section - all repositories defined
31179 after this option will inherit the current section name.
31180
31181 Defaults to @samp{""}.
31182
31183 @end deftypevr
31184
31185 @deftypevr {@code{cgit-configuration} parameter} string section-sort
31186 Flag which, when set to @samp{1}, will sort the sections on the
31187 repository listing by name.
31188
31189 Defaults to @samp{""}.
31190
31191 @end deftypevr
31192
31193 @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
31194 A number which, if defined prior to repository-directory, specifies how
31195 many path elements from each repo path to use as a default section name.
31196
31197 Defaults to @samp{0}.
31198
31199 @end deftypevr
31200
31201 @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
31202 If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
31203 default.
31204
31205 Defaults to @samp{#f}.
31206
31207 @end deftypevr
31208
31209 @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
31210 Specifies a command which will be invoked to format plaintext blobs in
31211 the tree view.
31212
31213 Defaults to @samp{""}.
31214
31215 @end deftypevr
31216
31217 @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
31218 Specifies the number of branches to display in the repository ``summary''
31219 view.
31220
31221 Defaults to @samp{10}.
31222
31223 @end deftypevr
31224
31225 @deftypevr {@code{cgit-configuration} parameter} integer summary-log
31226 Specifies the number of log entries to display in the repository
31227 ``summary'' view.
31228
31229 Defaults to @samp{10}.
31230
31231 @end deftypevr
31232
31233 @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
31234 Specifies the number of tags to display in the repository ``summary''
31235 view.
31236
31237 Defaults to @samp{10}.
31238
31239 @end deftypevr
31240
31241 @deftypevr {@code{cgit-configuration} parameter} string strict-export
31242 Filename which, if specified, needs to be present within the repository
31243 for cgit to allow access to that repository.
31244
31245 Defaults to @samp{""}.
31246
31247 @end deftypevr
31248
31249 @deftypevr {@code{cgit-configuration} parameter} string virtual-root
31250 URL which, if specified, will be used as root for all cgit links.
31251
31252 Defaults to @samp{"/"}.
31253
31254 @end deftypevr
31255
31256 @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
31257 A list of @dfn{cgit-repo} records to use with config.
31258
31259 Defaults to @samp{()}.
31260
31261 Available @code{repository-cgit-configuration} fields are:
31262
31263 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
31264 A mask of snapshot formats for this repo that cgit generates links for,
31265 restricted by the global @code{snapshots} setting.
31266
31267 Defaults to @samp{()}.
31268
31269 @end deftypevr
31270
31271 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
31272 Override the default @code{source-filter}.
31273
31274 Defaults to @samp{""}.
31275
31276 @end deftypevr
31277
31278 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
31279 The relative URL used to access the repository.
31280
31281 Defaults to @samp{""}.
31282
31283 @end deftypevr
31284
31285 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
31286 Override the default @code{about-filter}.
31287
31288 Defaults to @samp{""}.
31289
31290 @end deftypevr
31291
31292 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
31293 Flag which, when set to @samp{age}, enables date ordering in the branch
31294 ref list, and when set to @samp{name} enables ordering by branch name.
31295
31296 Defaults to @samp{""}.
31297
31298 @end deftypevr
31299
31300 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
31301 A list of URLs which can be used to clone repo.
31302
31303 Defaults to @samp{()}.
31304
31305 @end deftypevr
31306
31307 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
31308 Override the default @code{commit-filter}.
31309
31310 Defaults to @samp{""}.
31311
31312 @end deftypevr
31313
31314 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
31315 Flag which, when set to @samp{date}, enables strict date ordering in the
31316 commit log, and when set to @samp{topo} enables strict topological
31317 ordering.
31318
31319 Defaults to @samp{""}.
31320
31321 @end deftypevr
31322
31323 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
31324 The name of the default branch for this repository. If no such branch
31325 exists in the repository, the first branch name (when sorted) is used as
31326 default instead. By default branch pointed to by HEAD, or ``master'' if
31327 there is no suitable HEAD.
31328
31329 Defaults to @samp{""}.
31330
31331 @end deftypevr
31332
31333 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
31334 The value to show as repository description.
31335
31336 Defaults to @samp{""}.
31337
31338 @end deftypevr
31339
31340 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
31341 The value to show as repository homepage.
31342
31343 Defaults to @samp{""}.
31344
31345 @end deftypevr
31346
31347 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
31348 Override the default @code{email-filter}.
31349
31350 Defaults to @samp{""}.
31351
31352 @end deftypevr
31353
31354 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
31355 A flag which can be used to disable the global setting
31356 @code{enable-commit-graph?}.
31357
31358 Defaults to @samp{disabled}.
31359
31360 @end deftypevr
31361
31362 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
31363 A flag which can be used to disable the global setting
31364 @code{enable-log-filecount?}.
31365
31366 Defaults to @samp{disabled}.
31367
31368 @end deftypevr
31369
31370 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
31371 A flag which can be used to disable the global setting
31372 @code{enable-log-linecount?}.
31373
31374 Defaults to @samp{disabled}.
31375
31376 @end deftypevr
31377
31378 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
31379 Flag which, when set to @code{#t}, will make cgit display remote
31380 branches in the summary and refs views.
31381
31382 Defaults to @samp{disabled}.
31383
31384 @end deftypevr
31385
31386 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
31387 A flag which can be used to override the global setting
31388 @code{enable-subject-links?}.
31389
31390 Defaults to @samp{disabled}.
31391
31392 @end deftypevr
31393
31394 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
31395 A flag which can be used to override the global setting
31396 @code{enable-html-serving?}.
31397
31398 Defaults to @samp{disabled}.
31399
31400 @end deftypevr
31401
31402 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
31403 Flag which, when set to @code{#t}, hides the repository from the
31404 repository index.
31405
31406 Defaults to @samp{#f}.
31407
31408 @end deftypevr
31409
31410 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
31411 Flag which, when set to @samp{#t}, ignores the repository.
31412
31413 Defaults to @samp{#f}.
31414
31415 @end deftypevr
31416
31417 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
31418 URL which specifies the source of an image which will be used as a logo
31419 on this repo’s pages.
31420
31421 Defaults to @samp{""}.
31422
31423 @end deftypevr
31424
31425 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
31426 URL loaded when clicking on the cgit logo image.
31427
31428 Defaults to @samp{""}.
31429
31430 @end deftypevr
31431
31432 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
31433 Override the default @code{owner-filter}.
31434
31435 Defaults to @samp{""}.
31436
31437 @end deftypevr
31438
31439 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
31440 Text which will be used as the formatstring for a hyperlink when a
31441 submodule is printed in a directory listing. The arguments for the
31442 formatstring are the path and SHA1 of the submodule commit.
31443
31444 Defaults to @samp{""}.
31445
31446 @end deftypevr
31447
31448 @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
31449 Text which will be used as the formatstring for a hyperlink when a
31450 submodule with the specified subdirectory path is printed in a directory
31451 listing.
31452
31453 Defaults to @samp{()}.
31454
31455 @end deftypevr
31456
31457 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
31458 Override the default maximum statistics period.
31459
31460 Defaults to @samp{""}.
31461
31462 @end deftypevr
31463
31464 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
31465 The value to show as repository name.
31466
31467 Defaults to @samp{""}.
31468
31469 @end deftypevr
31470
31471 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
31472 A value used to identify the owner of the repository.
31473
31474 Defaults to @samp{""}.
31475
31476 @end deftypevr
31477
31478 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
31479 An absolute path to the repository directory.
31480
31481 Defaults to @samp{""}.
31482
31483 @end deftypevr
31484
31485 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
31486 A path (relative to repo) which specifies a file to include verbatim as
31487 the ``About'' page for this repo.
31488
31489 Defaults to @samp{""}.
31490
31491 @end deftypevr
31492
31493 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
31494 The name of the current repository section - all repositories defined
31495 after this option will inherit the current section name.
31496
31497 Defaults to @samp{""}.
31498
31499 @end deftypevr
31500
31501 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
31502 Extra options will be appended to cgitrc file.
31503
31504 Defaults to @samp{()}.
31505
31506 @end deftypevr
31507
31508 @end deftypevr
31509
31510 @deftypevr {@code{cgit-configuration} parameter} list extra-options
31511 Extra options will be appended to cgitrc file.
31512
31513 Defaults to @samp{()}.
31514
31515 @end deftypevr
31516
31517
31518 @c %end of fragment
31519
31520 However, it could be that you just want to get a @code{cgitrc} up and
31521 running. In that case, you can pass an @code{opaque-cgit-configuration}
31522 as a record to @code{cgit-service-type}. As its name indicates, an
31523 opaque configuration does not have easy reflective capabilities.
31524
31525 Available @code{opaque-cgit-configuration} fields are:
31526
31527 @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
31528 The cgit package.
31529 @end deftypevr
31530
31531 @deftypevr {@code{opaque-cgit-configuration} parameter} string string
31532 The contents of the @code{cgitrc}, as a string.
31533 @end deftypevr
31534
31535 For example, if your @code{cgitrc} is just the empty string, you
31536 could instantiate a cgit service like this:
31537
31538 @lisp
31539 (service cgit-service-type
31540 (opaque-cgit-configuration
31541 (cgitrc "")))
31542 @end lisp
31543
31544 @subsubheading Gitolite Service
31545
31546 @cindex Gitolite service
31547 @cindex Git, hosting
31548 @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
31549 repositories on a central server.
31550
31551 Gitolite can handle multiple repositories and users, and supports flexible
31552 configuration of the permissions for the users on the repositories.
31553
31554 The following example will configure Gitolite using the default @code{git}
31555 user, and the provided SSH public key.
31556
31557 @lisp
31558 (service gitolite-service-type
31559 (gitolite-configuration
31560 (admin-pubkey (plain-file
31561 "yourname.pub"
31562 "ssh-rsa AAAA... guix@@example.com"))))
31563 @end lisp
31564
31565 Gitolite is configured through a special admin repository which you can clone,
31566 for example, if you setup Gitolite on @code{example.com}, you would run the
31567 following command to clone the admin repository.
31568
31569 @example
31570 git clone git@@example.com:gitolite-admin
31571 @end example
31572
31573 When the Gitolite service is activated, the provided @code{admin-pubkey} will
31574 be inserted in to the @file{keydir} directory in the gitolite-admin
31575 repository. If this results in a change in the repository, it will be
31576 committed using the message ``gitolite setup by GNU Guix''.
31577
31578 @deftp {Data Type} gitolite-configuration
31579 Data type representing the configuration for @code{gitolite-service-type}.
31580
31581 @table @asis
31582 @item @code{package} (default: @var{gitolite})
31583 Gitolite package to use.
31584
31585 @item @code{user} (default: @var{git})
31586 User to use for Gitolite. This will be user that you use when accessing
31587 Gitolite over SSH.
31588
31589 @item @code{group} (default: @var{git})
31590 Group to use for Gitolite.
31591
31592 @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
31593 Directory in which to store the Gitolite configuration and repositories.
31594
31595 @item @code{rc-file} (default: @var{(gitolite-rc-file)})
31596 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
31597 representing the configuration for Gitolite.
31598
31599 @item @code{admin-pubkey} (default: @var{#f})
31600 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
31601 setup Gitolite. This will be inserted in to the @file{keydir} directory
31602 within the gitolite-admin repository.
31603
31604 To specify the SSH key as a string, use the @code{plain-file} function.
31605
31606 @lisp
31607 (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
31608 @end lisp
31609
31610 @end table
31611 @end deftp
31612
31613 @deftp {Data Type} gitolite-rc-file
31614 Data type representing the Gitolite RC file.
31615
31616 @table @asis
31617 @item @code{umask} (default: @code{#o0077})
31618 This controls the permissions Gitolite sets on the repositories and their
31619 contents.
31620
31621 A value like @code{#o0027} will give read access to the group used by Gitolite
31622 (by default: @code{git}). This is necessary when using Gitolite with software
31623 like cgit or gitweb.
31624
31625 @item @code{unsafe-pattern} (default: @code{#f})
31626 An optional Perl regular expression for catching unsafe configurations in
31627 the configuration file. See
31628 @uref{https://gitolite.com/gitolite/git-config.html#compensating-for-unsafe_patt,
31629 Gitolite's documentation} for more information.
31630
31631 When the value is not @code{#f}, it should be a string containing a Perl
31632 regular expression, such as @samp{"[`~#\$\&()|;<>]"}, which is the default
31633 value used by gitolite. It rejects any special character in configuration
31634 that might be interpreted by a shell, which is useful when sharing the
31635 administration burden with other people that do not otherwise have shell
31636 access on the server.
31637
31638 @item @code{git-config-keys} (default: @code{""})
31639 Gitolite allows you to set git config values using the @samp{config}
31640 keyword. This setting allows control over the config keys to accept.
31641
31642 @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
31643 Set the role names allowed to be used by users running the perms command.
31644
31645 @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
31646 This setting controls the commands and features to enable within Gitolite.
31647
31648 @end table
31649 @end deftp
31650
31651
31652 @subsubheading Gitile Service
31653
31654 @cindex Gitile service
31655 @cindex Git, forge
31656 @uref{https://git.lepiller.eu/gitile, Gitile} is a Git forge for viewing
31657 public git repository contents from a web browser.
31658
31659 Gitile works best in collaboration with Gitolite, and will serve the public
31660 repositories from Gitolite by default. The service should listen only on
31661 a local port, and a webserver should be configured to serve static resources.
31662 The gitile service provides an easy way to extend the Nginx service for
31663 that purpose (@pxref{NGINX}).
31664
31665 The following example will configure Gitile to serve repositories from a
31666 custom location, with some default messages for the home page and the
31667 footers.
31668
31669 @lisp
31670 (service gitile-service-type
31671 (gitile-configuration
31672 (repositories "/srv/git")
31673 (base-git-url "https://myweb.site/git")
31674 (index-title "My git repositories")
31675 (intro '((p "This is all my public work!")))
31676 (footer '((p "This is the end")))
31677 (nginx-server-block
31678 (nginx-server-configuration
31679 (ssl-certificate
31680 "/etc/letsencrypt/live/myweb.site/fullchain.pem")
31681 (ssl-certificate-key
31682 "/etc/letsencrypt/live/myweb.site/privkey.pem")
31683 (listen '("443 ssl http2" "[::]:443 ssl http2"))
31684 (locations
31685 (list
31686 ;; Allow for https anonymous fetch on /git/ urls.
31687 (git-http-nginx-location-configuration
31688 (git-http-configuration
31689 (uri-path "/git/")
31690 (git-root "/var/lib/gitolite/repositories")))))))))
31691 @end lisp
31692
31693 In addition to the configuration record, you should configure your git
31694 repositories to contain some optional information. First, your public
31695 repositories need to contain the @file{git-daemon-export-ok} magic file
31696 that allows Git to export the repository. Gitile uses the presence of this
31697 file to detect public repositories it should make accessible. To do so with
31698 Gitolite for instance, modify your @file{conf/gitolite.conf} to include
31699 this in the repositories you want to make public:
31700
31701 @example
31702 repo foo
31703 R = daemon
31704 @end example
31705
31706 In addition, Gitile can read the repository configuration to display more
31707 infomation on the repository. Gitile uses the gitweb namespace for its
31708 configuration. As an example, you can use the following in your
31709 @file{conf/gitolite.conf}:
31710
31711 @example
31712 repo foo
31713 R = daemon
31714 desc = A long description, optionally with <i>HTML</i>, shown on the index page
31715 config gitweb.name = The Foo Project
31716 config gitweb.synopsis = A short description, shown on the main page of the project
31717 @end example
31718
31719 Do not forget to commit and push these changes once you are satisfied. You
31720 may need to change your gitolite configuration to allow the previous
31721 configuration options to be set. One way to do that is to add the
31722 following service definition:
31723
31724 @lisp
31725 (service gitolite-service-type
31726 (gitolite-configuration
31727 (admin-pubkey (local-file "key.pub"))
31728 (rc-file
31729 (gitolite-rc-file
31730 (umask #o0027)
31731 ;; Allow to set any configuration key
31732 (git-config-keys ".*")
31733 ;; Allow any text as a valid configuration value
31734 (unsafe-patt "^$")))))
31735 @end lisp
31736
31737 @deftp {Data Type} gitile-configuration
31738 Data type representing the configuration for @code{gitile-service-type}.
31739
31740 @table @asis
31741 @item @code{package} (default: @var{gitile})
31742 Gitile package to use.
31743
31744 @item @code{host} (default: @code{"localhost"})
31745 The host on which gitile is listening.
31746
31747 @item @code{port} (default: @code{8080})
31748 The port on which gitile is listening.
31749
31750 @item @code{database} (default: @code{"/var/lib/gitile/gitile-db.sql"})
31751 The location of the database.
31752
31753 @item @code{repositories} (default: @code{"/var/lib/gitolite/repositories"})
31754 The location of the repositories. Note that only public repositories will
31755 be shown by Gitile. To make a repository public, add an empty
31756 @file{git-daemon-export-ok} file at the root of that repository.
31757
31758 @item @code{base-git-url}
31759 The base git url that will be used to show clone commands.
31760
31761 @item @code{index-title} (default: @code{"Index"})
31762 The page title for the index page that lists all the available repositories.
31763
31764 @item @code{intro} (default: @code{'()})
31765 The intro content, as a list of sxml expressions. This is shown above the list
31766 of repositories, on the index page.
31767
31768 @item @code{footer} (default: @code{'()})
31769 The footer content, as a list of sxml expressions. This is shown on every
31770 page served by Gitile.
31771
31772 @item @code{nginx-server-block}
31773 An nginx server block that will be extended and used as a reverse proxy by
31774 Gitile to serve its pages, and as a normal web server to serve its assets.
31775
31776 You can use this block to add more custom URLs to your domain, such as a
31777 @code{/git/} URL for anonymous clones, or serving any other files you would
31778 like to serve.
31779 @end table
31780 @end deftp
31781
31782
31783 @node Game Services
31784 @subsection Game Services
31785
31786 @subsubheading The Battle for Wesnoth Service
31787 @cindex wesnothd
31788 @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
31789 based tactical strategy game, with several single player campaigns, and
31790 multiplayer games (both networked and local).
31791
31792 @defvar {Scheme Variable} wesnothd-service-type
31793 Service type for the wesnothd service. Its value must be a
31794 @code{wesnothd-configuration} object. To run wesnothd in the default
31795 configuration, instantiate it as:
31796
31797 @lisp
31798 (service wesnothd-service-type)
31799 @end lisp
31800 @end defvar
31801
31802 @deftp {Data Type} wesnothd-configuration
31803 Data type representing the configuration of @command{wesnothd}.
31804
31805 @table @asis
31806 @item @code{package} (default: @code{wesnoth-server})
31807 The wesnoth server package to use.
31808
31809 @item @code{port} (default: @code{15000})
31810 The port to bind the server to.
31811 @end table
31812 @end deftp
31813
31814
31815 @node PAM Mount Service
31816 @subsection PAM Mount Service
31817 @cindex pam-mount
31818
31819 The @code{(gnu services pam-mount)} module provides a service allowing
31820 users to mount volumes when they log in. It should be able to mount any
31821 volume format supported by the system.
31822
31823 @defvar {Scheme Variable} pam-mount-service-type
31824 Service type for PAM Mount support.
31825 @end defvar
31826
31827 @deftp {Data Type} pam-mount-configuration
31828 Data type representing the configuration of PAM Mount.
31829
31830 It takes the following parameters:
31831
31832 @table @asis
31833 @item @code{rules}
31834 The configuration rules that will be used to generate
31835 @file{/etc/security/pam_mount.conf.xml}.
31836
31837 The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
31838 Guile Reference Manual}), and the default ones don't mount anything for
31839 anyone at login:
31840
31841 @lisp
31842 `((debug (@@ (enable "0")))
31843 (mntoptions (@@ (allow ,(string-join
31844 '("nosuid" "nodev" "loop"
31845 "encryption" "fsck" "nonempty"
31846 "allow_root" "allow_other")
31847 ","))))
31848 (mntoptions (@@ (require "nosuid,nodev")))
31849 (logout (@@ (wait "0")
31850 (hup "0")
31851 (term "no")
31852 (kill "no")))
31853 (mkmountpoint (@@ (enable "1")
31854 (remove "true"))))
31855 @end lisp
31856
31857 Some @code{volume} elements must be added to automatically mount volumes
31858 at login. Here's an example allowing the user @code{alice} to mount her
31859 encrypted @env{HOME} directory and allowing the user @code{bob} to mount
31860 the partition where he stores his data:
31861
31862 @lisp
31863 (define pam-mount-rules
31864 `((debug (@@ (enable "0")))
31865 (volume (@@ (user "alice")
31866 (fstype "crypt")
31867 (path "/dev/sda2")
31868 (mountpoint "/home/alice")))
31869 (volume (@@ (user "bob")
31870 (fstype "auto")
31871 (path "/dev/sdb3")
31872 (mountpoint "/home/bob/data")
31873 (options "defaults,autodefrag,compress")))
31874 (mntoptions (@@ (allow ,(string-join
31875 '("nosuid" "nodev" "loop"
31876 "encryption" "fsck" "nonempty"
31877 "allow_root" "allow_other")
31878 ","))))
31879 (mntoptions (@@ (require "nosuid,nodev")))
31880 (logout (@@ (wait "0")
31881 (hup "0")
31882 (term "no")
31883 (kill "no")))
31884 (mkmountpoint (@@ (enable "1")
31885 (remove "true")))))
31886
31887 (service pam-mount-service-type
31888 (pam-mount-configuration
31889 (rules pam-mount-rules)))
31890 @end lisp
31891
31892 The complete list of possible options can be found in the man page for
31893 @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
31894 @end table
31895 @end deftp
31896
31897
31898 @node Guix Services
31899 @subsection Guix Services
31900
31901 @subsubheading Guix Build Coordinator
31902 The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
31903 Coordinator} aids in distributing derivation builds among machines
31904 running an @dfn{agent}. The build daemon is still used to build the
31905 derivations, but the Guix Build Coordinator manages allocating builds
31906 and working with the results.
31907
31908 @quotation Note
31909 This service is considered experimental. Configuration options may be
31910 changed in a backwards-incompatible manner, and not all features have
31911 been thorougly tested.
31912 @end quotation
31913
31914 The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
31915 more connected @dfn{agent} processes. The coordinator process handles
31916 clients submitting builds, and allocating builds to agents. The agent
31917 processes talk to a build daemon to actually perform the builds, then
31918 send the results back to the coordinator.
31919
31920 There is a script to run the coordinator component of the Guix Build
31921 Coordinator, but the Guix service uses a custom Guile script instead, to
31922 provide better integration with G-expressions used in the configuration.
31923
31924 @defvar {Scheme Variable} guix-build-coordinator-service-type
31925 Service type for the Guix Build Coordinator. Its value must be a
31926 @code{guix-build-coordinator-configuration} object.
31927 @end defvar
31928
31929 @deftp {Data Type} guix-build-coordinator-configuration
31930 Data type representing the configuration of the Guix Build Coordinator.
31931
31932 @table @asis
31933 @item @code{package} (default: @code{guix-build-coordinator})
31934 The Guix Build Coordinator package to use.
31935
31936 @item @code{user} (default: @code{"guix-build-coordinator"})
31937 The system user to run the service as.
31938
31939 @item @code{group} (default: @code{"guix-build-coordinator"})
31940 The system group to run the service as.
31941
31942 @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
31943 The URI to use for the database.
31944
31945 @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
31946 The URI describing how to listen to requests from agent processes.
31947
31948 @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
31949 The URI describing how to listen to requests from clients. The client
31950 API allows submitting builds and currently isn't authenticated, so take
31951 care when configuring this value.
31952
31953 @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
31954 A G-expression for the allocation strategy to be used. This is a
31955 procedure that takes the datastore as an argument and populates the
31956 allocation plan in the database.
31957
31958 @item @code{hooks} (default: @var{'()})
31959 An association list of hooks. These provide a way to execute arbitrary
31960 code upon certain events, like a build result being processed.
31961
31962 @item @code{guile} (default: @code{guile-3.0-latest})
31963 The Guile package with which to run the Guix Build Coordinator.
31964
31965 @end table
31966 @end deftp
31967
31968 @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
31969 Service type for a Guix Build Coordinator agent. Its value must be a
31970 @code{guix-build-coordinator-agent-configuration} object.
31971 @end defvar
31972
31973 @deftp {Data Type} guix-build-coordinator-agent-configuration
31974 Data type representing the configuration a Guix Build Coordinator agent.
31975
31976 @table @asis
31977 @item @code{package} (default: @code{guix-build-coordinator})
31978 The Guix Build Coordinator package to use.
31979
31980 @item @code{user} (default: @code{"guix-build-coordinator-agent"})
31981 The system user to run the service as.
31982
31983 @item @code{coordinator} (default: @code{"http://localhost:8745"})
31984 The URI to use when connecting to the coordinator.
31985
31986 @item @code{authentication}
31987 Record describing how this agent should authenticate with the
31988 coordinator. Possible record types are described below.
31989
31990 @item @code{systems} (default: @code{#f})
31991 The systems for which this agent should fetch builds. The agent process
31992 will use the current system it's running on as the default.
31993
31994 @item @code{max-parallel-builds} (default: @code{1})
31995 The number of builds to perform in parallel.
31996
31997 @item @code{max-1min-load-average} (default: @code{#f})
31998 Load average value to look at when considering starting new builds, if
31999 the 1 minute load average exceeds this value, the agent will wait before
32000 starting new builds.
32001
32002 This will be unspecified if the value is @code{#f}, and the agent will
32003 use the number of cores reported by the system as the max 1 minute load
32004 average.
32005
32006 @item @code{derivation-substitute-urls} (default: @code{#f})
32007 URLs from which to attempt to fetch substitutes for derivations, if the
32008 derivations aren't already available.
32009
32010 @item @code{non-derivation-substitute-urls} (default: @code{#f})
32011 URLs from which to attempt to fetch substitutes for build inputs, if the
32012 input store items aren't already available.
32013
32014 @end table
32015 @end deftp
32016
32017 @deftp {Data Type} guix-build-coordinator-agent-password-auth
32018 Data type representing an agent authenticating with a coordinator via a
32019 UUID and password.
32020
32021 @table @asis
32022 @item @code{uuid}
32023 The UUID of the agent. This should be generated by the coordinator
32024 process, stored in the coordinator database, and used by the intended
32025 agent.
32026
32027 @item @code{password}
32028 The password to use when connecting to the coordinator.
32029
32030 @end table
32031 @end deftp
32032
32033 @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
32034 Data type representing an agent authenticating with a coordinator via a
32035 UUID and password read from a file.
32036
32037 @table @asis
32038 @item @code{uuid}
32039 The UUID of the agent. This should be generated by the coordinator
32040 process, stored in the coordinator database, and used by the intended
32041 agent.
32042
32043 @item @code{password-file}
32044 A file containing the password to use when connecting to the
32045 coordinator.
32046
32047 @end table
32048 @end deftp
32049
32050 @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
32051 Data type representing an agent authenticating with a coordinator via a
32052 dynamic auth token and agent name.
32053
32054 @table @asis
32055 @item @code{agent-name}
32056 Name of an agent, this is used to match up to an existing entry in the
32057 database if there is one. When no existing entry is found, a new entry
32058 is automatically added.
32059
32060 @item @code{token}
32061 Dynamic auth token, this is created and stored in the coordinator
32062 database, and is used by the agent to authenticate.
32063
32064 @end table
32065 @end deftp
32066
32067 @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
32068 Data type representing an agent authenticating with a coordinator via a
32069 dynamic auth token read from a file and agent name.
32070
32071 @table @asis
32072 @item @code{agent-name}
32073 Name of an agent, this is used to match up to an existing entry in the
32074 database if there is one. When no existing entry is found, a new entry
32075 is automatically added.
32076
32077 @item @code{token-file}
32078 File containing the dynamic auth token, this is created and stored in
32079 the coordinator database, and is used by the agent to authenticate.
32080
32081 @end table
32082 @end deftp
32083
32084 The Guix Build Coordinator package contains a script to query an
32085 instance of the Guix Data Service for derivations to build, and then
32086 submit builds for those derivations to the coordinator. The service
32087 type below assists in running this script. This is an additional tool
32088 that may be useful when building derivations contained within an
32089 instance of the Guix Data Service.
32090
32091 @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
32092 Service type for the
32093 guix-build-coordinator-queue-builds-from-guix-data-service script. Its
32094 value must be a @code{guix-build-coordinator-queue-builds-configuration}
32095 object.
32096 @end defvar
32097
32098 @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
32099 Data type representing the options to the queue builds from guix data
32100 service script.
32101
32102 @table @asis
32103 @item @code{package} (default: @code{guix-build-coordinator})
32104 The Guix Build Coordinator package to use.
32105
32106 @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
32107 The system user to run the service as.
32108
32109 @item @code{coordinator} (default: @code{"http://localhost:8746"})
32110 The URI to use when connecting to the coordinator.
32111
32112 @item @code{systems} (default: @code{#f})
32113 The systems for which to fetch derivations to build.
32114
32115 @item @code{systems-and-targets} (default: @code{#f})
32116 An association list of system and target pairs for which to fetch
32117 derivations to build.
32118
32119 @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
32120 The Guix Data Service instance from which to query to find out about
32121 derivations to build.
32122
32123 @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
32124 A file to record which commits have been processed, to avoid needlessly
32125 processing them again if the service is restarted.
32126
32127 @end table
32128 @end deftp
32129
32130 @subsubheading Guix Data Service
32131 The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
32132 and provides data about GNU Guix. This includes information about
32133 packages, derivations and lint warnings.
32134
32135 The data is stored in a PostgreSQL database, and available through a web
32136 interface.
32137
32138 @defvar {Scheme Variable} guix-data-service-type
32139 Service type for the Guix Data Service. Its value must be a
32140 @code{guix-data-service-configuration} object. The service optionally
32141 extends the getmail service, as the guix-commits mailing list is used to
32142 find out about changes in the Guix git repository.
32143 @end defvar
32144
32145 @deftp {Data Type} guix-data-service-configuration
32146 Data type representing the configuration of the Guix Data Service.
32147
32148 @table @asis
32149 @item @code{package} (default: @code{guix-data-service})
32150 The Guix Data Service package to use.
32151
32152 @item @code{user} (default: @code{"guix-data-service"})
32153 The system user to run the service as.
32154
32155 @item @code{group} (default: @code{"guix-data-service"})
32156 The system group to run the service as.
32157
32158 @item @code{port} (default: @code{8765})
32159 The port to bind the web service to.
32160
32161 @item @code{host} (default: @code{"127.0.0.1"})
32162 The host to bind the web service to.
32163
32164 @item @code{getmail-idle-mailboxes} (default: @code{#f})
32165 If set, this is the list of mailboxes that the getmail service will be
32166 configured to listen to.
32167
32168 @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
32169 If set, this is the @code{getmail-retriever-configuration} object with
32170 which to configure getmail to fetch mail from the guix-commits mailing
32171 list.
32172
32173 @item @code{extra-options} (default: @var{'()})
32174 Extra command line options for @code{guix-data-service}.
32175
32176 @item @code{extra-process-jobs-options} (default: @var{'()})
32177 Extra command line options for @code{guix-data-service-process-jobs}.
32178
32179 @end table
32180 @end deftp
32181
32182 @node Linux Services
32183 @subsection Linux Services
32184
32185 @cindex oom
32186 @cindex out of memory killer
32187 @cindex earlyoom
32188 @cindex early out of memory daemon
32189 @subsubheading Early OOM Service
32190
32191 @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
32192 Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
32193 space and provides a more responsive and configurable alternative to the
32194 in-kernel OOM killer. It is useful to prevent the system from becoming
32195 unresponsive when it runs out of memory.
32196
32197 @deffn {Scheme Variable} earlyoom-service-type
32198 The service type for running @command{earlyoom}, the Early OOM daemon.
32199 Its value must be a @code{earlyoom-configuration} object, described
32200 below. The service can be instantiated in its default configuration
32201 with:
32202
32203 @lisp
32204 (service earlyoom-service-type)
32205 @end lisp
32206 @end deffn
32207
32208 @deftp {Data Type} earlyoom-configuration
32209 This is the configuration record for the @code{earlyoom-service-type}.
32210
32211 @table @asis
32212 @item @code{earlyoom} (default: @var{earlyoom})
32213 The Earlyoom package to use.
32214
32215 @item @code{minimum-available-memory} (default: @code{10})
32216 The threshold for the minimum @emph{available} memory, in percentages.
32217
32218 @item @code{minimum-free-swap} (default: @code{10})
32219 The threshold for the minimum free swap memory, in percentages.
32220
32221 @item @code{prefer-regexp} (default: @code{#f})
32222 A regular expression (as a string) to match the names of the processes
32223 that should be preferably killed.
32224
32225 @item @code{avoid-regexp} (default: @code{#f})
32226 A regular expression (as a string) to match the names of the processes
32227 that should @emph{not} be killed.
32228
32229 @item @code{memory-report-interval} (default: @code{0})
32230 The interval in seconds at which a memory report is printed. It is
32231 disabled by default.
32232
32233 @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
32234 A boolean indicating whether the positive adjustments set in
32235 @file{/proc/*/oom_score_adj} should be ignored.
32236
32237 @item @code{show-debug-messages?} (default: @code{#f})
32238 A boolean indicating whether debug messages should be printed. The logs
32239 are saved at @file{/var/log/earlyoom.log}.
32240
32241 @item @code{send-notification-command} (default: @code{#f})
32242 This can be used to provide a custom command used for sending
32243 notifications.
32244 @end table
32245 @end deftp
32246
32247 @cindex modprobe
32248 @cindex kernel module loader
32249 @subsubheading Kernel Module Loader Service
32250
32251 The kernel module loader service allows one to load loadable kernel
32252 modules at boot. This is especially useful for modules that don't
32253 autoload and need to be manually loaded, as is the case with
32254 @code{ddcci}.
32255
32256 @deffn {Scheme Variable} kernel-module-loader-service-type
32257 The service type for loading loadable kernel modules at boot with
32258 @command{modprobe}. Its value must be a list of strings representing
32259 module names. For example loading the drivers provided by
32260 @code{ddcci-driver-linux}, in debugging mode by passing some module
32261 parameters, can be done as follow:
32262
32263 @lisp
32264 (use-modules (gnu) (gnu services))
32265 (use-package-modules linux)
32266 (use-service-modules linux)
32267
32268 (define ddcci-config
32269 (plain-file "ddcci.conf"
32270 "options ddcci dyndbg delay=120"))
32271
32272 (operating-system
32273 ...
32274 (services (cons* (service kernel-module-loader-service-type
32275 '("ddcci" "ddcci_backlight"))
32276 (simple-service 'ddcci-config etc-service-type
32277 (list `("modprobe.d/ddcci.conf"
32278 ,ddcci-config)))
32279 %base-services))
32280 (kernel-loadable-modules (list ddcci-driver-linux)))
32281 @end lisp
32282 @end deffn
32283
32284 @cindex rasdaemon
32285 @cindex Platform Reliability, Availability and Serviceability daemon
32286 @subsubheading Rasdaemon Service
32287
32288 The Rasdaemon service provides a daemon which monitors platform
32289 @acronym{RAS, Reliability@comma{} Availability@comma{} and Serviceability} reports from
32290 Linux kernel trace events, logging them to syslogd.
32291
32292 Reliability, Availability and Serviceability is a concept used on servers meant
32293 to measure their robustness.
32294
32295 @strong{Relability} is the probability that a system will produce correct
32296 outputs:
32297
32298 @itemize @bullet
32299 @item Generally measured as Mean Time Between Failures (MTBF), and
32300 @item Enhanced by features that help to avoid, detect and repair hardware
32301 faults
32302 @end itemize
32303
32304 @strong{Availability} is the probability that a system is operational at a
32305 given time:
32306
32307 @itemize @bullet
32308 @item Generally measured as a percentage of downtime per a period of time, and
32309 @item Often uses mechanisms to detect and correct hardware faults in runtime.
32310 @end itemize
32311
32312 @strong{Serviceability} is the simplicity and speed with which a system can be
32313 repaired or maintained:
32314
32315 @itemize @bullet
32316 @item Generally measured on Mean Time Between Repair (MTBR).
32317 @end itemize
32318
32319
32320 Among the monitoring measures, the most usual ones include:
32321
32322 @itemize @bullet
32323 @item CPU – detect errors at instruction execution and at L1/L2/L3 caches;
32324 @item Memory – add error correction logic (ECC) to detect and correct errors;
32325 @item I/O – add CRC checksums for transferred data;
32326 @item Storage – RAID, journal file systems, checksums, Self-Monitoring,
32327 Analysis and Reporting Technology (SMART).
32328 @end itemize
32329
32330 By monitoring the number of occurrences of error detections, it is possible to
32331 identify if the probability of hardware errors is increasing, and, on such
32332 case, do a preventive maintenance to replace a degraded component while those
32333 errors are correctable.
32334
32335 For detailed information about the types of error events gathered and how to
32336 make sense of them, see the kernel administrator's guide at
32337 @url{https://www.kernel.org/doc/html/latest/admin-guide/ras.html}.
32338
32339 @defvr {Scheme Variable} rasdaemon-service-type
32340 Service type for the @command{rasdaemon} service. It accepts a
32341 @code{rasdaemon-configuration} object. Instantiating like
32342
32343 @lisp
32344 (service rasdaemon-service-type)
32345 @end lisp
32346
32347 will load with a default configuration, which monitors all events and logs to
32348 syslogd.
32349 @end defvr
32350
32351 @deftp {Data Type} rasdaemon-configuration
32352 The data type representing the configuration of @command{rasdaemon}.
32353
32354 @table @asis
32355 @item @code{record?} (default: @code{#f})
32356
32357 A boolean indicating whether to record the events in an SQLite database. This
32358 provides a more structured access to the information contained in the log file.
32359 The database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}.
32360
32361 @end table
32362 @end deftp
32363
32364 @cindex zram
32365 @cindex compressed swap
32366 @cindex Compressed RAM-based block devices
32367 @subsubheading Zram Device Service
32368
32369 The Zram device service provides a compressed swap device in system
32370 memory. The Linux Kernel documentation has more information about
32371 @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
32372 devices.
32373
32374 @deffn {Scheme Variable} zram-device-service-type
32375 This service creates the zram block device, formats it as swap and
32376 enables it as a swap device. The service's value is a
32377 @code{zram-device-configuration} record.
32378
32379 @deftp {Data Type} zram-device-configuration
32380 This is the data type representing the configuration for the zram-device
32381 service.
32382
32383 @table @asis
32384 @item @code{size} (default @code{"1G"})
32385 This is the amount of space you wish to provide for the zram device. It
32386 accepts a string and can be a number of bytes or use a suffix, eg.:
32387 @code{"512M"} or @code{1024000}.
32388 @item @code{compression-algorithm} (default @code{'lzo})
32389 This is the compression algorithm you wish to use. It is difficult to
32390 list all the possible compression options, but common ones supported by
32391 Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
32392 @item @code{memory-limit} (default @code{0})
32393 This is the maximum amount of memory which the zram device can use.
32394 Setting it to '0' disables the limit. While it is generally expected
32395 that compression will be 2:1, it is possible that uncompressable data
32396 can be written to swap and this is a method to limit how much memory can
32397 be used. It accepts a string and can be a number of bytes or use a
32398 suffix, eg.: @code{"2G"}.
32399 @item @code{priority} (default @code{-1})
32400 This is the priority of the swap device created from the zram device.
32401 @code{swapon} accepts values between -1 and 32767, with higher values
32402 indicating higher priority. Higher priority swap will generally be used
32403 first.
32404 @end table
32405
32406 @end deftp
32407 @end deffn
32408
32409 @node Hurd Services
32410 @subsection Hurd Services
32411
32412 @defvr {Scheme Variable} hurd-console-service-type
32413 This service starts the fancy @code{VGA} console client on the Hurd.
32414
32415 The service's value is a @code{hurd-console-configuration} record.
32416 @end defvr
32417
32418 @deftp {Data Type} hurd-console-configuration
32419 This is the data type representing the configuration for the
32420 hurd-console-service.
32421
32422 @table @asis
32423 @item @code{hurd} (default: @var{hurd})
32424 The Hurd package to use.
32425 @end table
32426 @end deftp
32427
32428 @defvr {Scheme Variable} hurd-getty-service-type
32429 This service starts a tty using the Hurd @code{getty} program.
32430
32431 The service's value is a @code{hurd-getty-configuration} record.
32432 @end defvr
32433
32434 @deftp {Data Type} hurd-getty-configuration
32435 This is the data type representing the configuration for the
32436 hurd-getty-service.
32437
32438 @table @asis
32439 @item @code{hurd} (default: @var{hurd})
32440 The Hurd package to use.
32441
32442 @item @code{tty}
32443 The name of the console this Getty runs on---e.g., @code{"tty1"}.
32444
32445 @item @code{baud-rate} (default: @code{38400})
32446 An integer specifying the baud rate of the tty.
32447
32448 @end table
32449 @end deftp
32450
32451 @node Miscellaneous Services
32452 @subsection Miscellaneous Services
32453
32454 @cindex fingerprint
32455 @subsubheading Fingerprint Service
32456
32457 The @code{(gnu services authentication)} module provides a DBus service to
32458 read and identify fingerprints via a fingerprint sensor.
32459
32460 @defvr {Scheme Variable} fprintd-service-type
32461 The service type for @command{fprintd}, which provides the fingerprint
32462 reading capability.
32463
32464 @lisp
32465 (service fprintd-service-type)
32466 @end lisp
32467 @end defvr
32468
32469 @cindex sysctl
32470 @subsubheading System Control Service
32471
32472 The @code{(gnu services sysctl)} provides a service to configure kernel
32473 parameters at boot.
32474
32475 @defvr {Scheme Variable} sysctl-service-type
32476 The service type for @command{sysctl}, which modifies kernel parameters
32477 under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
32478 instantiated as:
32479
32480 @lisp
32481 (service sysctl-service-type
32482 (sysctl-configuration
32483 (settings '(("net.ipv4.ip_forward" . "1")))))
32484 @end lisp
32485
32486 Since @code{sysctl-service-type} is used in the default lists of
32487 services, @code{%base-services} and @code{%desktop-services}, you can
32488 use @code{modify-services} to change its configuration and add the
32489 kernel parameters that you want (@pxref{Service Reference,
32490 @code{modify-services}}).
32491
32492 @lisp
32493 (modify-services %base-services
32494 (sysctl-service-type config =>
32495 (sysctl-configuration
32496 (settings (append '(("net.ipv4.ip_forward" . "1"))
32497 %default-sysctl-settings)))))
32498 @end lisp
32499
32500 @end defvr
32501
32502 @deftp {Data Type} sysctl-configuration
32503 The data type representing the configuration of @command{sysctl}.
32504
32505 @table @asis
32506 @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
32507 The @command{sysctl} executable to use.
32508
32509 @item @code{settings} (default: @code{%default-sysctl-settings})
32510 An association list specifies kernel parameters and their values.
32511 @end table
32512 @end deftp
32513
32514 @defvr {Scheme Variable} %default-sysctl-settings
32515 An association list specifying the default @command{sysctl} parameters
32516 on Guix System.
32517 @end defvr
32518
32519 @cindex pcscd
32520 @subsubheading PC/SC Smart Card Daemon Service
32521
32522 The @code{(gnu services security-token)} module provides the following service
32523 to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
32524 daemon program for pcsc-lite and the MuscleCard framework. It is a resource
32525 manager that coordinates communications with smart card readers, smart cards
32526 and cryptographic tokens that are connected to the system.
32527
32528 @defvr {Scheme Variable} pcscd-service-type
32529 Service type for the @command{pcscd} service. Its value must be a
32530 @code{pcscd-configuration} object. To run pcscd in the default
32531 configuration, instantiate it as:
32532
32533 @lisp
32534 (service pcscd-service-type)
32535 @end lisp
32536 @end defvr
32537
32538 @deftp {Data Type} pcscd-configuration
32539 The data type representing the configuration of @command{pcscd}.
32540
32541 @table @asis
32542 @item @code{pcsc-lite} (default: @code{pcsc-lite})
32543 The pcsc-lite package that provides pcscd.
32544 @item @code{usb-drivers} (default: @code{(list ccid)})
32545 List of packages that provide USB drivers to pcscd. Drivers are expected to be
32546 under @file{pcsc/drivers} in the store directory of the package.
32547 @end table
32548 @end deftp
32549
32550 @cindex lirc
32551 @subsubheading Lirc Service
32552
32553 The @code{(gnu services lirc)} module provides the following service.
32554
32555 @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
32556 [#:device #f] [#:driver #f] [#:config-file #f] @
32557 [#:extra-options '()]
32558 Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
32559 decodes infrared signals from remote controls.
32560
32561 Optionally, @var{device}, @var{driver} and @var{config-file}
32562 (configuration file name) may be specified. See @command{lircd} manual
32563 for details.
32564
32565 Finally, @var{extra-options} is a list of additional command-line options
32566 passed to @command{lircd}.
32567 @end deffn
32568
32569 @cindex spice
32570 @subsubheading Spice Service
32571
32572 The @code{(gnu services spice)} module provides the following service.
32573
32574 @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
32575 Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
32576 that enables sharing the clipboard with a vm and setting the guest display
32577 resolution when the graphical console window resizes.
32578 @end deffn
32579
32580 @cindex inputattach
32581 @subsubheading inputattach Service
32582
32583 @cindex tablet input, for Xorg
32584 @cindex touchscreen input, for Xorg
32585 The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
32586 use input devices such as Wacom tablets, touchscreens, or joysticks with the
32587 Xorg display server.
32588
32589 @deffn {Scheme Variable} inputattach-service-type
32590 Type of a service that runs @command{inputattach} on a device and
32591 dispatches events from it.
32592 @end deffn
32593
32594 @deftp {Data Type} inputattach-configuration
32595 @table @asis
32596 @item @code{device-type} (default: @code{"wacom"})
32597 The type of device to connect to. Run @command{inputattach --help}, from the
32598 @code{inputattach} package, to see the list of supported device types.
32599
32600 @item @code{device} (default: @code{"/dev/ttyS0"})
32601 The device file to connect to the device.
32602
32603 @item @code{baud-rate} (default: @code{#f})
32604 Baud rate to use for the serial connection.
32605 Should be a number or @code{#f}.
32606
32607 @item @code{log-file} (default: @code{#f})
32608 If true, this must be the name of a file to log messages to.
32609 @end table
32610 @end deftp
32611
32612 @subsubheading Dictionary Service
32613 @cindex dictionary
32614 The @code{(gnu services dict)} module provides the following service:
32615
32616 @defvr {Scheme Variable} dicod-service-type
32617 This is the type of the service that runs the @command{dicod} daemon, an
32618 implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
32619 @end defvr
32620
32621 @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
32622 Return a service that runs the @command{dicod} daemon, an implementation
32623 of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
32624
32625 The optional @var{config} argument specifies the configuration for
32626 @command{dicod}, which should be a @code{<dicod-configuration>} object, by
32627 default it serves the GNU Collaborative International Dictionary of English.
32628
32629 You can add @command{open localhost} to your @file{~/.dico} file to make
32630 @code{localhost} the default server for @command{dico} client
32631 (@pxref{Initialization File,,, dico, GNU Dico Manual}).
32632 @end deffn
32633
32634 @deftp {Data Type} dicod-configuration
32635 Data type representing the configuration of dicod.
32636
32637 @table @asis
32638 @item @code{dico} (default: @var{dico})
32639 Package object of the GNU Dico dictionary server.
32640
32641 @item @code{interfaces} (default: @var{'("localhost")})
32642 This is the list of IP addresses and ports and possibly socket file
32643 names to listen to (@pxref{Server Settings, @code{listen} directive,,
32644 dico, GNU Dico Manual}).
32645
32646 @item @code{handlers} (default: @var{'()})
32647 List of @code{<dicod-handler>} objects denoting handlers (module instances).
32648
32649 @item @code{databases} (default: @var{(list %dicod-database:gcide)})
32650 List of @code{<dicod-database>} objects denoting dictionaries to be served.
32651 @end table
32652 @end deftp
32653
32654 @deftp {Data Type} dicod-handler
32655 Data type representing a dictionary handler (module instance).
32656
32657 @table @asis
32658 @item @code{name}
32659 Name of the handler (module instance).
32660
32661 @item @code{module} (default: @var{#f})
32662 Name of the dicod module of the handler (instance). If it is @code{#f},
32663 the module has the same name as the handler.
32664 (@pxref{Modules,,, dico, GNU Dico Manual}).
32665
32666 @item @code{options}
32667 List of strings or gexps representing the arguments for the module handler
32668 @end table
32669 @end deftp
32670
32671 @deftp {Data Type} dicod-database
32672 Data type representing a dictionary database.
32673
32674 @table @asis
32675 @item @code{name}
32676 Name of the database, will be used in DICT commands.
32677
32678 @item @code{handler}
32679 Name of the dicod handler (module instance) used by this database
32680 (@pxref{Handlers,,, dico, GNU Dico Manual}).
32681
32682 @item @code{complex?} (default: @var{#f})
32683 Whether the database configuration complex. The complex configuration
32684 will need a corresponding @code{<dicod-handler>} object, otherwise not.
32685
32686 @item @code{options}
32687 List of strings or gexps representing the arguments for the database
32688 (@pxref{Databases,,, dico, GNU Dico Manual}).
32689 @end table
32690 @end deftp
32691
32692 @defvr {Scheme Variable} %dicod-database:gcide
32693 A @code{<dicod-database>} object serving the GNU Collaborative International
32694 Dictionary of English using the @code{gcide} package.
32695 @end defvr
32696
32697 The following is an example @code{dicod-service} configuration.
32698
32699 @lisp
32700 (dicod-service #:config
32701 (dicod-configuration
32702 (handlers (list (dicod-handler
32703 (name "wordnet")
32704 (module "dictorg")
32705 (options
32706 (list #~(string-append "dbdir=" #$wordnet))))))
32707 (databases (list (dicod-database
32708 (name "wordnet")
32709 (complex? #t)
32710 (handler "wordnet")
32711 (options '("database=wn")))
32712 %dicod-database:gcide))))
32713 @end lisp
32714
32715 @cindex Docker
32716 @subsubheading Docker Service
32717
32718 The @code{(gnu services docker)} module provides the following services.
32719
32720 @defvr {Scheme Variable} docker-service-type
32721
32722 This is the type of the service that runs @url{https://www.docker.com,Docker},
32723 a daemon that can execute application bundles (sometimes referred to as
32724 ``containers'') in isolated environments.
32725
32726 @end defvr
32727
32728 @deftp {Data Type} docker-configuration
32729 This is the data type representing the configuration of Docker and Containerd.
32730
32731 @table @asis
32732
32733 @item @code{docker} (default: @code{docker})
32734 The Docker daemon package to use.
32735
32736 @item @code{docker-cli} (default: @code{docker-cli})
32737 The Docker client package to use.
32738
32739 @item @code{containerd} (default: @var{containerd})
32740 The Containerd package to use.
32741
32742 @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
32743 The Docker user-land networking proxy package to use.
32744
32745 @item @code{enable-proxy?} (default @code{#t})
32746 Enable or disable the use of the Docker user-land networking proxy.
32747
32748 @item @code{debug?} (default @code{#f})
32749 Enable or disable debug output.
32750
32751 @item @code{enable-iptables?} (default @code{#t})
32752 Enable or disable the addition of iptables rules.
32753
32754 @end table
32755 @end deftp
32756
32757 @cindex Singularity, container service
32758 @defvr {Scheme Variable} singularity-service-type
32759 This is the type of the service that allows you to run
32760 @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
32761 create and run application bundles (aka. ``containers''). The value for this
32762 service is the Singularity package to use.
32763
32764 The service does not install a daemon; instead, it installs helper programs as
32765 setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
32766 @command{singularity run} and similar commands.
32767 @end defvr
32768
32769 @cindex Audit
32770 @subsubheading Auditd Service
32771
32772 The @code{(gnu services auditd)} module provides the following service.
32773
32774 @defvr {Scheme Variable} auditd-service-type
32775
32776 This is the type of the service that runs
32777 @url{https://people.redhat.com/sgrubb/audit/,auditd},
32778 a daemon that tracks security-relevant information on your system.
32779
32780 Examples of things that can be tracked:
32781
32782 @enumerate
32783 @item
32784 File accesses
32785 @item
32786 System calls
32787 @item
32788 Invoked commands
32789 @item
32790 Failed login attempts
32791 @item
32792 Firewall filtering
32793 @item
32794 Network access
32795 @end enumerate
32796
32797 @command{auditctl} from the @code{audit} package can be used in order
32798 to add or remove events to be tracked (until the next reboot).
32799 In order to permanently track events, put the command line arguments
32800 of auditctl into a file called @code{audit.rules} in the configuration
32801 directory (see below).
32802 @command{aureport} from the @code{audit} package can be used in order
32803 to view a report of all recorded events.
32804 The audit daemon by default logs into the file
32805 @file{/var/log/audit.log}.
32806
32807 @end defvr
32808
32809 @deftp {Data Type} auditd-configuration
32810 This is the data type representing the configuration of auditd.
32811
32812 @table @asis
32813
32814 @item @code{audit} (default: @code{audit})
32815 The audit package to use.
32816
32817 @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
32818 The directory containing the configuration file for the audit package, which
32819 must be named @code{auditd.conf}, and optionally some audit rules to
32820 instantiate on startup.
32821
32822 @end table
32823 @end deftp
32824
32825 @cindex rshiny
32826 @subsubheading R-Shiny service
32827
32828 The @code{(gnu services science)} module provides the following service.
32829
32830 @defvr {Scheme Variable} rshiny-service-type
32831
32832 This is a type of service which is used to run a webapp created with
32833 @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
32834 variable and runs the provided script to call @code{runApp}.
32835
32836 @deftp {Data Type} rshiny-configuration
32837 This is the data type representing the configuration of rshiny.
32838
32839 @table @asis
32840
32841 @item @code{package} (default: @code{r-shiny})
32842 The package to use.
32843
32844 @item @code{binary} (defaunlt @code{"rshiny"})
32845 The name of the binary or shell script located at @code{package/bin/} to
32846 run when the service is run.
32847
32848 The common way to create this file is as follows:
32849
32850 @lisp
32851 @dots{}
32852 (let* ((out (assoc-ref %outputs "out"))
32853 (targetdir (string-append out "/share/" ,name))
32854 (app (string-append out "/bin/" ,name))
32855 (Rbin (string-append (assoc-ref %build-inputs "r-min")
32856 "/bin/Rscript")))
32857 ;; @dots{}
32858 (mkdir-p (string-append out "/bin"))
32859 (call-with-output-file app
32860 (lambda (port)
32861 (format port
32862 "#!~a
32863 library(shiny)
32864 setwd(\"~a\")
32865 runApp(launch.browser=0, port=4202)~%\n"
32866 Rbin targetdir))))
32867 @end lisp
32868
32869 @end table
32870 @end deftp
32871 @end defvr
32872
32873 @cindex Nix
32874 @subsubheading Nix service
32875
32876 The @code{(gnu services nix)} module provides the following service.
32877
32878 @defvr {Scheme Variable} nix-service-type
32879
32880 This is the type of the service that runs build daemon of the
32881 @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
32882 how to use it:
32883
32884 @lisp
32885 (use-modules (gnu))
32886 (use-service-modules nix)
32887 (use-package-modules package-management)
32888
32889 (operating-system
32890 ;; @dots{}
32891 (packages (append (list nix)
32892 %base-packages))
32893
32894 (services (append (list (service nix-service-type))
32895 %base-services)))
32896 @end lisp
32897
32898 After @command{guix system reconfigure} configure Nix for your user:
32899
32900 @itemize
32901 @item Add a Nix channel and update it. See
32902 @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
32903
32904 @item Create a symlink to your profile and activate Nix profile:
32905 @end itemize
32906
32907 @example
32908 $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
32909 $ source /run/current-system/profile/etc/profile.d/nix.sh
32910 @end example
32911
32912 @end defvr
32913
32914 @deftp {Data Type} nix-configuration
32915 This data type represents the configuration of the Nix daemon.
32916
32917 @table @asis
32918 @item @code{nix} (default: @code{nix})
32919 The Nix package to use.
32920
32921 @item @code{sandbox} (default: @code{#t})
32922 Specifies whether builds are sandboxed by default.
32923
32924 @item @code{build-sandbox-items} (default: @code{'()})
32925 This is a list of strings or objects appended to the
32926 @code{build-sandbox-items} field of the configuration file.
32927
32928 @item @code{extra-config} (default: @code{'()})
32929 This is a list of strings or objects appended to the configuration file.
32930 It is used to pass extra text to be added verbatim to the configuration
32931 file.
32932
32933 @item @code{extra-options} (default: @code{'()})
32934 Extra command line options for @code{nix-service-type}.
32935 @end table
32936 @end deftp
32937
32938 @node Setuid Programs
32939 @section Setuid Programs
32940
32941 @cindex setuid programs
32942 Some programs need to run with ``root'' privileges, even when they are
32943 launched by unprivileged users. A notorious example is the
32944 @command{passwd} program, which users can run to change their
32945 password, and which needs to access the @file{/etc/passwd} and
32946 @file{/etc/shadow} files---something normally restricted to root, for
32947 obvious security reasons. To address that, these executables are
32948 @dfn{setuid-root}, meaning that they always run with root privileges
32949 (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
32950 for more info about the setuid mechanism).
32951
32952 The store itself @emph{cannot} contain setuid programs: that would be a
32953 security issue since any user on the system can write derivations that
32954 populate the store (@pxref{The Store}). Thus, a different mechanism is
32955 used: instead of changing the setuid bit directly on files that are in
32956 the store, we let the system administrator @emph{declare} which programs
32957 should be setuid root.
32958
32959 The @code{setuid-programs} field of an @code{operating-system}
32960 declaration contains a list of @code{<setuid-program>} denoting the
32961 names of programs to have a setuid or setgid bit set (@pxref{Using the
32962 Configuration System}). For instance, the @command{passwd} program,
32963 which is part of the Shadow package, with a setuid root can be
32964 designated like this:
32965
32966 @example
32967 (setuid-program
32968 (program (file-append #$shadow "/bin/passwd")))
32969 @end example
32970
32971 @deftp {Data Type} setuid-program
32972 This data type represents a program with a setuid or setgid bit set.
32973
32974 @table @asis
32975 @item @code{program}
32976 A file-like object having its setuid and/or setgid bit set.
32977
32978 @item @code{setuid?} (default: @code{#t})
32979 Whether to set user setuid bit.
32980
32981 @item @code{setgid?} (default: @code{#f})
32982 Whether to set group setgid bit.
32983
32984 @item @code{user} (default: @code{0})
32985 UID (integer) or user name (string) for the user owner of the program,
32986 defaults to root.
32987
32988 @item @code{group} (default: @code{0})
32989 GID (integer) goup name (string) for the group owner of the program,
32990 defaults to root.
32991
32992 @end table
32993 @end deftp
32994
32995 A default set of setuid programs is defined by the
32996 @code{%setuid-programs} variable of the @code{(gnu system)} module.
32997
32998 @defvr {Scheme Variable} %setuid-programs
32999 A list of @code{<setuid-program>} denoting common programs that are
33000 setuid-root.
33001
33002 The list includes commands such as @command{passwd}, @command{ping},
33003 @command{su}, and @command{sudo}.
33004 @end defvr
33005
33006 Under the hood, the actual setuid programs are created in the
33007 @file{/run/setuid-programs} directory at system activation time. The
33008 files in this directory refer to the ``real'' binaries, which are in the
33009 store.
33010
33011 @node X.509 Certificates
33012 @section X.509 Certificates
33013
33014 @cindex HTTPS, certificates
33015 @cindex X.509 certificates
33016 @cindex TLS
33017 Web servers available over HTTPS (that is, HTTP over the transport-layer
33018 security mechanism, TLS) send client programs an @dfn{X.509 certificate}
33019 that the client can then use to @emph{authenticate} the server. To do
33020 that, clients verify that the server's certificate is signed by a
33021 so-called @dfn{certificate authority} (CA). But to verify the CA's
33022 signature, clients must have first acquired the CA's certificate.
33023
33024 Web browsers such as GNU@tie{}IceCat include their own set of CA
33025 certificates, such that they are able to verify CA signatures
33026 out-of-the-box.
33027
33028 However, most other programs that can talk HTTPS---@command{wget},
33029 @command{git}, @command{w3m}, etc.---need to be told where CA
33030 certificates can be found.
33031
33032 @cindex @code{nss-certs}
33033 In Guix, this is done by adding a package that provides certificates
33034 to the @code{packages} field of the @code{operating-system} declaration
33035 (@pxref{operating-system Reference}). Guix includes one such package,
33036 @code{nss-certs}, which is a set of CA certificates provided as part of
33037 Mozilla's Network Security Services.
33038
33039 Note that it is @emph{not} part of @code{%base-packages}, so you need to
33040 explicitly add it. The @file{/etc/ssl/certs} directory, which is where
33041 most applications and libraries look for certificates by default, points
33042 to the certificates installed globally.
33043
33044 Unprivileged users, including users of Guix on a foreign distro,
33045 can also install their own certificate package in
33046 their profile. A number of environment variables need to be defined so
33047 that applications and libraries know where to find them. Namely, the
33048 OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
33049 variables. Some applications add their own environment variables; for
33050 instance, the Git version control system honors the certificate bundle
33051 pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
33052 would typically run something like:
33053
33054 @example
33055 guix install nss-certs
33056 export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
33057 export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
33058 export GIT_SSL_CAINFO="$SSL_CERT_FILE"
33059 @end example
33060
33061 As another example, R requires the @env{CURL_CA_BUNDLE} environment
33062 variable to point to a certificate bundle, so you would have to run
33063 something like this:
33064
33065 @example
33066 guix install nss-certs
33067 export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
33068 @end example
33069
33070 For other applications you may want to look up the required environment
33071 variable in the relevant documentation.
33072
33073
33074 @node Name Service Switch
33075 @section Name Service Switch
33076
33077 @cindex name service switch
33078 @cindex NSS
33079 The @code{(gnu system nss)} module provides bindings to the
33080 configuration file of the libc @dfn{name service switch} or @dfn{NSS}
33081 (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
33082 Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
33083 extended with new ``name'' lookup methods for system databases, which
33084 includes host names, service names, user accounts, and more (@pxref{Name
33085 Service Switch, System Databases and Name Service Switch,, libc, The GNU
33086 C Library Reference Manual}).
33087
33088 The NSS configuration specifies, for each system database, which lookup
33089 method is to be used, and how the various methods are chained
33090 together---for instance, under which circumstances NSS should try the
33091 next method in the list. The NSS configuration is given in the
33092 @code{name-service-switch} field of @code{operating-system} declarations
33093 (@pxref{operating-system Reference, @code{name-service-switch}}).
33094
33095 @cindex nss-mdns
33096 @cindex .local, host name lookup
33097 As an example, the declaration below configures the NSS to use the
33098 @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
33099 back-end}, which supports host name lookups over multicast DNS (mDNS)
33100 for host names ending in @code{.local}:
33101
33102 @lisp
33103 (name-service-switch
33104 (hosts (list %files ;first, check /etc/hosts
33105
33106 ;; If the above did not succeed, try
33107 ;; with 'mdns_minimal'.
33108 (name-service
33109 (name "mdns_minimal")
33110
33111 ;; 'mdns_minimal' is authoritative for
33112 ;; '.local'. When it returns "not found",
33113 ;; no need to try the next methods.
33114 (reaction (lookup-specification
33115 (not-found => return))))
33116
33117 ;; Then fall back to DNS.
33118 (name-service
33119 (name "dns"))
33120
33121 ;; Finally, try with the "full" 'mdns'.
33122 (name-service
33123 (name "mdns")))))
33124 @end lisp
33125
33126 Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
33127 contains this configuration, so you will not have to type it if all you
33128 want is to have @code{.local} host lookup working.
33129
33130 Note that, in this case, in addition to setting the
33131 @code{name-service-switch} of the @code{operating-system} declaration,
33132 you also need to use @code{avahi-service-type} (@pxref{Networking Services,
33133 @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
33134 (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
33135 to the name service cache daemon (@pxref{Base Services,
33136 @code{nscd-service}}).
33137
33138 For convenience, the following variables provide typical NSS
33139 configurations.
33140
33141 @defvr {Scheme Variable} %default-nss
33142 This is the default name service switch configuration, a
33143 @code{name-service-switch} object.
33144 @end defvr
33145
33146 @defvr {Scheme Variable} %mdns-host-lookup-nss
33147 This is the name service switch configuration with support for host name
33148 lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
33149 @end defvr
33150
33151 The reference for name service switch configuration is given below. It
33152 is a direct mapping of the configuration file format of the C library , so
33153 please refer to the C library manual for more information (@pxref{NSS
33154 Configuration File,,, libc, The GNU C Library Reference Manual}).
33155 Compared to the configuration file format of libc NSS, it has the advantage
33156 not only of adding this warm parenthetic feel that we like, but also
33157 static checks: you will know about syntax errors and typos as soon as you
33158 run @command{guix system}.
33159
33160 @deftp {Data Type} name-service-switch
33161
33162 This is the data type representation the configuration of libc's name
33163 service switch (NSS). Each field below represents one of the supported
33164 system databases.
33165
33166 @table @code
33167 @item aliases
33168 @itemx ethers
33169 @itemx group
33170 @itemx gshadow
33171 @itemx hosts
33172 @itemx initgroups
33173 @itemx netgroup
33174 @itemx networks
33175 @itemx password
33176 @itemx public-key
33177 @itemx rpc
33178 @itemx services
33179 @itemx shadow
33180 The system databases handled by the NSS@. Each of these fields must be a
33181 list of @code{<name-service>} objects (see below).
33182 @end table
33183 @end deftp
33184
33185 @deftp {Data Type} name-service
33186
33187 This is the data type representing an actual name service and the
33188 associated lookup action.
33189
33190 @table @code
33191 @item name
33192 A string denoting the name service (@pxref{Services in the NSS
33193 configuration,,, libc, The GNU C Library Reference Manual}).
33194
33195 Note that name services listed here must be visible to nscd. This is
33196 achieved by passing the @code{#:name-services} argument to
33197 @code{nscd-service} the list of packages providing the needed name
33198 services (@pxref{Base Services, @code{nscd-service}}).
33199
33200 @item reaction
33201 An action specified using the @code{lookup-specification} macro
33202 (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
33203 Reference Manual}). For example:
33204
33205 @lisp
33206 (lookup-specification (unavailable => continue)
33207 (success => return))
33208 @end lisp
33209 @end table
33210 @end deftp
33211
33212 @node Initial RAM Disk
33213 @section Initial RAM Disk
33214
33215 @cindex initrd
33216 @cindex initial RAM disk
33217 For bootstrapping purposes, the Linux-Libre kernel is passed an
33218 @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
33219 root file system as well as an initialization script. The latter is
33220 responsible for mounting the real root file system, and for loading any
33221 kernel modules that may be needed to achieve that.
33222
33223 The @code{initrd-modules} field of an @code{operating-system}
33224 declaration allows you to specify Linux-libre kernel modules that must
33225 be available in the initrd. In particular, this is where you would list
33226 modules needed to actually drive the hard disk where your root partition
33227 is---although the default value of @code{initrd-modules} should cover
33228 most use cases. For example, assuming you need the @code{megaraid_sas}
33229 module in addition to the default modules to be able to access your root
33230 file system, you would write:
33231
33232 @lisp
33233 (operating-system
33234 ;; @dots{}
33235 (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
33236 @end lisp
33237
33238 @defvr {Scheme Variable} %base-initrd-modules
33239 This is the list of kernel modules included in the initrd by default.
33240 @end defvr
33241
33242 Furthermore, if you need lower-level customization, the @code{initrd}
33243 field of an @code{operating-system} declaration allows
33244 you to specify which initrd you would like to use. The @code{(gnu
33245 system linux-initrd)} module provides three ways to build an initrd: the
33246 high-level @code{base-initrd} procedure and the low-level
33247 @code{raw-initrd} and @code{expression->initrd} procedures.
33248
33249 The @code{base-initrd} procedure is intended to cover most common uses.
33250 For example, if you want to add a bunch of kernel modules to be loaded
33251 at boot time, you can define the @code{initrd} field of the operating
33252 system declaration like this:
33253
33254 @lisp
33255 (initrd (lambda (file-systems . rest)
33256 ;; Create a standard initrd but set up networking
33257 ;; with the parameters QEMU expects by default.
33258 (apply base-initrd file-systems
33259 #:qemu-networking? #t
33260 rest)))
33261 @end lisp
33262
33263 The @code{base-initrd} procedure also handles common use cases that
33264 involves using the system as a QEMU guest, or as a ``live'' system with
33265 volatile root file system.
33266
33267 The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
33268 Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
33269 such as trying to guess which kernel modules and packages should be included
33270 to the initrd. An example use of @code{raw-initrd} is when a user has
33271 a custom Linux kernel configuration and default kernel modules included by
33272 @code{base-initrd} are not available.
33273
33274 The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
33275 honors several options passed on the Linux kernel command line
33276 (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
33277 @code{-append} option of QEMU), notably:
33278
33279 @table @code
33280 @item --load=@var{boot}
33281 Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
33282 program, once it has mounted the root file system.
33283
33284 Guix uses this option to yield control to a boot program that runs the
33285 service activation programs and then spawns the GNU@tie{}Shepherd, the
33286 initialization system.
33287
33288 @item --root=@var{root}
33289 Mount @var{root} as the root file system. @var{root} can be a device
33290 name like @code{/dev/sda1}, a file system label, or a file system UUID.
33291 When unspecified, the device name from the root file system of the
33292 operating system declaration is used.
33293
33294 @item fsck.mode=@var{mode}
33295 Whether to check the @var{root} file system for errors before mounting
33296 it. @var{mode} is one of @code{skip} (never check), @code{force} (always
33297 check), or @code{auto} to respect the root file-system object's 'check?'
33298 setting (@pxref{File Systems}) and run a full scan only if the file system
33299 was not cleanly shut down.
33300
33301 @code{auto} is the default if this option is not present or if @var{mode}
33302 is not one of the above.
33303
33304 @item fsck.repair=@var{level}
33305 The level of repairs to perform automatically if errors are found in the
33306 @var{root} file system. @var{level} is one of @code{no} (do not write to
33307 @var{root} at all if possible), @code{yes} (repair as much as possible),
33308 or @code{preen} to repair problems considered safe to repair automatically.
33309
33310 @code{preen} is the default if this option is not present or if @var{level}
33311 is not one of the above.
33312
33313 @item --system=@var{system}
33314 Have @file{/run/booted-system} and @file{/run/current-system} point to
33315 @var{system}.
33316
33317 @item modprobe.blacklist=@var{modules}@dots{}
33318 @cindex module, black-listing
33319 @cindex black list, of kernel modules
33320 Instruct the initial RAM disk as well as the @command{modprobe} command
33321 (from the kmod package) to refuse to load @var{modules}. @var{modules}
33322 must be a comma-separated list of module names---e.g.,
33323 @code{usbkbd,9pnet}.
33324
33325 @item --repl
33326 Start a read-eval-print loop (REPL) from the initial RAM disk before it
33327 tries to load kernel modules and to mount the root file system. Our
33328 marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
33329 love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
33330 Manual}, for more information on Guile's REPL.
33331
33332 @end table
33333
33334 Now that you know all the features that initial RAM disks produced by
33335 @code{base-initrd} and @code{raw-initrd} provide,
33336 here is how to use it and customize it further.
33337
33338 @cindex initrd
33339 @cindex initial RAM disk
33340 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
33341 [#:linux-modules '()] [#:mapped-devices '()] @
33342 [#:keyboard-layout #f] @
33343 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
33344 Return a derivation that builds a raw initrd. @var{file-systems} is
33345 a list of file systems to be mounted by the initrd, possibly in addition to
33346 the root file system specified on the kernel command line via @option{--root}.
33347 @var{linux-modules} is a list of kernel modules to be loaded at boot time.
33348 @var{mapped-devices} is a list of device mappings to realize before
33349 @var{file-systems} are mounted (@pxref{Mapped Devices}).
33350 @var{helper-packages} is a list of packages to be copied in the initrd.
33351 It may
33352 include @code{e2fsck/static} or other packages needed by the initrd to check
33353 the root file system.
33354
33355 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
33356 the desired console keyboard layout. This is done before @var{mapped-devices}
33357 are set up and before @var{file-systems} are mounted such that, should the
33358 user need to enter a passphrase or use the REPL, this happens using the
33359 intended keyboard layout.
33360
33361 When @var{qemu-networking?} is true, set up networking with the standard QEMU
33362 parameters. When @var{virtio?} is true, load additional modules so that the
33363 initrd can be used as a QEMU guest with para-virtualized I/O drivers.
33364
33365 When @var{volatile-root?} is true, the root file system is writable but any changes
33366 to it are lost.
33367 @end deffn
33368
33369 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
33370 [#:mapped-devices '()] [#:keyboard-layout #f] @
33371 [#:qemu-networking? #f] [#:volatile-root? #f] @
33372 [#:linux-modules '()]
33373 Return as a file-like object a generic initrd, with kernel
33374 modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
33375 mounted by the initrd, possibly in addition to the root file system specified
33376 on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
33377 mappings to realize before @var{file-systems} are mounted.
33378
33379 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
33380 the desired console keyboard layout. This is done before @var{mapped-devices}
33381 are set up and before @var{file-systems} are mounted such that, should the
33382 user need to enter a passphrase or use the REPL, this happens using the
33383 intended keyboard layout.
33384
33385 @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
33386
33387 The initrd is automatically populated with all the kernel modules necessary
33388 for @var{file-systems} and for the given options. Additional kernel
33389 modules can be listed in @var{linux-modules}. They will be added to the initrd, and
33390 loaded at boot time in the order in which they appear.
33391 @end deffn
33392
33393 Needless to say, the initrds we produce and use embed a
33394 statically-linked Guile, and the initialization program is a Guile
33395 program. That gives a lot of flexibility. The
33396 @code{expression->initrd} procedure builds such an initrd, given the
33397 program to run in that initrd.
33398
33399 @deffn {Scheme Procedure} expression->initrd @var{exp} @
33400 [#:guile %guile-static-stripped] [#:name "guile-initrd"]
33401 Return as a file-like object a Linux initrd (a gzipped cpio archive)
33402 containing @var{guile} and that evaluates @var{exp}, a G-expression,
33403 upon booting. All the derivations referenced by @var{exp} are
33404 automatically copied to the initrd.
33405 @end deffn
33406
33407 @node Bootloader Configuration
33408 @section Bootloader Configuration
33409
33410 @cindex bootloader
33411 @cindex boot loader
33412
33413 The operating system supports multiple bootloaders. The bootloader is
33414 configured using @code{bootloader-configuration} declaration. All the
33415 fields of this structure are bootloader agnostic except for one field,
33416 @code{bootloader} that indicates the bootloader to be configured and
33417 installed.
33418
33419 Some of the bootloaders do not honor every field of
33420 @code{bootloader-configuration}. For instance, the extlinux
33421 bootloader does not support themes and thus ignores the @code{theme}
33422 field.
33423
33424 @deftp {Data Type} bootloader-configuration
33425 The type of a bootloader configuration declaration.
33426
33427 @table @asis
33428
33429 @item @code{bootloader}
33430 @cindex EFI, bootloader
33431 @cindex UEFI, bootloader
33432 @cindex BIOS, bootloader
33433 The bootloader to use, as a @code{bootloader} object. For now
33434 @code{grub-bootloader}, @code{grub-efi-bootloader},
33435 @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
33436 @code{u-boot-bootloader} are supported.
33437
33438 @cindex ARM, bootloaders
33439 @cindex AArch64, bootloaders
33440 Available bootloaders are described in @code{(gnu bootloader @dots{})}
33441 modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
33442 of bootloaders for a wide range of ARM and AArch64 systems, using the
33443 @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
33444
33445 @vindex grub-efi-bootloader
33446 @code{grub-efi-bootloader} allows to boot on modern systems using the
33447 @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
33448 use if the installation image contains a @file{/sys/firmware/efi} directory
33449 when you boot it on your system.
33450
33451 @vindex grub-bootloader
33452 @code{grub-bootloader} allows you to boot in particular Intel-based machines
33453 in ``legacy'' BIOS mode.
33454
33455 @vindex grub-efi-netboot-bootloader
33456 @code{grub-efi-netboot-bootloader} allows you to boot your system over network
33457 through TFTP@. In combination with an NFS root file system this allows you to
33458 build a diskless Guix system.
33459
33460 The installation of the @code{grub-efi-netboot-bootloader} generates the
33461 content of the TFTP root directory at @code{targets} (@pxref{Bootloader
33462 Configuration, @code{targets}}), to be served by a TFTP server. You may
33463 want to mount your TFTP server directories onto the @code{targets} to
33464 move the required files to the TFTP server automatically.
33465
33466 If you plan to use an NFS root file system as well (actually if you mount the
33467 store from an NFS share), then the TFTP server needs to serve the file
33468 @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
33469 image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
33470 initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
33471 files from the store will be accessed by GRUB through TFTP with their normal
33472 store path, for example as
33473 @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
33474
33475 Two symlinks are created to make this possible. For each target in the
33476 @code{targets} field, the first symlink is
33477 @samp{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
33478 @file{../../../boot/grub/grub.cfg}, where @samp{target} may be
33479 @file{/boot}. In this case the link is not leaving the served TFTP root
33480 directory, but otherwise it does. The second link is
33481 @samp{target}@file{/gnu/store} and points to @file{../gnu/store}. This
33482 link is leaving the served TFTP root directory.
33483
33484 The assumption behind all this is that you have an NFS server exporting
33485 the root file system for your Guix system, and additionally a TFTP
33486 server exporting your @code{targets} directories—usually a single
33487 @file{/boot}—from that same root file system for your Guix system. In
33488 this constellation the symlinks will work.
33489
33490 For other constellations you will have to program your own bootloader
33491 installer, which then takes care to make necessary files from the store
33492 accessible through TFTP, for example by copying them into the TFTP root
33493 directory to your @code{targets}.
33494
33495 It is important to note that symlinks pointing outside the TFTP root directory
33496 may need to be allowed in the configuration of your TFTP server. Further the
33497 store link exposes the whole store through TFTP@. Both points need to be
33498 considered carefully for security aspects.
33499
33500 Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
33501 NFS servers, you also need a properly configured DHCP server to make the booting
33502 over netboot possible. For all this we can currently only recommend you to look
33503 for instructions about @acronym{PXE, Preboot eXecution Environment}.
33504
33505 @item @code{targets}
33506 This is a list of strings denoting the targets onto which to install the
33507 bootloader.
33508
33509 The interpretation of targets depends on the bootloader in question.
33510 For @code{grub-bootloader}, for example, they should be device names
33511 understood by the bootloader @command{installer} command, such as
33512 @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
33513 GNU GRUB Manual}). For @code{grub-efi-bootloader}, they should be mount
33514 points of the EFI file system, usually @file{/boot/efi}. For
33515 @code{grub-efi-netboot-bootloader}, @code{targets} should be the mount
33516 points corresponding to TFTP root directories served by your TFTP
33517 server.
33518
33519 @item @code{menu-entries} (default: @code{()})
33520 A possibly empty list of @code{menu-entry} objects (see below), denoting
33521 entries to appear in the bootloader menu, in addition to the current
33522 system entry and the entry pointing to previous system generations.
33523
33524 @item @code{default-entry} (default: @code{0})
33525 The index of the default boot menu entry. Index 0 is for the entry of the
33526 current system.
33527
33528 @item @code{timeout} (default: @code{5})
33529 The number of seconds to wait for keyboard input before booting. Set to
33530 0 to boot immediately, and to -1 to wait indefinitely.
33531
33532 @cindex keyboard layout, for the bootloader
33533 @item @code{keyboard-layout} (default: @code{#f})
33534 If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
33535 layout, usually US@tie{}English (``qwerty'').
33536
33537 Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
33538 Layout}).
33539
33540 @quotation Note
33541 This option is currently ignored by bootloaders other than @code{grub} and
33542 @code{grub-efi}.
33543 @end quotation
33544
33545 @item @code{theme} (default: @var{#f})
33546 The bootloader theme object describing the theme to use. If no theme
33547 is provided, some bootloaders might use a default theme, that's true
33548 for GRUB.
33549
33550 @item @code{terminal-outputs} (default: @code{'(gfxterm)})
33551 The output terminals used for the bootloader boot menu, as a list of
33552 symbols. GRUB accepts the values: @code{console}, @code{serial},
33553 @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
33554 @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
33555 corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
33556 configuration,,, grub,GNU GRUB manual}).
33557
33558 @item @code{terminal-inputs} (default: @code{'()})
33559 The input terminals used for the bootloader boot menu, as a list of
33560 symbols. For GRUB, the default is the native platform terminal as
33561 determined at run-time. GRUB accepts the values: @code{console},
33562 @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
33563 @code{usb_keyboard}. This field corresponds to the GRUB variable
33564 @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
33565 manual}).
33566
33567 @item @code{serial-unit} (default: @code{#f})
33568 The serial unit used by the bootloader, as an integer from 0 to 3.
33569 For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
33570 corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
33571
33572 @item @code{serial-speed} (default: @code{#f})
33573 The speed of the serial interface, as an integer. For GRUB, the
33574 default value is chosen at run-time; currently GRUB chooses
33575 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
33576 @end table
33577
33578 @end deftp
33579
33580 @cindex dual boot
33581 @cindex boot menu
33582 Should you want to list additional boot menu entries @i{via} the
33583 @code{menu-entries} field above, you will need to create them with the
33584 @code{menu-entry} form. For example, imagine you want to be able to
33585 boot another distro (hard to imagine!), you can define a menu entry
33586 along these lines:
33587
33588 @lisp
33589 (menu-entry
33590 (label "The Other Distro")
33591 (linux "/boot/old/vmlinux-2.6.32")
33592 (linux-arguments '("root=/dev/sda2"))
33593 (initrd "/boot/old/initrd"))
33594 @end lisp
33595
33596 Details below.
33597
33598 @deftp {Data Type} menu-entry
33599 The type of an entry in the bootloader menu.
33600
33601 @table @asis
33602
33603 @item @code{label}
33604 The label to show in the menu---e.g., @code{"GNU"}.
33605
33606 @item @code{linux} (default: @code{#f})
33607 The Linux kernel image to boot, for example:
33608
33609 @lisp
33610 (file-append linux-libre "/bzImage")
33611 @end lisp
33612
33613 For GRUB, it is also possible to specify a device explicitly in the
33614 file path using GRUB's device naming convention (@pxref{Naming
33615 convention,,, grub, GNU GRUB manual}), for example:
33616
33617 @example
33618 "(hd0,msdos1)/boot/vmlinuz"
33619 @end example
33620
33621 If the device is specified explicitly as above, then the @code{device}
33622 field is ignored entirely.
33623
33624 @item @code{linux-arguments} (default: @code{()})
33625 The list of extra Linux kernel command-line arguments---e.g.,
33626 @code{("console=ttyS0")}.
33627
33628 @item @code{initrd} (default: @code{#f})
33629 A G-Expression or string denoting the file name of the initial RAM disk
33630 to use (@pxref{G-Expressions}).
33631
33632 @item @code{device} (default: @code{#f})
33633 The device where the kernel and initrd are to be found---i.e., for GRUB,
33634 @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
33635
33636 This may be a file system label (a string), a file system UUID (a
33637 bytevector, @pxref{File Systems}), or @code{#f}, in which case
33638 the bootloader will search the device containing the file specified by
33639 the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
33640 must @emph{not} be an OS device name such as @file{/dev/sda1}.
33641
33642 @item @code{multiboot-kernel} (default: @code{#f})
33643 The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
33644 manual}). When this field is set, a Multiboot menu-entry is generated.
33645 For example:
33646
33647 @lisp
33648 (file-append mach "/boot/gnumach")
33649 @end lisp
33650
33651 @item @code{multiboot-arguments} (default: @code{()})
33652 The list of extra command-line arguments for the multiboot-kernel.
33653
33654 @item @code{multiboot-modules} (default: @code{()})
33655 The list of commands for loading Multiboot modules. For example:
33656
33657 @lisp
33658 (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
33659 @dots{})
33660 (list (file-append libc "/lib/ld.so.1") "exec"
33661 @dots{}))
33662 @end lisp
33663
33664 @end table
33665 @end deftp
33666
33667 @cindex HDPI
33668 @cindex HiDPI
33669 @cindex resolution
33670 @c FIXME: Write documentation once it's stable.
33671 For now only GRUB has theme support. GRUB themes are created using
33672 the @code{grub-theme} form, which is not fully documented yet.
33673
33674 @deftp {Data Type} grub-theme
33675 Data type representing the configuration of the GRUB theme.
33676
33677 @table @asis
33678 @item @code{gfxmode} (default: @code{'("auto")})
33679 The GRUB @code{gfxmode} to set (a list of screen resolution strings,
33680 @pxref{gfxmode,,, grub, GNU GRUB manual}).
33681 @end table
33682 @end deftp
33683
33684 @deffn {Scheme Procedure} grub-theme
33685 Return the default GRUB theme used by the operating system if no
33686 @code{theme} field is specified in @code{bootloader-configuration}
33687 record.
33688
33689 It comes with a fancy background image displaying the GNU and Guix
33690 logos.
33691 @end deffn
33692
33693 For example, to override the default resolution, you may use something
33694 like
33695
33696 @lisp
33697 (bootloader
33698 (bootloader-configuration
33699 ;; @dots{}
33700 (theme (grub-theme
33701 (inherit (grub-theme))
33702 (gfxmode '("1024x786x32" "auto"))))))
33703 @end lisp
33704
33705 @node Invoking guix system
33706 @section Invoking @code{guix system}
33707
33708 Once you have written an operating system declaration as seen in the
33709 previous section, it can be @dfn{instantiated} using the @command{guix
33710 system} command. The synopsis is:
33711
33712 @example
33713 guix system @var{options}@dots{} @var{action} @var{file}
33714 @end example
33715
33716 @var{file} must be the name of a file containing an
33717 @code{operating-system} declaration. @var{action} specifies how the
33718 operating system is instantiated. Currently the following values are
33719 supported:
33720
33721 @table @code
33722 @item search
33723 Display available service type definitions that match the given regular
33724 expressions, sorted by relevance:
33725
33726 @cindex HDPI
33727 @cindex HiDPI
33728 @cindex resolution
33729 @example
33730 $ guix system search console
33731 name: console-fonts
33732 location: gnu/services/base.scm:806:2
33733 extends: shepherd-root
33734 description: Install the given fonts on the specified ttys (fonts are per
33735 + virtual console on GNU/Linux). The value of this service is a list of
33736 + tty/font pairs. The font can be the name of a font provided by the `kbd'
33737 + package or any valid argument to `setfont', as in this example:
33738 +
33739 + '(("tty1" . "LatGrkCyr-8x16")
33740 + ("tty2" . (file-append
33741 + font-tamzen
33742 + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
33743 + ("tty3" . (file-append
33744 + font-terminus
33745 + "/share/consolefonts/ter-132n"))) ; for HDPI
33746 relevance: 9
33747
33748 name: mingetty
33749 location: gnu/services/base.scm:1190:2
33750 extends: shepherd-root
33751 description: Provide console login using the `mingetty' program.
33752 relevance: 2
33753
33754 name: login
33755 location: gnu/services/base.scm:860:2
33756 extends: pam
33757 description: Provide a console log-in service as specified by its
33758 + configuration value, a `login-configuration' object.
33759 relevance: 2
33760
33761 @dots{}
33762 @end example
33763
33764 As for @command{guix package --search}, the result is written in
33765 @code{recutils} format, which makes it easy to filter the output
33766 (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
33767
33768 @item reconfigure
33769 Build the operating system described in @var{file}, activate it, and
33770 switch to it@footnote{This action (and the related actions
33771 @code{switch-generation} and @code{roll-back}) are usable only on
33772 systems already running Guix System.}.
33773
33774 @quotation Note
33775 @c The paragraph below refers to the problem discussed at
33776 @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
33777 It is highly recommended to run @command{guix pull} once before you run
33778 @command{guix system reconfigure} for the first time (@pxref{Invoking
33779 guix pull}). Failing to do that you would see an older version of Guix
33780 once @command{reconfigure} has completed.
33781 @end quotation
33782
33783 This effects all the configuration specified in @var{file}: user
33784 accounts, system services, global package list, setuid programs, etc.
33785 The command starts system services specified in @var{file} that are not
33786 currently running; if a service is currently running this command will
33787 arrange for it to be upgraded the next time it is stopped (e.g.@: by
33788 @code{herd stop X} or @code{herd restart X}).
33789
33790 This command creates a new generation whose number is one greater than
33791 the current generation (as reported by @command{guix system
33792 list-generations}). If that generation already exists, it will be
33793 overwritten. This behavior mirrors that of @command{guix package}
33794 (@pxref{Invoking guix package}).
33795
33796 It also adds a bootloader menu entry for the new OS configuration,
33797 ---unless @option{--no-bootloader} is passed. For GRUB, it moves
33798 entries for older configurations to a submenu, allowing you to choose
33799 an older system generation at boot time should you need it.
33800
33801 @cindex provenance tracking, of the operating system
33802 Upon completion, the new system is deployed under
33803 @file{/run/current-system}. This directory contains @dfn{provenance
33804 meta-data}: the list of channels in use (@pxref{Channels}) and
33805 @var{file} itself, when available. You can view it by running:
33806
33807 @example
33808 guix system describe
33809 @end example
33810
33811 This information is useful should you later want to inspect how this
33812 particular generation was built. In fact, assuming @var{file} is
33813 self-contained, you can later rebuild generation @var{n} of your
33814 operating system with:
33815
33816 @example
33817 guix time-machine \
33818 -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
33819 system reconfigure \
33820 /var/guix/profiles/system-@var{n}-link/configuration.scm
33821 @end example
33822
33823 You can think of it as some sort of built-in version control! Your
33824 system is not just a binary artifact: @emph{it carries its own source}.
33825 @xref{Service Reference, @code{provenance-service-type}}, for more
33826 information on provenance tracking.
33827
33828 By default, @command{reconfigure} @emph{prevents you from downgrading
33829 your system}, which could (re)introduce security vulnerabilities and
33830 also cause problems with ``stateful'' services such as database
33831 management systems. You can override that behavior by passing
33832 @option{--allow-downgrades}.
33833
33834 @item switch-generation
33835 @cindex generations
33836 Switch to an existing system generation. This action atomically
33837 switches the system profile to the specified system generation. It
33838 also rearranges the system's existing bootloader menu entries. It
33839 makes the menu entry for the specified system generation the default,
33840 and it moves the entries for the other generations to a submenu, if
33841 supported by the bootloader being used. The next time the system
33842 boots, it will use the specified system generation.
33843
33844 The bootloader itself is not being reinstalled when using this
33845 command. Thus, the installed bootloader is used with an updated
33846 configuration file.
33847
33848 The target generation can be specified explicitly by its generation
33849 number. For example, the following invocation would switch to system
33850 generation 7:
33851
33852 @example
33853 guix system switch-generation 7
33854 @end example
33855
33856 The target generation can also be specified relative to the current
33857 generation with the form @code{+N} or @code{-N}, where @code{+3} means
33858 ``3 generations ahead of the current generation,'' and @code{-1} means
33859 ``1 generation prior to the current generation.'' When specifying a
33860 negative value such as @code{-1}, you must precede it with @code{--} to
33861 prevent it from being parsed as an option. For example:
33862
33863 @example
33864 guix system switch-generation -- -1
33865 @end example
33866
33867 Currently, the effect of invoking this action is @emph{only} to switch
33868 the system profile to an existing generation and rearrange the
33869 bootloader menu entries. To actually start using the target system
33870 generation, you must reboot after running this action. In the future,
33871 it will be updated to do the same things as @command{reconfigure},
33872 like activating and deactivating services.
33873
33874 This action will fail if the specified generation does not exist.
33875
33876 @item roll-back
33877 @cindex rolling back
33878 Switch to the preceding system generation. The next time the system
33879 boots, it will use the preceding system generation. This is the inverse
33880 of @command{reconfigure}, and it is exactly the same as invoking
33881 @command{switch-generation} with an argument of @code{-1}.
33882
33883 Currently, as with @command{switch-generation}, you must reboot after
33884 running this action to actually start using the preceding system
33885 generation.
33886
33887 @item delete-generations
33888 @cindex deleting system generations
33889 @cindex saving space
33890 Delete system generations, making them candidates for garbage collection
33891 (@pxref{Invoking guix gc}, for information on how to run the ``garbage
33892 collector'').
33893
33894 This works in the same way as @samp{guix package --delete-generations}
33895 (@pxref{Invoking guix package, @option{--delete-generations}}). With no
33896 arguments, all system generations but the current one are deleted:
33897
33898 @example
33899 guix system delete-generations
33900 @end example
33901
33902 You can also select the generations you want to delete. The example below
33903 deletes all the system generations that are more than two month old:
33904
33905 @example
33906 guix system delete-generations 2m
33907 @end example
33908
33909 Running this command automatically reinstalls the bootloader with an updated
33910 list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
33911 longer lists the generations that have been deleted.
33912
33913 @item build
33914 Build the derivation of the operating system, which includes all the
33915 configuration files and programs needed to boot and run the system.
33916 This action does not actually install anything.
33917
33918 @item init
33919 Populate the given directory with all the files necessary to run the
33920 operating system specified in @var{file}. This is useful for first-time
33921 installations of Guix System. For instance:
33922
33923 @example
33924 guix system init my-os-config.scm /mnt
33925 @end example
33926
33927 copies to @file{/mnt} all the store items required by the configuration
33928 specified in @file{my-os-config.scm}. This includes configuration
33929 files, packages, and so on. It also creates other essential files
33930 needed for the system to operate correctly---e.g., the @file{/etc},
33931 @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
33932
33933 This command also installs bootloader on the targets specified in
33934 @file{my-os-config}, unless the @option{--no-bootloader} option was
33935 passed.
33936
33937 @item vm
33938 @cindex virtual machine
33939 @cindex VM
33940 @anchor{guix system vm}
33941 Build a virtual machine that contains the operating system declared in
33942 @var{file}, and return a script to run that virtual machine (VM).
33943
33944 @quotation Note
33945 The @code{vm} action and others below
33946 can use KVM support in the Linux-libre kernel. Specifically, if the
33947 machine has hardware virtualization support, the corresponding
33948 KVM kernel module should be loaded, and the @file{/dev/kvm} device node
33949 must exist and be readable and writable by the user and by the
33950 build users of the daemon (@pxref{Build Environment Setup}).
33951 @end quotation
33952
33953 Arguments given to the script are passed to QEMU as in the example
33954 below, which enables networking and requests 1@tie{}GiB of RAM for the
33955 emulated machine:
33956
33957 @example
33958 $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -nic user,model=virtio-net-pci
33959 @end example
33960
33961 The VM shares its store with the host system.
33962
33963 Additional file systems can be shared between the host and the VM using
33964 the @option{--share} and @option{--expose} command-line options: the former
33965 specifies a directory to be shared with write access, while the latter
33966 provides read-only access to the shared directory.
33967
33968 The example below creates a VM in which the user's home directory is
33969 accessible read-only, and where the @file{/exchange} directory is a
33970 read-write mapping of @file{$HOME/tmp} on the host:
33971
33972 @example
33973 guix system vm my-config.scm \
33974 --expose=$HOME --share=$HOME/tmp=/exchange
33975 @end example
33976
33977 On GNU/Linux, the default is to boot directly to the kernel; this has
33978 the advantage of requiring only a very tiny root disk image since the
33979 store of the host can then be mounted.
33980
33981 The @option{--full-boot} option forces a complete boot sequence, starting
33982 with the bootloader. This requires more disk space since a root image
33983 containing at least the kernel, initrd, and bootloader data files must
33984 be created. The @option{--image-size} option can be used to specify the
33985 size of the image.
33986
33987 @cindex System images, creation in various formats
33988 @cindex Creating system images in various formats
33989 @item image
33990 @itemx docker-image
33991 Return a virtual machine, disk image, or Docker image of the operating
33992 system declared in @var{file} that stands alone. By default,
33993 @command{guix system} estimates the size of the image needed to store
33994 the system, but you can use the @option{--image-size} option to specify
33995 a value. Docker images are built to contain exactly what they need, so
33996 the @option{--image-size} option is ignored in the case of
33997 @code{docker-image}.
33998
33999 @cindex image, creating disk images
34000 The @code{image} command can produce various image types. The
34001 image type can be selected using the @option{--image-type} option. It
34002 defaults to @code{efi-raw}. When its value is @code{iso9660}, the
34003 @option{--label} option can be used to specify a volume ID with
34004 @code{image}. By default, the root file system of a disk image is
34005 mounted non-volatile; the @option{--volatile} option can be provided to
34006 make it volatile instead. When using @code{image}, the bootloader
34007 installed on the generated image is taken from the provided
34008 @code{operating-system} definition. The following example demonstrates
34009 how to generate an image that uses the @code{grub-efi-bootloader}
34010 bootloader and boot it with QEMU:
34011
34012 @example
34013 image=$(guix system image --image-type=qcow2 \
34014 gnu/system/examples/lightweight-desktop.tmpl)
34015 cp $image /tmp/my-image.qcow2
34016 chmod +w /tmp/my-image.qcow2
34017 qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
34018 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
34019 @end example
34020
34021 When using the @code{efi-raw} image type, a raw disk image is produced;
34022 it can be copied as is to a USB stick, for instance. Assuming
34023 @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
34024 the image to it using the following command:
34025
34026 @example
34027 # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
34028 @end example
34029
34030 The @code{--list-image-types} command lists all the available image
34031 types.
34032
34033 @cindex creating virtual machine images
34034 When using the @code{qcow2} image type, the returned image is in qcow2
34035 format, which the QEMU emulator can efficiently use. @xref{Running Guix
34036 in a VM}, for more information on how to run the image in a virtual
34037 machine. The @code{grub-bootloader} bootloader is always used
34038 independently of what is declared in the @code{operating-system} file
34039 passed as argument. This is to make it easier to work with QEMU, which
34040 uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
34041 in the Master Boot Record (MBR).
34042
34043 @cindex docker-image, creating docker images
34044 When using @code{docker-image}, a Docker image is produced. Guix builds
34045 the image from scratch, not from a pre-existing Docker base image. As a
34046 result, it contains @emph{exactly} what you define in the operating
34047 system configuration file. You can then load the image and launch a
34048 Docker container using commands like the following:
34049
34050 @example
34051 image_id="$(docker load < guix-system-docker-image.tar.gz)"
34052 container_id="$(docker create $image_id)"
34053 docker start $container_id
34054 @end example
34055
34056 This command starts a new Docker container from the specified image. It
34057 will boot the Guix system in the usual manner, which means it will
34058 start any services you have defined in the operating system
34059 configuration. You can get an interactive shell running in the container
34060 using @command{docker exec}:
34061
34062 @example
34063 docker exec -ti $container_id /run/current-system/profile/bin/bash --login
34064 @end example
34065
34066 Depending on what you run in the Docker container, it
34067 may be necessary to give the container additional permissions. For
34068 example, if you intend to build software using Guix inside of the Docker
34069 container, you may need to pass the @option{--privileged} option to
34070 @code{docker create}.
34071
34072 Last, the @option{--network} option applies to @command{guix system
34073 docker-image}: it produces an image where network is supposedly shared
34074 with the host, and thus without services like nscd or NetworkManager.
34075
34076 @item container
34077 Return a script to run the operating system declared in @var{file}
34078 within a container. Containers are a set of lightweight isolation
34079 mechanisms provided by the kernel Linux-libre. Containers are
34080 substantially less resource-demanding than full virtual machines since
34081 the kernel, shared objects, and other resources can be shared with the
34082 host system; this also means they provide thinner isolation.
34083
34084 Currently, the script must be run as root in order to support more than
34085 a single user and group. The container shares its store with the host
34086 system.
34087
34088 As with the @code{vm} action (@pxref{guix system vm}), additional file
34089 systems to be shared between the host and container can be specified
34090 using the @option{--share} and @option{--expose} options:
34091
34092 @example
34093 guix system container my-config.scm \
34094 --expose=$HOME --share=$HOME/tmp=/exchange
34095 @end example
34096
34097 @quotation Note
34098 This option requires Linux-libre 3.19 or newer.
34099 @end quotation
34100
34101 @end table
34102
34103 @var{options} can contain any of the common build options (@pxref{Common
34104 Build Options}). In addition, @var{options} can contain one of the
34105 following:
34106
34107 @table @option
34108 @item --expression=@var{expr}
34109 @itemx -e @var{expr}
34110 Consider the operating-system @var{expr} evaluates to.
34111 This is an alternative to specifying a file which evaluates to an
34112 operating system.
34113 This is used to generate the Guix system installer @pxref{Building the
34114 Installation Image}).
34115
34116 @item --system=@var{system}
34117 @itemx -s @var{system}
34118 Attempt to build for @var{system} instead of the host system type.
34119 This works as per @command{guix build} (@pxref{Invoking guix build}).
34120
34121 @item --derivation
34122 @itemx -d
34123 Return the derivation file name of the given operating system without
34124 building anything.
34125
34126 @cindex provenance tracking, of the operating system
34127 @item --save-provenance
34128 As discussed above, @command{guix system init} and @command{guix system
34129 reconfigure} always save provenance information @i{via} a dedicated
34130 service (@pxref{Service Reference, @code{provenance-service-type}}).
34131 However, other commands don't do that by default. If you wish to, say,
34132 create a virtual machine image that contains provenance information, you
34133 can run:
34134
34135 @example
34136 guix system image -t qcow2 --save-provenance config.scm
34137 @end example
34138
34139 That way, the resulting image will effectively ``embed its own source''
34140 in the form of meta-data in @file{/run/current-system}. With that
34141 information, one can rebuild the image to make sure it really contains
34142 what it pretends to contain; or they could use that to derive a variant
34143 of the image.
34144
34145 @item --image-type=@var{type}
34146 @itemx -t @var{type}
34147 For the @code{image} action, create an image with given @var{type}.
34148
34149 When this option is omitted, @command{guix system} uses the
34150 @code{efi-raw} image type.
34151
34152 @cindex ISO-9660 format
34153 @cindex CD image format
34154 @cindex DVD image format
34155 @option{--image-type=iso9660} produces an ISO-9660 image, suitable
34156 for burning on CDs and DVDs.
34157
34158 @item --image-size=@var{size}
34159 For the @code{image} action, create an image of the given @var{size}.
34160 @var{size} may be a number of bytes, or it may include a unit as a
34161 suffix (@pxref{Block size, size specifications,, coreutils, GNU
34162 Coreutils}).
34163
34164 When this option is omitted, @command{guix system} computes an estimate
34165 of the image size as a function of the size of the system declared in
34166 @var{file}.
34167
34168 @item --network
34169 @itemx -N
34170 For the @code{container} action, allow containers to access the host network,
34171 that is, do not create a network namespace.
34172
34173 @item --root=@var{file}
34174 @itemx -r @var{file}
34175 Make @var{file} a symlink to the result, and register it as a garbage
34176 collector root.
34177
34178 @item --skip-checks
34179 Skip pre-installation safety checks.
34180
34181 By default, @command{guix system init} and @command{guix system
34182 reconfigure} perform safety checks: they make sure the file systems that
34183 appear in the @code{operating-system} declaration actually exist
34184 (@pxref{File Systems}), and that any Linux kernel modules that may be
34185 needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
34186 RAM Disk}). Passing this option skips these tests altogether.
34187
34188 @item --allow-downgrades
34189 Instruct @command{guix system reconfigure} to allow system downgrades.
34190
34191 By default, @command{reconfigure} prevents you from downgrading your
34192 system. It achieves that by comparing the provenance info of your
34193 system (shown by @command{guix system describe}) with that of your
34194 @command{guix} command (shown by @command{guix describe}). If the
34195 commits for @command{guix} are not descendants of those used for your
34196 system, @command{guix system reconfigure} errors out. Passing
34197 @option{--allow-downgrades} allows you to bypass these checks.
34198
34199 @quotation Note
34200 Make sure you understand its security implications before using
34201 @option{--allow-downgrades}.
34202 @end quotation
34203
34204 @cindex on-error
34205 @cindex on-error strategy
34206 @cindex error strategy
34207 @item --on-error=@var{strategy}
34208 Apply @var{strategy} when an error occurs when reading @var{file}.
34209 @var{strategy} may be one of the following:
34210
34211 @table @code
34212 @item nothing-special
34213 Report the error concisely and exit. This is the default strategy.
34214
34215 @item backtrace
34216 Likewise, but also display a backtrace.
34217
34218 @item debug
34219 Report the error and enter Guile's debugger. From there, you can run
34220 commands such as @code{,bt} to get a backtrace, @code{,locals} to
34221 display local variable values, and more generally inspect the state of the
34222 program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
34223 a list of available debugging commands.
34224 @end table
34225 @end table
34226
34227 Once you have built, configured, re-configured, and re-re-configured
34228 your Guix installation, you may find it useful to list the operating
34229 system generations available on disk---and that you can choose from the
34230 bootloader boot menu:
34231
34232 @table @code
34233
34234 @item describe
34235 Describe the current system generation: its file name, the kernel and
34236 bootloader used, etc., as well as provenance information when available.
34237
34238 @item list-generations
34239 List a summary of each generation of the operating system available on
34240 disk, in a human-readable way. This is similar to the
34241 @option{--list-generations} option of @command{guix package}
34242 (@pxref{Invoking guix package}).
34243
34244 Optionally, one can specify a pattern, with the same syntax that is used
34245 in @command{guix package --list-generations}, to restrict the list of
34246 generations displayed. For instance, the following command displays
34247 generations that are up to 10 days old:
34248
34249 @example
34250 $ guix system list-generations 10d
34251 @end example
34252
34253 @end table
34254
34255 The @command{guix system} command has even more to offer! The following
34256 sub-commands allow you to visualize how your system services relate to
34257 each other:
34258
34259 @anchor{system-extension-graph}
34260 @table @code
34261
34262 @item extension-graph
34263 Emit to standard output the @dfn{service
34264 extension graph} of the operating system defined in @var{file}
34265 (@pxref{Service Composition}, for more information on service
34266 extensions). By default the output is in Dot/Graphviz format, but you
34267 can choose a different format with @option{--graph-backend}, as with
34268 @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
34269
34270 The command:
34271
34272 @example
34273 $ guix system extension-graph @var{file} | xdot -
34274 @end example
34275
34276 shows the extension relations among services.
34277
34278 @anchor{system-shepherd-graph}
34279 @item shepherd-graph
34280 Emit to standard output the @dfn{dependency
34281 graph} of shepherd services of the operating system defined in
34282 @var{file}. @xref{Shepherd Services}, for more information and for an
34283 example graph.
34284
34285 Again, the default output format is Dot/Graphviz, but you can pass
34286 @option{--graph-backend} to select a different one.
34287
34288 @end table
34289
34290 @node Invoking guix deploy
34291 @section Invoking @code{guix deploy}
34292
34293 We've already seen @code{operating-system} declarations used to manage a
34294 machine's configuration locally. Suppose you need to configure multiple
34295 machines, though---perhaps you're managing a service on the web that's
34296 comprised of several servers. @command{guix deploy} enables you to use those
34297 same @code{operating-system} declarations to manage multiple remote hosts at
34298 once as a logical ``deployment''.
34299
34300 @quotation Note
34301 The functionality described in this section is still under development
34302 and is subject to change. Get in touch with us on
34303 @email{guix-devel@@gnu.org}!
34304 @end quotation
34305
34306 @example
34307 guix deploy @var{file}
34308 @end example
34309
34310 Such an invocation will deploy the machines that the code within @var{file}
34311 evaluates to. As an example, @var{file} might contain a definition like this:
34312
34313 @lisp
34314 ;; This is a Guix deployment of a "bare bones" setup, with
34315 ;; no X11 display server, to a machine with an SSH daemon
34316 ;; listening on localhost:2222. A configuration such as this
34317 ;; may be appropriate for virtual machine with ports
34318 ;; forwarded to the host's loopback interface.
34319
34320 (use-service-modules networking ssh)
34321 (use-package-modules bootloaders)
34322
34323 (define %system
34324 (operating-system
34325 (host-name "gnu-deployed")
34326 (timezone "Etc/UTC")
34327 (bootloader (bootloader-configuration
34328 (bootloader grub-bootloader)
34329 (targets '("/dev/vda"))
34330 (terminal-outputs '(console))))
34331 (file-systems (cons (file-system
34332 (mount-point "/")
34333 (device "/dev/vda1")
34334 (type "ext4"))
34335 %base-file-systems))
34336 (services
34337 (append (list (service dhcp-client-service-type)
34338 (service openssh-service-type
34339 (openssh-configuration
34340 (permit-root-login #t)
34341 (allow-empty-passwords? #t))))
34342 %base-services))))
34343
34344 (list (machine
34345 (operating-system %system)
34346 (environment managed-host-environment-type)
34347 (configuration (machine-ssh-configuration
34348 (host-name "localhost")
34349 (system "x86_64-linux")
34350 (user "alice")
34351 (identity "./id_rsa")
34352 (port 2222)))))
34353 @end lisp
34354
34355 The file should evaluate to a list of @var{machine} objects. This example,
34356 upon being deployed, will create a new generation on the remote system
34357 realizing the @code{operating-system} declaration @code{%system}.
34358 @code{environment} and @code{configuration} specify how the machine should be
34359 provisioned---that is, how the computing resources should be created and
34360 managed. The above example does not create any resources, as a
34361 @code{'managed-host} is a machine that is already running the Guix system and
34362 available over the network. This is a particularly simple case; a more
34363 complex deployment may involve, for example, starting virtual machines through
34364 a Virtual Private Server (VPS) provider. In such a case, a different
34365 @var{environment} type would be used.
34366
34367 Do note that you first need to generate a key pair on the coordinator machine
34368 to allow the daemon to export signed archives of files from the store
34369 (@pxref{Invoking guix archive}), though this step is automatic on Guix
34370 System:
34371
34372 @example
34373 # guix archive --generate-key
34374 @end example
34375
34376 @noindent
34377 Each target machine must authorize the key of the master machine so that it
34378 accepts store items it receives from the coordinator:
34379
34380 @example
34381 # guix archive --authorize < coordinator-public-key.txt
34382 @end example
34383
34384 @code{user}, in this example, specifies the name of the user account to log in
34385 as to perform the deployment. Its default value is @code{root}, but root
34386 login over SSH may be forbidden in some cases. To work around this,
34387 @command{guix deploy} can log in as an unprivileged user and employ
34388 @code{sudo} to escalate privileges. This will only work if @code{sudo} is
34389 currently installed on the remote and can be invoked non-interactively as
34390 @code{user}. That is, the line in @code{sudoers} granting @code{user} the
34391 ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
34392 be accomplished with the following operating system configuration snippet:
34393
34394 @lisp
34395 (use-modules ...
34396 (gnu system)) ;for %sudoers-specification
34397
34398 (define %user "username")
34399
34400 (operating-system
34401 ...
34402 (sudoers-file
34403 (plain-file "sudoers"
34404 (string-append (plain-file-content %sudoers-specification)
34405 (format #f "~a ALL = NOPASSWD: ALL~%"
34406 %user)))))
34407
34408 @end lisp
34409
34410 For more information regarding the format of the @file{sudoers} file,
34411 consult @command{man sudoers}.
34412
34413 @deftp {Data Type} machine
34414 This is the data type representing a single machine in a heterogeneous Guix
34415 deployment.
34416
34417 @table @asis
34418 @item @code{operating-system}
34419 The object of the operating system configuration to deploy.
34420
34421 @item @code{environment}
34422 An @code{environment-type} describing how the machine should be provisioned.
34423
34424 @item @code{configuration} (default: @code{#f})
34425 An object describing the configuration for the machine's @code{environment}.
34426 If the @code{environment} has a default configuration, @code{#f} may be used.
34427 If @code{#f} is used for an environment with no default configuration,
34428 however, an error will be thrown.
34429 @end table
34430 @end deftp
34431
34432 @deftp {Data Type} machine-ssh-configuration
34433 This is the data type representing the SSH client parameters for a machine
34434 with an @code{environment} of @code{managed-host-environment-type}.
34435
34436 @table @asis
34437 @item @code{host-name}
34438 @item @code{build-locally?} (default: @code{#t})
34439 If false, system derivations will be built on the machine being deployed to.
34440 @item @code{system}
34441 The system type describing the architecture of the machine being deployed
34442 to---e.g., @code{"x86_64-linux"}.
34443 @item @code{authorize?} (default: @code{#t})
34444 If true, the coordinator's signing key will be added to the remote's ACL
34445 keyring.
34446 @item @code{port} (default: @code{22})
34447 @item @code{user} (default: @code{"root"})
34448 @item @code{identity} (default: @code{#f})
34449 If specified, the path to the SSH private key to use to authenticate with the
34450 remote host.
34451
34452 @item @code{host-key} (default: @code{#f})
34453 This should be the SSH host key of the machine, which looks like this:
34454
34455 @example
34456 ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
34457 @end example
34458
34459 When @code{host-key} is @code{#f}, the server is authenticated against
34460 the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
34461 client does.
34462
34463 @item @code{allow-downgrades?} (default: @code{#f})
34464 Whether to allow potential downgrades.
34465
34466 Like @command{guix system reconfigure}, @command{guix deploy} compares
34467 the channel commits currently deployed on the remote host (as returned
34468 by @command{guix system describe}) to those currently in use (as
34469 returned by @command{guix describe}) to determine whether commits
34470 currently in use are descendants of those deployed. When this is not
34471 the case and @code{allow-downgrades?} is false, it raises an error.
34472 This ensures you do not accidentally downgrade remote machines.
34473 @end table
34474 @end deftp
34475
34476 @deftp {Data Type} digital-ocean-configuration
34477 This is the data type describing the Droplet that should be created for a
34478 machine with an @code{environment} of @code{digital-ocean-environment-type}.
34479
34480 @table @asis
34481 @item @code{ssh-key}
34482 The path to the SSH private key to use to authenticate with the remote
34483 host. In the future, this field may not exist.
34484 @item @code{tags}
34485 A list of string ``tags'' that uniquely identify the machine. Must be given
34486 such that no two machines in the deployment have the same set of tags.
34487 @item @code{region}
34488 A Digital Ocean region slug, such as @code{"nyc3"}.
34489 @item @code{size}
34490 A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
34491 @item @code{enable-ipv6?}
34492 Whether or not the droplet should be created with IPv6 networking.
34493 @end table
34494 @end deftp
34495
34496 @node Running Guix in a VM
34497 @section Running Guix in a Virtual Machine
34498
34499 @cindex virtual machine
34500 To run Guix in a virtual machine (VM), one can use the pre-built Guix VM
34501 image distributed at
34502 @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2}.
34503 This image is a compressed image in QCOW format. You can pass it to an
34504 emulator such as @uref{https://qemu.org/, QEMU} (see below for details).
34505
34506 This image boots the Xfce graphical environment and it contains some
34507 commonly used tools. You can install more software in the image by running
34508 @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
34509 also reconfigure the system based on its initial configuration file available
34510 as @file{/run/current-system/configuration.scm} (@pxref{Using the
34511 Configuration System}).
34512
34513 Instead of using this pre-built image, one can also build their own
34514 image using @command{guix system image} (@pxref{Invoking guix system}).
34515
34516 @cindex QEMU
34517 If you built your own image, you must copy it out of the store
34518 (@pxref{The Store}) and give yourself permission to write to the copy
34519 before you can use it. When invoking QEMU, you must choose a system
34520 emulator that is suitable for your hardware platform. Here is a minimal
34521 QEMU invocation that will boot the result of @command{guix system
34522 image -t qcow2} on x86_64 hardware:
34523
34524 @example
34525 $ qemu-system-x86_64 \
34526 -nic user,model=virtio-net-pci \
34527 -enable-kvm -m 1024 \
34528 -device virtio-blk,drive=myhd \
34529 -drive if=none,file=/tmp/qemu-image,id=myhd
34530 @end example
34531
34532 Here is what each of these options means:
34533
34534 @table @code
34535 @item qemu-system-x86_64
34536 This specifies the hardware platform to emulate. This should match the
34537 host.
34538
34539 @item -nic user,model=virtio-net-pci
34540 Enable the unprivileged user-mode network stack. The guest OS can
34541 access the host but not vice versa. This is the simplest way to get the
34542 guest OS online. @code{model} specifies which network device to emulate:
34543 @code{virtio-net-pci} is a special device made for virtualized operating
34544 systems and recommended for most uses. Assuming your hardware platform is
34545 x86_64, you can get a list of available NIC models by running
34546 @command{qemu-system-x86_64 -nic model=help}.
34547
34548 @item -enable-kvm
34549 If your system has hardware virtualization extensions, enabling the
34550 virtual machine support (KVM) of the Linux kernel will make things run
34551 faster.
34552
34553 @c To run Xfce + 'guix pull', we need at least 1G of RAM.
34554 @item -m 1024
34555 RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
34556 which may be insufficient for some operations.
34557
34558 @item -device virtio-blk,drive=myhd
34559 Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
34560 ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
34561 better performance than if it were emulating a complete disk drive. See the
34562 QEMU and KVM documentation for more info.
34563
34564 @item -drive if=none,file=/tmp/qemu-image,id=myhd
34565 Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
34566 store of the ``myhd'' drive.
34567 @end table
34568
34569 The default @command{run-vm.sh} script that is returned by an invocation of
34570 @command{guix system vm} does not add a @command{-nic user} flag by default.
34571 To get network access from within the vm add the @code{(dhcp-client-service)}
34572 to your system definition and start the VM using
34573 @command{$(guix system vm config.scm) -nic user}. An important caveat of using
34574 @command{-nic user} for networking is that @command{ping} will not work, because
34575 it uses the ICMP protocol. You'll have to use a different command to check for
34576 network connectivity, for example @command{guix download}.
34577
34578 @subsection Connecting Through SSH
34579
34580 @cindex SSH
34581 @cindex SSH server
34582 To enable SSH inside a VM you need to add an SSH server like
34583 @code{openssh-service-type} to your VM (@pxref{Networking Services,
34584 @code{openssh-service-type}}). In addition you need to forward the SSH port,
34585 22 by default, to the host. You can do this with
34586
34587 @example
34588 $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
34589 @end example
34590
34591 To connect to the VM you can run
34592
34593 @example
34594 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 localhost
34595 @end example
34596
34597 The @command{-p} tells @command{ssh} the port you want to connect to.
34598 @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
34599 every time you modify your @command{config.scm} file and the
34600 @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
34601 connection to an unknown host every time you connect.
34602
34603 @quotation Note
34604 If you find the above @samp{hostfwd} example not to be working (e.g.,
34605 your SSH client hangs attempting to connect to the mapped port of your
34606 VM), make sure that your Guix System VM has networking support, such as
34607 by using the @code{dhcp-client-service-type} service type.
34608 @end quotation
34609
34610 @subsection Using @command{virt-viewer} with Spice
34611
34612 As an alternative to the default @command{qemu} graphical client you can
34613 use the @command{remote-viewer} from the @command{virt-viewer} package. To
34614 connect pass the @command{-spice port=5930,disable-ticketing} flag to
34615 @command{qemu}. See previous section for further information on how to do this.
34616
34617 Spice also allows you to do some nice stuff like share your clipboard with your
34618 VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
34619
34620 @example
34621 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
34622 -chardev spicevmc,name=vdagent,id=vdagent
34623 -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
34624 name=com.redhat.spice.0
34625 @end example
34626
34627 You'll also need to add the @code{(spice-vdagent-service)} to your
34628 system definition (@pxref{Miscellaneous Services, Spice service}).
34629
34630 @node Defining Services
34631 @section Defining Services
34632
34633 The previous sections show the available services and how one can combine
34634 them in an @code{operating-system} declaration. But how do we define
34635 them in the first place? And what is a service anyway?
34636
34637 @menu
34638 * Service Composition:: The model for composing services.
34639 * Service Types and Services:: Types and services.
34640 * Service Reference:: API reference.
34641 * Shepherd Services:: A particular type of service.
34642 @end menu
34643
34644 @node Service Composition
34645 @subsection Service Composition
34646
34647 @cindex services
34648 @cindex daemons
34649 Here we define a @dfn{service} as, broadly, something that extends the
34650 functionality of the operating system. Often a service is a process---a
34651 @dfn{daemon}---started when the system boots: a secure shell server, a
34652 Web server, the Guix build daemon, etc. Sometimes a service is a daemon
34653 whose execution can be triggered by another daemon---e.g., an FTP server
34654 started by @command{inetd} or a D-Bus service activated by
34655 @command{dbus-daemon}. Occasionally, a service does not map to a
34656 daemon. For instance, the ``account'' service collects user accounts
34657 and makes sure they exist when the system runs; the ``udev'' service
34658 collects device management rules and makes them available to the eudev
34659 daemon; the @file{/etc} service populates the @file{/etc} directory
34660 of the system.
34661
34662 @cindex service extensions
34663 Guix system services are connected by @dfn{extensions}. For instance, the
34664 secure shell service @emph{extends} the Shepherd---the
34665 initialization system, running as PID@tie{}1---by giving it the command
34666 lines to start and stop the secure shell daemon (@pxref{Networking
34667 Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
34668 service by passing it its @file{.service} specification, and extends the
34669 udev service by passing it device management rules (@pxref{Desktop
34670 Services, @code{upower-service}}); the Guix daemon service extends the
34671 Shepherd by passing it the command lines to start and stop the daemon,
34672 and extends the account service by passing it a list of required build
34673 user accounts (@pxref{Base Services}).
34674
34675 All in all, services and their ``extends'' relations form a directed
34676 acyclic graph (DAG). If we represent services as boxes and extensions
34677 as arrows, a typical system might provide something like this:
34678
34679 @image{images/service-graph,,5in,Typical service extension graph.}
34680
34681 @cindex system service
34682 At the bottom, we see the @dfn{system service}, which produces the
34683 directory containing everything to run and boot the system, as returned
34684 by the @command{guix system build} command. @xref{Service Reference},
34685 to learn about the other service types shown here.
34686 @xref{system-extension-graph, the @command{guix system extension-graph}
34687 command}, for information on how to generate this representation for a
34688 particular operating system definition.
34689
34690 @cindex service types
34691 Technically, developers can define @dfn{service types} to express these
34692 relations. There can be any number of services of a given type on the
34693 system---for instance, a system running two instances of the GNU secure
34694 shell server (lsh) has two instances of @code{lsh-service-type}, with
34695 different parameters.
34696
34697 The following section describes the programming interface for service
34698 types and services.
34699
34700 @node Service Types and Services
34701 @subsection Service Types and Services
34702
34703 A @dfn{service type} is a node in the DAG described above. Let us start
34704 with a simple example, the service type for the Guix build daemon
34705 (@pxref{Invoking guix-daemon}):
34706
34707 @lisp
34708 (define guix-service-type
34709 (service-type
34710 (name 'guix)
34711 (extensions
34712 (list (service-extension shepherd-root-service-type guix-shepherd-service)
34713 (service-extension account-service-type guix-accounts)
34714 (service-extension activation-service-type guix-activation)))
34715 (default-value (guix-configuration))))
34716 @end lisp
34717
34718 @noindent
34719 It defines three things:
34720
34721 @enumerate
34722 @item
34723 A name, whose sole purpose is to make inspection and debugging easier.
34724
34725 @item
34726 A list of @dfn{service extensions}, where each extension designates the
34727 target service type and a procedure that, given the parameters of the
34728 service, returns a list of objects to extend the service of that type.
34729
34730 Every service type has at least one service extension. The only
34731 exception is the @dfn{boot service type}, which is the ultimate service.
34732
34733 @item
34734 Optionally, a default value for instances of this type.
34735 @end enumerate
34736
34737 In this example, @code{guix-service-type} extends three services:
34738
34739 @table @code
34740 @item shepherd-root-service-type
34741 The @code{guix-shepherd-service} procedure defines how the Shepherd
34742 service is extended. Namely, it returns a @code{<shepherd-service>}
34743 object that defines how @command{guix-daemon} is started and stopped
34744 (@pxref{Shepherd Services}).
34745
34746 @item account-service-type
34747 This extension for this service is computed by @code{guix-accounts},
34748 which returns a list of @code{user-group} and @code{user-account}
34749 objects representing the build user accounts (@pxref{Invoking
34750 guix-daemon}).
34751
34752 @item activation-service-type
34753 Here @code{guix-activation} is a procedure that returns a gexp, which is
34754 a code snippet to run at ``activation time''---e.g., when the service is
34755 booted.
34756 @end table
34757
34758 A service of this type is instantiated like this:
34759
34760 @lisp
34761 (service guix-service-type
34762 (guix-configuration
34763 (build-accounts 5)
34764 (extra-options '("--gc-keep-derivations"))))
34765 @end lisp
34766
34767 The second argument to the @code{service} form is a value representing
34768 the parameters of this specific service instance.
34769 @xref{guix-configuration-type, @code{guix-configuration}}, for
34770 information about the @code{guix-configuration} data type. When the
34771 value is omitted, the default value specified by
34772 @code{guix-service-type} is used:
34773
34774 @lisp
34775 (service guix-service-type)
34776 @end lisp
34777
34778 @code{guix-service-type} is quite simple because it extends other
34779 services but is not extensible itself.
34780
34781 @c @subsubsubsection Extensible Service Types
34782
34783 The service type for an @emph{extensible} service looks like this:
34784
34785 @lisp
34786 (define udev-service-type
34787 (service-type (name 'udev)
34788 (extensions
34789 (list (service-extension shepherd-root-service-type
34790 udev-shepherd-service)))
34791
34792 (compose concatenate) ;concatenate the list of rules
34793 (extend (lambda (config rules)
34794 (match config
34795 (($ <udev-configuration> udev initial-rules)
34796 (udev-configuration
34797 (udev udev) ;the udev package to use
34798 (rules (append initial-rules rules)))))))))
34799 @end lisp
34800
34801 This is the service type for the
34802 @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
34803 management daemon}. Compared to the previous example, in addition to an
34804 extension of @code{shepherd-root-service-type}, we see two new fields:
34805
34806 @table @code
34807 @item compose
34808 This is the procedure to @dfn{compose} the list of extensions to
34809 services of this type.
34810
34811 Services can extend the udev service by passing it lists of rules; we
34812 compose those extensions simply by concatenating them.
34813
34814 @item extend
34815 This procedure defines how the value of the service is @dfn{extended} with
34816 the composition of the extensions.
34817
34818 Udev extensions are composed into a list of rules, but the udev service
34819 value is itself a @code{<udev-configuration>} record. So here, we
34820 extend that record by appending the list of rules it contains to the
34821 list of contributed rules.
34822
34823 @item description
34824 This is a string giving an overview of the service type. The string can
34825 contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
34826 @command{guix system search} command searches these strings and displays
34827 them (@pxref{Invoking guix system}).
34828 @end table
34829
34830 There can be only one instance of an extensible service type such as
34831 @code{udev-service-type}. If there were more, the
34832 @code{service-extension} specifications would be ambiguous.
34833
34834 Still here? The next section provides a reference of the programming
34835 interface for services.
34836
34837 @node Service Reference
34838 @subsection Service Reference
34839
34840 We have seen an overview of service types (@pxref{Service Types and
34841 Services}). This section provides a reference on how to manipulate
34842 services and service types. This interface is provided by the
34843 @code{(gnu services)} module.
34844
34845 @deffn {Scheme Procedure} service @var{type} [@var{value}]
34846 Return a new service of @var{type}, a @code{<service-type>} object (see
34847 below). @var{value} can be any object; it represents the parameters of
34848 this particular service instance.
34849
34850 When @var{value} is omitted, the default value specified by @var{type}
34851 is used; if @var{type} does not specify a default value, an error is
34852 raised.
34853
34854 For instance, this:
34855
34856 @lisp
34857 (service openssh-service-type)
34858 @end lisp
34859
34860 @noindent
34861 is equivalent to this:
34862
34863 @lisp
34864 (service openssh-service-type
34865 (openssh-configuration))
34866 @end lisp
34867
34868 In both cases the result is an instance of @code{openssh-service-type}
34869 with the default configuration.
34870 @end deffn
34871
34872 @deffn {Scheme Procedure} service? @var{obj}
34873 Return true if @var{obj} is a service.
34874 @end deffn
34875
34876 @deffn {Scheme Procedure} service-kind @var{service}
34877 Return the type of @var{service}---i.e., a @code{<service-type>} object.
34878 @end deffn
34879
34880 @deffn {Scheme Procedure} service-value @var{service}
34881 Return the value associated with @var{service}. It represents its
34882 parameters.
34883 @end deffn
34884
34885 Here is an example of how a service is created and manipulated:
34886
34887 @lisp
34888 (define s
34889 (service nginx-service-type
34890 (nginx-configuration
34891 (nginx nginx)
34892 (log-directory log-directory)
34893 (run-directory run-directory)
34894 (file config-file))))
34895
34896 (service? s)
34897 @result{} #t
34898
34899 (eq? (service-kind s) nginx-service-type)
34900 @result{} #t
34901 @end lisp
34902
34903 The @code{modify-services} form provides a handy way to change the
34904 parameters of some of the services of a list such as
34905 @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
34906 evaluates to a list of services. Of course, you could always use
34907 standard list combinators such as @code{map} and @code{fold} to do that
34908 (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
34909 @code{modify-services} simply provides a more concise form for this
34910 common pattern.
34911
34912 @deffn {Scheme Syntax} modify-services @var{services} @
34913 (@var{type} @var{variable} => @var{body}) @dots{}
34914
34915 Modify the services listed in @var{services} according to the given
34916 clauses. Each clause has the form:
34917
34918 @example
34919 (@var{type} @var{variable} => @var{body})
34920 @end example
34921
34922 where @var{type} is a service type---e.g.,
34923 @code{guix-service-type}---and @var{variable} is an identifier that is
34924 bound within the @var{body} to the service parameters---e.g., a
34925 @code{guix-configuration} instance---of the original service of that
34926 @var{type}.
34927
34928 The @var{body} should evaluate to the new service parameters, which will
34929 be used to configure the new service. This new service will replace the
34930 original in the resulting list. Because a service's service parameters
34931 are created using @code{define-record-type*}, you can write a succinct
34932 @var{body} that evaluates to the new service parameters by using the
34933 @code{inherit} feature that @code{define-record-type*} provides.
34934
34935 @xref{Using the Configuration System}, for example usage.
34936
34937 @end deffn
34938
34939 Next comes the programming interface for service types. This is
34940 something you want to know when writing new service definitions, but not
34941 necessarily when simply looking for ways to customize your
34942 @code{operating-system} declaration.
34943
34944 @deftp {Data Type} service-type
34945 @cindex service type
34946 This is the representation of a @dfn{service type} (@pxref{Service Types
34947 and Services}).
34948
34949 @table @asis
34950 @item @code{name}
34951 This is a symbol, used only to simplify inspection and debugging.
34952
34953 @item @code{extensions}
34954 A non-empty list of @code{<service-extension>} objects (see below).
34955
34956 @item @code{compose} (default: @code{#f})
34957 If this is @code{#f}, then the service type denotes services that cannot
34958 be extended---i.e., services that do not receive ``values'' from other
34959 services.
34960
34961 Otherwise, it must be a one-argument procedure. The procedure is called
34962 by @code{fold-services} and is passed a list of values collected from
34963 extensions. It may return any single value.
34964
34965 @item @code{extend} (default: @code{#f})
34966 If this is @code{#f}, services of this type cannot be extended.
34967
34968 Otherwise, it must be a two-argument procedure: @code{fold-services}
34969 calls it, passing it the initial value of the service as the first
34970 argument and the result of applying @code{compose} to the extension
34971 values as the second argument. It must return a value that is a valid
34972 parameter value for the service instance.
34973
34974 @item @code{description}
34975 This is a string, possibly using Texinfo markup, describing in a couple
34976 of sentences what the service is about. This string allows users to
34977 find about the service through @command{guix system search}
34978 (@pxref{Invoking guix system}).
34979
34980 @item @code{default-value} (default: @code{&no-default-value})
34981 The default value associated for instances of this service type. This
34982 allows users to use the @code{service} form without its second argument:
34983
34984 @lisp
34985 (service @var{type})
34986 @end lisp
34987
34988 The returned service in this case has the default value specified by
34989 @var{type}.
34990 @end table
34991
34992 @xref{Service Types and Services}, for examples.
34993 @end deftp
34994
34995 @deffn {Scheme Procedure} service-extension @var{target-type} @
34996 @var{compute}
34997 Return a new extension for services of type @var{target-type}.
34998 @var{compute} must be a one-argument procedure: @code{fold-services}
34999 calls it, passing it the value associated with the service that provides
35000 the extension; it must return a valid value for the target service.
35001 @end deffn
35002
35003 @deffn {Scheme Procedure} service-extension? @var{obj}
35004 Return true if @var{obj} is a service extension.
35005 @end deffn
35006
35007 Occasionally, you might want to simply extend an existing service. This
35008 involves creating a new service type and specifying the extension of
35009 interest, which can be verbose; the @code{simple-service} procedure
35010 provides a shorthand for this.
35011
35012 @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
35013 Return a service that extends @var{target} with @var{value}. This works
35014 by creating a singleton service type @var{name}, of which the returned
35015 service is an instance.
35016
35017 For example, this extends mcron (@pxref{Scheduled Job Execution}) with
35018 an additional job:
35019
35020 @lisp
35021 (simple-service 'my-mcron-job mcron-service-type
35022 #~(job '(next-hour (3)) "guix gc -F 2G"))
35023 @end lisp
35024 @end deffn
35025
35026 At the core of the service abstraction lies the @code{fold-services}
35027 procedure, which is responsible for ``compiling'' a list of services
35028 down to a single directory that contains everything needed to boot and
35029 run the system---the directory shown by the @command{guix system build}
35030 command (@pxref{Invoking guix system}). In essence, it propagates
35031 service extensions down the service graph, updating each node parameters
35032 on the way, until it reaches the root node.
35033
35034 @deffn {Scheme Procedure} fold-services @var{services} @
35035 [#:target-type @var{system-service-type}]
35036 Fold @var{services} by propagating their extensions down to the root of
35037 type @var{target-type}; return the root service adjusted accordingly.
35038 @end deffn
35039
35040 Lastly, the @code{(gnu services)} module also defines several essential
35041 service types, some of which are listed below.
35042
35043 @defvr {Scheme Variable} system-service-type
35044 This is the root of the service graph. It produces the system directory
35045 as returned by the @command{guix system build} command.
35046 @end defvr
35047
35048 @defvr {Scheme Variable} boot-service-type
35049 The type of the ``boot service'', which produces the @dfn{boot script}.
35050 The boot script is what the initial RAM disk runs when booting.
35051 @end defvr
35052
35053 @defvr {Scheme Variable} etc-service-type
35054 The type of the @file{/etc} service. This service is used to create
35055 files under @file{/etc} and can be extended by
35056 passing it name/file tuples such as:
35057
35058 @lisp
35059 (list `("issue" ,(plain-file "issue" "Welcome!\n")))
35060 @end lisp
35061
35062 In this example, the effect would be to add an @file{/etc/issue} file
35063 pointing to the given file.
35064 @end defvr
35065
35066 @defvr {Scheme Variable} setuid-program-service-type
35067 Type for the ``setuid-program service''. This service collects lists of
35068 executable file names, passed as gexps, and adds them to the set of
35069 setuid-root programs on the system (@pxref{Setuid Programs}).
35070 @end defvr
35071
35072 @defvr {Scheme Variable} profile-service-type
35073 Type of the service that populates the @dfn{system profile}---i.e., the
35074 programs under @file{/run/current-system/profile}. Other services can
35075 extend it by passing it lists of packages to add to the system profile.
35076 @end defvr
35077
35078 @cindex provenance tracking, of the operating system
35079 @anchor{provenance-service-type}
35080 @defvr {Scheme Variable} provenance-service-type
35081 This is the type of the service that records @dfn{provenance meta-data}
35082 in the system itself. It creates several files under
35083 @file{/run/current-system}:
35084
35085 @table @file
35086 @item channels.scm
35087 This is a ``channel file'' that can be passed to @command{guix pull -C}
35088 or @command{guix time-machine -C}, and which describes the channels used
35089 to build the system, if that information was available
35090 (@pxref{Channels}).
35091
35092 @item configuration.scm
35093 This is the file that was passed as the value for this
35094 @code{provenance-service-type} service. By default, @command{guix
35095 system reconfigure} automatically passes the OS configuration file it
35096 received on the command line.
35097
35098 @item provenance
35099 This contains the same information as the two other files but in a
35100 format that is more readily processable.
35101 @end table
35102
35103 In general, these two pieces of information (channels and configuration
35104 file) are enough to reproduce the operating system ``from source''.
35105
35106 @quotation Caveats
35107 This information is necessary to rebuild your operating system, but it
35108 is not always sufficient. In particular, @file{configuration.scm}
35109 itself is insufficient if it is not self-contained---if it refers to
35110 external Guile modules or to extra files. If you want
35111 @file{configuration.scm} to be self-contained, we recommend that modules
35112 or files it refers to be part of a channel.
35113
35114 Besides, provenance meta-data is ``silent'' in the sense that it does
35115 not change the bits contained in your system, @emph{except for the
35116 meta-data bits themselves}. Two different OS configurations or sets of
35117 channels can lead to the same system, bit-for-bit; when
35118 @code{provenance-service-type} is used, these two systems will have
35119 different meta-data and thus different store file names, which makes
35120 comparison less trivial.
35121 @end quotation
35122
35123 This service is automatically added to your operating system
35124 configuration when you use @command{guix system reconfigure},
35125 @command{guix system init}, or @command{guix deploy}.
35126 @end defvr
35127
35128 @defvr {Scheme Variable} linux-loadable-module-service-type
35129 Type of the service that collects lists of packages containing
35130 kernel-loadable modules, and adds them to the set of kernel-loadable
35131 modules.
35132
35133 This service type is intended to be extended by other service types,
35134 such as below:
35135
35136 @lisp
35137 (simple-service 'installing-module
35138 linux-loadable-module-service-type
35139 (list module-to-install-1
35140 module-to-install-2))
35141 @end lisp
35142
35143 This does not actually load modules at bootup, only adds it to the
35144 kernel profile so that it @emph{can} be loaded by other means.
35145 @end defvr
35146
35147 @node Shepherd Services
35148 @subsection Shepherd Services
35149
35150 @cindex shepherd services
35151 @cindex PID 1
35152 @cindex init system
35153 The @code{(gnu services shepherd)} module provides a way to define
35154 services managed by the GNU@tie{}Shepherd, which is the
35155 initialization system---the first process that is started when the
35156 system boots, also known as PID@tie{}1
35157 (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
35158
35159 Services in the Shepherd can depend on each other. For instance, the
35160 SSH daemon may need to be started after the syslog daemon has been
35161 started, which in turn can only happen once all the file systems have
35162 been mounted. The simple operating system defined earlier (@pxref{Using
35163 the Configuration System}) results in a service graph like this:
35164
35165 @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
35166
35167 You can actually generate such a graph for any operating system
35168 definition using the @command{guix system shepherd-graph} command
35169 (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
35170
35171 The @code{%shepherd-root-service} is a service object representing
35172 PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
35173 by passing it lists of @code{<shepherd-service>} objects.
35174
35175 @deftp {Data Type} shepherd-service
35176 The data type representing a service managed by the Shepherd.
35177
35178 @table @asis
35179 @item @code{provision}
35180 This is a list of symbols denoting what the service provides.
35181
35182 These are the names that may be passed to @command{herd start},
35183 @command{herd status}, and similar commands (@pxref{Invoking herd,,,
35184 shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
35185 @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
35186
35187 @item @code{requirement} (default: @code{'()})
35188 List of symbols denoting the Shepherd services this one depends on.
35189
35190 @cindex one-shot services, for the Shepherd
35191 @item @code{one-shot?} (default: @code{#f})
35192 Whether this service is @dfn{one-shot}. One-shot services stop immediately
35193 after their @code{start} action has completed. @xref{Slots of services,,,
35194 shepherd, The GNU Shepherd Manual}, for more info.
35195
35196 @item @code{respawn?} (default: @code{#t})
35197 Whether to restart the service when it stops, for instance when the
35198 underlying process dies.
35199
35200 @item @code{start}
35201 @itemx @code{stop} (default: @code{#~(const #f)})
35202 The @code{start} and @code{stop} fields refer to the Shepherd's
35203 facilities to start and stop processes (@pxref{Service De- and
35204 Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
35205 G-expressions that get expanded in the Shepherd configuration file
35206 (@pxref{G-Expressions}).
35207
35208 @item @code{actions} (default: @code{'()})
35209 @cindex actions, of Shepherd services
35210 This is a list of @code{shepherd-action} objects (see below) defining
35211 @dfn{actions} supported by the service, in addition to the standard
35212 @code{start} and @code{stop} actions. Actions listed here become available as
35213 @command{herd} sub-commands:
35214
35215 @example
35216 herd @var{action} @var{service} [@var{arguments}@dots{}]
35217 @end example
35218
35219 @item @code{auto-start?} (default: @code{#t})
35220 Whether this service should be started automatically by the Shepherd. If it
35221 is @code{#f} the service has to be started manually with @code{herd start}.
35222
35223 @item @code{documentation}
35224 A documentation string, as shown when running:
35225
35226 @example
35227 herd doc @var{service-name}
35228 @end example
35229
35230 where @var{service-name} is one of the symbols in @code{provision}
35231 (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
35232
35233 @item @code{modules} (default: @code{%default-modules})
35234 This is the list of modules that must be in scope when @code{start} and
35235 @code{stop} are evaluated.
35236
35237 @end table
35238 @end deftp
35239
35240 The example below defines a Shepherd service that spawns
35241 @command{syslogd}, the system logger from the GNU Networking Utilities
35242 (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
35243 Inetutils}):
35244
35245 @example
35246 (let ((config (plain-file "syslogd.conf" "@dots{}")))
35247 (shepherd-service
35248 (documentation "Run the syslog daemon (syslogd).")
35249 (provision '(syslogd))
35250 (requirement '(user-processes))
35251 (start #~(make-forkexec-constructor
35252 (list #$(file-append inetutils "/libexec/syslogd")
35253 "--rcfile" #$config)
35254 #:pid-file "/var/run/syslog.pid"))
35255 (stop #~(make-kill-destructor))))
35256 @end example
35257
35258 Key elements in this example are the @code{start} and @code{stop}
35259 fields: they are @dfn{staged} code snippets that use the
35260 @code{make-forkexec-constructor} procedure provided by the Shepherd and
35261 its dual, @code{make-kill-destructor} (@pxref{Service De- and
35262 Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
35263 field will have @command{shepherd} spawn @command{syslogd} with the
35264 given option; note that we pass @code{config} after @option{--rcfile},
35265 which is a configuration file declared above (contents of this file are
35266 omitted). Likewise, the @code{stop} field tells how this service is to
35267 be stopped; in this case, it is stopped by making the @code{kill} system
35268 call on its PID@. Code staging is achieved using G-expressions:
35269 @code{#~} stages code, while @code{#$} ``escapes'' back to host code
35270 (@pxref{G-Expressions}).
35271
35272 @deftp {Data Type} shepherd-action
35273 This is the data type that defines additional actions implemented by a
35274 Shepherd service (see above).
35275
35276 @table @code
35277 @item name
35278 Symbol naming the action.
35279
35280 @item documentation
35281 This is a documentation string for the action. It can be viewed by running:
35282
35283 @example
35284 herd doc @var{service} action @var{action}
35285 @end example
35286
35287 @item procedure
35288 This should be a gexp that evaluates to a procedure of at least one argument,
35289 which is the ``running value'' of the service (@pxref{Slots of services,,,
35290 shepherd, The GNU Shepherd Manual}).
35291 @end table
35292
35293 The following example defines an action called @code{say-hello} that kindly
35294 greets the user:
35295
35296 @lisp
35297 (shepherd-action
35298 (name 'say-hello)
35299 (documentation "Say hi!")
35300 (procedure #~(lambda (running . args)
35301 (format #t "Hello, friend! arguments: ~s\n"
35302 args)
35303 #t)))
35304 @end lisp
35305
35306 Assuming this action is added to the @code{example} service, then you can do:
35307
35308 @example
35309 # herd say-hello example
35310 Hello, friend! arguments: ()
35311 # herd say-hello example a b c
35312 Hello, friend! arguments: ("a" "b" "c")
35313 @end example
35314
35315 This, as you can see, is a fairly sophisticated way to say hello.
35316 @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
35317 info on actions.
35318 @end deftp
35319
35320 @defvr {Scheme Variable} shepherd-root-service-type
35321 The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
35322
35323 This is the service type that extensions target when they want to create
35324 shepherd services (@pxref{Service Types and Services}, for an example).
35325 Each extension must pass a list of @code{<shepherd-service>}. Its
35326 value must be a @code{shepherd-configuration}, as described below.
35327 @end defvr
35328
35329 @deftp {Data Type} shepherd-configuration
35330 This data type represents the Shepherd's configuration.
35331
35332 @table @code
35333 @item shepherd (default: @code{shepherd})
35334 The Shepherd package to use.
35335
35336 @item services (default: @code{'()})
35337 A list of @code{<shepherd-service>} to start.
35338 You should probably use the service extension
35339 mechanism instead (@pxref{Shepherd Services}).
35340 @end table
35341 @end deftp
35342
35343 The following example specifies the Shepherd package for the operating
35344 system:
35345
35346 @lisp
35347 (operating-system
35348 ;; ...
35349 (services (append (list openssh-service-type))
35350 ;; ...
35351 %desktop-services)
35352 ;; ...
35353 ;; Use own Shepherd package.
35354 (essential-services
35355 (modify-services (operating-system-default-essential-services
35356 this-operating-system)
35357 (shepherd-root-service-type config => (shepherd-configuration
35358 (inherit config)
35359 (shepherd my-shepherd))))))
35360 @end lisp
35361
35362 @defvr {Scheme Variable} %shepherd-root-service
35363 This service represents PID@tie{}1.
35364 @end defvr
35365
35366 @node Home Configuration
35367 @chapter Home Configuration
35368 @cindex home configuration
35369 Guix supports declarative configuration of @dfn{home environments} by
35370 utilizing the configuration mechanism described in the previous chapter
35371 (@pxref{Defining Services}), but for user's dotfiles and packages. It
35372 works both on Guix System and foreign distros and allows users to
35373 declare all the packages and services that should be installed and
35374 configured for the user. Once a user has written a file containing
35375 @code{home-environment} record, such a configuration can be
35376 @dfn{instantiated} by an unprivileged user with the @command{guix home}
35377 command (@pxref{Invoking guix home}).
35378 @c Maybe later, it will be possible to make home configuration a part of
35379 @c system configuration to make everything managed by guix system.
35380
35381 @quotation Note
35382 The functionality described in this section is still under development
35383 and is subject to change. Get in touch with us on
35384 @email{guix-devel@@gnu.org}!
35385 @end quotation
35386
35387 The user's home environment usually consists of three basic parts:
35388 software, configuration, and state. Software in mainstream distros are
35389 usually installed system-wide, but with GNU Guix most software packages
35390 can be installed on a per-user basis without needing root privileges,
35391 and are thus considered part of the user’s @dfn{home environment}.
35392 Packages on their own not very useful in many cases, because often they
35393 require some additional configuration, usually config files that reside
35394 in @env{XDG_CONFIG_HOME} (@file{~/.config} by default) or other
35395 directories. Everything else can be considered state, like media files,
35396 application databases, and logs.
35397
35398 Using Guix for managing home environments provides a number of
35399 advantages:
35400
35401 @itemize
35402
35403 @item All software can be configured in one language (Guile Scheme),
35404 this gives users the ability to share values between configurations of
35405 different programs.
35406
35407 @item A well-defined home environment is self-contained and can be
35408 created in a declarative and reproducible way---there is no need to grab
35409 external binaries or manually edit some configuration file.
35410
35411 @item After every @command{guix home reconfigure} invocation, a new home
35412 environment generation will be created. This means that users can
35413 rollback to a previous home environment generation so they don’t have to
35414 worry about breaking their configuration.
35415
35416 @item It is possible to manage stateful data with Guix Home, this
35417 includes the ability to automatically clone Git repositories on the
35418 initial setup of the machine, and periodically running commands like
35419 @command{rsync} to sync data with another host. This functionality is
35420 still in an experimental stage, though.
35421
35422 @end itemize
35423
35424 @menu
35425 * Declaring the Home Environment:: Customizing your Home.
35426 * Configuring the Shell:: Enabling home environment.
35427 * Home Services:: Specifying home services.
35428 * Invoking guix home:: Instantiating a home configuration.
35429 @end menu
35430
35431 @node Declaring the Home Environment
35432 @section Declaring the Home Environment
35433 The home environment is configured by providing a
35434 @code{home-environment} declaration in a file that can be passed to the
35435 @command{guix home} command (@pxref{Invoking guix home}). A simple
35436 setup can include Bash and a custom text configuration, like in the
35437 example below. Don't be afraid to declare home environment parts, which
35438 overlaps with your current dotfiles, before installing any configuration
35439 files, Guix Home will back up existing config files to a separate place
35440 in the home folder.
35441
35442 @quotation Note
35443 It is highly recommended that you manage your shell or shells with Guix
35444 Home, because it will make sure that all the necessary scripts are
35445 sourced by the shell configuration file. Otherwise you will need to do
35446 it manually. (@pxref{Configuring the Shell}).
35447 @end quotation
35448
35449 @findex home-environment
35450 @lisp
35451 @include he-config-bare-bones.scm
35452 @end lisp
35453
35454 The @code{packages} field should be self-explanatory, it will install
35455 the list of packages into the user's profile. The most important field
35456 is @code{services}, it contains a list of @dfn{home services}, which are
35457 the basic building blocks of a home environment.
35458
35459 There is no daemon (at least not necessarily) related to a home service,
35460 a home service is just an element that is used to declare part of home
35461 environment and extend other parts of it. The extension mechanism
35462 discussed in the previous chapter (@pxref{Defining Services}) should not
35463 be confused with @ref{Shepherd Services}. Using this extension
35464 mechanism and some Scheme code that glues things together gives the user
35465 the freedom to declare their own, very custom, home environments.
35466
35467 @node Configuring the Shell
35468 @section Configuring the Shell
35469 This section is safe to skip if your shell or shells are managed by
35470 Guix Home. Otherwise, read it carefully.
35471
35472 There are a few scripts that must be evaluated by a login shell to
35473 activate the home environment. The shell startup files only read by
35474 login shells often have @code{profile} suffix. For more information
35475 about login shells see @ref{Invoking Bash,,, bash, The GNU Bash
35476 Reference Manual} and see @ref{Bash Startup Files,,, bash, The GNU Bash
35477 Reference Manual}.
35478
35479 The first script that needs to be sourced is @file{setup-environment},
35480 which sets all the necessary environment variables (including variables
35481 declared by the user) and the second one is @file{on-first-login}, which
35482 starts Shepherd for the current user and performs actions declared by
35483 other home services that extends
35484 @code{home-run-on-first-login-service-type}.
35485
35486 Guix Home will always create @file{~/.profile}, which contains the
35487 following lines:
35488
35489 @example
35490 HOME_ENVIRONMENT=$HOME/.guix-home
35491 . $HOME_ENVIRONMENT/setup-environment
35492 $HOME_ENVIRONMENT/on-first-login
35493 @end example
35494
35495 This makes POSIX compliant login shells activate the home environment.
35496 However, in most cases this file won't be read by most modern shells,
35497 because they are run in non POSIX mode by default and have their own
35498 @file{*profile} startup files. For example Bash will prefer
35499 @file{~/.bash_profile} in case it exists and only if it doesn't will it
35500 fallback to @file{~/.profile}. Zsh (if no additional options are
35501 specified) will ignore @file{~/.profile}, even if @file{~/.zprofile}
35502 doesn't exist.
35503
35504 To make your shell respect @file{~/.profile}, add @code{. ~/.profile} or
35505 @code{source ~/profile} to the startup file for the login shell. In
35506 case of Bash, it is @file{~/.bash_profile}, and in case of Zsh, it is
35507 @file{~/.zprofile}.
35508
35509 @quotation Note
35510 This step is only required if your shell is NOT managed by Guix Home.
35511 Otherwise, everything will be done automatically.
35512 @end quotation
35513
35514 @node Home Services
35515 @section Home Services
35516 @cindex home services
35517
35518 A @dfn{home service} is not necessarily something that has a daemon and
35519 is managed by Shepherd (@pxref{Jump Start,,, shepherd, The GNU Shepherd
35520 Manual}), in most cases it doesn't. It's a simple building block of the
35521 home environment, often declaring a set of packages to be installed in
35522 the home environment profile, a set of config files to be symlinked into
35523 @env{XDG_CONFIG_HOME} (@file{~/.config} by default), and environment
35524 variables to be set by a login shell.
35525
35526 There is a service extension mechanism (@pxref{Service Composition})
35527 which allows home services to extend other home services and utilize
35528 capabilities they provide; for example: declare mcron jobs
35529 (@pxref{Top,,, mcron, GNU@tie{}Mcron}) by extending @ref{Mcron Home
35530 Service}; declare daemons by extending @ref{Shepherd Home Service}; add
35531 commands, which will be invoked on by the Bash by extending
35532 @ref{Shells Home Services, @code{home-bash-service-type}}.
35533
35534 A good way to discover avaliable home services is using the
35535 @command{guix home search} command (@pxref{Invoking guix home}). After
35536 the required home services are found, include its module with the
35537 @code{use-modules} form (@pxref{use-modules,, Using Guile Modules,
35538 guile, The GNU Guile Reference Manual}), or the @code{#:use-modules}
35539 directive (@pxref{define-module,, Creating Guile Modules, guile, The GNU
35540 Guile Reference Manual}) and declare a home service using the
35541 @code{service} function, or extend a service type by declaring a new
35542 service with the @code{simple-service} procedure from @code{(gnu
35543 services)}.
35544
35545 @menu
35546 * Essential Home Services:: Environment variables, packages, on-* scripts.
35547 * Shells: Shells Home Services. POSIX shells, Bash, Zsh.
35548 * Mcron: Mcron Home Service. Scheduled User's Job Execution.
35549 * Shepherd: Shepherd Home Service. Managing User's Daemons.
35550 @end menu
35551 @c In addition to that Home Services can provide
35552
35553 @node Essential Home Services
35554 @subsection Essential Home Services
35555 There are a few essential services defined in @code{(gnu
35556 home-services)}, they are mostly for internal use and are required to
35557 build a home environment, but some of them will be useful for the end
35558 user.
35559
35560 @cindex environment variables
35561
35562 @defvr {Scheme Variable} home-environment-variables-service-type
35563 The service of this type will be instantiated by every home environment
35564 automatically by default, there is no need to define it, but someone may
35565 want to extend it with a list of pairs to set some environment
35566 variables.
35567
35568 @lisp
35569 (list ("ENV_VAR1" . "value1")
35570 ("ENV_VAR2" . "value2"))
35571 @end lisp
35572
35573 The easiest way to extend a service type, without defining new service
35574 type is to use the @code{simple-service} helper from @code{(gnu
35575 services)}.
35576
35577 @lisp
35578 (simple-service 'some-useful-env-vars-service
35579 home-environment-variables-service-type
35580 `(("LESSHISTFILE" . "$XDG_CACHE_HOME/.lesshst")
35581 ("SHELL" . ,(file-append zsh "/bin/zsh"))
35582 ("USELESS_VAR" . #f)
35583 ("_JAVA_AWT_WM_NONREPARENTING" . #t)))
35584 @end lisp
35585
35586 If you include such a service in you home environment definition, it
35587 will add the following content to the @file{setup-environment} script
35588 (which is expected to be sourced by the login shell):
35589
35590 @example
35591 export LESSHISTFILE=$XDG_CACHE_HOME/.lesshst
35592 export SHELL=/gnu/store/2hsg15n644f0glrcbkb1kqknmmqdar03-zsh-5.8/bin/zsh
35593 export _JAVA_AWT_WM_NONREPARENTING
35594 @end example
35595
35596 @quotation Note
35597 Make sure that module @code{(gnu packages shells)} is imported with
35598 @code{use-modules} or any other way, this namespace contains the
35599 definition of the @code{zsh} packages, which is used in the example
35600 above.
35601 @end quotation
35602
35603 The association list (@pxref{Association Lists, alists, Association
35604 Lists, guile, The GNU Guile Reference manual}) is a data structure
35605 containing key-value pairs, for
35606 @code{home-environment-variables-service-type} the key is always a
35607 string, the value can be a string, string-valued gexp
35608 (@pxref{G-Expressions}), file-like object (@pxref{G-Expressions,
35609 file-like object}) or boolean. For gexps, the variable will be set to
35610 the value of the gexp; for file-like objects, it will be set to the path
35611 of the file in the store (@pxref{The Store}); for @code{#t}, it will
35612 export the variable without any value; and for @code{#f}, it will omit
35613 variable.
35614
35615 @end defvr
35616
35617 @defvr {Scheme Variable} home-profile-service-type
35618 The service of this type will be instantiated by every home environment
35619 automatically, there is no need to define it, but you may want to extend
35620 it with a list of packages if you want to install additional packages
35621 into your profile. Other services, which need to make some programs
35622 avaliable to the user will also extend this service type.
35623
35624 The extension value is just a list of packages:
35625
35626 @lisp
35627 (list htop vim emacs)
35628 @end lisp
35629
35630 The same approach as @code{simple-service} (@pxref{Service Reference,
35631 simple-service}) for @code{home-environment-variables-service-type} can
35632 be used here, too. Make sure that modules containing the specified
35633 packages are imported with @code{use-modules}. To find a package or
35634 information about its module use @command{guix search} (@pxref{Invoking
35635 guix package}). Alternatively, @code{specification->package} can be
35636 used to get the package record from string without importing related
35637 module.
35638 @end defvr
35639
35640 There are few more essential services, but users are not expected to
35641 extend them.
35642
35643 @defvr {Scheme Variable} home-service-type
35644 The root of home services DAG, it generates a folder, which later will be
35645 symlinked to @file{~/.guix-home}, it contains configurations,
35646 profile with binaries and libraries, and some necessary scripts to glue
35647 things together.
35648 @end defvr
35649
35650 @defvr {Scheme Variable} home-run-on-first-login-service-type
35651 The service of this type generates a Guile script, which is expected to
35652 be executed by the login shell. It is only executed if the special flag
35653 file inside @env{XDG_RUNTIME_DIR} hasn't been created, this prevents
35654 redundant executions of the script if multiple login shells are spawned.
35655
35656 It can be extended with a gexp. However, to autostart an application,
35657 users @emph{should not} use this service, in most cases it's better to extend
35658 @code{home-shpeherd-service-type} with a Shepherd service
35659 (@pxref{Shepherd Services}), or extend the shell's startup file with
35660 required command using the appropriate service type.
35661 @end defvr
35662
35663 @defvr {Scheme Variable} home-activation-service-type
35664 The service of this type generates a guile script, which runs on every
35665 @command{guix home reconfigure} invocation or any other action, which
35666 leads to the activation of the home environment.
35667 @end defvr
35668
35669 @node Shells Home Services
35670 @subsection Shells
35671
35672 @cindex shell
35673 @cindex login shell
35674 @cindex interactive shell
35675 @cindex bash
35676 @cindex zsh
35677
35678 Shells play a quite important role in the environment initialization
35679 process, you can configure them manually as described in section
35680 @ref{Configuring the Shell}, but the recommended way is to use home services
35681 listed below. It's both easier and more reliable.
35682
35683 Each home environment instantiates
35684 @code{home-shell-profile-service-type}, which creates a
35685 @file{~/.profile} startup file for all POSIX-compatible shells. This
35686 file contains all the necessary steps to properly initialize the
35687 environment, but many modern shells like Bash or Zsh prefer their own
35688 startup files, that's why the respective home services
35689 (@code{home-bash-service-type} and @code{home-zsh-service-type}) ensure
35690 that @file{~/.profile} is sourced by @file{~/.bash_profile} and
35691 @file{~/.zprofile}, respectively.
35692
35693 @subsubheading Shell Profile Service
35694
35695 @deftp {Data Type} home-shell-profile-configuration
35696 Available @code{home-shell-profile-configuration} fields are:
35697
35698 @table @asis
35699 @item @code{profile} (default: @code{()}) (type: text-config)
35700 @code{home-shell-profile} is instantiated automatically by
35701 @code{home-environment}, DO NOT create this service manually, it can
35702 only be extended. @code{profile} is a list of strings or gexps, which
35703 will go to @file{~/.profile}. By default @file{~/.profile} contains the
35704 initialization code, which have to be evaluated by login shell to make
35705 home-environment's profile avaliable to the user, but other commands can
35706 be added to the file if it is really necessary. In most cases shell's
35707 configuration files are preferred places for user's customizations.
35708 Extend home-shell-profile service only if you really know what you do.
35709
35710 @end table
35711
35712 @end deftp
35713
35714 @subsubheading Bash Home Service
35715
35716 @deftp {Data Type} home-bash-configuration
35717 Available @code{home-bash-configuration} fields are:
35718
35719 @table @asis
35720 @item @code{package} (default: @code{bash}) (type: package)
35721 The Bash package to use.
35722
35723 @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
35724 Add sane defaults like reading @file{/etc/bashrc}, coloring output for
35725 @code{ls} provided by guix to @file{.bashrc}.
35726
35727 @item @code{environment-variables} (default: @code{()}) (type: alist)
35728 Association list of environment variables to set for the Bash session.
35729
35730 @item @code{bash-profile} (default: @code{()}) (type: text-config)
35731 List of strings or gexps, which will be added to @file{.bash_profile}.
35732 Used for executing user's commands at start of login shell (In most
35733 cases the shell started on tty just after login). @file{.bash_login}
35734 won't be ever read, because @file{.bash_profile} always present.
35735
35736 @item @code{bashrc} (default: @code{()}) (type: text-config)
35737 List of strings or gexps, which will be added to @file{.bashrc}. Used
35738 for executing user's commands at start of interactive shell (The shell
35739 for interactive usage started by typing @code{bash} or by terminal app
35740 or any other program).
35741
35742 @item @code{bash-logout} (default: @code{()}) (type: text-config)
35743 List of strings or gexps, which will be added to @file{.bash_logout}.
35744 Used for executing user's commands at the exit of login shell. It won't
35745 be read in some cases (if the shell terminates by exec'ing another
35746 process for example).
35747
35748 @end table
35749
35750 @end deftp
35751
35752 @subsubheading Zsh Home Service
35753
35754 @deftp {Data Type} home-zsh-configuration
35755 Available @code{home-zsh-configuration} fields are:
35756
35757 @table @asis
35758 @item @code{package} (default: @code{zsh}) (type: package)
35759 The Zsh package to use.
35760
35761 @item @code{xdg-flavor?} (default: @code{#t}) (type: boolean)
35762 Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes
35763 @file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}.
35764 Shell startup process will continue with
35765 @file{$XDG_CONFIG_HOME/zsh/.zshenv}.
35766
35767 @item @code{environment-variables} (default: @code{()}) (type: alist)
35768 Association list of environment variables to set for the Zsh session.
35769
35770 @item @code{zshenv} (default: @code{()}) (type: text-config)
35771 List of strings or gexps, which will be added to @file{.zshenv}. Used
35772 for setting user's shell environment variables. Must not contain
35773 commands assuming the presence of tty or producing output. Will be read
35774 always. Will be read before any other file in @env{ZDOTDIR}.
35775
35776 @item @code{zprofile} (default: @code{()}) (type: text-config)
35777 List of strings or gexps, which will be added to @file{.zprofile}. Used
35778 for executing user's commands at start of login shell (In most cases the
35779 shell started on tty just after login). Will be read before
35780 @file{.zlogin}.
35781
35782 @item @code{zshrc} (default: @code{()}) (type: text-config)
35783 List of strings or gexps, which will be added to @file{.zshrc}. Used
35784 for executing user's commands at start of interactive shell (The shell
35785 for interactive usage started by typing @code{zsh} or by terminal app or
35786 any other program).
35787
35788 @item @code{zlogin} (default: @code{()}) (type: text-config)
35789 List of strings or gexps, which will be added to @file{.zlogin}. Used
35790 for executing user's commands at the end of starting process of login
35791 shell.
35792
35793 @item @code{zlogout} (default: @code{()}) (type: text-config)
35794 List of strings or gexps, which will be added to @file{.zlogout}. Used
35795 for executing user's commands at the exit of login shell. It won't be
35796 read in some cases (if the shell terminates by exec'ing another process
35797 for example).
35798
35799 @end table
35800
35801 @end deftp
35802
35803 @node Mcron Home Service
35804 @subsection Scheduled User's Job Execution
35805
35806 @cindex cron
35807 @cindex mcron
35808 @cindex scheduling jobs
35809
35810 The @code{(gnu home-services mcron)} module provides an interface to
35811 GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
35812 mcron, GNU@tie{}mcron}). The information about system's mcron is
35813 applicable here (@pxref{Scheduled Job Execution}), the only difference
35814 for home services is that they have to be declared in a
35815 @code{home-envirnoment} record instead of an @code{operating-system}
35816 record.
35817
35818 @defvr {Scheme Variable} home-mcron-service-type
35819 This is the type of the @code{mcron} home service, whose value is an
35820 @code{home-mcron-configuration} object. It allows to manage scheduled
35821 tasks.
35822
35823 This service type can be the target of a service extension that provides
35824 additional job specifications (@pxref{Service Composition}). In other
35825 words, it is possible to define services that provide additional mcron
35826 jobs to run.
35827 @end defvr
35828
35829 @deftp {Data Type} home-mcron-configuration
35830 Data type representing the configuration of mcron.
35831
35832 @table @asis
35833 @item @code{mcron} (default: @var{mcron})
35834 The mcron package to use.
35835
35836 @item @code{jobs}
35837 This is a list of gexps (@pxref{G-Expressions}), where each gexp
35838 corresponds to an mcron job specification (@pxref{Syntax, mcron job
35839 specifications,, mcron, GNU@tie{}mcron}).
35840 @end table
35841 @end deftp
35842
35843 @node Shepherd Home Service
35844 @subsection Managing User's Daemons
35845
35846 @cindex shepherd services
35847
35848 @defvr {Scheme Variable} home-shepherd-service-type
35849 The service type for the userland Shepherd, which allows one to manage
35850 long-running processes or one-shot tasks. User's Shepherd is not an
35851 init process (PID 1), but almost all other information described in
35852 (@pxref{Shepherd Services}) is applicable here too.
35853
35854 This is the service type that extensions target when they want to create
35855 shepherd services (@pxref{Service Types and Services}, for an example).
35856 Each extension must pass a list of @code{<shepherd-service>}. Its
35857 value must be a @code{shepherd-configuration}, as described below.
35858 @end defvr
35859
35860 @deftp {Data Type} shepherd-configuration
35861 This data type represents the Shepherd's configuration.
35862
35863 @table @code
35864 @item shepherd (default: @code{shepherd})
35865 The Shepherd package to use.
35866
35867 @item auto-start? (default: @code{#t})
35868 Whether or not to start Shepherd on first login.
35869
35870 @item services (default: @code{'()})
35871 A list of @code{<shepherd-service>} to start.
35872 You should probably use the service extension
35873 mechanism instead (@pxref{Shepherd Services}).
35874 @end table
35875 @end deftp
35876
35877 @node Invoking guix home
35878 @section Invoking @code{guix home}
35879
35880 Once you have written a home environment declaration (@pxref{Declaring
35881 the Home Environment,,,,}, it can be @dfn{instantiated} using the
35882 @command{guix home} command. The synopsis is:
35883
35884 @example
35885 guix home @var{options}@dots{} @var{action} @var{file}
35886 @end example
35887
35888 @var{file} must be the name of a file containing a
35889 @code{home-environment} declaration. @var{action} specifies how the
35890 home environment is instantiated, but there are few auxuliary actions
35891 which don't instantiate it. Currently the following values are
35892 supported:
35893
35894 @table @code
35895 @item search
35896 Display available home service type definitions that match the given
35897 regular expressions, sorted by relevance:
35898
35899 @cindex shell
35900 @cindex shell-profile
35901 @cindex bash
35902 @cindex zsh
35903 @example
35904 $ guix home search shell
35905 name: home-shell-profile
35906 location: gnu/home-services/shells.scm:73:2
35907 extends: home-files
35908 description: Create `~/.profile', which is used for environment initialization
35909 + of POSIX compatible login shells. Can be extended with a list of strings or
35910 + gexps.
35911 relevance: 6
35912
35913 name: home-zsh-plugin-manager
35914 location: gnu/home-services/shellutils.scm:28:2
35915 extends: home-zsh home-profile
35916 description: Install plugins in profile and configure Zsh to load them.
35917 relevance: 1
35918
35919 name: home-zsh-direnv
35920 location: gnu/home-services/shellutils.scm:69:2
35921 extends: home-profile home-zsh
35922 description: Enables `direnv' for `zsh'. Adds hook to `.zshrc' and installs a
35923 + package in the profile.
35924 relevance: 1
35925
35926 name: home-zsh-autosuggestions
35927 location: gnu/home-services/shellutils.scm:43:2
35928 extends: home-zsh-plugin-manager home-zsh
35929 description: Enables Fish-like fast/unobtrusive autosuggestions for `zsh' and
35930 + sets reasonable default values for some plugin's variables to improve perfomance
35931 + and adjust behavior: `(history completion)' is set for strategy, manual rebind
35932 + and async are enabled.
35933 relevance: 1
35934
35935 name: home-zsh
35936 location: gnu/home-services/shells.scm:236:2
35937 extends: home-files home-profile
35938 description: Install and configure Zsh.
35939 relevance: 1
35940
35941 name: home-bash
35942 location: gnu/home-services/shells.scm:388:2
35943 extends: home-files home-profile
35944 description: Install and configure Bash.
35945 relevance: 1
35946
35947 @dots{}
35948 @end example
35949
35950 As for @command{guix package --search}, the result is written in
35951 @code{recutils} format, which makes it easy to filter the output
35952 (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
35953
35954 @item reconfigure
35955 Build the home environment described in @var{file}, and switch to it.
35956 Switching means that the activation script will be evaluated and (in
35957 basic scenario) symlinks to configuration files generated from
35958 @code{home-environment} declaration will be created in @file{~}. If the
35959 file with the same path already exists in home folder it will be moved
35960 to @file{~/TIMESTAMP-guix-home-legacy-configs-backup}, where TIMESTAMP
35961 is a current UNIX epoch time.
35962
35963 @quotation Note
35964 It is highly recommended to run @command{guix pull} once before you run
35965 @command{guix home reconfigure} for the first time (@pxref{Invoking guix
35966 pull}).
35967 @end quotation
35968
35969 This effects all the configuration specified in @var{file}. The command
35970 starts Shepherd services specified in @var{file} that are not currently
35971 running; if a service is currently running, this command will arrange
35972 for it to be upgraded the next time it is stopped (e.g.@: by @code{herd
35973 stop X} or @code{herd restart X}).
35974
35975 This command creates a new generation whose number is one greater than
35976 the current generation (as reported by @command{guix home
35977 list-generations}). If that generation already exists, it will be
35978 overwritten. This behavior mirrors that of @command{guix package}
35979 (@pxref{Invoking guix package}).
35980
35981 @cindex provenance tracking, of the home environment
35982 Upon completion, the new home is deployed under @file{~/.guix-home}.
35983 This directory contains @dfn{provenance meta-data}: the list of channels
35984 in use (@pxref{Channels}) and @var{file} itself, when available. You
35985 can view the provenance information by running:
35986
35987 @example
35988 guix home describe
35989 @end example
35990
35991 This information is useful should you later want to inspect how this
35992 particular generation was built. In fact, assuming @var{file} is
35993 self-contained, you can later rebuild generation @var{n} of your
35994 home environment with:
35995
35996 @example
35997 guix time-machine \
35998 -C /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/channels.scm -- \
35999 home reconfigure \
36000 /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/configuration.scm
36001
36002 @end example
36003
36004 You can think of it as some sort of built-in version control! Your
36005 home is not just a binary artifact: @emph{it carries its own source}.
36006 @c @xref{Service Reference, @code{provenance-service-type}}, for more
36007 @c information on provenance tracking.
36008
36009 @c @footnote{This action (and the related actions
36010 @c @code{switch-generation} and @code{roll-back}) are usable after the
36011 @c home environment is initialized.}.
36012
36013 @item switch-generation
36014 @cindex home generations
36015 Switch to an existing home generation. This action atomically switches
36016 the home profile to the specified home generation.
36017
36018 The target generation can be specified explicitly by its generation
36019 number. For example, the following invocation would switch to home
36020 generation 7:
36021
36022 @example
36023 guix home switch-generation 7
36024 @end example
36025
36026 The target generation can also be specified relative to the current
36027 generation with the form @code{+N} or @code{-N}, where @code{+3} means
36028 ``3 generations ahead of the current generation,'' and @code{-1} means
36029 ``1 generation prior to the current generation.'' When specifying a
36030 negative value such as @code{-1}, you must precede it with @code{--} to
36031 prevent it from being parsed as an option. For example:
36032
36033 @example
36034 guix home switch-generation -- -1
36035 @end example
36036
36037 This action will fail if the specified generation does not exist.
36038
36039 @item roll-back
36040 @cindex rolling back
36041 Switch to the preceding home generation. This is the inverse
36042 of @command{reconfigure}, and it is exactly the same as invoking
36043 @command{switch-generation} with an argument of @code{-1}.
36044
36045 @item delete-generations
36046 @cindex deleting home generations
36047 @cindex saving space
36048 Delete home generations, making them candidates for garbage collection
36049 (@pxref{Invoking guix gc}, for information on how to run the ``garbage
36050 collector'').
36051
36052 This works in the same way as @samp{guix package --delete-generations}
36053 (@pxref{Invoking guix package, @option{--delete-generations}}). With no
36054 arguments, all home generations but the current one are deleted:
36055
36056 @example
36057 guix home delete-generations
36058 @end example
36059
36060 You can also select the generations you want to delete. The example below
36061 deletes all the home generations that are more than two month old:
36062
36063 @example
36064 guix home delete-generations 2m
36065 @end example
36066
36067 @item build
36068 Build the derivation of the home environment, which includes all the
36069 configuration files and programs needed. This action does not actually
36070 install anything.
36071
36072 @item describe
36073 Describe the current home generation: its file name, as well as
36074 provenance information when available.
36075
36076 @item list-generations
36077 List a summary of each generation of the home environment available on
36078 disk, in a human-readable way. This is similar to the
36079 @option{--list-generations} option of @command{guix package}
36080 (@pxref{Invoking guix package}).
36081
36082 Optionally, one can specify a pattern, with the same syntax that is used
36083 in @command{guix package --list-generations}, to restrict the list of
36084 generations displayed. For instance, the following command displays
36085 generations that are up to 10 days old:
36086
36087 @example
36088 $ guix home list-generations 10d
36089 @end example
36090
36091 @end table
36092
36093 @node Documentation
36094 @chapter Documentation
36095
36096 @cindex documentation, searching for
36097 @cindex searching for documentation
36098 @cindex Info, documentation format
36099 @cindex man pages
36100 @cindex manual pages
36101 In most cases packages installed with Guix come with documentation.
36102 There are two main documentation formats: ``Info'', a browsable
36103 hypertext format used for GNU software, and ``manual pages'' (or ``man
36104 pages''), the linear documentation format traditionally found on Unix.
36105 Info manuals are accessed with the @command{info} command or with Emacs,
36106 and man pages are accessed using @command{man}.
36107
36108 You can look for documentation of software installed on your system by
36109 keyword. For example, the following command searches for information
36110 about ``TLS'' in Info manuals:
36111
36112 @example
36113 $ info -k TLS
36114 "(emacs)Network Security" -- STARTTLS
36115 "(emacs)Network Security" -- TLS
36116 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
36117 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
36118 @dots{}
36119 @end example
36120
36121 @noindent
36122 The command below searches for the same keyword in man pages:
36123
36124 @example
36125 $ man -k TLS
36126 SSL (7) - OpenSSL SSL/TLS library
36127 certtool (1) - GnuTLS certificate tool
36128 @dots {}
36129 @end example
36130
36131 These searches are purely local to your computer so you have the
36132 guarantee that documentation you find corresponds to what you have
36133 actually installed, you can access it off-line, and your privacy is
36134 respected.
36135
36136 Once you have these results, you can view the relevant documentation by
36137 running, say:
36138
36139 @example
36140 $ info "(gnutls)Core TLS API"
36141 @end example
36142
36143 @noindent
36144 or:
36145
36146 @example
36147 $ man certtool
36148 @end example
36149
36150 Info manuals contain sections and indices as well as hyperlinks like
36151 those found in Web pages. The @command{info} reader (@pxref{Top, Info
36152 reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
36153 (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
36154 bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
36155 Introduction}, for an introduction to Info navigation.
36156
36157 @node Installing Debugging Files
36158 @chapter Installing Debugging Files
36159
36160 @cindex debugging files
36161 Program binaries, as produced by the GCC compilers for instance, are
36162 typically written in the ELF format, with a section containing
36163 @dfn{debugging information}. Debugging information is what allows the
36164 debugger, GDB, to map binary code to source code; it is required to
36165 debug a compiled program in good conditions.
36166
36167 This chapter explains how to use separate debug info when packages
36168 provide it, and how to rebuild packages with debug info when it's
36169 missing.
36170
36171 @menu
36172 * Separate Debug Info:: Installing 'debug' outputs.
36173 * Rebuilding Debug Info:: Building missing debug info.
36174 @end menu
36175
36176 @node Separate Debug Info
36177 @section Separate Debug Info
36178
36179 The problem with debugging information is that is takes up a fair amount
36180 of disk space. For example, debugging information for the GNU C Library
36181 weighs in at more than 60 MiB@. Thus, as a user, keeping all the
36182 debugging info of all the installed programs is usually not an option.
36183 Yet, space savings should not come at the cost of an impediment to
36184 debugging---especially in the GNU system, which should make it easier
36185 for users to exert their computing freedom (@pxref{GNU Distribution}).
36186
36187 Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
36188 mechanism that allows users to get the best of both worlds: debugging
36189 information can be stripped from the binaries and stored in separate
36190 files. GDB is then able to load debugging information from those files,
36191 when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
36192 with GDB}).
36193
36194 The GNU distribution takes advantage of this by storing debugging
36195 information in the @code{lib/debug} sub-directory of a separate package
36196 output unimaginatively called @code{debug} (@pxref{Packages with
36197 Multiple Outputs}). Users can choose to install the @code{debug} output
36198 of a package when they need it. For instance, the following command
36199 installs the debugging information for the GNU C Library and for GNU
36200 Guile:
36201
36202 @example
36203 guix install glibc:debug guile:debug
36204 @end example
36205
36206 GDB must then be told to look for debug files in the user's profile, by
36207 setting the @code{debug-file-directory} variable (consider setting it
36208 from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
36209 GDB}):
36210
36211 @example
36212 (gdb) set debug-file-directory ~/.guix-profile/lib/debug
36213 @end example
36214
36215 From there on, GDB will pick up debugging information from the
36216 @file{.debug} files under @file{~/.guix-profile/lib/debug}.
36217
36218 In addition, you will most likely want GDB to be able to show the source
36219 code being debugged. To do that, you will have to unpack the source
36220 code of the package of interest (obtained with @code{guix build
36221 --source}, @pxref{Invoking guix build}), and to point GDB to that source
36222 directory using the @code{directory} command (@pxref{Source Path,
36223 @code{directory},, gdb, Debugging with GDB}).
36224
36225 @c XXX: keep me up-to-date
36226 The @code{debug} output mechanism in Guix is implemented by the
36227 @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
36228 opt-in---debugging information is available only for the packages with
36229 definitions explicitly declaring a @code{debug} output. To check
36230 whether a package has a @code{debug} output, use @command{guix package
36231 --list-available} (@pxref{Invoking guix package}).
36232
36233 Read on for how to deal with packages lacking a @code{debug} output.
36234
36235 @node Rebuilding Debug Info
36236 @section Rebuilding Debug Info
36237
36238 @cindex debugging info, rebuilding
36239 As we saw above, some packages, but not all, provide debugging info in a
36240 @code{debug} output. What can you do when debugging info is missing?
36241 The @option{--with-debug-info} option provides a solution to that: it
36242 allows you to rebuild the package(s) for which debugging info is
36243 missing---and only those---and to graft those onto the application
36244 you're debugging. Thus, while it's not as fast as installing a
36245 @code{debug} output, it is relatively inexpensive.
36246
36247 Let's illustrate that. Suppose you're experiencing a bug in Inkscape
36248 and would like to see what's going on in GLib, a library that's deep
36249 down in its dependency graph. As it turns out, GLib does not have a
36250 @code{debug} output and the backtrace GDB shows is all sadness:
36251
36252 @example
36253 (gdb) bt
36254 #0 0x00007ffff5f92190 in g_getenv ()
36255 from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
36256 #1 0x00007ffff608a7d6 in gobject_init_ctor ()
36257 from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
36258 #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
36259 env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
36260 #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
36261 at dl-init.c:118
36262 @end example
36263
36264 To address that, you install Inkscape linked against a variant GLib that
36265 contains debug info:
36266
36267 @example
36268 guix install inkscape --with-debug-info=glib
36269 @end example
36270
36271 This time, debugging will be a whole lot nicer:
36272
36273 @example
36274 $ gdb --args sh -c 'exec inkscape'
36275 @dots{}
36276 (gdb) b g_getenv
36277 Function "g_getenv" not defined.
36278 Make breakpoint pending on future shared library load? (y or [n]) y
36279 Breakpoint 1 (g_getenv) pending.
36280 (gdb) r
36281 Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
36282 @dots{}
36283 (gdb) bt
36284 #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
36285 #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
36286 #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
36287 #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
36288 env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
36289 @dots{}
36290 @end example
36291
36292 Much better!
36293
36294 Note that there can be packages for which @option{--with-debug-info}
36295 will not have the desired effect. @xref{Package Transformation Options,
36296 @option{--with-debug-info}}, for more information.
36297
36298 @node Security Updates
36299 @chapter Security Updates
36300
36301 @cindex security updates
36302 @cindex security vulnerabilities
36303 Occasionally, important security vulnerabilities are discovered in software
36304 packages and must be patched. Guix developers try hard to keep track of
36305 known vulnerabilities and to apply fixes as soon as possible in the
36306 @code{master} branch of Guix (we do not yet provide a ``stable'' branch
36307 containing only security updates). The @command{guix lint} tool helps
36308 developers find out about vulnerable versions of software packages in the
36309 distribution:
36310
36311 @smallexample
36312 $ guix lint -c cve
36313 gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
36314 gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
36315 gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
36316 @dots{}
36317 @end smallexample
36318
36319 @xref{Invoking guix lint}, for more information.
36320
36321 Guix follows a functional
36322 package management discipline (@pxref{Introduction}), which implies
36323 that, when a package is changed, @emph{every package that depends on it}
36324 must be rebuilt. This can significantly slow down the deployment of
36325 fixes in core packages such as libc or Bash, since basically the whole
36326 distribution would need to be rebuilt. Using pre-built binaries helps
36327 (@pxref{Substitutes}), but deployment may still take more time than
36328 desired.
36329
36330 @cindex grafts
36331 To address this, Guix implements @dfn{grafts}, a mechanism that allows
36332 for fast deployment of critical updates without the costs associated
36333 with a whole-distribution rebuild. The idea is to rebuild only the
36334 package that needs to be patched, and then to ``graft'' it onto packages
36335 explicitly installed by the user and that were previously referring to
36336 the original package. The cost of grafting is typically very low, and
36337 order of magnitudes lower than a full rebuild of the dependency chain.
36338
36339 @cindex replacements of packages, for grafts
36340 For instance, suppose a security update needs to be applied to Bash.
36341 Guix developers will provide a package definition for the ``fixed''
36342 Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
36343 Packages}). Then, the original package definition is augmented with a
36344 @code{replacement} field pointing to the package containing the bug fix:
36345
36346 @lisp
36347 (define bash
36348 (package
36349 (name "bash")
36350 ;; @dots{}
36351 (replacement bash-fixed)))
36352 @end lisp
36353
36354 From there on, any package depending directly or indirectly on Bash---as
36355 reported by @command{guix gc --requisites} (@pxref{Invoking guix
36356 gc})---that is installed is automatically ``rewritten'' to refer to
36357 @code{bash-fixed} instead of @code{bash}. This grafting process takes
36358 time proportional to the size of the package, usually less than a
36359 minute for an ``average'' package on a recent machine. Grafting is
36360 recursive: when an indirect dependency requires grafting, then grafting
36361 ``propagates'' up to the package that the user is installing.
36362
36363 Currently, the length of the name and version of the graft and that of
36364 the package it replaces (@code{bash-fixed} and @code{bash} in the example
36365 above) must be equal. This restriction mostly comes from the fact that
36366 grafting works by patching files, including binary files, directly.
36367 Other restrictions may apply: for instance, when adding a graft to a
36368 package providing a shared library, the original shared library and its
36369 replacement must have the same @code{SONAME} and be binary-compatible.
36370
36371 The @option{--no-grafts} command-line option allows you to forcefully
36372 avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
36373 Thus, the command:
36374
36375 @example
36376 guix build bash --no-grafts
36377 @end example
36378
36379 @noindent
36380 returns the store file name of the original Bash, whereas:
36381
36382 @example
36383 guix build bash
36384 @end example
36385
36386 @noindent
36387 returns the store file name of the ``fixed'', replacement Bash. This
36388 allows you to distinguish between the two variants of Bash.
36389
36390 To verify which Bash your whole profile refers to, you can run
36391 (@pxref{Invoking guix gc}):
36392
36393 @example
36394 guix gc -R $(readlink -f ~/.guix-profile) | grep bash
36395 @end example
36396
36397 @noindent
36398 @dots{} and compare the store file names that you get with those above.
36399 Likewise for a complete Guix system generation:
36400
36401 @example
36402 guix gc -R $(guix system build my-config.scm) | grep bash
36403 @end example
36404
36405 Lastly, to check which Bash running processes are using, you can use the
36406 @command{lsof} command:
36407
36408 @example
36409 lsof | grep /gnu/store/.*bash
36410 @end example
36411
36412
36413 @node Bootstrapping
36414 @chapter Bootstrapping
36415
36416 @c Adapted from the ELS 2013 paper.
36417
36418 @cindex bootstrapping
36419
36420 Bootstrapping in our context refers to how the distribution gets built
36421 ``from nothing''. Remember that the build environment of a derivation
36422 contains nothing but its declared inputs (@pxref{Introduction}). So
36423 there's an obvious chicken-and-egg problem: how does the first package
36424 get built? How does the first compiler get compiled?
36425
36426 It is tempting to think of this question as one that only die-hard
36427 hackers may care about. However, while the answer to that question is
36428 technical in nature, its implications are wide-ranging. How the
36429 distribution is bootstrapped defines the extent to which we, as
36430 individuals and as a collective of users and hackers, can trust the
36431 software we run. It is a central concern from the standpoint of
36432 @emph{security} and from a @emph{user freedom} viewpoint.
36433
36434 @cindex bootstrap binaries
36435 The GNU system is primarily made of C code, with libc at its core. The
36436 GNU build system itself assumes the availability of a Bourne shell and
36437 command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
36438 `grep'. Furthermore, build programs---programs that run
36439 @code{./configure}, @code{make}, etc.---are written in Guile Scheme
36440 (@pxref{Derivations}). Consequently, to be able to build anything at
36441 all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
36442 Binutils, libc, and the other packages mentioned above---the
36443 @dfn{bootstrap binaries}.
36444
36445 These bootstrap binaries are ``taken for granted'', though we can also
36446 re-create them if needed (@pxref{Preparing to Use the Bootstrap
36447 Binaries}).
36448
36449 @menu
36450 * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
36451 * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
36452 @end menu
36453
36454 @node Reduced Binary Seed Bootstrap
36455 @section The Reduced Binary Seed Bootstrap
36456
36457 Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
36458 a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
36459 Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
36460 GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
36461 ``taken for granted.''
36462
36463 Taking the bootstrap binaries for granted means that we consider them to
36464 be a correct and trustworthy ``seed'' for building the complete system.
36465 Therein lies a problem: the combined size of these bootstrap binaries is
36466 about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
36467 or even inspecting these is next to impossible.
36468
36469 For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
36470 ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
36471 Source Bootstrap'' and while we are working towards that goal it would
36472 be hyperbole to use that term for what we do now.}.
36473
36474 The Reduced Binary Seed bootstrap removes the most critical tools---from a
36475 trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
36476 Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
36477 linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
36478 written in Scheme and the Mes C Library, built for TinyCC and for GCC).
36479
36480 Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
36481 C Library are built from source. From here on the more traditional
36482 bootstrap process resumes. This approach has reduced the bootstrap
36483 binaries in size to about 145MB in Guix v1.1.
36484
36485 The next step that Guix has taken is to replace the shell and all its
36486 utilities with implementations in Guile Scheme, the @emph{Scheme-only
36487 bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
36488 POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
36489 which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
36490 Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
36491 removed are now built from source.
36492
36493 Building the GNU System from source is currently only possible by adding
36494 some historical GNU packages as intermediate steps@footnote{Packages
36495 such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
36496 @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
36497 @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
36498 and GNU packages become more bootstrappable again (e.g., new releases of
36499 GNU Sed will also ship as gzipped tarballs again, as alternative to the
36500 hard to bootstrap @code{xz}-compression), this set of added packages can
36501 hopefully be reduced again.
36502
36503 The graph below shows the resulting dependency graph for
36504 @code{gcc-core-mesboot0}, the bootstrap compiler used for the
36505 traditional bootstrap of the rest of the Guix System.
36506
36507 @c ./pre-inst-env guix graph -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' | sed -re 's,((bootstrap-mescc-tools|bootstrap-mes|guile-bootstrap).*shape =) box,\1 ellipse,' > doc/images/gcc-core-mesboot0-graph.dot
36508 @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
36509
36510 The only significant binary bootstrap seeds that remain@footnote{
36511 Ignoring the 68KB @code{mescc-tools}; that will be removed later,
36512 together with @code{mes}.} are a Scheme interpreter and a Scheme
36513 compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
36514 static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
36515 to get Guile running.}.
36516
36517 This further reduction has brought down the size of the binary seed to
36518 about 60MB for @code{i686-linux} and @code{x86_64-linux}.
36519
36520 Work is ongoing to remove all binary blobs from our free software
36521 bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
36522 is work to bring these bootstraps to the @code{arm-linux} and
36523 @code{aarch64-linux} architectures and to the Hurd.
36524
36525 If you are interested, join us on @samp{#bootstrappable} on the Freenode
36526 IRC network or discuss on @email{bug-mes@@gnu.org} or
36527 @email{gash-devel@@nongnu.org}.
36528
36529 @node Preparing to Use the Bootstrap Binaries
36530 @section Preparing to Use the Bootstrap Binaries
36531
36532 @c As of Emacs 24.3, Info-mode displays the image, but since it's a
36533 @c large image, it's hard to scroll. Oh well.
36534 @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
36535
36536 The figure above shows the very beginning of the dependency graph of the
36537 distribution, corresponding to the package definitions of the @code{(gnu
36538 packages bootstrap)} module. A similar figure can be generated with
36539 @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
36540
36541 @example
36542 guix graph -t derivation \
36543 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
36544 | dot -Tps > gcc.ps
36545 @end example
36546
36547 or, for the further Reduced Binary Seed bootstrap
36548
36549 @example
36550 guix graph -t derivation \
36551 -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
36552 | dot -Tps > mes.ps
36553 @end example
36554
36555 At this level of detail, things are
36556 slightly complex. First, Guile itself consists of an ELF executable,
36557 along with many source and compiled Scheme files that are dynamically
36558 loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
36559 tarball shown in this graph. This tarball is part of Guix's ``source''
36560 distribution, and gets inserted into the store with @code{add-to-store}
36561 (@pxref{The Store}).
36562
36563 But how do we write a derivation that unpacks this tarball and adds it
36564 to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
36565 derivation---the first one that gets built---uses @code{bash} as its
36566 builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
36567 @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
36568 @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
36569 the Guix source distribution, whose sole purpose is to allow the Guile
36570 tarball to be unpacked.
36571
36572 Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
36573 Guile that can be used to run subsequent build programs. Its first task
36574 is to download tarballs containing the other pre-built binaries---this
36575 is what the @file{.tar.xz.drv} derivations do. Guix modules such as
36576 @code{ftp-client.scm} are used for this purpose. The
36577 @code{module-import.drv} derivations import those modules in a directory
36578 in the store, using the original layout. The
36579 @code{module-import-compiled.drv} derivations compile those modules, and
36580 write them in an output directory with the right layout. This
36581 corresponds to the @code{#:modules} argument of
36582 @code{build-expression->derivation} (@pxref{Derivations}).
36583
36584 Finally, the various tarballs are unpacked by the derivations
36585 @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
36586 @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
36587 point we have a working C tool chain.
36588
36589 @unnumberedsec Building the Build Tools
36590
36591 Bootstrapping is complete when we have a full tool chain that does not
36592 depend on the pre-built bootstrap tools discussed above. This
36593 no-dependency requirement is verified by checking whether the files of
36594 the final tool chain contain references to the @file{/gnu/store}
36595 directories of the bootstrap inputs. The process that leads to this
36596 ``final'' tool chain is described by the package definitions found in
36597 the @code{(gnu packages commencement)} module.
36598
36599 The @command{guix graph} command allows us to ``zoom out'' compared to
36600 the graph above, by looking at the level of package objects instead of
36601 individual derivations---remember that a package may translate to
36602 several derivations, typically one derivation to download its source,
36603 one to build the Guile modules it needs, and one to actually build the
36604 package from source. The command:
36605
36606 @example
36607 guix graph -t bag \
36608 -e '(@@@@ (gnu packages commencement)
36609 glibc-final-with-bootstrap-bash)' | xdot -
36610 @end example
36611
36612 @noindent
36613 displays the dependency graph leading to the ``final'' C
36614 library@footnote{You may notice the @code{glibc-intermediate} label,
36615 suggesting that it is not @emph{quite} final, but as a good
36616 approximation, we will consider it final.}, depicted below.
36617
36618 @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
36619
36620 @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
36621 The first tool that gets built with the bootstrap binaries is
36622 GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
36623 for all the following packages. From there Findutils and Diffutils get
36624 built.
36625
36626 Then come the first-stage Binutils and GCC, built as pseudo cross
36627 tools---i.e., with @option{--target} equal to @option{--host}. They are
36628 used to build libc. Thanks to this cross-build trick, this libc is
36629 guaranteed not to hold any reference to the initial tool chain.
36630
36631 From there the final Binutils and GCC (not shown above) are built. GCC
36632 uses @command{ld} from the final Binutils, and links programs against
36633 the just-built libc. This tool chain is used to build the other
36634 packages used by Guix and by the GNU Build System: Guile, Bash,
36635 Coreutils, etc.
36636
36637 And voilà! At this point we have the complete set of build tools that
36638 the GNU Build System expects. These are in the @code{%final-inputs}
36639 variable of the @code{(gnu packages commencement)} module, and are
36640 implicitly used by any package that uses @code{gnu-build-system}
36641 (@pxref{Build Systems, @code{gnu-build-system}}).
36642
36643
36644 @unnumberedsec Building the Bootstrap Binaries
36645
36646 @cindex bootstrap binaries
36647 Because the final tool chain does not depend on the bootstrap binaries,
36648 those rarely need to be updated. Nevertheless, it is useful to have an
36649 automated way to produce them, should an update occur, and this is what
36650 the @code{(gnu packages make-bootstrap)} module provides.
36651
36652 The following command builds the tarballs containing the bootstrap binaries
36653 (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
36654 bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
36655 and Guile, and a tarball containing a mixture of Coreutils and other basic
36656 command-line tools):
36657
36658 @example
36659 guix build bootstrap-tarballs
36660 @end example
36661
36662 The generated tarballs are those that should be referred to in the
36663 @code{(gnu packages bootstrap)} module mentioned at the beginning of
36664 this section.
36665
36666 Still here? Then perhaps by now you've started to wonder: when do we
36667 reach a fixed point? That is an interesting question! The answer is
36668 unknown, but if you would like to investigate further (and have
36669 significant computational and storage resources to do so), then let us
36670 know.
36671
36672 @unnumberedsec Reducing the Set of Bootstrap Binaries
36673
36674 Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
36675 binary code! Why is that a problem? It's a problem because these big chunks
36676 of binary code are practically non-auditable, which makes it hard to establish
36677 what source code produced them. Every unauditable binary also leaves us
36678 vulnerable to compiler backdoors as described by Ken Thompson in the 1984
36679 paper @emph{Reflections on Trusting Trust}.
36680
36681 This is mitigated by the fact that our bootstrap binaries were generated
36682 from an earlier Guix revision. Nevertheless it lacks the level of
36683 transparency that we get in the rest of the package dependency graph,
36684 where Guix always gives us a source-to-binary mapping. Thus, our goal
36685 is to reduce the set of bootstrap binaries to the bare minimum.
36686
36687 The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
36688 on-going projects to do that. One of these is about replacing the
36689 bootstrap GCC with a sequence of assemblers, interpreters, and compilers
36690 of increasing complexity, which could be built from source starting from
36691 a simple and auditable assembler.
36692
36693 Our first major achievement is the replacement of of GCC, the GNU C Library
36694 and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
36695 (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
36696 and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
36697 bootstrapped yet and thus we inject them as binary seeds. We call this the
36698 Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
36699 binaries! Also, it has eliminated the C compiler binary; i686-linux and
36700 x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
36701
36702 Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
36703 also looking at any other bootstrap binaries. Your help is welcome!
36704
36705 @node Porting
36706 @chapter Porting to a New Platform
36707
36708 As discussed above, the GNU distribution is self-contained, and
36709 self-containment is achieved by relying on pre-built ``bootstrap
36710 binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
36711 operating system kernel, CPU architecture, and application binary
36712 interface (ABI). Thus, to port the distribution to a platform that is
36713 not yet supported, one must build those bootstrap binaries, and update
36714 the @code{(gnu packages bootstrap)} module to use them on that platform.
36715
36716 Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
36717 When everything goes well, and assuming the GNU tool chain supports the
36718 target platform, this can be as simple as running a command like this
36719 one:
36720
36721 @example
36722 guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
36723 @end example
36724
36725 For this to work, the @code{glibc-dynamic-linker} procedure in
36726 @code{(gnu packages bootstrap)} must be augmented to return the right
36727 file name for libc's dynamic linker on that platform; likewise,
36728 @code{system->linux-architecture} in @code{(gnu packages linux)} must be
36729 taught about the new platform.
36730
36731 Once these are built, the @code{(gnu packages bootstrap)} module needs
36732 to be updated to refer to these binaries on the target platform. That
36733 is, the hashes and URLs of the bootstrap tarballs for the new platform
36734 must be added alongside those of the currently supported platforms. The
36735 bootstrap Guile tarball is treated specially: it is expected to be
36736 available locally, and @file{gnu/local.mk} has rules to download it for
36737 the supported architectures; a rule for the new platform must be added
36738 as well.
36739
36740 In practice, there may be some complications. First, it may be that the
36741 extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
36742 above) is not recognized by all the GNU tools. Typically, glibc
36743 recognizes some of these, whereas GCC uses an extra @option{--with-abi}
36744 configure flag (see @code{gcc.scm} for examples of how to handle this).
36745 Second, some of the required packages could fail to build for that
36746 platform. Lastly, the generated binaries could be broken for some
36747 reason.
36748
36749 @c *********************************************************************
36750 @include contributing.texi
36751
36752 @c *********************************************************************
36753 @node Acknowledgments
36754 @chapter Acknowledgments
36755
36756 Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
36757 which was designed and
36758 implemented by Eelco Dolstra, with contributions from other people (see
36759 the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
36760 management, and promoted unprecedented features, such as transactional
36761 package upgrades and rollbacks, per-user profiles, and referentially
36762 transparent build processes. Without this work, Guix would not exist.
36763
36764 The Nix-based software distributions, Nixpkgs and NixOS, have also been
36765 an inspiration for Guix.
36766
36767 GNU@tie{}Guix itself is a collective work with contributions from a
36768 number of people. See the @file{AUTHORS} file in Guix for more
36769 information on these fine people. The @file{THANKS} file lists people
36770 who have helped by reporting bugs, taking care of the infrastructure,
36771 providing artwork and themes, making suggestions, and more---thank you!
36772
36773
36774 @c *********************************************************************
36775 @node GNU Free Documentation License
36776 @appendix GNU Free Documentation License
36777 @cindex license, GNU Free Documentation License
36778 @include fdl-1.3.texi
36779
36780 @c *********************************************************************
36781 @node Concept Index
36782 @unnumbered Concept Index
36783 @printindex cp
36784
36785 @node Programming Index
36786 @unnumbered Programming Index
36787 @syncodeindex tp fn
36788 @syncodeindex vr fn
36789 @printindex fn
36790
36791 @bye
36792
36793 @c Local Variables:
36794 @c ispell-local-dictionary: "american";
36795 @c End: