906ebff555c6baf9cb92b62f9ef7366c1dff05d3
[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 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
14 @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=15145
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 ci.guix.gnu.org
21 @set SUBSTITUTE-URL https://@value{SUBSTITUTE-SERVER}
22
23 @copying
24 Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès@*
25 Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
26 Copyright @copyright{} 2013 Nikita Karetnikov@*
27 Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
28 Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
29 Copyright @copyright{} 2014 Pierre-Antoine Rault@*
30 Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
31 Copyright @copyright{} 2015, 2016, 2017, 2019, 2020 Leo Famulari@*
32 Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus@*
33 Copyright @copyright{} 2016 Ben Woodcroft@*
34 Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
35 Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Efraim Flashner@*
36 Copyright @copyright{} 2016 John Darrington@*
37 Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
38 Copyright @copyright{} 2016, 2017, 2018, 2019 Jan Nieuwenhuizen@*
39 Copyright @copyright{} 2016 Julien Lepiller@*
40 Copyright @copyright{} 2016 Alex ter Weele@*
41 Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@*
42 Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
43 Copyright @copyright{} 2017, 2018 Mathieu Othacehe@*
44 Copyright @copyright{} 2017 Federico Beffa@*
45 Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
46 Copyright @copyright{} 2017 Thomas Danckaert@*
47 Copyright @copyright{} 2017 humanitiesNerd@*
48 Copyright @copyright{} 2017 Christopher Allan Webber@*
49 Copyright @copyright{} 2017, 2018, 2019, 2020 Marius Bakke@*
50 Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
51 Copyright @copyright{} 2017, 2019, 2020 Maxim Cournoyer@*
52 Copyright @copyright{} 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice@*
53 Copyright @copyright{} 2017 George Clemmer@*
54 Copyright @copyright{} 2017 Andy Wingo@*
55 Copyright @copyright{} 2017, 2018, 2019 Arun Isaac@*
56 Copyright @copyright{} 2017 nee@*
57 Copyright @copyright{} 2018 Rutger Helling@*
58 Copyright @copyright{} 2018 Oleg Pykhalov@*
59 Copyright @copyright{} 2018 Mike Gerwitz@*
60 Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
61 Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
62 Copyright @copyright{} 2018, 2019 Florian Pelz@*
63 Copyright @copyright{} 2018 Laura Lazzati@*
64 Copyright @copyright{} 2018 Alex Vong@*
65 Copyright @copyright{} 2019 Josh Holland@*
66 Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
67 Copyright @copyright{} 2019 Ivan Petkov@*
68 Copyright @copyright{} 2019 Jakob L. Kreuze@*
69 Copyright @copyright{} 2019 Kyle Andrews@*
70 Copyright @copyright{} 2019 Alex Griffin@*
71 Copyright @copyright{} 2019 Guillaume Le Vaillant@*
72 Copyright @copyright{} 2020 Leo Prikler@*
73 Copyright @copyright{} 2019, 2020 Simon Tournier@*
74 Copyright @copyright{} 2020 Wiktor Żelazny@*
75 Copyright @copyright{} 2020 Damien Cassou@*
76 Copyright @copyright{} 2020 Jakub Kądziołka@*
77 Copyright @copyright{} 2020 Jack Hill@*
78 Copyright @copyright{} 2020 Naga Malleswari@*
79 Copyright @copyright{} 2020 Brice Waegeneire@*
80 Copyright @copyright{} 2020 R Veera Kumar@*
81 Copyright @copyright{} 2020 Pierre Langlois@*
82 Copyright @copyright{} 2020 pinoaffe@*
83
84 Permission is granted to copy, distribute and/or modify this document
85 under the terms of the GNU Free Documentation License, Version 1.3 or
86 any later version published by the Free Software Foundation; with no
87 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
88 copy of the license is included in the section entitled ``GNU Free
89 Documentation License''.
90 @end copying
91
92 @dircategory System administration
93 @direntry
94 * Guix: (guix). Manage installed software and system configuration.
95 * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
96 * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
97 * guix pull: (guix)Invoking guix pull. Update the list of available packages.
98 * guix system: (guix)Invoking guix system. Manage the operating system configuration.
99 * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
100 @end direntry
101
102 @dircategory Software development
103 @direntry
104 * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
105 * guix build: (guix)Invoking guix build. Building packages.
106 * guix pack: (guix)Invoking guix pack. Creating binary bundles.
107 @end direntry
108
109 @titlepage
110 @title GNU Guix Reference Manual
111 @subtitle Using the GNU Guix Functional Package Manager
112 @author The GNU Guix Developers
113
114 @page
115 @vskip 0pt plus 1filll
116 Edition @value{EDITION} @*
117 @value{UPDATED} @*
118
119 @insertcopying
120 @end titlepage
121
122 @contents
123
124 @c *********************************************************************
125 @node Top
126 @top GNU Guix
127
128 This document describes GNU Guix version @value{VERSION}, a functional
129 package management tool written for the GNU system.
130
131 @c TRANSLATORS: You can replace the following paragraph with information on
132 @c how to join your own translation team and how to report issues with the
133 @c translation.
134 This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
135 GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
136 Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
137 Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
138 Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
139 would like to translate it in your native language, consider joining the
140 @uref{https://translationproject.org/domain/guix-manual.html, Translation
141 Project}.
142
143 @menu
144 * Introduction:: What is Guix about?
145 * Installation:: Installing Guix.
146 * System Installation:: Installing the whole operating system.
147 * Package Management:: Package installation, upgrade, etc.
148 * Development:: Guix-aided software development.
149 * Programming Interface:: Using Guix in Scheme.
150 * Utilities:: Package management commands.
151 * System Configuration:: Configuring the operating system.
152 * Documentation:: Browsing software user manuals.
153 * Installing Debugging Files:: Feeding the debugger.
154 * Security Updates:: Deploying security fixes quickly.
155 * Bootstrapping:: GNU/Linux built from scratch.
156 * Porting:: Targeting another platform or kernel.
157 * Contributing:: Your help needed!
158
159 * Acknowledgments:: Thanks!
160 * GNU Free Documentation License:: The license of this manual.
161 * Concept Index:: Concepts.
162 * Programming Index:: Data types, functions, and variables.
163
164 @detailmenu
165 --- The Detailed Node Listing ---
166
167 Introduction
168
169 * Managing Software the Guix Way:: What's special.
170 * GNU Distribution:: The packages and tools.
171
172 Installation
173
174 * Binary Installation:: Getting Guix running in no time!
175 * Requirements:: Software needed to build and run Guix.
176 * Running the Test Suite:: Testing Guix.
177 * Setting Up the Daemon:: Preparing the build daemon's environment.
178 * Invoking guix-daemon:: Running the build daemon.
179 * Application Setup:: Application-specific setup.
180
181 Setting Up the Daemon
182
183 * Build Environment Setup:: Preparing the isolated build environment.
184 * Daemon Offload Setup:: Offloading builds to remote machines.
185 * SELinux Support:: Using an SELinux policy for the daemon.
186
187 System Installation
188
189 * Limitations:: What you can expect.
190 * Hardware Considerations:: Supported hardware.
191 * USB Stick and DVD Installation:: Preparing the installation medium.
192 * Preparing for Installation:: Networking, partitioning, etc.
193 * Guided Graphical Installation:: Easy graphical installation.
194 * Manual Installation:: Manual installation for wizards.
195 * After System Installation:: When installation succeeded.
196 * Installing Guix in a VM:: Guix System playground.
197 * Building the Installation Image:: How this comes to be.
198
199 Manual Installation
200
201 * Keyboard Layout and Networking and Partitioning:: Initial setup.
202 * Proceeding with the Installation:: Installing.
203
204 Package Management
205
206 * Features:: How Guix will make your life brighter.
207 * Invoking guix package:: Package installation, removal, etc.
208 * Substitutes:: Downloading pre-built binaries.
209 * Packages with Multiple Outputs:: Single source package, multiple outputs.
210 * Invoking guix gc:: Running the garbage collector.
211 * Invoking guix pull:: Fetching the latest Guix and distribution.
212 * Channels:: Customizing the package collection.
213 * Invoking guix time-machine:: Running an older revision of Guix.
214 * Inferiors:: Interacting with another revision of Guix.
215 * Invoking guix describe:: Display information about your Guix revision.
216 * Invoking guix archive:: Exporting and importing store files.
217
218 Substitutes
219
220 * Official Substitute Server:: One particular source of substitutes.
221 * Substitute Server Authorization:: How to enable or disable substitutes.
222 * Substitute Authentication:: How Guix verifies substitutes.
223 * Proxy Settings:: How to get substitutes via proxy.
224 * Substitution Failure:: What happens when substitution fails.
225 * On Trusting Binaries:: How can you trust that binary blob?
226
227 Development
228
229 * Invoking guix environment:: Setting up development environments.
230 * Invoking guix pack:: Creating software bundles.
231
232 Programming Interface
233
234 * Package Modules:: Packages from the programmer's viewpoint.
235 * Defining Packages:: Defining new packages.
236 * Build Systems:: Specifying how packages are built.
237 * The Store:: Manipulating the package store.
238 * Derivations:: Low-level interface to package derivations.
239 * The Store Monad:: Purely functional interface to the store.
240 * G-Expressions:: Manipulating build expressions.
241 * Invoking guix repl:: Fiddling with Guix interactively.
242
243 Defining Packages
244
245 * package Reference:: The package data type.
246 * origin Reference:: The origin data type.
247
248 Utilities
249
250 * Invoking guix build:: Building packages from the command line.
251 * Invoking guix edit:: Editing package definitions.
252 * Invoking guix download:: Downloading a file and printing its hash.
253 * Invoking guix hash:: Computing the cryptographic hash of a file.
254 * Invoking guix import:: Importing package definitions.
255 * Invoking guix refresh:: Updating package definitions.
256 * Invoking guix lint:: Finding errors in package definitions.
257 * Invoking guix size:: Profiling disk usage.
258 * Invoking guix graph:: Visualizing the graph of packages.
259 * Invoking guix publish:: Sharing substitutes.
260 * Invoking guix challenge:: Challenging substitute servers.
261 * Invoking guix copy:: Copying to and from a remote store.
262 * Invoking guix container:: Process isolation.
263 * Invoking guix weather:: Assessing substitute availability.
264 * Invoking guix processes:: Listing client processes.
265
266 Invoking @command{guix build}
267
268 * Common Build Options:: Build options for most commands.
269 * Package Transformation Options:: Creating variants of packages.
270 * Additional Build Options:: Options specific to 'guix build'.
271 * Debugging Build Failures:: Real life packaging experience.
272
273 System Configuration
274
275 * Using the Configuration System:: Customizing your GNU system.
276 * operating-system Reference:: Detail of operating-system declarations.
277 * File Systems:: Configuring file system mounts.
278 * Mapped Devices:: Block device extra processing.
279 * User Accounts:: Specifying user accounts.
280 * Keyboard Layout:: How the system interprets key strokes.
281 * Locales:: Language and cultural convention settings.
282 * Services:: Specifying system services.
283 * Setuid Programs:: Programs running with root privileges.
284 * X.509 Certificates:: Authenticating HTTPS servers.
285 * Name Service Switch:: Configuring libc's name service switch.
286 * Initial RAM Disk:: Linux-Libre bootstrapping.
287 * Bootloader Configuration:: Configuring the boot loader.
288 * Invoking guix system:: Instantiating a system configuration.
289 * Invoking guix deploy:: Deploying a system configuration to a remote host.
290 * Running Guix in a VM:: How to run Guix System in a virtual machine.
291 * Defining Services:: Adding new service definitions.
292
293 Services
294
295 * Base Services:: Essential system services.
296 * Scheduled Job Execution:: The mcron service.
297 * Log Rotation:: The rottlog service.
298 * Networking Services:: Network setup, SSH daemon, etc.
299 * X Window:: Graphical display.
300 * Printing Services:: Local and remote printer support.
301 * Desktop Services:: D-Bus and desktop services.
302 * Sound Services:: ALSA and Pulseaudio services.
303 * Database Services:: SQL databases, key-value stores, etc.
304 * Mail Services:: IMAP, POP3, SMTP, and all that.
305 * Messaging Services:: Messaging services.
306 * Telephony Services:: Telephony services.
307 * Monitoring Services:: Monitoring services.
308 * Kerberos Services:: Kerberos services.
309 * Web Services:: Web servers.
310 * Certificate Services:: TLS certificates via Let's Encrypt.
311 * DNS Services:: DNS daemons.
312 * VPN Services:: VPN daemons.
313 * Network File System:: NFS related services.
314 * Continuous Integration:: The Cuirass service.
315 * Power Management Services:: Extending battery life.
316 * Audio Services:: The MPD.
317 * Virtualization Services:: Virtualization services.
318 * Version Control Services:: Providing remote access to Git repositories.
319 * Game Services:: Game servers.
320 * PAM Mount Service:: Service to mount volumes when logging in.
321 * Linux Services:: Services tied to the Linux kernel.
322 * Miscellaneous Services:: Other services.
323
324 Defining Services
325
326 * Service Composition:: The model for composing services.
327 * Service Types and Services:: Types and services.
328 * Service Reference:: API reference.
329 * Shepherd Services:: A particular type of service.
330
331 @end detailmenu
332 @end menu
333
334 @c *********************************************************************
335 @node Introduction
336 @chapter Introduction
337
338 @cindex purpose
339 GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
340 using the international phonetic alphabet (IPA).} is a package
341 management tool for and distribution of the GNU system.
342 Guix makes it easy for unprivileged
343 users to install, upgrade, or remove software packages, to roll back to a
344 previous package set, to build packages from source, and generally
345 assists with the creation and maintenance of software environments.
346
347 @cindex Guix System
348 @cindex GuixSD, now Guix System
349 @cindex Guix System Distribution, now Guix System
350 You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
351 complements the available tools without interference (@pxref{Installation}),
352 or you can use it as a standalone operating system distribution,
353 @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
354 System Distribution'' or ``GuixSD''. We now consider it makes more sense to
355 group everything under the ``Guix'' banner since, after all, Guix System is
356 readily available through the @command{guix system} command, even if you're
357 using a different distro underneath!}. @xref{GNU Distribution}.
358
359 @menu
360 * Managing Software the Guix Way:: What's special.
361 * GNU Distribution:: The packages and tools.
362 @end menu
363
364 @node Managing Software the Guix Way
365 @section Managing Software the Guix Way
366
367 @cindex user interfaces
368 Guix provides a command-line package management interface
369 (@pxref{Package Management}), tools to help with software development
370 (@pxref{Development}), command-line utilities for more advanced usage,
371 (@pxref{Utilities}), as well as Scheme programming interfaces
372 (@pxref{Programming Interface}).
373 @cindex build daemon
374 Its @dfn{build daemon} is responsible for building packages on behalf of
375 users (@pxref{Setting Up the Daemon}) and for downloading pre-built
376 binaries from authorized sources (@pxref{Substitutes}).
377
378 @cindex extensibility of the distribution
379 @cindex customization, of packages
380 Guix includes package definitions for many GNU and non-GNU packages, all
381 of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
382 user's computing freedom}. It is @emph{extensible}: users can write
383 their own package definitions (@pxref{Defining Packages}) and make them
384 available as independent package modules (@pxref{Package Modules}). It
385 is also @emph{customizable}: users can @emph{derive} specialized package
386 definitions from existing ones, including from the command line
387 (@pxref{Package Transformation Options}).
388
389 @cindex functional package management
390 @cindex isolation
391 Under the hood, Guix implements the @dfn{functional package management}
392 discipline pioneered by Nix (@pxref{Acknowledgments}).
393 In Guix, the package build and installation process is seen
394 as a @emph{function}, in the mathematical sense. That function takes inputs,
395 such as build scripts, a compiler, and libraries, and
396 returns an installed package. As a pure function, its result depends
397 solely on its inputs---for instance, it cannot refer to software or
398 scripts that were not explicitly passed as inputs. A build function
399 always produces the same result when passed a given set of inputs. It
400 cannot alter the environment of the running system in
401 any way; for instance, it cannot create, modify, or delete files outside
402 of its build and installation directories. This is achieved by running
403 build processes in isolated environments (or @dfn{containers}), where only their
404 explicit inputs are visible.
405
406 @cindex store
407 The result of package build functions is @dfn{cached} in the file
408 system, in a special directory called @dfn{the store} (@pxref{The
409 Store}). Each package is installed in a directory of its own in the
410 store---by default under @file{/gnu/store}. The directory name contains
411 a hash of all the inputs used to build that package; thus, changing an
412 input yields a different directory name.
413
414 This approach is the foundation for the salient features of Guix: support
415 for transactional package upgrade and rollback, per-user installation, and
416 garbage collection of packages (@pxref{Features}).
417
418
419 @node GNU Distribution
420 @section GNU Distribution
421
422 @cindex Guix System
423 Guix comes with a distribution of the GNU system consisting entirely of
424 free software@footnote{The term ``free'' here refers to the
425 @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
426 users of that software}.}. The
427 distribution can be installed on its own (@pxref{System Installation}),
428 but it is also possible to install Guix as a package manager on top of
429 an installed GNU/Linux system (@pxref{Installation}). When we need to
430 distinguish between the two, we refer to the standalone distribution as
431 Guix@tie{}System.
432
433 The distribution provides core GNU packages such as GNU libc, GCC, and
434 Binutils, as well as many GNU and non-GNU applications. The complete
435 list of available packages can be browsed
436 @url{https://www.gnu.org/software/guix/packages,on-line} or by
437 running @command{guix package} (@pxref{Invoking guix package}):
438
439 @example
440 guix package --list-available
441 @end example
442
443 Our goal is to provide a practical 100% free software distribution of
444 Linux-based and other variants of GNU, with a focus on the promotion and
445 tight integration of GNU components, and an emphasis on programs and
446 tools that help users exert that freedom.
447
448 Packages are currently available on the following platforms:
449
450 @table @code
451
452 @item x86_64-linux
453 Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
454
455 @item i686-linux
456 Intel 32-bit architecture (IA32), Linux-Libre kernel;
457
458 @item armhf-linux
459 ARMv7-A architecture with hard float, Thumb-2 and NEON,
460 using the EABI hard-float application binary interface (ABI),
461 and Linux-Libre kernel.
462
463 @item aarch64-linux
464 little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
465
466 @item mips64el-linux
467 little-endian 64-bit MIPS processors, specifically the Loongson series,
468 n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
469 supported; in particular, the project's build farms no longer provide
470 substitutes for this architecture.
471
472 @end table
473
474 With Guix@tie{}System, you @emph{declare} all aspects of the operating system
475 configuration and Guix takes care of instantiating the configuration in a
476 transactional, reproducible, and stateless fashion (@pxref{System
477 Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
478 initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
479 Manual}), the well-known GNU utilities and tool chain, as well as the
480 graphical environment or system services of your choice.
481
482 Guix System is available on all the above platforms except
483 @code{mips64el-linux}.
484
485 @noindent
486 For information on porting to other architectures or kernels,
487 @pxref{Porting}.
488
489 Building this distribution is a cooperative effort, and you are invited
490 to join! @xref{Contributing}, for information about how you can help.
491
492
493 @c *********************************************************************
494 @node Installation
495 @chapter Installation
496
497 @cindex installing Guix
498
499 @quotation Note
500 We recommend the use of this
501 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
502 shell installer script} to install Guix on top of a running GNU/Linux system,
503 thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
504 with the installation of the package manager, which can be done on top of a
505 running GNU/Linux system. If, instead, you want to install the complete GNU
506 operating system, @pxref{System Installation}.} The script automates the
507 download, installation, and initial configuration of Guix. It should be run
508 as the root user.
509 @end quotation
510
511 @cindex foreign distro
512 @cindex directories related to foreign distro
513 When installed on a foreign distro, GNU@tie{}Guix complements the available
514 tools without interference. Its data lives exclusively in two directories,
515 usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
516 such as @file{/etc}, are left untouched.
517
518 Once installed, Guix can be updated by running @command{guix pull}
519 (@pxref{Invoking guix pull}).
520
521 If you prefer to perform the installation steps manually or want to tweak
522 them, you may find the following subsections useful. They describe the
523 software requirements of Guix, as well as how to install it manually and get
524 ready to use it.
525
526 @menu
527 * Binary Installation:: Getting Guix running in no time!
528 * Requirements:: Software needed to build and run Guix.
529 * Running the Test Suite:: Testing Guix.
530 * Setting Up the Daemon:: Preparing the build daemon's environment.
531 * Invoking guix-daemon:: Running the build daemon.
532 * Application Setup:: Application-specific setup.
533 * Upgrading Guix:: Upgrading Guix and its build daemon.
534 @end menu
535
536 @node Binary Installation
537 @section Binary Installation
538
539 @cindex installing Guix from binaries
540 @cindex installer script
541 This section describes how to install Guix on an arbitrary system from a
542 self-contained tarball providing binaries for Guix and for all its
543 dependencies. This is often quicker than installing from source, which
544 is described in the next sections. The only requirement is to have
545 GNU@tie{}tar and Xz.
546
547 @c Note duplicated from the ``Installation'' node.
548 @quotation Note
549 We recommend the use of this
550 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
551 shell installer script}. The script automates the download, installation, and
552 initial configuration steps described below. It should be run as the root
553 user. As root, you can thus run this:
554
555 @example
556 cd /tmp
557 wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
558 chmod +x guix-install.sh
559 ./guix-install.sh
560 @end example
561 @end quotation
562
563 Installing goes along these lines:
564
565 @enumerate
566 @item
567 @cindex downloading Guix binary
568 Download the binary tarball from
569 @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.@var{system}.tar.xz},
570 where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
571 already running the kernel Linux, and so on.
572
573 @c The following is somewhat duplicated in ``System Installation''.
574 Make sure to download the associated @file{.sig} file and to verify the
575 authenticity of the tarball against it, along these lines:
576
577 @example
578 $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
579 $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
580 @end example
581
582 If that command fails because you do not have the required public key,
583 then run this command to import it:
584
585 @example
586 $ wget @value{OPENPGP-SIGNING-KEY-URL} \
587 -qO - | gpg --import -
588 @end example
589
590 @noindent
591 and rerun the @code{gpg --verify} command.
592
593 Take note that a warning like ``This key is not certified with a trusted
594 signature!'' is normal.
595
596 @c end authentication part
597
598 @item
599 Now, you need to become the @code{root} user. Depending on your distribution,
600 you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
601
602 @example
603 # cd /tmp
604 # tar --warning=no-timestamp -xf \
605 /path/to/guix-binary-@value{VERSION}.@var{system}.tar.xz
606 # mv var/guix /var/ && mv gnu /
607 @end example
608
609 This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
610 The latter contains a ready-to-use profile for @code{root} (see next
611 step.)
612
613 Do @emph{not} unpack the tarball on a working Guix system since that
614 would overwrite its own essential files.
615
616 The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
617 not emit warnings about ``implausibly old time stamps'' (such
618 warnings were triggered by GNU@tie{}tar 1.26 and older; recent
619 versions are fine.)
620 They stem from the fact that all the
621 files in the archive have their modification time set to zero (which
622 means January 1st, 1970.) This is done on purpose to make sure the
623 archive content is independent of its creation time, thus making it
624 reproducible.
625
626 @item
627 Make the profile available under @file{~root/.config/guix/current}, which is
628 where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
629
630 @example
631 # mkdir -p ~root/.config/guix
632 # ln -sf /var/guix/profiles/per-user/root/current-guix \
633 ~root/.config/guix/current
634 @end example
635
636 Source @file{etc/profile} to augment @env{PATH} and other relevant
637 environment variables:
638
639 @example
640 # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
641 source $GUIX_PROFILE/etc/profile
642 @end example
643
644 @item
645 Create the group and user accounts for build users as explained below
646 (@pxref{Build Environment Setup}).
647
648 @item
649 Run the daemon, and set it to automatically start on boot.
650
651 If your host distro uses the systemd init system, this can be achieved
652 with these commands:
653
654 @c Versions of systemd that supported symlinked service files are not
655 @c yet widely deployed, so we should suggest that users copy the service
656 @c files into place.
657 @c
658 @c See this thread for more information:
659 @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
660
661 @example
662 # cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
663 /etc/systemd/system/
664 # systemctl enable --now guix-daemon
665 @end example
666
667 If your host distro uses the Upstart init system:
668
669 @example
670 # initctl reload-configuration
671 # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
672 /etc/init/
673 # start guix-daemon
674 @end example
675
676 Otherwise, you can still start the daemon manually with:
677
678 @example
679 # ~root/.config/guix/current/bin/guix-daemon \
680 --build-users-group=guixbuild
681 @end example
682
683 @item
684 Make the @command{guix} command available to other users on the machine,
685 for instance with:
686
687 @example
688 # mkdir -p /usr/local/bin
689 # cd /usr/local/bin
690 # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
691 @end example
692
693 It is also a good idea to make the Info version of this manual available
694 there:
695
696 @example
697 # mkdir -p /usr/local/share/info
698 # cd /usr/local/share/info
699 # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
700 do ln -s $i ; done
701 @end example
702
703 That way, assuming @file{/usr/local/share/info} is in the search path,
704 running @command{info guix} will open this manual (@pxref{Other Info
705 Directories,,, texinfo, GNU Texinfo}, for more details on changing the
706 Info search path.)
707
708 @item
709 @cindex substitutes, authorization thereof
710 To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
711 (@pxref{Substitutes}), authorize them:
712
713 @example
714 # guix archive --authorize < \
715 ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
716 @end example
717
718 @item
719 Each user may need to perform a few additional steps to make their Guix
720 environment ready for use, @pxref{Application Setup}.
721 @end enumerate
722
723 Voilà, the installation is complete!
724
725 You can confirm that Guix is working by installing a sample package into
726 the root profile:
727
728 @example
729 # guix install hello
730 @end example
731
732 The binary installation tarball can be (re)produced and verified simply
733 by running the following command in the Guix source tree:
734
735 @example
736 make guix-binary.@var{system}.tar.xz
737 @end example
738
739 @noindent
740 ...@: which, in turn, runs:
741
742 @example
743 guix pack -s @var{system} --localstatedir \
744 --profile-name=current-guix guix
745 @end example
746
747 @xref{Invoking guix pack}, for more info on this handy tool.
748
749 @node Requirements
750 @section Requirements
751
752 This section lists requirements when building Guix from source. The
753 build procedure for Guix is the same as for other GNU software, and is
754 not covered here. Please see the files @file{README} and @file{INSTALL}
755 in the Guix source tree for additional details.
756
757 @cindex official website
758 GNU Guix is available for download from its website at
759 @url{https://www.gnu.org/software/guix/}.
760
761 GNU Guix depends on the following packages:
762
763 @itemize
764 @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x or
765 2.2.x;
766 @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
767 0.1.0 or later;
768 @item
769 @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
770 (@pxref{Guile Preparations, how to install the GnuTLS bindings for
771 Guile,, gnutls-guile, GnuTLS-Guile});
772 @item
773 @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
774 or later;
775 @item
776 @c FIXME: Specify a version number once a release has been made.
777 @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
778 2017 or later;
779 @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON} 3.x;
780 @item @url{https://zlib.net, zlib};
781 @item @url{https://www.gnu.org/software/make/, GNU Make}.
782 @end itemize
783
784 The following dependencies are optional:
785
786 @itemize
787 @item
788 @c Note: We need at least 0.12.0 for 'userauth-gssapi!'.
789 Support for build offloading (@pxref{Daemon Offload Setup}) and
790 @command{guix copy} (@pxref{Invoking guix copy}) depends on
791 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
792 version 0.12.0 or later.
793
794 @item
795 When @url{https://www.nongnu.org/lzip/lzlib.html, lzlib} is available, lzlib
796 substitutes can be used and @command{guix publish} can compress substitutes
797 with lzlib.
798
799 @item
800 When @url{http://www.bzip.org, libbz2} is available,
801 @command{guix-daemon} can use it to compress build logs.
802 @end itemize
803
804 Unless @option{--disable-daemon} was passed to @command{configure}, the
805 following packages are also needed:
806
807 @itemize
808 @item @url{https://gnupg.org/, GNU libgcrypt};
809 @item @url{https://sqlite.org, SQLite 3};
810 @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
811 C++11 standard.
812 @end itemize
813
814 @cindex state directory
815 When configuring Guix on a system that already has a Guix installation,
816 be sure to specify the same state directory as the existing installation
817 using the @option{--localstatedir} option of the @command{configure}
818 script (@pxref{Directory Variables, @code{localstatedir},, standards,
819 GNU Coding Standards}). Usually, this @var{localstatedir} option is
820 set to the value @file{/var}. The @command{configure} script protects
821 against unintended misconfiguration of @var{localstatedir} so you do not
822 inadvertently corrupt your store (@pxref{The Store}).
823
824 @node Running the Test Suite
825 @section Running the Test Suite
826
827 @cindex test suite
828 After a successful @command{configure} and @code{make} run, it is a good
829 idea to run the test suite. It can help catch issues with the setup or
830 environment, or bugs in Guix itself---and really, reporting test
831 failures is a good way to help improve the software. To run the test
832 suite, type:
833
834 @example
835 make check
836 @end example
837
838 Test cases can run in parallel: you can use the @code{-j} option of
839 GNU@tie{}make to speed things up. The first run may take a few minutes
840 on a recent machine; subsequent runs will be faster because the store
841 that is created for test purposes will already have various things in
842 cache.
843
844 It is also possible to run a subset of the tests by defining the
845 @code{TESTS} makefile variable as in this example:
846
847 @example
848 make check TESTS="tests/store.scm tests/cpio.scm"
849 @end example
850
851 By default, tests results are displayed at a file level. In order to
852 see the details of every individual test cases, it is possible to define
853 the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
854
855 @example
856 make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
857 @end example
858
859 Upon failure, please email @email{bug-guix@@gnu.org} and attach the
860 @file{test-suite.log} file. Please specify the Guix version being used
861 as well as version numbers of the dependencies (@pxref{Requirements}) in
862 your message.
863
864 Guix also comes with a whole-system test suite that tests complete
865 Guix System instances. It can only run on systems where
866 Guix is already installed, using:
867
868 @example
869 make check-system
870 @end example
871
872 @noindent
873 or, again, by defining @code{TESTS} to select a subset of tests to run:
874
875 @example
876 make check-system TESTS="basic mcron"
877 @end example
878
879 These system tests are defined in the @code{(gnu tests @dots{})}
880 modules. They work by running the operating systems under test with
881 lightweight instrumentation in a virtual machine (VM). They can be
882 computationally intensive or rather cheap, depending on whether
883 substitutes are available for their dependencies (@pxref{Substitutes}).
884 Some of them require a lot of storage space to hold VM images.
885
886 Again in case of test failures, please send @email{bug-guix@@gnu.org}
887 all the details.
888
889 @node Setting Up the Daemon
890 @section Setting Up the Daemon
891
892 @cindex daemon
893 Operations such as building a package or running the garbage collector
894 are all performed by a specialized process, the @dfn{build daemon}, on
895 behalf of clients. Only the daemon may access the store and its
896 associated database. Thus, any operation that manipulates the store
897 goes through the daemon. For instance, command-line tools such as
898 @command{guix package} and @command{guix build} communicate with the
899 daemon (@i{via} remote procedure calls) to instruct it what to do.
900
901 The following sections explain how to prepare the build daemon's
902 environment. See also @ref{Substitutes}, for information on how to allow
903 the daemon to download pre-built binaries.
904
905 @menu
906 * Build Environment Setup:: Preparing the isolated build environment.
907 * Daemon Offload Setup:: Offloading builds to remote machines.
908 * SELinux Support:: Using an SELinux policy for the daemon.
909 @end menu
910
911 @node Build Environment Setup
912 @subsection Build Environment Setup
913
914 @cindex build environment
915 In a standard multi-user setup, Guix and its daemon---the
916 @command{guix-daemon} program---are installed by the system
917 administrator; @file{/gnu/store} is owned by @code{root} and
918 @command{guix-daemon} runs as @code{root}. Unprivileged users may use
919 Guix tools to build packages or otherwise access the store, and the
920 daemon will do it on their behalf, ensuring that the store is kept in a
921 consistent state, and allowing built packages to be shared among users.
922
923 @cindex build users
924 When @command{guix-daemon} runs as @code{root}, you may not want package
925 build processes themselves to run as @code{root} too, for obvious
926 security reasons. To avoid that, a special pool of @dfn{build users}
927 should be created for use by build processes started by the daemon.
928 These build users need not have a shell and a home directory: they will
929 just be used when the daemon drops @code{root} privileges in build
930 processes. Having several such users allows the daemon to launch
931 distinct build processes under separate UIDs, which guarantees that they
932 do not interfere with each other---an essential feature since builds are
933 regarded as pure functions (@pxref{Introduction}).
934
935 On a GNU/Linux system, a build user pool may be created like this (using
936 Bash syntax and the @code{shadow} commands):
937
938 @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
939 @c for why `-G' is needed.
940 @example
941 # groupadd --system guixbuild
942 # for i in `seq -w 1 10`;
943 do
944 useradd -g guixbuild -G guixbuild \
945 -d /var/empty -s `which nologin` \
946 -c "Guix build user $i" --system \
947 guixbuilder$i;
948 done
949 @end example
950
951 @noindent
952 The number of build users determines how many build jobs may run in
953 parallel, as specified by the @option{--max-jobs} option
954 (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
955 @command{guix system vm} and related commands, you may need to add the
956 build users to the @code{kvm} group so they can access @file{/dev/kvm},
957 using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
958 (@pxref{Invoking guix system}).
959
960 The @code{guix-daemon} program may then be run as @code{root} with the
961 following command@footnote{If your machine uses the systemd init system,
962 dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
963 file in @file{/etc/systemd/system} will ensure that
964 @command{guix-daemon} is automatically started. Similarly, if your
965 machine uses the Upstart init system, drop the
966 @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
967 file in @file{/etc/init}.}:
968
969 @example
970 # guix-daemon --build-users-group=guixbuild
971 @end example
972
973 @cindex chroot
974 @noindent
975 This way, the daemon starts build processes in a chroot, under one of
976 the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
977 environment contains nothing but:
978
979 @c Keep this list in sync with libstore/build.cc! -----------------------
980 @itemize
981 @item
982 a minimal @code{/dev} directory, created mostly independently from the
983 host @code{/dev}@footnote{``Mostly'', because while the set of files
984 that appear in the chroot's @code{/dev} is fixed, most of these files
985 can only be created if the host has them.};
986
987 @item
988 the @code{/proc} directory; it only shows the processes of the container
989 since a separate PID name space is used;
990
991 @item
992 @file{/etc/passwd} with an entry for the current user and an entry for
993 user @file{nobody};
994
995 @item
996 @file{/etc/group} with an entry for the user's group;
997
998 @item
999 @file{/etc/hosts} with an entry that maps @code{localhost} to
1000 @code{127.0.0.1};
1001
1002 @item
1003 a writable @file{/tmp} directory.
1004 @end itemize
1005
1006 You can influence the directory where the daemon stores build trees
1007 @i{via} the @env{TMPDIR} environment variable. However, the build tree
1008 within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
1009 where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
1010 This way, the value of @env{TMPDIR} does not leak inside build
1011 environments, which avoids discrepancies in cases where build processes
1012 capture the name of their build tree.
1013
1014 @vindex http_proxy
1015 @vindex https_proxy
1016 The daemon also honors the @env{http_proxy} and @env{https_proxy}
1017 environment variables for HTTP and HTTPS downloads it performs, be it
1018 for fixed-output derivations (@pxref{Derivations}) or for substitutes
1019 (@pxref{Substitutes}).
1020
1021 If you are installing Guix as an unprivileged user, it is still possible
1022 to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
1023 However, build processes will not be isolated from one another, and not
1024 from the rest of the system. Thus, build processes may interfere with
1025 each other, and may access programs, libraries, and other files
1026 available on the system---making it much harder to view them as
1027 @emph{pure} functions.
1028
1029
1030 @node Daemon Offload Setup
1031 @subsection Using the Offload Facility
1032
1033 @cindex offloading
1034 @cindex build hook
1035 When desired, the build daemon can @dfn{offload} derivation builds to
1036 other machines running Guix, using the @code{offload} @dfn{build
1037 hook}@footnote{This feature is available only when
1038 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
1039 present.}. When that
1040 feature is enabled, a list of user-specified build machines is read from
1041 @file{/etc/guix/machines.scm}; every time a build is requested, for
1042 instance via @code{guix build}, the daemon attempts to offload it to one
1043 of the machines that satisfy the constraints of the derivation, in
1044 particular its system type---e.g., @file{x86_64-linux}. Missing
1045 prerequisites for the build are copied over SSH to the target machine,
1046 which then proceeds with the build; upon success the output(s) of the
1047 build are copied back to the initial machine.
1048
1049 The @file{/etc/guix/machines.scm} file typically looks like this:
1050
1051 @lisp
1052 (list (build-machine
1053 (name "eightysix.example.org")
1054 (system "x86_64-linux")
1055 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
1056 (user "bob")
1057 (speed 2.)) ;incredibly fast!
1058
1059 (build-machine
1060 (name "meeps.example.org")
1061 (system "mips64el-linux")
1062 (host-key "ssh-rsa AAAAB3Nza@dots{}")
1063 (user "alice")
1064 (private-key
1065 (string-append (getenv "HOME")
1066 "/.ssh/identity-for-guix"))))
1067 @end lisp
1068
1069 @noindent
1070 In the example above we specify a list of two build machines, one for
1071 the @code{x86_64} architecture and one for the @code{mips64el}
1072 architecture.
1073
1074 In fact, this file is---not surprisingly!---a Scheme file that is
1075 evaluated when the @code{offload} hook is started. Its return value
1076 must be a list of @code{build-machine} objects. While this example
1077 shows a fixed list of build machines, one could imagine, say, using
1078 DNS-SD to return a list of potential build machines discovered in the
1079 local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
1080 Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
1081 detailed below.
1082
1083 @deftp {Data Type} build-machine
1084 This data type represents build machines to which the daemon may offload
1085 builds. The important fields are:
1086
1087 @table @code
1088
1089 @item name
1090 The host name of the remote machine.
1091
1092 @item system
1093 The system type of the remote machine---e.g., @code{"x86_64-linux"}.
1094
1095 @item user
1096 The user account to use when connecting to the remote machine over SSH.
1097 Note that the SSH key pair must @emph{not} be passphrase-protected, to
1098 allow non-interactive logins.
1099
1100 @item host-key
1101 This must be the machine's SSH @dfn{public host key} in OpenSSH format.
1102 This is used to authenticate the machine when we connect to it. It is a
1103 long string that looks like this:
1104
1105 @example
1106 ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
1107 @end example
1108
1109 If the machine is running the OpenSSH daemon, @command{sshd}, the host
1110 key can be found in a file such as
1111 @file{/etc/ssh/ssh_host_ed25519_key.pub}.
1112
1113 If the machine is running the SSH daemon of GNU@tie{}lsh,
1114 @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
1115 similar file. It can be converted to the OpenSSH format using
1116 @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
1117
1118 @example
1119 $ lsh-export-key --openssh < /etc/lsh/host-key.pub
1120 ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
1121 @end example
1122
1123 @end table
1124
1125 A number of optional fields may be specified:
1126
1127 @table @asis
1128
1129 @item @code{port} (default: @code{22})
1130 Port number of SSH server on the machine.
1131
1132 @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
1133 The SSH private key file to use when connecting to the machine, in
1134 OpenSSH format. This key must not be protected with a passphrase.
1135
1136 Note that the default value is the private key @emph{of the root
1137 account}. Make sure it exists if you use the default.
1138
1139 @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
1140 @itemx @code{compression-level} (default: @code{3})
1141 The SSH-level compression methods and compression level requested.
1142
1143 Note that offloading relies on SSH compression to reduce bandwidth usage
1144 when transferring files to and from build machines.
1145
1146 @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
1147 File name of the Unix-domain socket @command{guix-daemon} is listening
1148 to on that machine.
1149
1150 @item @code{parallel-builds} (default: @code{1})
1151 The number of builds that may run in parallel on the machine.
1152
1153 @item @code{speed} (default: @code{1.0})
1154 A ``relative speed factor''. The offload scheduler will tend to prefer
1155 machines with a higher speed factor.
1156
1157 @item @code{features} (default: @code{'()})
1158 A list of strings denoting specific features supported by the machine.
1159 An example is @code{"kvm"} for machines that have the KVM Linux modules
1160 and corresponding hardware support. Derivations can request features by
1161 name, and they will be scheduled on matching build machines.
1162
1163 @end table
1164 @end deftp
1165
1166 The @command{guix} command must be in the search path on the build
1167 machines. You can check whether this is the case by running:
1168
1169 @example
1170 ssh build-machine guix repl --version
1171 @end example
1172
1173 There is one last thing to do once @file{machines.scm} is in place. As
1174 explained above, when offloading, files are transferred back and forth
1175 between the machine stores. For this to work, you first need to
1176 generate a key pair on each machine to allow the daemon to export signed
1177 archives of files from the store (@pxref{Invoking guix archive}):
1178
1179 @example
1180 # guix archive --generate-key
1181 @end example
1182
1183 @noindent
1184 Each build machine must authorize the key of the master machine so that
1185 it accepts store items it receives from the master:
1186
1187 @example
1188 # guix archive --authorize < master-public-key.txt
1189 @end example
1190
1191 @noindent
1192 Likewise, the master machine must authorize the key of each build machine.
1193
1194 All the fuss with keys is here to express pairwise mutual trust
1195 relations between the master and the build machines. Concretely, when
1196 the master receives files from a build machine (and @i{vice versa}), its
1197 build daemon can make sure they are genuine, have not been tampered
1198 with, and that they are signed by an authorized key.
1199
1200 @cindex offload test
1201 To test whether your setup is operational, run this command on the
1202 master node:
1203
1204 @example
1205 # guix offload test
1206 @end example
1207
1208 This will attempt to connect to each of the build machines specified in
1209 @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
1210 available on each machine, attempt to export to the machine and import
1211 from it, and report any error in the process.
1212
1213 If you want to test a different machine file, just specify it on the
1214 command line:
1215
1216 @example
1217 # guix offload test machines-qualif.scm
1218 @end example
1219
1220 Last, you can test the subset of the machines whose name matches a
1221 regular expression like this:
1222
1223 @example
1224 # guix offload test machines.scm '\.gnu\.org$'
1225 @end example
1226
1227 @cindex offload status
1228 To display the current load of all build hosts, run this command on the
1229 main node:
1230
1231 @example
1232 # guix offload status
1233 @end example
1234
1235
1236 @node SELinux Support
1237 @subsection SELinux Support
1238
1239 @cindex SELinux, daemon policy
1240 @cindex mandatory access control, SELinux
1241 @cindex security, guix-daemon
1242 Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
1243 can be installed on a system where SELinux is enabled, in order to label
1244 Guix files and to specify the expected behavior of the daemon. Since
1245 Guix System does not provide an SELinux base policy, the daemon policy cannot
1246 be used on Guix System.
1247
1248 @subsubsection Installing the SELinux policy
1249 @cindex SELinux, policy installation
1250 To install the policy run this command as root:
1251
1252 @example
1253 semodule -i etc/guix-daemon.cil
1254 @end example
1255
1256 Then relabel the file system with @code{restorecon} or by a different
1257 mechanism provided by your system.
1258
1259 Once the policy is installed, the file system has been relabeled, and
1260 the daemon has been restarted, it should be running in the
1261 @code{guix_daemon_t} context. You can confirm this with the following
1262 command:
1263
1264 @example
1265 ps -Zax | grep guix-daemon
1266 @end example
1267
1268 Monitor the SELinux log files as you run a command like @code{guix build
1269 hello} to convince yourself that SELinux permits all necessary
1270 operations.
1271
1272 @subsubsection Limitations
1273 @cindex SELinux, limitations
1274
1275 This policy is not perfect. Here is a list of limitations or quirks
1276 that should be considered when deploying the provided SELinux policy for
1277 the Guix daemon.
1278
1279 @enumerate
1280 @item
1281 @code{guix_daemon_socket_t} isn’t actually used. None of the socket
1282 operations involve contexts that have anything to do with
1283 @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
1284 but it would be preferrable to define socket rules for only this label.
1285
1286 @item
1287 @code{guix gc} cannot access arbitrary links to profiles. By design,
1288 the file label of the destination of a symlink is independent of the
1289 file label of the link itself. Although all profiles under
1290 $localstatedir are labelled, the links to these profiles inherit the
1291 label of the directory they are in. For links in the user’s home
1292 directory this will be @code{user_home_t}. But for links from the root
1293 user’s home directory, or @file{/tmp}, or the HTTP server’s working
1294 directory, etc, this won’t work. @code{guix gc} would be prevented from
1295 reading and following these links.
1296
1297 @item
1298 The daemon’s feature to listen for TCP connections might no longer work.
1299 This might require extra rules, because SELinux treats network sockets
1300 differently from files.
1301
1302 @item
1303 Currently all files with a name matching the regular expression
1304 @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
1305 label @code{guix_daemon_exec_t}; this means that @emph{any} file with
1306 that name in any profile would be permitted to run in the
1307 @code{guix_daemon_t} domain. This is not ideal. An attacker could
1308 build a package that provides this executable and convince a user to
1309 install and run it, which lifts it into the @code{guix_daemon_t} domain.
1310 At that point SELinux could not prevent it from accessing files that are
1311 allowed for processes in that domain.
1312
1313 We could generate a much more restrictive policy at installation time,
1314 so that only the @emph{exact} file name of the currently installed
1315 @code{guix-daemon} executable would be labelled with
1316 @code{guix_daemon_exec_t}, instead of using a broad regular expression.
1317 The downside is that root would have to install or upgrade the policy at
1318 installation time whenever the Guix package that provides the
1319 effectively running @code{guix-daemon} executable is upgraded.
1320 @end enumerate
1321
1322 @node Invoking guix-daemon
1323 @section Invoking @command{guix-daemon}
1324
1325 The @command{guix-daemon} program implements all the functionality to
1326 access the store. This includes launching build processes, running the
1327 garbage collector, querying the availability of a build result, etc. It
1328 is normally run as @code{root} like this:
1329
1330 @example
1331 # guix-daemon --build-users-group=guixbuild
1332 @end example
1333
1334 @noindent
1335 For details on how to set it up, @pxref{Setting Up the Daemon}.
1336
1337 @cindex chroot
1338 @cindex container, build environment
1339 @cindex build environment
1340 @cindex reproducible builds
1341 By default, @command{guix-daemon} launches build processes under
1342 different UIDs, taken from the build group specified with
1343 @option{--build-users-group}. In addition, each build process is run in a
1344 chroot environment that only contains the subset of the store that the
1345 build process depends on, as specified by its derivation
1346 (@pxref{Programming Interface, derivation}), plus a set of specific
1347 system directories. By default, the latter contains @file{/dev} and
1348 @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1349 @dfn{container}: in addition to having its own file system tree, it has
1350 a separate mount name space, its own PID name space, network name space,
1351 etc. This helps achieve reproducible builds (@pxref{Features}).
1352
1353 When the daemon performs a build on behalf of the user, it creates a
1354 build directory under @file{/tmp} or under the directory specified by
1355 its @env{TMPDIR} environment variable. This directory is shared with
1356 the container for the duration of the build, though within the container,
1357 the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
1358
1359 The build directory is automatically deleted upon completion, unless the
1360 build failed and the client specified @option{--keep-failed}
1361 (@pxref{Invoking guix build, @option{--keep-failed}}).
1362
1363 The daemon listens for connections and spawns one sub-process for each session
1364 started by a client (one of the @command{guix} sub-commands.) The
1365 @command{guix processes} command allows you to get an overview of the activity
1366 on your system by viewing each of the active sessions and clients.
1367 @xref{Invoking guix processes}, for more information.
1368
1369 The following command-line options are supported:
1370
1371 @table @code
1372 @item --build-users-group=@var{group}
1373 Take users from @var{group} to run build processes (@pxref{Setting Up
1374 the Daemon, build users}).
1375
1376 @item --no-substitutes
1377 @cindex substitutes
1378 Do not use substitutes for build products. That is, always build things
1379 locally instead of allowing downloads of pre-built binaries
1380 (@pxref{Substitutes}).
1381
1382 When the daemon runs with @option{--no-substitutes}, clients can still
1383 explicitly enable substitution @i{via} the @code{set-build-options}
1384 remote procedure call (@pxref{The Store}).
1385
1386 @item --substitute-urls=@var{urls}
1387 @anchor{daemon-substitute-urls}
1388 Consider @var{urls} the default whitespace-separated list of substitute
1389 source URLs. When this option is omitted,
1390 @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
1391
1392 This means that substitutes may be downloaded from @var{urls}, as long
1393 as they are signed by a trusted signature (@pxref{Substitutes}).
1394
1395 @cindex offloading
1396 @item --no-offload
1397 Do not use offload builds to other machines (@pxref{Daemon Offload
1398 Setup}). That is, always build things locally instead of offloading
1399 builds to remote machines.
1400
1401 @item --cache-failures
1402 Cache build failures. By default, only successful builds are cached.
1403
1404 When this option is used, @command{guix gc --list-failures} can be used
1405 to query the set of store items marked as failed; @command{guix gc
1406 --clear-failures} removes store items from the set of cached failures.
1407 @xref{Invoking guix gc}.
1408
1409 @item --cores=@var{n}
1410 @itemx -c @var{n}
1411 Use @var{n} CPU cores to build each derivation; @code{0} means as many
1412 as available.
1413
1414 The default value is @code{0}, but it may be overridden by clients, such
1415 as the @option{--cores} option of @command{guix build} (@pxref{Invoking
1416 guix build}).
1417
1418 The effect is to define the @env{NIX_BUILD_CORES} environment variable
1419 in the build process, which can then use it to exploit internal
1420 parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1421
1422 @item --max-jobs=@var{n}
1423 @itemx -M @var{n}
1424 Allow at most @var{n} build jobs in parallel. The default value is
1425 @code{1}. Setting it to @code{0} means that no builds will be performed
1426 locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1427 Setup}), or simply fail.
1428
1429 @item --max-silent-time=@var{seconds}
1430 When the build or substitution process remains silent for more than
1431 @var{seconds}, terminate it and report a build failure.
1432
1433 The default value is @code{0}, which disables the timeout.
1434
1435 The value specified here can be overridden by clients (@pxref{Common
1436 Build Options, @option{--max-silent-time}}).
1437
1438 @item --timeout=@var{seconds}
1439 Likewise, when the build or substitution process lasts for more than
1440 @var{seconds}, terminate it and report a build failure.
1441
1442 The default value is @code{0}, which disables the timeout.
1443
1444 The value specified here can be overridden by clients (@pxref{Common
1445 Build Options, @option{--timeout}}).
1446
1447 @item --rounds=@var{N}
1448 Build each derivation @var{n} times in a row, and raise an error if
1449 consecutive build results are not bit-for-bit identical. Note that this
1450 setting can be overridden by clients such as @command{guix build}
1451 (@pxref{Invoking guix build}).
1452
1453 When used in conjunction with @option{--keep-failed}, the differing
1454 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1455 This makes it easy to look for differences between the two results.
1456
1457 @item --debug
1458 Produce debugging output.
1459
1460 This is useful to debug daemon start-up issues, but then it may be
1461 overridden by clients, for example the @option{--verbosity} option of
1462 @command{guix build} (@pxref{Invoking guix build}).
1463
1464 @item --chroot-directory=@var{dir}
1465 Add @var{dir} to the build chroot.
1466
1467 Doing this may change the result of build processes---for instance if
1468 they use optional dependencies found in @var{dir} when it is available,
1469 and not otherwise. For that reason, it is not recommended to do so.
1470 Instead, make sure that each derivation declares all the inputs that it
1471 needs.
1472
1473 @item --disable-chroot
1474 Disable chroot builds.
1475
1476 Using this option is not recommended since, again, it would allow build
1477 processes to gain access to undeclared dependencies. It is necessary,
1478 though, when @command{guix-daemon} is running under an unprivileged user
1479 account.
1480
1481 @item --log-compression=@var{type}
1482 Compress build logs according to @var{type}, one of @code{gzip},
1483 @code{bzip2}, or @code{none}.
1484
1485 Unless @option{--lose-logs} is used, all the build logs are kept in the
1486 @var{localstatedir}. To save space, the daemon automatically compresses
1487 them with Bzip2 by default.
1488
1489 @item --disable-deduplication
1490 @cindex deduplication
1491 Disable automatic file ``deduplication'' in the store.
1492
1493 By default, files added to the store are automatically ``deduplicated'':
1494 if a newly added file is identical to another one found in the store,
1495 the daemon makes the new file a hard link to the other file. This can
1496 noticeably reduce disk usage, at the expense of slightly increased
1497 input/output load at the end of a build process. This option disables
1498 this optimization.
1499
1500 @item --gc-keep-outputs[=yes|no]
1501 Tell whether the garbage collector (GC) must keep outputs of live
1502 derivations.
1503
1504 @cindex GC roots
1505 @cindex garbage collector roots
1506 When set to @code{yes}, the GC will keep the outputs of any live
1507 derivation available in the store---the @file{.drv} files. The default
1508 is @code{no}, meaning that derivation outputs are kept only if they are
1509 reachable from a GC root. @xref{Invoking guix gc}, for more on GC
1510 roots.
1511
1512 @item --gc-keep-derivations[=yes|no]
1513 Tell whether the garbage collector (GC) must keep derivations
1514 corresponding to live outputs.
1515
1516 When set to @code{yes}, as is the case by default, the GC keeps
1517 derivations---i.e., @file{.drv} files---as long as at least one of their
1518 outputs is live. This allows users to keep track of the origins of
1519 items in their store. Setting it to @code{no} saves a bit of disk
1520 space.
1521
1522 In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
1523 liveness to flow from outputs to derivations, and setting
1524 @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
1525 derivations to outputs. When both are set to @code{yes}, the effect is
1526 to keep all the build prerequisites (the sources, compiler, libraries,
1527 and other build-time tools) of live objects in the store, regardless of
1528 whether these prerequisites are reachable from a GC root. This is
1529 convenient for developers since it saves rebuilds or downloads.
1530
1531 @item --impersonate-linux-2.6
1532 On Linux-based systems, impersonate Linux 2.6. This means that the
1533 kernel's @command{uname} system call will report 2.6 as the release number.
1534
1535 This might be helpful to build programs that (usually wrongfully) depend
1536 on the kernel version number.
1537
1538 @item --lose-logs
1539 Do not keep build logs. By default they are kept under
1540 @file{@var{localstatedir}/guix/log}.
1541
1542 @item --system=@var{system}
1543 Assume @var{system} as the current system type. By default it is the
1544 architecture/kernel pair found at configure time, such as
1545 @code{x86_64-linux}.
1546
1547 @item --listen=@var{endpoint}
1548 Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
1549 as the file name of a Unix-domain socket if it starts with
1550 @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
1551 host name or host name and port to listen to. Here are a few examples:
1552
1553 @table @code
1554 @item --listen=/gnu/var/daemon
1555 Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
1556 creating it if needed.
1557
1558 @item --listen=localhost
1559 @cindex daemon, remote access
1560 @cindex remote access to the daemon
1561 @cindex daemon, cluster setup
1562 @cindex clusters, daemon setup
1563 Listen for TCP connections on the network interface corresponding to
1564 @code{localhost}, on port 44146.
1565
1566 @item --listen=128.0.0.42:1234
1567 Listen for TCP connections on the network interface corresponding to
1568 @code{128.0.0.42}, on port 1234.
1569 @end table
1570
1571 This option can be repeated multiple times, in which case
1572 @command{guix-daemon} accepts connections on all the specified
1573 endpoints. Users can tell client commands what endpoint to connect to
1574 by setting the @env{GUIX_DAEMON_SOCKET} environment variable
1575 (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
1576
1577 @quotation Note
1578 The daemon protocol is @emph{unauthenticated and unencrypted}. Using
1579 @option{--listen=@var{host}} is suitable on local networks, such as
1580 clusters, where only trusted nodes may connect to the build daemon. In
1581 other cases where remote access to the daemon is needed, we recommend
1582 using Unix-domain sockets along with SSH.
1583 @end quotation
1584
1585 When @option{--listen} is omitted, @command{guix-daemon} listens for
1586 connections on the Unix-domain socket located at
1587 @file{@var{localstatedir}/guix/daemon-socket/socket}.
1588 @end table
1589
1590
1591 @node Application Setup
1592 @section Application Setup
1593
1594 @cindex foreign distro
1595 When using Guix on top of GNU/Linux distribution other than Guix System---a
1596 so-called @dfn{foreign distro}---a few additional steps are needed to
1597 get everything in place. Here are some of them.
1598
1599 @subsection Locales
1600
1601 @anchor{locales-and-locpath}
1602 @cindex locales, when not on Guix System
1603 @vindex LOCPATH
1604 @vindex GUIX_LOCPATH
1605 Packages installed @i{via} Guix will not use the locale data of the
1606 host system. Instead, you must first install one of the locale packages
1607 available with Guix and then define the @env{GUIX_LOCPATH} environment
1608 variable:
1609
1610 @example
1611 $ guix install glibc-locales
1612 $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
1613 @end example
1614
1615 Note that the @code{glibc-locales} package contains data for all the
1616 locales supported by the GNU@tie{}libc and weighs in at around
1617 917@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
1618 limited to a few UTF-8 locales.
1619
1620 The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
1621 (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
1622 Manual}). There are two important differences though:
1623
1624 @enumerate
1625 @item
1626 @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
1627 provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
1628 to make sure the programs of the foreign distro will not end up loading
1629 incompatible locale data.
1630
1631 @item
1632 libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
1633 @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1634 should your Guix profile contain a mixture of programs linked against
1635 different libc version, each libc version will only try to load locale
1636 data in the right format.
1637 @end enumerate
1638
1639 This is important because the locale data format used by different libc
1640 versions may be incompatible.
1641
1642 @subsection Name Service Switch
1643
1644 @cindex name service switch, glibc
1645 @cindex NSS (name service switch), glibc
1646 @cindex nscd (name service caching daemon)
1647 @cindex name service caching daemon (nscd)
1648 When using Guix on a foreign distro, we @emph{strongly recommend} that
1649 the system run the GNU C library's @dfn{name service cache daemon},
1650 @command{nscd}, which should be listening on the
1651 @file{/var/run/nscd/socket} socket. Failing to do that, applications
1652 installed with Guix may fail to look up host names or user accounts, or
1653 may even crash. The next paragraphs explain why.
1654
1655 @cindex @file{nsswitch.conf}
1656 The GNU C library implements a @dfn{name service switch} (NSS), which is
1657 an extensible mechanism for ``name lookups'' in general: host name
1658 resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1659 The GNU C Library Reference Manual}).
1660
1661 @cindex Network information service (NIS)
1662 @cindex NIS (Network information service)
1663 Being extensible, the NSS supports @dfn{plugins}, which provide new name
1664 lookup implementations: for example, the @code{nss-mdns} plugin allow
1665 resolution of @code{.local} host names, the @code{nis} plugin allows
1666 user account lookup using the Network information service (NIS), and so
1667 on. These extra ``lookup services'' are configured system-wide in
1668 @file{/etc/nsswitch.conf}, and all the programs running on the system
1669 honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1670 Reference Manual}).
1671
1672 When they perform a name lookup---for instance by calling the
1673 @code{getaddrinfo} function in C---applications first try to connect to
1674 the nscd; on success, nscd performs name lookups on their behalf. If
1675 the nscd is not running, then they perform the name lookup by
1676 themselves, by loading the name lookup services into their own address
1677 space and running it. These name lookup services---the
1678 @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1679 the host system's C library, rather than from the C library the
1680 application is linked against (the C library coming from Guix).
1681
1682 And this is where the problem is: if your application is linked against
1683 Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1684 another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1685 likely crash or have its name lookups fail unexpectedly.
1686
1687 Running @command{nscd} on the system, among other advantages, eliminates
1688 this binary incompatibility problem because those @code{libnss_*.so}
1689 files are loaded in the @command{nscd} process, not in applications
1690 themselves.
1691
1692 @subsection X11 Fonts
1693
1694 @cindex fonts
1695 The majority of graphical applications use Fontconfig to locate and
1696 load fonts and perform X11-client-side rendering. The @code{fontconfig}
1697 package in Guix looks for fonts in @file{$HOME/.guix-profile}
1698 by default. Thus, to allow graphical applications installed with Guix
1699 to display fonts, you have to install fonts with Guix as well.
1700 Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
1701 @code{font-gnu-freefont}.
1702
1703 @cindex @code{fc-cache}
1704 @cindex font cache
1705 Once you have installed or removed fonts, or when you notice an
1706 application that does not find fonts, you may need to install Fontconfig
1707 and to force an update of its font cache by running:
1708
1709 @example
1710 guix install fontconfig
1711 fc-cache -rv
1712 @end example
1713
1714 To display text written in Chinese languages, Japanese, or Korean in
1715 graphical applications, consider installing
1716 @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1717 has multiple outputs, one per language family (@pxref{Packages with
1718 Multiple Outputs}). For instance, the following command installs fonts
1719 for Chinese languages:
1720
1721 @example
1722 guix install font-adobe-source-han-sans:cn
1723 @end example
1724
1725 @cindex @code{xterm}
1726 Older programs such as @command{xterm} do not use Fontconfig and instead
1727 rely on server-side font rendering. Such programs require to specify a
1728 full name of a font using XLFD (X Logical Font Description), like this:
1729
1730 @example
1731 -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1732 @end example
1733
1734 To be able to use such full names for the TrueType fonts installed in
1735 your Guix profile, you need to extend the font path of the X server:
1736
1737 @c Note: 'xset' does not accept symlinks so the trick below arranges to
1738 @c get at the real directory. See <https://bugs.gnu.org/30655>.
1739 @example
1740 xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
1741 @end example
1742
1743 @cindex @code{xlsfonts}
1744 After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1745 to make sure your TrueType fonts are listed there.
1746
1747
1748 @subsection X.509 Certificates
1749
1750 @cindex @code{nss-certs}
1751 The @code{nss-certs} package provides X.509 certificates, which allow
1752 programs to authenticate Web servers accessed over HTTPS.
1753
1754 When using Guix on a foreign distro, you can install this package and
1755 define the relevant environment variables so that packages know where to
1756 look for certificates. @xref{X.509 Certificates}, for detailed
1757 information.
1758
1759 @subsection Emacs Packages
1760
1761 @cindex @code{emacs}
1762 When you install Emacs packages with Guix, the Elisp files are placed
1763 under the @file{share/emacs/site-lisp/} directory of the profile in
1764 which they are installed. The Elisp libraries are made available to
1765 Emacs through the @env{EMACSLOADPATH} environment variable, which is
1766 set when installing Emacs itself.
1767
1768 Additionally, autoload definitions are automatically evaluated at the
1769 initialization of Emacs, by the Guix-specific
1770 @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
1771 want to avoid auto-loading the Emacs packages installed with Guix, you
1772 can do so by running Emacs with the @option{--no-site-file} option
1773 (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1774
1775 @subsection The GCC toolchain
1776
1777 @c XXX: The contents of this section were moved under
1778 @c ``Development'', since it makes more sense there and is not specific
1779 @c foreign distros. Remove it from here eventually?
1780 @xref{Packages for C Development}, for information on packages for C/C++
1781 development.
1782
1783 @node Upgrading Guix
1784 @section Upgrading Guix
1785
1786 @cindex Upgrading Guix, on a foreign distro
1787
1788 To upgrade Guix, run:
1789
1790 @example
1791 guix pull
1792 @end example
1793
1794 @xref{Invoking guix pull}, for more information.
1795
1796 @cindex upgrading Guix for the root user, on a foreign distro
1797 @cindex upgrading the Guix daemon, on a foreign distro
1798 @cindex @command{guix pull} for the root user, on a foreign distro
1799
1800 On a foreign distro, you can upgrade the build daemon by running:
1801
1802 @example
1803 sudo -i guix pull
1804 @end example
1805
1806 @noindent
1807 followed by (assuming your distro uses the systemd service management
1808 tool):
1809
1810 @example
1811 systemctl restart guix-daemon.service
1812 @end example
1813
1814 On Guix System, upgrading the daemon is achieved by reconfiguring the
1815 system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
1816
1817 @c TODO What else?
1818
1819 @c *********************************************************************
1820 @node System Installation
1821 @chapter System Installation
1822
1823 @cindex installing Guix System
1824 @cindex Guix System, installation
1825 This section explains how to install Guix System
1826 on a machine. Guix, as a package manager, can
1827 also be installed on top of a running GNU/Linux system,
1828 @pxref{Installation}.
1829
1830 @ifinfo
1831 @quotation Note
1832 @c This paragraph is for people reading this from tty2 of the
1833 @c installation image.
1834 You are reading this documentation with an Info reader. For details on
1835 how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
1836 link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
1837 Info}. Hit @kbd{l} afterwards to come back here.
1838
1839 Alternately, run @command{info info} in another tty to keep the manual
1840 available.
1841 @end quotation
1842 @end ifinfo
1843
1844 @menu
1845 * Limitations:: What you can expect.
1846 * Hardware Considerations:: Supported hardware.
1847 * USB Stick and DVD Installation:: Preparing the installation medium.
1848 * Preparing for Installation:: Networking, partitioning, etc.
1849 * Guided Graphical Installation:: Easy graphical installation.
1850 * Manual Installation:: Manual installation for wizards.
1851 * After System Installation:: When installation succeeded.
1852 * Installing Guix in a VM:: Guix System playground.
1853 * Building the Installation Image:: How this comes to be.
1854 @end menu
1855
1856 @node Limitations
1857 @section Limitations
1858
1859 We consider Guix System to be ready for a wide range of ``desktop'' and server
1860 use cases. The reliability guarantees it provides---transactional upgrades
1861 and rollbacks, reproducibility---make it a solid foundation.
1862
1863 Nevertheless, before you proceed with the installation, be aware of the
1864 following noteworthy limitations applicable to version @value{VERSION}:
1865
1866 @itemize
1867 @item
1868 Support for the Logical Volume Manager (LVM) is missing.
1869
1870 @item
1871 More and more system services are provided (@pxref{Services}), but some
1872 may be missing.
1873
1874 @item
1875 GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
1876 as well as a number of X11 window managers. However, KDE is currently
1877 missing.
1878 @end itemize
1879
1880 More than a disclaimer, this is an invitation to report issues (and success
1881 stories!), and to join us in improving it. @xref{Contributing}, for more
1882 info.
1883
1884
1885 @node Hardware Considerations
1886 @section Hardware Considerations
1887
1888 @cindex hardware support on Guix System
1889 GNU@tie{}Guix focuses on respecting the user's computing freedom. It
1890 builds around the kernel Linux-libre, which means that only hardware for
1891 which free software drivers and firmware exist is supported. Nowadays,
1892 a wide range of off-the-shelf hardware is supported on
1893 GNU/Linux-libre---from keyboards to graphics cards to scanners and
1894 Ethernet controllers. Unfortunately, there are still areas where
1895 hardware vendors deny users control over their own computing, and such
1896 hardware is not supported on Guix System.
1897
1898 @cindex WiFi, hardware support
1899 One of the main areas where free drivers or firmware are lacking is WiFi
1900 devices. WiFi devices known to work include those using Atheros chips
1901 (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
1902 driver, and those using Broadcom/AirForce chips (BCM43xx with
1903 Wireless-Core Revision 5), which corresponds to the @code{b43-open}
1904 Linux-libre driver. Free firmware exists for both and is available
1905 out-of-the-box on Guix System, as part of @code{%base-firmware}
1906 (@pxref{operating-system Reference, @code{firmware}}).
1907
1908 @cindex RYF, Respects Your Freedom
1909 The @uref{https://www.fsf.org/, Free Software Foundation} runs
1910 @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
1911 certification program for hardware products that respect your freedom
1912 and your privacy and ensure that you have control over your device. We
1913 encourage you to check the list of RYF-certified devices.
1914
1915 Another useful resource is the @uref{https://www.h-node.org/, H-Node}
1916 web site. It contains a catalog of hardware devices with information
1917 about their support in GNU/Linux.
1918
1919
1920 @node USB Stick and DVD Installation
1921 @section USB Stick and DVD Installation
1922
1923 An ISO-9660 installation image that can be written to a USB stick or
1924 burnt to a DVD can be downloaded from
1925 @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.@var{system}.iso.xz},
1926 where @var{system} is one of:
1927
1928 @table @code
1929 @item x86_64-linux
1930 for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
1931
1932 @item i686-linux
1933 for a 32-bit GNU/Linux system on Intel-compatible CPUs.
1934 @end table
1935
1936 @c start duplication of authentication part from ``Binary Installation''
1937 Make sure to download the associated @file{.sig} file and to verify the
1938 authenticity of the image against it, along these lines:
1939
1940 @example
1941 $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.@var{system}.iso.xz.sig
1942 $ gpg --verify guix-system-install-@value{VERSION}.@var{system}.iso.xz.sig
1943 @end example
1944
1945 If that command fails because you do not have the required public key,
1946 then run this command to import it:
1947
1948 @example
1949 $ wget @value{OPENPGP-SIGNING-KEY-URL} \
1950 -qO - | gpg --import -
1951 @end example
1952
1953 @noindent
1954 and rerun the @code{gpg --verify} command.
1955
1956 Take note that a warning like ``This key is not certified with a trusted
1957 signature!'' is normal.
1958
1959 @c end duplication
1960
1961 This image contains the tools necessary for an installation.
1962 It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
1963
1964 @unnumberedsubsec Copying to a USB Stick
1965
1966 To copy the image to a USB stick, follow these steps:
1967
1968 @enumerate
1969 @item
1970 Decompress the image using the @command{xz} command:
1971
1972 @example
1973 xz -d guix-system-install-@value{VERSION}.@var{system}.iso.xz
1974 @end example
1975
1976 @item
1977 Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
1978 its device name. Assuming that the USB stick is known as @file{/dev/sdX},
1979 copy the image with:
1980
1981 @example
1982 dd if=guix-system-install-@value{VERSION}.@var{system}.iso of=/dev/sdX
1983 sync
1984 @end example
1985
1986 Access to @file{/dev/sdX} usually requires root privileges.
1987 @end enumerate
1988
1989 @unnumberedsubsec Burning on a DVD
1990
1991 To copy the image to a DVD, follow these steps:
1992
1993 @enumerate
1994 @item
1995 Decompress the image using the @command{xz} command:
1996
1997 @example
1998 xz -d guix-system-install-@value{VERSION}.@var{system}.iso.xz
1999 @end example
2000
2001 @item
2002 Insert a blank DVD into your machine, and determine
2003 its device name. Assuming that the DVD drive is known as @file{/dev/srX},
2004 copy the image with:
2005
2006 @example
2007 growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.@var{system}.iso
2008 @end example
2009
2010 Access to @file{/dev/srX} usually requires root privileges.
2011 @end enumerate
2012
2013 @unnumberedsubsec Booting
2014
2015 Once this is done, you should be able to reboot the system and boot from
2016 the USB stick or DVD. The latter usually requires you to get in the
2017 BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
2018 In order to boot from Libreboot, switch to the command mode by pressing
2019 the @kbd{c} key and type @command{search_grub usb}.
2020
2021 @xref{Installing Guix in a VM}, if, instead, you would like to install
2022 Guix System in a virtual machine (VM).
2023
2024
2025 @node Preparing for Installation
2026 @section Preparing for Installation
2027
2028 Once you have booted, you can use the guided graphical installer, which makes
2029 it easy to get started (@pxref{Guided Graphical Installation}). Alternately,
2030 if you are already familiar with GNU/Linux and if you want more control than
2031 what the graphical installer provides, you can choose the ``manual''
2032 installation process (@pxref{Manual Installation}).
2033
2034 The graphical installer is available on TTY1. You can obtain root shells on
2035 TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
2036 this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
2037 is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
2038 Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
2039 which allows you to select text with the left mouse button and to paste it
2040 with the middle button.
2041
2042 @quotation Note
2043 Installation requires access to the Internet so that any missing
2044 dependencies of your system configuration can be downloaded. See the
2045 ``Networking'' section below.
2046 @end quotation
2047
2048 @node Guided Graphical Installation
2049 @section Guided Graphical Installation
2050
2051 The graphical installer is a text-based user interface. It will guide you,
2052 with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
2053
2054 The first dialog boxes allow you to set up the system as you use it during the
2055 installation: you can choose the language, keyboard layout, and set up
2056 networking, which will be used during the installation. The image below shows
2057 the networking dialog.
2058
2059 @image{images/installer-network,5in,, networking setup with the graphical installer}
2060
2061 Later steps allow you to partition your hard disk, as shown in the image
2062 below, to choose whether or not to use encrypted file systems, to enter the
2063 host name and root password, and to create an additional account, among other
2064 things.
2065
2066 @image{images/installer-partitions,5in,, partitioning with the graphical installer}
2067
2068 Note that, at any time, the installer allows you to exit the current
2069 installation step and resume at a previous step, as show in the image below.
2070
2071 @image{images/installer-resume,5in,, resuming the installation process}
2072
2073 Once you're done, the installer produces an operating system configuration and
2074 displays it (@pxref{Using the Configuration System}). At that point you can
2075 hit ``OK'' and installation will proceed. On success, you can reboot into the
2076 new system and enjoy. @xref{After System Installation}, for what's next!
2077
2078
2079 @node Manual Installation
2080 @section Manual Installation
2081
2082 This section describes how you would ``manually'' install GNU@tie{}Guix System
2083 on your machine. This option requires familiarity with GNU/Linux, with the
2084 shell, and with common administration tools. If you think this is not for
2085 you, consider using the guided graphical installer (@pxref{Guided Graphical
2086 Installation}).
2087
2088 The installation system provides root shells on TTYs 3 to 6; press
2089 @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
2090 many common tools needed to install the system. But it is also a full-blown
2091 Guix System, which means that you can install additional packages, should you
2092 need it, using @command{guix package} (@pxref{Invoking guix package}).
2093
2094 @menu
2095 * Keyboard Layout and Networking and Partitioning:: Initial setup.
2096 * Proceeding with the Installation:: Installing.
2097 @end menu
2098
2099 @node Keyboard Layout and Networking and Partitioning
2100 @subsection Keyboard Layout, Networking, and Partitioning
2101
2102 Before you can install the system, you may want to adjust the keyboard layout,
2103 set up networking, and partition your target hard disk. This section will
2104 guide you through this.
2105
2106 @subsubsection Keyboard Layout
2107
2108 @cindex keyboard layout
2109 The installation image uses the US qwerty keyboard layout. If you want
2110 to change it, you can use the @command{loadkeys} command. For example,
2111 the following command selects the Dvorak keyboard layout:
2112
2113 @example
2114 loadkeys dvorak
2115 @end example
2116
2117 See the files under @file{/run/current-system/profile/share/keymaps} for
2118 a list of available keyboard layouts. Run @command{man loadkeys} for
2119 more information.
2120
2121 @subsubsection Networking
2122
2123 Run the following command to see what your network interfaces are called:
2124
2125 @example
2126 ifconfig -a
2127 @end example
2128
2129 @noindent
2130 @dots{} or, using the GNU/Linux-specific @command{ip} command:
2131
2132 @example
2133 ip address
2134 @end example
2135
2136 @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
2137 Wired interfaces have a name starting with @samp{e}; for example, the
2138 interface corresponding to the first on-board Ethernet controller is
2139 called @samp{eno1}. Wireless interfaces have a name starting with
2140 @samp{w}, like @samp{w1p2s0}.
2141
2142 @table @asis
2143 @item Wired connection
2144 To configure a wired network run the following command, substituting
2145 @var{interface} with the name of the wired interface you want to use.
2146
2147 @example
2148 ifconfig @var{interface} up
2149 @end example
2150
2151 @noindent
2152 @dots{} or, using the GNU/Linux-specific @command{ip} command:
2153
2154 @example
2155 ip link set @var{interface} up
2156 @end example
2157
2158 @item Wireless connection
2159 @cindex wireless
2160 @cindex WiFi
2161 To configure wireless networking, you can create a configuration file
2162 for the @command{wpa_supplicant} configuration tool (its location is not
2163 important) using one of the available text editors such as
2164 @command{nano}:
2165
2166 @example
2167 nano wpa_supplicant.conf
2168 @end example
2169
2170 As an example, the following stanza can go to this file and will work
2171 for many wireless networks, provided you give the actual SSID and
2172 passphrase for the network you are connecting to:
2173
2174 @example
2175 network=@{
2176 ssid="@var{my-ssid}"
2177 key_mgmt=WPA-PSK
2178 psk="the network's secret passphrase"
2179 @}
2180 @end example
2181
2182 Start the wireless service and run it in the background with the
2183 following command (substitute @var{interface} with the name of the
2184 network interface you want to use):
2185
2186 @example
2187 wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
2188 @end example
2189
2190 Run @command{man wpa_supplicant} for more information.
2191 @end table
2192
2193 @cindex DHCP
2194 At this point, you need to acquire an IP address. On a network where IP
2195 addresses are automatically assigned @i{via} DHCP, you can run:
2196
2197 @example
2198 dhclient -v @var{interface}
2199 @end example
2200
2201 Try to ping a server to see if networking is up and running:
2202
2203 @example
2204 ping -c 3 gnu.org
2205 @end example
2206
2207 Setting up network access is almost always a requirement because the
2208 image does not contain all the software and tools that may be needed.
2209
2210 @cindex proxy, during system installation
2211 If you need HTTP and HTTPS access to go through a proxy, run the
2212 following command:
2213
2214 @example
2215 herd set-http-proxy guix-daemon @var{URL}
2216 @end example
2217
2218 @noindent
2219 where @var{URL} is the proxy URL, for example
2220 @code{http://example.org:8118}.
2221
2222 @cindex installing over SSH
2223 If you want to, you can continue the installation remotely by starting
2224 an SSH server:
2225
2226 @example
2227 herd start ssh-daemon
2228 @end example
2229
2230 Make sure to either set a password with @command{passwd}, or configure
2231 OpenSSH public key authentication before logging in.
2232
2233 @subsubsection Disk Partitioning
2234
2235 Unless this has already been done, the next step is to partition, and
2236 then format the target partition(s).
2237
2238 The installation image includes several partitioning tools, including
2239 Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
2240 @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
2241 the partition layout you want:
2242
2243 @example
2244 cfdisk
2245 @end example
2246
2247 If your disk uses the GUID Partition Table (GPT) format and you plan to
2248 install BIOS-based GRUB (which is the default), make sure a BIOS Boot
2249 Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
2250 manual}).
2251
2252 @cindex EFI, installation
2253 @cindex UEFI, installation
2254 @cindex ESP, EFI system partition
2255 If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
2256 (ESP) is required. This partition can be mounted at @file{/boot/efi} for
2257 instance and must have the @code{esp} flag set. E.g., for @command{parted}:
2258
2259 @example
2260 parted /dev/sda set 1 esp on
2261 @end example
2262
2263 @quotation Note
2264 @vindex grub-bootloader
2265 @vindex grub-efi-bootloader
2266 Unsure whether to use EFI- or BIOS-based GRUB? If the directory
2267 @file{/sys/firmware/efi} exists in the installation image, then you should
2268 probably perform an EFI installation, using @code{grub-efi-bootloader}.
2269 Otherwise you should use the BIOS-based GRUB, known as
2270 @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
2271 bootloaders.
2272 @end quotation
2273
2274 Once you are done partitioning the target hard disk drive, you have to
2275 create a file system on the relevant partition(s)@footnote{Currently
2276 Guix System only supports ext4, btrfs, and JFS file systems. In particular,
2277 code that reads file system UUIDs and labels only works for these file system
2278 types.}. For the ESP, if you have one and assuming it is
2279 @file{/dev/sda1}, run:
2280
2281 @example
2282 mkfs.fat -F32 /dev/sda1
2283 @end example
2284
2285 Preferably, assign file systems a label so that you can easily and
2286 reliably refer to them in @code{file-system} declarations (@pxref{File
2287 Systems}). This is typically done using the @code{-L} option of
2288 @command{mkfs.ext4} and related commands. So, assuming the target root
2289 partition lives at @file{/dev/sda2}, a file system with the label
2290 @code{my-root} can be created with:
2291
2292 @example
2293 mkfs.ext4 -L my-root /dev/sda2
2294 @end example
2295
2296 @cindex encrypted disk
2297 If you are instead planning to encrypt the root partition, you can use
2298 the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
2299 @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
2300 @code{man cryptsetup}} for more information.) Assuming you want to
2301 store the root partition on @file{/dev/sda2}, the command sequence would
2302 be along these lines:
2303
2304 @example
2305 cryptsetup luksFormat /dev/sda2
2306 cryptsetup open --type luks /dev/sda2 my-partition
2307 mkfs.ext4 -L my-root /dev/mapper/my-partition
2308 @end example
2309
2310 Once that is done, mount the target file system under @file{/mnt}
2311 with a command like (again, assuming @code{my-root} is the label of the
2312 root file system):
2313
2314 @example
2315 mount LABEL=my-root /mnt
2316 @end example
2317
2318 Also mount any other file systems you would like to use on the target
2319 system relative to this path. If you have opted for @file{/boot/efi} as an
2320 EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
2321 found by @code{guix system init} afterwards.
2322
2323 Finally, if you plan to use one or more swap partitions (@pxref{Memory
2324 Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
2325 sure to initialize them with @command{mkswap}. Assuming you have one
2326 swap partition on @file{/dev/sda3}, you would run:
2327
2328 @example
2329 mkswap /dev/sda3
2330 swapon /dev/sda3
2331 @end example
2332
2333 Alternatively, you may use a swap file. For example, assuming that in
2334 the new system you want to use the file @file{/swapfile} as a swap file,
2335 you would run@footnote{This example will work for many types of file
2336 systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
2337 btrfs), the required steps may be different. For details, see the
2338 manual pages for @command{mkswap} and @command{swapon}.}:
2339
2340 @example
2341 # This is 10 GiB of swap space. Adjust "count" to change the size.
2342 dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
2343 # For security, make the file readable and writable only by root.
2344 chmod 600 /mnt/swapfile
2345 mkswap /mnt/swapfile
2346 swapon /mnt/swapfile
2347 @end example
2348
2349 Note that if you have encrypted the root partition and created a swap
2350 file in its file system as described above, then the encryption also
2351 protects the swap file, just like any other file in that file system.
2352
2353 @node Proceeding with the Installation
2354 @subsection Proceeding with the Installation
2355
2356 With the target partitions ready and the target root mounted on
2357 @file{/mnt}, we're ready to go. First, run:
2358
2359 @example
2360 herd start cow-store /mnt
2361 @end example
2362
2363 This makes @file{/gnu/store} copy-on-write, such that packages added to it
2364 during the installation phase are written to the target disk on @file{/mnt}
2365 rather than kept in memory. This is necessary because the first phase of
2366 the @command{guix system init} command (see below) entails downloads or
2367 builds to @file{/gnu/store} which, initially, is an in-memory file system.
2368
2369 Next, you have to edit a file and
2370 provide the declaration of the operating system to be installed. To
2371 that end, the installation system comes with three text editors. We
2372 recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
2373 supports syntax highlighting and parentheses matching; other editors
2374 include GNU Zile (an Emacs clone), and
2375 nvi (a clone of the original BSD @command{vi} editor).
2376 We strongly recommend storing that file on the target root file system, say,
2377 as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
2378 configuration file once you have rebooted into the newly-installed system.
2379
2380 @xref{Using the Configuration System}, for an overview of the
2381 configuration file. The example configurations discussed in that
2382 section are available under @file{/etc/configuration} in the
2383 installation image. Thus, to get started with a system configuration
2384 providing a graphical display server (a ``desktop'' system), you can run
2385 something along these lines:
2386
2387 @example
2388 # mkdir /mnt/etc
2389 # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
2390 # nano /mnt/etc/config.scm
2391 @end example
2392
2393 You should pay attention to what your configuration file contains, and
2394 in particular:
2395
2396 @itemize
2397 @item
2398 Make sure the @code{bootloader-configuration} form refers to the target
2399 you want to install GRUB on. It should mention @code{grub-bootloader} if
2400 you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
2401 for newer UEFI systems. For legacy systems, the @code{target} field
2402 names a device, like @code{/dev/sda}; for UEFI systems it names a path
2403 to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
2404 currently mounted and a @code{file-system} entry is specified in your
2405 configuration.
2406
2407 @item
2408 Be sure that your file system labels match the value of their respective
2409 @code{device} fields in your @code{file-system} configuration, assuming
2410 your @code{file-system} configuration uses the @code{file-system-label}
2411 procedure in its @code{device} field.
2412
2413 @item
2414 If there are encrypted or RAID partitions, make sure to add a
2415 @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
2416 @end itemize
2417
2418 Once you are done preparing the configuration file, the new system must
2419 be initialized (remember that the target root file system is mounted
2420 under @file{/mnt}):
2421
2422 @example
2423 guix system init /mnt/etc/config.scm /mnt
2424 @end example
2425
2426 @noindent
2427 This copies all the necessary files and installs GRUB on
2428 @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
2429 more information, @pxref{Invoking guix system}. This command may trigger
2430 downloads or builds of missing packages, which can take some time.
2431
2432 Once that command has completed---and hopefully succeeded!---you can run
2433 @command{reboot} and boot into the new system. The @code{root} password
2434 in the new system is initially empty; other users' passwords need to be
2435 initialized by running the @command{passwd} command as @code{root},
2436 unless your configuration specifies otherwise
2437 (@pxref{user-account-password, user account passwords}).
2438 @xref{After System Installation}, for what's next!
2439
2440
2441 @node After System Installation
2442 @section After System Installation
2443
2444 Success, you've now booted into Guix System! From then on, you can update the
2445 system whenever you want by running, say:
2446
2447 @example
2448 guix pull
2449 sudo guix system reconfigure /etc/config.scm
2450 @end example
2451
2452 @noindent
2453 This builds a new system generation with the latest packages and services
2454 (@pxref{Invoking guix system}). We recommend doing that regularly so that
2455 your system includes the latest security updates (@pxref{Security Updates}).
2456
2457 @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
2458 @quotation Note
2459 @cindex sudo vs. @command{guix pull}
2460 Note that @command{sudo guix} runs your user's @command{guix} command and
2461 @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
2462 explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
2463
2464 The difference matters here, because @command{guix pull} updates
2465 the @command{guix} command and package definitions only for the user it is ran
2466 as. This means that if you choose to use @command{guix system reconfigure} in
2467 root's login shell, you'll need to @command{guix pull} separately.
2468 @end quotation
2469
2470 Join us on @code{#guix} on the Freenode IRC network or on
2471 @email{guix-devel@@gnu.org} to share your experience!
2472
2473
2474 @node Installing Guix in a VM
2475 @section Installing Guix in a Virtual Machine
2476
2477 @cindex virtual machine, Guix System installation
2478 @cindex virtual private server (VPS)
2479 @cindex VPS (virtual private server)
2480 If you'd like to install Guix System in a virtual machine (VM) or on a
2481 virtual private server (VPS) rather than on your beloved machine, this
2482 section is for you.
2483
2484 To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
2485 disk image, follow these steps:
2486
2487 @enumerate
2488 @item
2489 First, retrieve and decompress the Guix system installation image as
2490 described previously (@pxref{USB Stick and DVD Installation}).
2491
2492 @item
2493 Create a disk image that will hold the installed system. To make a
2494 qcow2-formatted disk image, use the @command{qemu-img} command:
2495
2496 @example
2497 qemu-img create -f qcow2 guix-system.img 50G
2498 @end example
2499
2500 The resulting file will be much smaller than 50 GB (typically less than
2501 1 MB), but it will grow as the virtualized storage device is filled up.
2502
2503 @item
2504 Boot the USB installation image in an VM:
2505
2506 @example
2507 qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
2508 -nic user,model=virtio-net-pci -boot menu=on,order=d \
2509 -drive file=guix-system.img \
2510 -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
2511 @end example
2512
2513 @code{-enable-kvm} is optional, but significantly improves performance,
2514 @pxref{Running Guix in a VM}.
2515
2516 @item
2517 You're now root in the VM, proceed with the installation process.
2518 @xref{Preparing for Installation}, and follow the instructions.
2519 @end enumerate
2520
2521 Once installation is complete, you can boot the system that's on your
2522 @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
2523 that.
2524
2525 @node Building the Installation Image
2526 @section Building the Installation Image
2527
2528 @cindex installation image
2529 The installation image described above was built using the @command{guix
2530 system} command, specifically:
2531
2532 @example
2533 guix system disk-image --file-system-type=iso9660 \
2534 gnu/system/install.scm
2535 @end example
2536
2537 Have a look at @file{gnu/system/install.scm} in the source tree,
2538 and see also @ref{Invoking guix system} for more information
2539 about the installation image.
2540
2541 @section Building the Installation Image for ARM Boards
2542
2543 Many ARM boards require a specific variant of the
2544 @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
2545
2546 If you build a disk image and the bootloader is not available otherwise
2547 (on another boot drive etc), it's advisable to build an image that
2548 includes the bootloader, specifically:
2549
2550 @example
2551 guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
2552 @end example
2553
2554 @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
2555 board, a list of possible boards will be printed.
2556
2557 @c *********************************************************************
2558 @node Package Management
2559 @chapter Package Management
2560
2561 @cindex packages
2562 The purpose of GNU Guix is to allow users to easily install, upgrade, and
2563 remove software packages, without having to know about their build
2564 procedures or dependencies. Guix also goes beyond this obvious set of
2565 features.
2566
2567 This chapter describes the main features of Guix, as well as the
2568 package management tools it provides. Along with the command-line
2569 interface described below (@pxref{Invoking guix package, @code{guix
2570 package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
2571 emacs-guix, The Emacs-Guix Reference Manual}), after installing
2572 @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
2573 with it):
2574
2575 @example
2576 guix install emacs-guix
2577 @end example
2578
2579 @menu
2580 * Features:: How Guix will make your life brighter.
2581 * Invoking guix package:: Package installation, removal, etc.
2582 * Substitutes:: Downloading pre-built binaries.
2583 * Packages with Multiple Outputs:: Single source package, multiple outputs.
2584 * Invoking guix gc:: Running the garbage collector.
2585 * Invoking guix pull:: Fetching the latest Guix and distribution.
2586 * Channels:: Customizing the package collection.
2587 * Invoking guix time-machine:: Running an older revision of Guix.
2588 * Inferiors:: Interacting with another revision of Guix.
2589 * Invoking guix describe:: Display information about your Guix revision.
2590 * Invoking guix archive:: Exporting and importing store files.
2591 @end menu
2592
2593 @node Features
2594 @section Features
2595
2596 When using Guix, each package ends up in the @dfn{package store}, in its
2597 own directory---something that resembles
2598 @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
2599
2600 Instead of referring to these directories, users have their own
2601 @dfn{profile}, which points to the packages that they actually want to
2602 use. These profiles are stored within each user's home directory, at
2603 @code{$HOME/.guix-profile}.
2604
2605 For example, @code{alice} installs GCC 4.7.2. As a result,
2606 @file{/home/alice/.guix-profile/bin/gcc} points to
2607 @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
2608 @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
2609 simply continues to point to
2610 @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
2611 coexist on the same system without any interference.
2612
2613 The @command{guix package} command is the central tool to manage
2614 packages (@pxref{Invoking guix package}). It operates on the per-user
2615 profiles, and can be used @emph{with normal user privileges}.
2616
2617 @cindex transactions
2618 The command provides the obvious install, remove, and upgrade
2619 operations. Each invocation is actually a @emph{transaction}: either
2620 the specified operation succeeds, or nothing happens. Thus, if the
2621 @command{guix package} process is terminated during the transaction,
2622 or if a power outage occurs during the transaction, then the user's
2623 profile remains in its previous state, and remains usable.
2624
2625 In addition, any package transaction may be @emph{rolled back}. So, if,
2626 for example, an upgrade installs a new version of a package that turns
2627 out to have a serious bug, users may roll back to the previous instance
2628 of their profile, which was known to work well. Similarly, the global
2629 system configuration on Guix is subject to
2630 transactional upgrades and roll-back
2631 (@pxref{Using the Configuration System}).
2632
2633 All packages in the package store may be @emph{garbage-collected}.
2634 Guix can determine which packages are still referenced by user
2635 profiles, and remove those that are provably no longer referenced
2636 (@pxref{Invoking guix gc}). Users may also explicitly remove old
2637 generations of their profile so that the packages they refer to can be
2638 collected.
2639
2640 @cindex reproducibility
2641 @cindex reproducible builds
2642 Guix takes a @dfn{purely functional} approach to package
2643 management, as described in the introduction (@pxref{Introduction}).
2644 Each @file{/gnu/store} package directory name contains a hash of all the
2645 inputs that were used to build that package---compiler, libraries, build
2646 scripts, etc. This direct correspondence allows users to make sure a
2647 given package installation matches the current state of their
2648 distribution. It also helps maximize @dfn{build reproducibility}:
2649 thanks to the isolated build environments that are used, a given build
2650 is likely to yield bit-identical files when performed on different
2651 machines (@pxref{Invoking guix-daemon, container}).
2652
2653 @cindex substitutes
2654 This foundation allows Guix to support @dfn{transparent binary/source
2655 deployment}. When a pre-built binary for a @file{/gnu/store} item is
2656 available from an external source---a @dfn{substitute}, Guix just
2657 downloads it and unpacks it;
2658 otherwise, it builds the package from source, locally
2659 (@pxref{Substitutes}). Because build results are usually bit-for-bit
2660 reproducible, users do not have to trust servers that provide
2661 substitutes: they can force a local build and @emph{challenge} providers
2662 (@pxref{Invoking guix challenge}).
2663
2664 Control over the build environment is a feature that is also useful for
2665 developers. The @command{guix environment} command allows developers of
2666 a package to quickly set up the right development environment for their
2667 package, without having to manually install the dependencies of the
2668 package into their profile (@pxref{Invoking guix environment}).
2669
2670 @cindex replication, of software environments
2671 @cindex provenance tracking, of software artifacts
2672 All of Guix and its package definitions is version-controlled, and
2673 @command{guix pull} allows you to ``travel in time'' on the history of Guix
2674 itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
2675 Guix instance on a different machine or at a later point in time, which in
2676 turn allows you to @emph{replicate complete software environments}, while
2677 retaining precise @dfn{provenance tracking} of the software.
2678
2679 @node Invoking guix package
2680 @section Invoking @command{guix package}
2681
2682 @cindex installing packages
2683 @cindex removing packages
2684 @cindex package installation
2685 @cindex package removal
2686 The @command{guix package} command is the tool that allows users to
2687 install, upgrade, and remove packages, as well as rolling back to
2688 previous configurations. It operates only on the user's own profile,
2689 and works with normal user privileges (@pxref{Features}). Its syntax
2690 is:
2691
2692 @example
2693 guix package @var{options}
2694 @end example
2695
2696 @cindex transactions
2697 Primarily, @var{options} specifies the operations to be performed during
2698 the transaction. Upon completion, a new profile is created, but
2699 previous @dfn{generations} of the profile remain available, should the user
2700 want to roll back.
2701
2702 For example, to remove @code{lua} and install @code{guile} and
2703 @code{guile-cairo} in a single transaction:
2704
2705 @example
2706 guix package -r lua -i guile guile-cairo
2707 @end example
2708
2709 @cindex aliases, for @command{guix package}
2710 For your convenience, we also provide the following aliases:
2711
2712 @itemize
2713 @item
2714 @command{guix search} is an alias for @command{guix package -s},
2715 @item
2716 @command{guix install} is an alias for @command{guix package -i},
2717 @item
2718 @command{guix remove} is an alias for @command{guix package -r},
2719 @item
2720 @command{guix upgrade} is an alias for @command{guix package -u},
2721 @item
2722 and @command{guix show} is an alias for @command{guix package --show=}.
2723 @end itemize
2724
2725 These aliases are less expressive than @command{guix package} and provide
2726 fewer options, so in some cases you'll probably want to use @command{guix
2727 package} directly.
2728
2729 @command{guix package} also supports a @dfn{declarative approach}
2730 whereby the user specifies the exact set of packages to be available and
2731 passes it @i{via} the @option{--manifest} option
2732 (@pxref{profile-manifest, @option{--manifest}}).
2733
2734 @cindex profile
2735 For each user, a symlink to the user's default profile is automatically
2736 created in @file{$HOME/.guix-profile}. This symlink always points to the
2737 current generation of the user's default profile. Thus, users can add
2738 @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
2739 variable, and so on.
2740 @cindex search paths
2741 If you are not using Guix System, consider adding the
2742 following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
2743 Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
2744 shells get all the right environment variable definitions:
2745
2746 @example
2747 GUIX_PROFILE="$HOME/.guix-profile" ; \
2748 source "$HOME/.guix-profile/etc/profile"
2749 @end example
2750
2751 In a multi-user setup, user profiles are stored in a place registered as
2752 a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
2753 to (@pxref{Invoking guix gc}). That directory is normally
2754 @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
2755 @var{localstatedir} is the value passed to @code{configure} as
2756 @option{--localstatedir}, and @var{user} is the user name. The
2757 @file{per-user} directory is created when @command{guix-daemon} is
2758 started, and the @var{user} sub-directory is created by @command{guix
2759 package}.
2760
2761 The @var{options} can be among the following:
2762
2763 @table @code
2764
2765 @item --install=@var{package} @dots{}
2766 @itemx -i @var{package} @dots{}
2767 Install the specified @var{package}s.
2768
2769 Each @var{package} may specify either a simple package name, such as
2770 @code{guile}, or a package name followed by an at-sign and version number,
2771 such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
2772 case, the newest version prefixed by @code{1.8} is selected.)
2773
2774 If no version number is specified, the
2775 newest available version will be selected. In addition, @var{package}
2776 may contain a colon, followed by the name of one of the outputs of the
2777 package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
2778 (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
2779 name (and optionally version) are searched for among the GNU
2780 distribution modules (@pxref{Package Modules}).
2781
2782 @cindex propagated inputs
2783 Sometimes packages have @dfn{propagated inputs}: these are dependencies
2784 that automatically get installed along with the required package
2785 (@pxref{package-propagated-inputs, @code{propagated-inputs} in
2786 @code{package} objects}, for information about propagated inputs in
2787 package definitions).
2788
2789 @anchor{package-cmd-propagated-inputs}
2790 An example is the GNU MPC library: its C header files refer to those of
2791 the GNU MPFR library, which in turn refer to those of the GMP library.
2792 Thus, when installing MPC, the MPFR and GMP libraries also get installed
2793 in the profile; removing MPC also removes MPFR and GMP---unless they had
2794 also been explicitly installed by the user.
2795
2796 Besides, packages sometimes rely on the definition of environment
2797 variables for their search paths (see explanation of
2798 @option{--search-paths} below). Any missing or possibly incorrect
2799 environment variable definitions are reported here.
2800
2801 @item --install-from-expression=@var{exp}
2802 @itemx -e @var{exp}
2803 Install the package @var{exp} evaluates to.
2804
2805 @var{exp} must be a Scheme expression that evaluates to a
2806 @code{<package>} object. This option is notably useful to disambiguate
2807 between same-named variants of a package, with expressions such as
2808 @code{(@@ (gnu packages base) guile-final)}.
2809
2810 Note that this option installs the first output of the specified
2811 package, which may be insufficient when needing a specific output of a
2812 multiple-output package.
2813
2814 @item --install-from-file=@var{file}
2815 @itemx -f @var{file}
2816 Install the package that the code within @var{file} evaluates to.
2817
2818 As an example, @var{file} might contain a definition like this
2819 (@pxref{Defining Packages}):
2820
2821 @lisp
2822 @include package-hello.scm
2823 @end lisp
2824
2825 Developers may find it useful to include such a @file{guix.scm} file
2826 in the root of their project source tree that can be used to test
2827 development snapshots and create reproducible development environments
2828 (@pxref{Invoking guix environment}).
2829
2830 The @var{file} may also contain a JSON representation of one or more
2831 package definitions. Running @code{guix package -f} on
2832 @file{hello.json} with the following contents would result in installing
2833 the package @code{greeter} after building @code{myhello}:
2834
2835 @example
2836 @verbatiminclude package-hello.json
2837 @end example
2838
2839 @item --remove=@var{package} @dots{}
2840 @itemx -r @var{package} @dots{}
2841 Remove the specified @var{package}s.
2842
2843 As for @option{--install}, each @var{package} may specify a version number
2844 and/or output name in addition to the package name. For instance,
2845 @samp{-r glibc:debug} would remove the @code{debug} output of
2846 @code{glibc}.
2847
2848 @item --upgrade[=@var{regexp} @dots{}]
2849 @itemx -u [@var{regexp} @dots{}]
2850 @cindex upgrading packages
2851 Upgrade all the installed packages. If one or more @var{regexp}s are
2852 specified, upgrade only installed packages whose name matches a
2853 @var{regexp}. Also see the @option{--do-not-upgrade} option below.
2854
2855 Note that this upgrades package to the latest version of packages found
2856 in the distribution currently installed. To update your distribution,
2857 you should regularly run @command{guix pull} (@pxref{Invoking guix
2858 pull}).
2859
2860 @item --do-not-upgrade[=@var{regexp} @dots{}]
2861 When used together with the @option{--upgrade} option, do @emph{not}
2862 upgrade any packages whose name matches a @var{regexp}. For example, to
2863 upgrade all packages in the current profile except those containing the
2864 substring ``emacs'':
2865
2866 @example
2867 $ guix package --upgrade . --do-not-upgrade emacs
2868 @end example
2869
2870 @item @anchor{profile-manifest}--manifest=@var{file}
2871 @itemx -m @var{file}
2872 @cindex profile declaration
2873 @cindex profile manifest
2874 Create a new generation of the profile from the manifest object
2875 returned by the Scheme code in @var{file}. This option can be repeated
2876 several times, in which case the manifests are concatenated.
2877
2878 This allows you to @emph{declare} the profile's contents rather than
2879 constructing it through a sequence of @option{--install} and similar
2880 commands. The advantage is that @var{file} can be put under version
2881 control, copied to different machines to reproduce the same profile, and
2882 so on.
2883
2884 @c FIXME: Add reference to (guix profile) documentation when available.
2885 @var{file} must return a @dfn{manifest} object, which is roughly a list
2886 of packages:
2887
2888 @findex packages->manifest
2889 @lisp
2890 (use-package-modules guile emacs)
2891
2892 (packages->manifest
2893 (list emacs
2894 guile-2.0
2895 ;; Use a specific package output.
2896 (list guile-2.0 "debug")))
2897 @end lisp
2898
2899 @findex specifications->manifest
2900 In this example we have to know which modules define the @code{emacs}
2901 and @code{guile-2.0} variables to provide the right
2902 @code{use-package-modules} line, which can be cumbersome. We can
2903 instead provide regular package specifications and let
2904 @code{specifications->manifest} look up the corresponding package
2905 objects, like this:
2906
2907 @lisp
2908 (specifications->manifest
2909 '("emacs" "guile@@2.2" "guile@@2.2:debug"))
2910 @end lisp
2911
2912 @item --roll-back
2913 @cindex rolling back
2914 @cindex undoing transactions
2915 @cindex transactions, undoing
2916 Roll back to the previous @dfn{generation} of the profile---i.e., undo
2917 the last transaction.
2918
2919 When combined with options such as @option{--install}, roll back occurs
2920 before any other actions.
2921
2922 When rolling back from the first generation that actually contains
2923 installed packages, the profile is made to point to the @dfn{zeroth
2924 generation}, which contains no files apart from its own metadata.
2925
2926 After having rolled back, installing, removing, or upgrading packages
2927 overwrites previous future generations. Thus, the history of the
2928 generations in a profile is always linear.
2929
2930 @item --switch-generation=@var{pattern}
2931 @itemx -S @var{pattern}
2932 @cindex generations
2933 Switch to a particular generation defined by @var{pattern}.
2934
2935 @var{pattern} may be either a generation number or a number prefixed
2936 with ``+'' or ``-''. The latter means: move forward/backward by a
2937 specified number of generations. For example, if you want to return to
2938 the latest generation after @option{--roll-back}, use
2939 @option{--switch-generation=+1}.
2940
2941 The difference between @option{--roll-back} and
2942 @option{--switch-generation=-1} is that @option{--switch-generation} will
2943 not make a zeroth generation, so if a specified generation does not
2944 exist, the current generation will not be changed.
2945
2946 @item --search-paths[=@var{kind}]
2947 @cindex search paths
2948 Report environment variable definitions, in Bash syntax, that may be
2949 needed in order to use the set of installed packages. These environment
2950 variables are used to specify @dfn{search paths} for files used by some
2951 of the installed packages.
2952
2953 For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
2954 environment variables to be defined so it can look for headers and
2955 libraries in the user's profile (@pxref{Environment Variables,,, gcc,
2956 Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
2957 library are installed in the profile, then @option{--search-paths} will
2958 suggest setting these variables to @file{@var{profile}/include} and
2959 @file{@var{profile}/lib}, respectively.
2960
2961 The typical use case is to define these environment variables in the
2962 shell:
2963
2964 @example
2965 $ eval `guix package --search-paths`
2966 @end example
2967
2968 @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
2969 meaning that the returned environment variable definitions will either
2970 be exact settings, or prefixes or suffixes of the current value of these
2971 variables. When omitted, @var{kind} defaults to @code{exact}.
2972
2973 This option can also be used to compute the @emph{combined} search paths
2974 of several profiles. Consider this example:
2975
2976 @example
2977 $ guix package -p foo -i guile
2978 $ guix package -p bar -i guile-json
2979 $ guix package -p foo -p bar --search-paths
2980 @end example
2981
2982 The last command above reports about the @env{GUILE_LOAD_PATH}
2983 variable, even though, taken individually, neither @file{foo} nor
2984 @file{bar} would lead to that recommendation.
2985
2986
2987 @item --profile=@var{profile}
2988 @itemx -p @var{profile}
2989 Use @var{profile} instead of the user's default profile.
2990
2991 @var{profile} must be the name of a file that will be created upon
2992 completion. Concretely, @var{profile} will be a mere symbolic link
2993 (``symlink'') pointing to the actual profile where packages are
2994 installed:
2995
2996 @example
2997 $ guix install hello -p ~/code/my-profile
2998 @dots{}
2999 $ ~/code/my-profile/bin/hello
3000 Hello, world!
3001 @end example
3002
3003 All it takes to get rid of the profile is to remove this symlink and its
3004 siblings that point to specific generations:
3005
3006 @example
3007 $ rm ~/code/my-profile ~/code/my-profile-*-link
3008 @end example
3009
3010 @item --list-profiles
3011 List all the user's profiles:
3012
3013 @example
3014 $ guix package --list-profiles
3015 /home/charlie/.guix-profile
3016 /home/charlie/code/my-profile
3017 /home/charlie/code/devel-profile
3018 /home/charlie/tmp/test
3019 @end example
3020
3021 When running as root, list all the profiles of all the users.
3022
3023 @cindex collisions, in a profile
3024 @cindex colliding packages in profiles
3025 @cindex profile collisions
3026 @item --allow-collisions
3027 Allow colliding packages in the new profile. Use at your own risk!
3028
3029 By default, @command{guix package} reports as an error @dfn{collisions}
3030 in the profile. Collisions happen when two or more different versions
3031 or variants of a given package end up in the profile.
3032
3033 @item --bootstrap
3034 Use the bootstrap Guile to build the profile. This option is only
3035 useful to distribution developers.
3036
3037 @end table
3038
3039 In addition to these actions, @command{guix package} supports the
3040 following options to query the current state of a profile, or the
3041 availability of packages:
3042
3043 @table @option
3044
3045 @item --search=@var{regexp}
3046 @itemx -s @var{regexp}
3047 @cindex searching for packages
3048 List the available packages whose name, synopsis, or description matches
3049 @var{regexp} (in a case-insensitive fashion), sorted by relevance.
3050 Print all the metadata of matching packages in
3051 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
3052 GNU recutils manual}).
3053
3054 This allows specific fields to be extracted using the @command{recsel}
3055 command, for instance:
3056
3057 @example
3058 $ guix package -s malloc | recsel -p name,version,relevance
3059 name: jemalloc
3060 version: 4.5.0
3061 relevance: 6
3062
3063 name: glibc
3064 version: 2.25
3065 relevance: 1
3066
3067 name: libgc
3068 version: 7.6.0
3069 relevance: 1
3070 @end example
3071
3072 Similarly, to show the name of all the packages available under the
3073 terms of the GNU@tie{}LGPL version 3:
3074
3075 @example
3076 $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
3077 name: elfutils
3078
3079 name: gmp
3080 @dots{}
3081 @end example
3082
3083 It is also possible to refine search results using several @code{-s} flags to
3084 @command{guix package}, or several arguments to @command{guix search}. For
3085 example, the following command returns a list of board games (this time using
3086 the @command{guix search} alias):
3087
3088 @example
3089 $ guix search '\<board\>' game | recsel -p name
3090 name: gnubg
3091 @dots{}
3092 @end example
3093
3094 If we were to omit @code{-s game}, we would also get software packages
3095 that deal with printed circuit boards; removing the angle brackets
3096 around @code{board} would further add packages that have to do with
3097 keyboards.
3098
3099 And now for a more elaborate example. The following command searches
3100 for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
3101 libraries, and prints the name and synopsis of the matching packages:
3102
3103 @example
3104 $ guix search crypto library | \
3105 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
3106 @end example
3107
3108 @noindent
3109 @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
3110 information on @dfn{selection expressions} for @code{recsel -e}.
3111
3112 @item --show=@var{package}
3113 Show details about @var{package}, taken from the list of available packages, in
3114 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
3115 recutils manual}).
3116
3117 @example
3118 $ guix package --show=python | recsel -p name,version
3119 name: python
3120 version: 2.7.6
3121
3122 name: python
3123 version: 3.3.5
3124 @end example
3125
3126 You may also specify the full name of a package to only get details about a
3127 specific version of it (this time using the @command{guix show} alias):
3128 @example
3129 $ guix show python@@3.4 | recsel -p name,version
3130 name: python
3131 version: 3.4.3
3132 @end example
3133
3134
3135
3136 @item --list-installed[=@var{regexp}]
3137 @itemx -I [@var{regexp}]
3138 List the currently installed packages in the specified profile, with the
3139 most recently installed packages shown last. When @var{regexp} is
3140 specified, list only installed packages whose name matches @var{regexp}.
3141
3142 For each installed package, print the following items, separated by
3143 tabs: the package name, its version string, the part of the package that
3144 is installed (for instance, @code{out} for the default output,
3145 @code{include} for its headers, etc.), and the path of this package in
3146 the store.
3147
3148 @item --list-available[=@var{regexp}]
3149 @itemx -A [@var{regexp}]
3150 List packages currently available in the distribution for this system
3151 (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
3152 available packages whose name matches @var{regexp}.
3153
3154 For each package, print the following items separated by tabs: its name,
3155 its version string, the parts of the package (@pxref{Packages with
3156 Multiple Outputs}), and the source location of its definition.
3157
3158 @item --list-generations[=@var{pattern}]
3159 @itemx -l [@var{pattern}]
3160 @cindex generations
3161 Return a list of generations along with their creation dates; for each
3162 generation, show the installed packages, with the most recently
3163 installed packages shown last. Note that the zeroth generation is never
3164 shown.
3165
3166 For each installed package, print the following items, separated by
3167 tabs: the name of a package, its version string, the part of the package
3168 that is installed (@pxref{Packages with Multiple Outputs}), and the
3169 location of this package in the store.
3170
3171 When @var{pattern} is used, the command returns only matching
3172 generations. Valid patterns include:
3173
3174 @itemize
3175 @item @emph{Integers and comma-separated integers}. Both patterns denote
3176 generation numbers. For instance, @option{--list-generations=1} returns
3177 the first one.
3178
3179 And @option{--list-generations=1,8,2} outputs three generations in the
3180 specified order. Neither spaces nor trailing commas are allowed.
3181
3182 @item @emph{Ranges}. @option{--list-generations=2..9} prints the
3183 specified generations and everything in between. Note that the start of
3184 a range must be smaller than its end.
3185
3186 It is also possible to omit the endpoint. For example,
3187 @option{--list-generations=2..}, returns all generations starting from the
3188 second one.
3189
3190 @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
3191 or months by passing an integer along with the first letter of the
3192 duration. For example, @option{--list-generations=20d} lists generations
3193 that are up to 20 days old.
3194 @end itemize
3195
3196 @item --delete-generations[=@var{pattern}]
3197 @itemx -d [@var{pattern}]
3198 When @var{pattern} is omitted, delete all generations except the current
3199 one.
3200
3201 This command accepts the same patterns as @option{--list-generations}.
3202 When @var{pattern} is specified, delete the matching generations. When
3203 @var{pattern} specifies a duration, generations @emph{older} than the
3204 specified duration match. For instance, @option{--delete-generations=1m}
3205 deletes generations that are more than one month old.
3206
3207 If the current generation matches, it is @emph{not} deleted. Also, the
3208 zeroth generation is never deleted.
3209
3210 Note that deleting generations prevents rolling back to them.
3211 Consequently, this command must be used with care.
3212
3213 @end table
3214
3215 Finally, since @command{guix package} may actually start build
3216 processes, it supports all the common build options (@pxref{Common Build
3217 Options}). It also supports package transformation options, such as
3218 @option{--with-source} (@pxref{Package Transformation Options}).
3219 However, note that package transformations are lost when upgrading; to
3220 preserve transformations across upgrades, you should define your own
3221 package variant in a Guile module and add it to @env{GUIX_PACKAGE_PATH}
3222 (@pxref{Defining Packages}).
3223
3224 @node Substitutes
3225 @section Substitutes
3226
3227 @cindex substitutes
3228 @cindex pre-built binaries
3229 Guix supports transparent source/binary deployment, which means that it
3230 can either build things locally, or download pre-built items from a
3231 server, or both. We call these pre-built items @dfn{substitutes}---they
3232 are substitutes for local build results. In many cases, downloading a
3233 substitute is much faster than building things locally.
3234
3235 Substitutes can be anything resulting from a derivation build
3236 (@pxref{Derivations}). Of course, in the common case, they are
3237 pre-built package binaries, but source tarballs, for instance, which
3238 also result from derivation builds, can be available as substitutes.
3239
3240 @menu
3241 * Official Substitute Server:: One particular source of substitutes.
3242 * Substitute Server Authorization:: How to enable or disable substitutes.
3243 * Substitute Authentication:: How Guix verifies substitutes.
3244 * Proxy Settings:: How to get substitutes via proxy.
3245 * Substitution Failure:: What happens when substitution fails.
3246 * On Trusting Binaries:: How can you trust that binary blob?
3247 @end menu
3248
3249 @node Official Substitute Server
3250 @subsection Official Substitute Server
3251
3252 @cindex build farm
3253 The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
3254 that builds packages from Guix continuously for some
3255 architectures, and makes them available as substitutes. This is the
3256 default source of substitutes; it can be overridden by passing the
3257 @option{--substitute-urls} option either to @command{guix-daemon}
3258 (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
3259 or to client tools such as @command{guix package}
3260 (@pxref{client-substitute-urls,, client @option{--substitute-urls}
3261 option}).
3262
3263 Substitute URLs can be either HTTP or HTTPS.
3264 HTTPS is recommended because communications are encrypted; conversely,
3265 using HTTP makes all communications visible to an eavesdropper, who
3266 could use the information gathered to determine, for instance, whether
3267 your system has unpatched security vulnerabilities.
3268
3269 Substitutes from the official build farm are enabled by default when
3270 using Guix System (@pxref{GNU Distribution}). However,
3271 they are disabled by default when using Guix on a foreign distribution,
3272 unless you have explicitly enabled them via one of the recommended
3273 installation steps (@pxref{Installation}). The following paragraphs
3274 describe how to enable or disable substitutes for the official build
3275 farm; the same procedure can also be used to enable substitutes for any
3276 other substitute server.
3277
3278 @node Substitute Server Authorization
3279 @subsection Substitute Server Authorization
3280
3281 @cindex security
3282 @cindex substitutes, authorization thereof
3283 @cindex access control list (ACL), for substitutes
3284 @cindex ACL (access control list), for substitutes
3285 To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
3286 mirror thereof, you
3287 must add its public key to the access control list (ACL) of archive
3288 imports, using the @command{guix archive} command (@pxref{Invoking guix
3289 archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
3290 be compromised and to serve genuine substitutes.
3291
3292 The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
3293 @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
3294 the installation prefix of Guix. If you installed Guix from source,
3295 make sure you checked the GPG signature of
3296 @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
3297 Then, you can run something like this:
3298
3299 @example
3300 # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
3301 @end example
3302
3303 Once this is in place, the output of a command like @code{guix build}
3304 should change from something like:
3305
3306 @example
3307 $ guix build emacs --dry-run
3308 The following derivations would be built:
3309 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
3310 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
3311 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
3312 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
3313 @dots{}
3314 @end example
3315
3316 @noindent
3317 to something like:
3318
3319 @example
3320 $ guix build emacs --dry-run
3321 112.3 MB would be downloaded:
3322 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
3323 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
3324 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
3325 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
3326 @dots{}
3327 @end example
3328
3329 @noindent
3330 The text changed from ``The following derivations would be built'' to
3331 ``112.3 MB would be downloaded''. This indicates that substitutes from
3332 @code{@value{SUBSTITUTE-SERVER}} are usable and will be downloaded, when
3333 possible, for future builds.
3334
3335 @cindex substitutes, how to disable
3336 The substitute mechanism can be disabled globally by running
3337 @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
3338 guix-daemon}). It can also be disabled temporarily by passing the
3339 @option{--no-substitutes} option to @command{guix package},
3340 @command{guix build}, and other command-line tools.
3341
3342 @node Substitute Authentication
3343 @subsection Substitute Authentication
3344
3345 @cindex digital signatures
3346 Guix detects and raises an error when attempting to use a substitute
3347 that has been tampered with. Likewise, it ignores substitutes that are
3348 not signed, or that are not signed by one of the keys listed in the ACL.
3349
3350 There is one exception though: if an unauthorized server provides
3351 substitutes that are @emph{bit-for-bit identical} to those provided by
3352 an authorized server, then the unauthorized server becomes eligible for
3353 downloads. For example, assume we have chosen two substitute servers
3354 with this option:
3355
3356 @example
3357 --substitute-urls="https://a.example.org https://b.example.org"
3358 @end example
3359
3360 @noindent
3361 @cindex reproducible builds
3362 If the ACL contains only the key for @samp{b.example.org}, and if
3363 @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
3364 then Guix will download substitutes from @samp{a.example.org} because it
3365 comes first in the list and can be considered a mirror of
3366 @samp{b.example.org}. In practice, independent build machines usually
3367 produce the same binaries, thanks to bit-reproducible builds (see
3368 below).
3369
3370 When using HTTPS, the server's X.509 certificate is @emph{not} validated
3371 (in other words, the server is not authenticated), contrary to what
3372 HTTPS clients such as Web browsers usually do. This is because Guix
3373 authenticates substitute information itself, as explained above, which
3374 is what we care about (whereas X.509 certificates are about
3375 authenticating bindings between domain names and public keys.)
3376
3377 @node Proxy Settings
3378 @subsection Proxy Settings
3379
3380 @vindex http_proxy
3381 @vindex https_proxy
3382 Substitutes are downloaded over HTTP or HTTPS. The @env{http_proxy} and
3383 @env{https_proxy} environment variables can be set in the environment of
3384 @command{guix-daemon} and are honored for downloads of substitutes.
3385 Note that the value of those environment variables in the environment
3386 where @command{guix build}, @command{guix package}, and other client
3387 commands are run has @emph{absolutely no effect}.
3388
3389 @node Substitution Failure
3390 @subsection Substitution Failure
3391
3392 Even when a substitute for a derivation is available, sometimes the
3393 substitution attempt will fail. This can happen for a variety of
3394 reasons: the substitute server might be offline, the substitute may
3395 recently have been deleted, the connection might have been interrupted,
3396 etc.
3397
3398 When substitutes are enabled and a substitute for a derivation is
3399 available, but the substitution attempt fails, Guix will attempt to
3400 build the derivation locally depending on whether or not
3401 @option{--fallback} was given (@pxref{fallback-option,, common build
3402 option @option{--fallback}}). Specifically, if @option{--fallback} was
3403 omitted, then no local build will be performed, and the derivation is
3404 considered to have failed. However, if @option{--fallback} was given,
3405 then Guix will attempt to build the derivation locally, and the success
3406 or failure of the derivation depends on the success or failure of the
3407 local build. Note that when substitutes are disabled or no substitute
3408 is available for the derivation in question, a local build will
3409 @emph{always} be performed, regardless of whether or not
3410 @option{--fallback} was given.
3411
3412 To get an idea of how many substitutes are available right now, you can
3413 try running the @command{guix weather} command (@pxref{Invoking guix
3414 weather}). This command provides statistics on the substitutes provided
3415 by a server.
3416
3417 @node On Trusting Binaries
3418 @subsection On Trusting Binaries
3419
3420 @cindex trust, of pre-built binaries
3421 Today, each individual's control over their own computing is at the
3422 mercy of institutions, corporations, and groups with enough power and
3423 determination to subvert the computing infrastructure and exploit its
3424 weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
3425 convenient, we encourage users to also build on their own, or even run
3426 their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
3427 interesting target. One way to help is by publishing the software you
3428 build using @command{guix publish} so that others have one more choice
3429 of server to download substitutes from (@pxref{Invoking guix publish}).
3430
3431 Guix has the foundations to maximize build reproducibility
3432 (@pxref{Features}). In most cases, independent builds of a given
3433 package or derivation should yield bit-identical results. Thus, through
3434 a diverse set of independent package builds, we can strengthen the
3435 integrity of our systems. The @command{guix challenge} command aims to
3436 help users assess substitute servers, and to assist developers in
3437 finding out about non-deterministic package builds (@pxref{Invoking guix
3438 challenge}). Similarly, the @option{--check} option of @command{guix
3439 build} allows users to check whether previously-installed substitutes
3440 are genuine by rebuilding them locally (@pxref{build-check,
3441 @command{guix build --check}}).
3442
3443 In the future, we want Guix to have support to publish and retrieve
3444 binaries to/from other users, in a peer-to-peer fashion. If you would
3445 like to discuss this project, join us on @email{guix-devel@@gnu.org}.
3446
3447 @node Packages with Multiple Outputs
3448 @section Packages with Multiple Outputs
3449
3450 @cindex multiple-output packages
3451 @cindex package outputs
3452 @cindex outputs
3453
3454 Often, packages defined in Guix have a single @dfn{output}---i.e., the
3455 source package leads to exactly one directory in the store. When running
3456 @command{guix install glibc}, one installs the default output of the
3457 GNU libc package; the default output is called @code{out}, but its name
3458 can be omitted as shown in this command. In this particular case, the
3459 default output of @code{glibc} contains all the C header files, shared
3460 libraries, static libraries, Info documentation, and other supporting
3461 files.
3462
3463 Sometimes it is more appropriate to separate the various types of files
3464 produced from a single source package into separate outputs. For
3465 instance, the GLib C library (used by GTK+ and related packages)
3466 installs more than 20 MiB of reference documentation as HTML pages.
3467 To save space for users who do not need it, the documentation goes to a
3468 separate output, called @code{doc}. To install the main GLib output,
3469 which contains everything but the documentation, one would run:
3470
3471 @example
3472 guix install glib
3473 @end example
3474
3475 @cindex documentation
3476 The command to install its documentation is:
3477
3478 @example
3479 guix install glib:doc
3480 @end example
3481
3482 Some packages install programs with different ``dependency footprints''.
3483 For instance, the WordNet package installs both command-line tools and
3484 graphical user interfaces (GUIs). The former depend solely on the C
3485 library, whereas the latter depend on Tcl/Tk and the underlying X
3486 libraries. In this case, we leave the command-line tools in the default
3487 output, whereas the GUIs are in a separate output. This allows users
3488 who do not need the GUIs to save space. The @command{guix size} command
3489 can help find out about such situations (@pxref{Invoking guix size}).
3490 @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
3491
3492 There are several such multiple-output packages in the GNU distribution.
3493 Other conventional output names include @code{lib} for libraries and
3494 possibly header files, @code{bin} for stand-alone programs, and
3495 @code{debug} for debugging information (@pxref{Installing Debugging
3496 Files}). The outputs of a packages are listed in the third column of
3497 the output of @command{guix package --list-available} (@pxref{Invoking
3498 guix package}).
3499
3500
3501 @node Invoking guix gc
3502 @section Invoking @command{guix gc}
3503
3504 @cindex garbage collector
3505 @cindex disk space
3506 Packages that are installed, but not used, may be @dfn{garbage-collected}.
3507 The @command{guix gc} command allows users to explicitly run the garbage
3508 collector to reclaim space from the @file{/gnu/store} directory. It is
3509 the @emph{only} way to remove files from @file{/gnu/store}---removing
3510 files or directories manually may break it beyond repair!
3511
3512 @cindex GC roots
3513 @cindex garbage collector roots
3514 The garbage collector has a set of known @dfn{roots}: any file under
3515 @file{/gnu/store} reachable from a root is considered @dfn{live} and
3516 cannot be deleted; any other file is considered @dfn{dead} and may be
3517 deleted. The set of garbage collector roots (``GC roots'' for short)
3518 includes default user profiles; by default, the symlinks under
3519 @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
3520 added with @command{guix build --root}, for example (@pxref{Invoking
3521 guix build}). The @command{guix gc --list-roots} command lists them.
3522
3523 Prior to running @code{guix gc --collect-garbage} to make space, it is
3524 often useful to remove old generations from user profiles; that way, old
3525 package builds referenced by those generations can be reclaimed. This
3526 is achieved by running @code{guix package --delete-generations}
3527 (@pxref{Invoking guix package}).
3528
3529 Our recommendation is to run a garbage collection periodically, or when
3530 you are short on disk space. For instance, to guarantee that at least
3531 5@tie{}GB are available on your disk, simply run:
3532
3533 @example
3534 guix gc -F 5G
3535 @end example
3536
3537 It is perfectly safe to run as a non-interactive periodic job
3538 (@pxref{Scheduled Job Execution}, for how to set up such a job).
3539 Running @command{guix gc} with no arguments will collect as
3540 much garbage as it can, but that is often inconvenient: you may find
3541 yourself having to rebuild or re-download software that is ``dead'' from
3542 the GC viewpoint but that is necessary to build other pieces of
3543 software---e.g., the compiler tool chain.
3544
3545 The @command{guix gc} command has three modes of operation: it can be
3546 used to garbage-collect any dead files (the default), to delete specific
3547 files (the @option{--delete} option), to print garbage-collector
3548 information, or for more advanced queries. The garbage collection
3549 options are as follows:
3550
3551 @table @code
3552 @item --collect-garbage[=@var{min}]
3553 @itemx -C [@var{min}]
3554 Collect garbage---i.e., unreachable @file{/gnu/store} files and
3555 sub-directories. This is the default operation when no option is
3556 specified.
3557
3558 When @var{min} is given, stop once @var{min} bytes have been collected.
3559 @var{min} may be a number of bytes, or it may include a unit as a
3560 suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
3561 (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
3562
3563 When @var{min} is omitted, collect all the garbage.
3564
3565 @item --free-space=@var{free}
3566 @itemx -F @var{free}
3567 Collect garbage until @var{free} space is available under
3568 @file{/gnu/store}, if possible; @var{free} denotes storage space, such
3569 as @code{500MiB}, as described above.
3570
3571 When @var{free} or more is already available in @file{/gnu/store}, do
3572 nothing and exit immediately.
3573
3574 @item --delete-generations[=@var{duration}]
3575 @itemx -d [@var{duration}]
3576 Before starting the garbage collection process, delete all the generations
3577 older than @var{duration}, for all the user profiles; when run as root, this
3578 applies to all the profiles @emph{of all the users}.
3579
3580 For example, this command deletes all the generations of all your profiles
3581 that are older than 2 months (except generations that are current), and then
3582 proceeds to free space until at least 10 GiB are available:
3583
3584 @example
3585 guix gc -d 2m -F 10G
3586 @end example
3587
3588 @item --delete
3589 @itemx -D
3590 Attempt to delete all the store files and directories specified as
3591 arguments. This fails if some of the files are not in the store, or if
3592 they are still live.
3593
3594 @item --list-failures
3595 List store items corresponding to cached build failures.
3596
3597 This prints nothing unless the daemon was started with
3598 @option{--cache-failures} (@pxref{Invoking guix-daemon,
3599 @option{--cache-failures}}).
3600
3601 @item --list-roots
3602 List the GC roots owned by the user; when run as root, list @emph{all} the GC
3603 roots.
3604
3605 @item --list-busy
3606 List store items in use by currently running processes. These store
3607 items are effectively considered GC roots: they cannot be deleted.
3608
3609 @item --clear-failures
3610 Remove the specified store items from the failed-build cache.
3611
3612 Again, this option only makes sense when the daemon is started with
3613 @option{--cache-failures}. Otherwise, it does nothing.
3614
3615 @item --list-dead
3616 Show the list of dead files and directories still present in the
3617 store---i.e., files and directories no longer reachable from any root.
3618
3619 @item --list-live
3620 Show the list of live store files and directories.
3621
3622 @end table
3623
3624 In addition, the references among existing store files can be queried:
3625
3626 @table @code
3627
3628 @item --references
3629 @itemx --referrers
3630 @cindex package dependencies
3631 List the references (respectively, the referrers) of store files given
3632 as arguments.
3633
3634 @item --requisites
3635 @itemx -R
3636 @cindex closure
3637 List the requisites of the store files passed as arguments. Requisites
3638 include the store files themselves, their references, and the references
3639 of these, recursively. In other words, the returned list is the
3640 @dfn{transitive closure} of the store files.
3641
3642 @xref{Invoking guix size}, for a tool to profile the size of the closure
3643 of an element. @xref{Invoking guix graph}, for a tool to visualize
3644 the graph of references.
3645
3646 @item --derivers
3647 @cindex derivation
3648 Return the derivation(s) leading to the given store items
3649 (@pxref{Derivations}).
3650
3651 For example, this command:
3652
3653 @example
3654 guix gc --derivers `guix package -I ^emacs$ | cut -f4`
3655 @end example
3656
3657 @noindent
3658 returns the @file{.drv} file(s) leading to the @code{emacs} package
3659 installed in your profile.
3660
3661 Note that there may be zero matching @file{.drv} files, for instance
3662 because these files have been garbage-collected. There can also be more
3663 than one matching @file{.drv} due to fixed-output derivations.
3664 @end table
3665
3666 Lastly, the following options allow you to check the integrity of the
3667 store and to control disk usage.
3668
3669 @table @option
3670
3671 @item --verify[=@var{options}]
3672 @cindex integrity, of the store
3673 @cindex integrity checking
3674 Verify the integrity of the store.
3675
3676 By default, make sure that all the store items marked as valid in the
3677 database of the daemon actually exist in @file{/gnu/store}.
3678
3679 When provided, @var{options} must be a comma-separated list containing one
3680 or more of @code{contents} and @code{repair}.
3681
3682 When passing @option{--verify=contents}, the daemon computes the
3683 content hash of each store item and compares it against its hash in the
3684 database. Hash mismatches are reported as data corruptions. Because it
3685 traverses @emph{all the files in the store}, this command can take a
3686 long time, especially on systems with a slow disk drive.
3687
3688 @cindex repairing the store
3689 @cindex corruption, recovering from
3690 Using @option{--verify=repair} or @option{--verify=contents,repair}
3691 causes the daemon to try to repair corrupt store items by fetching
3692 substitutes for them (@pxref{Substitutes}). Because repairing is not
3693 atomic, and thus potentially dangerous, it is available only to the
3694 system administrator. A lightweight alternative, when you know exactly
3695 which items in the store are corrupt, is @command{guix build --repair}
3696 (@pxref{Invoking guix build}).
3697
3698 @item --optimize
3699 @cindex deduplication
3700 Optimize the store by hard-linking identical files---this is
3701 @dfn{deduplication}.
3702
3703 The daemon performs deduplication after each successful build or archive
3704 import, unless it was started with @option{--disable-deduplication}
3705 (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
3706 this option is primarily useful when the daemon was running with
3707 @option{--disable-deduplication}.
3708
3709 @end table
3710
3711 @node Invoking guix pull
3712 @section Invoking @command{guix pull}
3713
3714 @cindex upgrading Guix
3715 @cindex updating Guix
3716 @cindex @command{guix pull}
3717 @cindex pull
3718 Packages are installed or upgraded to the latest version available in
3719 the distribution currently available on your local machine. To update
3720 that distribution, along with the Guix tools, you must run @command{guix
3721 pull}: the command downloads the latest Guix source code and package
3722 descriptions, and deploys it. Source code is downloaded from a
3723 @uref{https://git-scm.com, Git} repository, by default the official
3724 GNU@tie{}Guix repository, though this can be customized.
3725
3726 Specifically, @command{guix pull} downloads code from the @dfn{channels}
3727 (@pxref{Channels}) specified by one of the followings, in this order:
3728
3729 @enumerate
3730 @item
3731 the @option{--channels} option;
3732 @item
3733 the user's @file{~/.config/guix/channels.scm} file;
3734 @item
3735 the system-wide @file{/etc/guix/channels.scm} file;
3736 @item
3737 the built-in default channels specified in the @code{%default-channels}
3738 variable.
3739 @end enumerate
3740
3741 On completion, @command{guix package} will use packages and package
3742 versions from this just-retrieved copy of Guix. Not only that, but all
3743 the Guix commands and Scheme modules will also be taken from that latest
3744 version. New @command{guix} sub-commands added by the update also
3745 become available.
3746
3747 Any user can update their Guix copy using @command{guix pull}, and the
3748 effect is limited to the user who ran @command{guix pull}. For
3749 instance, when user @code{root} runs @command{guix pull}, this has no
3750 effect on the version of Guix that user @code{alice} sees, and vice
3751 versa.
3752
3753 The result of running @command{guix pull} is a @dfn{profile} available
3754 under @file{~/.config/guix/current} containing the latest Guix. Thus,
3755 make sure to add it to the beginning of your search path so that you use
3756 the latest version, and similarly for the Info manual
3757 (@pxref{Documentation}):
3758
3759 @example
3760 export PATH="$HOME/.config/guix/current/bin:$PATH"
3761 export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
3762 @end example
3763
3764 The @option{--list-generations} or @option{-l} option lists past generations
3765 produced by @command{guix pull}, along with details about their provenance:
3766
3767 @example
3768 $ guix pull -l
3769 Generation 1 Jun 10 2018 00:18:18
3770 guix 65956ad
3771 repository URL: https://git.savannah.gnu.org/git/guix.git
3772 branch: origin/master
3773 commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
3774
3775 Generation 2 Jun 11 2018 11:02:49
3776 guix e0cc7f6
3777 repository URL: https://git.savannah.gnu.org/git/guix.git
3778 branch: origin/master
3779 commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
3780 2 new packages: keepalived, libnfnetlink
3781 6 packages upgraded: emacs-nix-mode@@2.0.4,
3782 guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
3783 heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
3784
3785 Generation 3 Jun 13 2018 23:31:07 (current)
3786 guix 844cc1c
3787 repository URL: https://git.savannah.gnu.org/git/guix.git
3788 branch: origin/master
3789 commit: 844cc1c8f394f03b404c5bb3aee086922373490c
3790 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
3791 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
3792 @end example
3793
3794 @xref{Invoking guix describe, @command{guix describe}}, for other ways to
3795 describe the current status of Guix.
3796
3797 This @code{~/.config/guix/current} profile works exactly like the profiles
3798 created by @command{guix package} (@pxref{Invoking guix package}). That
3799 is, you can list generations, roll back to the previous
3800 generation---i.e., the previous Guix---and so on:
3801
3802 @example
3803 $ guix pull --roll-back
3804 switched from generation 3 to 2
3805 $ guix pull --delete-generations=1
3806 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
3807 @end example
3808
3809 You can also use @command{guix package} (@pxref{Invoking guix package})
3810 to manage the profile by naming it explicitly:
3811 @example
3812 $ guix package -p ~/.config/guix/current --roll-back
3813 switched from generation 3 to 2
3814 $ guix package -p ~/.config/guix/current --delete-generations=1
3815 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
3816 @end example
3817
3818 The @command{guix pull} command is usually invoked with no arguments,
3819 but it supports the following options:
3820
3821 @table @code
3822 @item --url=@var{url}
3823 @itemx --commit=@var{commit}
3824 @itemx --branch=@var{branch}
3825 Download code for the @code{guix} channel from the specified @var{url}, at the
3826 given @var{commit} (a valid Git commit ID represented as a hexadecimal
3827 string), or @var{branch}.
3828
3829 @cindex @file{channels.scm}, configuration file
3830 @cindex configuration file for channels
3831 These options are provided for convenience, but you can also specify your
3832 configuration in the @file{~/.config/guix/channels.scm} file or using the
3833 @option{--channels} option (see below).
3834
3835 @item --channels=@var{file}
3836 @itemx -C @var{file}
3837 Read the list of channels from @var{file} instead of
3838 @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
3839 @var{file} must contain Scheme code that
3840 evaluates to a list of channel objects. @xref{Channels}, for more
3841 information.
3842
3843 @cindex channel news
3844 @item --news
3845 @itemx -N
3846 Display the list of packages added or upgraded since the previous
3847 generation, as well as, occasionally, news written by channel authors
3848 for their users (@pxref{Channels, Writing Channel News}).
3849
3850 The package information is the same as displayed upon @command{guix
3851 pull} completion, but without ellipses; it is also similar to the output
3852 of @command{guix pull -l} for the last generation (see below).
3853
3854 @item --list-generations[=@var{pattern}]
3855 @itemx -l [@var{pattern}]
3856 List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
3857 is provided, the subset of generations that match @var{pattern}.
3858 The syntax of @var{pattern} is the same as with @code{guix package
3859 --list-generations} (@pxref{Invoking guix package}).
3860
3861 @item --roll-back
3862 @cindex rolling back
3863 @cindex undoing transactions
3864 @cindex transactions, undoing
3865 Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
3866 undo the last transaction.
3867
3868 @item --switch-generation=@var{pattern}
3869 @itemx -S @var{pattern}
3870 @cindex generations
3871 Switch to a particular generation defined by @var{pattern}.
3872
3873 @var{pattern} may be either a generation number or a number prefixed
3874 with ``+'' or ``-''. The latter means: move forward/backward by a
3875 specified number of generations. For example, if you want to return to
3876 the latest generation after @option{--roll-back}, use
3877 @option{--switch-generation=+1}.
3878
3879 @item --delete-generations[=@var{pattern}]
3880 @itemx -d [@var{pattern}]
3881 When @var{pattern} is omitted, delete all generations except the current
3882 one.
3883
3884 This command accepts the same patterns as @option{--list-generations}.
3885 When @var{pattern} is specified, delete the matching generations. When
3886 @var{pattern} specifies a duration, generations @emph{older} than the
3887 specified duration match. For instance, @option{--delete-generations=1m}
3888 deletes generations that are more than one month old.
3889
3890 If the current generation matches, it is @emph{not} deleted.
3891
3892 Note that deleting generations prevents rolling back to them.
3893 Consequently, this command must be used with care.
3894
3895 @xref{Invoking guix describe}, for a way to display information about the
3896 current generation only.
3897
3898 @item --profile=@var{profile}
3899 @itemx -p @var{profile}
3900 Use @var{profile} instead of @file{~/.config/guix/current}.
3901
3902 @item --dry-run
3903 @itemx -n
3904 Show which channel commit(s) would be used and what would be built or
3905 substituted but do not actually do it.
3906
3907 @item --system=@var{system}
3908 @itemx -s @var{system}
3909 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
3910 the system type of the build host.
3911
3912 @item --verbose
3913 Produce verbose output, writing build logs to the standard error output.
3914
3915 @item --bootstrap
3916 Use the bootstrap Guile to build the latest Guix. This option is only
3917 useful to Guix developers.
3918 @end table
3919
3920 The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
3921 repository and branch to pull from, as well as @emph{additional} repositories
3922 containing package modules that should be deployed. @xref{Channels}, for more
3923 information.
3924
3925 In addition, @command{guix pull} supports all the common build options
3926 (@pxref{Common Build Options}).
3927
3928 @node Channels
3929 @section Channels
3930
3931 @cindex channels
3932 @cindex @file{channels.scm}, configuration file
3933 @cindex configuration file for channels
3934 @cindex @command{guix pull}, configuration file
3935 @cindex configuration of @command{guix pull}
3936 Guix and its package collection are updated by running @command{guix pull}
3937 (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
3938 deploys Guix itself from the official GNU@tie{}Guix repository. This can be
3939 customized by defining @dfn{channels} in the
3940 @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
3941 of a Git repository to be deployed, and @command{guix pull} can be instructed
3942 to pull from one or more channels. In other words, channels can be used to
3943 @emph{customize} and to @emph{extend} Guix, as we will see below.
3944
3945 @subsection Using a Custom Guix Channel
3946
3947 The channel called @code{guix} specifies where Guix itself---its command-line
3948 tools as well as its package collection---should be downloaded. For instance,
3949 suppose you want to update from your own copy of the Guix repository at
3950 @code{example.org}, and specifically the @code{super-hacks} branch, you can
3951 write in @code{~/.config/guix/channels.scm} this specification:
3952
3953 @lisp
3954 ;; Tell 'guix pull' to use my own repo.
3955 (list (channel
3956 (name 'guix)
3957 (url "https://example.org/my-guix.git")
3958 (branch "super-hacks")))
3959 @end lisp
3960
3961 @noindent
3962 From there on, @command{guix pull} will fetch code from the @code{super-hacks}
3963 branch of the repository at @code{example.org}.
3964
3965 @subsection Specifying Additional Channels
3966
3967 @cindex extending the package collection (channels)
3968 @cindex personal packages (channels)
3969 @cindex channels, for personal packages
3970 You can also specify @emph{additional channels} to pull from. Let's say you
3971 have a bunch of custom package variants or personal packages that you think
3972 would make little sense to contribute to the Guix project, but would like to
3973 have these packages transparently available to you at the command line. You
3974 would first write modules containing those package definitions (@pxref{Package
3975 Modules}), maintain them in a Git repository, and then you and anyone else can
3976 use it as an additional channel to get packages from. Neat, no?
3977
3978 @c What follows stems from discussions at
3979 @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
3980 @c earlier discussions on guix-devel@gnu.org.
3981 @quotation Warning
3982 Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
3983 publish your personal channel to the world, we would like to share a few words
3984 of caution:
3985
3986 @itemize
3987 @item
3988 Before publishing a channel, please consider contributing your package
3989 definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
3990 to free software of all sorts, and packages in Guix proper are readily
3991 available to all Guix users and benefit from the project's quality assurance
3992 process.
3993
3994 @item
3995 When you maintain package definitions outside Guix, we, Guix developers,
3996 consider that @emph{the compatibility burden is on you}. Remember that
3997 package modules and package definitions are just Scheme code that uses various
3998 programming interfaces (APIs). We want to remain free to change these APIs to
3999 keep improving Guix, possibly in ways that break your channel. We never
4000 change APIs gratuitously, but we will @emph{not} commit to freezing APIs
4001 either.
4002
4003 @item
4004 Corollary: if you're using an external channel and that channel breaks, please
4005 @emph{report the issue to the channel authors}, not to the Guix project.
4006 @end itemize
4007
4008 You've been warned! Having said this, we believe external channels are a
4009 practical way to exert your freedom to augment Guix' package collection and to
4010 share your improvements, which are basic tenets of
4011 @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
4012 email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
4013 @end quotation
4014
4015 To use a channel, write @code{~/.config/guix/channels.scm} to instruct
4016 @command{guix pull} to pull from it @emph{in addition} to the default Guix
4017 channel(s):
4018
4019 @vindex %default-channels
4020 @lisp
4021 ;; Add my personal packages to those Guix provides.
4022 (cons (channel
4023 (name 'my-personal-packages)
4024 (url "https://example.org/personal-packages.git"))
4025 %default-channels)
4026 @end lisp
4027
4028 @noindent
4029 Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
4030 add a channel the list of channels that the variable @code{%default-channels}
4031 is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
4032 Manual}). With this file in place, @command{guix pull} builds not only Guix
4033 but also the package modules from your own repository. The result in
4034 @file{~/.config/guix/current} is the union of Guix with your own package
4035 modules:
4036
4037 @example
4038 $ guix pull --list-generations
4039 @dots{}
4040 Generation 19 Aug 27 2018 16:20:48
4041 guix d894ab8
4042 repository URL: https://git.savannah.gnu.org/git/guix.git
4043 branch: master
4044 commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
4045 my-personal-packages dd3df5e
4046 repository URL: https://example.org/personal-packages.git
4047 branch: master
4048 commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
4049 11 new packages: my-gimp, my-emacs-with-cool-features, @dots{}
4050 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
4051 @end example
4052
4053 @noindent
4054 The output of @command{guix pull} above shows that Generation@tie{}19 includes
4055 both Guix and packages from the @code{my-personal-packages} channel. Among
4056 the new and upgraded packages that are listed, some like @code{my-gimp} and
4057 @code{my-emacs-with-cool-features} might come from
4058 @code{my-personal-packages}, while others come from the Guix default channel.
4059
4060 To create a channel, create a Git repository containing your own package
4061 modules and make it available. The repository can contain anything, but a
4062 useful channel will contain Guile modules that export packages. Once you
4063 start using a channel, Guix will behave as if the root directory of that
4064 channel's Git repository has been added to the Guile load path (@pxref{Load
4065 Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
4066 contains a file at @file{my-packages/my-tools.scm} that defines a Guile
4067 module, then the module will be available under the name @code{(my-packages
4068 my-tools)}, and you will be able to use it like any other module
4069 (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
4070
4071 @cindex dependencies, channels
4072 @cindex meta-data, channels
4073 @subsection Declaring Channel Dependencies
4074
4075 Channel authors may decide to augment a package collection provided by other
4076 channels. They can declare their channel to be dependent on other channels in
4077 a meta-data file @file{.guix-channel}, which is to be placed in the root of
4078 the channel repository.
4079
4080 The meta-data file should contain a simple S-expression like this:
4081
4082 @lisp
4083 (channel
4084 (version 0)
4085 (dependencies
4086 (channel
4087 (name some-collection)
4088 (url "https://example.org/first-collection.git"))
4089 (channel
4090 (name some-other-collection)
4091 (url "https://example.org/second-collection.git")
4092 (branch "testing"))))
4093 @end lisp
4094
4095 In the above example this channel is declared to depend on two other channels,
4096 which will both be fetched automatically. The modules provided by the channel
4097 will be compiled in an environment where the modules of all these declared
4098 channels are available.
4099
4100 For the sake of reliability and maintainability, you should avoid dependencies
4101 on channels that you don't control, and you should aim to keep the number of
4102 dependencies to a minimum.
4103
4104 @cindex subdirectory, channels
4105 @subsection Package Modules in a Sub-directory
4106
4107 As a channel author, you may want to keep your channel modules in a
4108 sub-directory. If your modules are in the sub-directory @file{guix}, you must
4109 add a meta-data file @file{.guix-channel} that contains:
4110
4111 @lisp
4112 (channel
4113 (version 0)
4114 (directory "guix"))
4115 @end lisp
4116
4117 @cindex news, for channels
4118 @subsection Writing Channel News
4119
4120 Channel authors may occasionally want to communicate to their users
4121 information about important changes in the channel. You'd send them all
4122 an email, but that's not convenient.
4123
4124 Instead, channels can provide a @dfn{news file}; when the channel users
4125 run @command{guix pull}, that news file is automatically read and
4126 @command{guix pull --news} can display the announcements that correspond
4127 to the new commits that have been pulled, if any.
4128
4129 To do that, channel authors must first declare the name of the news file
4130 in their @file{.guix-channel} file:
4131
4132 @lisp
4133 (channel
4134 (version 0)
4135 (news-file "etc/news.txt"))
4136 @end lisp
4137
4138 The news file itself, @file{etc/news.txt} in this example, must look
4139 something like this:
4140
4141 @lisp
4142 (channel-news
4143 (version 0)
4144 (entry (tag "the-bug-fix")
4145 (title (en "Fixed terrible bug")
4146 (fr "Oh la la"))
4147 (body (en "@@emph@{Good news@}! It's fixed!")
4148 (eo "Certe ĝi pli bone funkcias nun!")))
4149 (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
4150 (title (en "Added a great package")
4151 (ca "Què vol dir guix?"))
4152 (body (en "Don't miss the @@code@{hello@} package!"))))
4153 @end lisp
4154
4155 The file consists of a list of @dfn{news entries}. Each entry is
4156 associated with a commit or tag: it describes changes made in this
4157 commit, possibly in preceding commits as well. Users see entries only
4158 the first time they obtain the commit the entry refers to.
4159
4160 The @code{title} field should be a one-line summary while @code{body}
4161 can be arbitrarily long, and both can contain Texinfo markup
4162 (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
4163 a list of language tag/message tuples, which allows @command{guix pull}
4164 to display news in the language that corresponds to the user's locale.
4165
4166 If you want to translate news using a gettext-based workflow, you can
4167 extract translatable strings with @command{xgettext} (@pxref{xgettext
4168 Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
4169 you write news entries in English first, the command below creates a PO
4170 file containing the strings to translate:
4171
4172 @example
4173 xgettext -o news.po -l scheme -ken etc/news.scm
4174 @end example
4175
4176 To sum up, yes, you could use your channel as a blog. But beware, this
4177 is @emph{not quite} what your users might expect.
4178
4179 @subsection Replicating Guix
4180
4181 @cindex pinning, channels
4182 @cindex replicating Guix
4183 @cindex reproducibility, of Guix
4184 The @command{guix pull --list-generations} output above shows precisely which
4185 commits were used to build this instance of Guix. We can thus replicate it,
4186 say, on another machine, by providing a channel specification in
4187 @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
4188
4189 @lisp
4190 ;; Deploy specific commits of my channels of interest.
4191 (list (channel
4192 (name 'guix)
4193 (url "https://git.savannah.gnu.org/git/guix.git")
4194 (commit "d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300"))
4195 (channel
4196 (name 'my-personal-packages)
4197 (url "https://example.org/personal-packages.git")
4198 (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
4199 @end lisp
4200
4201 The @command{guix describe --format=channels} command can even generate this
4202 list of channels directly (@pxref{Invoking guix describe}). The resulting
4203 file can be used with the -C options of @command{guix pull}
4204 (@pxref{Invoking guix pull}) or @command{guix time-machine}
4205 (@pxref{Invoking guix time-machine}).
4206
4207 At this point the two machines run the @emph{exact same Guix}, with access to
4208 the @emph{exact same packages}. The output of @command{guix build gimp} on
4209 one machine will be exactly the same, bit for bit, as the output of the same
4210 command on the other machine. It also means both machines have access to all
4211 the source code of Guix and, transitively, to all the source code of every
4212 package it defines.
4213
4214 This gives you super powers, allowing you to track the provenance of binary
4215 artifacts with very fine grain, and to reproduce software environments at
4216 will---some sort of ``meta reproducibility'' capabilities, if you will.
4217 @xref{Inferiors}, for another way to take advantage of these super powers.
4218
4219 @node Invoking guix time-machine
4220 @section Invoking @command{guix time-machine}
4221
4222 @cindex @command{guix time-machine}
4223 @cindex pinning, channels
4224 @cindex replicating Guix
4225 @cindex reproducibility, of Guix
4226
4227 The @command{guix time-machine} command provides access to other
4228 revisions of Guix, for example to install older versions of packages,
4229 or to reproduce a computation in an identical environment. The revision
4230 of Guix to be used is defined by a commit or by a channel
4231 description file created by @command{guix describe}
4232 (@pxref{Invoking guix describe}).
4233
4234 The general syntax is:
4235
4236 @example
4237 guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
4238 @end example
4239
4240 where @var{command} and @var{arg}@dots{} are passed unmodified to the
4241 @command{guix} command of the specified revision. The @var{options} that define
4242 this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
4243
4244 @table @code
4245 @item --url=@var{url}
4246 @itemx --commit=@var{commit}
4247 @itemx --branch=@var{branch}
4248 Use the @code{guix} channel from the specified @var{url}, at the
4249 given @var{commit} (a valid Git commit ID represented as a hexadecimal
4250 string), or @var{branch}.
4251
4252 @item --channels=@var{file}
4253 @itemx -C @var{file}
4254 Read the list of channels from @var{file}. @var{file} must contain
4255 Scheme code that evaluates to a list of channel objects.
4256 @xref{Channels} for more information.
4257 @end table
4258
4259 As for @command{guix pull}, the absence of any options means that the
4260 the latest commit on the master branch will be used. The command
4261
4262 @example
4263 guix time-machine -- build hello
4264 @end example
4265
4266 will thus build the package @code{hello} as defined in the master branch,
4267 which is in general a newer revision of Guix than you have installed.
4268 Time travel works in both directions!
4269
4270 Note that @command{guix time-machine} can trigger builds of channels and
4271 their dependencies, and these are controlled by the standard build
4272 options (@pxref{Common Build Options}).
4273
4274 @node Inferiors
4275 @section Inferiors
4276
4277 @c TODO: Remove this once we're more confident about API stability.
4278 @quotation Note
4279 The functionality described here is a ``technology preview'' as of version
4280 @value{VERSION}. As such, the interface is subject to change.
4281 @end quotation
4282
4283 @cindex inferiors
4284 @cindex composition of Guix revisions
4285 Sometimes you might need to mix packages from the revision of Guix you're
4286 currently running with packages available in a different revision of Guix.
4287 Guix @dfn{inferiors} allow you to achieve that by composing different Guix
4288 revisions in arbitrary ways.
4289
4290 @cindex inferior packages
4291 Technically, an ``inferior'' is essentially a separate Guix process connected
4292 to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
4293 @code{(guix inferior)} module allows you to create inferiors and to
4294 communicate with them. It also provides a high-level interface to browse and
4295 manipulate the packages that an inferior provides---@dfn{inferior packages}.
4296
4297 When combined with channels (@pxref{Channels}), inferiors provide a simple way
4298 to interact with a separate revision of Guix. For example, let's assume you
4299 want to install in your profile the current @code{guile} package, along with
4300 the @code{guile-json} as it existed in an older revision of Guix---perhaps
4301 because the newer @code{guile-json} has an incompatible API and you want to
4302 run your code against the old API@. To do that, you could write a manifest for
4303 use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
4304 manifest, you would create an inferior for that old Guix revision you care
4305 about, and you would look up the @code{guile-json} package in the inferior:
4306
4307 @lisp
4308 (use-modules (guix inferior) (guix channels)
4309 (srfi srfi-1)) ;for 'first'
4310
4311 (define channels
4312 ;; This is the old revision from which we want to
4313 ;; extract guile-json.
4314 (list (channel
4315 (name 'guix)
4316 (url "https://git.savannah.gnu.org/git/guix.git")
4317 (commit
4318 "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
4319
4320 (define inferior
4321 ;; An inferior representing the above revision.
4322 (inferior-for-channels channels))
4323
4324 ;; Now create a manifest with the current "guile" package
4325 ;; and the old "guile-json" package.
4326 (packages->manifest
4327 (list (first (lookup-inferior-packages inferior "guile-json"))
4328 (specification->package "guile")))
4329 @end lisp
4330
4331 On its first run, @command{guix package --manifest} might have to build the
4332 channel you specified before it can create the inferior; subsequent runs will
4333 be much faster because the Guix revision will be cached.
4334
4335 The @code{(guix inferior)} module provides the following procedures to open an
4336 inferior:
4337
4338 @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
4339 [#:cache-directory] [#:ttl]
4340 Return an inferior for @var{channels}, a list of channels. Use the cache at
4341 @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
4342 This procedure opens a new connection to the build daemon.
4343
4344 As a side effect, this procedure may build or substitute binaries for
4345 @var{channels}, which can take time.
4346 @end deffn
4347
4348 @deffn {Scheme Procedure} open-inferior @var{directory} @
4349 [#:command "bin/guix"]
4350 Open the inferior Guix in @var{directory}, running
4351 @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
4352 the inferior could not be launched.
4353 @end deffn
4354
4355 @cindex inferior packages
4356 The procedures listed below allow you to obtain and manipulate inferior
4357 packages.
4358
4359 @deffn {Scheme Procedure} inferior-packages @var{inferior}
4360 Return the list of packages known to @var{inferior}.
4361 @end deffn
4362
4363 @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
4364 [@var{version}]
4365 Return the sorted list of inferior packages matching @var{name} in
4366 @var{inferior}, with highest version numbers first. If @var{version} is true,
4367 return only packages with a version number prefixed by @var{version}.
4368 @end deffn
4369
4370 @deffn {Scheme Procedure} inferior-package? @var{obj}
4371 Return true if @var{obj} is an inferior package.
4372 @end deffn
4373
4374 @deffn {Scheme Procedure} inferior-package-name @var{package}
4375 @deffnx {Scheme Procedure} inferior-package-version @var{package}
4376 @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
4377 @deffnx {Scheme Procedure} inferior-package-description @var{package}
4378 @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
4379 @deffnx {Scheme Procedure} inferior-package-location @var{package}
4380 @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
4381 @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
4382 @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
4383 @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
4384 @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
4385 @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
4386 @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
4387 These procedures are the counterpart of package record accessors
4388 (@pxref{package Reference}). Most of them work by querying the inferior
4389 @var{package} comes from, so the inferior must still be live when you call
4390 these procedures.
4391 @end deffn
4392
4393 Inferior packages can be used transparently like any other package or
4394 file-like object in G-expressions (@pxref{G-Expressions}). They are also
4395 transparently handled by the @code{packages->manifest} procedure, which is
4396 commonly use in manifests (@pxref{Invoking guix package, the
4397 @option{--manifest} option of @command{guix package}}). Thus you can insert
4398 an inferior package pretty much anywhere you would insert a regular package:
4399 in manifests, in the @code{packages} field of your @code{operating-system}
4400 declaration, and so on.
4401
4402 @node Invoking guix describe
4403 @section Invoking @command{guix describe}
4404
4405 @cindex reproducibility
4406 @cindex replicating Guix
4407 Often you may want to answer questions like: ``Which revision of Guix am I
4408 using?'' or ``Which channels am I using?'' This is useful information in many
4409 situations: if you want to @emph{replicate} an environment on a different
4410 machine or user account, if you want to report a bug or to determine what
4411 change in the channels you are using caused it, or if you want to record your
4412 system state for reproducibility purposes. The @command{guix describe}
4413 command answers these questions.
4414
4415 When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
4416 displays the channel(s) that it was built from, including their repository URL
4417 and commit IDs (@pxref{Channels}):
4418
4419 @example
4420 $ guix describe
4421 Generation 10 Sep 03 2018 17:32:44 (current)
4422 guix e0fa68c
4423 repository URL: https://git.savannah.gnu.org/git/guix.git
4424 branch: master
4425 commit: e0fa68c7718fffd33d81af415279d6ddb518f727
4426 @end example
4427
4428 If you're familiar with the Git version control system, this is similar in
4429 spirit to @command{git describe}; the output is also similar to that of
4430 @command{guix pull --list-generations}, but limited to the current generation
4431 (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
4432 the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
4433 information is all it takes to describe the revision of Guix you're using, and
4434 also to replicate it.
4435
4436 To make it easier to replicate Guix, @command{guix describe} can also be asked
4437 to return a list of channels instead of the human-readable description above:
4438
4439 @example
4440 $ guix describe -f channels
4441 (list (channel
4442 (name 'guix)
4443 (url "https://git.savannah.gnu.org/git/guix.git")
4444 (commit
4445 "e0fa68c7718fffd33d81af415279d6ddb518f727")))
4446 @end example
4447
4448 @noindent
4449 You can save this to a file and feed it to @command{guix pull -C} on some
4450 other machine or at a later point in time, which will instantiate @emph{this
4451 exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
4452 From there on, since you're able to deploy the same revision of Guix, you can
4453 just as well @emph{replicate a complete software environment}. We humbly
4454 think that this is @emph{awesome}, and we hope you'll like it too!
4455
4456 The details of the options supported by @command{guix describe} are as
4457 follows:
4458
4459 @table @code
4460 @item --format=@var{format}
4461 @itemx -f @var{format}
4462 Produce output in the specified @var{format}, one of:
4463
4464 @table @code
4465 @item human
4466 produce human-readable output;
4467 @item channels
4468 produce a list of channel specifications that can be passed to @command{guix
4469 pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
4470 guix pull});
4471 @item json
4472 @cindex JSON
4473 produce a list of channel specifications in JSON format;
4474 @item recutils
4475 produce a list of channel specifications in Recutils format.
4476 @end table
4477
4478 @item --profile=@var{profile}
4479 @itemx -p @var{profile}
4480 Display information about @var{profile}.
4481 @end table
4482
4483 @node Invoking guix archive
4484 @section Invoking @command{guix archive}
4485
4486 @cindex @command{guix archive}
4487 @cindex archive
4488 The @command{guix archive} command allows users to @dfn{export} files
4489 from the store into a single archive, and to later @dfn{import} them on
4490 a machine that runs Guix.
4491 In particular, it allows store files to be transferred from one machine
4492 to the store on another machine.
4493
4494 @quotation Note
4495 If you're looking for a way to produce archives in a format suitable for
4496 tools other than Guix, @pxref{Invoking guix pack}.
4497 @end quotation
4498
4499 @cindex exporting store items
4500 To export store files as an archive to standard output, run:
4501
4502 @example
4503 guix archive --export @var{options} @var{specifications}...
4504 @end example
4505
4506 @var{specifications} may be either store file names or package
4507 specifications, as for @command{guix package} (@pxref{Invoking guix
4508 package}). For instance, the following command creates an archive
4509 containing the @code{gui} output of the @code{git} package and the main
4510 output of @code{emacs}:
4511
4512 @example
4513 guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
4514 @end example
4515
4516 If the specified packages are not built yet, @command{guix archive}
4517 automatically builds them. The build process may be controlled with the
4518 common build options (@pxref{Common Build Options}).
4519
4520 To transfer the @code{emacs} package to a machine connected over SSH,
4521 one would run:
4522
4523 @example
4524 guix archive --export -r emacs | ssh the-machine guix archive --import
4525 @end example
4526
4527 @noindent
4528 Similarly, a complete user profile may be transferred from one machine
4529 to another like this:
4530
4531 @example
4532 guix archive --export -r $(readlink -f ~/.guix-profile) | \
4533 ssh the-machine guix archive --import
4534 @end example
4535
4536 @noindent
4537 However, note that, in both examples, all of @code{emacs} and the
4538 profile as well as all of their dependencies are transferred (due to
4539 @option{-r}), regardless of what is already available in the store on
4540 the target machine. The @option{--missing} option can help figure out
4541 which items are missing from the target store. The @command{guix copy}
4542 command simplifies and optimizes this whole process, so this is probably
4543 what you should use in this case (@pxref{Invoking guix copy}).
4544
4545 @cindex nar, archive format
4546 @cindex normalized archive (nar)
4547 Archives are stored in the ``normalized archive'' or ``nar'' format, which is
4548 comparable in spirit to `tar', but with differences
4549 that make it more appropriate for our purposes. First, rather than
4550 recording all Unix metadata for each file, the nar format only mentions
4551 the file type (regular, directory, or symbolic link); Unix permissions
4552 and owner/group are dismissed. Second, the order in which directory
4553 entries are stored always follows the order of file names according to
4554 the C locale collation order. This makes archive production fully
4555 deterministic.
4556
4557 When exporting, the daemon digitally signs the contents of the archive,
4558 and that digital signature is appended. When importing, the daemon
4559 verifies the signature and rejects the import in case of an invalid
4560 signature or if the signing key is not authorized.
4561 @c FIXME: Add xref to daemon doc about signatures.
4562
4563 The main options are:
4564
4565 @table @code
4566 @item --export
4567 Export the specified store files or packages (see below.) Write the
4568 resulting archive to the standard output.
4569
4570 Dependencies are @emph{not} included in the output, unless
4571 @option{--recursive} is passed.
4572
4573 @item -r
4574 @itemx --recursive
4575 When combined with @option{--export}, this instructs @command{guix archive}
4576 to include dependencies of the given items in the archive. Thus, the
4577 resulting archive is self-contained: it contains the closure of the
4578 exported store items.
4579
4580 @item --import
4581 Read an archive from the standard input, and import the files listed
4582 therein into the store. Abort if the archive has an invalid digital
4583 signature, or if it is signed by a public key not among the authorized
4584 keys (see @option{--authorize} below.)
4585
4586 @item --missing
4587 Read a list of store file names from the standard input, one per line,
4588 and write on the standard output the subset of these files missing from
4589 the store.
4590
4591 @item --generate-key[=@var{parameters}]
4592 @cindex signing, archives
4593 Generate a new key pair for the daemon. This is a prerequisite before
4594 archives can be exported with @option{--export}. Note that this
4595 operation usually takes time, because it needs to gather enough entropy
4596 to generate the key pair.
4597
4598 The generated key pair is typically stored under @file{/etc/guix}, in
4599 @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
4600 key, which must be kept secret.) When @var{parameters} is omitted,
4601 an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
4602 versions before 1.6.0, it is a 4096-bit RSA key.
4603 Alternatively, @var{parameters} can specify
4604 @code{genkey} parameters suitable for Libgcrypt (@pxref{General
4605 public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
4606 Libgcrypt Reference Manual}).
4607
4608 @item --authorize
4609 @cindex authorizing, archives
4610 Authorize imports signed by the public key passed on standard input.
4611 The public key must be in ``s-expression advanced format''---i.e., the
4612 same format as the @file{signing-key.pub} file.
4613
4614 The list of authorized keys is kept in the human-editable file
4615 @file{/etc/guix/acl}. The file contains
4616 @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
4617 s-expressions''} and is structured as an access-control list in the
4618 @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
4619 (SPKI)}.
4620
4621 @item --extract=@var{directory}
4622 @itemx -x @var{directory}
4623 Read a single-item archive as served by substitute servers
4624 (@pxref{Substitutes}) and extract it to @var{directory}. This is a
4625 low-level operation needed in only very narrow use cases; see below.
4626
4627 For example, the following command extracts the substitute for Emacs
4628 served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
4629
4630 @example
4631 $ wget -O - \
4632 https://@value{SUBSTITUTE-SERVER}/nar/gzip/@dots{}-emacs-24.5 \
4633 | gunzip | guix archive -x /tmp/emacs
4634 @end example
4635
4636 Single-item archives are different from multiple-item archives produced
4637 by @command{guix archive --export}; they contain a single store item,
4638 and they do @emph{not} embed a signature. Thus this operation does
4639 @emph{no} signature verification and its output should be considered
4640 unsafe.
4641
4642 The primary purpose of this operation is to facilitate inspection of
4643 archive contents coming from possibly untrusted substitute servers
4644 (@pxref{Invoking guix challenge}).
4645
4646 @item --list
4647 @itemx -t
4648 Read a single-item archive as served by substitute servers
4649 (@pxref{Substitutes}) and print the list of files it contains, as in
4650 this example:
4651
4652 @example
4653 $ wget -O - \
4654 https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-emacs-26.3 \
4655 | lzip -d | guix archive -t
4656 @end example
4657
4658 @end table
4659
4660
4661 @c *********************************************************************
4662 @node Development
4663 @chapter Development
4664
4665 @cindex software development
4666 If you are a software developer, Guix provides tools that you should find
4667 helpful---independently of the language you're developing in. This is what
4668 this chapter is about.
4669
4670 The @command{guix environment} command provides a convenient way to set up
4671 @dfn{development environments} containing all the dependencies and tools
4672 necessary to work on the software package of your choice. The @command{guix
4673 pack} command allows you to create @dfn{application bundles} that can be
4674 easily distributed to users who do not run Guix.
4675
4676 @menu
4677 * Invoking guix environment:: Setting up development environments.
4678 * Invoking guix pack:: Creating software bundles.
4679 * Packages for C Development:: Working with C code with Guix.
4680 @end menu
4681
4682 @node Invoking guix environment
4683 @section Invoking @command{guix environment}
4684
4685 @cindex reproducible build environments
4686 @cindex development environments
4687 @cindex @command{guix environment}
4688 @cindex environment, package build environment
4689 The purpose of @command{guix environment} is to assist hackers in
4690 creating reproducible development environments without polluting their
4691 package profile. The @command{guix environment} tool takes one or more
4692 packages, builds all of their inputs, and creates a shell
4693 environment to use them.
4694
4695 The general syntax is:
4696
4697 @example
4698 guix environment @var{options} @var{package}@dots{}
4699 @end example
4700
4701 The following example spawns a new shell set up for the development of
4702 GNU@tie{}Guile:
4703
4704 @example
4705 guix environment guile
4706 @end example
4707
4708 If the needed dependencies are not built yet, @command{guix environment}
4709 automatically builds them. The environment of the new shell is an
4710 augmented version of the environment that @command{guix environment} was
4711 run in. It contains the necessary search paths for building the given
4712 package added to the existing environment variables. To create
4713 a ``pure'' environment, in which the original environment variables have
4714 been unset, use the @option{--pure} option@footnote{Users sometimes
4715 wrongfully augment environment variables such as @env{PATH} in their
4716 @file{~/.bashrc} file. As a consequence, when @command{guix
4717 environment} launches it, Bash may read @file{~/.bashrc}, thereby
4718 introducing ``impurities'' in these environment variables. It is an
4719 error to define such environment variables in @file{.bashrc}; instead,
4720 they should be defined in @file{.bash_profile}, which is sourced only by
4721 log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
4722 Manual}, for details on Bash start-up files.}.
4723
4724 @vindex GUIX_ENVIRONMENT
4725 @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
4726 variable in the shell it spawns; its value is the file name of the
4727 profile of this environment. This allows users to, say, define a
4728 specific prompt for development environments in their @file{.bashrc}
4729 (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
4730
4731 @example
4732 if [ -n "$GUIX_ENVIRONMENT" ]
4733 then
4734 export PS1="\u@@\h \w [dev]\$ "
4735 fi
4736 @end example
4737
4738 @noindent
4739 ...@: or to browse the profile:
4740
4741 @example
4742 $ ls "$GUIX_ENVIRONMENT/bin"
4743 @end example
4744
4745 Additionally, more than one package may be specified, in which case the
4746 union of the inputs for the given packages are used. For example, the
4747 command below spawns a shell where all of the dependencies of both Guile
4748 and Emacs are available:
4749
4750 @example
4751 guix environment guile emacs
4752 @end example
4753
4754 Sometimes an interactive shell session is not desired. An arbitrary
4755 command may be invoked by placing the @code{--} token to separate the
4756 command from the rest of the arguments:
4757
4758 @example
4759 guix environment guile -- make -j4
4760 @end example
4761
4762 In other situations, it is more convenient to specify the list of
4763 packages needed in the environment. For example, the following command
4764 runs @command{python} from an environment containing Python@tie{}2.7 and
4765 NumPy:
4766
4767 @example
4768 guix environment --ad-hoc python2-numpy python-2.7 -- python
4769 @end example
4770
4771 Furthermore, one might want the dependencies of a package and also some
4772 additional packages that are not build-time or runtime dependencies, but
4773 are useful when developing nonetheless. Because of this, the
4774 @option{--ad-hoc} flag is positional. Packages appearing before
4775 @option{--ad-hoc} are interpreted as packages whose dependencies will be
4776 added to the environment. Packages appearing after are interpreted as
4777 packages that will be added to the environment directly. For example,
4778 the following command creates a Guix development environment that
4779 additionally includes Git and strace:
4780
4781 @example
4782 guix environment --pure guix --ad-hoc git strace
4783 @end example
4784
4785 @cindex container
4786 Sometimes it is desirable to isolate the environment as much as
4787 possible, for maximal purity and reproducibility. In particular, when
4788 using Guix on a host distro that is not Guix System, it is desirable to
4789 prevent access to @file{/usr/bin} and other system-wide resources from
4790 the development environment. For example, the following command spawns
4791 a Guile REPL in a ``container'' where only the store and the current
4792 working directory are mounted:
4793
4794 @example
4795 guix environment --ad-hoc --container guile -- guile
4796 @end example
4797
4798 @quotation Note
4799 The @option{--container} option requires Linux-libre 3.19 or newer.
4800 @end quotation
4801
4802 @cindex certificates
4803 Another typical use case for containers is to run security-sensitive
4804 applications such as a web browser. To run Eolie, we must expose and
4805 share some files and directories; we include @code{nss-certs} and expose
4806 @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
4807 the @env{DISPLAY} environment variable since containerized graphical
4808 applications won't display without it.
4809
4810 @example
4811 guix environment --preserve='^DISPLAY$' --container --network \
4812 --expose=/etc/machine-id \
4813 --expose=/etc/ssl/certs/ \
4814 --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
4815 --ad-hoc eolie nss-certs dbus -- eolie
4816 @end example
4817
4818 The available options are summarized below.
4819
4820 @table @code
4821 @item --root=@var{file}
4822 @itemx -r @var{file}
4823 @cindex persistent environment
4824 @cindex garbage collector root, for environments
4825 Make @var{file} a symlink to the profile for this environment, and
4826 register it as a garbage collector root.
4827
4828 This is useful if you want to protect your environment from garbage
4829 collection, to make it ``persistent''.
4830
4831 When this option is omitted, the environment is protected from garbage
4832 collection only for the duration of the @command{guix environment}
4833 session. This means that next time you recreate the same environment,
4834 you could have to rebuild or re-download packages. @xref{Invoking guix
4835 gc}, for more on GC roots.
4836
4837 @item --expression=@var{expr}
4838 @itemx -e @var{expr}
4839 Create an environment for the package or list of packages that
4840 @var{expr} evaluates to.
4841
4842 For example, running:
4843
4844 @example
4845 guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
4846 @end example
4847
4848 starts a shell with the environment for this specific variant of the
4849 PETSc package.
4850
4851 Running:
4852
4853 @example
4854 guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
4855 @end example
4856
4857 starts a shell with all the base system packages available.
4858
4859 The above commands only use the default output of the given packages.
4860 To select other outputs, two element tuples can be specified:
4861
4862 @example
4863 guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
4864 @end example
4865
4866 @item --load=@var{file}
4867 @itemx -l @var{file}
4868 Create an environment for the package or list of packages that the code
4869 within @var{file} evaluates to.
4870
4871 As an example, @var{file} might contain a definition like this
4872 (@pxref{Defining Packages}):
4873
4874 @lisp
4875 @verbatiminclude environment-gdb.scm
4876 @end lisp
4877
4878 @item --manifest=@var{file}
4879 @itemx -m @var{file}
4880 Create an environment for the packages contained in the manifest object
4881 returned by the Scheme code in @var{file}. This option can be repeated
4882 several times, in which case the manifests are concatenated.
4883
4884 This is similar to the same-named option in @command{guix package}
4885 (@pxref{profile-manifest, @option{--manifest}}) and uses the same
4886 manifest files.
4887
4888 @item --ad-hoc
4889 Include all specified packages in the resulting environment, as if an
4890 @i{ad hoc} package were defined with them as inputs. This option is
4891 useful for quickly creating an environment without having to write a
4892 package expression to contain the desired inputs.
4893
4894 For instance, the command:
4895
4896 @example
4897 guix environment --ad-hoc guile guile-sdl -- guile
4898 @end example
4899
4900 runs @command{guile} in an environment where Guile and Guile-SDL are
4901 available.
4902
4903 Note that this example implicitly asks for the default output of
4904 @code{guile} and @code{guile-sdl}, but it is possible to ask for a
4905 specific output---e.g., @code{glib:bin} asks for the @code{bin} output
4906 of @code{glib} (@pxref{Packages with Multiple Outputs}).
4907
4908 This option may be composed with the default behavior of @command{guix
4909 environment}. Packages appearing before @option{--ad-hoc} are
4910 interpreted as packages whose dependencies will be added to the
4911 environment, the default behavior. Packages appearing after are
4912 interpreted as packages that will be added to the environment directly.
4913
4914 @item --pure
4915 Unset existing environment variables when building the new environment, except
4916 those specified with @option{--preserve} (see below.) This has the effect of
4917 creating an environment in which search paths only contain package inputs.
4918
4919 @item --preserve=@var{regexp}
4920 @itemx -E @var{regexp}
4921 When used alongside @option{--pure}, preserve the environment variables
4922 matching @var{regexp}---in other words, put them on a ``white list'' of
4923 environment variables that must be preserved. This option can be repeated
4924 several times.
4925
4926 @example
4927 guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
4928 -- mpirun @dots{}
4929 @end example
4930
4931 This example runs @command{mpirun} in a context where the only environment
4932 variables defined are @env{PATH}, environment variables whose name starts
4933 with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
4934 @env{USER}, etc.)
4935
4936 @item --search-paths
4937 Display the environment variable definitions that make up the
4938 environment.
4939
4940 @item --system=@var{system}
4941 @itemx -s @var{system}
4942 Attempt to build for @var{system}---e.g., @code{i686-linux}.
4943
4944 @item --container
4945 @itemx -C
4946 @cindex container
4947 Run @var{command} within an isolated container. The current working
4948 directory outside the container is mapped inside the container.
4949 Additionally, unless overridden with @option{--user}, a dummy home
4950 directory is created that matches the current user's home directory, and
4951 @file{/etc/passwd} is configured accordingly.
4952
4953 The spawned process runs as the current user outside the container. Inside
4954 the container, it has the same UID and GID as the current user, unless
4955 @option{--user} is passed (see below.)
4956
4957 @item --network
4958 @itemx -N
4959 For containers, share the network namespace with the host system.
4960 Containers created without this flag only have access to the loopback
4961 device.
4962
4963 @item --link-profile
4964 @itemx -P
4965 For containers, link the environment profile to @file{~/.guix-profile}
4966 within the container. This is equivalent to running the command
4967 @samp{ln -s $GUIX_ENVIRONMENT ~/.guix-profile} within the container.
4968 Linking will fail and abort the environment if the directory already
4969 exists, which will certainly be the case if @command{guix environment}
4970 was invoked in the user's home directory.
4971
4972 Certain packages are configured to look in @file{~/.guix-profile} for
4973 configuration files and data;@footnote{For example, the
4974 @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
4975 for additional fonts.} @option{--link-profile} allows these programs to
4976 behave as expected within the environment.
4977
4978 @item --user=@var{user}
4979 @itemx -u @var{user}
4980 For containers, use the username @var{user} in place of the current
4981 user. The generated @file{/etc/passwd} entry within the container will
4982 contain the name @var{user}, the home directory will be
4983 @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
4984 the UID and GID inside the container are 1000. @var{user}
4985 need not exist on the system.
4986
4987 Additionally, any shared or exposed path (see @option{--share} and
4988 @option{--expose} respectively) whose target is within the current user's
4989 home directory will be remapped relative to @file{/home/USER}; this
4990 includes the automatic mapping of the current working directory.
4991
4992 @example
4993 # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
4994 cd $HOME/wd
4995 guix environment --container --user=foo \
4996 --expose=$HOME/test \
4997 --expose=/tmp/target=$HOME/target
4998 @end example
4999
5000 While this will limit the leaking of user identity through home paths
5001 and each of the user fields, this is only one useful component of a
5002 broader privacy/anonymity solution---not one in and of itself.
5003
5004 @item --no-cwd
5005 For containers, the default behavior is to share the current working
5006 directory with the isolated container and immediately change to that
5007 directory within the container. If this is undesirable,
5008 @option{--no-cwd} will cause the current working directory to @emph{not}
5009 be automatically shared and will change to the user's home directory
5010 within the container instead. See also @option{--user}.
5011
5012 @item --expose=@var{source}[=@var{target}]
5013 @itemx --share=@var{source}[=@var{target}]
5014 For containers, @option{--expose} (resp. @option{--share}) exposes the
5015 file system @var{source} from the host system as the read-only
5016 (resp. writable) file system @var{target} within the container. If
5017 @var{target} is not specified, @var{source} is used as the target mount
5018 point in the container.
5019
5020 The example below spawns a Guile REPL in a container in which the user's
5021 home directory is accessible read-only via the @file{/exchange}
5022 directory:
5023
5024 @example
5025 guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
5026 @end example
5027
5028 @end table
5029
5030 @command{guix environment}
5031 also supports all of the common build options that @command{guix
5032 build} supports (@pxref{Common Build Options}) as well as package
5033 transformation options (@pxref{Package Transformation Options}).
5034
5035 @node Invoking guix pack
5036 @section Invoking @command{guix pack}
5037
5038 Occasionally you want to pass software to people who are not (yet!)
5039 lucky enough to be using Guix. You'd tell them to run @command{guix
5040 package -i @var{something}}, but that's not possible in this case. This
5041 is where @command{guix pack} comes in.
5042
5043 @quotation Note
5044 If you are looking for ways to exchange binaries among machines that
5045 already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
5046 publish}, and @ref{Invoking guix archive}.
5047 @end quotation
5048
5049 @cindex pack
5050 @cindex bundle
5051 @cindex application bundle
5052 @cindex software bundle
5053 The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
5054 @dfn{software bundle}: it creates a tarball or some other archive
5055 containing the binaries of the software you're interested in, and all
5056 its dependencies. The resulting archive can be used on any machine that
5057 does not have Guix, and people can run the exact same binaries as those
5058 you have with Guix. The pack itself is created in a bit-reproducible
5059 fashion, so anyone can verify that it really contains the build results
5060 that you pretend to be shipping.
5061
5062 For example, to create a bundle containing Guile, Emacs, Geiser, and all
5063 their dependencies, you can run:
5064
5065 @example
5066 $ guix pack guile emacs geiser
5067 @dots{}
5068 /gnu/store/@dots{}-pack.tar.gz
5069 @end example
5070
5071 The result here is a tarball containing a @file{/gnu/store} directory
5072 with all the relevant packages. The resulting tarball contains a
5073 @dfn{profile} with the three packages of interest; the profile is the
5074 same as would be created by @command{guix package -i}. It is this
5075 mechanism that is used to create Guix's own standalone binary tarball
5076 (@pxref{Binary Installation}).
5077
5078 Users of this pack would have to run
5079 @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
5080 find inconvenient. To work around it, you can create, say, a
5081 @file{/opt/gnu/bin} symlink to the profile:
5082
5083 @example
5084 guix pack -S /opt/gnu/bin=bin guile emacs geiser
5085 @end example
5086
5087 @noindent
5088 That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
5089
5090 @cindex relocatable binaries, with @command{guix pack}
5091 What if the recipient of your pack does not have root privileges on
5092 their machine, and thus cannot unpack it in the root file system? In
5093 that case, you will want to use the @option{--relocatable} option (see
5094 below). This option produces @dfn{relocatable binaries}, meaning they
5095 they can be placed anywhere in the file system hierarchy: in the example
5096 above, users can unpack your tarball in their home directory and
5097 directly run @file{./opt/gnu/bin/guile}.
5098
5099 @cindex Docker, build an image with guix pack
5100 Alternatively, you can produce a pack in the Docker image format using
5101 the following command:
5102
5103 @example
5104 guix pack -f docker -S /bin=bin guile guile-readline
5105 @end example
5106
5107 @noindent
5108 The result is a tarball that can be passed to the @command{docker load}
5109 command, followed by @code{docker run}:
5110
5111 @example
5112 docker load < @var{file}
5113 docker run -ti guile-guile-readline /bin/guile
5114 @end example
5115
5116 @noindent
5117 where @var{file} is the image returned by @var{guix pack}, and
5118 @code{guile-guile-readline} is its ``image tag''. See the
5119 @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
5120 documentation} for more information.
5121
5122 @cindex Singularity, build an image with guix pack
5123 @cindex SquashFS, build an image with guix pack
5124 Yet another option is to produce a SquashFS image with the following
5125 command:
5126
5127 @example
5128 guix pack -f squashfs bash guile emacs geiser
5129 @end example
5130
5131 @noindent
5132 The result is a SquashFS file system image that can either be mounted or
5133 directly be used as a file system container image with the
5134 @uref{https://www.sylabs.io/docs/, Singularity container execution
5135 environment}, using commands like @command{singularity shell} or
5136 @command{singularity exec}.
5137
5138 Several command-line options allow you to customize your pack:
5139
5140 @table @code
5141 @item --format=@var{format}
5142 @itemx -f @var{format}
5143 Produce a pack in the given @var{format}.
5144
5145 The available formats are:
5146
5147 @table @code
5148 @item tarball
5149 This is the default format. It produces a tarball containing all the
5150 specified binaries and symlinks.
5151
5152 @item docker
5153 This produces a tarball that follows the
5154 @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
5155 Docker Image Specification}. The ``repository name'' as it appears in
5156 the output of the @command{docker images} command is computed from
5157 package names passed on the command line or in the manifest file.
5158
5159 @item squashfs
5160 This produces a SquashFS image containing all the specified binaries and
5161 symlinks, as well as empty mount points for virtual file systems like
5162 procfs.
5163
5164 @quotation Note
5165 Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
5166 For that reason, @command{guix pack -f squashfs} always implies @code{-S
5167 /bin=bin}. Thus, your @command{guix pack} invocation must always start
5168 with something like:
5169
5170 @example
5171 guix pack -f squashfs bash @dots{}
5172 @end example
5173
5174 If you forget the @code{bash} (or similar) package, @command{singularity
5175 run} and @command{singularity exec} will fail with an unhelpful ``no
5176 such file or directory'' message.
5177 @end quotation
5178 @end table
5179
5180 @cindex relocatable binaries
5181 @item --relocatable
5182 @itemx -R
5183 Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
5184 anywhere in the file system hierarchy and run from there.
5185
5186 When this option is passed once, the resulting binaries require support for
5187 @dfn{user namespaces} in the kernel Linux; when passed
5188 @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
5189 PRoot support, can be thought of as the abbreviation of ``Really
5190 Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
5191 other techniques if user namespaces are unavailable, and essentially
5192 work anywhere---see below for the implications.
5193
5194 For example, if you create a pack containing Bash with:
5195
5196 @example
5197 guix pack -RR -S /mybin=bin bash
5198 @end example
5199
5200 @noindent
5201 ...@: you can copy that pack to a machine that lacks Guix, and from your
5202 home directory as a normal user, run:
5203
5204 @example
5205 tar xf pack.tar.gz
5206 ./mybin/sh
5207 @end example
5208
5209 @noindent
5210 In that shell, if you type @code{ls /gnu/store}, you'll notice that
5211 @file{/gnu/store} shows up and contains all the dependencies of
5212 @code{bash}, even though the machine actually lacks @file{/gnu/store}
5213 altogether! That is probably the simplest way to deploy Guix-built
5214 software on a non-Guix machine.
5215
5216 @quotation Note
5217 By default, relocatable binaries rely on the @dfn{user namespace} feature of
5218 the kernel Linux, which allows unprivileged users to mount or change root.
5219 Old versions of Linux did not support it, and some GNU/Linux distributions
5220 turn it off.
5221
5222 To produce relocatable binaries that work even in the absence of user
5223 namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
5224 case, binaries will try user namespace support and fall back to another
5225 @dfn{execution engine} if user namespaces are not supported. The
5226 following execution engines are supported:
5227
5228 @table @code
5229 @item default
5230 Try user namespaces and fall back to PRoot if user namespaces are not
5231 supported (see below).
5232
5233 @item userns
5234 Run the program through user namespaces and abort if they are not
5235 supported.
5236
5237 @item proot
5238 Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
5239 provides the necessary
5240 support for file system virtualization. It achieves that by using the
5241 @code{ptrace} system call on the running program. This approach has the
5242 advantage to work without requiring special kernel support, but it incurs
5243 run-time overhead every time a system call is made.
5244 @end table
5245
5246 @vindex GUIX_EXECUTION_ENGINE
5247 When running a wrapped program, you can explicitly request one of the
5248 execution engines listed above by setting the
5249 @code{GUIX_EXECUTION_ENGINE} environment variable accordingly.
5250 @end quotation
5251
5252 @cindex entry point, for Docker images
5253 @item --entry-point=@var{command}
5254 Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
5255 format supports it---currently @code{docker} and @code{squashfs} (Singularity)
5256 support it. @var{command} must be relative to the profile contained in the
5257 pack.
5258
5259 The entry point specifies the command that tools like @code{docker run} or
5260 @code{singularity run} automatically start by default. For example, you can
5261 do:
5262
5263 @example
5264 guix pack -f docker --entry-point=bin/guile guile
5265 @end example
5266
5267 The resulting pack can easily be loaded and @code{docker run} with no extra
5268 arguments will spawn @code{bin/guile}:
5269
5270 @example
5271 docker load -i pack.tar.gz
5272 docker run @var{image-id}
5273 @end example
5274
5275 @item --expression=@var{expr}
5276 @itemx -e @var{expr}
5277 Consider the package @var{expr} evaluates to.
5278
5279 This has the same purpose as the same-named option in @command{guix
5280 build} (@pxref{Additional Build Options, @option{--expression} in
5281 @command{guix build}}).
5282
5283 @item --manifest=@var{file}
5284 @itemx -m @var{file}
5285 Use the packages contained in the manifest object returned by the Scheme
5286 code in @var{file}. This option can be repeated several times, in which
5287 case the manifests are concatenated.
5288
5289 This has a similar purpose as the same-named option in @command{guix
5290 package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
5291 same manifest files. It allows you to define a collection of packages
5292 once and use it both for creating profiles and for creating archives
5293 for use on machines that do not have Guix installed. Note that you can
5294 specify @emph{either} a manifest file @emph{or} a list of packages,
5295 but not both.
5296
5297 @item --system=@var{system}
5298 @itemx -s @var{system}
5299 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
5300 the system type of the build host.
5301
5302 @item --target=@var{triplet}
5303 @cindex cross-compilation
5304 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
5305 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
5306 configuration triplets,, autoconf, Autoconf}).
5307
5308 @item --compression=@var{tool}
5309 @itemx -C @var{tool}
5310 Compress the resulting tarball using @var{tool}---one of @code{gzip},
5311 @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
5312
5313 @item --symlink=@var{spec}
5314 @itemx -S @var{spec}
5315 Add the symlinks specified by @var{spec} to the pack. This option can
5316 appear several times.
5317
5318 @var{spec} has the form @code{@var{source}=@var{target}}, where
5319 @var{source} is the symlink that will be created and @var{target} is the
5320 symlink target.
5321
5322 For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
5323 symlink pointing to the @file{bin} sub-directory of the profile.
5324
5325 @item --save-provenance
5326 Save provenance information for the packages passed on the command line.
5327 Provenance information includes the URL and commit of the channels in use
5328 (@pxref{Channels}).
5329
5330 Provenance information is saved in the
5331 @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
5332 usual package metadata---the name and version of each package, their
5333 propagated inputs, and so on. It is useful information to the recipient of
5334 the pack, who then knows how the pack was (supposedly) obtained.
5335
5336 This option is not enabled by default because, like timestamps, provenance
5337 information contributes nothing to the build process. In other words, there
5338 is an infinity of channel URLs and commit IDs that can lead to the same pack.
5339 Recording such ``silent'' metadata in the output thus potentially breaks the
5340 source-to-binary bitwise reproducibility property.
5341
5342 @item --root=@var{file}
5343 @itemx -r @var{file}
5344 @cindex garbage collector root, for packs
5345 Make @var{file} a symlink to the resulting pack, and register it as a garbage
5346 collector root.
5347
5348 @item --localstatedir
5349 @itemx --profile-name=@var{name}
5350 Include the ``local state directory'', @file{/var/guix}, in the resulting
5351 pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
5352 profile---by default @var{name} is @code{guix-profile}, which corresponds to
5353 @file{~root/.guix-profile}.
5354
5355 @file{/var/guix} contains the store database (@pxref{The Store}) as well
5356 as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
5357 the pack means that the store is ``complete'' and manageable by Guix;
5358 not providing it pack means that the store is ``dead'': items cannot be
5359 added to it or removed from it after extraction of the pack.
5360
5361 One use case for this is the Guix self-contained binary tarball
5362 (@pxref{Binary Installation}).
5363
5364 @item --derivation
5365 @itemx -d
5366 Print the name of the derivation that builds the pack.
5367
5368 @item --bootstrap
5369 Use the bootstrap binaries to build the pack. This option is only
5370 useful to Guix developers.
5371 @end table
5372
5373 In addition, @command{guix pack} supports all the common build options
5374 (@pxref{Common Build Options}) and all the package transformation
5375 options (@pxref{Package Transformation Options}).
5376
5377 @node Packages for C Development
5378 @section Packages for C Development
5379
5380 @cindex GCC
5381 @cindex ld-wrapper
5382 @cindex linker wrapper
5383 @cindex toolchain, for C development
5384
5385 If you need a complete toolchain for compiling and linking C or C++
5386 source code, use the @code{gcc-toolchain} package. This package
5387 provides a complete GCC toolchain for C/C++ development, including GCC
5388 itself, the GNU C Library (headers and binaries, plus debugging symbols
5389 in the @code{debug} output), Binutils, and a linker wrapper.
5390
5391 The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
5392 passed to the linker, add corresponding @code{-rpath} arguments, and
5393 invoke the actual linker with this new set of arguments. You can instruct the
5394 wrapper to refuse to link against libraries not in the store by setting the
5395 @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
5396
5397
5398
5399 @c *********************************************************************
5400 @node Programming Interface
5401 @chapter Programming Interface
5402
5403 GNU Guix provides several Scheme programming interfaces (APIs) to
5404 define, build, and query packages. The first interface allows users to
5405 write high-level package definitions. These definitions refer to
5406 familiar packaging concepts, such as the name and version of a package,
5407 its build system, and its dependencies. These definitions can then be
5408 turned into concrete build actions.
5409
5410 Build actions are performed by the Guix daemon, on behalf of users. In a
5411 standard setup, the daemon has write access to the store---the
5412 @file{/gnu/store} directory---whereas users do not. The recommended
5413 setup also has the daemon perform builds in chroots, under a specific
5414 build users, to minimize interference with the rest of the system.
5415
5416 @cindex derivation
5417 Lower-level APIs are available to interact with the daemon and the
5418 store. To instruct the daemon to perform a build action, users actually
5419 provide it with a @dfn{derivation}. A derivation is a low-level
5420 representation of the build actions to be taken, and the environment in
5421 which they should occur---derivations are to package definitions what
5422 assembly is to C programs. The term ``derivation'' comes from the fact
5423 that build results @emph{derive} from them.
5424
5425 This chapter describes all these APIs in turn, starting from high-level
5426 package definitions.
5427
5428 @menu
5429 * Package Modules:: Packages from the programmer's viewpoint.
5430 * Defining Packages:: Defining new packages.
5431 * Build Systems:: Specifying how packages are built.
5432 * The Store:: Manipulating the package store.
5433 * Derivations:: Low-level interface to package derivations.
5434 * The Store Monad:: Purely functional interface to the store.
5435 * G-Expressions:: Manipulating build expressions.
5436 * Invoking guix repl:: Fiddling with Guix interactively.
5437 @end menu
5438
5439 @node Package Modules
5440 @section Package Modules
5441
5442 From a programming viewpoint, the package definitions of the
5443 GNU distribution are provided by Guile modules in the @code{(gnu packages
5444 @dots{})} name space@footnote{Note that packages under the @code{(gnu
5445 packages @dots{})} module name space are not necessarily ``GNU
5446 packages''. This module naming scheme follows the usual Guile module
5447 naming convention: @code{gnu} means that these modules are distributed
5448 as part of the GNU system, and @code{packages} identifies modules that
5449 define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
5450 Reference Manual}). For instance, the @code{(gnu packages emacs)}
5451 module exports a variable named @code{emacs}, which is bound to a
5452 @code{<package>} object (@pxref{Defining Packages}).
5453
5454 The @code{(gnu packages @dots{})} module name space is
5455 automatically scanned for packages by the command-line tools. For
5456 instance, when running @code{guix install emacs}, all the @code{(gnu
5457 packages @dots{})} modules are scanned until one that exports a package
5458 object whose name is @code{emacs} is found. This package search
5459 facility is implemented in the @code{(gnu packages)} module.
5460
5461 @cindex customization, of packages
5462 @cindex package module search path
5463 Users can store package definitions in modules with different
5464 names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
5465 name and module name must match. For instance, the @code{(my-packages
5466 emacs)} module must be stored in a @file{my-packages/emacs.scm} file
5467 relative to the load path specified with @option{--load-path} or
5468 @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
5469 guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
5470 these package definitions visible to the user interfaces:
5471
5472 @enumerate
5473 @item
5474 By adding the directory containing your package modules to the search path
5475 with the @code{-L} flag of @command{guix package} and other commands
5476 (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
5477 environment variable described below.
5478
5479 @item
5480 By defining a @dfn{channel} and configuring @command{guix pull} so that it
5481 pulls from it. A channel is essentially a Git repository containing package
5482 modules. @xref{Channels}, for more information on how to define and use
5483 channels.
5484 @end enumerate
5485
5486 @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
5487
5488 @defvr {Environment Variable} GUIX_PACKAGE_PATH
5489 This is a colon-separated list of directories to search for additional
5490 package modules. Directories listed in this variable take precedence
5491 over the own modules of the distribution.
5492 @end defvr
5493
5494 The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
5495 each package is built based solely on other packages in the
5496 distribution. The root of this dependency graph is a small set of
5497 @dfn{bootstrap binaries}, provided by the @code{(gnu packages
5498 bootstrap)} module. For more information on bootstrapping,
5499 @pxref{Bootstrapping}.
5500
5501 @node Defining Packages
5502 @section Defining Packages
5503
5504 The high-level interface to package definitions is implemented in the
5505 @code{(guix packages)} and @code{(guix build-system)} modules. As an
5506 example, the package definition, or @dfn{recipe}, for the GNU Hello
5507 package looks like this:
5508
5509 @lisp
5510 (define-module (gnu packages hello)
5511 #:use-module (guix packages)
5512 #:use-module (guix download)
5513 #:use-module (guix build-system gnu)
5514 #:use-module (guix licenses)
5515 #:use-module (gnu packages gawk))
5516
5517 (define-public hello
5518 (package
5519 (name "hello")
5520 (version "2.10")
5521 (source (origin
5522 (method url-fetch)
5523 (uri (string-append "mirror://gnu/hello/hello-" version
5524 ".tar.gz"))
5525 (sha256
5526 (base32
5527 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
5528 (build-system gnu-build-system)
5529 (arguments '(#:configure-flags '("--enable-silent-rules")))
5530 (inputs `(("gawk" ,gawk)))
5531 (synopsis "Hello, GNU world: An example GNU package")
5532 (description "Guess what GNU Hello prints!")
5533 (home-page "https://www.gnu.org/software/hello/")
5534 (license gpl3+)))
5535 @end lisp
5536
5537 @noindent
5538 Without being a Scheme expert, the reader may have guessed the meaning
5539 of the various fields here. This expression binds the variable
5540 @code{hello} to a @code{<package>} object, which is essentially a record
5541 (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
5542 This package object can be inspected using procedures found in the
5543 @code{(guix packages)} module; for instance, @code{(package-name hello)}
5544 returns---surprise!---@code{"hello"}.
5545
5546 With luck, you may be able to import part or all of the definition of
5547 the package you are interested in from another repository, using the
5548 @code{guix import} command (@pxref{Invoking guix import}).
5549
5550 In the example above, @var{hello} is defined in a module of its own,
5551 @code{(gnu packages hello)}. Technically, this is not strictly
5552 necessary, but it is convenient to do so: all the packages defined in
5553 modules under @code{(gnu packages @dots{})} are automatically known to
5554 the command-line tools (@pxref{Package Modules}).
5555
5556 There are a few points worth noting in the above package definition:
5557
5558 @itemize
5559 @item
5560 The @code{source} field of the package is an @code{<origin>} object
5561 (@pxref{origin Reference}, for the complete reference).
5562 Here, the @code{url-fetch} method from @code{(guix download)} is used,
5563 meaning that the source is a file to be downloaded over FTP or HTTP.
5564
5565 The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
5566 the GNU mirrors defined in @code{(guix download)}.
5567
5568 The @code{sha256} field specifies the expected SHA256 hash of the file
5569 being downloaded. It is mandatory, and allows Guix to check the
5570 integrity of the file. The @code{(base32 @dots{})} form introduces the
5571 base32 representation of the hash. You can obtain this information with
5572 @code{guix download} (@pxref{Invoking guix download}) and @code{guix
5573 hash} (@pxref{Invoking guix hash}).
5574
5575 @cindex patches
5576 When needed, the @code{origin} form can also have a @code{patches} field
5577 listing patches to be applied, and a @code{snippet} field giving a
5578 Scheme expression to modify the source code.
5579
5580 @item
5581 @cindex GNU Build System
5582 The @code{build-system} field specifies the procedure to build the
5583 package (@pxref{Build Systems}). Here, @var{gnu-build-system}
5584 represents the familiar GNU Build System, where packages may be
5585 configured, built, and installed with the usual @code{./configure &&
5586 make && make check && make install} command sequence.
5587
5588 @item
5589 The @code{arguments} field specifies options for the build system
5590 (@pxref{Build Systems}). Here it is interpreted by
5591 @var{gnu-build-system} as a request run @file{configure} with the
5592 @option{--enable-silent-rules} flag.
5593
5594 @cindex quote
5595 @cindex quoting
5596 @findex '
5597 @findex quote
5598 What about these quote (@code{'}) characters? They are Scheme syntax to
5599 introduce a literal list; @code{'} is synonymous with @code{quote}.
5600 @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
5601 for details. Here the value of the @code{arguments} field is a list of
5602 arguments passed to the build system down the road, as with @code{apply}
5603 (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
5604 Manual}).
5605
5606 The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
5607 (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
5608 @code{#:configure-flags} is a keyword used to pass a keyword argument
5609 to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
5610 Reference Manual}).
5611
5612 @item
5613 The @code{inputs} field specifies inputs to the build process---i.e.,
5614 build-time or run-time dependencies of the package. Here, we define an
5615 input called @code{"gawk"} whose value is that of the @var{gawk}
5616 variable; @var{gawk} is itself bound to a @code{<package>} object.
5617
5618 @cindex backquote (quasiquote)
5619 @findex `
5620 @findex quasiquote
5621 @cindex comma (unquote)
5622 @findex ,
5623 @findex unquote
5624 @findex ,@@
5625 @findex unquote-splicing
5626 Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
5627 us to introduce a literal list in the @code{inputs} field, while
5628 @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
5629 value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
5630 Reference Manual}).
5631
5632 Note that GCC, Coreutils, Bash, and other essential tools do not need to
5633 be specified as inputs here. Instead, @var{gnu-build-system} takes care
5634 of ensuring that they are present (@pxref{Build Systems}).
5635
5636 However, any other dependencies need to be specified in the
5637 @code{inputs} field. Any dependency not specified here will simply be
5638 unavailable to the build process, possibly leading to a build failure.
5639 @end itemize
5640
5641 @xref{package Reference}, for a full description of possible fields.
5642
5643 Once a package definition is in place, the
5644 package may actually be built using the @code{guix build} command-line
5645 tool (@pxref{Invoking guix build}), troubleshooting any build failures
5646 you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
5647 package definition using the @command{guix edit} command
5648 (@pxref{Invoking guix edit}).
5649 @xref{Packaging Guidelines}, for
5650 more information on how to test package definitions, and
5651 @ref{Invoking guix lint}, for information on how to check a definition
5652 for style conformance.
5653 @vindex GUIX_PACKAGE_PATH
5654 Lastly, @pxref{Channels}, for information
5655 on how to extend the distribution by adding your own package definitions
5656 in a ``channel''.
5657
5658 Finally, updating the package definition to a new upstream version
5659 can be partly automated by the @command{guix refresh} command
5660 (@pxref{Invoking guix refresh}).
5661
5662 Behind the scenes, a derivation corresponding to the @code{<package>}
5663 object is first computed by the @code{package-derivation} procedure.
5664 That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
5665 The build actions it prescribes may then be realized by using the
5666 @code{build-derivations} procedure (@pxref{The Store}).
5667
5668 @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
5669 Return the @code{<derivation>} object of @var{package} for @var{system}
5670 (@pxref{Derivations}).
5671
5672 @var{package} must be a valid @code{<package>} object, and @var{system}
5673 must be a string denoting the target system type---e.g.,
5674 @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
5675 must be a connection to the daemon, which operates on the store
5676 (@pxref{The Store}).
5677 @end deffn
5678
5679 @noindent
5680 @cindex cross-compilation
5681 Similarly, it is possible to compute a derivation that cross-builds a
5682 package for some other system:
5683
5684 @deffn {Scheme Procedure} package-cross-derivation @var{store} @
5685 @var{package} @var{target} [@var{system}]
5686 Return the @code{<derivation>} object of @var{package} cross-built from
5687 @var{system} to @var{target}.
5688
5689 @var{target} must be a valid GNU triplet denoting the target hardware
5690 and operating system, such as @code{"mips64el-linux-gnu"}
5691 (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
5692 @end deffn
5693
5694 @cindex package transformations
5695 @cindex input rewriting
5696 @cindex dependency tree rewriting
5697 Packages can be manipulated in arbitrary ways. An example of a useful
5698 transformation is @dfn{input rewriting}, whereby the dependency tree of
5699 a package is rewritten by replacing specific inputs by others:
5700
5701 @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
5702 [@var{rewrite-name}]
5703 Return a procedure that, when passed a package, replaces its direct and
5704 indirect dependencies (but not its implicit inputs) according to
5705 @var{replacements}. @var{replacements} is a list of package pairs; the
5706 first element of each pair is the package to replace, and the second one
5707 is the replacement.
5708
5709 Optionally, @var{rewrite-name} is a one-argument procedure that takes
5710 the name of a package and returns its new name after rewrite.
5711 @end deffn
5712
5713 @noindent
5714 Consider this example:
5715
5716 @lisp
5717 (define libressl-instead-of-openssl
5718 ;; This is a procedure to replace OPENSSL by LIBRESSL,
5719 ;; recursively.
5720 (package-input-rewriting `((,openssl . ,libressl))))
5721
5722 (define git-with-libressl
5723 (libressl-instead-of-openssl git))
5724 @end lisp
5725
5726 @noindent
5727 Here we first define a rewriting procedure that replaces @var{openssl}
5728 with @var{libressl}. Then we use it to define a @dfn{variant} of the
5729 @var{git} package that uses @var{libressl} instead of @var{openssl}.
5730 This is exactly what the @option{--with-input} command-line option does
5731 (@pxref{Package Transformation Options, @option{--with-input}}).
5732
5733 The following variant of @code{package-input-rewriting} can match packages to
5734 be replaced by name rather than by identity.
5735
5736 @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements}
5737 Return a procedure that, given a package, applies the given @var{replacements} to
5738 all the package graph (excluding implicit inputs). @var{replacements} is a list of
5739 spec/procedures pair; each spec is a package specification such as @code{"gcc"} or
5740 @code{"guile@@2"}, and each procedure takes a matching package and returns a
5741 replacement for that package.
5742 @end deffn
5743
5744 The example above could be rewritten this way:
5745
5746 @lisp
5747 (define libressl-instead-of-openssl
5748 ;; Replace all the packages called "openssl" with LibreSSL.
5749 (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
5750 @end lisp
5751
5752 The key difference here is that, this time, packages are matched by spec and
5753 not by identity. In other words, any package in the graph that is called
5754 @code{openssl} will be replaced.
5755
5756 A more generic procedure to rewrite a package dependency graph is
5757 @code{package-mapping}: it supports arbitrary changes to nodes in the
5758 graph.
5759
5760 @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
5761 Return a procedure that, given a package, applies @var{proc} to all the packages
5762 depended on and returns the resulting package. The procedure stops recursion
5763 when @var{cut?} returns true for a given package.
5764 @end deffn
5765
5766 @menu
5767 * package Reference:: The package data type.
5768 * origin Reference:: The origin data type.
5769 @end menu
5770
5771
5772 @node package Reference
5773 @subsection @code{package} Reference
5774
5775 This section summarizes all the options available in @code{package}
5776 declarations (@pxref{Defining Packages}).
5777
5778 @deftp {Data Type} package
5779 This is the data type representing a package recipe.
5780
5781 @table @asis
5782 @item @code{name}
5783 The name of the package, as a string.
5784
5785 @item @code{version}
5786 The version of the package, as a string.
5787
5788 @item @code{source}
5789 An object telling how the source code for the package should be
5790 acquired. Most of the time, this is an @code{origin} object, which
5791 denotes a file fetched from the Internet (@pxref{origin Reference}). It
5792 can also be any other ``file-like'' object such as a @code{local-file},
5793 which denotes a file from the local file system (@pxref{G-Expressions,
5794 @code{local-file}}).
5795
5796 @item @code{build-system}
5797 The build system that should be used to build the package (@pxref{Build
5798 Systems}).
5799
5800 @item @code{arguments} (default: @code{'()})
5801 The arguments that should be passed to the build system. This is a
5802 list, typically containing sequential keyword-value pairs.
5803
5804 @item @code{inputs} (default: @code{'()})
5805 @itemx @code{native-inputs} (default: @code{'()})
5806 @itemx @code{propagated-inputs} (default: @code{'()})
5807 @cindex inputs, of packages
5808 These fields list dependencies of the package. Each one is a list of
5809 tuples, where each tuple has a label for the input (a string) as its
5810 first element, a package, origin, or derivation as its second element,
5811 and optionally the name of the output thereof that should be used, which
5812 defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
5813 more on package outputs). For example, the list below specifies three
5814 inputs:
5815
5816 @lisp
5817 `(("libffi" ,libffi)
5818 ("libunistring" ,libunistring)
5819 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
5820 @end lisp
5821
5822 @cindex cross compilation, package dependencies
5823 The distinction between @code{native-inputs} and @code{inputs} is
5824 necessary when considering cross-compilation. When cross-compiling,
5825 dependencies listed in @code{inputs} are built for the @emph{target}
5826 architecture; conversely, dependencies listed in @code{native-inputs}
5827 are built for the architecture of the @emph{build} machine.
5828
5829 @code{native-inputs} is typically used to list tools needed at
5830 build time, but not at run time, such as Autoconf, Automake, pkg-config,
5831 Gettext, or Bison. @command{guix lint} can report likely mistakes in
5832 this area (@pxref{Invoking guix lint}).
5833
5834 @anchor{package-propagated-inputs}
5835 Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
5836 specified packages will be automatically installed alongside the package
5837 they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
5838 package}}, for information on how @command{guix package} deals with
5839 propagated inputs.)
5840
5841 For example this is necessary when a C/C++ library needs headers of
5842 another library to compile, or when a pkg-config file refers to another
5843 one @i{via} its @code{Requires} field.
5844
5845 Another example where @code{propagated-inputs} is useful is for languages
5846 that lack a facility to record the run-time search path akin to the
5847 @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
5848 more. To ensure that libraries written in those languages can find
5849 library code they depend on at run time, run-time dependencies must be
5850 listed in @code{propagated-inputs} rather than @code{inputs}.
5851
5852 @item @code{outputs} (default: @code{'("out")})
5853 The list of output names of the package. @xref{Packages with Multiple
5854 Outputs}, for typical uses of additional outputs.
5855
5856 @item @code{native-search-paths} (default: @code{'()})
5857 @itemx @code{search-paths} (default: @code{'()})
5858 A list of @code{search-path-specification} objects describing
5859 search-path environment variables honored by the package.
5860
5861 @item @code{replacement} (default: @code{#f})
5862 This must be either @code{#f} or a package object that will be used as a
5863 @dfn{replacement} for this package. @xref{Security Updates, grafts},
5864 for details.
5865
5866 @item @code{synopsis}
5867 A one-line description of the package.
5868
5869 @item @code{description}
5870 A more elaborate description of the package.
5871
5872 @item @code{license}
5873 @cindex license, of packages
5874 The license of the package; a value from @code{(guix licenses)},
5875 or a list of such values.
5876
5877 @item @code{home-page}
5878 The URL to the home-page of the package, as a string.
5879
5880 @item @code{supported-systems} (default: @code{%supported-systems})
5881 The list of systems supported by the package, as strings of the form
5882 @code{architecture-kernel}, for example @code{"x86_64-linux"}.
5883
5884 @item @code{location} (default: source location of the @code{package} form)
5885 The source location of the package. It is useful to override this when
5886 inheriting from another package, in which case this field is not
5887 automatically corrected.
5888 @end table
5889 @end deftp
5890
5891 @deffn {Scheme Syntax} this-package
5892 When used in the @emph{lexical scope} of a package field definition, this
5893 identifier resolves to the package being defined.
5894
5895 The example below shows how to add a package as a native input of itself when
5896 cross-compiling:
5897
5898 @lisp
5899 (package
5900 (name "guile")
5901 ;; ...
5902
5903 ;; When cross-compiled, Guile, for example, depends on
5904 ;; a native version of itself. Add it here.
5905 (native-inputs (if (%current-target-system)
5906 `(("self" ,this-package))
5907 '())))
5908 @end lisp
5909
5910 It is an error to refer to @code{this-package} outside a package definition.
5911 @end deffn
5912
5913 @node origin Reference
5914 @subsection @code{origin} Reference
5915
5916 This section summarizes all the options available in @code{origin}
5917 declarations (@pxref{Defining Packages}).
5918
5919 @deftp {Data Type} origin
5920 This is the data type representing a source code origin.
5921
5922 @table @asis
5923 @item @code{uri}
5924 An object containing the URI of the source. The object type depends on
5925 the @code{method} (see below). For example, when using the
5926 @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
5927 values are: a URL represented as a string, or a list thereof.
5928
5929 @item @code{method}
5930 A procedure that handles the URI.
5931
5932 Examples include:
5933
5934 @table @asis
5935 @item @var{url-fetch} from @code{(guix download)}
5936 download a file from the HTTP, HTTPS, or FTP URL specified in the
5937 @code{uri} field;
5938
5939 @vindex git-fetch
5940 @item @var{git-fetch} from @code{(guix git-download)}
5941 clone the Git version control repository, and check out the revision
5942 specified in the @code{uri} field as a @code{git-reference} object; a
5943 @code{git-reference} looks like this:
5944
5945 @lisp
5946 (git-reference
5947 (url "https://git.savannah.gnu.org/git/hello.git")
5948 (commit "v2.10"))
5949 @end lisp
5950 @end table
5951
5952 @item @code{sha256}
5953 A bytevector containing the SHA-256 hash of the source. Typically the
5954 @code{base32} form is used here to generate the bytevector from a
5955 base-32 string.
5956
5957 You can obtain this information using @code{guix download}
5958 (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
5959 guix hash}).
5960
5961 @item @code{file-name} (default: @code{#f})
5962 The file name under which the source code should be saved. When this is
5963 @code{#f}, a sensible default value will be used in most cases. In case
5964 the source is fetched from a URL, the file name from the URL will be
5965 used. For version control checkouts, it is recommended to provide the
5966 file name explicitly because the default is not very descriptive.
5967
5968 @item @code{patches} (default: @code{'()})
5969 A list of file names, origins, or file-like objects (@pxref{G-Expressions,
5970 file-like objects}) pointing to patches to be applied to the source.
5971
5972 This list of patches must be unconditional. In particular, it cannot
5973 depend on the value of @code{%current-system} or
5974 @code{%current-target-system}.
5975
5976 @item @code{snippet} (default: @code{#f})
5977 A G-expression (@pxref{G-Expressions}) or S-expression that will be run
5978 in the source directory. This is a convenient way to modify the source,
5979 sometimes more convenient than a patch.
5980
5981 @item @code{patch-flags} (default: @code{'("-p1")})
5982 A list of command-line flags that should be passed to the @code{patch}
5983 command.
5984
5985 @item @code{patch-inputs} (default: @code{#f})
5986 Input packages or derivations to the patching process. When this is
5987 @code{#f}, the usual set of inputs necessary for patching are provided,
5988 such as GNU@tie{}Patch.
5989
5990 @item @code{modules} (default: @code{'()})
5991 A list of Guile modules that should be loaded during the patching
5992 process and while running the code in the @code{snippet} field.
5993
5994 @item @code{patch-guile} (default: @code{#f})
5995 The Guile package that should be used in the patching process. When
5996 this is @code{#f}, a sensible default is used.
5997 @end table
5998 @end deftp
5999
6000
6001 @node Build Systems
6002 @section Build Systems
6003
6004 @cindex build system
6005 Each package definition specifies a @dfn{build system} and arguments for
6006 that build system (@pxref{Defining Packages}). This @code{build-system}
6007 field represents the build procedure of the package, as well as implicit
6008 dependencies of that build procedure.
6009
6010 Build systems are @code{<build-system>} objects. The interface to
6011 create and manipulate them is provided by the @code{(guix build-system)}
6012 module, and actual build systems are exported by specific modules.
6013
6014 @cindex bag (low-level package representation)
6015 Under the hood, build systems first compile package objects to
6016 @dfn{bags}. A @dfn{bag} is like a package, but with less
6017 ornamentation---in other words, a bag is a lower-level representation of
6018 a package, which includes all the inputs of that package, including some
6019 that were implicitly added by the build system. This intermediate
6020 representation is then compiled to a derivation (@pxref{Derivations}).
6021
6022 Build systems accept an optional list of @dfn{arguments}. In package
6023 definitions, these are passed @i{via} the @code{arguments} field
6024 (@pxref{Defining Packages}). They are typically keyword arguments
6025 (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
6026 Guile Reference Manual}). The value of these arguments is usually
6027 evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
6028 by the daemon (@pxref{Derivations}).
6029
6030 The main build system is @code{gnu-build-system}, which implements the
6031 standard build procedure for GNU and many other packages. It
6032 is provided by the @code{(guix build-system gnu)} module.
6033
6034 @defvr {Scheme Variable} gnu-build-system
6035 @code{gnu-build-system} represents the GNU Build System, and variants
6036 thereof (@pxref{Configuration, configuration and makefile conventions,,
6037 standards, GNU Coding Standards}).
6038
6039 @cindex build phases
6040 In a nutshell, packages using it are configured, built, and installed with
6041 the usual @code{./configure && make && make check && make install}
6042 command sequence. In practice, a few additional steps are often needed.
6043 All these steps are split up in separate @dfn{phases},
6044 notably@footnote{Please see the @code{(guix build gnu-build-system)}
6045 modules for more details about the build phases.}:
6046
6047 @table @code
6048 @item unpack
6049 Unpack the source tarball, and change the current directory to the
6050 extracted source tree. If the source is actually a directory, copy it
6051 to the build tree, and enter that directory.
6052
6053 @item patch-source-shebangs
6054 Patch shebangs encountered in source files so they refer to the right
6055 store file names. For instance, this changes @code{#!/bin/sh} to
6056 @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
6057
6058 @item configure
6059 Run the @file{configure} script with a number of default options, such
6060 as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
6061 by the @code{#:configure-flags} argument.
6062
6063 @item build
6064 Run @code{make} with the list of flags specified with
6065 @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
6066 (the default), build with @code{make -j}.
6067
6068 @item check
6069 Run @code{make check}, or some other target specified with
6070 @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
6071 @code{#:parallel-tests?} argument is true (the default), run @code{make
6072 check -j}.
6073
6074 @item install
6075 Run @code{make install} with the flags listed in @code{#:make-flags}.
6076
6077 @item patch-shebangs
6078 Patch shebangs on the installed executable files.
6079
6080 @item strip
6081 Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
6082 is false), copying them to the @code{debug} output when available
6083 (@pxref{Installing Debugging Files}).
6084 @end table
6085
6086 @vindex %standard-phases
6087 The build-side module @code{(guix build gnu-build-system)} defines
6088 @code{%standard-phases} as the default list of build phases.
6089 @code{%standard-phases} is a list of symbol/procedure pairs, where the
6090 procedure implements the actual phase.
6091
6092 The list of phases used for a particular package can be changed with the
6093 @code{#:phases} parameter. For instance, passing:
6094
6095 @example
6096 #:phases (modify-phases %standard-phases (delete 'configure))
6097 @end example
6098
6099 means that all the phases described above will be used, except the
6100 @code{configure} phase.
6101
6102 In addition, this build system ensures that the ``standard'' environment
6103 for GNU packages is available. This includes tools such as GCC, libc,
6104 Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
6105 build-system gnu)} module for a complete list). We call these the
6106 @dfn{implicit inputs} of a package, because package definitions do not
6107 have to mention them.
6108 @end defvr
6109
6110 Other @code{<build-system>} objects are defined to support other
6111 conventions and tools used by free software packages. They inherit most
6112 of @code{gnu-build-system}, and differ mainly in the set of inputs
6113 implicitly added to the build process, and in the list of phases
6114 executed. Some of these build systems are listed below.
6115
6116 @defvr {Scheme Variable} ant-build-system
6117 This variable is exported by @code{(guix build-system ant)}. It
6118 implements the build procedure for Java packages that can be built with
6119 @url{https://ant.apache.org/, Ant build tool}.
6120
6121 It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
6122 provided by the @code{icedtea} package to the set of inputs. Different
6123 packages can be specified with the @code{#:ant} and @code{#:jdk}
6124 parameters, respectively.
6125
6126 When the original package does not provide a suitable Ant build file,
6127 the parameter @code{#:jar-name} can be used to generate a minimal Ant
6128 build file @file{build.xml} with tasks to build the specified jar
6129 archive. In this case the parameter @code{#:source-dir} can be used to
6130 specify the source sub-directory, defaulting to ``src''.
6131
6132 The @code{#:main-class} parameter can be used with the minimal ant
6133 buildfile to specify the main class of the resulting jar. This makes the
6134 jar file executable. The @code{#:test-include} parameter can be used to
6135 specify the list of junit tests to run. It defaults to
6136 @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
6137 disable some tests. It defaults to @code{(list "**/Abstract*.java")},
6138 because abstract classes cannot be run as tests.
6139
6140 The parameter @code{#:build-target} can be used to specify the Ant task
6141 that should be run during the @code{build} phase. By default the
6142 ``jar'' task will be run.
6143
6144 @end defvr
6145
6146 @defvr {Scheme Variable} android-ndk-build-system
6147 @cindex Android distribution
6148 @cindex Android NDK build system
6149 This variable is exported by @code{(guix build-system android-ndk)}. It
6150 implements a build procedure for Android NDK (native development kit)
6151 packages using a Guix-specific build process.
6152
6153 The build system assumes that packages install their public interface
6154 (header) files to the subdirectory @file{include} of the @code{out} output and
6155 their libraries to the subdirectory @file{lib} the @code{out} output.
6156
6157 It's also assumed that the union of all the dependencies of a package
6158 has no conflicting files.
6159
6160 For the time being, cross-compilation is not supported - so right now
6161 the libraries and header files are assumed to be host tools.
6162
6163 @end defvr
6164
6165 @defvr {Scheme Variable} asdf-build-system/source
6166 @defvrx {Scheme Variable} asdf-build-system/sbcl
6167 @defvrx {Scheme Variable} asdf-build-system/ecl
6168
6169 These variables, exported by @code{(guix build-system asdf)}, implement
6170 build procedures for Common Lisp packages using
6171 @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
6172 definition facility for Common Lisp programs and libraries.
6173
6174 The @code{asdf-build-system/source} system installs the packages in
6175 source form, and can be loaded using any common lisp implementation, via
6176 ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
6177 systems in the format which a particular implementation understands.
6178 These build systems can also be used to produce executable programs, or
6179 lisp images which contain a set of packages pre-loaded.
6180
6181 The build system uses naming conventions. For binary packages, the
6182 package name should be prefixed with the lisp implementation, such as
6183 @code{sbcl-} for @code{asdf-build-system/sbcl}.
6184
6185 Additionally, the corresponding source package should be labeled using
6186 the same convention as python packages (see @ref{Python Modules}), using
6187 the @code{cl-} prefix.
6188
6189 For binary packages, each system should be defined as a Guix package.
6190 If one package @code{origin} contains several systems, package variants
6191 can be created in order to build all the systems. Source packages,
6192 which use @code{asdf-build-system/source}, may contain several systems.
6193
6194 In order to create executable programs and images, the build-side
6195 procedures @code{build-program} and @code{build-image} can be used.
6196 They should be called in a build phase after the @code{create-symlinks}
6197 phase, so that the system which was just built can be used within the
6198 resulting image. @code{build-program} requires a list of Common Lisp
6199 expressions to be passed as the @code{#:entry-program} argument.
6200
6201 If the system is not defined within its own @file{.asd} file of the same
6202 name, then the @code{#:asd-file} parameter should be used to specify
6203 which file the system is defined in. Furthermore, if the package
6204 defines a system for its tests in a separate file, it will be loaded
6205 before the tests are run if it is specified by the
6206 @code{#:test-asd-file} parameter. If it is not set, the files
6207 @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
6208 and @code{test.asd} will be tried if they exist.
6209
6210 If for some reason the package must be named in a different way than the
6211 naming conventions suggest, the @code{#:asd-system-name} parameter can
6212 be used to specify the name of the system.
6213
6214 @end defvr
6215
6216 @defvr {Scheme Variable} cargo-build-system
6217 @cindex Rust programming language
6218 @cindex Cargo (Rust build system)
6219 This variable is exported by @code{(guix build-system cargo)}. It
6220 supports builds of packages using Cargo, the build tool of the
6221 @uref{https://www.rust-lang.org, Rust programming language}.
6222
6223 It adds @code{rustc} and @code{cargo} to the set of inputs.
6224 A different Rust package can be specified with the @code{#:rust} parameter.
6225
6226 Regular cargo dependencies should be added to the package definition via the
6227 @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
6228 spec can be a package or a source definition. Note that the spec must
6229 evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
6230 file at its root, or it will be ignored. Similarly, cargo dev-dependencies
6231 should be added to the package definition via the
6232 @code{#:cargo-development-inputs} parameter.
6233
6234 In its @code{configure} phase, this build system will make any source inputs
6235 specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
6236 parameters available to cargo. It will also remove an included
6237 @code{Cargo.lock} file to be recreated by @code{cargo} during the
6238 @code{build} phase. The @code{install} phase installs any crate the binaries
6239 if they are defined by the crate.
6240 @end defvr
6241
6242
6243 @defvr {Scheme Variable} copy-build-system
6244 This variable is exported by @code{(guix build-system copy)}. It
6245 supports builds of simple packages that don't require much compiling,
6246 mostly just moving files around.
6247
6248 It adds much of the @code{gnu-build-system} packages to the set of
6249 inputs. Because of this, the @code{copy-build-system} does not require
6250 all the boilerplate code often needed for the
6251 @code{trivial-build-system}.
6252
6253 To further simplify the file installation process, an
6254 @code{#:install-plan} argument is exposed to let the packager specify
6255 which files go where. The install plan is a list of @code{(@var{source}
6256 @var{target} [@var{filters}])}. @var{filters} are optional.
6257
6258 @itemize
6259 @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
6260 @itemize
6261 @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
6262 @item Otherwise install @var{source} as @var{target}.
6263 @end itemize
6264
6265 @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
6266 the trailing slash of @var{target} is implied with the same meaning
6267 as above.
6268 @itemize
6269 @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
6270 @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
6271 @code{#:exclude-regexp}, only select files are installed depending on
6272 the filters. Each filters is specified by a list of strings.
6273 @itemize
6274 @item With @code{#:include}, install all the files which the path suffix matches
6275 at least one of the elements in the given list.
6276 @item With @code{#:include-regexp}, install all the files which the
6277 subpaths match at least one of the regular expressions in the given
6278 list.
6279 @item The @code{#:exclude} and @code{#:exclude-regexp} filters
6280 are the complement of their inclusion counterpart. Without @code{#:include} flags,
6281 install all files but those matching the exclusion filters.
6282 If both inclusions and exclusions are specified, the exclusions are done
6283 on top of the inclusions.
6284 @end itemize
6285 @end itemize
6286 In all cases, the paths relative to @var{source} are preserved within
6287 @var{target}.
6288 @end itemize
6289
6290 Examples:
6291
6292 @itemize
6293 @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
6294 @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
6295 @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
6296 e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
6297 @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
6298 @file{share/my-app/sub/file}.
6299 @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
6300 @file{share/my-app/file}.
6301 @end itemize
6302 @end defvr
6303
6304
6305 @cindex Clojure (programming language)
6306 @cindex simple Clojure build system
6307 @defvr {Scheme Variable} clojure-build-system
6308 This variable is exported by @code{(guix build-system clojure)}. It implements
6309 a simple build procedure for @uref{https://clojure.org/, Clojure} packages
6310 using plain old @code{compile} in Clojure. Cross-compilation is not supported
6311 yet.
6312
6313 It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
6314 Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
6315 @code{#:zip} parameters, respectively.
6316
6317 A list of source directories, test directories and jar names can be specified
6318 with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
6319 parameters, respectively. Compile directory and main class can be specified
6320 with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
6321 Other parameters are documented below.
6322
6323 This build system is an extension of @code{ant-build-system}, but with the
6324 following phases changed:
6325
6326 @table @code
6327
6328 @item build
6329 This phase calls @code{compile} in Clojure to compile source files and runs
6330 @command{jar} to create jars from both source files and compiled files
6331 according to the include list and exclude list specified in
6332 @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
6333 has priority over the include list. These lists consist of symbols
6334 representing Clojure libraries or the special keyword @code{#:all} representing
6335 all Clojure libraries found under the source directories. The parameter
6336 @code{#:omit-source?} decides if source should be included into the jars.
6337
6338 @item check
6339 This phase runs tests according to the include list and exclude list specified
6340 in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
6341 meanings are analogous to that of @code{#:aot-include} and
6342 @code{#:aot-exclude}, except that the special keyword @code{#:all} now
6343 stands for all Clojure libraries found under the test directories. The
6344 parameter @code{#:tests?} decides if tests should be run.
6345
6346 @item install
6347 This phase installs all jars built previously.
6348 @end table
6349
6350 Apart from the above, this build system also contains an additional phase:
6351
6352 @table @code
6353
6354 @item install-doc
6355 This phase installs all top-level files with base name matching
6356 @code{%doc-regex}. A different regex can be specified with the
6357 @code{#:doc-regex} parameter. All files (recursively) inside the documentation
6358 directories specified in @code{#:doc-dirs} are installed as well.
6359 @end table
6360 @end defvr
6361
6362 @defvr {Scheme Variable} cmake-build-system
6363 This variable is exported by @code{(guix build-system cmake)}. It
6364 implements the build procedure for packages using the
6365 @url{https://www.cmake.org, CMake build tool}.
6366
6367 It automatically adds the @code{cmake} package to the set of inputs.
6368 Which package is used can be specified with the @code{#:cmake}
6369 parameter.
6370
6371 The @code{#:configure-flags} parameter is taken as a list of flags
6372 passed to the @command{cmake} command. The @code{#:build-type}
6373 parameter specifies in abstract terms the flags passed to the compiler;
6374 it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
6375 debugging information''), which roughly means that code is compiled with
6376 @code{-O2 -g}, as is the case for Autoconf-based packages by default.
6377 @end defvr
6378
6379 @defvr {Scheme Variable} dune-build-system
6380 This variable is exported by @code{(guix build-system dune)}. It
6381 supports builds of packages using @uref{https://dune.build/, Dune}, a build
6382 tool for the OCaml programming language. It is implemented as an extension
6383 of the @code{ocaml-build-system} which is described below. As such, the
6384 @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
6385 system.
6386
6387 It automatically adds the @code{dune} package to the set of inputs.
6388 Which package is used can be specified with the @code{#:dune}
6389 parameter.
6390
6391 There is no @code{configure} phase because dune packages typically don't
6392 need to be configured. The @code{#:build-flags} parameter is taken as a
6393 list of flags passed to the @code{dune} command during the build.
6394
6395 The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
6396 command instead of the more recent @code{dune} command while building
6397 a package. Its default value is @code{#f}.
6398
6399 The @code{#:package} parameter can be passed to specify a package name, which
6400 is useful when a package contains multiple packages and you want to build
6401 only one of them. This is equivalent to passing the @code{-p} argument to
6402 @code{dune}.
6403 @end defvr
6404
6405 @defvr {Scheme Variable} go-build-system
6406 This variable is exported by @code{(guix build-system go)}. It
6407 implements a build procedure for Go packages using the standard
6408 @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
6409 Go build mechanisms}.
6410
6411 The user is expected to provide a value for the key @code{#:import-path}
6412 and, in some cases, @code{#:unpack-path}. The
6413 @url{https://golang.org/doc/code.html#ImportPaths, import path}
6414 corresponds to the file system path expected by the package's build
6415 scripts and any referring packages, and provides a unique way to
6416 refer to a Go package. It is typically based on a combination of the
6417 package source code's remote URI and file system hierarchy structure. In
6418 some cases, you will need to unpack the package's source code to a
6419 different directory structure than the one indicated by the import path,
6420 and @code{#:unpack-path} should be used in such cases.
6421
6422 Packages that provide Go libraries should install their source code into
6423 the built output. The key @code{#:install-source?}, which defaults to
6424 @code{#t}, controls whether or not the source code is installed. It can
6425 be set to @code{#f} for packages that only provide executable files.
6426 @end defvr
6427
6428 @defvr {Scheme Variable} glib-or-gtk-build-system
6429 This variable is exported by @code{(guix build-system glib-or-gtk)}. It
6430 is intended for use with packages making use of GLib or GTK+.
6431
6432 This build system adds the following two phases to the ones defined by
6433 @code{gnu-build-system}:
6434
6435 @table @code
6436 @item glib-or-gtk-wrap
6437 The phase @code{glib-or-gtk-wrap} ensures that programs in
6438 @file{bin/} are able to find GLib ``schemas'' and
6439 @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
6440 modules}. This is achieved by wrapping the programs in launch scripts
6441 that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
6442 environment variables.
6443
6444 It is possible to exclude specific package outputs from that wrapping
6445 process by listing their names in the
6446 @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
6447 when an output is known not to contain any GLib or GTK+ binaries, and
6448 where wrapping would gratuitously add a dependency of that output on
6449 GLib and GTK+.
6450
6451 @item glib-or-gtk-compile-schemas
6452 The phase @code{glib-or-gtk-compile-schemas} makes sure that all
6453 @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
6454 GSettings schemas} of GLib are compiled. Compilation is performed by the
6455 @command{glib-compile-schemas} program. It is provided by the package
6456 @code{glib:bin} which is automatically imported by the build system.
6457 The @code{glib} package providing @command{glib-compile-schemas} can be
6458 specified with the @code{#:glib} parameter.
6459 @end table
6460
6461 Both phases are executed after the @code{install} phase.
6462 @end defvr
6463
6464 @defvr {Scheme Variable} guile-build-system
6465 This build system is for Guile packages that consist exclusively of Scheme
6466 code and that are so lean that they don't even have a makefile, let alone a
6467 @file{configure} script. It compiles Scheme code using @command{guild
6468 compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
6469 installs the @file{.scm} and @file{.go} files in the right place. It also
6470 installs documentation.
6471
6472 This build system supports cross-compilation by using the
6473 @option{--target} option of @samp{guild compile}.
6474
6475 Packages built with @code{guile-build-system} must provide a Guile package in
6476 their @code{native-inputs} field.
6477 @end defvr
6478
6479 @defvr {Scheme Variable} julia-build-system
6480 This variable is exported by @code{(guix build-system julia)}. It
6481 implements the build procedure used by @uref{https://julialang.org/,
6482 julia} packages, which essentially is similar to running @samp{julia -e
6483 'using Pkg; Pkg.add(package)'} in an environment where
6484 @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
6485 Tests are run not run.
6486
6487 Julia packages require the source @code{file-name} to be the real name of the
6488 package, correctly capitalized.
6489
6490 For packages requiring shared library dependencies, you may need to write the
6491 @file{/deps/deps.jl} file manually. It's usually a line of @code{const
6492 variable = /gnu/store/library.so} for each dependency, plus a void function
6493 @code{check_deps() = nothing}.
6494
6495 Some older packages that aren't using @file{Package.toml} yet, will require
6496 this file to be created, too. The function @code{julia-create-package-toml}
6497 helps creating the file. You need to pass the outputs and the source of the
6498 package, it's name (the same as the @code{file-name} parameter), the package
6499 uuid, the package version, and a list of dependencies specified by their name
6500 and their uuid.
6501 @end defvr
6502
6503 @defvr {Scheme Variable} minify-build-system
6504 This variable is exported by @code{(guix build-system minify)}. It
6505 implements a minification procedure for simple JavaScript packages.
6506
6507 It adds @code{uglify-js} to the set of inputs and uses it to compress
6508 all JavaScript files in the @file{src} directory. A different minifier
6509 package can be specified with the @code{#:uglify-js} parameter, but it
6510 is expected that the package writes the minified code to the standard
6511 output.
6512
6513 When the input JavaScript files are not all located in the @file{src}
6514 directory, the parameter @code{#:javascript-files} can be used to
6515 specify a list of file names to feed to the minifier.
6516 @end defvr
6517
6518 @defvr {Scheme Variable} ocaml-build-system
6519 This variable is exported by @code{(guix build-system ocaml)}. It implements
6520 a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
6521 of choosing the correct set of commands to run for each package. OCaml
6522 packages can expect many different commands to be run. This build system will
6523 try some of them.
6524
6525 When the package has a @file{setup.ml} file present at the top-level, it will
6526 run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
6527 @code{ocaml setup.ml -install}. The build system will assume that this file
6528 was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
6529 care of setting the prefix and enabling tests if they are not disabled. You
6530 can pass configure and build flags with the @code{#:configure-flags} and
6531 @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
6532 set of flags used to enable tests. The @code{#:use-make?} key can be used to
6533 bypass this system in the build and install phases.
6534
6535 When the package has a @file{configure} file, it is assumed that it is a
6536 hand-made configure script that requires a different argument format than
6537 in the @code{gnu-build-system}. You can add more flags with the
6538 @code{#:configure-flags} key.
6539
6540 When the package has a @file{Makefile} file (or @code{#:use-make?} is
6541 @code{#t}), it will be used and more flags can be passed to the build and
6542 install phases with the @code{#:make-flags} key.
6543
6544 Finally, some packages do not have these files and use a somewhat standard
6545 location for its build system. In that case, the build system will run
6546 @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
6547 providing the path to the required findlib module. Additional flags can
6548 be passed via the @code{#:build-flags} key. Install is taken care of by
6549 @command{opam-installer}. In this case, the @code{opam} package must
6550 be added to the @code{native-inputs} field of the package definition.
6551
6552 Note that most OCaml packages assume they will be installed in the same
6553 directory as OCaml, which is not what we want in guix. In particular, they
6554 will install @file{.so} files in their module's directory, which is usually
6555 fine because it is in the OCaml compiler directory. In guix though, these
6556 libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
6557 variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
6558 @file{.so} libraries should be installed.
6559 @end defvr
6560
6561 @defvr {Scheme Variable} python-build-system
6562 This variable is exported by @code{(guix build-system python)}. It
6563 implements the more or less standard build procedure used by Python
6564 packages, which consists in running @code{python setup.py build} and
6565 then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
6566
6567 For packages that install stand-alone Python programs under @code{bin/},
6568 it takes care of wrapping these programs so that their @env{PYTHONPATH}
6569 environment variable points to all the Python libraries they depend on.
6570
6571 Which Python package is used to perform the build can be specified with
6572 the @code{#:python} parameter. This is a useful way to force a package
6573 to be built for a specific version of the Python interpreter, which
6574 might be necessary if the package is only compatible with a single
6575 interpreter version.
6576
6577 By default guix calls @code{setup.py} under control of
6578 @code{setuptools}, much like @command{pip} does. Some packages are not
6579 compatible with setuptools (and pip), thus you can disable this by
6580 setting the @code{#:use-setuptools?} parameter to @code{#f}.
6581 @end defvr
6582
6583 @defvr {Scheme Variable} perl-build-system
6584 This variable is exported by @code{(guix build-system perl)}. It
6585 implements the standard build procedure for Perl packages, which either
6586 consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
6587 followed by @code{Build} and @code{Build install}; or in running
6588 @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
6589 @code{make} and @code{make install}, depending on which of
6590 @code{Build.PL} or @code{Makefile.PL} is present in the package
6591 distribution. Preference is given to the former if both @code{Build.PL}
6592 and @code{Makefile.PL} exist in the package distribution. This
6593 preference can be reversed by specifying @code{#t} for the
6594 @code{#:make-maker?} parameter.
6595
6596 The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
6597 passes flags specified by the @code{#:make-maker-flags} or
6598 @code{#:module-build-flags} parameter, respectively.
6599
6600 Which Perl package is used can be specified with @code{#:perl}.
6601 @end defvr
6602
6603 @defvr {Scheme Variable} qt-build-system
6604 This variable is exported by @code{(guix build-system qt)}. It
6605 is intended for use with applications using Qt or KDE.
6606
6607 This build system adds the following two phases to the ones defined by
6608 @code{cmake-build-system}:
6609
6610 @table @code
6611 @item check-setup
6612 The phase @code{check-setup} prepares the environment for running
6613 the checks as commonly used by Qt test programs.
6614 For now this only sets some environment variables:
6615 @code{QT_QPA_PLATFORM=offscreen},
6616 @code{DBUS_FATAL_WARNINGS=0} and
6617 @code{CTEST_OUTPUT_ON_FAILURE=1}.
6618
6619 This phase is added before the @code{check} phase.
6620 It's a separate phase to ease adjusting if necessary.
6621
6622 @item qt-wrap
6623 The phase @code{qt-wrap}
6624 searches for Qt5 plugin paths, QML paths and some XDG in the inputs
6625 and output. In case some path is found, all programs in the output's
6626 @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
6627 are wrapped in scripts defining the necessary environment variables.
6628
6629 It is possible to exclude specific package outputs from that wrapping process
6630 by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
6631 This is useful when an output is known not to contain any Qt binaries, and
6632 where wrapping would gratuitously add a dependency of that output on Qt, KDE,
6633 or such.
6634
6635 This phase is added after the @code{install} phase.
6636 @end table
6637 @end defvr
6638
6639 @defvr {Scheme Variable} r-build-system
6640 This variable is exported by @code{(guix build-system r)}. It
6641 implements the build procedure used by @uref{https://r-project.org, R}
6642 packages, which essentially is little more than running @samp{R CMD
6643 INSTALL --library=/gnu/store/@dots{}} in an environment where
6644 @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
6645 run after installation using the R function
6646 @code{tools::testInstalledPackage}.
6647 @end defvr
6648
6649 @defvr {Scheme Variable} rakudo-build-system
6650 This variable is exported by @code{(guix build-system rakudo)}. It
6651 implements the build procedure used by @uref{https://rakudo.org/,
6652 Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
6653 package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
6654 installs the binaries, library files and the resources, as well as wrap
6655 the files under the @code{bin/} directory. Tests can be skipped by
6656 passing @code{#f} to the @code{tests?} parameter.
6657
6658 Which rakudo package is used can be specified with @code{rakudo}.
6659 Which perl6-tap-harness package used for the tests can be specified with
6660 @code{#:prove6} or removed by passing @code{#f} to the
6661 @code{with-prove6?} parameter.
6662 Which perl6-zef package used for tests and installing can be specified
6663 with @code{#:zef} or removed by passing @code{#f} to the
6664 @code{with-zef?} parameter.
6665 @end defvr
6666
6667 @defvr {Scheme Variable} texlive-build-system
6668 This variable is exported by @code{(guix build-system texlive)}. It is
6669 used to build TeX packages in batch mode with a specified engine. The
6670 build system sets the @env{TEXINPUTS} variable to find all TeX source
6671 files in the inputs.
6672
6673 By default it runs @code{luatex} on all files ending on @code{ins}. A
6674 different engine and format can be specified with the
6675 @code{#:tex-format} argument. Different build targets can be specified
6676 with the @code{#:build-targets} argument, which expects a list of file
6677 names. The build system adds only @code{texlive-bin} and
6678 @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
6679 inputs. Both can be overridden with the arguments @code{#:texlive-bin}
6680 and @code{#:texlive-latex-base}, respectively.
6681
6682 The @code{#:tex-directory} parameter tells the build system where to
6683 install the built files under the texmf tree.
6684 @end defvr
6685
6686 @defvr {Scheme Variable} ruby-build-system
6687 This variable is exported by @code{(guix build-system ruby)}. It
6688 implements the RubyGems build procedure used by Ruby packages, which
6689 involves running @code{gem build} followed by @code{gem install}.
6690
6691 The @code{source} field of a package that uses this build system
6692 typically references a gem archive, since this is the format that Ruby
6693 developers use when releasing their software. The build system unpacks
6694 the gem archive, potentially patches the source, runs the test suite,
6695 repackages the gem, and installs it. Additionally, directories and
6696 tarballs may be referenced to allow building unreleased gems from Git or
6697 a traditional source release tarball.
6698
6699 Which Ruby package is used can be specified with the @code{#:ruby}
6700 parameter. A list of additional flags to be passed to the @command{gem}
6701 command can be specified with the @code{#:gem-flags} parameter.
6702 @end defvr
6703
6704 @defvr {Scheme Variable} waf-build-system
6705 This variable is exported by @code{(guix build-system waf)}. It
6706 implements a build procedure around the @code{waf} script. The common
6707 phases---@code{configure}, @code{build}, and @code{install}---are
6708 implemented by passing their names as arguments to the @code{waf}
6709 script.
6710
6711 The @code{waf} script is executed by the Python interpreter. Which
6712 Python package is used to run the script can be specified with the
6713 @code{#:python} parameter.
6714 @end defvr
6715
6716 @defvr {Scheme Variable} scons-build-system
6717 This variable is exported by @code{(guix build-system scons)}. It
6718 implements the build procedure used by the SCons software construction
6719 tool. This build system runs @code{scons} to build the package,
6720 @code{scons test} to run tests, and then @code{scons install} to install
6721 the package.
6722
6723 Additional flags to be passed to @code{scons} can be specified with the
6724 @code{#:scons-flags} parameter. The default build and install targets
6725 can be overridden with @code{#:build-targets} and
6726 @code{#:install-targets} respectively. The version of Python used to
6727 run SCons can be specified by selecting the appropriate SCons package
6728 with the @code{#:scons} parameter.
6729 @end defvr
6730
6731 @defvr {Scheme Variable} haskell-build-system
6732 This variable is exported by @code{(guix build-system haskell)}. It
6733 implements the Cabal build procedure used by Haskell packages, which
6734 involves running @code{runhaskell Setup.hs configure
6735 --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
6736 Instead of installing the package by running @code{runhaskell Setup.hs
6737 install}, to avoid trying to register libraries in the read-only
6738 compiler store directory, the build system uses @code{runhaskell
6739 Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
6740 addition, the build system generates the package documentation by
6741 running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
6742 is passed. Optional Haddock parameters can be passed with the help of
6743 the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
6744 not found, the build system looks for @code{Setup.lhs} instead.
6745
6746 Which Haskell compiler is used can be specified with the @code{#:haskell}
6747 parameter which defaults to @code{ghc}.
6748 @end defvr
6749
6750 @defvr {Scheme Variable} dub-build-system
6751 This variable is exported by @code{(guix build-system dub)}. It
6752 implements the Dub build procedure used by D packages, which
6753 involves running @code{dub build} and @code{dub run}.
6754 Installation is done by copying the files manually.
6755
6756 Which D compiler is used can be specified with the @code{#:ldc}
6757 parameter which defaults to @code{ldc}.
6758 @end defvr
6759
6760 @defvr {Scheme Variable} emacs-build-system
6761 This variable is exported by @code{(guix build-system emacs)}. It
6762 implements an installation procedure similar to the packaging system
6763 of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
6764
6765 It first creates the @code{@code{package}-autoloads.el} file, then it
6766 byte compiles all Emacs Lisp files. Differently from the Emacs
6767 packaging system, the Info documentation files are moved to the standard
6768 documentation directory and the @file{dir} file is deleted. The Elisp
6769 package files are installed directly under @file{share/emacs/site-lisp}.
6770 @end defvr
6771
6772 @defvr {Scheme Variable} font-build-system
6773 This variable is exported by @code{(guix build-system font)}. It
6774 implements an installation procedure for font packages where upstream
6775 provides pre-compiled TrueType, OpenType, etc.@: font files that merely
6776 need to be copied into place. It copies font files to standard
6777 locations in the output directory.
6778 @end defvr
6779
6780 @defvr {Scheme Variable} meson-build-system
6781 This variable is exported by @code{(guix build-system meson)}. It
6782 implements the build procedure for packages that use
6783 @url{https://mesonbuild.com, Meson} as their build system.
6784
6785 It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
6786 of inputs, and they can be changed with the parameters @code{#:meson}
6787 and @code{#:ninja} if needed. The default Meson is
6788 @code{meson-for-build}, which is special because it doesn't clear the
6789 @code{RUNPATH} of binaries and libraries when they are installed.
6790
6791 This build system is an extension of @code{gnu-build-system}, but with the
6792 following phases changed to some specific for Meson:
6793
6794 @table @code
6795
6796 @item configure
6797 The phase runs @code{meson} with the flags specified in
6798 @code{#:configure-flags}. The flag @option{--build-type} is always set to
6799 @code{plain} unless something else is specified in @code{#:build-type}.
6800
6801 @item build
6802 The phase runs @code{ninja} to build the package in parallel by default, but
6803 this can be changed with @code{#:parallel-build?}.
6804
6805 @item check
6806 The phase runs @code{ninja} with the target specified in @code{#:test-target},
6807 which is @code{"test"} by default.
6808
6809 @item install
6810 The phase runs @code{ninja install} and can not be changed.
6811 @end table
6812
6813 Apart from that, the build system also adds the following phases:
6814
6815 @table @code
6816
6817 @item fix-runpath
6818 This phase ensures that all binaries can find the libraries they need.
6819 It searches for required libraries in subdirectories of the package being
6820 built, and adds those to @code{RUNPATH} where needed. It also removes
6821 references to libraries left over from the build phase by
6822 @code{meson-for-build}, such as test dependencies, that aren't actually
6823 required for the program to run.
6824
6825 @item glib-or-gtk-wrap
6826 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
6827 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
6828
6829 @item glib-or-gtk-compile-schemas
6830 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
6831 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
6832 @end table
6833 @end defvr
6834
6835 @defvr {Scheme Variable} linux-module-build-system
6836 @code{linux-module-build-system} allows building Linux kernel modules.
6837
6838 @cindex build phases
6839 This build system is an extension of @code{gnu-build-system}, but with the
6840 following phases changed:
6841
6842 @table @code
6843
6844 @item configure
6845 This phase configures the environment so that the Linux kernel's Makefile
6846 can be used to build the external kernel module.
6847
6848 @item build
6849 This phase uses the Linux kernel's Makefile in order to build the external
6850 kernel module.
6851
6852 @item install
6853 This phase uses the Linux kernel's Makefile in order to install the external
6854 kernel module.
6855 @end table
6856
6857 It is possible and useful to specify the Linux kernel to use for building
6858 the module (in the @code{arguments} form of a package using the
6859 @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
6860 @end defvr
6861
6862 @defvr {Scheme Variable} node-build-system
6863 This variable is exported by @code{(guix build-system node)}. It
6864 implements the build procedure used by @uref{https://nodejs.org,
6865 Node.js}, which implements an approximation of the @code{npm install}
6866 command, followed by an @code{npm test} command.
6867
6868 Which Node.js package is used to interpret the @code{npm} commands can
6869 be specified with the @code{#:node} parameter which defaults to
6870 @code{node}.
6871 @end defvr
6872
6873 Lastly, for packages that do not need anything as sophisticated, a
6874 ``trivial'' build system is provided. It is trivial in the sense that
6875 it provides basically no support: it does not pull any implicit inputs,
6876 and does not have a notion of build phases.
6877
6878 @defvr {Scheme Variable} trivial-build-system
6879 This variable is exported by @code{(guix build-system trivial)}.
6880
6881 This build system requires a @code{#:builder} argument. This argument
6882 must be a Scheme expression that builds the package output(s)---as
6883 with @code{build-expression->derivation} (@pxref{Derivations,
6884 @code{build-expression->derivation}}).
6885 @end defvr
6886
6887 @node The Store
6888 @section The Store
6889
6890 @cindex store
6891 @cindex store items
6892 @cindex store paths
6893
6894 Conceptually, the @dfn{store} is the place where derivations that have
6895 been built successfully are stored---by default, @file{/gnu/store}.
6896 Sub-directories in the store are referred to as @dfn{store items} or
6897 sometimes @dfn{store paths}. The store has an associated database that
6898 contains information such as the store paths referred to by each store
6899 path, and the list of @emph{valid} store items---results of successful
6900 builds. This database resides in @file{@var{localstatedir}/guix/db},
6901 where @var{localstatedir} is the state directory specified @i{via}
6902 @option{--localstatedir} at configure time, usually @file{/var}.
6903
6904 The store is @emph{always} accessed by the daemon on behalf of its clients
6905 (@pxref{Invoking guix-daemon}). To manipulate the store, clients
6906 connect to the daemon over a Unix-domain socket, send requests to it,
6907 and read the result---these are remote procedure calls, or RPCs.
6908
6909 @quotation Note
6910 Users must @emph{never} modify files under @file{/gnu/store} directly.
6911 This would lead to inconsistencies and break the immutability
6912 assumptions of Guix's functional model (@pxref{Introduction}).
6913
6914 @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
6915 how to check the integrity of the store and attempt recovery from
6916 accidental modifications.
6917 @end quotation
6918
6919 The @code{(guix store)} module provides procedures to connect to the
6920 daemon, and to perform RPCs. These are described below. By default,
6921 @code{open-connection}, and thus all the @command{guix} commands,
6922 connect to the local daemon or to the URI specified by the
6923 @env{GUIX_DAEMON_SOCKET} environment variable.
6924
6925 @defvr {Environment Variable} GUIX_DAEMON_SOCKET
6926 When set, the value of this variable should be a file name or a URI
6927 designating the daemon endpoint. When it is a file name, it denotes a
6928 Unix-domain socket to connect to. In addition to file names, the
6929 supported URI schemes are:
6930
6931 @table @code
6932 @item file
6933 @itemx unix
6934 These are for Unix-domain sockets.
6935 @code{file:///var/guix/daemon-socket/socket} is equivalent to
6936 @file{/var/guix/daemon-socket/socket}.
6937
6938 @item guix
6939 @cindex daemon, remote access
6940 @cindex remote access to the daemon
6941 @cindex daemon, cluster setup
6942 @cindex clusters, daemon setup
6943 These URIs denote connections over TCP/IP, without encryption nor
6944 authentication of the remote host. The URI must specify the host name
6945 and optionally a port number (by default port 44146 is used):
6946
6947 @example
6948 guix://master.guix.example.org:1234
6949 @end example
6950
6951 This setup is suitable on local networks, such as clusters, where only
6952 trusted nodes may connect to the build daemon at
6953 @code{master.guix.example.org}.
6954
6955 The @option{--listen} option of @command{guix-daemon} can be used to
6956 instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
6957 @option{--listen}}).
6958
6959 @item ssh
6960 @cindex SSH access to build daemons
6961 These URIs allow you to connect to a remote daemon over SSH. This
6962 feature requires Guile-SSH (@pxref{Requirements}) and a working
6963 @command{guile} binary in @env{PATH} on the destination machine. It
6964 supports public key and GSSAPI authentication. A typical URL might look
6965 like this:
6966
6967 @example
6968 ssh://charlie@@guix.example.org:22
6969 @end example
6970
6971 As for @command{guix copy}, the usual OpenSSH client configuration files
6972 are honored (@pxref{Invoking guix copy}).
6973 @end table
6974
6975 Additional URI schemes may be supported in the future.
6976
6977 @c XXX: Remove this note when the protocol incurs fewer round trips
6978 @c and when (guix derivations) no longer relies on file system access.
6979 @quotation Note
6980 The ability to connect to remote build daemons is considered
6981 experimental as of @value{VERSION}. Please get in touch with us to
6982 share any problems or suggestions you may have (@pxref{Contributing}).
6983 @end quotation
6984 @end defvr
6985
6986 @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
6987 Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
6988 @var{reserve-space?} is true, instruct it to reserve a little bit of
6989 extra space on the file system so that the garbage collector can still
6990 operate should the disk become full. Return a server object.
6991
6992 @var{file} defaults to @code{%default-socket-path}, which is the normal
6993 location given the options that were passed to @command{configure}.
6994 @end deffn
6995
6996 @deffn {Scheme Procedure} close-connection @var{server}
6997 Close the connection to @var{server}.
6998 @end deffn
6999
7000 @defvr {Scheme Variable} current-build-output-port
7001 This variable is bound to a SRFI-39 parameter, which refers to the port
7002 where build and error logs sent by the daemon should be written.
7003 @end defvr
7004
7005 Procedures that make RPCs all take a server object as their first
7006 argument.
7007
7008 @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
7009 @cindex invalid store items
7010 Return @code{#t} when @var{path} designates a valid store item and
7011 @code{#f} otherwise (an invalid item may exist on disk but still be
7012 invalid, for instance because it is the result of an aborted or failed
7013 build.)
7014
7015 A @code{&store-protocol-error} condition is raised if @var{path} is not
7016 prefixed by the store directory (@file{/gnu/store}).
7017 @end deffn
7018
7019 @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
7020 Add @var{text} under file @var{name} in the store, and return its store
7021 path. @var{references} is the list of store paths referred to by the
7022 resulting store path.
7023 @end deffn
7024
7025 @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
7026 [@var{mode}]
7027 Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
7028 file names, or derivation/output pairs, using the specified
7029 @var{mode}---@code{(build-mode normal)} by default.
7030 @end deffn
7031
7032 Note that the @code{(guix monads)} module provides a monad as well as
7033 monadic versions of the above procedures, with the goal of making it
7034 more convenient to work with code that accesses the store (@pxref{The
7035 Store Monad}).
7036
7037 @c FIXME
7038 @i{This section is currently incomplete.}
7039
7040 @node Derivations
7041 @section Derivations
7042
7043 @cindex derivations
7044 Low-level build actions and the environment in which they are performed
7045 are represented by @dfn{derivations}. A derivation contains the
7046 following pieces of information:
7047
7048 @itemize
7049 @item
7050 The outputs of the derivation---derivations produce at least one file or
7051 directory in the store, but may produce more.
7052
7053 @item
7054 @cindex build-time dependencies
7055 @cindex dependencies, build-time
7056 The inputs of the derivations---i.e., its build-time dependencies---which may
7057 be other derivations or plain files in the store (patches, build scripts,
7058 etc.)
7059
7060 @item
7061 The system type targeted by the derivation---e.g., @code{x86_64-linux}.
7062
7063 @item
7064 The file name of a build script in the store, along with the arguments
7065 to be passed.
7066
7067 @item
7068 A list of environment variables to be defined.
7069
7070 @end itemize
7071
7072 @cindex derivation path
7073 Derivations allow clients of the daemon to communicate build actions to
7074 the store. They exist in two forms: as an in-memory representation,
7075 both on the client- and daemon-side, and as files in the store whose
7076 name end in @file{.drv}---these files are referred to as @dfn{derivation
7077 paths}. Derivations paths can be passed to the @code{build-derivations}
7078 procedure to perform the build actions they prescribe (@pxref{The
7079 Store}).
7080
7081 @cindex fixed-output derivations
7082 Operations such as file downloads and version-control checkouts for
7083 which the expected content hash is known in advance are modeled as
7084 @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
7085 of a fixed-output derivation are independent of its inputs---e.g., a
7086 source code download produces the same result regardless of the download
7087 method and tools being used.
7088
7089 @cindex references
7090 @cindex run-time dependencies
7091 @cindex dependencies, run-time
7092 The outputs of derivations---i.e., the build results---have a set of
7093 @dfn{references}, as reported by the @code{references} RPC or the
7094 @command{guix gc --references} command (@pxref{Invoking guix gc}). References
7095 are the set of run-time dependencies of the build results. References are a
7096 subset of the inputs of the derivation; this subset is automatically computed
7097 by the build daemon by scanning all the files in the outputs.
7098
7099 The @code{(guix derivations)} module provides a representation of
7100 derivations as Scheme objects, along with procedures to create and
7101 otherwise manipulate derivations. The lowest-level primitive to create
7102 a derivation is the @code{derivation} procedure:
7103
7104 @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
7105 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
7106 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
7107 [#:system (%current-system)] [#:references-graphs #f] @
7108 [#:allowed-references #f] [#:disallowed-references #f] @
7109 [#:leaked-env-vars #f] [#:local-build? #f] @
7110 [#:substitutable? #t] [#:properties '()]
7111 Build a derivation with the given arguments, and return the resulting
7112 @code{<derivation>} object.
7113
7114 When @var{hash} and @var{hash-algo} are given, a
7115 @dfn{fixed-output derivation} is created---i.e., one whose result is
7116 known in advance, such as a file download. If, in addition,
7117 @var{recursive?} is true, then that fixed output may be an executable
7118 file or a directory and @var{hash} must be the hash of an archive
7119 containing this output.
7120
7121 When @var{references-graphs} is true, it must be a list of file
7122 name/store path pairs. In that case, the reference graph of each store
7123 path is exported in the build environment in the corresponding file, in
7124 a simple text format.
7125
7126 When @var{allowed-references} is true, it must be a list of store items
7127 or outputs that the derivation's output may refer to. Likewise,
7128 @var{disallowed-references}, if true, must be a list of things the
7129 outputs may @emph{not} refer to.
7130
7131 When @var{leaked-env-vars} is true, it must be a list of strings
7132 denoting environment variables that are allowed to ``leak'' from the
7133 daemon's environment to the build environment. This is only applicable
7134 to fixed-output derivations---i.e., when @var{hash} is true. The main
7135 use is to allow variables such as @code{http_proxy} to be passed to
7136 derivations that download files.
7137
7138 When @var{local-build?} is true, declare that the derivation is not a
7139 good candidate for offloading and should rather be built locally
7140 (@pxref{Daemon Offload Setup}). This is the case for small derivations
7141 where the costs of data transfers would outweigh the benefits.
7142
7143 When @var{substitutable?} is false, declare that substitutes of the
7144 derivation's output should not be used (@pxref{Substitutes}). This is
7145 useful, for instance, when building packages that capture details of the
7146 host CPU instruction set.
7147
7148 @var{properties} must be an association list describing ``properties'' of the
7149 derivation. It is kept as-is, uninterpreted, in the derivation.
7150 @end deffn
7151
7152 @noindent
7153 Here's an example with a shell script as its builder, assuming
7154 @var{store} is an open connection to the daemon, and @var{bash} points
7155 to a Bash executable in the store:
7156
7157 @lisp
7158 (use-modules (guix utils)
7159 (guix store)
7160 (guix derivations))
7161
7162 (let ((builder ; add the Bash script to the store
7163 (add-text-to-store store "my-builder.sh"
7164 "echo hello world > $out\n" '())))
7165 (derivation store "foo"
7166 bash `("-e" ,builder)
7167 #:inputs `((,bash) (,builder))
7168 #:env-vars '(("HOME" . "/homeless"))))
7169 @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
7170 @end lisp
7171
7172 As can be guessed, this primitive is cumbersome to use directly. A
7173 better approach is to write build scripts in Scheme, of course! The
7174 best course of action for that is to write the build code as a
7175 ``G-expression'', and to pass it to @code{gexp->derivation}. For more
7176 information, @pxref{G-Expressions}.
7177
7178 Once upon a time, @code{gexp->derivation} did not exist and constructing
7179 derivations with build code written in Scheme was achieved with
7180 @code{build-expression->derivation}, documented below. This procedure
7181 is now deprecated in favor of the much nicer @code{gexp->derivation}.
7182
7183 @deffn {Scheme Procedure} build-expression->derivation @var{store} @
7184 @var{name} @var{exp} @
7185 [#:system (%current-system)] [#:inputs '()] @
7186 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
7187 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
7188 [#:references-graphs #f] [#:allowed-references #f] @
7189 [#:disallowed-references #f] @
7190 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
7191 Return a derivation that executes Scheme expression @var{exp} as a
7192 builder for derivation @var{name}. @var{inputs} must be a list of
7193 @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
7194 @code{"out"} is assumed. @var{modules} is a list of names of Guile
7195 modules from the current search path to be copied in the store,
7196 compiled, and made available in the load path during the execution of
7197 @var{exp}---e.g., @code{((guix build utils) (guix build
7198 gnu-build-system))}.
7199
7200 @var{exp} is evaluated in an environment where @code{%outputs} is bound
7201 to a list of output/path pairs, and where @code{%build-inputs} is bound
7202 to a list of string/output-path pairs made from @var{inputs}.
7203 Optionally, @var{env-vars} is a list of string pairs specifying the name
7204 and value of environment variables visible to the builder. The builder
7205 terminates by passing the result of @var{exp} to @code{exit}; thus, when
7206 @var{exp} returns @code{#f}, the build is considered to have failed.
7207
7208 @var{exp} is built using @var{guile-for-build} (a derivation). When
7209 @var{guile-for-build} is omitted or is @code{#f}, the value of the
7210 @code{%guile-for-build} fluid is used instead.
7211
7212 See the @code{derivation} procedure for the meaning of
7213 @var{references-graphs}, @var{allowed-references},
7214 @var{disallowed-references}, @var{local-build?}, and
7215 @var{substitutable?}.
7216 @end deffn
7217
7218 @noindent
7219 Here's an example of a single-output derivation that creates a directory
7220 containing one file:
7221
7222 @lisp
7223 (let ((builder '(let ((out (assoc-ref %outputs "out")))
7224 (mkdir out) ; create /gnu/store/@dots{}-goo
7225 (call-with-output-file (string-append out "/test")
7226 (lambda (p)
7227 (display '(hello guix) p))))))
7228 (build-expression->derivation store "goo" builder))
7229
7230 @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
7231 @end lisp
7232
7233
7234 @node The Store Monad
7235 @section The Store Monad
7236
7237 @cindex monad
7238
7239 The procedures that operate on the store described in the previous
7240 sections all take an open connection to the build daemon as their first
7241 argument. Although the underlying model is functional, they either have
7242 side effects or depend on the current state of the store.
7243
7244 The former is inconvenient: the connection to the build daemon has to be
7245 carried around in all those functions, making it impossible to compose
7246 functions that do not take that parameter with functions that do. The
7247 latter can be problematic: since store operations have side effects
7248 and/or depend on external state, they have to be properly sequenced.
7249
7250 @cindex monadic values
7251 @cindex monadic functions
7252 This is where the @code{(guix monads)} module comes in. This module
7253 provides a framework for working with @dfn{monads}, and a particularly
7254 useful monad for our uses, the @dfn{store monad}. Monads are a
7255 construct that allows two things: associating ``context'' with values
7256 (in our case, the context is the store), and building sequences of
7257 computations (here computations include accesses to the store). Values
7258 in a monad---values that carry this additional context---are called
7259 @dfn{monadic values}; procedures that return such values are called
7260 @dfn{monadic procedures}.
7261
7262 Consider this ``normal'' procedure:
7263
7264 @lisp
7265 (define (sh-symlink store)
7266 ;; Return a derivation that symlinks the 'bash' executable.
7267 (let* ((drv (package-derivation store bash))
7268 (out (derivation->output-path drv))
7269 (sh (string-append out "/bin/bash")))
7270 (build-expression->derivation store "sh"
7271 `(symlink ,sh %output))))
7272 @end lisp
7273
7274 Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
7275 as a monadic function:
7276
7277 @lisp
7278 (define (sh-symlink)
7279 ;; Same, but return a monadic value.
7280 (mlet %store-monad ((drv (package->derivation bash)))
7281 (gexp->derivation "sh"
7282 #~(symlink (string-append #$drv "/bin/bash")
7283 #$output))))
7284 @end lisp
7285
7286 There are several things to note in the second version: the @code{store}
7287 parameter is now implicit and is ``threaded'' in the calls to the
7288 @code{package->derivation} and @code{gexp->derivation} monadic
7289 procedures, and the monadic value returned by @code{package->derivation}
7290 is @dfn{bound} using @code{mlet} instead of plain @code{let}.
7291
7292 As it turns out, the call to @code{package->derivation} can even be
7293 omitted since it will take place implicitly, as we will see later
7294 (@pxref{G-Expressions}):
7295
7296 @lisp
7297 (define (sh-symlink)
7298 (gexp->derivation "sh"
7299 #~(symlink (string-append #$bash "/bin/bash")
7300 #$output)))
7301 @end lisp
7302
7303 @c See
7304 @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
7305 @c for the funny quote.
7306 Calling the monadic @code{sh-symlink} has no effect. As someone once
7307 said, ``you exit a monad like you exit a building on fire: by running''.
7308 So, to exit the monad and get the desired effect, one must use
7309 @code{run-with-store}:
7310
7311 @lisp
7312 (run-with-store (open-connection) (sh-symlink))
7313 @result{} /gnu/store/...-sh-symlink
7314 @end lisp
7315
7316 Note that the @code{(guix monad-repl)} module extends the Guile REPL with
7317 new ``meta-commands'' to make it easier to deal with monadic procedures:
7318 @code{run-in-store}, and @code{enter-store-monad}. The former is used
7319 to ``run'' a single monadic value through the store:
7320
7321 @example
7322 scheme@@(guile-user)> ,run-in-store (package->derivation hello)
7323 $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
7324 @end example
7325
7326 The latter enters a recursive REPL, where all the return values are
7327 automatically run through the store:
7328
7329 @example
7330 scheme@@(guile-user)> ,enter-store-monad
7331 store-monad@@(guile-user) [1]> (package->derivation hello)
7332 $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
7333 store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
7334 $3 = "/gnu/store/@dots{}-foo"
7335 store-monad@@(guile-user) [1]> ,q
7336 scheme@@(guile-user)>
7337 @end example
7338
7339 @noindent
7340 Note that non-monadic values cannot be returned in the
7341 @code{store-monad} REPL.
7342
7343 The main syntactic forms to deal with monads in general are provided by
7344 the @code{(guix monads)} module and are described below.
7345
7346 @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
7347 Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
7348 in @var{monad}.
7349 @end deffn
7350
7351 @deffn {Scheme Syntax} return @var{val}
7352 Return a monadic value that encapsulates @var{val}.
7353 @end deffn
7354
7355 @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
7356 @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
7357 procedures @var{mproc}@dots{}@footnote{This operation is commonly
7358 referred to as ``bind'', but that name denotes an unrelated procedure in
7359 Guile. Thus we use this somewhat cryptic symbol inherited from the
7360 Haskell language.}. There can be one @var{mproc} or several of them, as
7361 in this example:
7362
7363 @lisp
7364 (run-with-state
7365 (with-monad %state-monad
7366 (>>= (return 1)
7367 (lambda (x) (return (+ 1 x)))
7368 (lambda (x) (return (* 2 x)))))
7369 'some-state)
7370
7371 @result{} 4
7372 @result{} some-state
7373 @end lisp
7374 @end deffn
7375
7376 @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
7377 @var{body} ...
7378 @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
7379 @var{body} ...
7380 Bind the variables @var{var} to the monadic values @var{mval} in
7381 @var{body}, which is a sequence of expressions. As with the bind
7382 operator, this can be thought of as ``unpacking'' the raw, non-monadic
7383 value ``contained'' in @var{mval} and making @var{var} refer to that
7384 raw, non-monadic value within the scope of the @var{body}. The form
7385 (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
7386 @var{val}, as per @code{let}. The binding operations occur in sequence
7387 from left to right. The last expression of @var{body} must be a monadic
7388 expression, and its result will become the result of the @code{mlet} or
7389 @code{mlet*} when run in the @var{monad}.
7390
7391 @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
7392 (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
7393 @end deffn
7394
7395 @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
7396 Bind @var{mexp} and the following monadic expressions in sequence,
7397 returning the result of the last expression. Every expression in the
7398 sequence must be a monadic expression.
7399
7400 This is akin to @code{mlet}, except that the return values of the
7401 monadic expressions are ignored. In that sense, it is analogous to
7402 @code{begin}, but applied to monadic expressions.
7403 @end deffn
7404
7405 @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
7406 When @var{condition} is true, evaluate the sequence of monadic
7407 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
7408 @var{condition} is false, return @code{*unspecified*} in the current
7409 monad. Every expression in the sequence must be a monadic expression.
7410 @end deffn
7411
7412 @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
7413 When @var{condition} is false, evaluate the sequence of monadic
7414 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
7415 @var{condition} is true, return @code{*unspecified*} in the current
7416 monad. Every expression in the sequence must be a monadic expression.
7417 @end deffn
7418
7419 @cindex state monad
7420 The @code{(guix monads)} module provides the @dfn{state monad}, which
7421 allows an additional value---the state---to be @emph{threaded} through
7422 monadic procedure calls.
7423
7424 @defvr {Scheme Variable} %state-monad
7425 The state monad. Procedures in the state monad can access and change
7426 the state that is threaded.
7427
7428 Consider the example below. The @code{square} procedure returns a value
7429 in the state monad. It returns the square of its argument, but also
7430 increments the current state value:
7431
7432 @lisp
7433 (define (square x)
7434 (mlet %state-monad ((count (current-state)))
7435 (mbegin %state-monad
7436 (set-current-state (+ 1 count))
7437 (return (* x x)))))
7438
7439 (run-with-state (sequence %state-monad (map square (iota 3))) 0)
7440 @result{} (0 1 4)
7441 @result{} 3
7442 @end lisp
7443
7444 When ``run'' through @code{%state-monad}, we obtain that additional state
7445 value, which is the number of @code{square} calls.
7446 @end defvr
7447
7448 @deffn {Monadic Procedure} current-state
7449 Return the current state as a monadic value.
7450 @end deffn
7451
7452 @deffn {Monadic Procedure} set-current-state @var{value}
7453 Set the current state to @var{value} and return the previous state as a
7454 monadic value.
7455 @end deffn
7456
7457 @deffn {Monadic Procedure} state-push @var{value}
7458 Push @var{value} to the current state, which is assumed to be a list,
7459 and return the previous state as a monadic value.
7460 @end deffn
7461
7462 @deffn {Monadic Procedure} state-pop
7463 Pop a value from the current state and return it as a monadic value.
7464 The state is assumed to be a list.
7465 @end deffn
7466
7467 @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
7468 Run monadic value @var{mval} starting with @var{state} as the initial
7469 state. Return two values: the resulting value, and the resulting state.
7470 @end deffn
7471
7472 The main interface to the store monad, provided by the @code{(guix
7473 store)} module, is as follows.
7474
7475 @defvr {Scheme Variable} %store-monad
7476 The store monad---an alias for @code{%state-monad}.
7477
7478 Values in the store monad encapsulate accesses to the store. When its
7479 effect is needed, a value of the store monad must be ``evaluated'' by
7480 passing it to the @code{run-with-store} procedure (see below.)
7481 @end defvr
7482
7483 @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
7484 Run @var{mval}, a monadic value in the store monad, in @var{store}, an
7485 open store connection.
7486 @end deffn
7487
7488 @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
7489 Return as a monadic value the absolute file name in the store of the file
7490 containing @var{text}, a string. @var{references} is a list of store items that the
7491 resulting text file refers to; it defaults to the empty list.
7492 @end deffn
7493
7494 @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
7495 Return as a monadic value the absolute file name in the store of the file
7496 containing @var{data}, a bytevector. @var{references} is a list of store
7497 items that the resulting binary file refers to; it defaults to the empty list.
7498 @end deffn
7499
7500 @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
7501 [#:recursive? #t] [#:select? (const #t)]
7502 Return the name of @var{file} once interned in the store. Use
7503 @var{name} as its store name, or the basename of @var{file} if
7504 @var{name} is omitted.
7505
7506 When @var{recursive?} is true, the contents of @var{file} are added
7507 recursively; if @var{file} designates a flat file and @var{recursive?}
7508 is true, its contents are added, and its permission bits are kept.
7509
7510 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
7511 @var{stat})} for each directory entry, where @var{file} is the entry's
7512 absolute file name and @var{stat} is the result of @code{lstat}; exclude
7513 entries for which @var{select?} does not return true.
7514
7515 The example below adds a file to the store, under two different names:
7516
7517 @lisp
7518 (run-with-store (open-connection)
7519 (mlet %store-monad ((a (interned-file "README"))
7520 (b (interned-file "README" "LEGU-MIN")))
7521 (return (list a b))))
7522
7523 @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
7524 @end lisp
7525
7526 @end deffn
7527
7528 The @code{(guix packages)} module exports the following package-related
7529 monadic procedures:
7530
7531 @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
7532 [#:system (%current-system)] [#:target #f] @
7533 [#:output "out"]
7534 Return as a monadic
7535 value in the absolute file name of @var{file} within the @var{output}
7536 directory of @var{package}. When @var{file} is omitted, return the name
7537 of the @var{output} directory of @var{package}. When @var{target} is
7538 true, use it as a cross-compilation target triplet.
7539
7540 Note that this procedure does @emph{not} build @var{package}. Thus, the
7541 result might or might not designate an existing file. We recommend not
7542 using this procedure unless you know what you are doing.
7543 @end deffn
7544
7545 @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
7546 @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
7547 @var{target} [@var{system}]
7548 Monadic version of @code{package-derivation} and
7549 @code{package-cross-derivation} (@pxref{Defining Packages}).
7550 @end deffn
7551
7552
7553 @node G-Expressions
7554 @section G-Expressions
7555
7556 @cindex G-expression
7557 @cindex build code quoting
7558 So we have ``derivations'', which represent a sequence of build actions
7559 to be performed to produce an item in the store (@pxref{Derivations}).
7560 These build actions are performed when asking the daemon to actually
7561 build the derivations; they are run by the daemon in a container
7562 (@pxref{Invoking guix-daemon}).
7563
7564 @cindex strata of code
7565 It should come as no surprise that we like to write these build actions
7566 in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
7567 code@footnote{The term @dfn{stratum} in this context was coined by
7568 Manuel Serrano et al.@: in the context of their work on Hop. Oleg
7569 Kiselyov, who has written insightful
7570 @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
7571 on this topic}, refers to this kind of code generation as
7572 @dfn{staging}.}: the ``host code''---code that defines packages, talks
7573 to the daemon, etc.---and the ``build code''---code that actually
7574 performs build actions, such as making directories, invoking
7575 @command{make}, etc.
7576
7577 To describe a derivation and its build actions, one typically needs to
7578 embed build code inside host code. It boils down to manipulating build
7579 code as data, and the homoiconicity of Scheme---code has a direct
7580 representation as data---comes in handy for that. But we need more than
7581 the normal @code{quasiquote} mechanism in Scheme to construct build
7582 expressions.
7583
7584 The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
7585 S-expressions adapted to build expressions. G-expressions, or
7586 @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
7587 @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
7588 @code{#$}, and @code{#$@@}), which are comparable to
7589 @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
7590 respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
7591 GNU Guile Reference Manual}). However, there are major differences:
7592
7593 @itemize
7594 @item
7595 Gexps are meant to be written to a file and run or manipulated by other
7596 processes.
7597
7598 @item
7599 When a high-level object such as a package or derivation is unquoted
7600 inside a gexp, the result is as if its output file name had been
7601 introduced.
7602
7603 @item
7604 Gexps carry information about the packages or derivations they refer to,
7605 and these dependencies are automatically added as inputs to the build
7606 processes that use them.
7607 @end itemize
7608
7609 @cindex lowering, of high-level objects in gexps
7610 This mechanism is not limited to package and derivation
7611 objects: @dfn{compilers} able to ``lower'' other high-level objects to
7612 derivations or files in the store can be defined,
7613 such that these objects can also be inserted
7614 into gexps. For example, a useful type of high-level objects that can be
7615 inserted in a gexp is ``file-like objects'', which make it easy to
7616 add files to the store and to refer to them in
7617 derivations and such (see @code{local-file} and @code{plain-file}
7618 below.)
7619
7620 To illustrate the idea, here is an example of a gexp:
7621
7622 @lisp
7623 (define build-exp
7624 #~(begin
7625 (mkdir #$output)
7626 (chdir #$output)
7627 (symlink (string-append #$coreutils "/bin/ls")
7628 "list-files")))
7629 @end lisp
7630
7631 This gexp can be passed to @code{gexp->derivation}; we obtain a
7632 derivation that builds a directory containing exactly one symlink to
7633 @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
7634
7635 @lisp
7636 (gexp->derivation "the-thing" build-exp)
7637 @end lisp
7638
7639 As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
7640 substituted to the reference to the @var{coreutils} package in the
7641 actual build code, and @var{coreutils} is automatically made an input to
7642 the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
7643 output)}) is replaced by a string containing the directory name of the
7644 output of the derivation.
7645
7646 @cindex cross compilation
7647 In a cross-compilation context, it is useful to distinguish between
7648 references to the @emph{native} build of a package---that can run on the
7649 host---versus references to cross builds of a package. To that end, the
7650 @code{#+} plays the same role as @code{#$}, but is a reference to a
7651 native package build:
7652
7653 @lisp
7654 (gexp->derivation "vi"
7655 #~(begin
7656 (mkdir #$output)
7657 (mkdir (string-append #$output "/bin"))
7658 (system* (string-append #+coreutils "/bin/ln")
7659 "-s"
7660 (string-append #$emacs "/bin/emacs")
7661 (string-append #$output "/bin/vi")))
7662 #:target "mips64el-linux-gnu")
7663 @end lisp
7664
7665 @noindent
7666 In the example above, the native build of @var{coreutils} is used, so
7667 that @command{ln} can actually run on the host; but then the
7668 cross-compiled build of @var{emacs} is referenced.
7669
7670 @cindex imported modules, for gexps
7671 @findex with-imported-modules
7672 Another gexp feature is @dfn{imported modules}: sometimes you want to be
7673 able to use certain Guile modules from the ``host environment'' in the
7674 gexp, so those modules should be imported in the ``build environment''.
7675 The @code{with-imported-modules} form allows you to express that:
7676
7677 @lisp
7678 (let ((build (with-imported-modules '((guix build utils))
7679 #~(begin
7680 (use-modules (guix build utils))
7681 (mkdir-p (string-append #$output "/bin"))))))
7682 (gexp->derivation "empty-dir"
7683 #~(begin
7684 #$build
7685 (display "success!\n")
7686 #t)))
7687 @end lisp
7688
7689 @noindent
7690 In this example, the @code{(guix build utils)} module is automatically
7691 pulled into the isolated build environment of our gexp, such that
7692 @code{(use-modules (guix build utils))} works as expected.
7693
7694 @cindex module closure
7695 @findex source-module-closure
7696 Usually you want the @emph{closure} of the module to be imported---i.e.,
7697 the module itself and all the modules it depends on---rather than just
7698 the module; failing to do that, attempts to use the module will fail
7699 because of missing dependent modules. The @code{source-module-closure}
7700 procedure computes the closure of a module by looking at its source file
7701 headers, which comes in handy in this case:
7702
7703 @lisp
7704 (use-modules (guix modules)) ;for 'source-module-closure'
7705
7706 (with-imported-modules (source-module-closure
7707 '((guix build utils)
7708 (gnu build vm)))
7709 (gexp->derivation "something-with-vms"
7710 #~(begin
7711 (use-modules (guix build utils)
7712 (gnu build vm))
7713 @dots{})))
7714 @end lisp
7715
7716 @cindex extensions, for gexps
7717 @findex with-extensions
7718 In the same vein, sometimes you want to import not just pure-Scheme
7719 modules, but also ``extensions'' such as Guile bindings to C libraries
7720 or other ``full-blown'' packages. Say you need the @code{guile-json}
7721 package available on the build side, here's how you would do it:
7722
7723 @lisp
7724 (use-modules (gnu packages guile)) ;for 'guile-json'
7725
7726 (with-extensions (list guile-json)
7727 (gexp->derivation "something-with-json"
7728 #~(begin
7729 (use-modules (json))
7730 @dots{})))
7731 @end lisp
7732
7733 The syntactic form to construct gexps is summarized below.
7734
7735 @deffn {Scheme Syntax} #~@var{exp}
7736 @deffnx {Scheme Syntax} (gexp @var{exp})
7737 Return a G-expression containing @var{exp}. @var{exp} may contain one
7738 or more of the following forms:
7739
7740 @table @code
7741 @item #$@var{obj}
7742 @itemx (ungexp @var{obj})
7743 Introduce a reference to @var{obj}. @var{obj} may have one of the
7744 supported types, for example a package or a
7745 derivation, in which case the @code{ungexp} form is replaced by its
7746 output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
7747
7748 If @var{obj} is a list, it is traversed and references to supported
7749 objects are substituted similarly.
7750
7751 If @var{obj} is another gexp, its contents are inserted and its
7752 dependencies are added to those of the containing gexp.
7753
7754 If @var{obj} is another kind of object, it is inserted as is.
7755
7756 @item #$@var{obj}:@var{output}
7757 @itemx (ungexp @var{obj} @var{output})
7758 This is like the form above, but referring explicitly to the
7759 @var{output} of @var{obj}---this is useful when @var{obj} produces
7760 multiple outputs (@pxref{Packages with Multiple Outputs}).
7761
7762 @item #+@var{obj}
7763 @itemx #+@var{obj}:output
7764 @itemx (ungexp-native @var{obj})
7765 @itemx (ungexp-native @var{obj} @var{output})
7766 Same as @code{ungexp}, but produces a reference to the @emph{native}
7767 build of @var{obj} when used in a cross compilation context.
7768
7769 @item #$output[:@var{output}]
7770 @itemx (ungexp output [@var{output}])
7771 Insert a reference to derivation output @var{output}, or to the main
7772 output when @var{output} is omitted.
7773
7774 This only makes sense for gexps passed to @code{gexp->derivation}.
7775
7776 @item #$@@@var{lst}
7777 @itemx (ungexp-splicing @var{lst})
7778 Like the above, but splices the contents of @var{lst} inside the
7779 containing list.
7780
7781 @item #+@@@var{lst}
7782 @itemx (ungexp-native-splicing @var{lst})
7783 Like the above, but refers to native builds of the objects listed in
7784 @var{lst}.
7785
7786 @end table
7787
7788 G-expressions created by @code{gexp} or @code{#~} are run-time objects
7789 of the @code{gexp?} type (see below.)
7790 @end deffn
7791
7792 @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
7793 Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
7794 in their execution environment.
7795
7796 Each item in @var{modules} can be the name of a module, such as
7797 @code{(guix build utils)}, or it can be a module name, followed by an
7798 arrow, followed by a file-like object:
7799
7800 @lisp
7801 `((guix build utils)
7802 (guix gcrypt)
7803 ((guix config) => ,(scheme-file "config.scm"
7804 #~(define-module @dots{}))))
7805 @end lisp
7806
7807 @noindent
7808 In the example above, the first two modules are taken from the search
7809 path, and the last one is created from the given file-like object.
7810
7811 This form has @emph{lexical} scope: it has an effect on the gexps
7812 directly defined in @var{body}@dots{}, but not on those defined, say, in
7813 procedures called from @var{body}@dots{}.
7814 @end deffn
7815
7816 @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
7817 Mark the gexps defined in @var{body}@dots{} as requiring
7818 @var{extensions} in their build and execution environment.
7819 @var{extensions} is typically a list of package objects such as those
7820 defined in the @code{(gnu packages guile)} module.
7821
7822 Concretely, the packages listed in @var{extensions} are added to the
7823 load path while compiling imported modules in @var{body}@dots{}; they
7824 are also added to the load path of the gexp returned by
7825 @var{body}@dots{}.
7826 @end deffn
7827
7828 @deffn {Scheme Procedure} gexp? @var{obj}
7829 Return @code{#t} if @var{obj} is a G-expression.
7830 @end deffn
7831
7832 G-expressions are meant to be written to disk, either as code building
7833 some derivation, or as plain files in the store. The monadic procedures
7834 below allow you to do that (@pxref{The Store Monad}, for more
7835 information about monads.)
7836
7837 @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
7838 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
7839 [#:hash #f] [#:hash-algo #f] @
7840 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
7841 [#:module-path @code{%load-path}] @
7842 [#:effective-version "2.2"] @
7843 [#:references-graphs #f] [#:allowed-references #f] @
7844 [#:disallowed-references #f] @
7845 [#:leaked-env-vars #f] @
7846 [#:script-name (string-append @var{name} "-builder")] @
7847 [#:deprecation-warnings #f] @
7848 [#:local-build? #f] [#:substitutable? #t] @
7849 [#:properties '()] [#:guile-for-build #f]
7850 Return a derivation @var{name} that runs @var{exp} (a gexp) with
7851 @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
7852 stored in a file called @var{script-name}. When @var{target} is true,
7853 it is used as the cross-compilation target triplet for packages referred
7854 to by @var{exp}.
7855
7856 @var{modules} is deprecated in favor of @code{with-imported-modules}.
7857 Its meaning is to
7858 make @var{modules} available in the evaluation context of @var{exp};
7859 @var{modules} is a list of names of Guile modules searched in
7860 @var{module-path} to be copied in the store, compiled, and made available in
7861 the load path during the execution of @var{exp}---e.g., @code{((guix
7862 build utils) (guix build gnu-build-system))}.
7863
7864 @var{effective-version} determines the string to use when adding extensions of
7865 @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
7866
7867 @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
7868 applicable.
7869
7870 When @var{references-graphs} is true, it must be a list of tuples of one of the
7871 following forms:
7872
7873 @example
7874 (@var{file-name} @var{package})
7875 (@var{file-name} @var{package} @var{output})
7876 (@var{file-name} @var{derivation})
7877 (@var{file-name} @var{derivation} @var{output})
7878 (@var{file-name} @var{store-item})
7879 @end example
7880
7881 The right-hand-side of each element of @var{references-graphs} is automatically made
7882 an input of the build process of @var{exp}. In the build environment, each
7883 @var{file-name} contains the reference graph of the corresponding item, in a simple
7884 text format.
7885
7886 @var{allowed-references} must be either @code{#f} or a list of output names and packages.
7887 In the latter case, the list denotes store items that the result is allowed to
7888 refer to. Any reference to another store item will lead to a build error.
7889 Similarly for @var{disallowed-references}, which can list items that must not be
7890 referenced by the outputs.
7891
7892 @var{deprecation-warnings} determines whether to show deprecation warnings while
7893 compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
7894
7895 The other arguments are as for @code{derivation} (@pxref{Derivations}).
7896 @end deffn
7897
7898 @cindex file-like objects
7899 The @code{local-file}, @code{plain-file}, @code{computed-file},
7900 @code{program-file}, and @code{scheme-file} procedures below return
7901 @dfn{file-like objects}. That is, when unquoted in a G-expression,
7902 these objects lead to a file in the store. Consider this G-expression:
7903
7904 @lisp
7905 #~(system* #$(file-append glibc "/sbin/nscd") "-f"
7906 #$(local-file "/tmp/my-nscd.conf"))
7907 @end lisp
7908
7909 The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
7910 to the store. Once expanded, for instance @i{via}
7911 @code{gexp->derivation}, the G-expression refers to that copy under
7912 @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
7913 does not have any effect on what the G-expression does.
7914 @code{plain-file} can be used similarly; it differs in that the file
7915 content is directly passed as a string.
7916
7917 @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
7918 [#:recursive? #f] [#:select? (const #t)]
7919 Return an object representing local file @var{file} to add to the store;
7920 this object can be used in a gexp. If @var{file} is a literal string
7921 denoting a relative file name, it is looked up relative to the source
7922 file where it appears; if @var{file} is not a literal string, it is
7923 looked up relative to the current working directory at run time.
7924 @var{file} will be added to the store under @var{name}--by default the
7925 base name of @var{file}.
7926
7927 When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
7928 designates a flat file and @var{recursive?} is true, its contents are added, and its
7929 permission bits are kept.
7930
7931 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
7932 @var{stat})} for each directory entry, where @var{file} is the entry's
7933 absolute file name and @var{stat} is the result of @code{lstat}; exclude
7934 entries for which @var{select?} does not return true.
7935
7936 This is the declarative counterpart of the @code{interned-file} monadic
7937 procedure (@pxref{The Store Monad, @code{interned-file}}).
7938 @end deffn
7939
7940 @deffn {Scheme Procedure} plain-file @var{name} @var{content}
7941 Return an object representing a text file called @var{name} with the given
7942 @var{content} (a string or a bytevector) to be added to the store.
7943
7944 This is the declarative counterpart of @code{text-file}.
7945 @end deffn
7946
7947 @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
7948 [#:options '(#:local-build? #t)]
7949 Return an object representing the store item @var{name}, a file or
7950 directory computed by @var{gexp}. @var{options}
7951 is a list of additional arguments to pass to @code{gexp->derivation}.
7952
7953 This is the declarative counterpart of @code{gexp->derivation}.
7954 @end deffn
7955
7956 @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
7957 [#:guile (default-guile)] [#:module-path %load-path] @
7958 [#:system (%current-system)] [#:target #f]
7959 Return an executable script @var{name} that runs @var{exp} using
7960 @var{guile}, with @var{exp}'s imported modules in its search path.
7961 Look up @var{exp}'s modules in @var{module-path}.
7962
7963 The example below builds a script that simply invokes the @command{ls}
7964 command:
7965
7966 @lisp
7967 (use-modules (guix gexp) (gnu packages base))
7968
7969 (gexp->script "list-files"
7970 #~(execl #$(file-append coreutils "/bin/ls")
7971 "ls"))
7972 @end lisp
7973
7974 When ``running'' it through the store (@pxref{The Store Monad,
7975 @code{run-with-store}}), we obtain a derivation that produces an
7976 executable file @file{/gnu/store/@dots{}-list-files} along these lines:
7977
7978 @example
7979 #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
7980 !#
7981 (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
7982 @end example
7983 @end deffn
7984
7985 @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
7986 [#:guile #f] [#:module-path %load-path]
7987 Return an object representing the executable store item @var{name} that
7988 runs @var{gexp}. @var{guile} is the Guile package used to execute that
7989 script. Imported modules of @var{gexp} are looked up in @var{module-path}.
7990
7991 This is the declarative counterpart of @code{gexp->script}.
7992 @end deffn
7993
7994 @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
7995 [#:set-load-path? #t] [#:module-path %load-path] @
7996 [#:splice? #f] @
7997 [#:guile (default-guile)]
7998 Return a derivation that builds a file @var{name} containing @var{exp}.
7999 When @var{splice?} is true, @var{exp} is considered to be a list of
8000 expressions that will be spliced in the resulting file.
8001
8002 When @var{set-load-path?} is true, emit code in the resulting file to
8003 set @code{%load-path} and @code{%load-compiled-path} to honor
8004 @var{exp}'s imported modules. Look up @var{exp}'s modules in
8005 @var{module-path}.
8006
8007 The resulting file holds references to all the dependencies of @var{exp}
8008 or a subset thereof.
8009 @end deffn
8010
8011 @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
8012 [#:splice? #f] [#:set-load-path? #t]
8013 Return an object representing the Scheme file @var{name} that contains
8014 @var{exp}.
8015
8016 This is the declarative counterpart of @code{gexp->file}.
8017 @end deffn
8018
8019 @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
8020 Return as a monadic value a derivation that builds a text file
8021 containing all of @var{text}. @var{text} may list, in addition to
8022 strings, objects of any type that can be used in a gexp: packages,
8023 derivations, local file objects, etc. The resulting store file holds
8024 references to all these.
8025
8026 This variant should be preferred over @code{text-file} anytime the file
8027 to create will reference items from the store. This is typically the
8028 case when building a configuration file that embeds store file names,
8029 like this:
8030
8031 @lisp
8032 (define (profile.sh)
8033 ;; Return the name of a shell script in the store that
8034 ;; initializes the 'PATH' environment variable.
8035 (text-file* "profile.sh"
8036 "export PATH=" coreutils "/bin:"
8037 grep "/bin:" sed "/bin\n"))
8038 @end lisp
8039
8040 In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
8041 will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
8042 preventing them from being garbage-collected during its lifetime.
8043 @end deffn
8044
8045 @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
8046 Return an object representing store file @var{name} containing
8047 @var{text}. @var{text} is a sequence of strings and file-like objects,
8048 as in:
8049
8050 @lisp
8051 (mixed-text-file "profile"
8052 "export PATH=" coreutils "/bin:" grep "/bin")
8053 @end lisp
8054
8055 This is the declarative counterpart of @code{text-file*}.
8056 @end deffn
8057
8058 @deffn {Scheme Procedure} file-union @var{name} @var{files}
8059 Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
8060 Each item in @var{files} must be a two-element list where the first element is the
8061 file name to use in the new directory, and the second element is a gexp
8062 denoting the target file. Here's an example:
8063
8064 @lisp
8065 (file-union "etc"
8066 `(("hosts" ,(plain-file "hosts"
8067 "127.0.0.1 localhost"))
8068 ("bashrc" ,(plain-file "bashrc"
8069 "alias ls='ls --color=auto'"))))
8070 @end lisp
8071
8072 This yields an @code{etc} directory containing these two files.
8073 @end deffn
8074
8075 @deffn {Scheme Procedure} directory-union @var{name} @var{things}
8076 Return a directory that is the union of @var{things}, where @var{things} is a list of
8077 file-like objects denoting directories. For example:
8078
8079 @lisp
8080 (directory-union "guile+emacs" (list guile emacs))
8081 @end lisp
8082
8083 yields a directory that is the union of the @code{guile} and @code{emacs} packages.
8084 @end deffn
8085
8086 @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
8087 Return a file-like object that expands to the concatenation of @var{obj}
8088 and @var{suffix}, where @var{obj} is a lowerable object and each
8089 @var{suffix} is a string.
8090
8091 As an example, consider this gexp:
8092
8093 @lisp
8094 (gexp->script "run-uname"
8095 #~(system* #$(file-append coreutils
8096 "/bin/uname")))
8097 @end lisp
8098
8099 The same effect could be achieved with:
8100
8101 @lisp
8102 (gexp->script "run-uname"
8103 #~(system* (string-append #$coreutils
8104 "/bin/uname")))
8105 @end lisp
8106
8107 There is one difference though: in the @code{file-append} case, the
8108 resulting script contains the absolute file name as a string, whereas in
8109 the second case, the resulting script contains a @code{(string-append
8110 @dots{})} expression to construct the file name @emph{at run time}.
8111 @end deffn
8112
8113 @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
8114 This macro is similar to the @code{parameterize} form for
8115 dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
8116 Guile Reference Manual}). The key difference is that it takes effect
8117 when the file-like object returned by @var{exp} is lowered to a
8118 derivation or store item.
8119
8120 A typical use of @code{with-parameters} is to force the system in effect
8121 for a given object:
8122
8123 @lisp
8124 (with-parameters ((%current-system "i686-linux"))
8125 coreutils)
8126 @end lisp
8127
8128 The example above returns an object that corresponds to the i686 build
8129 of Coreutils, regardless of the current value of @code{%current-system}.
8130 @end deffn
8131
8132
8133 Of course, in addition to gexps embedded in ``host'' code, there are
8134 also modules containing build tools. To make it clear that they are
8135 meant to be used in the build stratum, these modules are kept in the
8136 @code{(guix build @dots{})} name space.
8137
8138 @cindex lowering, of high-level objects in gexps
8139 Internally, high-level objects are @dfn{lowered}, using their compiler,
8140 to either derivations or store items. For instance, lowering a package
8141 yields a derivation, and lowering a @code{plain-file} yields a store
8142 item. This is achieved using the @code{lower-object} monadic procedure.
8143
8144 @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
8145 [#:target #f]
8146 Return as a value in @code{%store-monad} the derivation or store item
8147 corresponding to @var{obj} for @var{system}, cross-compiling for
8148 @var{target} if @var{target} is true. @var{obj} must be an object that
8149 has an associated gexp compiler, such as a @code{<package>}.
8150 @end deffn
8151
8152 @node Invoking guix repl
8153 @section Invoking @command{guix repl}
8154
8155 @cindex REPL, read-eval-print loop
8156 The @command{guix repl} command spawns a Guile @dfn{read-eval-print loop}
8157 (REPL) for interactive programming (@pxref{Using Guile Interactively,,, guile,
8158 GNU Guile Reference Manual}). Compared to just launching the @command{guile}
8159 command, @command{guix repl} guarantees that all the Guix modules and all its
8160 dependencies are available in the search path. You can use it this way:
8161
8162 @example
8163 $ guix repl
8164 scheme@@(guile-user)> ,use (gnu packages base)
8165 scheme@@(guile-user)> coreutils
8166 $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
8167 @end example
8168
8169 @cindex inferiors
8170 In addition, @command{guix repl} implements a simple machine-readable REPL
8171 protocol for use by @code{(guix inferior)}, a facility to interact with
8172 @dfn{inferiors}, separate processes running a potentially different revision
8173 of Guix.
8174
8175 The available options are as follows:
8176
8177 @table @code
8178 @item --type=@var{type}
8179 @itemx -t @var{type}
8180 Start a REPL of the given @var{TYPE}, which can be one of the following:
8181
8182 @table @code
8183 @item guile
8184 This is default, and it spawns a standard full-featured Guile REPL.
8185 @item machine
8186 Spawn a REPL that uses the machine-readable protocol. This is the protocol
8187 that the @code{(guix inferior)} module speaks.
8188 @end table
8189
8190 @item --listen=@var{endpoint}
8191 By default, @command{guix repl} reads from standard input and writes to
8192 standard output. When this option is passed, it will instead listen for
8193 connections on @var{endpoint}. Here are examples of valid options:
8194
8195 @table @code
8196 @item --listen=tcp:37146
8197 Accept connections on localhost on port 37146.
8198
8199 @item --listen=unix:/tmp/socket
8200 Accept connections on the Unix-domain socket @file{/tmp/socket}.
8201 @end table
8202
8203 @item --load-path=@var{directory}
8204 @itemx -L @var{directory}
8205 Add @var{directory} to the front of the package module search path
8206 (@pxref{Package Modules}).
8207
8208 This allows users to define their own packages and make them visible to
8209 the command-line tool.
8210
8211 @item -q
8212 Inhibit loading of the @file{~/.guile} file. By default, that
8213 configuration file is loaded when spawning a @code{guile} REPL.
8214 @end table
8215
8216 @c *********************************************************************
8217 @node Utilities
8218 @chapter Utilities
8219
8220 This section describes Guix command-line utilities. Some of them are
8221 primarily targeted at developers and users who write new package
8222 definitions, while others are more generally useful. They complement
8223 the Scheme programming interface of Guix in a convenient way.
8224
8225 @menu
8226 * Invoking guix build:: Building packages from the command line.
8227 * Invoking guix edit:: Editing package definitions.
8228 * Invoking guix download:: Downloading a file and printing its hash.
8229 * Invoking guix hash:: Computing the cryptographic hash of a file.
8230 * Invoking guix import:: Importing package definitions.
8231 * Invoking guix refresh:: Updating package definitions.
8232 * Invoking guix lint:: Finding errors in package definitions.
8233 * Invoking guix size:: Profiling disk usage.
8234 * Invoking guix graph:: Visualizing the graph of packages.
8235 * Invoking guix publish:: Sharing substitutes.
8236 * Invoking guix challenge:: Challenging substitute servers.
8237 * Invoking guix copy:: Copying to and from a remote store.
8238 * Invoking guix container:: Process isolation.
8239 * Invoking guix weather:: Assessing substitute availability.
8240 * Invoking guix processes:: Listing client processes.
8241 @end menu
8242
8243 @node Invoking guix build
8244 @section Invoking @command{guix build}
8245
8246 @cindex package building
8247 @cindex @command{guix build}
8248 The @command{guix build} command builds packages or derivations and
8249 their dependencies, and prints the resulting store paths. Note that it
8250 does not modify the user's profile---this is the job of the
8251 @command{guix package} command (@pxref{Invoking guix package}). Thus,
8252 it is mainly useful for distribution developers.
8253
8254 The general syntax is:
8255
8256 @example
8257 guix build @var{options} @var{package-or-derivation}@dots{}
8258 @end example
8259
8260 As an example, the following command builds the latest versions of Emacs
8261 and of Guile, displays their build logs, and finally displays the
8262 resulting directories:
8263
8264 @example
8265 guix build emacs guile
8266 @end example
8267
8268 Similarly, the following command builds all the available packages:
8269
8270 @example
8271 guix build --quiet --keep-going \
8272 `guix package -A | cut -f1,2 --output-delimiter=@@`
8273 @end example
8274
8275 @var{package-or-derivation} may be either the name of a package found in
8276 the software distribution such as @code{coreutils} or
8277 @code{coreutils@@8.20}, or a derivation such as
8278 @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
8279 package with the corresponding name (and optionally version) is searched
8280 for among the GNU distribution modules (@pxref{Package Modules}).
8281
8282 Alternatively, the @option{--expression} option may be used to specify a
8283 Scheme expression that evaluates to a package; this is useful when
8284 disambiguating among several same-named packages or package variants is
8285 needed.
8286
8287 There may be zero or more @var{options}. The available options are
8288 described in the subsections below.
8289
8290 @menu
8291 * Common Build Options:: Build options for most commands.
8292 * Package Transformation Options:: Creating variants of packages.
8293 * Additional Build Options:: Options specific to 'guix build'.
8294 * Debugging Build Failures:: Real life packaging experience.
8295 @end menu
8296
8297 @node Common Build Options
8298 @subsection Common Build Options
8299
8300 A number of options that control the build process are common to
8301 @command{guix build} and other commands that can spawn builds, such as
8302 @command{guix package} or @command{guix archive}. These are the
8303 following:
8304
8305 @table @code
8306
8307 @item --load-path=@var{directory}
8308 @itemx -L @var{directory}
8309 Add @var{directory} to the front of the package module search path
8310 (@pxref{Package Modules}).
8311
8312 This allows users to define their own packages and make them visible to
8313 the command-line tools.
8314
8315 @item --keep-failed
8316 @itemx -K
8317 Keep the build tree of failed builds. Thus, if a build fails, its build
8318 tree is kept under @file{/tmp}, in a directory whose name is shown at
8319 the end of the build log. This is useful when debugging build issues.
8320 @xref{Debugging Build Failures}, for tips and tricks on how to debug
8321 build issues.
8322
8323 This option implies @option{--no-offload}, and it has no effect when
8324 connecting to a remote daemon with a @code{guix://} URI (@pxref{The
8325 Store, the @env{GUIX_DAEMON_SOCKET} variable}).
8326
8327 @item --keep-going
8328 @itemx -k
8329 Keep going when some of the derivations fail to build; return only once
8330 all the builds have either completed or failed.
8331
8332 The default behavior is to stop as soon as one of the specified
8333 derivations has failed.
8334
8335 @item --dry-run
8336 @itemx -n
8337 Do not build the derivations.
8338
8339 @anchor{fallback-option}
8340 @item --fallback
8341 When substituting a pre-built binary fails, fall back to building
8342 packages locally (@pxref{Substitution Failure}).
8343
8344 @item --substitute-urls=@var{urls}
8345 @anchor{client-substitute-urls}
8346 Consider @var{urls} the whitespace-separated list of substitute source
8347 URLs, overriding the default list of URLs of @command{guix-daemon}
8348 (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
8349
8350 This means that substitutes may be downloaded from @var{urls}, provided
8351 they are signed by a key authorized by the system administrator
8352 (@pxref{Substitutes}).
8353
8354 When @var{urls} is the empty string, substitutes are effectively
8355 disabled.
8356
8357 @item --no-substitutes
8358 Do not use substitutes for build products. That is, always build things
8359 locally instead of allowing downloads of pre-built binaries
8360 (@pxref{Substitutes}).
8361
8362 @item --no-grafts
8363 Do not ``graft'' packages. In practice, this means that package updates
8364 available as grafts are not applied. @xref{Security Updates}, for more
8365 information on grafts.
8366
8367 @item --rounds=@var{n}
8368 Build each derivation @var{n} times in a row, and raise an error if
8369 consecutive build results are not bit-for-bit identical.
8370
8371 This is a useful way to detect non-deterministic builds processes.
8372 Non-deterministic build processes are a problem because they make it
8373 practically impossible for users to @emph{verify} whether third-party
8374 binaries are genuine. @xref{Invoking guix challenge}, for more.
8375
8376 Note that, currently, the differing build results are not kept around,
8377 so you will have to manually investigate in case of an error---e.g., by
8378 stashing one of the build results with @code{guix archive --export}
8379 (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
8380 the two results.
8381
8382 @item --no-offload
8383 Do not use offload builds to other machines (@pxref{Daemon Offload
8384 Setup}). That is, always build things locally instead of offloading
8385 builds to remote machines.
8386
8387 @item --max-silent-time=@var{seconds}
8388 When the build or substitution process remains silent for more than
8389 @var{seconds}, terminate it and report a build failure.
8390
8391 By default, the daemon's setting is honored (@pxref{Invoking
8392 guix-daemon, @option{--max-silent-time}}).
8393
8394 @item --timeout=@var{seconds}
8395 Likewise, when the build or substitution process lasts for more than
8396 @var{seconds}, terminate it and report a build failure.
8397
8398 By default, the daemon's setting is honored (@pxref{Invoking
8399 guix-daemon, @option{--timeout}}).
8400
8401 @c Note: This option is actually not part of %standard-build-options but
8402 @c most programs honor it.
8403 @cindex verbosity, of the command-line tools
8404 @cindex build logs, verbosity
8405 @item -v @var{level}
8406 @itemx --verbosity=@var{level}
8407 Use the given verbosity @var{level}, an integer. Choosing 0 means that no
8408 output is produced, 1 is for quiet output, and 2 shows all the build log
8409 output on standard error.
8410
8411 @item --cores=@var{n}
8412 @itemx -c @var{n}
8413 Allow the use of up to @var{n} CPU cores for the build. The special
8414 value @code{0} means to use as many CPU cores as available.
8415
8416 @item --max-jobs=@var{n}
8417 @itemx -M @var{n}
8418 Allow at most @var{n} build jobs in parallel. @xref{Invoking
8419 guix-daemon, @option{--max-jobs}}, for details about this option and the
8420 equivalent @command{guix-daemon} option.
8421
8422 @item --debug=@var{level}
8423 Produce debugging output coming from the build daemon. @var{level} must be an
8424 integer between 0 and 5; higher means more verbose output. Setting a level of
8425 4 or more may be helpful when debugging setup issues with the build daemon.
8426
8427 @end table
8428
8429 Behind the scenes, @command{guix build} is essentially an interface to
8430 the @code{package-derivation} procedure of the @code{(guix packages)}
8431 module, and to the @code{build-derivations} procedure of the @code{(guix
8432 derivations)} module.
8433
8434 In addition to options explicitly passed on the command line,
8435 @command{guix build} and other @command{guix} commands that support
8436 building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
8437
8438 @defvr {Environment Variable} GUIX_BUILD_OPTIONS
8439 Users can define this variable to a list of command line options that
8440 will automatically be used by @command{guix build} and other
8441 @command{guix} commands that can perform builds, as in the example
8442 below:
8443
8444 @example
8445 $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
8446 @end example
8447
8448 These options are parsed independently, and the result is appended to
8449 the parsed command-line options.
8450 @end defvr
8451
8452
8453 @node Package Transformation Options
8454 @subsection Package Transformation Options
8455
8456 @cindex package variants
8457 Another set of command-line options supported by @command{guix build}
8458 and also @command{guix package} are @dfn{package transformation
8459 options}. These are options that make it possible to define @dfn{package
8460 variants}---for instance, packages built from different source code.
8461 This is a convenient way to create customized packages on the fly
8462 without having to type in the definitions of package variants
8463 (@pxref{Defining Packages}).
8464
8465 @table @code
8466
8467 @item --with-source=@var{source}
8468 @itemx --with-source=@var{package}=@var{source}
8469 @itemx --with-source=@var{package}@@@var{version}=@var{source}
8470 Use @var{source} as the source of @var{package}, and @var{version} as
8471 its version number.
8472 @var{source} must be a file name or a URL, as for @command{guix
8473 download} (@pxref{Invoking guix download}).
8474
8475 When @var{package} is omitted,
8476 it is taken to be the package name specified on the
8477 command line that matches the base of @var{source}---e.g.,
8478 if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
8479 package is @code{guile}.
8480
8481 Likewise, when @var{version} is omitted, the version string is inferred from
8482 @var{source}; in the previous example, it is @code{2.0.10}.
8483
8484 This option allows users to try out versions of packages other than the
8485 one provided by the distribution. The example below downloads
8486 @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
8487 the @code{ed} package:
8488
8489 @example
8490 guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
8491 @end example
8492
8493 As a developer, @option{--with-source} makes it easy to test release
8494 candidates:
8495
8496 @example
8497 guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
8498 @end example
8499
8500 @dots{} or to build from a checkout in a pristine environment:
8501
8502 @example
8503 $ git clone git://git.sv.gnu.org/guix.git
8504 $ guix build guix --with-source=guix@@1.0=./guix
8505 @end example
8506
8507 @item --with-input=@var{package}=@var{replacement}
8508 Replace dependency on @var{package} by a dependency on
8509 @var{replacement}. @var{package} must be a package name, and
8510 @var{replacement} must be a package specification such as @code{guile}
8511 or @code{guile@@1.8}.
8512
8513 For instance, the following command builds Guix, but replaces its
8514 dependency on the current stable version of Guile with a dependency on
8515 the legacy version of Guile, @code{guile@@2.0}:
8516
8517 @example
8518 guix build --with-input=guile=guile@@2.0 guix
8519 @end example
8520
8521 This is a recursive, deep replacement. So in this example, both
8522 @code{guix} and its dependency @code{guile-json} (which also depends on
8523 @code{guile}) get rebuilt against @code{guile@@2.0}.
8524
8525 This is implemented using the @code{package-input-rewriting} Scheme
8526 procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
8527
8528 @item --with-graft=@var{package}=@var{replacement}
8529 This is similar to @option{--with-input} but with an important difference:
8530 instead of rebuilding the whole dependency chain, @var{replacement} is
8531 built and then @dfn{grafted} onto the binaries that were initially
8532 referring to @var{package}. @xref{Security Updates}, for more
8533 information on grafts.
8534
8535 For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
8536 and all its dependencies, replacing references to the version of GnuTLS
8537 they currently refer to:
8538
8539 @example
8540 guix build --with-graft=gnutls=gnutls@@3.5.4 wget
8541 @end example
8542
8543 This has the advantage of being much faster than rebuilding everything.
8544 But there is a caveat: it works if and only if @var{package} and
8545 @var{replacement} are strictly compatible---for example, if they provide
8546 a library, the application binary interface (ABI) of those libraries
8547 must be compatible. If @var{replacement} is somehow incompatible with
8548 @var{package}, then the resulting package may be unusable. Use with
8549 care!
8550
8551 @item --with-git-url=@var{package}=@var{url}
8552 @cindex Git, using the latest commit
8553 @cindex latest commit, building
8554 Build @var{package} from the latest commit of the @code{master} branch of the
8555 Git repository at @var{url}. Git sub-modules of the repository are fetched,
8556 recursively.
8557
8558 For example, the following command builds the NumPy Python library against the
8559 latest commit of the master branch of Python itself:
8560
8561 @example
8562 guix build python-numpy \
8563 --with-git-url=python=https://github.com/python/cpython
8564 @end example
8565
8566 This option can also be combined with @option{--with-branch} or
8567 @option{--with-commit} (see below).
8568
8569 @cindex continuous integration
8570 Obviously, since it uses the latest commit of the given branch, the result of
8571 such a command varies over time. Nevertheless it is a convenient way to
8572 rebuild entire software stacks against the latest commit of one or more
8573 packages. This is particularly useful in the context of continuous
8574 integration (CI).
8575
8576 Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
8577 consecutive accesses to the same repository. You may want to clean it up once
8578 in a while to save disk space.
8579
8580 @item --with-branch=@var{package}=@var{branch}
8581 Build @var{package} from the latest commit of @var{branch}. If the
8582 @code{source} field of @var{package} is an origin with the @code{git-fetch}
8583 method (@pxref{origin Reference}) or a @code{git-checkout} object, the
8584 repository URL is taken from that @code{source}. Otherwise you have to use
8585 @option{--with-git-url} to specify the URL of the Git repository.
8586
8587 For instance, the following command builds @code{guile-sqlite3} from the
8588 latest commit of its @code{master} branch, and then builds @code{guix} (which
8589 depends on it) and @code{cuirass} (which depends on @code{guix}) against this
8590 specific @code{guile-sqlite3} build:
8591
8592 @example
8593 guix build --with-branch=guile-sqlite3=master cuirass
8594 @end example
8595
8596 @item --with-commit=@var{package}=@var{commit}
8597 This is similar to @option{--with-branch}, except that it builds from
8598 @var{commit} rather than the tip of a branch. @var{commit} must be a valid
8599 Git commit SHA1 identifier or a tag.
8600 @end table
8601
8602 @node Additional Build Options
8603 @subsection Additional Build Options
8604
8605 The command-line options presented below are specific to @command{guix
8606 build}.
8607
8608 @table @code
8609
8610 @item --quiet
8611 @itemx -q
8612 Build quietly, without displaying the build log; this is equivalent to
8613 @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
8614 (or similar) and can always be retrieved using the @option{--log-file} option.
8615
8616 @item --file=@var{file}
8617 @itemx -f @var{file}
8618 Build the package, derivation, or other file-like object that the code within
8619 @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
8620
8621 As an example, @var{file} might contain a package definition like this
8622 (@pxref{Defining Packages}):
8623
8624 @lisp
8625 @include package-hello.scm
8626 @end lisp
8627
8628 The @var{file} may also contain a JSON representation of one or more
8629 package definitions. Running @code{guix build -f} on @file{hello.json}
8630 with the following contents would result in building the packages
8631 @code{myhello} and @code{greeter}:
8632
8633 @example
8634 @verbatiminclude package-hello.json
8635 @end example
8636
8637 @item --manifest=@var{manifest}
8638 @itemx -m @var{manifest}
8639 Build all packages listed in the given @var{manifest}
8640 (@pxref{profile-manifest, @option{--manifest}}).
8641
8642 @item --expression=@var{expr}
8643 @itemx -e @var{expr}
8644 Build the package or derivation @var{expr} evaluates to.
8645
8646 For example, @var{expr} may be @code{(@@ (gnu packages guile)
8647 guile-1.8)}, which unambiguously designates this specific variant of
8648 version 1.8 of Guile.
8649
8650 Alternatively, @var{expr} may be a G-expression, in which case it is used
8651 as a build program passed to @code{gexp->derivation}
8652 (@pxref{G-Expressions}).
8653
8654 Lastly, @var{expr} may refer to a zero-argument monadic procedure
8655 (@pxref{The Store Monad}). The procedure must return a derivation as a
8656 monadic value, which is then passed through @code{run-with-store}.
8657
8658 @item --source
8659 @itemx -S
8660 Build the source derivations of the packages, rather than the packages
8661 themselves.
8662
8663 For instance, @code{guix build -S gcc} returns something like
8664 @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
8665 source tarball.
8666
8667 The returned source tarball is the result of applying any patches and
8668 code snippets specified in the package @code{origin} (@pxref{Defining
8669 Packages}).
8670
8671 Note that @command{guix build -S} compiles the sources only of the
8672 specified packages. They do not include the sources of statically
8673 linked dependencies and by themselves are insufficient for reproducing
8674 the packages.
8675
8676 @item --sources
8677 Fetch and return the source of @var{package-or-derivation} and all their
8678 dependencies, recursively. This is a handy way to obtain a local copy
8679 of all the source code needed to build @var{packages}, allowing you to
8680 eventually build them even without network access. It is an extension
8681 of the @option{--source} option and can accept one of the following
8682 optional argument values:
8683
8684 @table @code
8685 @item package
8686 This value causes the @option{--sources} option to behave in the same way
8687 as the @option{--source} option.
8688
8689 @item all
8690 Build the source derivations of all packages, including any source that
8691 might be listed as @code{inputs}. This is the default value.
8692
8693 @example
8694 $ guix build --sources tzdata
8695 The following derivations will be built:
8696 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
8697 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
8698 @end example
8699
8700 @item transitive
8701 Build the source derivations of all packages, as well of all transitive
8702 inputs to the packages. This can be used e.g.@: to
8703 prefetch package source for later offline building.
8704
8705 @example
8706 $ guix build --sources=transitive tzdata
8707 The following derivations will be built:
8708 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
8709 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
8710 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
8711 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
8712 /gnu/store/@dots{}-make-4.1.tar.xz.drv
8713 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
8714 @dots{}
8715 @end example
8716
8717 @end table
8718
8719 @item --system=@var{system}
8720 @itemx -s @var{system}
8721 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
8722 the system type of the build host. The @command{guix build} command allows
8723 you to repeat this option several times, in which case it builds for all the
8724 specified systems; other commands ignore extraneous @option{-s} options.
8725
8726 @quotation Note
8727 The @option{--system} flag is for @emph{native} compilation and must not
8728 be confused with cross-compilation. See @option{--target} below for
8729 information on cross-compilation.
8730 @end quotation
8731
8732 An example use of this is on Linux-based systems, which can emulate
8733 different personalities. For instance, passing
8734 @option{--system=i686-linux} on an @code{x86_64-linux} system or
8735 @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
8736 you to build packages in a complete 32-bit environment.
8737
8738 @quotation Note
8739 Building for an @code{armhf-linux} system is unconditionally enabled on
8740 @code{aarch64-linux} machines, although certain aarch64 chipsets do not
8741 allow for this functionality, notably the ThunderX.
8742 @end quotation
8743
8744 Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
8745 is enabled (@pxref{Virtualization Services,
8746 @code{qemu-binfmt-service-type}}), you can build for any system for
8747 which a QEMU @code{binfmt_misc} handler is installed.
8748
8749 Builds for a system other than that of the machine you are using can
8750 also be offloaded to a remote machine of the right architecture.
8751 @xref{Daemon Offload Setup}, for more information on offloading.
8752
8753 @item --target=@var{triplet}
8754 @cindex cross-compilation
8755 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
8756 as @code{"mips64el-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
8757 configuration triplets,, autoconf, Autoconf}).
8758
8759 @anchor{build-check}
8760 @item --check
8761 @cindex determinism, checking
8762 @cindex reproducibility, checking
8763 Rebuild @var{package-or-derivation}, which are already available in the
8764 store, and raise an error if the build results are not bit-for-bit
8765 identical.
8766
8767 This mechanism allows you to check whether previously installed
8768 substitutes are genuine (@pxref{Substitutes}), or whether the build result
8769 of a package is deterministic. @xref{Invoking guix challenge}, for more
8770 background information and tools.
8771
8772 When used in conjunction with @option{--keep-failed}, the differing
8773 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
8774 This makes it easy to look for differences between the two results.
8775
8776 @item --repair
8777 @cindex repairing store items
8778 @cindex corruption, recovering from
8779 Attempt to repair the specified store items, if they are corrupt, by
8780 re-downloading or rebuilding them.
8781
8782 This operation is not atomic and thus restricted to @code{root}.
8783
8784 @item --derivations
8785 @itemx -d
8786 Return the derivation paths, not the output paths, of the given
8787 packages.
8788
8789 @item --root=@var{file}
8790 @itemx -r @var{file}
8791 @cindex GC roots, adding
8792 @cindex garbage collector roots, adding
8793 Make @var{file} a symlink to the result, and register it as a garbage
8794 collector root.
8795
8796 Consequently, the results of this @command{guix build} invocation are
8797 protected from garbage collection until @var{file} is removed. When
8798 that option is omitted, build results are eligible for garbage
8799 collection as soon as the build completes. @xref{Invoking guix gc}, for
8800 more on GC roots.
8801
8802 @item --log-file
8803 @cindex build logs, access
8804 Return the build log file names or URLs for the given
8805 @var{package-or-derivation}, or raise an error if build logs are
8806 missing.
8807
8808 This works regardless of how packages or derivations are specified. For
8809 instance, the following invocations are equivalent:
8810
8811 @example
8812 guix build --log-file `guix build -d guile`
8813 guix build --log-file `guix build guile`
8814 guix build --log-file guile
8815 guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
8816 @end example
8817
8818 If a log is unavailable locally, and unless @option{--no-substitutes} is
8819 passed, the command looks for a corresponding log on one of the
8820 substitute servers (as specified with @option{--substitute-urls}.)
8821
8822 So for instance, imagine you want to see the build log of GDB on MIPS,
8823 but you are actually on an @code{x86_64} machine:
8824
8825 @example
8826 $ guix build --log-file gdb -s mips64el-linux
8827 https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
8828 @end example
8829
8830 You can freely access a huge library of build logs!
8831 @end table
8832
8833 @node Debugging Build Failures
8834 @subsection Debugging Build Failures
8835
8836 @cindex build failures, debugging
8837 When defining a new package (@pxref{Defining Packages}), you will
8838 probably find yourself spending some time debugging and tweaking the
8839 build until it succeeds. To do that, you need to operate the build
8840 commands yourself in an environment as close as possible to the one the
8841 build daemon uses.
8842
8843 To that end, the first thing to do is to use the @option{--keep-failed}
8844 or @option{-K} option of @command{guix build}, which will keep the
8845 failed build tree in @file{/tmp} or whatever directory you specified as
8846 @env{TMPDIR} (@pxref{Invoking guix build, @option{--keep-failed}}).
8847
8848 From there on, you can @command{cd} to the failed build tree and source
8849 the @file{environment-variables} file, which contains all the
8850 environment variable definitions that were in place when the build
8851 failed. So let's say you're debugging a build failure in package
8852 @code{foo}; a typical session would look like this:
8853
8854 @example
8855 $ guix build foo -K
8856 @dots{} @i{build fails}
8857 $ cd /tmp/guix-build-foo.drv-0
8858 $ source ./environment-variables
8859 $ cd foo-1.2
8860 @end example
8861
8862 Now, you can invoke commands as if you were the daemon (almost) and
8863 troubleshoot your build process.
8864
8865 Sometimes it happens that, for example, a package's tests pass when you
8866 run them manually but they fail when the daemon runs them. This can
8867 happen because the daemon runs builds in containers where, unlike in our
8868 environment above, network access is missing, @file{/bin/sh} does not
8869 exist, etc. (@pxref{Build Environment Setup}).
8870
8871 In such cases, you may need to run inspect the build process from within
8872 a container similar to the one the build daemon creates:
8873
8874 @example
8875 $ guix build -K foo
8876 @dots{}
8877 $ cd /tmp/guix-build-foo.drv-0
8878 $ guix environment --no-grafts -C foo --ad-hoc strace gdb
8879 [env]# source ./environment-variables
8880 [env]# cd foo-1.2
8881 @end example
8882
8883 Here, @command{guix environment -C} creates a container and spawns a new
8884 shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
8885 strace gdb} part adds the @command{strace} and @command{gdb} commands to
8886 the container, which you may find handy while debugging. The
8887 @option{--no-grafts} option makes sure we get the exact same
8888 environment, with ungrafted packages (@pxref{Security Updates}, for more
8889 info on grafts).
8890
8891 To get closer to a container like that used by the build daemon, we can
8892 remove @file{/bin/sh}:
8893
8894 @example
8895 [env]# rm /bin/sh
8896 @end example
8897
8898 (Don't worry, this is harmless: this is all happening in the throw-away
8899 container created by @command{guix environment}.)
8900
8901 The @command{strace} command is probably not in the search path, but we
8902 can run:
8903
8904 @example
8905 [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
8906 @end example
8907
8908 In this way, not only you will have reproduced the environment variables
8909 the daemon uses, you will also be running the build process in a container
8910 similar to the one the daemon uses.
8911
8912
8913 @node Invoking guix edit
8914 @section Invoking @command{guix edit}
8915
8916 @cindex @command{guix edit}
8917 @cindex package definition, editing
8918 So many packages, so many source files! The @command{guix edit} command
8919 facilitates the life of users and packagers by pointing their editor at
8920 the source file containing the definition of the specified packages.
8921 For instance:
8922
8923 @example
8924 guix edit gcc@@4.9 vim
8925 @end example
8926
8927 @noindent
8928 launches the program specified in the @env{VISUAL} or in the
8929 @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
8930 and that of Vim.
8931
8932 If you are using a Guix Git checkout (@pxref{Building from Git}), or
8933 have created your own packages on @env{GUIX_PACKAGE_PATH}
8934 (@pxref{Package Modules}), you will be able to edit the package
8935 recipes. In other cases, you will be able to examine the read-only recipes
8936 for packages currently in the store.
8937
8938 Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
8939 @option{--load-path=@var{directory}} (or in short @option{-L
8940 @var{directory}}) allows you to add @var{directory} to the front of the
8941 package module search path and so make your own packages visible.
8942
8943 @node Invoking guix download
8944 @section Invoking @command{guix download}
8945
8946 @cindex @command{guix download}
8947 @cindex downloading package sources
8948 When writing a package definition, developers typically need to download
8949 a source tarball, compute its SHA256 hash, and write that
8950 hash in the package definition (@pxref{Defining Packages}). The
8951 @command{guix download} tool helps with this task: it downloads a file
8952 from the given URI, adds it to the store, and prints both its file name
8953 in the store and its SHA256 hash.
8954
8955 The fact that the downloaded file is added to the store saves bandwidth:
8956 when the developer eventually tries to build the newly defined package
8957 with @command{guix build}, the source tarball will not have to be
8958 downloaded again because it is already in the store. It is also a
8959 convenient way to temporarily stash files, which may be deleted
8960 eventually (@pxref{Invoking guix gc}).
8961
8962 The @command{guix download} command supports the same URIs as used in
8963 package definitions. In particular, it supports @code{mirror://} URIs.
8964 @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
8965 Guile bindings for GnuTLS are available in the user's environment; when
8966 they are not available, an error is raised. @xref{Guile Preparations,
8967 how to install the GnuTLS bindings for Guile,, gnutls-guile,
8968 GnuTLS-Guile}, for more information.
8969
8970 @command{guix download} verifies HTTPS server certificates by loading
8971 the certificates of X.509 authorities from the directory pointed to by
8972 the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
8973 Certificates}), unless @option{--no-check-certificate} is used.
8974
8975 The following options are available:
8976
8977 @table @code
8978 @item --format=@var{fmt}
8979 @itemx -f @var{fmt}
8980 Write the hash in the format specified by @var{fmt}. For more
8981 information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
8982
8983 @item --no-check-certificate
8984 Do not validate the X.509 certificates of HTTPS servers.
8985
8986 When using this option, you have @emph{absolutely no guarantee} that you
8987 are communicating with the authentic server responsible for the given
8988 URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
8989
8990 @item --output=@var{file}
8991 @itemx -o @var{file}
8992 Save the downloaded file to @var{file} instead of adding it to the
8993 store.
8994 @end table
8995
8996 @node Invoking guix hash
8997 @section Invoking @command{guix hash}
8998
8999 @cindex @command{guix hash}
9000 The @command{guix hash} command computes the SHA256 hash of a file.
9001 It is primarily a convenience tool for anyone contributing to the
9002 distribution: it computes the cryptographic hash of a file, which can be
9003 used in the definition of a package (@pxref{Defining Packages}).
9004
9005 The general syntax is:
9006
9007 @example
9008 guix hash @var{option} @var{file}
9009 @end example
9010
9011 When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
9012 hash of data read from standard input. @command{guix hash} has the
9013 following options:
9014
9015 @table @code
9016
9017 @item --format=@var{fmt}
9018 @itemx -f @var{fmt}
9019 Write the hash in the format specified by @var{fmt}.
9020
9021 Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
9022 (@code{hex} and @code{hexadecimal} can be used as well).
9023
9024 If the @option{--format} option is not specified, @command{guix hash}
9025 will output the hash in @code{nix-base32}. This representation is used
9026 in the definitions of packages.
9027
9028 @item --recursive
9029 @itemx -r
9030 Compute the hash on @var{file} recursively.
9031
9032 In this case, the hash is computed on an archive containing @var{file},
9033 including its children if it is a directory. Some of the metadata of
9034 @var{file} is part of the archive; for instance, when @var{file} is a
9035 regular file, the hash is different depending on whether @var{file} is
9036 executable or not. Metadata such as time stamps has no impact on the
9037 hash (@pxref{Invoking guix archive}).
9038 @c FIXME: Replace xref above with xref to an ``Archive'' section when
9039 @c it exists.
9040
9041 @item --exclude-vcs
9042 @itemx -x
9043 When combined with @option{--recursive}, exclude version control system
9044 directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
9045
9046 @vindex git-fetch
9047 As an example, here is how you would compute the hash of a Git checkout,
9048 which is useful when using the @code{git-fetch} method (@pxref{origin
9049 Reference}):
9050
9051 @example
9052 $ git clone http://example.org/foo.git
9053 $ cd foo
9054 $ guix hash -rx .
9055 @end example
9056 @end table
9057
9058 @node Invoking guix import
9059 @section Invoking @command{guix import}
9060
9061 @cindex importing packages
9062 @cindex package import
9063 @cindex package conversion
9064 @cindex Invoking @command{guix import}
9065 The @command{guix import} command is useful for people who would like to
9066 add a package to the distribution with as little work as
9067 possible---a legitimate demand. The command knows of a few
9068 repositories from which it can ``import'' package metadata. The result
9069 is a package definition, or a template thereof, in the format we know
9070 (@pxref{Defining Packages}).
9071
9072 The general syntax is:
9073
9074 @example
9075 guix import @var{importer} @var{options}@dots{}
9076 @end example
9077
9078 @var{importer} specifies the source from which to import package
9079 metadata, and @var{options} specifies a package identifier and other
9080 options specific to @var{importer}.
9081
9082 Some of the importers rely on the ability to run the @command{gpgv} command.
9083 For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
9084 gnupg} if needed.
9085
9086 Currently, the available ``importers'' are:
9087
9088 @table @code
9089 @item gnu
9090 Import metadata for the given GNU package. This provides a template
9091 for the latest version of that GNU package, including the hash of its
9092 source tarball, and its canonical synopsis and description.
9093
9094 Additional information such as the package dependencies and its
9095 license needs to be figured out manually.
9096
9097 For example, the following command returns a package definition for
9098 GNU@tie{}Hello:
9099
9100 @example
9101 guix import gnu hello
9102 @end example
9103
9104 Specific command-line options are:
9105
9106 @table @code
9107 @item --key-download=@var{policy}
9108 As for @command{guix refresh}, specify the policy to handle missing
9109 OpenPGP keys when verifying the package signature. @xref{Invoking guix
9110 refresh, @option{--key-download}}.
9111 @end table
9112
9113 @item pypi
9114 @cindex pypi
9115 Import metadata from the @uref{https://pypi.python.org/, Python Package
9116 Index}. Information is taken from the JSON-formatted description
9117 available at @code{pypi.python.org} and usually includes all the relevant
9118 information, including package dependencies. For maximum efficiency, it
9119 is recommended to install the @command{unzip} utility, so that the
9120 importer can unzip Python wheels and gather data from them.
9121
9122 The command below imports metadata for the @code{itsdangerous} Python
9123 package:
9124
9125 @example
9126 guix import pypi itsdangerous
9127 @end example
9128
9129 @table @code
9130 @item --recursive
9131 @itemx -r
9132 Traverse the dependency graph of the given upstream package recursively
9133 and generate package expressions for all those packages that are not yet
9134 in Guix.
9135 @end table
9136
9137 @item gem
9138 @cindex gem
9139 Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
9140 is taken from the JSON-formatted description available at
9141 @code{rubygems.org} and includes most relevant information, including
9142 runtime dependencies. There are some caveats, however. The metadata
9143 doesn't distinguish between synopses and descriptions, so the same string
9144 is used for both fields. Additionally, the details of non-Ruby
9145 dependencies required to build native extensions is unavailable and left
9146 as an exercise to the packager.
9147
9148 The command below imports metadata for the @code{rails} Ruby package:
9149
9150 @example
9151 guix import gem rails
9152 @end example
9153
9154 @table @code
9155 @item --recursive
9156 @itemx -r
9157 Traverse the dependency graph of the given upstream package recursively
9158 and generate package expressions for all those packages that are not yet
9159 in Guix.
9160 @end table
9161
9162 @item cpan
9163 @cindex CPAN
9164 Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
9165 Information is taken from the JSON-formatted metadata provided through
9166 @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
9167 relevant information, such as module dependencies. License information
9168 should be checked closely. If Perl is available in the store, then the
9169 @code{corelist} utility will be used to filter core modules out of the
9170 list of dependencies.
9171
9172 The command command below imports metadata for the Acme::Boolean Perl
9173 module:
9174
9175 @example
9176 guix import cpan Acme::Boolean
9177 @end example
9178
9179 @item cran
9180 @cindex CRAN
9181 @cindex Bioconductor
9182 Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
9183 central repository for the @uref{https://r-project.org, GNU@tie{}R
9184 statistical and graphical environment}.
9185
9186 Information is extracted from the @file{DESCRIPTION} file of the package.
9187
9188 The command command below imports metadata for the Cairo R package:
9189
9190 @example
9191 guix import cran Cairo
9192 @end example
9193
9194 When @option{--recursive} is added, the importer will traverse the
9195 dependency graph of the given upstream package recursively and generate
9196 package expressions for all those packages that are not yet in Guix.
9197
9198 When @option{--archive=bioconductor} is added, metadata is imported from
9199 @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
9200 packages for for the analysis and comprehension of high-throughput
9201 genomic data in bioinformatics.
9202
9203 Information is extracted from the @file{DESCRIPTION} file contained in the
9204 package archive.
9205
9206 The command below imports metadata for the GenomicRanges R package:
9207
9208 @example
9209 guix import cran --archive=bioconductor GenomicRanges
9210 @end example
9211
9212 Finally, you can also import R packages that have not yet been published on
9213 CRAN or Bioconductor as long as they are in a git repository. Use
9214 @option{--archive=git} followed by the URL of the git repository:
9215
9216 @example
9217 guix import cran --archive=git https://github.com/immunogenomics/harmony
9218 @end example
9219
9220 @item texlive
9221 @cindex TeX Live
9222 @cindex CTAN
9223 Import metadata from @uref{https://www.ctan.org/, CTAN}, the
9224 comprehensive TeX archive network for TeX packages that are part of the
9225 @uref{https://www.tug.org/texlive/, TeX Live distribution}.
9226
9227 Information about the package is obtained through the XML API provided
9228 by CTAN, while the source code is downloaded from the SVN repository of
9229 the Tex Live project. This is done because the CTAN does not keep
9230 versioned archives.
9231
9232 The command command below imports metadata for the @code{fontspec}
9233 TeX package:
9234
9235 @example
9236 guix import texlive fontspec
9237 @end example
9238
9239 When @option{--archive=@var{directory}} is added, the source code is
9240 downloaded not from the @file{latex} sub-directory of the
9241 @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
9242 the specified sibling @var{directory} under the same root.
9243
9244 The command below imports metadata for the @code{ifxetex} package from
9245 CTAN while fetching the sources from the directory
9246 @file{texmf/source/generic}:
9247
9248 @example
9249 guix import texlive --archive=generic ifxetex
9250 @end example
9251
9252 @item json
9253 @cindex JSON, import
9254 Import package metadata from a local JSON file. Consider the following
9255 example package definition in JSON format:
9256
9257 @example
9258 @{
9259 "name": "hello",
9260 "version": "2.10",
9261 "source": "mirror://gnu/hello/hello-2.10.tar.gz",
9262 "build-system": "gnu",
9263 "home-page": "https://www.gnu.org/software/hello/",
9264 "synopsis": "Hello, GNU world: An example GNU package",
9265 "description": "GNU Hello prints a greeting.",
9266 "license": "GPL-3.0+",
9267 "native-inputs": ["gettext"]
9268 @}
9269 @end example
9270
9271 The field names are the same as for the @code{<package>} record
9272 (@xref{Defining Packages}). References to other packages are provided
9273 as JSON lists of quoted package specification strings such as
9274 @code{guile} or @code{guile@@2.0}.
9275
9276 The importer also supports a more explicit source definition using the
9277 common fields for @code{<origin>} records:
9278
9279 @example
9280 @{
9281 @dots{}
9282 "source": @{
9283 "method": "url-fetch",
9284 "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
9285 "sha256": @{
9286 "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
9287 @}
9288 @}
9289 @dots{}
9290 @}
9291 @end example
9292
9293 The command below reads metadata from the JSON file @code{hello.json}
9294 and outputs a package expression:
9295
9296 @example
9297 guix import json hello.json
9298 @end example
9299
9300 @item nix
9301 Import metadata from a local copy of the source of the
9302 @uref{https://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
9303 relies on the @command{nix-instantiate} command of
9304 @uref{https://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
9305 typically written in a mixture of Nix-language and Bash code. This
9306 command only imports the high-level package structure that is written in
9307 the Nix language. It normally includes all the basic fields of a
9308 package definition.
9309
9310 When importing a GNU package, the synopsis and descriptions are replaced
9311 by their canonical upstream variant.
9312
9313 Usually, you will first need to do:
9314
9315 @example
9316 export NIX_REMOTE=daemon
9317 @end example
9318
9319 @noindent
9320 so that @command{nix-instantiate} does not try to open the Nix database.
9321
9322 As an example, the command below imports the package definition of
9323 LibreOffice (more precisely, it imports the definition of the package
9324 bound to the @code{libreoffice} top-level attribute):
9325
9326 @example
9327 guix import nix ~/path/to/nixpkgs libreoffice
9328 @end example
9329
9330 @item hackage
9331 @cindex hackage
9332 Import metadata from the Haskell community's central package archive
9333 @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
9334 Cabal files and includes all the relevant information, including package
9335 dependencies.
9336
9337 Specific command-line options are:
9338
9339 @table @code
9340 @item --stdin
9341 @itemx -s
9342 Read a Cabal file from standard input.
9343 @item --no-test-dependencies
9344 @itemx -t
9345 Do not include dependencies required only by the test suites.
9346 @item --cabal-environment=@var{alist}
9347 @itemx -e @var{alist}
9348 @var{alist} is a Scheme alist defining the environment in which the
9349 Cabal conditionals are evaluated. The accepted keys are: @code{os},
9350 @code{arch}, @code{impl} and a string representing the name of a flag.
9351 The value associated with a flag has to be either the symbol
9352 @code{true} or @code{false}. The value associated with other keys
9353 has to conform to the Cabal file format definition. The default value
9354 associated with the keys @code{os}, @code{arch} and @code{impl} is
9355 @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
9356 @item --recursive
9357 @itemx -r
9358 Traverse the dependency graph of the given upstream package recursively
9359 and generate package expressions for all those packages that are not yet
9360 in Guix.
9361 @end table
9362
9363 The command below imports metadata for the latest version of the
9364 HTTP Haskell package without including test dependencies and
9365 specifying the value of the flag @samp{network-uri} as @code{false}:
9366
9367 @example
9368 guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
9369 @end example
9370
9371 A specific package version may optionally be specified by following the
9372 package name by an at-sign and a version number as in the following example:
9373
9374 @example
9375 guix import hackage mtl@@2.1.3.1
9376 @end example
9377
9378 @item stackage
9379 @cindex stackage
9380 The @code{stackage} importer is a wrapper around the @code{hackage} one.
9381 It takes a package name, looks up the package version included in a
9382 long-term support (LTS) @uref{https://www.stackage.org, Stackage}
9383 release and uses the @code{hackage} importer to retrieve its metadata.
9384 Note that it is up to you to select an LTS release compatible with the
9385 GHC compiler used by Guix.
9386
9387 Specific command-line options are:
9388
9389 @table @code
9390 @item --no-test-dependencies
9391 @itemx -t
9392 Do not include dependencies required only by the test suites.
9393 @item --lts-version=@var{version}
9394 @itemx -l @var{version}
9395 @var{version} is the desired LTS release version. If omitted the latest
9396 release is used.
9397 @item --recursive
9398 @itemx -r
9399 Traverse the dependency graph of the given upstream package recursively
9400 and generate package expressions for all those packages that are not yet
9401 in Guix.
9402 @end table
9403
9404 The command below imports metadata for the HTTP Haskell package
9405 included in the LTS Stackage release version 7.18:
9406
9407 @example
9408 guix import stackage --lts-version=7.18 HTTP
9409 @end example
9410
9411 @item elpa
9412 @cindex elpa
9413 Import metadata from an Emacs Lisp Package Archive (ELPA) package
9414 repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
9415
9416 Specific command-line options are:
9417
9418 @table @code
9419 @item --archive=@var{repo}
9420 @itemx -a @var{repo}
9421 @var{repo} identifies the archive repository from which to retrieve the
9422 information. Currently the supported repositories and their identifiers
9423 are:
9424 @itemize -
9425 @item
9426 @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
9427 identifier. This is the default.
9428
9429 Packages from @code{elpa.gnu.org} are signed with one of the keys
9430 contained in the GnuPG keyring at
9431 @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
9432 @code{emacs} package (@pxref{Package Installation, ELPA package
9433 signatures,, emacs, The GNU Emacs Manual}).
9434
9435 @item
9436 @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
9437 @code{melpa-stable} identifier.
9438
9439 @item
9440 @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
9441 identifier.
9442 @end itemize
9443
9444 @item --recursive
9445 @itemx -r
9446 Traverse the dependency graph of the given upstream package recursively
9447 and generate package expressions for all those packages that are not yet
9448 in Guix.
9449 @end table
9450
9451 @item crate
9452 @cindex crate
9453 Import metadata from the crates.io Rust package repository
9454 @uref{https://crates.io, crates.io}, as in this example:
9455
9456 @example
9457 guix import crate blake2-rfc
9458 @end example
9459
9460 The crate importer also allows you to specify a version string:
9461
9462 @example
9463 guix import crate constant-time-eq@@0.1.0
9464 @end example
9465
9466 Additional options include:
9467
9468 @table @code
9469 @item --recursive
9470 @itemx -r
9471 Traverse the dependency graph of the given upstream package recursively
9472 and generate package expressions for all those packages that are not yet
9473 in Guix.
9474 @end table
9475
9476 @item opam
9477 @cindex OPAM
9478 @cindex OCaml
9479 Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
9480 repository used by the OCaml community.
9481 @end table
9482
9483 The structure of the @command{guix import} code is modular. It would be
9484 useful to have more importers for other package formats, and your help
9485 is welcome here (@pxref{Contributing}).
9486
9487 @node Invoking guix refresh
9488 @section Invoking @command{guix refresh}
9489
9490 @cindex @command {guix refresh}
9491 The primary audience of the @command{guix refresh} command is developers
9492 of the GNU software distribution. By default, it reports any packages
9493 provided by the distribution that are outdated compared to the latest
9494 upstream version, like this:
9495
9496 @example
9497 $ guix refresh
9498 gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
9499 gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
9500 @end example
9501
9502 Alternately, one can specify packages to consider, in which case a
9503 warning is emitted for packages that lack an updater:
9504
9505 @example
9506 $ guix refresh coreutils guile guile-ssh
9507 gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
9508 gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
9509 @end example
9510
9511 @command{guix refresh} browses the upstream repository of each package and determines
9512 the highest version number of the releases therein. The command
9513 knows how to update specific types of packages: GNU packages, ELPA
9514 packages, etc.---see the documentation for @option{--type} below. There
9515 are many packages, though, for which it lacks a method to determine
9516 whether a new upstream release is available. However, the mechanism is
9517 extensible, so feel free to get in touch with us to add a new method!
9518
9519 @table @code
9520
9521 @item --recursive
9522 Consider the packages specified, and all the packages upon which they depend.
9523
9524 @example
9525 $ guix refresh --recursive coreutils
9526 gnu/packages/acl.scm:35:2: warning: no updater for acl
9527 gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
9528 gnu/packages/xml.scm:68:2: warning: no updater for expat
9529 gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest version of gmp
9530 @dots{}
9531 @end example
9532
9533 @end table
9534
9535 Sometimes the upstream name differs from the package name used in Guix,
9536 and @command{guix refresh} needs a little help. Most updaters honor the
9537 @code{upstream-name} property in package definitions, which can be used
9538 to that effect:
9539
9540 @lisp
9541 (define-public network-manager
9542 (package
9543 (name "network-manager")
9544 ;; @dots{}
9545 (properties '((upstream-name . "NetworkManager")))))
9546 @end lisp
9547
9548 When passed @option{--update}, it modifies distribution source files to
9549 update the version numbers and source tarball hashes of those package
9550 recipes (@pxref{Defining Packages}). This is achieved by downloading
9551 each package's latest source tarball and its associated OpenPGP
9552 signature, authenticating the downloaded tarball against its signature
9553 using @command{gpgv}, and finally computing its hash---note that GnuPG must be
9554 installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
9555
9556 When the public
9557 key used to sign the tarball is missing from the user's keyring, an
9558 attempt is made to automatically retrieve it from a public key server;
9559 when this is successful, the key is added to the user's keyring; otherwise,
9560 @command{guix refresh} reports an error.
9561
9562 The following options are supported:
9563
9564 @table @code
9565
9566 @item --expression=@var{expr}
9567 @itemx -e @var{expr}
9568 Consider the package @var{expr} evaluates to.
9569
9570 This is useful to precisely refer to a package, as in this example:
9571
9572 @example
9573 guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
9574 @end example
9575
9576 This command lists the dependents of the ``final'' libc (essentially all
9577 the packages.)
9578
9579 @item --update
9580 @itemx -u
9581 Update distribution source files (package recipes) in place. This is
9582 usually run from a checkout of the Guix source tree (@pxref{Running
9583 Guix Before It Is Installed}):
9584
9585 @example
9586 $ ./pre-inst-env guix refresh -s non-core -u
9587 @end example
9588
9589 @xref{Defining Packages}, for more information on package definitions.
9590
9591 @item --select=[@var{subset}]
9592 @itemx -s @var{subset}
9593 Select all the packages in @var{subset}, one of @code{core} or
9594 @code{non-core}.
9595
9596 The @code{core} subset refers to all the packages at the core of the
9597 distribution---i.e., packages that are used to build ``everything
9598 else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
9599 changing one of these packages in the distribution entails a rebuild of
9600 all the others. Thus, such updates are an inconvenience to users in
9601 terms of build time or bandwidth used to achieve the upgrade.
9602
9603 The @code{non-core} subset refers to the remaining packages. It is
9604 typically useful in cases where an update of the core packages would be
9605 inconvenient.
9606
9607 @item --manifest=@var{file}
9608 @itemx -m @var{file}
9609 Select all the packages from the manifest in @var{file}. This is useful to
9610 check if any packages of the user manifest can be updated.
9611
9612 @item --type=@var{updater}
9613 @itemx -t @var{updater}
9614 Select only packages handled by @var{updater} (may be a comma-separated
9615 list of updaters). Currently, @var{updater} may be one of:
9616
9617 @table @code
9618 @item gnu
9619 the updater for GNU packages;
9620 @item gnome
9621 the updater for GNOME packages;
9622 @item kde
9623 the updater for KDE packages;
9624 @item xorg
9625 the updater for X.org packages;
9626 @item kernel.org
9627 the updater for packages hosted on kernel.org;
9628 @item elpa
9629 the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
9630 @item cran
9631 the updater for @uref{https://cran.r-project.org/, CRAN} packages;
9632 @item bioconductor
9633 the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
9634 @item cpan
9635 the updater for @uref{https://www.cpan.org/, CPAN} packages;
9636 @item pypi
9637 the updater for @uref{https://pypi.python.org, PyPI} packages.
9638 @item gem
9639 the updater for @uref{https://rubygems.org, RubyGems} packages.
9640 @item github
9641 the updater for @uref{https://github.com, GitHub} packages.
9642 @item hackage
9643 the updater for @uref{https://hackage.haskell.org, Hackage} packages.
9644 @item stackage
9645 the updater for @uref{https://www.stackage.org, Stackage} packages.
9646 @item crate
9647 the updater for @uref{https://crates.io, Crates} packages.
9648 @item launchpad
9649 the updater for @uref{https://launchpad.net, Launchpad} packages.
9650 @end table
9651
9652 For instance, the following command only checks for updates of Emacs
9653 packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
9654
9655 @example
9656 $ guix refresh --type=elpa,cran
9657 gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
9658 gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
9659 @end example
9660
9661 @end table
9662
9663 In addition, @command{guix refresh} can be passed one or more package
9664 names, as in this example:
9665
9666 @example
9667 $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
9668 @end example
9669
9670 @noindent
9671 The command above specifically updates the @code{emacs} and
9672 @code{idutils} packages. The @option{--select} option would have no
9673 effect in this case.
9674
9675 When considering whether to upgrade a package, it is sometimes
9676 convenient to know which packages would be affected by the upgrade and
9677 should be checked for compatibility. For this the following option may
9678 be used when passing @command{guix refresh} one or more package names:
9679
9680 @table @code
9681
9682 @item --list-updaters
9683 @itemx -L
9684 List available updaters and exit (see @option{--type} above.)
9685
9686 For each updater, display the fraction of packages it covers; at the
9687 end, display the fraction of packages covered by all these updaters.
9688
9689 @item --list-dependent
9690 @itemx -l
9691 List top-level dependent packages that would need to be rebuilt as a
9692 result of upgrading one or more packages.
9693
9694 @xref{Invoking guix graph, the @code{reverse-package} type of
9695 @command{guix graph}}, for information on how to visualize the list of
9696 dependents of a package.
9697
9698 @end table
9699
9700 Be aware that the @option{--list-dependent} option only
9701 @emph{approximates} the rebuilds that would be required as a result of
9702 an upgrade. More rebuilds might be required under some circumstances.
9703
9704 @example
9705 $ guix refresh --list-dependent flex
9706 Building the following 120 packages would ensure 213 dependent packages are rebuilt:
9707 hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
9708 @end example
9709
9710 The command above lists a set of packages that could be built to check
9711 for compatibility with an upgraded @code{flex} package.
9712
9713 @table @code
9714
9715 @item --list-transitive
9716 List all the packages which one or more packages depend upon.
9717
9718 @example
9719 $ guix refresh --list-transitive flex
9720 flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
9721 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{}
9722 @end example
9723
9724 @end table
9725
9726 The command above lists a set of packages which, when changed, would cause
9727 @code{flex} to be rebuilt.
9728
9729 The following options can be used to customize GnuPG operation:
9730
9731 @table @code
9732
9733 @item --gpg=@var{command}
9734 Use @var{command} as the GnuPG 2.x command. @var{command} is searched
9735 for in @code{$PATH}.
9736
9737 @item --keyring=@var{file}
9738 Use @var{file} as the keyring for upstream keys. @var{file} must be in the
9739 @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
9740 and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
9741 (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
9742 information on a tool to manipulate keybox files).
9743
9744 When this option is omitted, @command{guix refresh} uses
9745 @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
9746 signing keys. OpenPGP signatures are checked against keys from this keyring;
9747 missing keys are downloaded to this keyring as well (see
9748 @option{--key-download} below.)
9749
9750 You can export keys from your default GPG keyring into a keybox file using
9751 commands like this one:
9752
9753 @example
9754 gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
9755 @end example
9756
9757 Likewise, you can fetch keys to a specific keybox file like this:
9758
9759 @example
9760 gpg --no-default-keyring --keyring mykeyring.kbx \
9761 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
9762 @end example
9763
9764 @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
9765 Privacy Guard}, for more information on GPG's @option{--keyring} option.
9766
9767 @item --key-download=@var{policy}
9768 Handle missing OpenPGP keys according to @var{policy}, which may be one
9769 of:
9770
9771 @table @code
9772 @item always
9773 Always download missing OpenPGP keys from the key server, and add them
9774 to the user's GnuPG keyring.
9775
9776 @item never
9777 Never try to download missing OpenPGP keys. Instead just bail out.
9778
9779 @item interactive
9780 When a package signed with an unknown OpenPGP key is encountered, ask
9781 the user whether to download it or not. This is the default behavior.
9782 @end table
9783
9784 @item --key-server=@var{host}
9785 Use @var{host} as the OpenPGP key server when importing a public key.
9786
9787 @item --load-path=@var{directory}
9788 Add @var{directory} to the front of the package module search path
9789 (@pxref{Package Modules}).
9790
9791 This allows users to define their own packages and make them visible to
9792 the command-line tools.
9793
9794 @end table
9795
9796 The @code{github} updater uses the
9797 @uref{https://developer.github.com/v3/, GitHub API} to query for new
9798 releases. When used repeatedly e.g.@: when refreshing all packages,
9799 GitHub will eventually refuse to answer any further API requests. By
9800 default 60 API requests per hour are allowed, and a full refresh on all
9801 GitHub packages in Guix requires more than this. Authentication with
9802 GitHub through the use of an API token alleviates these limits. To use
9803 an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
9804 token procured from @uref{https://github.com/settings/tokens} or
9805 otherwise.
9806
9807
9808 @node Invoking guix lint
9809 @section Invoking @command{guix lint}
9810
9811 @cindex @command{guix lint}
9812 @cindex package, checking for errors
9813 The @command{guix lint} command is meant to help package developers avoid
9814 common errors and use a consistent style. It runs a number of checks on
9815 a given set of packages in order to find common mistakes in their
9816 definitions. Available @dfn{checkers} include (see
9817 @option{--list-checkers} for a complete list):
9818
9819 @table @code
9820 @item synopsis
9821 @itemx description
9822 Validate certain typographical and stylistic rules about package
9823 descriptions and synopses.
9824
9825 @item inputs-should-be-native
9826 Identify inputs that should most likely be native inputs.
9827
9828 @item source
9829 @itemx home-page
9830 @itemx mirror-url
9831 @itemx github-url
9832 @itemx source-file-name
9833 Probe @code{home-page} and @code{source} URLs and report those that are
9834 invalid. Suggest a @code{mirror://} URL when applicable. If the
9835 @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
9836 URL. Check that the source file name is meaningful, e.g.@: is not just a
9837 version number or ``git-checkout'', without a declared @code{file-name}
9838 (@pxref{origin Reference}).
9839
9840 @item source-unstable-tarball
9841 Parse the @code{source} URL to determine if a tarball from GitHub is
9842 autogenerated or if it is a release tarball. Unfortunately GitHub's
9843 autogenerated tarballs are sometimes regenerated.
9844
9845 @item archival
9846 @cindex Software Heritage, source code archive
9847 @cindex archival of source code, Software Heritage
9848 Checks whether the package's source code is archived at
9849 @uref{https://www.softwareheritage.org, Software Heritage}.
9850
9851 When the source code that is not archived comes from a version-control system
9852 (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
9853 ``save'' request so that it eventually archives it. This ensures that the
9854 source will remain available in the long term, and that Guix can fall back to
9855 Software Heritage should the source code disappear from its original host.
9856 The status of recent ``save'' requests can be
9857 @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
9858
9859 When source code is a tarball obtained with @code{url-fetch}, simply print a
9860 message when it is not archived. As of this writing, Software Heritage does
9861 not allow requests to save arbitrary tarballs; we are working on ways to
9862 ensure that non-VCS source code is also archived.
9863
9864 Software Heritage
9865 @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
9866 request rate per IP address}. When the limit is reached, @command{guix lint}
9867 prints a message and the @code{archival} checker stops doing anything until
9868 that limit has been reset.
9869
9870 @item cve
9871 @cindex security vulnerabilities
9872 @cindex CVE, Common Vulnerabilities and Exposures
9873 Report known vulnerabilities found in the Common Vulnerabilities and
9874 Exposures (CVE) databases of the current and past year
9875 @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
9876 NIST}.
9877
9878 To view information about a particular vulnerability, visit pages such as:
9879
9880 @itemize
9881 @item
9882 @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
9883 @item
9884 @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
9885 @end itemize
9886
9887 @noindent
9888 where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
9889 @code{CVE-2015-7554}.
9890
9891 Package developers can specify in package recipes the
9892 @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
9893 name and version of the package when they differ from the name or version
9894 that Guix uses, as in this example:
9895
9896 @lisp
9897 (package
9898 (name "grub")
9899 ;; @dots{}
9900 ;; CPE calls this package "grub2".
9901 (properties '((cpe-name . "grub2")
9902 (cpe-version . "2.3"))))
9903 @end lisp
9904
9905 @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
9906 Some entries in the CVE database do not specify which version of a
9907 package they apply to, and would thus ``stick around'' forever. Package
9908 developers who found CVE alerts and verified they can be ignored can
9909 declare them as in this example:
9910
9911 @lisp
9912 (package
9913 (name "t1lib")
9914 ;; @dots{}
9915 ;; These CVEs no longer apply and can be safely ignored.
9916 (properties `((lint-hidden-cve . ("CVE-2011-0433"
9917 "CVE-2011-1553"
9918 "CVE-2011-1554"
9919 "CVE-2011-5244")))))
9920 @end lisp
9921
9922 @item formatting
9923 Warn about obvious source code formatting issues: trailing white space,
9924 use of tabulations, etc.
9925 @end table
9926
9927 The general syntax is:
9928
9929 @example
9930 guix lint @var{options} @var{package}@dots{}
9931 @end example
9932
9933 If no package is given on the command line, then all packages are checked.
9934 The @var{options} may be zero or more of the following:
9935
9936 @table @code
9937 @item --list-checkers
9938 @itemx -l
9939 List and describe all the available checkers that will be run on packages
9940 and exit.
9941
9942 @item --checkers
9943 @itemx -c
9944 Only enable the checkers specified in a comma-separated list using the
9945 names returned by @option{--list-checkers}.
9946
9947 @item --load-path=@var{directory}
9948 @itemx -L @var{directory}
9949 Add @var{directory} to the front of the package module search path
9950 (@pxref{Package Modules}).
9951
9952 This allows users to define their own packages and make them visible to
9953 the command-line tools.
9954
9955 @end table
9956
9957 @node Invoking guix size
9958 @section Invoking @command{guix size}
9959
9960 @cindex size
9961 @cindex package size
9962 @cindex closure
9963 @cindex @command{guix size}
9964 The @command{guix size} command helps package developers profile the
9965 disk usage of packages. It is easy to overlook the impact of an
9966 additional dependency added to a package, or the impact of using a
9967 single output for a package that could easily be split (@pxref{Packages
9968 with Multiple Outputs}). Such are the typical issues that
9969 @command{guix size} can highlight.
9970
9971 The command can be passed one or more package specifications
9972 such as @code{gcc@@4.8}
9973 or @code{guile:debug}, or a file name in the store. Consider this
9974 example:
9975
9976 @example
9977 $ guix size coreutils
9978 store item total self
9979 /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
9980 /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
9981 /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
9982 /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
9983 /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
9984 /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
9985 /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
9986 /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
9987 total: 78.9 MiB
9988 @end example
9989
9990 @cindex closure
9991 The store items listed here constitute the @dfn{transitive closure} of
9992 Coreutils---i.e., Coreutils and all its dependencies, recursively---as
9993 would be returned by:
9994
9995 @example
9996 $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
9997 @end example
9998
9999 Here the output shows three columns next to store items. The first column,
10000 labeled ``total'', shows the size in mebibytes (MiB) of the closure of
10001 the store item---that is, its own size plus the size of all its
10002 dependencies. The next column, labeled ``self'', shows the size of the
10003 item itself. The last column shows the ratio of the size of the item
10004 itself to the space occupied by all the items listed here.
10005
10006 In this example, we see that the closure of Coreutils weighs in at
10007 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
10008 libraries. (That libc and GCC's libraries represent a large fraction of
10009 the closure is not a problem @i{per se} because they are always available
10010 on the system anyway.)
10011
10012 When the package(s) passed to @command{guix size} are available in the
10013 store@footnote{More precisely, @command{guix size} looks for the
10014 @emph{ungrafted} variant of the given package(s), as returned by
10015 @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
10016 for information on grafts.}, @command{guix size} queries the daemon to determine its
10017 dependencies, and measures its size in the store, similar to @command{du
10018 -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
10019 Coreutils}).
10020
10021 When the given packages are @emph{not} in the store, @command{guix size}
10022 reports information based on the available substitutes
10023 (@pxref{Substitutes}). This makes it possible it to profile disk usage of
10024 store items that are not even on disk, only available remotely.
10025
10026 You can also specify several package names:
10027
10028 @example
10029 $ guix size coreutils grep sed bash
10030 store item total self
10031 /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
10032 /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
10033 /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
10034 /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
10035 @dots{}
10036 total: 102.3 MiB
10037 @end example
10038
10039 @noindent
10040 In this example we see that the combination of the four packages takes
10041 102.3@tie{}MiB in total, which is much less than the sum of each closure
10042 since they have a lot of dependencies in common.
10043
10044 When looking at the profile returned by @command{guix size}, you may
10045 find yourself wondering why a given package shows up in the profile at
10046 all. To understand it, you can use @command{guix graph --path -t
10047 references} to display the shortest path between the two packages
10048 (@pxref{Invoking guix graph}).
10049
10050 The available options are:
10051
10052 @table @option
10053
10054 @item --substitute-urls=@var{urls}
10055 Use substitute information from @var{urls}.
10056 @xref{client-substitute-urls, the same option for @code{guix build}}.
10057
10058 @item --sort=@var{key}
10059 Sort lines according to @var{key}, one of the following options:
10060
10061 @table @code
10062 @item self
10063 the size of each item (the default);
10064 @item closure
10065 the total size of the item's closure.
10066 @end table
10067
10068 @item --map-file=@var{file}
10069 Write a graphical map of disk usage in PNG format to @var{file}.
10070
10071 For the example above, the map looks like this:
10072
10073 @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
10074 produced by @command{guix size}}
10075
10076 This option requires that
10077 @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
10078 installed and visible in Guile's module search path. When that is not
10079 the case, @command{guix size} fails as it tries to load it.
10080
10081 @item --system=@var{system}
10082 @itemx -s @var{system}
10083 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
10084
10085 @item --load-path=@var{directory}
10086 @itemx -L @var{directory}
10087 Add @var{directory} to the front of the package module search path
10088 (@pxref{Package Modules}).
10089
10090 This allows users to define their own packages and make them visible to
10091 the command-line tools.
10092 @end table
10093
10094 @node Invoking guix graph
10095 @section Invoking @command{guix graph}
10096
10097 @cindex DAG
10098 @cindex @command{guix graph}
10099 @cindex package dependencies
10100 Packages and their dependencies form a @dfn{graph}, specifically a
10101 directed acyclic graph (DAG). It can quickly become difficult to have a
10102 mental model of the package DAG, so the @command{guix graph} command
10103 provides a visual representation of the DAG. By default,
10104 @command{guix graph} emits a DAG representation in the input format of
10105 @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
10106 directly to the @command{dot} command of Graphviz. It can also emit an
10107 HTML page with embedded JavaScript code to display a ``chord diagram''
10108 in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
10109 emit Cypher queries to construct a graph in a graph database supporting
10110 the @uref{https://www.opencypher.org/, openCypher} query language. With
10111 @option{--path}, it simply displays the shortest path between two
10112 packages. The general syntax is:
10113
10114 @example
10115 guix graph @var{options} @var{package}@dots{}
10116 @end example
10117
10118 For example, the following command generates a PDF file representing the
10119 package DAG for the GNU@tie{}Core Utilities, showing its build-time
10120 dependencies:
10121
10122 @example
10123 guix graph coreutils | dot -Tpdf > dag.pdf
10124 @end example
10125
10126 The output looks like this:
10127
10128 @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
10129
10130 Nice little graph, no?
10131
10132 You may find it more pleasant to navigate the graph interactively with
10133 @command{xdot} (from the @code{xdot} package):
10134
10135 @example
10136 guix graph coreutils | xdot -
10137 @end example
10138
10139 But there is more than one graph! The one above is concise: it is the
10140 graph of package objects, omitting implicit inputs such as GCC, libc,
10141 grep, etc. It is often useful to have such a concise graph, but
10142 sometimes one may want to see more details. @command{guix graph} supports
10143 several types of graphs, allowing you to choose the level of detail:
10144
10145 @table @code
10146 @item package
10147 This is the default type used in the example above. It shows the DAG of
10148 package objects, excluding implicit dependencies. It is concise, but
10149 filters out many details.
10150
10151 @item reverse-package
10152 This shows the @emph{reverse} DAG of packages. For example:
10153
10154 @example
10155 guix graph --type=reverse-package ocaml
10156 @end example
10157
10158 ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
10159 you are also interested in cases where OCaml is an implicit dependency, see
10160 @code{reverse-bag} below.)
10161
10162 Note that for core packages this can yield huge graphs. If all you want
10163 is to know the number of packages that depend on a given package, use
10164 @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
10165 @option{--list-dependent}}).
10166
10167 @item bag-emerged
10168 This is the package DAG, @emph{including} implicit inputs.
10169
10170 For instance, the following command:
10171
10172 @example
10173 guix graph --type=bag-emerged coreutils
10174 @end example
10175
10176 ...@: yields this bigger graph:
10177
10178 @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
10179
10180 At the bottom of the graph, we see all the implicit inputs of
10181 @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
10182
10183 Now, note that the dependencies of these implicit inputs---that is, the
10184 @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
10185 here, for conciseness.
10186
10187 @item bag
10188 Similar to @code{bag-emerged}, but this time including all the bootstrap
10189 dependencies.
10190
10191 @item bag-with-origins
10192 Similar to @code{bag}, but also showing origins and their dependencies.
10193
10194 @item reverse-bag
10195 This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
10196 it also takes implicit dependencies into account. For example:
10197
10198 @example
10199 guix graph -t reverse-bag dune
10200 @end example
10201
10202 @noindent
10203 ...@: yields the graph of all packages that depend on Dune, directly or
10204 indirectly. Since Dune is an @emph{implicit} dependency of many packages
10205 @i{via} @code{dune-build-system}, this shows a large number of packages,
10206 whereas @code{reverse-package} would show very few if any.
10207
10208 @item derivation
10209 This is the most detailed representation: It shows the DAG of
10210 derivations (@pxref{Derivations}) and plain store items. Compared to
10211 the above representation, many additional nodes are visible, including
10212 build scripts, patches, Guile modules, etc.
10213
10214 For this type of graph, it is also possible to pass a @file{.drv} file
10215 name instead of a package name, as in:
10216
10217 @example
10218 guix graph -t derivation `guix system build -d my-config.scm`
10219 @end example
10220
10221 @item module
10222 This is the graph of @dfn{package modules} (@pxref{Package Modules}).
10223 For example, the following command shows the graph for the package
10224 module that defines the @code{guile} package:
10225
10226 @example
10227 guix graph -t module guile | xdot -
10228 @end example
10229 @end table
10230
10231 All the types above correspond to @emph{build-time dependencies}. The
10232 following graph type represents the @emph{run-time dependencies}:
10233
10234 @table @code
10235 @item references
10236 This is the graph of @dfn{references} of a package output, as returned
10237 by @command{guix gc --references} (@pxref{Invoking guix gc}).
10238
10239 If the given package output is not available in the store, @command{guix
10240 graph} attempts to obtain dependency information from substitutes.
10241
10242 Here you can also pass a store file name instead of a package name. For
10243 example, the command below produces the reference graph of your profile
10244 (which can be big!):
10245
10246 @example
10247 guix graph -t references `readlink -f ~/.guix-profile`
10248 @end example
10249
10250 @item referrers
10251 This is the graph of the @dfn{referrers} of a store item, as returned by
10252 @command{guix gc --referrers} (@pxref{Invoking guix gc}).
10253
10254 This relies exclusively on local information from your store. For
10255 instance, let us suppose that the current Inkscape is available in 10
10256 profiles on your machine; @command{guix graph -t referrers inkscape}
10257 will show a graph rooted at Inkscape and with those 10 profiles linked
10258 to it.
10259
10260 It can help determine what is preventing a store item from being garbage
10261 collected.
10262
10263 @end table
10264
10265 @cindex shortest path, between packages
10266 Often, the graph of the package you are interested in does not fit on
10267 your screen, and anyway all you want to know is @emph{why} that package
10268 actually depends on some seemingly unrelated package. The
10269 @option{--path} option instructs @command{guix graph} to display the
10270 shortest path between two packages (or derivations, or store items,
10271 etc.):
10272
10273 @example
10274 $ guix graph --path emacs libunistring
10275 emacs@@26.3
10276 mailutils@@3.9
10277 libunistring@@0.9.10
10278 $ guix graph --path -t derivation emacs libunistring
10279 /gnu/store/@dots{}-emacs-26.3.drv
10280 /gnu/store/@dots{}-mailutils-3.9.drv
10281 /gnu/store/@dots{}-libunistring-0.9.10.drv
10282 $ guix graph --path -t references emacs libunistring
10283 /gnu/store/@dots{}-emacs-26.3
10284 /gnu/store/@dots{}-libidn2-2.2.0
10285 /gnu/store/@dots{}-libunistring-0.9.10
10286 @end example
10287
10288 The available options are the following:
10289
10290 @table @option
10291 @item --type=@var{type}
10292 @itemx -t @var{type}
10293 Produce a graph output of @var{type}, where @var{type} must be one of
10294 the values listed above.
10295
10296 @item --list-types
10297 List the supported graph types.
10298
10299 @item --backend=@var{backend}
10300 @itemx -b @var{backend}
10301 Produce a graph using the selected @var{backend}.
10302
10303 @item --list-backends
10304 List the supported graph backends.
10305
10306 Currently, the available backends are Graphviz and d3.js.
10307
10308 @item --path
10309 Display the shortest path between two nodes of the type specified by
10310 @option{--type}. The example below shows the shortest path between
10311 @code{libreoffice} and @code{llvm} according to the references of
10312 @code{libreoffice}:
10313
10314 @example
10315 $ guix graph --path -t references libreoffice llvm
10316 /gnu/store/@dots{}-libreoffice-6.4.2.2
10317 /gnu/store/@dots{}-libepoxy-1.5.4
10318 /gnu/store/@dots{}-mesa-19.3.4
10319 /gnu/store/@dots{}-llvm-9.0.1
10320 @end example
10321
10322 @item --expression=@var{expr}
10323 @itemx -e @var{expr}
10324 Consider the package @var{expr} evaluates to.
10325
10326 This is useful to precisely refer to a package, as in this example:
10327
10328 @example
10329 guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
10330 @end example
10331
10332 @item --system=@var{system}
10333 @itemx -s @var{system}
10334 Display the graph for @var{system}---e.g., @code{i686-linux}.
10335
10336 The package dependency graph is largely architecture-independent, but there
10337 are some architecture-dependent bits that this option allows you to visualize.
10338
10339 @item --load-path=@var{directory}
10340 @itemx -L @var{directory}
10341 Add @var{directory} to the front of the package module search path
10342 (@pxref{Package Modules}).
10343
10344 This allows users to define their own packages and make them visible to
10345 the command-line tools.
10346 @end table
10347
10348 On top of that, @command{guix graph} supports all the usual package
10349 transformation options (@pxref{Package Transformation Options}). This
10350 makes it easy to view the effect of a graph-rewriting transformation
10351 such as @option{--with-input}. For example, the command below outputs
10352 the graph of @code{git} once @code{openssl} has been replaced by
10353 @code{libressl} everywhere in the graph:
10354
10355 @example
10356 guix graph git --with-input=openssl=libressl
10357 @end example
10358
10359 So many possibilities, so much fun!
10360
10361 @node Invoking guix publish
10362 @section Invoking @command{guix publish}
10363
10364 @cindex @command{guix publish}
10365 The purpose of @command{guix publish} is to enable users to easily share
10366 their store with others, who can then use it as a substitute server
10367 (@pxref{Substitutes}).
10368
10369 When @command{guix publish} runs, it spawns an HTTP server which allows
10370 anyone with network access to obtain substitutes from it. This means
10371 that any machine running Guix can also act as if it were a build farm,
10372 since the HTTP interface is compatible with Cuirass, the software behind
10373 the @code{@value{SUBSTITUTE-SERVER}} build farm.
10374
10375 For security, each substitute is signed, allowing recipients to check
10376 their authenticity and integrity (@pxref{Substitutes}). Because
10377 @command{guix publish} uses the signing key of the system, which is only
10378 readable by the system administrator, it must be started as root; the
10379 @option{--user} option makes it drop root privileges early on.
10380
10381 The signing key pair must be generated before @command{guix publish} is
10382 launched, using @command{guix archive --generate-key} (@pxref{Invoking
10383 guix archive}).
10384
10385 The general syntax is:
10386
10387 @example
10388 guix publish @var{options}@dots{}
10389 @end example
10390
10391 Running @command{guix publish} without any additional arguments will
10392 spawn an HTTP server on port 8080:
10393
10394 @example
10395 guix publish
10396 @end example
10397
10398 Once a publishing server has been authorized (@pxref{Invoking guix
10399 archive}), the daemon may download substitutes from it:
10400
10401 @example
10402 guix-daemon --substitute-urls=http://example.org:8080
10403 @end example
10404
10405 By default, @command{guix publish} compresses archives on the fly as it
10406 serves them. This ``on-the-fly'' mode is convenient in that it requires
10407 no setup and is immediately available. However, when serving lots of
10408 clients, we recommend using the @option{--cache} option, which enables
10409 caching of the archives before they are sent to clients---see below for
10410 details. The @command{guix weather} command provides a handy way to
10411 check what a server provides (@pxref{Invoking guix weather}).
10412
10413 As a bonus, @command{guix publish} also serves as a content-addressed
10414 mirror for source files referenced in @code{origin} records
10415 (@pxref{origin Reference}). For instance, assuming @command{guix
10416 publish} is running on @code{example.org}, the following URL returns the
10417 raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
10418 (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
10419
10420 @example
10421 http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
10422 @end example
10423
10424 Obviously, these URLs only work for files that are in the store; in
10425 other cases, they return 404 (``Not Found'').
10426
10427 @cindex build logs, publication
10428 Build logs are available from @code{/log} URLs like:
10429
10430 @example
10431 http://example.org/log/gwspk@dots{}-guile-2.2.3
10432 @end example
10433
10434 @noindent
10435 When @command{guix-daemon} is configured to save compressed build logs,
10436 as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
10437 URLs return the compressed log as-is, with an appropriate
10438 @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
10439 running @command{guix-daemon} with @option{--log-compression=gzip} since
10440 Web browsers can automatically decompress it, which is not the case with
10441 Bzip2 compression.
10442
10443 The following options are available:
10444
10445 @table @code
10446 @item --port=@var{port}
10447 @itemx -p @var{port}
10448 Listen for HTTP requests on @var{port}.
10449
10450 @item --listen=@var{host}
10451 Listen on the network interface for @var{host}. The default is to
10452 accept connections from any interface.
10453
10454 @item --user=@var{user}
10455 @itemx -u @var{user}
10456 Change privileges to @var{user} as soon as possible---i.e., once the
10457 server socket is open and the signing key has been read.
10458
10459 @item --compression[=@var{method}[:@var{level}]]
10460 @itemx -C [@var{method}[:@var{level}]]
10461 Compress data using the given @var{method} and @var{level}. @var{method} is
10462 one of @code{lzip} and @code{gzip}; when @var{method} is omitted, @code{gzip}
10463 is used.
10464
10465 When @var{level} is zero, disable compression. The range 1 to 9 corresponds
10466 to different compression levels: 1 is the fastest, and 9 is the best
10467 (CPU-intensive). The default is 3.
10468
10469 Usually, @code{lzip} compresses noticeably better than @code{gzip} for a small
10470 increase in CPU usage; see
10471 @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip Web
10472 page}.
10473
10474 Unless @option{--cache} is used, compression occurs on the fly and
10475 the compressed streams are not
10476 cached. Thus, to reduce load on the machine that runs @command{guix
10477 publish}, it may be a good idea to choose a low compression level, to
10478 run @command{guix publish} behind a caching proxy, or to use
10479 @option{--cache}. Using @option{--cache} has the advantage that it
10480 allows @command{guix publish} to add @code{Content-Length} HTTP header
10481 to its responses.
10482
10483 This option can be repeated, in which case every substitute gets compressed
10484 using all the selected methods, and all of them are advertised. This is
10485 useful when users may not support all the compression methods: they can select
10486 the one they support.
10487
10488 @item --cache=@var{directory}
10489 @itemx -c @var{directory}
10490 Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
10491 and only serve archives that are in cache.
10492
10493 When this option is omitted, archives and meta-data are created
10494 on-the-fly. This can reduce the available bandwidth, especially when
10495 compression is enabled, since this may become CPU-bound. Another
10496 drawback of the default mode is that the length of archives is not known
10497 in advance, so @command{guix publish} does not add a
10498 @code{Content-Length} HTTP header to its responses, which in turn
10499 prevents clients from knowing the amount of data being downloaded.
10500
10501 Conversely, when @option{--cache} is used, the first request for a store
10502 item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
10503 background process to @dfn{bake} the archive---computing its
10504 @code{.narinfo} and compressing the archive, if needed. Once the
10505 archive is cached in @var{directory}, subsequent requests succeed and
10506 are served directly from the cache, which guarantees that clients get
10507 the best possible bandwidth.
10508
10509 The ``baking'' process is performed by worker threads. By default, one
10510 thread per CPU core is created, but this can be customized. See
10511 @option{--workers} below.
10512
10513 When @option{--ttl} is used, cached entries are automatically deleted
10514 when they have expired.
10515
10516 @item --workers=@var{N}
10517 When @option{--cache} is used, request the allocation of @var{N} worker
10518 threads to ``bake'' archives.
10519
10520 @item --ttl=@var{ttl}
10521 Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
10522 (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
10523 days, @code{1m} means 1 month, and so on.
10524
10525 This allows the user's Guix to keep substitute information in cache for
10526 @var{ttl}. However, note that @code{guix publish} does not itself
10527 guarantee that the store items it provides will indeed remain available
10528 for as long as @var{ttl}.
10529
10530 Additionally, when @option{--cache} is used, cached entries that have
10531 not been accessed for @var{ttl} and that no longer have a corresponding
10532 item in the store, may be deleted.
10533
10534 @item --nar-path=@var{path}
10535 Use @var{path} as the prefix for the URLs of ``nar'' files
10536 (@pxref{Invoking guix archive, normalized archives}).
10537
10538 By default, nars are served at a URL such as
10539 @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
10540 change the @code{/nar} part to @var{path}.
10541
10542 @item --public-key=@var{file}
10543 @itemx --private-key=@var{file}
10544 Use the specific @var{file}s as the public/private key pair used to sign
10545 the store items being published.
10546
10547 The files must correspond to the same key pair (the private key is used
10548 for signing and the public key is merely advertised in the signature
10549 metadata). They must contain keys in the canonical s-expression format
10550 as produced by @command{guix archive --generate-key} (@pxref{Invoking
10551 guix archive}). By default, @file{/etc/guix/signing-key.pub} and
10552 @file{/etc/guix/signing-key.sec} are used.
10553
10554 @item --repl[=@var{port}]
10555 @itemx -r [@var{port}]
10556 Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
10557 Reference Manual}) on @var{port} (37146 by default). This is used
10558 primarily for debugging a running @command{guix publish} server.
10559 @end table
10560
10561 Enabling @command{guix publish} on Guix System is a one-liner: just
10562 instantiate a @code{guix-publish-service-type} service in the @code{services} field
10563 of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
10564 @code{guix-publish-service-type}}).
10565
10566 If you are instead running Guix on a ``foreign distro'', follow these
10567 instructions:
10568
10569 @itemize
10570 @item
10571 If your host distro uses the systemd init system:
10572
10573 @example
10574 # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
10575 /etc/systemd/system/
10576 # systemctl start guix-publish && systemctl enable guix-publish
10577 @end example
10578
10579 @item
10580 If your host distro uses the Upstart init system:
10581
10582 @example
10583 # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
10584 # start guix-publish
10585 @end example
10586
10587 @item
10588 Otherwise, proceed similarly with your distro's init system.
10589 @end itemize
10590
10591 @node Invoking guix challenge
10592 @section Invoking @command{guix challenge}
10593
10594 @cindex reproducible builds
10595 @cindex verifiable builds
10596 @cindex @command{guix challenge}
10597 @cindex challenge
10598 Do the binaries provided by this server really correspond to the source
10599 code it claims to build? Is a package build process deterministic?
10600 These are the questions the @command{guix challenge} command attempts to
10601 answer.
10602
10603 The former is obviously an important question: Before using a substitute
10604 server (@pxref{Substitutes}), one had better @emph{verify} that it
10605 provides the right binaries, and thus @emph{challenge} it. The latter
10606 is what enables the former: If package builds are deterministic, then
10607 independent builds of the package should yield the exact same result,
10608 bit for bit; if a server provides a binary different from the one
10609 obtained locally, it may be either corrupt or malicious.
10610
10611 We know that the hash that shows up in @file{/gnu/store} file names is
10612 the hash of all the inputs of the process that built the file or
10613 directory---compilers, libraries, build scripts,
10614 etc. (@pxref{Introduction}). Assuming deterministic build processes,
10615 one store file name should map to exactly one build output.
10616 @command{guix challenge} checks whether there is, indeed, a single
10617 mapping by comparing the build outputs of several independent builds of
10618 any given store item.
10619
10620 The command output looks like this:
10621
10622 @smallexample
10623 $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
10624 updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
10625 updating list of substitutes from 'https://guix.example.org'... 100.0%
10626 /gnu/store/@dots{}-openssl-1.0.2d contents differ:
10627 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
10628 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
10629 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
10630 differing files:
10631 /lib/libcrypto.so.1.1
10632 /lib/libssl.so.1.1
10633
10634 /gnu/store/@dots{}-git-2.5.0 contents differ:
10635 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
10636 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
10637 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
10638 differing file:
10639 /libexec/git-core/git-fsck
10640
10641 /gnu/store/@dots{}-pius-2.1.1 contents differ:
10642 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
10643 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
10644 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
10645 differing file:
10646 /share/man/man1/pius.1.gz
10647
10648 @dots{}
10649
10650 6,406 store items were analyzed:
10651 - 4,749 (74.1%) were identical
10652 - 525 (8.2%) differed
10653 - 1,132 (17.7%) were inconclusive
10654 @end smallexample
10655
10656 @noindent
10657 In this example, @command{guix challenge} first scans the store to
10658 determine the set of locally-built derivations---as opposed to store
10659 items that were downloaded from a substitute server---and then queries
10660 all the substitute servers. It then reports those store items for which
10661 the servers obtained a result different from the local build.
10662
10663 @cindex non-determinism, in package builds
10664 As an example, @code{guix.example.org} always gets a different answer.
10665 Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
10666 case of Git. This might indicate that the build process of Git is
10667 non-deterministic, meaning that its output varies as a function of
10668 various things that Guix does not fully control, in spite of building
10669 packages in isolated environments (@pxref{Features}). Most common
10670 sources of non-determinism include the addition of timestamps in build
10671 results, the inclusion of random numbers, and directory listings sorted
10672 by inode number. See @uref{https://reproducible-builds.org/docs/}, for
10673 more information.
10674
10675 To find out what is wrong with this Git binary, the easiest approach is
10676 to run:
10677
10678 @example
10679 guix challenge git \
10680 --diff=diffoscope \
10681 --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
10682 @end example
10683
10684 This automatically invokes @command{diffoscope}, which displays detailed
10685 information about files that differ.
10686
10687 Alternately, we can do something along these lines (@pxref{Invoking guix
10688 archive}):
10689
10690 @example
10691 $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-git-2.5.0 \
10692 | lzip -d | guix archive -x /tmp/git
10693 $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
10694 @end example
10695
10696 This command shows the difference between the files resulting from the
10697 local build, and the files resulting from the build on
10698 @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
10699 diffutils, Comparing and Merging Files}). The @command{diff} command
10700 works great for text files. When binary files differ, a better option
10701 is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
10702 visualize differences for all kinds of files.
10703
10704 Once you have done that work, you can tell whether the differences are due
10705 to a non-deterministic build process or to a malicious server. We try
10706 hard to remove sources of non-determinism in packages to make it easier
10707 to verify substitutes, but of course, this is a process that
10708 involves not just Guix, but a large part of the free software community.
10709 In the meantime, @command{guix challenge} is one tool to help address
10710 the problem.
10711
10712 If you are writing packages for Guix, you are encouraged to check
10713 whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
10714 same build result as you did with:
10715
10716 @example
10717 $ guix challenge @var{package}
10718 @end example
10719
10720 @noindent
10721 where @var{package} is a package specification such as
10722 @code{guile@@2.0} or @code{glibc:debug}.
10723
10724 The general syntax is:
10725
10726 @example
10727 guix challenge @var{options} [@var{packages}@dots{}]
10728 @end example
10729
10730 When a difference is found between the hash of a locally-built item and
10731 that of a server-provided substitute, or among substitutes provided by
10732 different servers, the command displays it as in the example above and
10733 its exit code is 2 (other non-zero exit codes denote other kinds of
10734 errors.)
10735
10736 The one option that matters is:
10737
10738 @table @code
10739
10740 @item --substitute-urls=@var{urls}
10741 Consider @var{urls} the whitespace-separated list of substitute source
10742 URLs to compare to.
10743
10744 @item --diff=@var{mode}
10745 Upon mismatches, show differences according to @var{mode}, one of:
10746
10747 @table @asis
10748 @item @code{simple} (the default)
10749 Show the list of files that differ.
10750
10751 @item @code{diffoscope}
10752 @itemx @var{command}
10753 Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
10754 two directories whose contents do not match.
10755
10756 When @var{command} is an absolute file name, run @var{command} instead
10757 of Diffoscope.
10758
10759 @item @code{none}
10760 Do not show further details about the differences.
10761 @end table
10762
10763 Thus, unless @option{--diff=none} is passed, @command{guix challenge}
10764 downloads the store items from the given substitute servers so that it
10765 can compare them.
10766
10767 @item --verbose
10768 @itemx -v
10769 Show details about matches (identical contents) in addition to
10770 information about mismatches.
10771
10772 @end table
10773
10774 @node Invoking guix copy
10775 @section Invoking @command{guix copy}
10776
10777 @cindex copy, of store items, over SSH
10778 @cindex SSH, copy of store items
10779 @cindex sharing store items across machines
10780 @cindex transferring store items across machines
10781 The @command{guix copy} command copies items from the store of one
10782 machine to that of another machine over a secure shell (SSH)
10783 connection@footnote{This command is available only when Guile-SSH was
10784 found. @xref{Requirements}, for details.}. For example, the following
10785 command copies the @code{coreutils} package, the user's profile, and all
10786 their dependencies over to @var{host}, logged in as @var{user}:
10787
10788 @example
10789 guix copy --to=@var{user}@@@var{host} \
10790 coreutils `readlink -f ~/.guix-profile`
10791 @end example
10792
10793 If some of the items to be copied are already present on @var{host},
10794 they are not actually sent.
10795
10796 The command below retrieves @code{libreoffice} and @code{gimp} from
10797 @var{host}, assuming they are available there:
10798
10799 @example
10800 guix copy --from=@var{host} libreoffice gimp
10801 @end example
10802
10803 The SSH connection is established using the Guile-SSH client, which is
10804 compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
10805 @file{~/.ssh/config}, and uses the SSH agent for authentication.
10806
10807 The key used to sign items that are sent must be accepted by the remote
10808 machine. Likewise, the key used by the remote machine to sign items you
10809 are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
10810 own daemon. @xref{Invoking guix archive}, for more information about
10811 store item authentication.
10812
10813 The general syntax is:
10814
10815 @example
10816 guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
10817 @end example
10818
10819 You must always specify one of the following options:
10820
10821 @table @code
10822 @item --to=@var{spec}
10823 @itemx --from=@var{spec}
10824 Specify the host to send to or receive from. @var{spec} must be an SSH
10825 spec such as @code{example.org}, @code{charlie@@example.org}, or
10826 @code{charlie@@example.org:2222}.
10827 @end table
10828
10829 The @var{items} can be either package names, such as @code{gimp}, or
10830 store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
10831
10832 When specifying the name of a package to send, it is first built if
10833 needed, unless @option{--dry-run} was specified. Common build options
10834 are supported (@pxref{Common Build Options}).
10835
10836
10837 @node Invoking guix container
10838 @section Invoking @command{guix container}
10839 @cindex container
10840 @cindex @command{guix container}
10841 @quotation Note
10842 As of version @value{VERSION}, this tool is experimental. The interface
10843 is subject to radical change in the future.
10844 @end quotation
10845
10846 The purpose of @command{guix container} is to manipulate processes
10847 running within an isolated environment, commonly known as a
10848 ``container'', typically created by the @command{guix environment}
10849 (@pxref{Invoking guix environment}) and @command{guix system container}
10850 (@pxref{Invoking guix system}) commands.
10851
10852 The general syntax is:
10853
10854 @example
10855 guix container @var{action} @var{options}@dots{}
10856 @end example
10857
10858 @var{action} specifies the operation to perform with a container, and
10859 @var{options} specifies the context-specific arguments for the action.
10860
10861 The following actions are available:
10862
10863 @table @code
10864 @item exec
10865 Execute a command within the context of a running container.
10866
10867 The syntax is:
10868
10869 @example
10870 guix container exec @var{pid} @var{program} @var{arguments}@dots{}
10871 @end example
10872
10873 @var{pid} specifies the process ID of the running container.
10874 @var{program} specifies an executable file name within the root file
10875 system of the container. @var{arguments} are the additional options that
10876 will be passed to @var{program}.
10877
10878 The following command launches an interactive login shell inside a
10879 Guix system container, started by @command{guix system container}, and whose
10880 process ID is 9001:
10881
10882 @example
10883 guix container exec 9001 /run/current-system/profile/bin/bash --login
10884 @end example
10885
10886 Note that the @var{pid} cannot be the parent process of a container. It
10887 must be PID 1 of the container or one of its child processes.
10888
10889 @end table
10890
10891 @node Invoking guix weather
10892 @section Invoking @command{guix weather}
10893
10894 Occasionally you're grumpy because substitutes are lacking and you end
10895 up building packages by yourself (@pxref{Substitutes}). The
10896 @command{guix weather} command reports on substitute availability on the
10897 specified servers so you can have an idea of whether you'll be grumpy
10898 today. It can sometimes be useful info as a user, but it is primarily
10899 useful to people running @command{guix publish} (@pxref{Invoking guix
10900 publish}).
10901
10902 @cindex statistics, for substitutes
10903 @cindex availability of substitutes
10904 @cindex substitute availability
10905 @cindex weather, substitute availability
10906 Here's a sample run:
10907
10908 @example
10909 $ guix weather --substitute-urls=https://guix.example.org
10910 computing 5,872 package derivations for x86_64-linux...
10911 looking for 6,128 store items on https://guix.example.org..
10912 updating list of substitutes from 'https://guix.example.org'... 100.0%
10913 https://guix.example.org
10914 43.4% substitutes available (2,658 out of 6,128)
10915 7,032.5 MiB of nars (compressed)
10916 19,824.2 MiB on disk (uncompressed)
10917 0.030 seconds per request (182.9 seconds in total)
10918 33.5 requests per second
10919
10920 9.8% (342 out of 3,470) of the missing items are queued
10921 867 queued builds
10922 x86_64-linux: 518 (59.7%)
10923 i686-linux: 221 (25.5%)
10924 aarch64-linux: 128 (14.8%)
10925 build rate: 23.41 builds per hour
10926 x86_64-linux: 11.16 builds per hour
10927 i686-linux: 6.03 builds per hour
10928 aarch64-linux: 6.41 builds per hour
10929 @end example
10930
10931 @cindex continuous integration, statistics
10932 As you can see, it reports the fraction of all the packages for which
10933 substitutes are available on the server---regardless of whether
10934 substitutes are enabled, and regardless of whether this server's signing
10935 key is authorized. It also reports the size of the compressed archives
10936 (``nars'') provided by the server, the size the corresponding store
10937 items occupy in the store (assuming deduplication is turned off), and
10938 the server's throughput. The second part gives continuous integration
10939 (CI) statistics, if the server supports it. In addition, using the
10940 @option{--coverage} option, @command{guix weather} can list ``important''
10941 package substitutes missing on the server (see below).
10942
10943 To achieve that, @command{guix weather} queries over HTTP(S) meta-data
10944 (@dfn{narinfos}) for all the relevant store items. Like @command{guix
10945 challenge}, it ignores signatures on those substitutes, which is
10946 innocuous since the command only gathers statistics and cannot install
10947 those substitutes.
10948
10949 The general syntax is:
10950
10951 @example
10952 guix weather @var{options}@dots{} [@var{packages}@dots{}]
10953 @end example
10954
10955 When @var{packages} is omitted, @command{guix weather} checks the availability
10956 of substitutes for @emph{all} the packages, or for those specified with
10957 @option{--manifest}; otherwise it only considers the specified packages. It
10958 is also possible to query specific system types with @option{--system}.
10959 @command{guix weather} exits with a non-zero code when the fraction of
10960 available substitutes is below 100%.
10961
10962 The available options are listed below.
10963
10964 @table @code
10965 @item --substitute-urls=@var{urls}
10966 @var{urls} is the space-separated list of substitute server URLs to
10967 query. When this option is omitted, the default set of substitute
10968 servers is queried.
10969
10970 @item --system=@var{system}
10971 @itemx -s @var{system}
10972 Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
10973 option can be repeated, in which case @command{guix weather} will query
10974 substitutes for several system types.
10975
10976 @item --manifest=@var{file}
10977 Instead of querying substitutes for all the packages, only ask for those
10978 specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
10979 with the @code{-m} option of @command{guix package} (@pxref{Invoking
10980 guix package}).
10981
10982 This option can be repeated several times, in which case the manifests
10983 are concatenated.
10984
10985 @item --coverage[=@var{count}]
10986 @itemx -c [@var{count}]
10987 Report on substitute coverage for packages: list packages with at least
10988 @var{count} dependents (zero by default) for which substitutes are
10989 unavailable. Dependent packages themselves are not listed: if @var{b} depends
10990 on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
10991 @var{b} usually lacks substitutes as well. The result looks like this:
10992
10993 @example
10994 $ guix weather --substitute-urls=@value{SUBSTITUTE-URL} -c 10
10995 computing 8,983 package derivations for x86_64-linux...
10996 looking for 9,343 store items on @value{SUBSTITUTE-URL}...
10997 updating substitutes from '@value{SUBSTITUTE-URL}'... 100.0%
10998 @value{SUBSTITUTE-URL}
10999 64.7% substitutes available (6,047 out of 9,343)
11000 @dots{}
11001 2502 packages are missing from '@value{SUBSTITUTE-URL}' for 'x86_64-linux', among which:
11002 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
11003 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
11004 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
11005 @dots{}
11006 @end example
11007
11008 What this example shows is that @code{kcoreaddons} and presumably the 58
11009 packages that depend on it have no substitutes at @code{ci.guix.info};
11010 likewise for @code{qgpgme} and the 46 packages that depend on it.
11011
11012 If you are a Guix developer, or if you are taking care of this build farm,
11013 you'll probably want to have a closer look at these packages: they may simply
11014 fail to build.
11015
11016 @item --display-missing
11017 Display the list of store items for which substitutes are missing.
11018 @end table
11019
11020 @node Invoking guix processes
11021 @section Invoking @command{guix processes}
11022
11023 The @command{guix processes} command can be useful to developers and system
11024 administrators, especially on multi-user machines and on build farms: it lists
11025 the current sessions (connections to the daemon), as well as information about
11026 the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
11027 started with @option{--listen} specifying a TCP endpoint, are @emph{not}
11028 listed.}. Here's an example of the information it returns:
11029
11030 @example
11031 $ sudo guix processes
11032 SessionPID: 19002
11033 ClientPID: 19090
11034 ClientCommand: guix environment --ad-hoc python
11035
11036 SessionPID: 19402
11037 ClientPID: 19367
11038 ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
11039
11040 SessionPID: 19444
11041 ClientPID: 19419
11042 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
11043 LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
11044 LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
11045 LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
11046 ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
11047 ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
11048 ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
11049 @end example
11050
11051 In this example we see that @command{guix-daemon} has three clients:
11052 @command{guix environment}, @command{guix publish}, and the Cuirass continuous
11053 integration tool; their process identifier (PID) is given by the
11054 @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
11055 @command{guix-daemon} sub-process of this particular session.
11056
11057 The @code{LockHeld} fields show which store items are currently locked by this
11058 session, which corresponds to store items being built or substituted (the
11059 @code{LockHeld} field is not displayed when @command{guix processes} is not
11060 running as root.) Last, by looking at the @code{ChildProcess} field, we
11061 understand that these three builds are being offloaded (@pxref{Daemon Offload
11062 Setup}).
11063
11064 The output is in Recutils format so we can use the handy @command{recsel}
11065 command to select sessions of interest (@pxref{Selection Expressions,,,
11066 recutils, GNU recutils manual}). As an example, the command shows the command
11067 line and PID of the client that triggered the build of a Perl package:
11068
11069 @example
11070 $ sudo guix processes | \
11071 recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
11072 ClientPID: 19419
11073 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
11074 @end example
11075
11076 @node System Configuration
11077 @chapter System Configuration
11078
11079 @cindex system configuration
11080 Guix System supports a consistent whole-system configuration
11081 mechanism. By that we mean that all aspects of the global system
11082 configuration---such as the available system services, timezone and
11083 locale settings, user accounts---are declared in a single place. Such
11084 a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
11085
11086 One of the advantages of putting all the system configuration under the
11087 control of Guix is that it supports transactional system upgrades, and
11088 makes it possible to roll back to a previous system instantiation,
11089 should something go wrong with the new one (@pxref{Features}). Another
11090 advantage is that it makes it easy to replicate the exact same configuration
11091 across different machines, or at different points in time, without
11092 having to resort to additional administration tools layered on top of
11093 the own tools of the system.
11094 @c Yes, we're talking of Puppet, Chef, & co. here. ↑
11095
11096 This section describes this mechanism. First we focus on the system
11097 administrator's viewpoint---explaining how the system is configured and
11098 instantiated. Then we show how this mechanism can be extended, for
11099 instance to support new system services.
11100
11101 @menu
11102 * Using the Configuration System:: Customizing your GNU system.
11103 * operating-system Reference:: Detail of operating-system declarations.
11104 * File Systems:: Configuring file system mounts.
11105 * Mapped Devices:: Block device extra processing.
11106 * User Accounts:: Specifying user accounts.
11107 * Keyboard Layout:: How the system interprets key strokes.
11108 * Locales:: Language and cultural convention settings.
11109 * Services:: Specifying system services.
11110 * Setuid Programs:: Programs running with root privileges.
11111 * X.509 Certificates:: Authenticating HTTPS servers.
11112 * Name Service Switch:: Configuring libc's name service switch.
11113 * Initial RAM Disk:: Linux-Libre bootstrapping.
11114 * Bootloader Configuration:: Configuring the boot loader.
11115 * Invoking guix system:: Instantiating a system configuration.
11116 * Invoking guix deploy:: Deploying a system configuration to a remote host.
11117 * Running Guix in a VM:: How to run Guix System in a virtual machine.
11118 * Defining Services:: Adding new service definitions.
11119 @end menu
11120
11121 @node Using the Configuration System
11122 @section Using the Configuration System
11123
11124 The operating system is configured by providing an
11125 @code{operating-system} declaration in a file that can then be passed to
11126 the @command{guix system} command (@pxref{Invoking guix system}). A
11127 simple setup, with the default system services, the default Linux-Libre
11128 kernel, initial RAM disk, and boot loader looks like this:
11129
11130 @findex operating-system
11131 @lisp
11132 @include os-config-bare-bones.texi
11133 @end lisp
11134
11135 This example should be self-describing. Some of the fields defined
11136 above, such as @code{host-name} and @code{bootloader}, are mandatory.
11137 Others, such as @code{packages} and @code{services}, can be omitted, in
11138 which case they get a default value.
11139
11140 Below we discuss the effect of some of the most important fields
11141 (@pxref{operating-system Reference}, for details about all the available
11142 fields), and how to @dfn{instantiate} the operating system using
11143 @command{guix system}.
11144
11145 @unnumberedsubsec Bootloader
11146
11147 @cindex legacy boot, on Intel machines
11148 @cindex BIOS boot, on Intel machines
11149 @cindex UEFI boot
11150 @cindex EFI boot
11151 The @code{bootloader} field describes the method that will be used to boot
11152 your system. Machines based on Intel processors can boot in ``legacy'' BIOS
11153 mode, as in the example above. However, more recent machines rely instead on
11154 the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
11155 the @code{bootloader} field should contain something along these lines:
11156
11157 @lisp
11158 (bootloader-configuration
11159 (bootloader grub-efi-bootloader)
11160 (target "/boot/efi"))
11161 @end lisp
11162
11163 @xref{Bootloader Configuration}, for more information on the available
11164 configuration options.
11165
11166 @unnumberedsubsec Globally-Visible Packages
11167
11168 @vindex %base-packages
11169 The @code{packages} field lists packages that will be globally visible
11170 on the system, for all user accounts---i.e., in every user's @env{PATH}
11171 environment variable---in addition to the per-user profiles
11172 (@pxref{Invoking guix package}). The @code{%base-packages} variable
11173 provides all the tools one would expect for basic user and administrator
11174 tasks---including the GNU Core Utilities, the GNU Networking Utilities,
11175 the GNU Zile lightweight text editor, @command{find}, @command{grep},
11176 etc. The example above adds GNU@tie{}Screen to those,
11177 taken from the @code{(gnu packages screen)}
11178 module (@pxref{Package Modules}). The
11179 @code{(list package output)} syntax can be used to add a specific output
11180 of a package:
11181
11182 @lisp
11183 (use-modules (gnu packages))
11184 (use-modules (gnu packages dns))
11185
11186 (operating-system
11187 ;; ...
11188 (packages (cons (list bind "utils")
11189 %base-packages)))
11190 @end lisp
11191
11192 @findex specification->package
11193 Referring to packages by variable name, like @code{bind} above, has
11194 the advantage of being unambiguous; it also allows typos and such to be
11195 diagnosed right away as ``unbound variables''. The downside is that one
11196 needs to know which module defines which package, and to augment the
11197 @code{use-package-modules} line accordingly. To avoid that, one can use
11198 the @code{specification->package} procedure of the @code{(gnu packages)}
11199 module, which returns the best package for a given name or name and
11200 version:
11201
11202 @lisp
11203 (use-modules (gnu packages))
11204
11205 (operating-system
11206 ;; ...
11207 (packages (append (map specification->package
11208 '("tcpdump" "htop" "gnupg@@2.0"))
11209 %base-packages)))
11210 @end lisp
11211
11212 @unnumberedsubsec System Services
11213
11214 @cindex services
11215 @vindex %base-services
11216 The @code{services} field lists @dfn{system services} to be made
11217 available when the system starts (@pxref{Services}).
11218 The @code{operating-system} declaration above specifies that, in
11219 addition to the basic services, we want the OpenSSH secure shell
11220 daemon listening on port 2222 (@pxref{Networking Services,
11221 @code{openssh-service-type}}). Under the hood,
11222 @code{openssh-service-type} arranges so that @command{sshd} is started with the
11223 right command-line options, possibly with supporting configuration files
11224 generated as needed (@pxref{Defining Services}).
11225
11226 @cindex customization, of services
11227 @findex modify-services
11228 Occasionally, instead of using the base services as is, you will want to
11229 customize them. To do this, use @code{modify-services} (@pxref{Service
11230 Reference, @code{modify-services}}) to modify the list.
11231
11232 For example, suppose you want to modify @code{guix-daemon} and Mingetty
11233 (the console log-in) in the @code{%base-services} list (@pxref{Base
11234 Services, @code{%base-services}}). To do that, you can write the
11235 following in your operating system declaration:
11236
11237 @lisp
11238 (define %my-services
11239 ;; My very own list of services.
11240 (modify-services %base-services
11241 (guix-service-type config =>
11242 (guix-configuration
11243 (inherit config)
11244 (use-substitutes? #f)
11245 (extra-options '("--gc-keep-derivations"))))
11246 (mingetty-service-type config =>
11247 (mingetty-configuration
11248 (inherit config)))))
11249
11250 (operating-system
11251 ;; @dots{}
11252 (services %my-services))
11253 @end lisp
11254
11255 This changes the configuration---i.e., the service parameters---of the
11256 @code{guix-service-type} instance, and that of all the
11257 @code{mingetty-service-type} instances in the @code{%base-services} list.
11258 Observe how this is accomplished: first, we arrange for the original
11259 configuration to be bound to the identifier @code{config} in the
11260 @var{body}, and then we write the @var{body} so that it evaluates to the
11261 desired configuration. In particular, notice how we use @code{inherit}
11262 to create a new configuration which has the same values as the old
11263 configuration, but with a few modifications.
11264
11265 @cindex encrypted disk
11266 The configuration for a typical ``desktop'' usage, with an encrypted
11267 root partition, the X11 display
11268 server, GNOME and Xfce (users can choose which of these desktop
11269 environments to use at the log-in screen by pressing @kbd{F1}), network
11270 management, power management, and more, would look like this:
11271
11272 @lisp
11273 @include os-config-desktop.texi
11274 @end lisp
11275
11276 A graphical system with a choice of lightweight window managers
11277 instead of full-blown desktop environments would look like this:
11278
11279 @lisp
11280 @include os-config-lightweight-desktop.texi
11281 @end lisp
11282
11283 This example refers to the @file{/boot/efi} file system by its UUID,
11284 @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
11285 as returned by the @command{blkid} command.
11286
11287 @xref{Desktop Services}, for the exact list of services provided by
11288 @code{%desktop-services}. @xref{X.509 Certificates}, for background
11289 information about the @code{nss-certs} package that is used here.
11290
11291 Again, @code{%desktop-services} is just a list of service objects. If
11292 you want to remove services from there, you can do so using the
11293 procedures for list filtering (@pxref{SRFI-1 Filtering and
11294 Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
11295 following expression returns a list that contains all the services in
11296 @code{%desktop-services} minus the Avahi service:
11297
11298 @lisp
11299 (remove (lambda (service)
11300 (eq? (service-kind service) avahi-service-type))
11301 %desktop-services)
11302 @end lisp
11303
11304 @unnumberedsubsec Instantiating the System
11305
11306 Assuming the @code{operating-system} declaration
11307 is stored in the @file{my-system-config.scm}
11308 file, the @command{guix system reconfigure my-system-config.scm} command
11309 instantiates that configuration, and makes it the default GRUB boot
11310 entry (@pxref{Invoking guix system}).
11311
11312 The normal way to change the system configuration is by updating this
11313 file and re-running @command{guix system reconfigure}. One should never
11314 have to touch files in @file{/etc} or to run commands that modify the
11315 system state such as @command{useradd} or @command{grub-install}. In
11316 fact, you must avoid that since that would not only void your warranty
11317 but also prevent you from rolling back to previous versions of your
11318 system, should you ever need to.
11319
11320 @cindex roll-back, of the operating system
11321 Speaking of roll-back, each time you run @command{guix system
11322 reconfigure}, a new @dfn{generation} of the system is created---without
11323 modifying or deleting previous generations. Old system generations get
11324 an entry in the bootloader boot menu, allowing you to boot them in case
11325 something went wrong with the latest generation. Reassuring, no? The
11326 @command{guix system list-generations} command lists the system
11327 generations available on disk. It is also possible to roll back the
11328 system via the commands @command{guix system roll-back} and
11329 @command{guix system switch-generation}.
11330
11331 Although the @command{guix system reconfigure} command will not modify
11332 previous generations, you must take care when the current generation is not
11333 the latest (e.g., after invoking @command{guix system roll-back}), since
11334 the operation might overwrite a later generation (@pxref{Invoking guix
11335 system}).
11336
11337 @unnumberedsubsec The Programming Interface
11338
11339 At the Scheme level, the bulk of an @code{operating-system} declaration
11340 is instantiated with the following monadic procedure (@pxref{The Store
11341 Monad}):
11342
11343 @deffn {Monadic Procedure} operating-system-derivation os
11344 Return a derivation that builds @var{os}, an @code{operating-system}
11345 object (@pxref{Derivations}).
11346
11347 The output of the derivation is a single directory that refers to all
11348 the packages, configuration files, and other supporting files needed to
11349 instantiate @var{os}.
11350 @end deffn
11351
11352 This procedure is provided by the @code{(gnu system)} module. Along
11353 with @code{(gnu services)} (@pxref{Services}), this module contains the
11354 guts of Guix System. Make sure to visit it!
11355
11356
11357 @node operating-system Reference
11358 @section @code{operating-system} Reference
11359
11360 This section summarizes all the options available in
11361 @code{operating-system} declarations (@pxref{Using the Configuration
11362 System}).
11363
11364 @deftp {Data Type} operating-system
11365 This is the data type representing an operating system configuration.
11366 By that, we mean all the global system configuration, not per-user
11367 configuration (@pxref{Using the Configuration System}).
11368
11369 @table @asis
11370 @item @code{kernel} (default: @code{linux-libre})
11371 The package object of the operating system kernel to use@footnote{Currently
11372 only the Linux-libre kernel is supported. In the future, it will be
11373 possible to use the GNU@tie{}Hurd.}.
11374
11375 @item @code{kernel-loadable-modules} (default: '())
11376 A list of objects (usually packages) to collect loadable kernel modules
11377 from--e.g. @code{(list ddcci-driver-linux)}.
11378
11379 @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
11380 List of strings or gexps representing additional arguments to pass on
11381 the command-line of the kernel---e.g., @code{("console=ttyS0")}.
11382
11383 @item @code{bootloader}
11384 The system bootloader configuration object. @xref{Bootloader Configuration}.
11385
11386 @item @code{label}
11387 This is the label (a string) as it appears in the bootloader's menu entry.
11388 The default label includes the kernel name and version.
11389
11390 @item @code{keyboard-layout} (default: @code{#f})
11391 This field specifies the keyboard layout to use in the console. It can be
11392 either @code{#f}, in which case the default keyboard layout is used (usually
11393 US English), or a @code{<keyboard-layout>} record.
11394
11395 This keyboard layout is in effect as soon as the kernel has booted. For
11396 instance, it is the keyboard layout in effect when you type a passphrase if
11397 your root file system is on a @code{luks-device-mapping} mapped device
11398 (@pxref{Mapped Devices}).
11399
11400 @quotation Note
11401 This does @emph{not} specify the keyboard layout used by the bootloader, nor
11402 that used by the graphical display server. @xref{Bootloader Configuration},
11403 for information on how to specify the bootloader's keyboard layout. @xref{X
11404 Window}, for information on how to specify the keyboard layout used by the X
11405 Window System.
11406 @end quotation
11407
11408 @item @code{initrd-modules} (default: @code{%base-initrd-modules})
11409 @cindex initrd
11410 @cindex initial RAM disk
11411 The list of Linux kernel modules that need to be available in the
11412 initial RAM disk. @xref{Initial RAM Disk}.
11413
11414 @item @code{initrd} (default: @code{base-initrd})
11415 A procedure that returns an initial RAM disk for the Linux
11416 kernel. This field is provided to support low-level customization and
11417 should rarely be needed for casual use. @xref{Initial RAM Disk}.
11418
11419 @item @code{firmware} (default: @code{%base-firmware})
11420 @cindex firmware
11421 List of firmware packages loadable by the operating system kernel.
11422
11423 The default includes firmware needed for Atheros- and Broadcom-based
11424 WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
11425 respectively). @xref{Hardware Considerations}, for more info on
11426 supported hardware.
11427
11428 @item @code{host-name}
11429 The host name.
11430
11431 @item @code{hosts-file}
11432 @cindex hosts file
11433 A file-like object (@pxref{G-Expressions, file-like objects}) for use as
11434 @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
11435 Reference Manual}). The default is a file with entries for
11436 @code{localhost} and @var{host-name}.
11437
11438 @item @code{mapped-devices} (default: @code{'()})
11439 A list of mapped devices. @xref{Mapped Devices}.
11440
11441 @item @code{file-systems}
11442 A list of file systems. @xref{File Systems}.
11443
11444 @item @code{swap-devices} (default: @code{'()})
11445 @cindex swap devices
11446 A list of strings identifying devices or files to be used for ``swap
11447 space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
11448 Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
11449 It is possible to specify a swap file in a file system on a mapped
11450 device, provided that the necessary device mapping and file system are
11451 also specified. @xref{Mapped Devices} and @ref{File Systems}.
11452
11453 @item @code{users} (default: @code{%base-user-accounts})
11454 @itemx @code{groups} (default: @code{%base-groups})
11455 List of user accounts and groups. @xref{User Accounts}.
11456
11457 If the @code{users} list lacks a user account with UID@tie{}0, a
11458 ``root'' account with UID@tie{}0 is automatically added.
11459
11460 @item @code{skeletons} (default: @code{(default-skeletons)})
11461 A list target file name/file-like object tuples (@pxref{G-Expressions,
11462 file-like objects}). These are the skeleton files that will be added to
11463 the home directory of newly-created user accounts.
11464
11465 For instance, a valid value may look like this:
11466
11467 @lisp
11468 `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
11469 (".guile" ,(plain-file "guile"
11470 "(use-modules (ice-9 readline))
11471 (activate-readline)")))
11472 @end lisp
11473
11474 @item @code{issue} (default: @code{%default-issue})
11475 A string denoting the contents of the @file{/etc/issue} file, which is
11476 displayed when users log in on a text console.
11477
11478 @item @code{packages} (default: @code{%base-packages})
11479 The set of packages installed in the global profile, which is accessible
11480 at @file{/run/current-system/profile}.
11481
11482 The default set includes core utilities and it is good practice to
11483 install non-core utilities in user profiles (@pxref{Invoking guix
11484 package}).
11485
11486 @item @code{timezone}
11487 A timezone identifying string---e.g., @code{"Europe/Paris"}.
11488
11489 You can run the @command{tzselect} command to find out which timezone
11490 string corresponds to your region. Choosing an invalid timezone name
11491 causes @command{guix system} to fail.
11492
11493 @item @code{locale} (default: @code{"en_US.utf8"})
11494 The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
11495 Library Reference Manual}). @xref{Locales}, for more information.
11496
11497 @item @code{locale-definitions} (default: @code{%default-locale-definitions})
11498 The list of locale definitions to be compiled and that may be used at
11499 run time. @xref{Locales}.
11500
11501 @item @code{locale-libcs} (default: @code{(list @var{glibc})})
11502 The list of GNU@tie{}libc packages whose locale data and tools are used
11503 to build the locale definitions. @xref{Locales}, for compatibility
11504 considerations that justify this option.
11505
11506 @item @code{name-service-switch} (default: @code{%default-nss})
11507 Configuration of the libc name service switch (NSS)---a
11508 @code{<name-service-switch>} object. @xref{Name Service Switch}, for
11509 details.
11510
11511 @item @code{services} (default: @code{%base-services})
11512 A list of service objects denoting system services. @xref{Services}.
11513
11514 @cindex essential services
11515 @item @code{essential-services} (default: ...)
11516 The list of ``essential services''---i.e., things like instances of
11517 @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
11518 Reference}), which are derived from the operating system definition itself.
11519 As a user you should @emph{never} need to touch this field.
11520
11521 @item @code{pam-services} (default: @code{(base-pam-services)})
11522 @cindex PAM
11523 @cindex pluggable authentication modules
11524 Linux @dfn{pluggable authentication module} (PAM) services.
11525 @c FIXME: Add xref to PAM services section.
11526
11527 @item @code{setuid-programs} (default: @code{%setuid-programs})
11528 List of string-valued G-expressions denoting setuid programs.
11529 @xref{Setuid Programs}.
11530
11531 @item @code{sudoers-file} (default: @code{%sudoers-specification})
11532 @cindex sudoers file
11533 The contents of the @file{/etc/sudoers} file as a file-like object
11534 (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
11535
11536 This file specifies which users can use the @command{sudo} command, what
11537 they are allowed to do, and what privileges they may gain. The default
11538 is that only @code{root} and members of the @code{wheel} group may use
11539 @code{sudo}.
11540
11541 @end table
11542
11543 @deffn {Scheme Syntax} this-operating-system
11544 When used in the @emph{lexical scope} of an operating system field definition,
11545 this identifier resolves to the operating system being defined.
11546
11547 The example below shows how to refer to the operating system being defined in
11548 the definition of the @code{label} field:
11549
11550 @lisp
11551 (use-modules (gnu) (guix))
11552
11553 (operating-system
11554 ;; ...
11555 (label (package-full-name
11556 (operating-system-kernel this-operating-system))))
11557 @end lisp
11558
11559 It is an error to refer to @code{this-operating-system} outside an operating
11560 system definition.
11561 @end deffn
11562
11563 @end deftp
11564
11565 @node File Systems
11566 @section File Systems
11567
11568 The list of file systems to be mounted is specified in the
11569 @code{file-systems} field of the operating system declaration
11570 (@pxref{Using the Configuration System}). Each file system is declared
11571 using the @code{file-system} form, like this:
11572
11573 @lisp
11574 (file-system
11575 (mount-point "/home")
11576 (device "/dev/sda3")
11577 (type "ext4"))
11578 @end lisp
11579
11580 As usual, some of the fields are mandatory---those shown in the example
11581 above---while others can be omitted. These are described below.
11582
11583 @deftp {Data Type} file-system
11584 Objects of this type represent file systems to be mounted. They
11585 contain the following members:
11586
11587 @table @asis
11588 @item @code{type}
11589 This is a string specifying the type of the file system---e.g.,
11590 @code{"ext4"}.
11591
11592 @item @code{mount-point}
11593 This designates the place where the file system is to be mounted.
11594
11595 @item @code{device}
11596 This names the ``source'' of the file system. It can be one of three
11597 things: a file system label, a file system UUID, or the name of a
11598 @file{/dev} node. Labels and UUIDs offer a way to refer to file
11599 systems without having to hard-code their actual device
11600 name@footnote{Note that, while it is tempting to use
11601 @file{/dev/disk/by-uuid} and similar device names to achieve the same
11602 result, this is not recommended: These special device nodes are created
11603 by the udev daemon and may be unavailable at the time the device is
11604 mounted.}.
11605
11606 @findex file-system-label
11607 File system labels are created using the @code{file-system-label}
11608 procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
11609 plain strings. Here's an example of a file system referred to by its
11610 label, as shown by the @command{e2label} command:
11611
11612 @lisp
11613 (file-system
11614 (mount-point "/home")
11615 (type "ext4")
11616 (device (file-system-label "my-home")))
11617 @end lisp
11618
11619 @findex uuid
11620 UUIDs are converted from their string representation (as shown by the
11621 @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
11622 @code{uuid} form expects 16-byte UUIDs as defined in
11623 @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
11624 form of UUID used by the ext2 family of file systems and others, but it
11625 is different from ``UUIDs'' found in FAT file systems, for instance.},
11626 like this:
11627
11628 @lisp
11629 (file-system
11630 (mount-point "/home")
11631 (type "ext4")
11632 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
11633 @end lisp
11634
11635 When the source of a file system is a mapped device (@pxref{Mapped
11636 Devices}), its @code{device} field @emph{must} refer to the mapped
11637 device name---e.g., @file{"/dev/mapper/root-partition"}.
11638 This is required so that
11639 the system knows that mounting the file system depends on having the
11640 corresponding device mapping established.
11641
11642 @item @code{flags} (default: @code{'()})
11643 This is a list of symbols denoting mount flags. Recognized flags
11644 include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
11645 access to special files), @code{no-suid} (ignore setuid and setgid
11646 bits), @code{no-atime} (do not update file access times),
11647 @code{strict-atime} (update file access time), @code{lazy-time} (only
11648 update time on the in-memory version of the file inode), and
11649 @code{no-exec} (disallow program execution).
11650 @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
11651 Manual}, for more information on these flags.
11652
11653 @item @code{options} (default: @code{#f})
11654 This is either @code{#f}, or a string denoting mount options passed to the
11655 file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library
11656 Reference Manual}, for details and run @command{man 8 mount} for options for
11657 various file systems.
11658
11659 @item @code{mount?} (default: @code{#t})
11660 This value indicates whether to automatically mount the file system when
11661 the system is brought up. When set to @code{#f}, the file system gets
11662 an entry in @file{/etc/fstab} (read by the @command{mount} command) but
11663 is not automatically mounted.
11664
11665 @item @code{needed-for-boot?} (default: @code{#f})
11666 This Boolean value indicates whether the file system is needed when
11667 booting. If that is true, then the file system is mounted when the
11668 initial RAM disk (initrd) is loaded. This is always the case, for
11669 instance, for the root file system.
11670
11671 @item @code{check?} (default: @code{#t})
11672 This Boolean indicates whether the file system needs to be checked for
11673 errors before being mounted.
11674
11675 @item @code{create-mount-point?} (default: @code{#f})
11676 When true, the mount point is created if it does not exist yet.
11677
11678 @item @code{dependencies} (default: @code{'()})
11679 This is a list of @code{<file-system>} or @code{<mapped-device>} objects
11680 representing file systems that must be mounted or mapped devices that
11681 must be opened before (and unmounted or closed after) this one.
11682
11683 As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
11684 a dependency of @file{/sys/fs/cgroup/cpu} and
11685 @file{/sys/fs/cgroup/memory}.
11686
11687 Another example is a file system that depends on a mapped device, for
11688 example for an encrypted partition (@pxref{Mapped Devices}).
11689 @end table
11690 @end deftp
11691
11692 The @code{(gnu system file-systems)} exports the following useful
11693 variables.
11694
11695 @defvr {Scheme Variable} %base-file-systems
11696 These are essential file systems that are required on normal systems,
11697 such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
11698 below.) Operating system declarations should always contain at least
11699 these.
11700 @end defvr
11701
11702 @defvr {Scheme Variable} %pseudo-terminal-file-system
11703 This is the file system to be mounted as @file{/dev/pts}. It supports
11704 @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
11705 functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
11706 Manual}). Pseudo-terminals are used by terminal emulators such as
11707 @command{xterm}.
11708 @end defvr
11709
11710 @defvr {Scheme Variable} %shared-memory-file-system
11711 This file system is mounted as @file{/dev/shm} and is used to support
11712 memory sharing across processes (@pxref{Memory-mapped I/O,
11713 @code{shm_open},, libc, The GNU C Library Reference Manual}).
11714 @end defvr
11715
11716 @defvr {Scheme Variable} %immutable-store
11717 This file system performs a read-only ``bind mount'' of
11718 @file{/gnu/store}, making it read-only for all the users including
11719 @code{root}. This prevents against accidental modification by software
11720 running as @code{root} or by system administrators.
11721
11722 The daemon itself is still able to write to the store: it remounts it
11723 read-write in its own ``name space.''
11724 @end defvr
11725
11726 @defvr {Scheme Variable} %binary-format-file-system
11727 The @code{binfmt_misc} file system, which allows handling of arbitrary
11728 executable file types to be delegated to user space. This requires the
11729 @code{binfmt.ko} kernel module to be loaded.
11730 @end defvr
11731
11732 @defvr {Scheme Variable} %fuse-control-file-system
11733 The @code{fusectl} file system, which allows unprivileged users to mount
11734 and unmount user-space FUSE file systems. This requires the
11735 @code{fuse.ko} kernel module to be loaded.
11736 @end defvr
11737
11738 @node Mapped Devices
11739 @section Mapped Devices
11740
11741 @cindex device mapping
11742 @cindex mapped devices
11743 The Linux kernel has a notion of @dfn{device mapping}: a block device,
11744 such as a hard disk partition, can be @dfn{mapped} into another device,
11745 usually in @code{/dev/mapper/},
11746 with additional processing over the data that flows through
11747 it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
11748 concept of a ``mapped device'' and that of a file system: both boil down
11749 to @emph{translating} input/output operations made on a file to
11750 operations on its backing store. Thus, the Hurd implements mapped
11751 devices, like file systems, using the generic @dfn{translator} mechanism
11752 (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
11753 typical example is encryption device mapping: all writes to the mapped
11754 device are encrypted, and all reads are deciphered, transparently.
11755 Guix extends this notion by considering any device or set of devices that
11756 are @dfn{transformed} in some way to create a new device; for instance,
11757 RAID devices are obtained by @dfn{assembling} several other devices, such
11758 as hard disks or partitions, into a new one that behaves as one partition.
11759 Other examples, not yet implemented, are LVM logical volumes.
11760
11761 Mapped devices are declared using the @code{mapped-device} form,
11762 defined as follows; for examples, see below.
11763
11764 @deftp {Data Type} mapped-device
11765 Objects of this type represent device mappings that will be made when
11766 the system boots up.
11767
11768 @table @code
11769 @item source
11770 This is either a string specifying the name of the block device to be mapped,
11771 such as @code{"/dev/sda3"}, or a list of such strings when several devices
11772 need to be assembled for creating a new one.
11773
11774 @item target
11775 This string specifies the name of the resulting mapped device. For
11776 kernel mappers such as encrypted devices of type @code{luks-device-mapping},
11777 specifying @code{"my-partition"} leads to the creation of
11778 the @code{"/dev/mapper/my-partition"} device.
11779 For RAID devices of type @code{raid-device-mapping}, the full device name
11780 such as @code{"/dev/md0"} needs to be given.
11781
11782 @item type
11783 This must be a @code{mapped-device-kind} object, which specifies how
11784 @var{source} is mapped to @var{target}.
11785 @end table
11786 @end deftp
11787
11788 @defvr {Scheme Variable} luks-device-mapping
11789 This defines LUKS block device encryption using the @command{cryptsetup}
11790 command from the package with the same name. It relies on the
11791 @code{dm-crypt} Linux kernel module.
11792 @end defvr
11793
11794 @defvr {Scheme Variable} raid-device-mapping
11795 This defines a RAID device, which is assembled using the @code{mdadm}
11796 command from the package with the same name. It requires a Linux kernel
11797 module for the appropriate RAID level to be loaded, such as @code{raid456}
11798 for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
11799 @end defvr
11800
11801 @cindex disk encryption
11802 @cindex LUKS
11803 The following example specifies a mapping from @file{/dev/sda3} to
11804 @file{/dev/mapper/home} using LUKS---the
11805 @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
11806 standard mechanism for disk encryption.
11807 The @file{/dev/mapper/home}
11808 device can then be used as the @code{device} of a @code{file-system}
11809 declaration (@pxref{File Systems}).
11810
11811 @lisp
11812 (mapped-device
11813 (source "/dev/sda3")
11814 (target "home")
11815 (type luks-device-mapping))
11816 @end lisp
11817
11818 Alternatively, to become independent of device numbering, one may obtain
11819 the LUKS UUID (@dfn{unique identifier}) of the source device by a
11820 command like:
11821
11822 @example
11823 cryptsetup luksUUID /dev/sda3
11824 @end example
11825
11826 and use it as follows:
11827
11828 @lisp
11829 (mapped-device
11830 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
11831 (target "home")
11832 (type luks-device-mapping))
11833 @end lisp
11834
11835 @cindex swap encryption
11836 It is also desirable to encrypt swap space, since swap space may contain
11837 sensitive data. One way to accomplish that is to use a swap file in a
11838 file system on a device mapped via LUKS encryption. In this way, the
11839 swap file is encrypted because the entire device is encrypted.
11840 @xref{Preparing for Installation,,Disk Partitioning}, for an example.
11841
11842 A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
11843 may be declared as follows:
11844
11845 @lisp
11846 (mapped-device
11847 (source (list "/dev/sda1" "/dev/sdb1"))
11848 (target "/dev/md0")
11849 (type raid-device-mapping))
11850 @end lisp
11851
11852 The @file{/dev/md0} device can then be used as the @code{device} of a
11853 @code{file-system} declaration (@pxref{File Systems}).
11854 Note that the RAID level need not be given; it is chosen during the
11855 initial creation and formatting of the RAID device and is determined
11856 automatically later.
11857
11858
11859 @node User Accounts
11860 @section User Accounts
11861
11862 @cindex users
11863 @cindex accounts
11864 @cindex user accounts
11865 User accounts and groups are entirely managed through the
11866 @code{operating-system} declaration. They are specified with the
11867 @code{user-account} and @code{user-group} forms:
11868
11869 @lisp
11870 (user-account
11871 (name "alice")
11872 (group "users")
11873 (supplementary-groups '("wheel" ;allow use of sudo, etc.
11874 "audio" ;sound card
11875 "video" ;video devices such as webcams
11876 "cdrom")) ;the good ol' CD-ROM
11877 (comment "Bob's sister")
11878 (home-directory "/home/alice"))
11879 @end lisp
11880
11881 When booting or upon completion of @command{guix system reconfigure},
11882 the system ensures that only the user accounts and groups specified in
11883 the @code{operating-system} declaration exist, and with the specified
11884 properties. Thus, account or group creations or modifications made by
11885 directly invoking commands such as @command{useradd} are lost upon
11886 reconfiguration or reboot. This ensures that the system remains exactly
11887 as declared.
11888
11889 @deftp {Data Type} user-account
11890 Objects of this type represent user accounts. The following members may
11891 be specified:
11892
11893 @table @asis
11894 @item @code{name}
11895 The name of the user account.
11896
11897 @item @code{group}
11898 @cindex groups
11899 This is the name (a string) or identifier (a number) of the user group
11900 this account belongs to.
11901
11902 @item @code{supplementary-groups} (default: @code{'()})
11903 Optionally, this can be defined as a list of group names that this
11904 account belongs to.
11905
11906 @item @code{uid} (default: @code{#f})
11907 This is the user ID for this account (a number), or @code{#f}. In the
11908 latter case, a number is automatically chosen by the system when the
11909 account is created.
11910
11911 @item @code{comment} (default: @code{""})
11912 A comment about the account, such as the account owner's full name.
11913
11914 @item @code{home-directory}
11915 This is the name of the home directory for the account.
11916
11917 @item @code{create-home-directory?} (default: @code{#t})
11918 Indicates whether the home directory of this account should be created
11919 if it does not exist yet.
11920
11921 @item @code{shell} (default: Bash)
11922 This is a G-expression denoting the file name of a program to be used as
11923 the shell (@pxref{G-Expressions}).
11924
11925 @item @code{system?} (default: @code{#f})
11926 This Boolean value indicates whether the account is a ``system''
11927 account. System accounts are sometimes treated specially; for instance,
11928 graphical login managers do not list them.
11929
11930 @anchor{user-account-password}
11931 @cindex password, for user accounts
11932 @item @code{password} (default: @code{#f})
11933 You would normally leave this field to @code{#f}, initialize user
11934 passwords as @code{root} with the @command{passwd} command, and then let
11935 users change it with @command{passwd}. Passwords set with
11936 @command{passwd} are of course preserved across reboot and
11937 reconfiguration.
11938
11939 If you @emph{do} want to set an initial password for an account, then
11940 this field must contain the encrypted password, as a string. You can use the
11941 @code{crypt} procedure for this purpose:
11942
11943 @lisp
11944 (user-account
11945 (name "charlie")
11946 (group "users")
11947
11948 ;; Specify a SHA-512-hashed initial password.
11949 (password (crypt "InitialPassword!" "$6$abc")))
11950 @end lisp
11951
11952 @quotation Note
11953 The hash of this initial password will be available in a file in
11954 @file{/gnu/store}, readable by all the users, so this method must be used with
11955 care.
11956 @end quotation
11957
11958 @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
11959 more information on password encryption, and @ref{Encryption,,, guile, GNU
11960 Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
11961
11962 @end table
11963 @end deftp
11964
11965 @cindex groups
11966 User group declarations are even simpler:
11967
11968 @lisp
11969 (user-group (name "students"))
11970 @end lisp
11971
11972 @deftp {Data Type} user-group
11973 This type is for, well, user groups. There are just a few fields:
11974
11975 @table @asis
11976 @item @code{name}
11977 The name of the group.
11978
11979 @item @code{id} (default: @code{#f})
11980 The group identifier (a number). If @code{#f}, a new number is
11981 automatically allocated when the group is created.
11982
11983 @item @code{system?} (default: @code{#f})
11984 This Boolean value indicates whether the group is a ``system'' group.
11985 System groups have low numerical IDs.
11986
11987 @item @code{password} (default: @code{#f})
11988 What, user groups can have a password? Well, apparently yes. Unless
11989 @code{#f}, this field specifies the password of the group.
11990
11991 @end table
11992 @end deftp
11993
11994 For convenience, a variable lists all the basic user groups one may
11995 expect:
11996
11997 @defvr {Scheme Variable} %base-groups
11998 This is the list of basic user groups that users and/or packages expect
11999 to be present on the system. This includes groups such as ``root'',
12000 ``wheel'', and ``users'', as well as groups used to control access to
12001 specific devices such as ``audio'', ``disk'', and ``cdrom''.
12002 @end defvr
12003
12004 @defvr {Scheme Variable} %base-user-accounts
12005 This is the list of basic system accounts that programs may expect to
12006 find on a GNU/Linux system, such as the ``nobody'' account.
12007
12008 Note that the ``root'' account is not included here. It is a
12009 special-case and is automatically added whether or not it is specified.
12010 @end defvr
12011
12012 @node Keyboard Layout
12013 @section Keyboard Layout
12014
12015 @cindex keyboard layout
12016 @cindex keymap
12017 To specify what each key of your keyboard does, you need to tell the operating
12018 system what @dfn{keyboard layout} you want to use. The default, when nothing
12019 is specified, is the US English QWERTY layout for 105-key PC keyboards.
12020 However, German speakers will usually prefer the German QWERTZ layout, French
12021 speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
12022 or bépo, and they might even want to further customize the effect of some of
12023 the keys. This section explains how to get that done.
12024
12025 @cindex keyboard layout, definition
12026 There are three components that will want to know about your keyboard layout:
12027
12028 @itemize
12029 @item
12030 The @emph{bootloader} may want to know what keyboard layout you want to use
12031 (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
12032 you want, for instance, to make sure that you can type the passphrase of your
12033 encrypted root partition using the right layout.
12034
12035 @item
12036 The @emph{operating system kernel}, Linux, will need that so that the console
12037 is properly configured (@pxref{operating-system Reference,
12038 @code{keyboard-layout}}).
12039
12040 @item
12041 The @emph{graphical display server}, usually Xorg, also has its own idea of
12042 the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
12043 @end itemize
12044
12045 Guix allows you to configure all three separately but, fortunately, it allows
12046 you to share the same keyboard layout for all three components.
12047
12048 @cindex XKB, keyboard layouts
12049 Keyboard layouts are represented by records created by the
12050 @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
12051 the X Keyboard extension (XKB), each layout has four attributes: a name (often
12052 a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
12053 optional variant name, an optional keyboard model name, and a possibly empty
12054 list of additional options. In most cases the layout name is all you care
12055 about. Here are a few example:
12056
12057 @lisp
12058 ;; The German QWERTZ layout. Here we assume a standard
12059 ;; "pc105" keyboard model.
12060 (keyboard-layout "de")
12061
12062 ;; The bépo variant of the French layout.
12063 (keyboard-layout "fr" "bepo")
12064
12065 ;; The Catalan layout.
12066 (keyboard-layout "es" "cat")
12067
12068 ;; Arabic layout with "Alt-Shift" to switch to US layout.
12069 (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
12070
12071 ;; The Latin American Spanish layout. In addition, the
12072 ;; "Caps Lock" key is used as an additional "Ctrl" key,
12073 ;; and the "Menu" key is used as a "Compose" key to enter
12074 ;; accented letters.
12075 (keyboard-layout "latam"
12076 #:options '("ctrl:nocaps" "compose:menu"))
12077
12078 ;; The Russian layout for a ThinkPad keyboard.
12079 (keyboard-layout "ru" #:model "thinkpad")
12080
12081 ;; The "US international" layout, which is the US layout plus
12082 ;; dead keys to enter accented characters. This is for an
12083 ;; Apple MacBook keyboard.
12084 (keyboard-layout "us" "intl" #:model "macbook78")
12085 @end lisp
12086
12087 See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
12088 for a complete list of supported layouts, variants, and models.
12089
12090 @cindex keyboard layout, configuration
12091 Let's say you want your system to use the Turkish keyboard layout throughout
12092 your system---bootloader, console, and Xorg. Here's what your system
12093 configuration would look like:
12094
12095 @findex set-xorg-configuration
12096 @lisp
12097 ;; Using the Turkish layout for the bootloader, the console,
12098 ;; and for Xorg.
12099
12100 (operating-system
12101 ;; ...
12102 (keyboard-layout (keyboard-layout "tr")) ;for the console
12103 (bootloader (bootloader-configuration
12104 (bootloader grub-efi-bootloader)
12105 (target "/boot/efi")
12106 (keyboard-layout keyboard-layout))) ;for GRUB
12107 (services (cons (set-xorg-configuration
12108 (xorg-configuration ;for Xorg
12109 (keyboard-layout keyboard-layout)))
12110 %desktop-services)))
12111 @end lisp
12112
12113 In the example above, for GRUB and for Xorg, we just refer to the
12114 @code{keyboard-layout} field defined above, but we could just as well refer to
12115 a different layout. The @code{set-xorg-configuration} procedure communicates
12116 the desired Xorg configuration to the graphical log-in manager, by default
12117 GDM.
12118
12119 We've discussed how to specify the @emph{default} keyboard layout of your
12120 system when it starts, but you can also adjust it at run time:
12121
12122 @itemize
12123 @item
12124 If you're using GNOME, its settings panel has a ``Region & Language'' entry
12125 where you can select one or more keyboard layouts.
12126
12127 @item
12128 Under Xorg, the @command{setxkbmap} command (from the same-named package)
12129 allows you to change the current layout. For example, this is how you would
12130 change the layout to US Dvorak:
12131
12132 @example
12133 setxkbmap us dvorak
12134 @end example
12135
12136 @item
12137 The @code{loadkeys} command changes the keyboard layout in effect in the Linux
12138 console. However, note that @code{loadkeys} does @emph{not} use the XKB
12139 keyboard layout categorization described above. The command below loads the
12140 French bépo layout:
12141
12142 @example
12143 loadkeys fr-bepo
12144 @end example
12145 @end itemize
12146
12147 @node Locales
12148 @section Locales
12149
12150 @cindex locale
12151 A @dfn{locale} defines cultural conventions for a particular language
12152 and region of the world (@pxref{Locales,,, libc, The GNU C Library
12153 Reference Manual}). Each locale has a name that typically has the form
12154 @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
12155 @code{fr_LU.utf8} designates the locale for the French language, with
12156 cultural conventions from Luxembourg, and using the UTF-8 encoding.
12157
12158 @cindex locale definition
12159 Usually, you will want to specify the default locale for the machine
12160 using the @code{locale} field of the @code{operating-system} declaration
12161 (@pxref{operating-system Reference, @code{locale}}).
12162
12163 The selected locale is automatically added to the @dfn{locale
12164 definitions} known to the system if needed, with its codeset inferred
12165 from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
12166 @code{UTF-8} codeset. Additional locale definitions can be specified in
12167 the @code{locale-definitions} slot of @code{operating-system}---this is
12168 useful, for instance, if the codeset could not be inferred from the
12169 locale name. The default set of locale definitions includes some widely
12170 used locales, but not all the available locales, in order to save space.
12171
12172 For instance, to add the North Frisian locale for Germany, the value of
12173 that field may be:
12174
12175 @lisp
12176 (cons (locale-definition
12177 (name "fy_DE.utf8") (source "fy_DE"))
12178 %default-locale-definitions)
12179 @end lisp
12180
12181 Likewise, to save space, one might want @code{locale-definitions} to
12182 list only the locales that are actually used, as in:
12183
12184 @lisp
12185 (list (locale-definition
12186 (name "ja_JP.eucjp") (source "ja_JP")
12187 (charset "EUC-JP")))
12188 @end lisp
12189
12190 @vindex LOCPATH
12191 The compiled locale definitions are available at
12192 @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
12193 version, which is the default location where the GNU@tie{}libc provided
12194 by Guix looks for locale data. This can be overridden using the
12195 @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
12196 @env{LOCPATH} and locale packages}).
12197
12198 The @code{locale-definition} form is provided by the @code{(gnu system
12199 locale)} module. Details are given below.
12200
12201 @deftp {Data Type} locale-definition
12202 This is the data type of a locale definition.
12203
12204 @table @asis
12205
12206 @item @code{name}
12207 The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
12208 Reference Manual}, for more information on locale names.
12209
12210 @item @code{source}
12211 The name of the source for that locale. This is typically the
12212 @code{@var{language}_@var{territory}} part of the locale name.
12213
12214 @item @code{charset} (default: @code{"UTF-8"})
12215 The ``character set'' or ``code set'' for that locale,
12216 @uref{https://www.iana.org/assignments/character-sets, as defined by
12217 IANA}.
12218
12219 @end table
12220 @end deftp
12221
12222 @defvr {Scheme Variable} %default-locale-definitions
12223 A list of commonly used UTF-8 locales, used as the default
12224 value of the @code{locale-definitions} field of @code{operating-system}
12225 declarations.
12226
12227 @cindex locale name
12228 @cindex normalized codeset in locale names
12229 These locale definitions use the @dfn{normalized codeset} for the part
12230 that follows the dot in the name (@pxref{Using gettextized software,
12231 normalized codeset,, libc, The GNU C Library Reference Manual}). So for
12232 instance it has @code{uk_UA.utf8} but @emph{not}, say,
12233 @code{uk_UA.UTF-8}.
12234 @end defvr
12235
12236 @subsection Locale Data Compatibility Considerations
12237
12238 @cindex incompatibility, of locale data
12239 @code{operating-system} declarations provide a @code{locale-libcs} field
12240 to specify the GNU@tie{}libc packages that are used to compile locale
12241 declarations (@pxref{operating-system Reference}). ``Why would I
12242 care?'', you may ask. Well, it turns out that the binary format of
12243 locale data is occasionally incompatible from one libc version to
12244 another.
12245
12246 @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
12247 @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
12248 For instance, a program linked against libc version 2.21 is unable to
12249 read locale data produced with libc 2.22; worse, that program
12250 @emph{aborts} instead of simply ignoring the incompatible locale
12251 data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
12252 the incompatible locale data, which is already an improvement.}.
12253 Similarly, a program linked against libc 2.22 can read most, but not
12254 all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
12255 data is incompatible); thus calls to @code{setlocale} may fail, but
12256 programs will not abort.
12257
12258 The ``problem'' with Guix is that users have a lot of freedom: They can
12259 choose whether and when to upgrade software in their profiles, and might
12260 be using a libc version different from the one the system administrator
12261 used to build the system-wide locale data.
12262
12263 Fortunately, unprivileged users can also install their own locale data
12264 and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
12265 @env{GUIX_LOCPATH} and locale packages}).
12266
12267 Still, it is best if the system-wide locale data at
12268 @file{/run/current-system/locale} is built for all the libc versions
12269 actually in use on the system, so that all the programs can access
12270 it---this is especially crucial on a multi-user system. To do that, the
12271 administrator can specify several libc packages in the
12272 @code{locale-libcs} field of @code{operating-system}:
12273
12274 @lisp
12275 (use-package-modules base)
12276
12277 (operating-system
12278 ;; @dots{}
12279 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
12280 @end lisp
12281
12282 This example would lead to a system containing locale definitions for
12283 both libc 2.21 and the current version of libc in
12284 @file{/run/current-system/locale}.
12285
12286
12287 @node Services
12288 @section Services
12289
12290 @cindex system services
12291 An important part of preparing an @code{operating-system} declaration is
12292 listing @dfn{system services} and their configuration (@pxref{Using the
12293 Configuration System}). System services are typically daemons launched
12294 when the system boots, or other actions needed at that time---e.g.,
12295 configuring network access.
12296
12297 Guix has a broad definition of ``service'' (@pxref{Service
12298 Composition}), but many services are managed by the GNU@tie{}Shepherd
12299 (@pxref{Shepherd Services}). On a running system, the @command{herd}
12300 command allows you to list the available services, show their status,
12301 start and stop them, or do other specific operations (@pxref{Jump
12302 Start,,, shepherd, The GNU Shepherd Manual}). For example:
12303
12304 @example
12305 # herd status
12306 @end example
12307
12308 The above command, run as @code{root}, lists the currently defined
12309 services. The @command{herd doc} command shows a synopsis of the given
12310 service and its associated actions:
12311
12312 @example
12313 # herd doc nscd
12314 Run libc's name service cache daemon (nscd).
12315
12316 # herd doc nscd action invalidate
12317 invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
12318 @end example
12319
12320 The @command{start}, @command{stop}, and @command{restart} sub-commands
12321 have the effect you would expect. For instance, the commands below stop
12322 the nscd service and restart the Xorg display server:
12323
12324 @example
12325 # herd stop nscd
12326 Service nscd has been stopped.
12327 # herd restart xorg-server
12328 Service xorg-server has been stopped.
12329 Service xorg-server has been started.
12330 @end example
12331
12332 The following sections document the available services, starting with
12333 the core services, that may be used in an @code{operating-system}
12334 declaration.
12335
12336 @menu
12337 * Base Services:: Essential system services.
12338 * Scheduled Job Execution:: The mcron service.
12339 * Log Rotation:: The rottlog service.
12340 * Networking Services:: Network setup, SSH daemon, etc.
12341 * X Window:: Graphical display.
12342 * Printing Services:: Local and remote printer support.
12343 * Desktop Services:: D-Bus and desktop services.
12344 * Sound Services:: ALSA and Pulseaudio services.
12345 * Database Services:: SQL databases, key-value stores, etc.
12346 * Mail Services:: IMAP, POP3, SMTP, and all that.
12347 * Messaging Services:: Messaging services.
12348 * Telephony Services:: Telephony services.
12349 * Monitoring Services:: Monitoring services.
12350 * Kerberos Services:: Kerberos services.
12351 * LDAP Services:: LDAP services.
12352 * Web Services:: Web servers.
12353 * Certificate Services:: TLS certificates via Let's Encrypt.
12354 * DNS Services:: DNS daemons.
12355 * VPN Services:: VPN daemons.
12356 * Network File System:: NFS related services.
12357 * Continuous Integration:: The Cuirass service.
12358 * Power Management Services:: Extending battery life.
12359 * Audio Services:: The MPD.
12360 * Virtualization Services:: Virtualization services.
12361 * Version Control Services:: Providing remote access to Git repositories.
12362 * Game Services:: Game servers.
12363 * PAM Mount Service:: Service to mount volumes when logging in.
12364 * Guix Services:: Services relating specifically to Guix.
12365 * Linux Services:: Services tied to the Linux kernel.
12366 * Miscellaneous Services:: Other services.
12367 @end menu
12368
12369 @node Base Services
12370 @subsection Base Services
12371
12372 The @code{(gnu services base)} module provides definitions for the basic
12373 services that one expects from the system. The services exported by
12374 this module are listed below.
12375
12376 @defvr {Scheme Variable} %base-services
12377 This variable contains a list of basic services (@pxref{Service Types
12378 and Services}, for more information on service objects) one would
12379 expect from the system: a login service (mingetty) on each tty, syslogd,
12380 the libc name service cache daemon (nscd), the udev device manager, and
12381 more.
12382
12383 This is the default value of the @code{services} field of
12384 @code{operating-system} declarations. Usually, when customizing a
12385 system, you will want to append services to @code{%base-services}, like
12386 this:
12387
12388 @lisp
12389 (append (list (service avahi-service-type)
12390 (service openssh-service-type))
12391 %base-services)
12392 @end lisp
12393 @end defvr
12394
12395 @defvr {Scheme Variable} special-files-service-type
12396 This is the service that sets up ``special files'' such as
12397 @file{/bin/sh}; an instance of it is part of @code{%base-services}.
12398
12399 The value associated with @code{special-files-service-type} services
12400 must be a list of tuples where the first element is the ``special file''
12401 and the second element is its target. By default it is:
12402
12403 @cindex @file{/bin/sh}
12404 @cindex @file{sh}, in @file{/bin}
12405 @lisp
12406 `(("/bin/sh" ,(file-append bash "/bin/sh")))
12407 @end lisp
12408
12409 @cindex @file{/usr/bin/env}
12410 @cindex @file{env}, in @file{/usr/bin}
12411 If you want to add, say, @code{/usr/bin/env} to your system, you can
12412 change it to:
12413
12414 @lisp
12415 `(("/bin/sh" ,(file-append bash "/bin/sh"))
12416 ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
12417 @end lisp
12418
12419 Since this is part of @code{%base-services}, you can use
12420 @code{modify-services} to customize the set of special files
12421 (@pxref{Service Reference, @code{modify-services}}). But the simple way
12422 to add a special file is @i{via} the @code{extra-special-file} procedure
12423 (see below.)
12424 @end defvr
12425
12426 @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
12427 Use @var{target} as the ``special file'' @var{file}.
12428
12429 For example, adding the following lines to the @code{services} field of
12430 your operating system declaration leads to a @file{/usr/bin/env}
12431 symlink:
12432
12433 @lisp
12434 (extra-special-file "/usr/bin/env"
12435 (file-append coreutils "/bin/env"))
12436 @end lisp
12437 @end deffn
12438
12439 @deffn {Scheme Procedure} host-name-service @var{name}
12440 Return a service that sets the host name to @var{name}.
12441 @end deffn
12442
12443 @defvr {Scheme Variable} console-font-service-type
12444 Install the given fonts on the specified ttys (fonts are per
12445 virtual console on the kernel Linux). The value of this service is a list of
12446 tty/font pairs. The font can be the name of a font provided by the @code{kbd}
12447 package or any valid argument to @command{setfont}, as in this example:
12448
12449 @lisp
12450 `(("tty1" . "LatGrkCyr-8x16")
12451 ("tty2" . ,(file-append
12452 font-tamzen
12453 "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
12454 ("tty3" . ,(file-append
12455 font-terminus
12456 "/share/consolefonts/ter-132n"))) ; for HDPI
12457 @end lisp
12458 @end defvr
12459
12460 @deffn {Scheme Procedure} login-service @var{config}
12461 Return a service to run login according to @var{config}, a
12462 @code{<login-configuration>} object, which specifies the message of the day,
12463 among other things.
12464 @end deffn
12465
12466 @deftp {Data Type} login-configuration
12467 This is the data type representing the configuration of login.
12468
12469 @table @asis
12470
12471 @item @code{motd}
12472 @cindex message of the day
12473 A file-like object containing the ``message of the day''.
12474
12475 @item @code{allow-empty-passwords?} (default: @code{#t})
12476 Allow empty passwords by default so that first-time users can log in when
12477 the 'root' account has just been created.
12478
12479 @end table
12480 @end deftp
12481
12482 @deffn {Scheme Procedure} mingetty-service @var{config}
12483 Return a service to run mingetty according to @var{config}, a
12484 @code{<mingetty-configuration>} object, which specifies the tty to run, among
12485 other things.
12486 @end deffn
12487
12488 @deftp {Data Type} mingetty-configuration
12489 This is the data type representing the configuration of Mingetty, which
12490 provides the default implementation of virtual console log-in.
12491
12492 @table @asis
12493
12494 @item @code{tty}
12495 The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
12496
12497 @item @code{auto-login} (default: @code{#f})
12498 When true, this field must be a string denoting the user name under
12499 which the system automatically logs in. When it is @code{#f}, a
12500 user name and password must be entered to log in.
12501
12502 @item @code{login-program} (default: @code{#f})
12503 This must be either @code{#f}, in which case the default log-in program
12504 is used (@command{login} from the Shadow tool suite), or a gexp denoting
12505 the name of the log-in program.
12506
12507 @item @code{login-pause?} (default: @code{#f})
12508 When set to @code{#t} in conjunction with @var{auto-login}, the user
12509 will have to press a key before the log-in shell is launched.
12510
12511 @item @code{mingetty} (default: @var{mingetty})
12512 The Mingetty package to use.
12513
12514 @end table
12515 @end deftp
12516
12517 @deffn {Scheme Procedure} agetty-service @var{config}
12518 Return a service to run agetty according to @var{config}, an
12519 @code{<agetty-configuration>} object, which specifies the tty to run,
12520 among other things.
12521 @end deffn
12522
12523 @deftp {Data Type} agetty-configuration
12524 This is the data type representing the configuration of agetty, which
12525 implements virtual and serial console log-in. See the @code{agetty(8)}
12526 man page for more information.
12527
12528 @table @asis
12529
12530 @item @code{tty}
12531 The name of the console this agetty runs on, as a string---e.g.,
12532 @code{"ttyS0"}. This argument is optional, it will default to
12533 a reasonable default serial port used by the kernel Linux.
12534
12535 For this, if there is a value for an option @code{agetty.tty} in the kernel
12536 command line, agetty will extract the device name of the serial port
12537 from it and use that.
12538
12539 If not and if there is a value for an option @code{console} with a tty in
12540 the Linux command line, agetty will extract the device name of the
12541 serial port from it and use that.
12542
12543 In both cases, agetty will leave the other serial device settings
12544 (baud rate etc.)@: alone---in the hope that Linux pinned them to the
12545 correct values.
12546
12547 @item @code{baud-rate} (default: @code{#f})
12548 A string containing a comma-separated list of one or more baud rates, in
12549 descending order.
12550
12551 @item @code{term} (default: @code{#f})
12552 A string containing the value used for the @env{TERM} environment
12553 variable.
12554
12555 @item @code{eight-bits?} (default: @code{#f})
12556 When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
12557 disabled.
12558
12559 @item @code{auto-login} (default: @code{#f})
12560 When passed a login name, as a string, the specified user will be logged
12561 in automatically without prompting for their login name or password.
12562
12563 @item @code{no-reset?} (default: @code{#f})
12564 When @code{#t}, don't reset terminal cflags (control modes).
12565
12566 @item @code{host} (default: @code{#f})
12567 This accepts a string containing the ``login_host'', which will be written
12568 into the @file{/var/run/utmpx} file.
12569
12570 @item @code{remote?} (default: @code{#f})
12571 When set to @code{#t} in conjunction with @var{host}, this will add an
12572 @code{-r} fakehost option to the command line of the login program
12573 specified in @var{login-program}.
12574
12575 @item @code{flow-control?} (default: @code{#f})
12576 When set to @code{#t}, enable hardware (RTS/CTS) flow control.
12577
12578 @item @code{no-issue?} (default: @code{#f})
12579 When set to @code{#t}, the contents of the @file{/etc/issue} file will
12580 not be displayed before presenting the login prompt.
12581
12582 @item @code{init-string} (default: @code{#f})
12583 This accepts a string that will be sent to the tty or modem before
12584 sending anything else. It can be used to initialize a modem.
12585
12586 @item @code{no-clear?} (default: @code{#f})
12587 When set to @code{#t}, agetty will not clear the screen before showing
12588 the login prompt.
12589
12590 @item @code{login-program} (default: (file-append shadow "/bin/login"))
12591 This must be either a gexp denoting the name of a log-in program, or
12592 unset, in which case the default value is the @command{login} from the
12593 Shadow tool suite.
12594
12595 @item @code{local-line} (default: @code{#f})
12596 Control the CLOCAL line flag. This accepts one of three symbols as
12597 arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
12598 the default value chosen by agetty is @code{'auto}.
12599
12600 @item @code{extract-baud?} (default: @code{#f})
12601 When set to @code{#t}, instruct agetty to try to extract the baud rate
12602 from the status messages produced by certain types of modems.
12603
12604 @item @code{skip-login?} (default: @code{#f})
12605 When set to @code{#t}, do not prompt the user for a login name. This
12606 can be used with @var{login-program} field to use non-standard login
12607 systems.
12608
12609 @item @code{no-newline?} (default: @code{#f})
12610 When set to @code{#t}, do not print a newline before printing the
12611 @file{/etc/issue} file.
12612
12613 @c Is this dangerous only when used with login-program, or always?
12614 @item @code{login-options} (default: @code{#f})
12615 This option accepts a string containing options that are passed to the
12616 login program. When used with the @var{login-program}, be aware that a
12617 malicious user could try to enter a login name containing embedded
12618 options that could be parsed by the login program.
12619
12620 @item @code{login-pause} (default: @code{#f})
12621 When set to @code{#t}, wait for any key before showing the login prompt.
12622 This can be used in conjunction with @var{auto-login} to save memory by
12623 lazily spawning shells.
12624
12625 @item @code{chroot} (default: @code{#f})
12626 Change root to the specified directory. This option accepts a directory
12627 path as a string.
12628
12629 @item @code{hangup?} (default: @code{#f})
12630 Use the Linux system call @code{vhangup} to do a virtual hangup of the
12631 specified terminal.
12632
12633 @item @code{keep-baud?} (default: @code{#f})
12634 When set to @code{#t}, try to keep the existing baud rate. The baud
12635 rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
12636 character.
12637
12638 @item @code{timeout} (default: @code{#f})
12639 When set to an integer value, terminate if no user name could be read
12640 within @var{timeout} seconds.
12641
12642 @item @code{detect-case?} (default: @code{#f})
12643 When set to @code{#t}, turn on support for detecting an uppercase-only
12644 terminal. This setting will detect a login name containing only
12645 uppercase letters as indicating an uppercase-only terminal and turn on
12646 some upper-to-lower case conversions. Note that this will not support
12647 Unicode characters.
12648
12649 @item @code{wait-cr?} (default: @code{#f})
12650 When set to @code{#t}, wait for the user or modem to send a
12651 carriage-return or linefeed character before displaying
12652 @file{/etc/issue} or login prompt. This is typically used with the
12653 @var{init-string} option.
12654
12655 @item @code{no-hints?} (default: @code{#f})
12656 When set to @code{#t}, do not print hints about Num, Caps, and Scroll
12657 locks.
12658
12659 @item @code{no-hostname?} (default: @code{#f})
12660 By default, the hostname is printed. When this option is set to
12661 @code{#t}, no hostname will be shown at all.
12662
12663 @item @code{long-hostname?} (default: @code{#f})
12664 By default, the hostname is only printed until the first dot. When this
12665 option is set to @code{#t}, the fully qualified hostname by
12666 @code{gethostname} or @code{getaddrinfo} is shown.
12667
12668 @item @code{erase-characters} (default: @code{#f})
12669 This option accepts a string of additional characters that should be
12670 interpreted as backspace when the user types their login name.
12671
12672 @item @code{kill-characters} (default: @code{#f})
12673 This option accepts a string that should be interpreted to mean ``ignore
12674 all previous characters'' (also called a ``kill'' character) when the user
12675 types their login name.
12676
12677 @item @code{chdir} (default: @code{#f})
12678 This option accepts, as a string, a directory path that will be changed
12679 to before login.
12680
12681 @item @code{delay} (default: @code{#f})
12682 This options accepts, as an integer, the number of seconds to sleep
12683 before opening the tty and displaying the login prompt.
12684
12685 @item @code{nice} (default: @code{#f})
12686 This option accepts, as an integer, the nice value with which to run the
12687 @command{login} program.
12688
12689 @item @code{extra-options} (default: @code{'()})
12690 This option provides an ``escape hatch'' for the user to provide arbitrary
12691 command-line arguments to @command{agetty} as a list of strings.
12692
12693 @end table
12694 @end deftp
12695
12696 @deffn {Scheme Procedure} kmscon-service-type @var{config}
12697 Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
12698 according to @var{config}, a @code{<kmscon-configuration>} object, which
12699 specifies the tty to run, among other things.
12700 @end deffn
12701
12702 @deftp {Data Type} kmscon-configuration
12703 This is the data type representing the configuration of Kmscon, which
12704 implements virtual console log-in.
12705
12706 @table @asis
12707
12708 @item @code{virtual-terminal}
12709 The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
12710
12711 @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
12712 A gexp denoting the name of the log-in program. The default log-in program is
12713 @command{login} from the Shadow tool suite.
12714
12715 @item @code{login-arguments} (default: @code{'("-p")})
12716 A list of arguments to pass to @command{login}.
12717
12718 @item @code{auto-login} (default: @code{#f})
12719 When passed a login name, as a string, the specified user will be logged
12720 in automatically without prompting for their login name or password.
12721
12722 @item @code{hardware-acceleration?} (default: #f)
12723 Whether to use hardware acceleration.
12724
12725 @item @code{kmscon} (default: @var{kmscon})
12726 The Kmscon package to use.
12727
12728 @end table
12729 @end deftp
12730
12731 @cindex name service cache daemon
12732 @cindex nscd
12733 @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
12734 [#:name-services '()]
12735 Return a service that runs the libc name service cache daemon (nscd) with the
12736 given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
12737 Service Switch}, for an example.
12738
12739 For convenience, the Shepherd service for nscd provides the following actions:
12740
12741 @table @code
12742 @item invalidate
12743 @cindex cache invalidation, nscd
12744 @cindex nscd, cache invalidation
12745 This invalidate the given cache. For instance, running:
12746
12747 @example
12748 herd invalidate nscd hosts
12749 @end example
12750
12751 @noindent
12752 invalidates the host name lookup cache of nscd.
12753
12754 @item statistics
12755 Running @command{herd statistics nscd} displays information about nscd usage
12756 and caches.
12757 @end table
12758
12759 @end deffn
12760
12761 @defvr {Scheme Variable} %nscd-default-configuration
12762 This is the default @code{<nscd-configuration>} value (see below) used
12763 by @code{nscd-service}. It uses the caches defined by
12764 @code{%nscd-default-caches}; see below.
12765 @end defvr
12766
12767 @deftp {Data Type} nscd-configuration
12768 This is the data type representing the name service cache daemon (nscd)
12769 configuration.
12770
12771 @table @asis
12772
12773 @item @code{name-services} (default: @code{'()})
12774 List of packages denoting @dfn{name services} that must be visible to
12775 the nscd---e.g., @code{(list @var{nss-mdns})}.
12776
12777 @item @code{glibc} (default: @var{glibc})
12778 Package object denoting the GNU C Library providing the @command{nscd}
12779 command.
12780
12781 @item @code{log-file} (default: @code{"/var/log/nscd.log"})
12782 Name of the nscd log file. This is where debugging output goes when
12783 @code{debug-level} is strictly positive.
12784
12785 @item @code{debug-level} (default: @code{0})
12786 Integer denoting the debugging levels. Higher numbers mean that more
12787 debugging output is logged.
12788
12789 @item @code{caches} (default: @code{%nscd-default-caches})
12790 List of @code{<nscd-cache>} objects denoting things to be cached; see
12791 below.
12792
12793 @end table
12794 @end deftp
12795
12796 @deftp {Data Type} nscd-cache
12797 Data type representing a cache database of nscd and its parameters.
12798
12799 @table @asis
12800
12801 @item @code{database}
12802 This is a symbol representing the name of the database to be cached.
12803 Valid values are @code{passwd}, @code{group}, @code{hosts}, and
12804 @code{services}, which designate the corresponding NSS database
12805 (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
12806
12807 @item @code{positive-time-to-live}
12808 @itemx @code{negative-time-to-live} (default: @code{20})
12809 A number representing the number of seconds during which a positive or
12810 negative lookup result remains in cache.
12811
12812 @item @code{check-files?} (default: @code{#t})
12813 Whether to check for updates of the files corresponding to
12814 @var{database}.
12815
12816 For instance, when @var{database} is @code{hosts}, setting this flag
12817 instructs nscd to check for updates in @file{/etc/hosts} and to take
12818 them into account.
12819
12820 @item @code{persistent?} (default: @code{#t})
12821 Whether the cache should be stored persistently on disk.
12822
12823 @item @code{shared?} (default: @code{#t})
12824 Whether the cache should be shared among users.
12825
12826 @item @code{max-database-size} (default: 32@tie{}MiB)
12827 Maximum size in bytes of the database cache.
12828
12829 @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
12830 @c settings, so leave them out.
12831
12832 @end table
12833 @end deftp
12834
12835 @defvr {Scheme Variable} %nscd-default-caches
12836 List of @code{<nscd-cache>} objects used by default by
12837 @code{nscd-configuration} (see above).
12838
12839 It enables persistent and aggressive caching of service and host name
12840 lookups. The latter provides better host name lookup performance,
12841 resilience in the face of unreliable name servers, and also better
12842 privacy---often the result of host name lookups is in local cache, so
12843 external name servers do not even need to be queried.
12844 @end defvr
12845
12846 @anchor{syslog-configuration-type}
12847 @cindex syslog
12848 @cindex logging
12849 @deftp {Data Type} syslog-configuration
12850 This data type represents the configuration of the syslog daemon.
12851
12852 @table @asis
12853 @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
12854 The syslog daemon to use.
12855
12856 @item @code{config-file} (default: @code{%default-syslog.conf})
12857 The syslog configuration file to use.
12858
12859 @end table
12860 @end deftp
12861
12862 @anchor{syslog-service}
12863 @cindex syslog
12864 @deffn {Scheme Procedure} syslog-service @var{config}
12865 Return a service that runs a syslog daemon according to @var{config}.
12866
12867 @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
12868 information on the configuration file syntax.
12869 @end deffn
12870
12871 @defvr {Scheme Variable} guix-service-type
12872 This is the type of the service that runs the build daemon,
12873 @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
12874 @code{guix-configuration} record as described below.
12875 @end defvr
12876
12877 @anchor{guix-configuration-type}
12878 @deftp {Data Type} guix-configuration
12879 This data type represents the configuration of the Guix build daemon.
12880 @xref{Invoking guix-daemon}, for more information.
12881
12882 @table @asis
12883 @item @code{guix} (default: @var{guix})
12884 The Guix package to use.
12885
12886 @item @code{build-group} (default: @code{"guixbuild"})
12887 Name of the group for build user accounts.
12888
12889 @item @code{build-accounts} (default: @code{10})
12890 Number of build user accounts to create.
12891
12892 @item @code{authorize-key?} (default: @code{#t})
12893 @cindex substitutes, authorization thereof
12894 Whether to authorize the substitute keys listed in
12895 @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
12896 (@pxref{Substitutes}).
12897
12898 @vindex %default-authorized-guix-keys
12899 @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
12900 The list of authorized key files for archive imports, as a list of
12901 string-valued gexps (@pxref{Invoking guix archive}). By default, it
12902 contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
12903
12904 @item @code{use-substitutes?} (default: @code{#t})
12905 Whether to use substitutes.
12906
12907 @item @code{substitute-urls} (default: @code{%default-substitute-urls})
12908 The list of URLs where to look for substitutes by default.
12909
12910 @item @code{max-silent-time} (default: @code{0})
12911 @itemx @code{timeout} (default: @code{0})
12912 The number of seconds of silence and the number of seconds of activity,
12913 respectively, after which a build process times out. A value of zero
12914 disables the timeout.
12915
12916 @item @code{log-compression} (default: @code{'bzip2})
12917 The type of compression used for build logs---one of @code{gzip},
12918 @code{bzip2}, or @code{none}.
12919
12920 @item @code{extra-options} (default: @code{'()})
12921 List of extra command-line options for @command{guix-daemon}.
12922
12923 @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
12924 File where @command{guix-daemon}'s standard output and standard error
12925 are written.
12926
12927 @cindex HTTP proxy, for @code{guix-daemon}
12928 @cindex proxy, for @code{guix-daemon} HTTP access
12929 @item @code{http-proxy} (default: @code{#f})
12930 The URL of the HTTP and HTTPS proxy used for downloading fixed-output
12931 derivations and substitutes.
12932
12933 It is also possible to change the daemon's proxy at run time through the
12934 @code{set-http-proxy} action, which restarts it:
12935
12936 @example
12937 herd set-http-proxy guix-daemon http://localhost:8118
12938 @end example
12939
12940 To clear the proxy settings, run:
12941
12942 @example
12943 herd set-http-proxy guix-daemon
12944 @end example
12945
12946 @item @code{tmpdir} (default: @code{#f})
12947 A directory path where the @command{guix-daemon} will perform builds.
12948
12949 @end table
12950 @end deftp
12951
12952 @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
12953 Run @var{udev}, which populates the @file{/dev} directory dynamically.
12954 udev rules can be provided as a list of files through the @var{rules}
12955 variable. The procedures @code{udev-rule}, @code{udev-rules-service}
12956 and @code{file->udev-rule} from @code{(gnu services base)} simplify the
12957 creation of such rule files.
12958
12959 The @command{herd rules udev} command, as root, returns the name of the
12960 directory containing all the active udev rules.
12961 @end deffn
12962
12963 @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
12964 Return a udev-rule file named @var{file-name} containing the rules
12965 defined by the @var{contents} literal.
12966
12967 In the following example, a rule for a USB device is defined to be
12968 stored in the file @file{90-usb-thing.rules}. The rule runs a script
12969 upon detecting a USB device with a given product identifier.
12970
12971 @lisp
12972 (define %example-udev-rule
12973 (udev-rule
12974 "90-usb-thing.rules"
12975 (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
12976 "ATTR@{product@}==\"Example\", "
12977 "RUN+=\"/path/to/script\"")))
12978 @end lisp
12979 @end deffn
12980
12981 @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
12982 [#:groups @var{groups}]
12983 Return a service that extends @code{udev-service-type } with @var{rules}
12984 and @code{account-service-type} with @var{groups} as system groups.
12985 This works by creating a singleton service type
12986 @code{@var{name}-udev-rules}, of which the returned service is an
12987 instance.
12988
12989 Here we show how it can be used to extend @code{udev-service-type} with the
12990 previously defined rule @code{%example-udev-rule}.
12991
12992 @lisp
12993 (operating-system
12994 ;; @dots{}
12995 (services
12996 (cons (udev-rules-service 'usb-thing %example-udev-rule)
12997 %desktop-services)))
12998 @end lisp
12999 @end deffn
13000
13001 @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
13002 Return a udev file named @var{file-name} containing the rules defined
13003 within @var{file}, a file-like object.
13004
13005 The following example showcases how we can use an existing rule file.
13006
13007 @lisp
13008 (use-modules (guix download) ;for url-fetch
13009 (guix packages) ;for origin
13010 @dots{})
13011
13012 (define %android-udev-rules
13013 (file->udev-rule
13014 "51-android-udev.rules"
13015 (let ((version "20170910"))
13016 (origin
13017 (method url-fetch)
13018 (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
13019 "android-udev-rules/" version "/51-android.rules"))
13020 (sha256
13021 (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
13022 @end lisp
13023 @end deffn
13024
13025 Additionally, Guix package definitions can be included in @var{rules} in
13026 order to extend the udev rules with the definitions found under their
13027 @file{lib/udev/rules.d} sub-directory. In lieu of the previous
13028 @var{file->udev-rule} example, we could have used the
13029 @var{android-udev-rules} package which exists in Guix in the @code{(gnu
13030 packages android)} module.
13031
13032 The following example shows how to use the @var{android-udev-rules}
13033 package so that the Android tool @command{adb} can detect devices
13034 without root privileges. It also details how to create the
13035 @code{adbusers} group, which is required for the proper functioning of
13036 the rules defined within the @code{android-udev-rules} package. To
13037 create such a group, we must define it both as part of the
13038 @code{supplementary-groups} of our @code{user-account} declaration, as
13039 well as in the @var{groups} of the @code{udev-rules-service} procedure.
13040
13041 @lisp
13042 (use-modules (gnu packages android) ;for android-udev-rules
13043 (gnu system shadow) ;for user-group
13044 @dots{})
13045
13046 (operating-system
13047 ;; @dots{}
13048 (users (cons (user-account
13049 ;; @dots{}
13050 (supplementary-groups
13051 '("adbusers" ;for adb
13052 "wheel" "netdev" "audio" "video")))))
13053 ;; @dots{}
13054 (services
13055 (cons (udev-rules-service 'android android-udev-rules
13056 #:groups '("adbusers"))
13057 %desktop-services)))
13058 @end lisp
13059
13060 @defvr {Scheme Variable} urandom-seed-service-type
13061 Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
13062 when rebooting. It also tries to seed @file{/dev/urandom} from
13063 @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
13064 readable.
13065 @end defvr
13066
13067 @defvr {Scheme Variable} %random-seed-file
13068 This is the name of the file where some random bytes are saved by
13069 @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
13070 It defaults to @file{/var/lib/random-seed}.
13071 @end defvr
13072
13073 @cindex mouse
13074 @cindex gpm
13075 @defvr {Scheme Variable} gpm-service-type
13076 This is the type of the service that runs GPM, the @dfn{general-purpose
13077 mouse daemon}, which provides mouse support to the Linux console. GPM
13078 allows users to use the mouse in the console, notably to select, copy,
13079 and paste text.
13080
13081 The value for services of this type must be a @code{gpm-configuration}
13082 (see below). This service is not part of @code{%base-services}.
13083 @end defvr
13084
13085 @deftp {Data Type} gpm-configuration
13086 Data type representing the configuration of GPM.
13087
13088 @table @asis
13089 @item @code{options} (default: @code{%default-gpm-options})
13090 Command-line options passed to @command{gpm}. The default set of
13091 options instruct @command{gpm} to listen to mouse events on
13092 @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
13093 more information.
13094
13095 @item @code{gpm} (default: @code{gpm})
13096 The GPM package to use.
13097
13098 @end table
13099 @end deftp
13100
13101 @anchor{guix-publish-service-type}
13102 @deffn {Scheme Variable} guix-publish-service-type
13103 This is the service type for @command{guix publish} (@pxref{Invoking
13104 guix publish}). Its value must be a @code{guix-publish-configuration}
13105 object, as described below.
13106
13107 This assumes that @file{/etc/guix} already contains a signing key pair as
13108 created by @command{guix archive --generate-key} (@pxref{Invoking guix
13109 archive}). If that is not the case, the service will fail to start.
13110 @end deffn
13111
13112 @deftp {Data Type} guix-publish-configuration
13113 Data type representing the configuration of the @code{guix publish}
13114 service.
13115
13116 @table @asis
13117 @item @code{guix} (default: @code{guix})
13118 The Guix package to use.
13119
13120 @item @code{port} (default: @code{80})
13121 The TCP port to listen for connections.
13122
13123 @item @code{host} (default: @code{"localhost"})
13124 The host (and thus, network interface) to listen to. Use
13125 @code{"0.0.0.0"} to listen on all the network interfaces.
13126
13127 @item @code{compression} (default: @code{'(("gzip" 3))})
13128 This is a list of compression method/level tuple used when compressing
13129 substitutes. For example, to compress all substitutes with @emph{both} lzip
13130 at level 7 and gzip at level 9, write:
13131
13132 @lisp
13133 '(("lzip" 7) ("gzip" 9))
13134 @end lisp
13135
13136 Level 9 achieves the best compression ratio at the expense of increased CPU
13137 usage, whereas level 1 achieves fast compression.
13138
13139 An empty list disables compression altogether.
13140
13141 @item @code{nar-path} (default: @code{"nar"})
13142 The URL path at which ``nars'' can be fetched. @xref{Invoking guix
13143 publish, @option{--nar-path}}, for details.
13144
13145 @item @code{cache} (default: @code{#f})
13146 When it is @code{#f}, disable caching and instead generate archives on
13147 demand. Otherwise, this should be the name of a directory---e.g.,
13148 @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
13149 archives and meta-data ready to be sent. @xref{Invoking guix publish,
13150 @option{--cache}}, for more information on the tradeoffs involved.
13151
13152 @item @code{workers} (default: @code{#f})
13153 When it is an integer, this is the number of worker threads used for
13154 caching; when @code{#f}, the number of processors is used.
13155 @xref{Invoking guix publish, @option{--workers}}, for more information.
13156
13157 @item @code{ttl} (default: @code{#f})
13158 When it is an integer, this denotes the @dfn{time-to-live} in seconds
13159 of the published archives. @xref{Invoking guix publish, @option{--ttl}},
13160 for more information.
13161 @end table
13162 @end deftp
13163
13164 @anchor{rngd-service}
13165 @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
13166 [#:device "/dev/hwrng"]
13167 Return a service that runs the @command{rngd} program from @var{rng-tools}
13168 to add @var{device} to the kernel's entropy pool. The service will fail if
13169 @var{device} does not exist.
13170 @end deffn
13171
13172 @anchor{pam-limits-service}
13173 @cindex session limits
13174 @cindex ulimit
13175 @cindex priority
13176 @cindex realtime
13177 @cindex jackd
13178 @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
13179
13180 Return a service that installs a configuration file for the
13181 @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
13182 @code{pam_limits} module}. The procedure optionally takes a list of
13183 @code{pam-limits-entry} values, which can be used to specify
13184 @code{ulimit} limits and nice priority limits to user sessions.
13185
13186 The following limits definition sets two hard and soft limits for all
13187 login sessions of users in the @code{realtime} group:
13188
13189 @lisp
13190 (pam-limits-service
13191 (list
13192 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
13193 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
13194 @end lisp
13195
13196 The first entry increases the maximum realtime priority for
13197 non-privileged processes; the second entry lifts any restriction of the
13198 maximum address space that can be locked in memory. These settings are
13199 commonly used for real-time audio systems.
13200 @end deffn
13201
13202 @node Scheduled Job Execution
13203 @subsection Scheduled Job Execution
13204
13205 @cindex cron
13206 @cindex mcron
13207 @cindex scheduling jobs
13208 The @code{(gnu services mcron)} module provides an interface to
13209 GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
13210 mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
13211 Unix @command{cron} daemon; the main difference is that it is
13212 implemented in Guile Scheme, which provides a lot of flexibility when
13213 specifying the scheduling of jobs and their actions.
13214
13215 The example below defines an operating system that runs the
13216 @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
13217 and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
13218 well as the @command{mkid} command on behalf of an unprivileged user
13219 (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
13220 gexps to introduce job definitions that are passed to mcron
13221 (@pxref{G-Expressions}).
13222
13223 @lisp
13224 (use-modules (guix) (gnu) (gnu services mcron))
13225 (use-package-modules base idutils)
13226
13227 (define updatedb-job
13228 ;; Run 'updatedb' at 3AM every day. Here we write the
13229 ;; job's action as a Scheme procedure.
13230 #~(job '(next-hour '(3))
13231 (lambda ()
13232 (execl (string-append #$findutils "/bin/updatedb")
13233 "updatedb"
13234 "--prunepaths=/tmp /var/tmp /gnu/store"))))
13235
13236 (define garbage-collector-job
13237 ;; Collect garbage 5 minutes after midnight every day.
13238 ;; The job's action is a shell command.
13239 #~(job "5 0 * * *" ;Vixie cron syntax
13240 "guix gc -F 1G"))
13241
13242 (define idutils-job
13243 ;; Update the index database as user "charlie" at 12:15PM
13244 ;; and 19:15PM. This runs from the user's home directory.
13245 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
13246 (string-append #$idutils "/bin/mkid src")
13247 #:user "charlie"))
13248
13249 (operating-system
13250 ;; @dots{}
13251 (services (cons (service mcron-service-type
13252 (mcron-configuration
13253 (jobs (list garbage-collector-job
13254 updatedb-job
13255 idutils-job))))
13256 %base-services)))
13257 @end lisp
13258
13259 For more complex jobs defined in Scheme where you need control over the top
13260 level, for instance to introduce a @code{use-modules} form, you can move your
13261 code to a separate program using the @code{program-file} procedure of the
13262 @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
13263 illustrates that.
13264
13265 @lisp
13266 (define %battery-alert-job
13267 ;; Beep when the battery percentage falls below %MIN-LEVEL.
13268 #~(job
13269 '(next-minute (range 0 60 1))
13270 #$(program-file
13271 "battery-alert.scm"
13272 (with-imported-modules (source-module-closure
13273 '((guix build utils)))
13274 #~(begin
13275 (define %min-level 20)
13276 (use-modules (guix build utils)
13277 (ice-9 popen)
13278 (ice-9 regex)
13279 (ice-9 textual-ports)
13280 (srfi srfi-2))
13281 (setenv "LC_ALL" "C") ;ensure English output
13282 (and-let* ((input-pipe (open-pipe*
13283 OPEN_READ
13284 #$(file-append acpi "/bin/acpi")))
13285 (output (get-string-all input-pipe))
13286 (m (string-match "Discharging, ([0-9]+)%" output))
13287 (level (string->number (match:substring m 1)))
13288 ((< level %min-level)))
13289 (format #t "warning: Battery level is low (~a%)~%" level)
13290 (invoke #$(file-append beep "/bin/beep") "-r5")))))))
13291 @end lisp
13292
13293 @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
13294 for more information on mcron job specifications. Below is the
13295 reference of the mcron service.
13296
13297 On a running system, you can use the @code{schedule} action of the service to
13298 visualize the mcron jobs that will be executed next:
13299
13300 @example
13301 # herd schedule mcron
13302 @end example
13303
13304 @noindent
13305 The example above lists the next five tasks that will be executed, but you can
13306 also specify the number of tasks to display:
13307
13308 @example
13309 # herd schedule mcron 10
13310 @end example
13311
13312 @defvr {Scheme Variable} mcron-service-type
13313 This is the type of the @code{mcron} service, whose value is an
13314 @code{mcron-configuration} object.
13315
13316 This service type can be the target of a service extension that provides
13317 it additional job specifications (@pxref{Service Composition}). In
13318 other words, it is possible to define services that provide additional
13319 mcron jobs to run.
13320 @end defvr
13321
13322 @deftp {Data Type} mcron-configuration
13323 Data type representing the configuration of mcron.
13324
13325 @table @asis
13326 @item @code{mcron} (default: @var{mcron})
13327 The mcron package to use.
13328
13329 @item @code{jobs}
13330 This is a list of gexps (@pxref{G-Expressions}), where each gexp
13331 corresponds to an mcron job specification (@pxref{Syntax, mcron job
13332 specifications,, mcron, GNU@tie{}mcron}).
13333 @end table
13334 @end deftp
13335
13336
13337 @node Log Rotation
13338 @subsection Log Rotation
13339
13340 @cindex rottlog
13341 @cindex log rotation
13342 @cindex logging
13343 Log files such as those found in @file{/var/log} tend to grow endlessly,
13344 so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
13345 their contents in separate files, possibly compressed. The @code{(gnu
13346 services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
13347 log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
13348
13349 This service is part of @code{%base-services}, and thus enabled by
13350 default, with the default settings, for commonly encountered log files.
13351 The example below shows how to extend it with an additional
13352 @dfn{rotation}, should you need to do that (usually, services that
13353 produce log files already take care of that):
13354
13355 @lisp
13356 (use-modules (guix) (gnu))
13357 (use-service-modules admin)
13358
13359 (define my-log-files
13360 ;; Log files that I want to rotate.
13361 '("/var/log/something.log" "/var/log/another.log"))
13362
13363 (operating-system
13364 ;; @dots{}
13365 (services (cons (simple-service 'rotate-my-stuff
13366 rottlog-service-type
13367 (list (log-rotation
13368 (frequency 'daily)
13369 (files my-log-files))))
13370 %base-services)))
13371 @end lisp
13372
13373 @defvr {Scheme Variable} rottlog-service-type
13374 This is the type of the Rottlog service, whose value is a
13375 @code{rottlog-configuration} object.
13376
13377 Other services can extend this one with new @code{log-rotation} objects
13378 (see below), thereby augmenting the set of files to be rotated.
13379
13380 This service type can define mcron jobs (@pxref{Scheduled Job
13381 Execution}) to run the rottlog service.
13382 @end defvr
13383
13384 @deftp {Data Type} rottlog-configuration
13385 Data type representing the configuration of rottlog.
13386
13387 @table @asis
13388 @item @code{rottlog} (default: @code{rottlog})
13389 The Rottlog package to use.
13390
13391 @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
13392 The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
13393 rottlog, GNU Rot[t]log Manual}).
13394
13395 @item @code{rotations} (default: @code{%default-rotations})
13396 A list of @code{log-rotation} objects as defined below.
13397
13398 @item @code{jobs}
13399 This is a list of gexps where each gexp corresponds to an mcron job
13400 specification (@pxref{Scheduled Job Execution}).
13401 @end table
13402 @end deftp
13403
13404 @deftp {Data Type} log-rotation
13405 Data type representing the rotation of a group of log files.
13406
13407 Taking an example from the Rottlog manual (@pxref{Period Related File
13408 Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
13409 defined like this:
13410
13411 @lisp
13412 (log-rotation
13413 (frequency 'daily)
13414 (files '("/var/log/apache/*"))
13415 (options '("storedir apache-archives"
13416 "rotate 6"
13417 "notifempty"
13418 "nocompress")))
13419 @end lisp
13420
13421 The list of fields is as follows:
13422
13423 @table @asis
13424 @item @code{frequency} (default: @code{'weekly})
13425 The log rotation frequency, a symbol.
13426
13427 @item @code{files}
13428 The list of files or file glob patterns to rotate.
13429
13430 @item @code{options} (default: @code{'()})
13431 The list of rottlog options for this rotation (@pxref{Configuration
13432 parameters,,, rottlog, GNU Rot[t]lg Manual}).
13433
13434 @item @code{post-rotate} (default: @code{#f})
13435 Either @code{#f} or a gexp to execute once the rotation has completed.
13436 @end table
13437 @end deftp
13438
13439 @defvr {Scheme Variable} %default-rotations
13440 Specifies weekly rotation of @code{%rotated-files} and of
13441 @file{/var/log/guix-daemon.log}.
13442 @end defvr
13443
13444 @defvr {Scheme Variable} %rotated-files
13445 The list of syslog-controlled files to be rotated. By default it is:
13446 @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
13447 "/var/log/maillog")}.
13448 @end defvr
13449
13450 @node Networking Services
13451 @subsection Networking Services
13452
13453 The @code{(gnu services networking)} module provides services to configure
13454 the network interface.
13455
13456 @cindex DHCP, networking service
13457 @defvr {Scheme Variable} dhcp-client-service-type
13458 This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
13459 Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
13460 is the DHCP client package to use, @code{isc-dhcp} by default.
13461 @end defvr
13462
13463 @deffn {Scheme Procedure} dhcpd-service-type
13464 This type defines a service that runs a DHCP daemon. To create a
13465 service of this type, you must supply a @code{<dhcpd-configuration>}.
13466 For example:
13467
13468 @lisp
13469 (service dhcpd-service-type
13470 (dhcpd-configuration
13471 (config-file (local-file "my-dhcpd.conf"))
13472 (interfaces '("enp0s25"))))
13473 @end lisp
13474 @end deffn
13475
13476 @deftp {Data Type} dhcpd-configuration
13477 @table @asis
13478 @item @code{package} (default: @code{isc-dhcp})
13479 The package that provides the DHCP daemon. This package is expected to
13480 provide the daemon at @file{sbin/dhcpd} relative to its output
13481 directory. The default package is the
13482 @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
13483 @item @code{config-file} (default: @code{#f})
13484 The configuration file to use. This is required. It will be passed to
13485 @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
13486 object (@pxref{G-Expressions, file-like objects}). See @code{man
13487 dhcpd.conf} for details on the configuration file syntax.
13488 @item @code{version} (default: @code{"4"})
13489 The DHCP version to use. The ISC DHCP server supports the values ``4'',
13490 ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
13491 options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
13492 details.
13493 @item @code{run-directory} (default: @code{"/run/dhcpd"})
13494 The run directory to use. At service activation time, this directory
13495 will be created if it does not exist.
13496 @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
13497 The PID file to use. This corresponds to the @code{-pf} option of
13498 @code{dhcpd}. See @code{man dhcpd} for details.
13499 @item @code{interfaces} (default: @code{'()})
13500 The names of the network interfaces on which dhcpd should listen for
13501 broadcasts. If this list is not empty, then its elements (which must be
13502 strings) will be appended to the @code{dhcpd} invocation when starting
13503 the daemon. It may not be necessary to explicitly specify any
13504 interfaces here; see @code{man dhcpd} for details.
13505 @end table
13506 @end deftp
13507
13508 @defvr {Scheme Variable} static-networking-service-type
13509 This is the type for statically-configured network interfaces.
13510 @c TODO Document <static-networking> data structures.
13511 @end defvr
13512
13513 @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
13514 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
13515 [#:requirement @code{'(udev)}]
13516 Return a service that starts @var{interface} with address @var{ip}. If
13517 @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
13518 it must be a string specifying the default network gateway. @var{requirement}
13519 can be used to declare a dependency on another service before configuring the
13520 interface.
13521
13522 This procedure can be called several times, one for each network
13523 interface of interest. Behind the scenes what it does is extend
13524 @code{static-networking-service-type} with additional network interfaces
13525 to handle.
13526
13527 For example:
13528
13529 @lisp
13530 (static-networking-service "eno1" "192.168.1.82"
13531 #:gateway "192.168.1.2"
13532 #:name-servers '("192.168.1.2"))
13533 @end lisp
13534 @end deffn
13535
13536 @cindex wicd
13537 @cindex wireless
13538 @cindex WiFi
13539 @cindex network management
13540 @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
13541 Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
13542 management daemon that aims to simplify wired and wireless networking.
13543
13544 This service adds the @var{wicd} package to the global profile, providing
13545 several commands to interact with the daemon and configure networking:
13546 @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
13547 and @command{wicd-curses} user interfaces.
13548 @end deffn
13549
13550 @cindex ModemManager
13551
13552 @defvr {Scheme Variable} modem-manager-service-type
13553 This is the service type for the
13554 @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
13555 service. The value for this service type is a
13556 @code{modem-manager-configuration} record.
13557
13558 This service is part of @code{%desktop-services} (@pxref{Desktop
13559 Services}).
13560 @end defvr
13561
13562 @deftp {Data Type} modem-manager-configuration
13563 Data type representing the configuration of ModemManager.
13564
13565 @table @asis
13566 @item @code{modem-manager} (default: @code{modem-manager})
13567 The ModemManager package to use.
13568
13569 @end table
13570 @end deftp
13571
13572 @cindex USB_ModeSwitch
13573 @cindex Modeswitching
13574
13575 @defvr {Scheme Variable} usb-modeswitch-service-type
13576 This is the service type for the
13577 @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch} service. The
13578 value for this service type is a @code{usb-modeswitch-configuration} record.
13579
13580 When plugged in, some USB modems (and other USB devices) initially present
13581 themselves as a read-only storage medium and not as a modem. They need to be
13582 @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
13583 installs udev rules to automatically modeswitch these devices when they are
13584 plugged in.
13585
13586 This service is part of @code{%desktop-services} (@pxref{Desktop
13587 Services}).
13588 @end defvr
13589
13590 @deftp {Data Type} usb-modeswitch-configuration
13591 Data type representing the configuration of USB_ModeSwitch.
13592
13593 @table @asis
13594 @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
13595 The USB_ModeSwitch package providing the binaries for modeswitching.
13596
13597 @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
13598 The package providing the device data and udev rules file used by
13599 USB_ModeSwitch.
13600
13601 @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
13602 Which config file to use for the USB_ModeSwitch dispatcher. By default the
13603 config file shipped with USB_ModeSwitch is used which disables logging to
13604 @file{/var/log} among other default settings. If set to @code{#f}, no config
13605 file is used.
13606
13607 @end table
13608 @end deftp
13609
13610 @cindex NetworkManager
13611
13612 @defvr {Scheme Variable} network-manager-service-type
13613 This is the service type for the
13614 @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
13615 service. The value for this service type is a
13616 @code{network-manager-configuration} record.
13617
13618 This service is part of @code{%desktop-services} (@pxref{Desktop
13619 Services}).
13620 @end defvr
13621
13622 @deftp {Data Type} network-manager-configuration
13623 Data type representing the configuration of NetworkManager.
13624
13625 @table @asis
13626 @item @code{network-manager} (default: @code{network-manager})
13627 The NetworkManager package to use.
13628
13629 @item @code{dns} (default: @code{"default"})
13630 Processing mode for DNS, which affects how NetworkManager uses the
13631 @code{resolv.conf} configuration file.
13632
13633 @table @samp
13634 @item default
13635 NetworkManager will update @code{resolv.conf} to reflect the nameservers
13636 provided by currently active connections.
13637
13638 @item dnsmasq
13639 NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
13640 @dfn{conditional forwarding} configuration if you are connected to a VPN, and
13641 then update @code{resolv.conf} to point to the local nameserver.
13642
13643 With this setting, you can share your network connection. For example when
13644 you want to share your network connection to another laptop @i{via} an
13645 Ethernet cable, you can open @command{nm-connection-editor} and configure the
13646 Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
13647 and reestablish the connection (or reboot).
13648
13649 You can also set up a @dfn{host-to-guest connection} to QEMU VMs
13650 (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
13651 e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
13652 browser on your host system, or connect to the VM @i{via} SSH
13653 (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
13654 host-to-guest connection, run this command once:
13655
13656 @example
13657 nmcli connection add type tun \
13658 connection.interface-name tap0 \
13659 tun.mode tap tun.owner $(id -u) \
13660 ipv4.method shared \
13661 ipv4.addresses 172.28.112.1/24
13662 @end example
13663
13664 Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
13665 @option{-nic tap,ifname=tap0,script=no,downscript=no} to
13666 @command{qemu-system-...}.
13667
13668 @item none
13669 NetworkManager will not modify @code{resolv.conf}.
13670 @end table
13671
13672 @item @code{vpn-plugins} (default: @code{'()})
13673 This is the list of available plugins for virtual private networks
13674 (VPNs). An example of this is the @code{network-manager-openvpn}
13675 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
13676
13677 @end table
13678 @end deftp
13679
13680 @cindex Connman
13681 @deffn {Scheme Variable} connman-service-type
13682 This is the service type to run @url{https://01.org/connman,Connman},
13683 a network connection manager.
13684
13685 Its value must be an
13686 @code{connman-configuration} record as in this example:
13687
13688 @lisp
13689 (service connman-service-type
13690 (connman-configuration
13691 (disable-vpn? #t)))
13692 @end lisp
13693
13694 See below for details about @code{connman-configuration}.
13695 @end deffn
13696
13697 @deftp {Data Type} connman-configuration
13698 Data Type representing the configuration of connman.
13699
13700 @table @asis
13701 @item @code{connman} (default: @var{connman})
13702 The connman package to use.
13703
13704 @item @code{disable-vpn?} (default: @code{#f})
13705 When true, disable connman's vpn plugin.
13706 @end table
13707 @end deftp
13708
13709 @cindex WPA Supplicant
13710 @defvr {Scheme Variable} wpa-supplicant-service-type
13711 This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
13712 supplicant}, an authentication daemon required to authenticate against
13713 encrypted WiFi or ethernet networks.
13714 @end defvr
13715
13716 @deftp {Data Type} wpa-supplicant-configuration
13717 Data type representing the configuration of WPA Supplicant.
13718
13719 It takes the following parameters:
13720
13721 @table @asis
13722 @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
13723 The WPA Supplicant package to use.
13724
13725 @item @code{dbus?} (default: @code{#t})
13726 Whether to listen for requests on D-Bus.
13727
13728 @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
13729 Where to store the PID file.
13730
13731 @item @code{interface} (default: @code{#f})
13732 If this is set, it must specify the name of a network interface that
13733 WPA supplicant will control.
13734
13735 @item @code{config-file} (default: @code{#f})
13736 Optional configuration file to use.
13737
13738 @item @code{extra-options} (default: @code{'()})
13739 List of additional command-line arguments to pass to the daemon.
13740 @end table
13741 @end deftp
13742
13743 @cindex hostapd service, for Wi-Fi access points
13744 @cindex Wi-Fi access points, hostapd service
13745 @defvr {Scheme Variable} hostapd-service-type
13746 This is the service type to run the @uref{https://w1.fi/hostapd/,
13747 hostapd} daemon to set up WiFi (IEEE 802.11) access points and
13748 authentication servers. Its associated value must be a
13749 @code{hostapd-configuration} as shown below:
13750
13751 @lisp
13752 ;; Use wlan1 to run the access point for "My Network".
13753 (service hostapd-service-type
13754 (hostapd-configuration
13755 (interface "wlan1")
13756 (ssid "My Network")
13757 (channel 12)))
13758 @end lisp
13759 @end defvr
13760
13761 @deftp {Data Type} hostapd-configuration
13762 This data type represents the configuration of the hostapd service, with
13763 the following fields:
13764
13765 @table @asis
13766 @item @code{package} (default: @code{hostapd})
13767 The hostapd package to use.
13768
13769 @item @code{interface} (default: @code{"wlan0"})
13770 The network interface to run the WiFi access point.
13771
13772 @item @code{ssid}
13773 The SSID (@dfn{service set identifier}), a string that identifies this
13774 network.
13775
13776 @item @code{broadcast-ssid?} (default: @code{#t})
13777 Whether to broadcast this SSID.
13778
13779 @item @code{channel} (default: @code{1})
13780 The WiFi channel to use.
13781
13782 @item @code{driver} (default: @code{"nl80211"})
13783 The driver interface type. @code{"nl80211"} is used with all Linux
13784 mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
13785 RADIUS server that does # not control any wireless/wired driver.
13786
13787 @item @code{extra-settings} (default: @code{""})
13788 Extra settings to append as-is to the hostapd configuration file. See
13789 @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
13790 configuration file reference.
13791 @end table
13792 @end deftp
13793
13794 @defvr {Scheme Variable} simulated-wifi-service-type
13795 This is the type of a service to simulate WiFi networking, which can be
13796 useful in virtual machines for testing purposes. The service loads the
13797 Linux kernel
13798 @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
13799 @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
13800 network that can be seen on @code{wlan0}, by default.
13801
13802 The service's value is a @code{hostapd-configuration} record.
13803 @end defvr
13804
13805 @cindex iptables
13806 @defvr {Scheme Variable} iptables-service-type
13807 This is the service type to set up an iptables configuration. iptables is a
13808 packet filtering framework supported by the Linux kernel. This service
13809 supports configuring iptables for both IPv4 and IPv6. A simple example
13810 configuration rejecting all incoming connections except those to the ssh port
13811 22 is shown below.
13812
13813 @lisp
13814 (service iptables-service-type
13815 (iptables-configuration
13816 (ipv4-rules (plain-file "iptables.rules" "*filter
13817 :INPUT ACCEPT
13818 :FORWARD ACCEPT
13819 :OUTPUT ACCEPT
13820 -A INPUT -p tcp --dport 22 -j ACCEPT
13821 -A INPUT -j REJECT --reject-with icmp-port-unreachable
13822 COMMIT
13823 "))
13824 (ipv6-rules (plain-file "ip6tables.rules" "*filter
13825 :INPUT ACCEPT
13826 :FORWARD ACCEPT
13827 :OUTPUT ACCEPT
13828 -A INPUT -p tcp --dport 22 -j ACCEPT
13829 -A INPUT -j REJECT --reject-with icmp6-port-unreachable
13830 COMMIT
13831 "))))
13832 @end lisp
13833 @end defvr
13834
13835 @deftp {Data Type} iptables-configuration
13836 The data type representing the configuration of iptables.
13837
13838 @table @asis
13839 @item @code{iptables} (default: @code{iptables})
13840 The iptables package that provides @code{iptables-restore} and
13841 @code{ip6tables-restore}.
13842 @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
13843 The iptables rules to use. It will be passed to @code{iptables-restore}.
13844 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
13845 objects}).
13846 @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
13847 The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
13848 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
13849 objects}).
13850 @end table
13851 @end deftp
13852
13853 @cindex nftables
13854 @defvr {Scheme Variable} nftables-service-type
13855 This is the service type to set up a nftables configuration. nftables is a
13856 netfilter project that aims to replace the existing iptables, ip6tables,
13857 arptables and ebtables framework. It provides a new packet filtering
13858 framework, a new user-space utility @command{nft}, and a compatibility layer
13859 for iptables. This service comes with a default ruleset
13860 @code{%default-nftables-ruleset} that rejecting all incomming connections
13861 except those to the ssh port 22. To use it, simply write:
13862
13863 @lisp
13864 (service nftables-service-type)
13865 @end lisp
13866 @end defvr
13867
13868 @deftp {Data Type} nftables-configuration
13869 The data type representing the configuration of nftables.
13870
13871 @table @asis
13872 @item @code{package} (default: @code{nftables})
13873 The nftables package that provides @command{nft}.
13874 @item @code{ruleset} (default: @code{%default-nftables-ruleset})
13875 The nftables ruleset to use. This may be any ``file-like'' object
13876 (@pxref{G-Expressions, file-like objects}).
13877 @end table
13878 @end deftp
13879
13880 @cindex NTP (Network Time Protocol), service
13881 @cindex ntpd, service for the Network Time Protocol daemon
13882 @cindex real time clock
13883 @defvr {Scheme Variable} ntp-service-type
13884 This is the type of the service running the @uref{https://www.ntp.org,
13885 Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
13886 system clock synchronized with that of the specified NTP servers.
13887
13888 The value of this service is an @code{ntpd-configuration} object, as described
13889 below.
13890 @end defvr
13891
13892 @deftp {Data Type} ntp-configuration
13893 This is the data type for the NTP service configuration.
13894
13895 @table @asis
13896 @item @code{servers} (default: @code{%ntp-servers})
13897 This is the list of servers (@code{<ntp-server>} records) with which
13898 @command{ntpd} will be synchronized. See the @code{ntp-server} data type
13899 definition below.
13900
13901 @item @code{allow-large-adjustment?} (default: @code{#t})
13902 This determines whether @command{ntpd} is allowed to make an initial
13903 adjustment of more than 1,000 seconds.
13904
13905 @item @code{ntp} (default: @code{ntp})
13906 The NTP package to use.
13907 @end table
13908 @end deftp
13909
13910 @defvr {Scheme Variable} %ntp-servers
13911 List of host names used as the default NTP servers. These are servers of the
13912 @uref{https://www.ntppool.org/en/, NTP Pool Project}.
13913 @end defvr
13914
13915 @deftp {Data Type} ntp-server
13916 The data type representing the configuration of a NTP server.
13917
13918 @table @asis
13919 @item @code{type} (default: @code{'server})
13920 The type of the NTP server, given as a symbol. One of @code{'pool},
13921 @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
13922
13923 @item @code{address}
13924 The address of the server, as a string.
13925
13926 @item @code{options}
13927 NTPD options to use with that specific server, given as a list of option names
13928 and/or of option names and values tuples. The following example define a server
13929 to use with the options @option{iburst} and @option{prefer}, as well as
13930 @option{version} 3 and a @option{maxpoll} time of 16 seconds.
13931
13932 @example
13933 (ntp-server
13934 (type 'server)
13935 (address "some.ntp.server.org")
13936 (options `(iburst (version 3) (maxpoll 16) prefer))))
13937 @end example
13938 @end table
13939 @end deftp
13940
13941 @cindex OpenNTPD
13942 @deffn {Scheme Procedure} openntpd-service-type
13943 Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
13944 by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
13945 clock synchronized with that of the given servers.
13946
13947 @lisp
13948 (service
13949 openntpd-service-type
13950 (openntpd-configuration
13951 (listen-on '("127.0.0.1" "::1"))
13952 (sensor '("udcf0 correction 70000"))
13953 (constraint-from '("www.gnu.org"))
13954 (constraints-from '("https://www.google.com/"))
13955 (allow-large-adjustment? #t)))
13956
13957 @end lisp
13958 @end deffn
13959
13960 @defvr {Scheme Variable} %openntpd-servers
13961 This variable is a list of the server addresses defined in
13962 @code{%ntp-servers}.
13963 @end defvr
13964
13965 @deftp {Data Type} openntpd-configuration
13966 @table @asis
13967 @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
13968 The openntpd executable to use.
13969 @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
13970 A list of local IP addresses or hostnames the ntpd daemon should listen on.
13971 @item @code{query-from} (default: @code{'()})
13972 A list of local IP address the ntpd daemon should use for outgoing queries.
13973 @item @code{sensor} (default: @code{'()})
13974 Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
13975 will listen to each sensor that actually exists and ignore non-existent ones.
13976 See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
13977 information.
13978 @item @code{server} (default: @code{'()})
13979 Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
13980 @item @code{servers} (default: @code{%openntp-servers})
13981 Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
13982 @item @code{constraint-from} (default: @code{'()})
13983 @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
13984 This time information is not used for precision but acts as an authenticated
13985 constraint, thereby reducing the impact of unauthenticated NTP
13986 man-in-the-middle attacks.
13987 Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
13988 a constraint.
13989 @item @code{constraints-from} (default: @code{'()})
13990 As with constraint from, specify a list of URLs, IP addresses or hostnames of
13991 HTTPS servers to provide a constraint. Should the hostname resolve to multiple
13992 IP addresses, @code{ntpd} will calculate a median constraint from all of them.
13993 @item @code{allow-large-adjustment?} (default: @code{#f})
13994 Determines if @code{ntpd} is allowed to make an initial adjustment of more
13995 than 180 seconds.
13996 @end table
13997 @end deftp
13998
13999 @cindex inetd
14000 @deffn {Scheme variable} inetd-service-type
14001 This service runs the @command{inetd} (@pxref{inetd invocation,,,
14002 inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
14003 connections on internet sockets, and lazily starts the specified server
14004 program when a connection is made on one of these sockets.
14005
14006 The value of this service is an @code{inetd-configuration} object. The
14007 following example configures the @command{inetd} daemon to provide the
14008 built-in @command{echo} service, as well as an smtp service which
14009 forwards smtp traffic over ssh to a server @code{smtp-server} behind a
14010 gateway @code{hostname}:
14011
14012 @lisp
14013 (service
14014 inetd-service-type
14015 (inetd-configuration
14016 (entries (list
14017 (inetd-entry
14018 (name "echo")
14019 (socket-type 'stream)
14020 (protocol "tcp")
14021 (wait? #f)
14022 (user "root"))
14023 (inetd-entry
14024 (node "127.0.0.1")
14025 (name "smtp")
14026 (socket-type 'stream)
14027 (protocol "tcp")
14028 (wait? #f)
14029 (user "root")
14030 (program (file-append openssh "/bin/ssh"))
14031 (arguments
14032 '("ssh" "-qT" "-i" "/path/to/ssh_key"
14033 "-W" "smtp-server:25" "user@@hostname")))))))
14034 @end lisp
14035
14036 See below for more details about @code{inetd-configuration}.
14037 @end deffn
14038
14039 @deftp {Data Type} inetd-configuration
14040 Data type representing the configuration of @command{inetd}.
14041
14042 @table @asis
14043 @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
14044 The @command{inetd} executable to use.
14045
14046 @item @code{entries} (default: @code{'()})
14047 A list of @command{inetd} service entries. Each entry should be created
14048 by the @code{inetd-entry} constructor.
14049 @end table
14050 @end deftp
14051
14052 @deftp {Data Type} inetd-entry
14053 Data type representing an entry in the @command{inetd} configuration.
14054 Each entry corresponds to a socket where @command{inetd} will listen for
14055 requests.
14056
14057 @table @asis
14058 @item @code{node} (default: @code{#f})
14059 Optional string, a comma-separated list of local addresses
14060 @command{inetd} should use when listening for this service.
14061 @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
14062 description of all options.
14063 @item @code{name}
14064 A string, the name must correspond to an entry in @code{/etc/services}.
14065 @item @code{socket-type}
14066 One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
14067 @code{'seqpacket}.
14068 @item @code{protocol}
14069 A string, must correspond to an entry in @code{/etc/protocols}.
14070 @item @code{wait?} (default: @code{#t})
14071 Whether @command{inetd} should wait for the server to exit before
14072 listening to new service requests.
14073 @item @code{user}
14074 A string containing the user (and, optionally, group) name of the user
14075 as whom the server should run. The group name can be specified in a
14076 suffix, separated by a colon or period, i.e.@: @code{"user"},
14077 @code{"user:group"} or @code{"user.group"}.
14078 @item @code{program} (default: @code{"internal"})
14079 The server program which will serve the requests, or @code{"internal"}
14080 if @command{inetd} should use a built-in service.
14081 @item @code{arguments} (default: @code{'()})
14082 A list strings or file-like objects, which are the server program's
14083 arguments, starting with the zeroth argument, i.e.@: the name of the
14084 program itself. For @command{inetd}'s internal services, this entry
14085 must be @code{'()} or @code{'("internal")}.
14086 @end table
14087
14088 @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
14089 detailed discussion of each configuration field.
14090 @end deftp
14091
14092 @cindex Tor
14093 @defvr {Scheme Variable} tor-service-type
14094 This is the type for a service that runs the @uref{https://torproject.org,
14095 Tor} anonymous networking daemon. The service is configured using a
14096 @code{<tor-configuration>} record. By default, the Tor daemon runs as the
14097 @code{tor} unprivileged user, which is a member of the @code{tor} group.
14098
14099 @end defvr
14100
14101 @deftp {Data Type} tor-configuration
14102 @table @asis
14103 @item @code{tor} (default: @code{tor})
14104 The package that provides the Tor daemon. This package is expected to provide
14105 the daemon at @file{bin/tor} relative to its output directory. The default
14106 package is the @uref{https://www.torproject.org, Tor Project's}
14107 implementation.
14108
14109 @item @code{config-file} (default: @code{(plain-file "empty" "")})
14110 The configuration file to use. It will be appended to a default configuration
14111 file, and the final configuration file will be passed to @code{tor} via its
14112 @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
14113 file-like objects}). See @code{man tor} for details on the configuration file
14114 syntax.
14115
14116 @item @code{hidden-services} (default: @code{'()})
14117 The list of @code{<hidden-service>} records to use. For any hidden service
14118 you include in this list, appropriate configuration to enable the hidden
14119 service will be automatically added to the default configuration file. You
14120 may conveniently create @code{<hidden-service>} records using the
14121 @code{tor-hidden-service} procedure described below.
14122
14123 @item @code{socks-socket-type} (default: @code{'tcp})
14124 The default socket type that Tor should use for its SOCKS socket. This must
14125 be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
14126 Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
14127 If it is @code{'unix}, then Tor will listen on the UNIX domain socket
14128 @file{/var/run/tor/socks-sock}, which will be made writable by members of the
14129 @code{tor} group.
14130
14131 If you want to customize the SOCKS socket in more detail, leave
14132 @code{socks-socket-type} at its default value of @code{'tcp} and use
14133 @code{config-file} to override the default by providing your own
14134 @code{SocksPort} option.
14135 @end table
14136 @end deftp
14137
14138 @cindex hidden service
14139 @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
14140 Define a new Tor @dfn{hidden service} called @var{name} and implementing
14141 @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
14142
14143 @example
14144 '((22 "127.0.0.1:22")
14145 (80 "127.0.0.1:8080"))
14146 @end example
14147
14148 In this example, port 22 of the hidden service is mapped to local port 22, and
14149 port 80 is mapped to local port 8080.
14150
14151 This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
14152 the @file{hostname} file contains the @code{.onion} host name for the hidden
14153 service.
14154
14155 See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
14156 project's documentation} for more information.
14157 @end deffn
14158
14159 The @code{(gnu services rsync)} module provides the following services:
14160
14161 You might want an rsync daemon if you have files that you want available
14162 so anyone (or just yourself) can download existing files or upload new
14163 files.
14164
14165 @deffn {Scheme Variable} rsync-service-type
14166 This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
14167 The value for this service type is a
14168 @command{rsync-configuration} record as in this example:
14169
14170 @lisp
14171 (service rsync-service-type)
14172 @end lisp
14173
14174 See below for details about @code{rsync-configuration}.
14175 @end deffn
14176
14177 @deftp {Data Type} rsync-configuration
14178 Data type representing the configuration for @code{rsync-service}.
14179
14180 @table @asis
14181 @item @code{package} (default: @var{rsync})
14182 @code{rsync} package to use.
14183
14184 @item @code{port-number} (default: @code{873})
14185 TCP port on which @command{rsync} listens for incoming connections. If port
14186 is less than @code{1024} @command{rsync} needs to be started as the
14187 @code{root} user and group.
14188
14189 @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
14190 Name of the file where @command{rsync} writes its PID.
14191
14192 @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
14193 Name of the file where @command{rsync} writes its lock file.
14194
14195 @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
14196 Name of the file where @command{rsync} writes its log file.
14197
14198 @item @code{use-chroot?} (default: @var{#t})
14199 Whether to use chroot for @command{rsync} shared directory.
14200
14201 @item @code{share-path} (default: @file{/srv/rsync})
14202 Location of the @command{rsync} shared directory.
14203
14204 @item @code{share-comment} (default: @code{"Rsync share"})
14205 Comment of the @command{rsync} shared directory.
14206
14207 @item @code{read-only?} (default: @var{#f})
14208 Read-write permissions to shared directory.
14209
14210 @item @code{timeout} (default: @code{300})
14211 I/O timeout in seconds.
14212
14213 @item @code{user} (default: @var{"root"})
14214 Owner of the @code{rsync} process.
14215
14216 @item @code{group} (default: @var{"root"})
14217 Group of the @code{rsync} process.
14218
14219 @item @code{uid} (default: @var{"rsyncd"})
14220 User name or user ID that file transfers to and from that module should take
14221 place as when the daemon was run as @code{root}.
14222
14223 @item @code{gid} (default: @var{"rsyncd"})
14224 Group name or group ID that will be used when accessing the module.
14225
14226 @end table
14227 @end deftp
14228
14229 Furthermore, @code{(gnu services ssh)} provides the following services.
14230 @cindex SSH
14231 @cindex SSH server
14232
14233 @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
14234 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
14235 [#:allow-empty-passwords? #f] [#:root-login? #f] @
14236 [#:syslog-output? #t] [#:x11-forwarding? #t] @
14237 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
14238 [#:public-key-authentication? #t] [#:initialize? #t]
14239 Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
14240 @var{host-key} must designate a file containing the host key, and readable
14241 only by root.
14242
14243 When @var{daemonic?} is true, @command{lshd} will detach from the
14244 controlling terminal and log its output to syslogd, unless one sets
14245 @var{syslog-output?} to false. Obviously, it also makes lsh-service
14246 depend on existence of syslogd service. When @var{pid-file?} is true,
14247 @command{lshd} writes its PID to the file called @var{pid-file}.
14248
14249 When @var{initialize?} is true, automatically create the seed and host key
14250 upon service activation if they do not exist yet. This may take long and
14251 require interaction.
14252
14253 When @var{initialize?} is false, it is up to the user to initialize the
14254 randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
14255 a key pair with the private key stored in file @var{host-key} (@pxref{lshd
14256 basics,,, lsh, LSH Manual}).
14257
14258 When @var{interfaces} is empty, lshd listens for connections on all the
14259 network interfaces; otherwise, @var{interfaces} must be a list of host names
14260 or addresses.
14261
14262 @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
14263 passwords, and @var{root-login?} specifies whether to accept log-ins as
14264 root.
14265
14266 The other options should be self-descriptive.
14267 @end deffn
14268
14269 @cindex SSH
14270 @cindex SSH server
14271 @deffn {Scheme Variable} openssh-service-type
14272 This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
14273 shell daemon, @command{sshd}. Its value must be an
14274 @code{openssh-configuration} record as in this example:
14275
14276 @lisp
14277 (service openssh-service-type
14278 (openssh-configuration
14279 (x11-forwarding? #t)
14280 (permit-root-login 'without-password)
14281 (authorized-keys
14282 `(("alice" ,(local-file "alice.pub"))
14283 ("bob" ,(local-file "bob.pub"))))))
14284 @end lisp
14285
14286 See below for details about @code{openssh-configuration}.
14287
14288 This service can be extended with extra authorized keys, as in this
14289 example:
14290
14291 @lisp
14292 (service-extension openssh-service-type
14293 (const `(("charlie"
14294 ,(local-file "charlie.pub")))))
14295 @end lisp
14296 @end deffn
14297
14298 @deftp {Data Type} openssh-configuration
14299 This is the configuration record for OpenSSH's @command{sshd}.
14300
14301 @table @asis
14302 @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
14303 Name of the file where @command{sshd} writes its PID.
14304
14305 @item @code{port-number} (default: @code{22})
14306 TCP port on which @command{sshd} listens for incoming connections.
14307
14308 @item @code{permit-root-login} (default: @code{#f})
14309 This field determines whether and when to allow logins as root. If
14310 @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
14311 If it's the symbol @code{'without-password}, then root logins are
14312 permitted but not with password-based authentication.
14313
14314 @item @code{allow-empty-passwords?} (default: @code{#f})
14315 When true, users with empty passwords may log in. When false, they may
14316 not.
14317
14318 @item @code{password-authentication?} (default: @code{#t})
14319 When true, users may log in with their password. When false, they have
14320 other authentication methods.
14321
14322 @item @code{public-key-authentication?} (default: @code{#t})
14323 When true, users may log in using public key authentication. When
14324 false, users have to use other authentication method.
14325
14326 Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
14327 This is used only by protocol version 2.
14328
14329 @item @code{x11-forwarding?} (default: @code{#f})
14330 When true, forwarding of X11 graphical client connections is
14331 enabled---in other words, @command{ssh} options @option{-X} and
14332 @option{-Y} will work.
14333
14334 @item @code{allow-agent-forwarding?} (default: @code{#t})
14335 Whether to allow agent forwarding.
14336
14337 @item @code{allow-tcp-forwarding?} (default: @code{#t})
14338 Whether to allow TCP forwarding.
14339
14340 @item @code{gateway-ports?} (default: @code{#f})
14341 Whether to allow gateway ports.
14342
14343 @item @code{challenge-response-authentication?} (default: @code{#f})
14344 Specifies whether challenge response authentication is allowed (e.g.@: via
14345 PAM).
14346
14347 @item @code{use-pam?} (default: @code{#t})
14348 Enables the Pluggable Authentication Module interface. If set to
14349 @code{#t}, this will enable PAM authentication using
14350 @code{challenge-response-authentication?} and
14351 @code{password-authentication?}, in addition to PAM account and session
14352 module processing for all authentication types.
14353
14354 Because PAM challenge response authentication usually serves an
14355 equivalent role to password authentication, you should disable either
14356 @code{challenge-response-authentication?} or
14357 @code{password-authentication?}.
14358
14359 @item @code{print-last-log?} (default: @code{#t})
14360 Specifies whether @command{sshd} should print the date and time of the
14361 last user login when a user logs in interactively.
14362
14363 @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
14364 Configures external subsystems (e.g.@: file transfer daemon).
14365
14366 This is a list of two-element lists, each of which containing the
14367 subsystem name and a command (with optional arguments) to execute upon
14368 subsystem request.
14369
14370 The command @command{internal-sftp} implements an in-process SFTP
14371 server. Alternately, one can specify the @command{sftp-server} command:
14372 @lisp
14373 (service openssh-service-type
14374 (openssh-configuration
14375 (subsystems
14376 `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
14377 @end lisp
14378
14379 @item @code{accepted-environment} (default: @code{'()})
14380 List of strings describing which environment variables may be exported.
14381
14382 Each string gets on its own line. See the @code{AcceptEnv} option in
14383 @code{man sshd_config}.
14384
14385 This example allows ssh-clients to export the @env{COLORTERM} variable.
14386 It is set by terminal emulators, which support colors. You can use it in
14387 your shell's resource file to enable colors for the prompt and commands
14388 if this variable is set.
14389
14390 @lisp
14391 (service openssh-service-type
14392 (openssh-configuration
14393 (accepted-environment '("COLORTERM"))))
14394 @end lisp
14395
14396 @item @code{authorized-keys} (default: @code{'()})
14397 @cindex authorized keys, SSH
14398 @cindex SSH authorized keys
14399 This is the list of authorized keys. Each element of the list is a user
14400 name followed by one or more file-like objects that represent SSH public
14401 keys. For example:
14402
14403 @lisp
14404 (openssh-configuration
14405 (authorized-keys
14406 `(("rekado" ,(local-file "rekado.pub"))
14407 ("chris" ,(local-file "chris.pub"))
14408 ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
14409 @end lisp
14410
14411 @noindent
14412 registers the specified public keys for user accounts @code{rekado},
14413 @code{chris}, and @code{root}.
14414
14415 Additional authorized keys can be specified @i{via}
14416 @code{service-extension}.
14417
14418 Note that this does @emph{not} interfere with the use of
14419 @file{~/.ssh/authorized_keys}.
14420
14421 @item @code{log-level} (default: @code{'info})
14422 This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
14423 @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
14424 page for @file{sshd_config} for the full list of level names.
14425
14426 @item @code{extra-content} (default: @code{""})
14427 This field can be used to append arbitrary text to the configuration file. It
14428 is especially useful for elaborate configurations that cannot be expressed
14429 otherwise. This configuration, for example, would generally disable root
14430 logins, but permit them from one specific IP address:
14431
14432 @lisp
14433 (openssh-configuration
14434 (extra-content "\
14435 Match Address 192.168.0.1
14436 PermitRootLogin yes"))
14437 @end lisp
14438
14439 @end table
14440 @end deftp
14441
14442 @deffn {Scheme Procedure} dropbear-service [@var{config}]
14443 Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
14444 daemon} with the given @var{config}, a @code{<dropbear-configuration>}
14445 object.
14446
14447 For example, to specify a Dropbear service listening on port 1234, add
14448 this call to the operating system's @code{services} field:
14449
14450 @lisp
14451 (dropbear-service (dropbear-configuration
14452 (port-number 1234)))
14453 @end lisp
14454 @end deffn
14455
14456 @deftp {Data Type} dropbear-configuration
14457 This data type represents the configuration of a Dropbear SSH daemon.
14458
14459 @table @asis
14460 @item @code{dropbear} (default: @var{dropbear})
14461 The Dropbear package to use.
14462
14463 @item @code{port-number} (default: 22)
14464 The TCP port where the daemon waits for incoming connections.
14465
14466 @item @code{syslog-output?} (default: @code{#t})
14467 Whether to enable syslog output.
14468
14469 @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
14470 File name of the daemon's PID file.
14471
14472 @item @code{root-login?} (default: @code{#f})
14473 Whether to allow @code{root} logins.
14474
14475 @item @code{allow-empty-passwords?} (default: @code{#f})
14476 Whether to allow empty passwords.
14477
14478 @item @code{password-authentication?} (default: @code{#t})
14479 Whether to enable password-based authentication.
14480 @end table
14481 @end deftp
14482
14483 @cindex AutoSSH
14484 @deffn {Scheme Variable} autossh-service-type
14485 This is the type for the @uref{https://www.harding.motd.ca/autossh,
14486 AutoSSH} program that runs a copy of @command{ssh} and monitors it,
14487 restarting it as necessary should it die or stop passing traffic.
14488 AutoSSH can be run manually from the command-line by passing arguments
14489 to the binary @command{autossh} from the package @code{autossh}, but it
14490 can also be run as a Guix service. This latter use case is documented
14491 here.
14492
14493 AutoSSH can be used to forward local traffic to a remote machine using
14494 an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
14495 is run as.
14496
14497 For example, to specify a service running autossh as the user
14498 @code{pino} and forwarding all local connections to port @code{8081} to
14499 @code{remote:8081} using an SSH tunnel, add this call to the operating
14500 system's @code{services} field:
14501
14502 @lisp
14503 (service autossh-service-type
14504 (autossh-configuration
14505 (user "pino")
14506 (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
14507 @end lisp
14508 @end deffn
14509
14510 @deftp {Data Type} autossh-configuration
14511 This data type represents the configuration of an AutoSSH service.
14512
14513 @table @asis
14514
14515 @item @code{user} (default @code{"autossh"})
14516 The user as which the AutoSSH service is to be run.
14517 This assumes that the specified user exists.
14518
14519 @item @code{poll} (default @code{600})
14520 Specifies the connection poll time in seconds.
14521
14522 @item @code{first-poll} (default @code{#f})
14523 Specifies how many seconds AutoSSH waits before the first connection
14524 test. After this first test, polling is resumed at the pace defined in
14525 @code{poll}. When set to @code{#f}, the first poll is not treated
14526 specially and will also use the connection poll specified in
14527 @code{poll}.
14528
14529 @item @code{gate-time} (default @code{30})
14530 Specifies how many seconds an SSH connection must be active before it is
14531 considered successful.
14532
14533 @item @code{log-level} (default @code{1})
14534 The log level, corresponding to the levels used by syslog---so @code{0}
14535 is the most silent while @code{7} is the chattiest.
14536
14537 @item @code{max-start} (default @code{#f})
14538 The maximum number of times SSH may be (re)started before AutoSSH exits.
14539 When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
14540
14541 @item @code{message} (default @code{""})
14542 The message to append to the echo message sent when testing connections.
14543
14544 @item @code{port} (default @code{"0"})
14545 The ports used for monitoring the connection. When set to @code{"0"},
14546 monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
14547 a positive integer, ports @var{n} and @var{n}+1 are used for
14548 monitoring the connection, such that port @var{n} is the base
14549 monitoring port and @code{n+1} is the echo port. When set to
14550 @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
14551 integers, the ports @var{n} and @var{n}+1 are used for monitoring the
14552 connection, such that port @var{n} is the base monitoring port and
14553 @var{m} is the echo port.
14554
14555 @item @code{ssh-options} (default @code{'()})
14556 The list of command-line arguments to pass to @command{ssh} when it is
14557 run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
14558 may cause undefined behaviour.
14559
14560 @end table
14561 @end deftp
14562
14563 @defvr {Scheme Variable} %facebook-host-aliases
14564 This variable contains a string for use in @file{/etc/hosts}
14565 (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
14566 line contains a entry that maps a known server name of the Facebook
14567 on-line service---e.g., @code{www.facebook.com}---to the local
14568 host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
14569
14570 This variable is typically used in the @code{hosts-file} field of an
14571 @code{operating-system} declaration (@pxref{operating-system Reference,
14572 @file{/etc/hosts}}):
14573
14574 @lisp
14575 (use-modules (gnu) (guix))
14576
14577 (operating-system
14578 (host-name "mymachine")
14579 ;; ...
14580 (hosts-file
14581 ;; Create a /etc/hosts file with aliases for "localhost"
14582 ;; and "mymachine", as well as for Facebook servers.
14583 (plain-file "hosts"
14584 (string-append (local-host-aliases host-name)
14585 %facebook-host-aliases))))
14586 @end lisp
14587
14588 This mechanism can prevent programs running locally, such as Web
14589 browsers, from accessing Facebook.
14590 @end defvr
14591
14592 The @code{(gnu services avahi)} provides the following definition.
14593
14594 @defvr {Scheme Variable} avahi-service-type
14595 This is the service that runs @command{avahi-daemon}, a system-wide
14596 mDNS/DNS-SD responder that allows for service discovery and
14597 ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
14598 Its value must be a @code{zero-configuration} record---see below.
14599
14600 This service extends the name service cache daemon (nscd) so that it can
14601 resolve @code{.local} host names using
14602 @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
14603 Service Switch}, for information on host name resolution.
14604
14605 Additionally, add the @var{avahi} package to the system profile so that
14606 commands such as @command{avahi-browse} are directly usable.
14607 @end defvr
14608
14609 @deftp {Data Type} avahi-configuration
14610 Data type representation the configuration for Avahi.
14611
14612 @table @asis
14613
14614 @item @code{host-name} (default: @code{#f})
14615 If different from @code{#f}, use that as the host name to
14616 publish for this machine; otherwise, use the machine's actual host name.
14617
14618 @item @code{publish?} (default: @code{#t})
14619 When true, allow host names and services to be published (broadcast) over the
14620 network.
14621
14622 @item @code{publish-workstation?} (default: @code{#t})
14623 When true, @command{avahi-daemon} publishes the machine's host name and IP
14624 address via mDNS on the local network. To view the host names published on
14625 your local network, you can run:
14626
14627 @example
14628 avahi-browse _workstation._tcp
14629 @end example
14630
14631 @item @code{wide-area?} (default: @code{#f})
14632 When true, DNS-SD over unicast DNS is enabled.
14633
14634 @item @code{ipv4?} (default: @code{#t})
14635 @itemx @code{ipv6?} (default: @code{#t})
14636 These fields determine whether to use IPv4/IPv6 sockets.
14637
14638 @item @code{domains-to-browse} (default: @code{'()})
14639 This is a list of domains to browse.
14640 @end table
14641 @end deftp
14642
14643 @deffn {Scheme Variable} openvswitch-service-type
14644 This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
14645 service, whose value should be an @code{openvswitch-configuration}
14646 object.
14647 @end deffn
14648
14649 @deftp {Data Type} openvswitch-configuration
14650 Data type representing the configuration of Open vSwitch, a multilayer
14651 virtual switch which is designed to enable massive network automation
14652 through programmatic extension.
14653
14654 @table @asis
14655 @item @code{package} (default: @var{openvswitch})
14656 Package object of the Open vSwitch.
14657
14658 @end table
14659 @end deftp
14660
14661 @defvr {Scheme Variable} pagekite-service-type
14662 This is the service type for the @uref{https://pagekite.net, PageKite} service,
14663 a tunneling solution for making localhost servers publicly visible, even from
14664 behind restrictive firewalls or NAT without forwarded ports. The value for
14665 this service type is a @code{pagekite-configuration} record.
14666
14667 Here's an example exposing the local HTTP and SSH daemons:
14668
14669 @lisp
14670 (service pagekite-service-type
14671 (pagekite-configuration
14672 (kites '("http:@@kitename:localhost:80:@@kitesecret"
14673 "raw/22:@@kitename:localhost:22:@@kitesecret"))
14674 (extra-file "/etc/pagekite.rc")))
14675 @end lisp
14676 @end defvr
14677
14678 @deftp {Data Type} pagekite-configuration
14679 Data type representing the configuration of PageKite.
14680
14681 @table @asis
14682 @item @code{package} (default: @var{pagekite})
14683 Package object of PageKite.
14684
14685 @item @code{kitename} (default: @code{#f})
14686 PageKite name for authenticating to the frontend server.
14687
14688 @item @code{kitesecret} (default: @code{#f})
14689 Shared secret for authenticating to the frontend server. You should probably
14690 put this inside @code{extra-file} instead.
14691
14692 @item @code{frontend} (default: @code{#f})
14693 Connect to the named PageKite frontend server instead of the
14694 @uref{https://pagekite.net,,pagekite.net} service.
14695
14696 @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
14697 List of service kites to use. Exposes HTTP on port 80 by default. The format
14698 is @code{proto:kitename:host:port:secret}.
14699
14700 @item @code{extra-file} (default: @code{#f})
14701 Extra configuration file to read, which you are expected to create manually.
14702 Use this to add additional options and manage shared secrets out-of-band.
14703
14704 @end table
14705 @end deftp
14706
14707 @node X Window
14708 @subsection X Window
14709
14710 @cindex X11
14711 @cindex X Window System
14712 @cindex login manager
14713 Support for the X Window graphical display system---specifically
14714 Xorg---is provided by the @code{(gnu services xorg)} module. Note that
14715 there is no @code{xorg-service} procedure. Instead, the X server is
14716 started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
14717
14718 @cindex GDM
14719 @cindex GNOME, login manager
14720 GDM of course allows users to log in into window managers and desktop
14721 environments other than GNOME; for those using GNOME, GDM is required for
14722 features such as automatic screen locking.
14723
14724 @cindex window manager
14725 To use X11, you must install at least one @dfn{window manager}---for
14726 example the @code{windowmaker} or @code{openbox} packages---preferably
14727 by adding it to the @code{packages} field of your operating system
14728 definition (@pxref{operating-system Reference, system-wide packages}).
14729
14730 @defvr {Scheme Variable} gdm-service-type
14731 This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
14732 Desktop Manager} (GDM), a program that manages graphical display servers and
14733 handles graphical user logins. Its value must be a @code{gdm-configuration}
14734 (see below.)
14735
14736 @cindex session types (X11)
14737 @cindex X11 session types
14738 GDM looks for @dfn{session types} described by the @file{.desktop} files in
14739 @file{/run/current-system/profile/share/xsessions} and allows users to choose
14740 a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
14741 and @code{i3} provide @file{.desktop} files; adding them to the system-wide
14742 set of packages automatically makes them available at the log-in screen.
14743
14744 In addition, @file{~/.xsession} files are honored. When available,
14745 @file{~/.xsession} must be an executable that starts a window manager
14746 and/or other X clients.
14747 @end defvr
14748
14749 @deftp {Data Type} gdm-configuration
14750 @table @asis
14751 @item @code{auto-login?} (default: @code{#f})
14752 @itemx @code{default-user} (default: @code{#f})
14753 When @code{auto-login?} is false, GDM presents a log-in screen.
14754
14755 When @code{auto-login?} is true, GDM logs in directly as
14756 @code{default-user}.
14757
14758 @item @code{debug?} (default: @code{#f})
14759 When true, GDM writes debug messages to its log.
14760
14761 @item @code{gnome-shell-assets} (default: ...)
14762 List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
14763
14764 @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
14765 Configuration of the Xorg graphical server.
14766
14767 @item @code{xsession} (default: @code{(xinitrc)})
14768 Script to run before starting a X session.
14769
14770 @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
14771 File name of the @code{dbus-daemon} executable.
14772
14773 @item @code{gdm} (default: @code{gdm})
14774 The GDM package to use.
14775 @end table
14776 @end deftp
14777
14778 @defvr {Scheme Variable} slim-service-type
14779 This is the type for the SLiM graphical login manager for X11.
14780
14781 Like GDM, SLiM looks for session types described by @file{.desktop} files and
14782 allows users to choose a session from the log-in screen using @kbd{F1}. It
14783 also honors @file{~/.xsession} files.
14784
14785 Unlike GDM, SLiM does not spawn the user session on a different VT after
14786 logging in, which means that you can only start one graphical session. If you
14787 want to be able to run multiple graphical sessions at the same time you have
14788 to add multiple SLiM services to your system services. The following example
14789 shows how to replace the default GDM service with two SLiM services on tty7
14790 and tty8.
14791
14792 @lisp
14793 (use-modules (gnu services)
14794 (gnu services desktop)
14795 (gnu services xorg)
14796 (srfi srfi-1)) ;for 'remove'
14797
14798 (operating-system
14799 ;; ...
14800 (services (cons* (service slim-service-type (slim-configuration
14801 (display ":0")
14802 (vt "vt7")))
14803 (service slim-service-type (slim-configuration
14804 (display ":1")
14805 (vt "vt8")))
14806 (remove (lambda (service)
14807 (eq? (service-kind service) gdm-service-type))
14808 %desktop-services))))
14809 @end lisp
14810
14811 @end defvr
14812
14813 @deftp {Data Type} slim-configuration
14814 Data type representing the configuration of @code{slim-service-type}.
14815
14816 @table @asis
14817 @item @code{allow-empty-passwords?} (default: @code{#t})
14818 Whether to allow logins with empty passwords.
14819
14820 @item @code{auto-login?} (default: @code{#f})
14821 @itemx @code{default-user} (default: @code{""})
14822 When @code{auto-login?} is false, SLiM presents a log-in screen.
14823
14824 When @code{auto-login?} is true, SLiM logs in directly as
14825 @code{default-user}.
14826
14827 @item @code{theme} (default: @code{%default-slim-theme})
14828 @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
14829 The graphical theme to use and its name.
14830
14831 @item @code{auto-login-session} (default: @code{#f})
14832 If true, this must be the name of the executable to start as the default
14833 session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
14834
14835 If false, a session described by one of the available @file{.desktop}
14836 files in @code{/run/current-system/profile} and @code{~/.guix-profile}
14837 will be used.
14838
14839 @quotation Note
14840 You must install at least one window manager in the system profile or in
14841 your user profile. Failing to do that, if @code{auto-login-session} is
14842 false, you will be unable to log in.
14843 @end quotation
14844
14845 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
14846 Configuration of the Xorg graphical server.
14847
14848 @item @code{display} (default @code{":0"})
14849 The display on which to start the Xorg graphical server.
14850
14851 @item @code{vt} (default @code{"vt7"})
14852 The VT on which to start the Xorg graphical server.
14853
14854 @item @code{xauth} (default: @code{xauth})
14855 The XAuth package to use.
14856
14857 @item @code{shepherd} (default: @code{shepherd})
14858 The Shepherd package used when invoking @command{halt} and
14859 @command{reboot}.
14860
14861 @item @code{sessreg} (default: @code{sessreg})
14862 The sessreg package used in order to register the session.
14863
14864 @item @code{slim} (default: @code{slim})
14865 The SLiM package to use.
14866 @end table
14867 @end deftp
14868
14869 @defvr {Scheme Variable} %default-theme
14870 @defvrx {Scheme Variable} %default-theme-name
14871 The default SLiM theme and its name.
14872 @end defvr
14873
14874
14875 @deftp {Data Type} sddm-configuration
14876 This is the data type representing the SDDM service configuration.
14877
14878 @table @asis
14879 @item @code{display-server} (default: "x11")
14880 Select display server to use for the greeter. Valid values are
14881 @samp{"x11"} or @samp{"wayland"}.
14882
14883 @item @code{numlock} (default: "on")
14884 Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
14885
14886 @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
14887 Command to run when halting.
14888
14889 @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
14890 Command to run when rebooting.
14891
14892 @item @code{theme} (default "maldives")
14893 Theme to use. Default themes provided by SDDM are @samp{"elarun"},
14894 @samp{"maldives"} or @samp{"maya"}.
14895
14896 @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
14897 Directory to look for themes.
14898
14899 @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
14900 Directory to look for faces.
14901
14902 @item @code{default-path} (default "/run/current-system/profile/bin")
14903 Default PATH to use.
14904
14905 @item @code{minimum-uid} (default: 1000)
14906 Minimum UID displayed in SDDM and allowed for log-in.
14907
14908 @item @code{maximum-uid} (default: 2000)
14909 Maximum UID to display in SDDM.
14910
14911 @item @code{remember-last-user?} (default #t)
14912 Remember last user.
14913
14914 @item @code{remember-last-session?} (default #t)
14915 Remember last session.
14916
14917 @item @code{hide-users} (default "")
14918 Usernames to hide from SDDM greeter.
14919
14920 @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
14921 Users with shells listed will be hidden from the SDDM greeter.
14922
14923 @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
14924 Script to run before starting a wayland session.
14925
14926 @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
14927 Directory to look for desktop files starting wayland sessions.
14928
14929 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
14930 Configuration of the Xorg graphical server.
14931
14932 @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
14933 Path to xauth.
14934
14935 @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
14936 Path to Xephyr.
14937
14938 @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
14939 Script to run after starting xorg-server.
14940
14941 @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
14942 Script to run before stopping xorg-server.
14943
14944 @item @code{xsession-command} (default: @code{xinitrc})
14945 Script to run before starting a X session.
14946
14947 @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
14948 Directory to look for desktop files starting X sessions.
14949
14950 @item @code{minimum-vt} (default: 7)
14951 Minimum VT to use.
14952
14953 @item @code{auto-login-user} (default "")
14954 User to use for auto-login.
14955
14956 @item @code{auto-login-session} (default "")
14957 Desktop file to use for auto-login.
14958
14959 @item @code{relogin?} (default #f)
14960 Relogin after logout.
14961
14962 @end table
14963 @end deftp
14964
14965 @cindex login manager
14966 @cindex X11 login
14967 @defvr {Scheme Variable} sddm-service-type
14968 This is the type of the service to run the
14969 @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
14970 must be a @code{sddm-configuration} record (see below).
14971
14972 Here's an example use:
14973
14974 @lisp
14975 (service sddm-service-type
14976 (sddm-configuration
14977 (auto-login-user "alice")
14978 (auto-login-session "xfce.desktop")))
14979 @end lisp
14980 @end defvr
14981
14982 @deftp {Data Type} sddm-configuration
14983 This data type represents the configuration of the SDDM login manager.
14984 The available fields are:
14985
14986 @table @asis
14987 @item @code{sddm} (default: @code{sddm})
14988 The SDDM package to use.
14989
14990 @item @code{display-server} (default: @code{"x11"})
14991 This must be either @code{"x11"} or @code{"wayland"}.
14992
14993 @c FIXME: Add more fields.
14994
14995 @item @code{auto-login-user} (default: @code{""})
14996 If non-empty, this is the user account under which to log in
14997 automatically.
14998
14999 @item @code{auto-login-session} (default: @code{""})
15000 If non-empty, this is the @file{.desktop} file name to use as the
15001 auto-login session.
15002 @end table
15003 @end deftp
15004
15005 @cindex Xorg, configuration
15006 @deftp {Data Type} xorg-configuration
15007 This data type represents the configuration of the Xorg graphical display
15008 server. Note that there is not Xorg service; instead, the X server is started
15009 by a ``display manager'' such as GDM, SDDM, and SLiM. Thus, the configuration
15010 of these display managers aggregates an @code{xorg-configuration} record.
15011
15012 @table @asis
15013 @item @code{modules} (default: @code{%default-xorg-modules})
15014 This is a list of @dfn{module packages} loaded by the Xorg
15015 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
15016
15017 @item @code{fonts} (default: @code{%default-xorg-fonts})
15018 This is a list of font directories to add to the server's @dfn{font path}.
15019
15020 @item @code{drivers} (default: @code{'()})
15021 This must be either the empty list, in which case Xorg chooses a graphics
15022 driver automatically, or a list of driver names that will be tried in this
15023 order---e.g., @code{("modesetting" "vesa")}.
15024
15025 @item @code{resolutions} (default: @code{'()})
15026 When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
15027 resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
15028 768) (640 480))}.
15029
15030 @cindex keyboard layout, for Xorg
15031 @cindex keymap, for Xorg
15032 @item @code{keyboard-layout} (default: @code{#f})
15033 If this is @code{#f}, Xorg uses the default keyboard layout---usually US
15034 English (``qwerty'') for a 105-key PC keyboard.
15035
15036 Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
15037 layout in use when Xorg is running. @xref{Keyboard Layout}, for more
15038 information on how to specify the keyboard layout.
15039
15040 @item @code{extra-config} (default: @code{'()})
15041 This is a list of strings or objects appended to the configuration file. It
15042 is used to pass extra text to be added verbatim to the configuration file.
15043
15044 @item @code{server} (default: @code{xorg-server})
15045 This is the package providing the Xorg server.
15046
15047 @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
15048 This is the list of command-line arguments to pass to the X server. The
15049 default is @code{-nolisten tcp}.
15050 @end table
15051 @end deftp
15052
15053 @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
15054 [@var{login-manager-service-type}]
15055 Tell the log-in manager (of type @var{login-manager-service-type}) to use
15056 @var{config}, an @code{<xorg-configuration>} record.
15057
15058 Since the Xorg configuration is embedded in the log-in manager's
15059 configuration---e.g., @code{gdm-configuration}---this procedure provides a
15060 shorthand to set the Xorg configuration.
15061 @end deffn
15062
15063 @deffn {Scheme Procedure} xorg-start-command [@var{config}]
15064 Return a @code{startx} script in which the modules, fonts, etc. specified
15065 in @var{config}, are available. The result should be used in place of
15066 @code{startx}.
15067
15068 Usually the X server is started by a login manager.
15069 @end deffn
15070
15071
15072 @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
15073 Add @var{package}, a package for a screen locker or screen saver whose
15074 command is @var{program}, to the set of setuid programs and add a PAM entry
15075 for it. For example:
15076
15077 @lisp
15078 (screen-locker-service xlockmore "xlock")
15079 @end lisp
15080
15081 makes the good ol' XlockMore usable.
15082 @end deffn
15083
15084
15085 @node Printing Services
15086 @subsection Printing Services
15087
15088 @cindex printer support with CUPS
15089 The @code{(gnu services cups)} module provides a Guix service definition
15090 for the CUPS printing service. To add printer support to a Guix
15091 system, add a @code{cups-service} to the operating system definition:
15092
15093 @deffn {Scheme Variable} cups-service-type
15094 The service type for the CUPS print server. Its value should be a valid
15095 CUPS configuration (see below). To use the default settings, simply
15096 write:
15097 @lisp
15098 (service cups-service-type)
15099 @end lisp
15100 @end deffn
15101
15102 The CUPS configuration controls the basic things about your CUPS
15103 installation: what interfaces it listens on, what to do if a print job
15104 fails, how much logging to do, and so on. To actually add a printer,
15105 you have to visit the @url{http://localhost:631} URL, or use a tool such
15106 as GNOME's printer configuration services. By default, configuring a
15107 CUPS service will generate a self-signed certificate if needed, for
15108 secure connections to the print server.
15109
15110 Suppose you want to enable the Web interface of CUPS and also add
15111 support for Epson printers @i{via} the @code{escpr} package and for HP
15112 printers @i{via} the @code{hplip-minimal} package. You can do that directly,
15113 like this (you need to use the @code{(gnu packages cups)} module):
15114
15115 @lisp
15116 (service cups-service-type
15117 (cups-configuration
15118 (web-interface? #t)
15119 (extensions
15120 (list cups-filters escpr hplip-minimal))))
15121 @end lisp
15122
15123 Note: If you wish to use the Qt5 based GUI which comes with the hplip
15124 package then it is suggested that you install the @code{hplip} package,
15125 either in your OS configuration file or as your user.
15126
15127 The available configuration parameters follow. Each parameter
15128 definition is preceded by its type; for example, @samp{string-list foo}
15129 indicates that the @code{foo} parameter should be specified as a list of
15130 strings. There is also a way to specify the configuration as a string,
15131 if you have an old @code{cupsd.conf} file that you want to port over
15132 from some other system; see the end for more details.
15133
15134 @c The following documentation was initially generated by
15135 @c (generate-documentation) in (gnu services cups). Manually maintained
15136 @c documentation is better, so we shouldn't hesitate to edit below as
15137 @c needed. However if the change you want to make to this documentation
15138 @c can be done in an automated way, it's probably easier to change
15139 @c (generate-documentation) than to make it below and have to deal with
15140 @c the churn as CUPS updates.
15141
15142
15143 Available @code{cups-configuration} fields are:
15144
15145 @deftypevr {@code{cups-configuration} parameter} package cups
15146 The CUPS package.
15147 @end deftypevr
15148
15149 @deftypevr {@code{cups-configuration} parameter} package-list extensions
15150 Drivers and other extensions to the CUPS package.
15151 @end deftypevr
15152
15153 @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
15154 Configuration of where to write logs, what directories to use for print
15155 spools, and related privileged configuration parameters.
15156
15157 Available @code{files-configuration} fields are:
15158
15159 @deftypevr {@code{files-configuration} parameter} log-location access-log
15160 Defines the access log filename. Specifying a blank filename disables
15161 access log generation. The value @code{stderr} causes log entries to be
15162 sent to the standard error file when the scheduler is running in the
15163 foreground, or to the system log daemon when run in the background. The
15164 value @code{syslog} causes log entries to be sent to the system log
15165 daemon. The server name may be included in filenames using the string
15166 @code{%s}, as in @code{/var/log/cups/%s-access_log}.
15167
15168 Defaults to @samp{"/var/log/cups/access_log"}.
15169 @end deftypevr
15170
15171 @deftypevr {@code{files-configuration} parameter} file-name cache-dir
15172 Where CUPS should cache data.
15173
15174 Defaults to @samp{"/var/cache/cups"}.
15175 @end deftypevr
15176
15177 @deftypevr {@code{files-configuration} parameter} string config-file-perm
15178 Specifies the permissions for all configuration files that the scheduler
15179 writes.
15180
15181 Note that the permissions for the printers.conf file are currently
15182 masked to only allow access from the scheduler user (typically root).
15183 This is done because printer device URIs sometimes contain sensitive
15184 authentication information that should not be generally known on the
15185 system. There is no way to disable this security feature.
15186
15187 Defaults to @samp{"0640"}.
15188 @end deftypevr
15189
15190 @deftypevr {@code{files-configuration} parameter} log-location error-log
15191 Defines the error log filename. Specifying a blank filename disables
15192 error log generation. The value @code{stderr} causes log entries to be
15193 sent to the standard error file when the scheduler is running in the
15194 foreground, or to the system log daemon when run in the background. The
15195 value @code{syslog} causes log entries to be sent to the system log
15196 daemon. The server name may be included in filenames using the string
15197 @code{%s}, as in @code{/var/log/cups/%s-error_log}.
15198
15199 Defaults to @samp{"/var/log/cups/error_log"}.
15200 @end deftypevr
15201
15202 @deftypevr {@code{files-configuration} parameter} string fatal-errors
15203 Specifies which errors are fatal, causing the scheduler to exit. The
15204 kind strings are:
15205
15206 @table @code
15207 @item none
15208 No errors are fatal.
15209
15210 @item all
15211 All of the errors below are fatal.
15212
15213 @item browse
15214 Browsing initialization errors are fatal, for example failed connections
15215 to the DNS-SD daemon.
15216
15217 @item config
15218 Configuration file syntax errors are fatal.
15219
15220 @item listen
15221 Listen or Port errors are fatal, except for IPv6 failures on the
15222 loopback or @code{any} addresses.
15223
15224 @item log
15225 Log file creation or write errors are fatal.
15226
15227 @item permissions
15228 Bad startup file permissions are fatal, for example shared TLS
15229 certificate and key files with world-read permissions.
15230 @end table
15231
15232 Defaults to @samp{"all -browse"}.
15233 @end deftypevr
15234
15235 @deftypevr {@code{files-configuration} parameter} boolean file-device?
15236 Specifies whether the file pseudo-device can be used for new printer
15237 queues. The URI @uref{file:///dev/null} is always allowed.
15238
15239 Defaults to @samp{#f}.
15240 @end deftypevr
15241
15242 @deftypevr {@code{files-configuration} parameter} string group
15243 Specifies the group name or ID that will be used when executing external
15244 programs.
15245
15246 Defaults to @samp{"lp"}.
15247 @end deftypevr
15248
15249 @deftypevr {@code{files-configuration} parameter} string log-file-perm
15250 Specifies the permissions for all log files that the scheduler writes.
15251
15252 Defaults to @samp{"0644"}.
15253 @end deftypevr
15254
15255 @deftypevr {@code{files-configuration} parameter} log-location page-log
15256 Defines the page log filename. Specifying a blank filename disables
15257 page log generation. The value @code{stderr} causes log entries to be
15258 sent to the standard error file when the scheduler is running in the
15259 foreground, or to the system log daemon when run in the background. The
15260 value @code{syslog} causes log entries to be sent to the system log
15261 daemon. The server name may be included in filenames using the string
15262 @code{%s}, as in @code{/var/log/cups/%s-page_log}.
15263
15264 Defaults to @samp{"/var/log/cups/page_log"}.
15265 @end deftypevr
15266
15267 @deftypevr {@code{files-configuration} parameter} string remote-root
15268 Specifies the username that is associated with unauthenticated accesses
15269 by clients claiming to be the root user. The default is @code{remroot}.
15270
15271 Defaults to @samp{"remroot"}.
15272 @end deftypevr
15273
15274 @deftypevr {@code{files-configuration} parameter} file-name request-root
15275 Specifies the directory that contains print jobs and other HTTP request
15276 data.
15277
15278 Defaults to @samp{"/var/spool/cups"}.
15279 @end deftypevr
15280
15281 @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
15282 Specifies the level of security sandboxing that is applied to print
15283 filters, backends, and other child processes of the scheduler; either
15284 @code{relaxed} or @code{strict}. This directive is currently only
15285 used/supported on macOS.
15286
15287 Defaults to @samp{strict}.
15288 @end deftypevr
15289
15290 @deftypevr {@code{files-configuration} parameter} file-name server-keychain
15291 Specifies the location of TLS certificates and private keys. CUPS will
15292 look for public and private keys in this directory: @file{.crt} files
15293 for PEM-encoded certificates and corresponding @file{.key} files for
15294 PEM-encoded private keys.
15295
15296 Defaults to @samp{"/etc/cups/ssl"}.
15297 @end deftypevr
15298
15299 @deftypevr {@code{files-configuration} parameter} file-name server-root
15300 Specifies the directory containing the server configuration files.
15301
15302 Defaults to @samp{"/etc/cups"}.
15303 @end deftypevr
15304
15305 @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
15306 Specifies whether the scheduler calls fsync(2) after writing
15307 configuration or state files.
15308
15309 Defaults to @samp{#f}.
15310 @end deftypevr
15311
15312 @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
15313 Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
15314 @end deftypevr
15315
15316 @deftypevr {@code{files-configuration} parameter} file-name temp-dir
15317 Specifies the directory where temporary files are stored.
15318
15319 Defaults to @samp{"/var/spool/cups/tmp"}.
15320 @end deftypevr
15321
15322 @deftypevr {@code{files-configuration} parameter} string user
15323 Specifies the user name or ID that is used when running external
15324 programs.
15325
15326 Defaults to @samp{"lp"}.
15327 @end deftypevr
15328
15329 @deftypevr {@code{files-configuration} parameter} string set-env
15330 Set the specified environment variable to be passed to child processes.
15331
15332 Defaults to @samp{"variable value"}.
15333 @end deftypevr
15334 @end deftypevr
15335
15336 @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
15337 Specifies the logging level for the AccessLog file. The @code{config}
15338 level logs when printers and classes are added, deleted, or modified and
15339 when configuration files are accessed or updated. The @code{actions}
15340 level logs when print jobs are submitted, held, released, modified, or
15341 canceled, and any of the conditions for @code{config}. The @code{all}
15342 level logs all requests.
15343
15344 Defaults to @samp{actions}.
15345 @end deftypevr
15346
15347 @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
15348 Specifies whether to purge job history data automatically when it is no
15349 longer required for quotas.
15350
15351 Defaults to @samp{#f}.
15352 @end deftypevr
15353
15354 @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
15355 Specifies a list of DNS-SD sub-types to advertise for each shared printer.
15356 For example, @samp{"_cups" "_print"} will tell network clients that both
15357 CUPS sharing and IPP Everywhere are supported.
15358
15359 Defaults to @samp{"_cups"}.
15360 @end deftypevr
15361
15362 @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
15363 Specifies which protocols to use for local printer sharing.
15364
15365 Defaults to @samp{dnssd}.
15366 @end deftypevr
15367
15368 @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
15369 Specifies whether the CUPS web interface is advertised.
15370
15371 Defaults to @samp{#f}.
15372 @end deftypevr
15373
15374 @deftypevr {@code{cups-configuration} parameter} boolean browsing?
15375 Specifies whether shared printers are advertised.
15376
15377 Defaults to @samp{#f}.
15378 @end deftypevr
15379
15380 @deftypevr {@code{cups-configuration} parameter} string classification
15381 Specifies the security classification of the server. Any valid banner
15382 name can be used, including @samp{"classified"}, @samp{"confidential"},
15383 @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
15384 banner can be omitted to disable secure printing functions.
15385
15386 Defaults to @samp{""}.
15387 @end deftypevr
15388
15389 @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
15390 Specifies whether users may override the classification (cover page) of
15391 individual print jobs using the @code{job-sheets} option.
15392
15393 Defaults to @samp{#f}.
15394 @end deftypevr
15395
15396 @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
15397 Specifies the default type of authentication to use.
15398
15399 Defaults to @samp{Basic}.
15400 @end deftypevr
15401
15402 @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
15403 Specifies whether encryption will be used for authenticated requests.
15404
15405 Defaults to @samp{Required}.
15406 @end deftypevr
15407
15408 @deftypevr {@code{cups-configuration} parameter} string default-language
15409 Specifies the default language to use for text and web content.
15410
15411 Defaults to @samp{"en"}.
15412 @end deftypevr
15413
15414 @deftypevr {@code{cups-configuration} parameter} string default-paper-size
15415 Specifies the default paper size for new print queues. @samp{"Auto"}
15416 uses a locale-specific default, while @samp{"None"} specifies there is
15417 no default paper size. Specific size names are typically
15418 @samp{"Letter"} or @samp{"A4"}.
15419
15420 Defaults to @samp{"Auto"}.
15421 @end deftypevr
15422
15423 @deftypevr {@code{cups-configuration} parameter} string default-policy
15424 Specifies the default access policy to use.
15425
15426 Defaults to @samp{"default"}.
15427 @end deftypevr
15428
15429 @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
15430 Specifies whether local printers are shared by default.
15431
15432 Defaults to @samp{#t}.
15433 @end deftypevr
15434
15435 @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
15436 Specifies the delay for updating of configuration and state files, in
15437 seconds. A value of 0 causes the update to happen as soon as possible,
15438 typically within a few milliseconds.
15439
15440 Defaults to @samp{30}.
15441 @end deftypevr
15442
15443 @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
15444 Specifies what to do when an error occurs. Possible values are
15445 @code{abort-job}, which will discard the failed print job;
15446 @code{retry-job}, which will retry the job at a later time;
15447 @code{retry-current-job}, which retries the failed job immediately; and
15448 @code{stop-printer}, which stops the printer.
15449
15450 Defaults to @samp{stop-printer}.
15451 @end deftypevr
15452
15453 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
15454 Specifies the maximum cost of filters that are run concurrently, which
15455 can be used to minimize disk, memory, and CPU resource problems. A
15456 limit of 0 disables filter limiting. An average print to a
15457 non-PostScript printer needs a filter limit of about 200. A PostScript
15458 printer needs about half that (100). Setting the limit below these
15459 thresholds will effectively limit the scheduler to printing a single job
15460 at any time.
15461
15462 Defaults to @samp{0}.
15463 @end deftypevr
15464
15465 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
15466 Specifies the scheduling priority of filters that are run to print a
15467 job. The nice value ranges from 0, the highest priority, to 19, the
15468 lowest priority.
15469
15470 Defaults to @samp{0}.
15471 @end deftypevr
15472
15473 @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
15474 Specifies whether to do reverse lookups on connecting clients. The
15475 @code{double} setting causes @code{cupsd} to verify that the hostname
15476 resolved from the address matches one of the addresses returned for that
15477 hostname. Double lookups also prevent clients with unregistered
15478 addresses from connecting to your server. Only set this option to
15479 @code{#t} or @code{double} if absolutely required.
15480
15481 Defaults to @samp{#f}.
15482 @end deftypevr
15483
15484 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
15485 Specifies the number of seconds to wait before killing the filters and
15486 backend associated with a canceled or held job.
15487
15488 Defaults to @samp{30}.
15489 @end deftypevr
15490
15491 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
15492 Specifies the interval between retries of jobs in seconds. This is
15493 typically used for fax queues but can also be used with normal print
15494 queues whose error policy is @code{retry-job} or
15495 @code{retry-current-job}.
15496
15497 Defaults to @samp{30}.
15498 @end deftypevr
15499
15500 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
15501 Specifies the number of retries that are done for jobs. This is
15502 typically used for fax queues but can also be used with normal print
15503 queues whose error policy is @code{retry-job} or
15504 @code{retry-current-job}.
15505
15506 Defaults to @samp{5}.
15507 @end deftypevr
15508
15509 @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
15510 Specifies whether to support HTTP keep-alive connections.
15511
15512 Defaults to @samp{#t}.
15513 @end deftypevr
15514
15515 @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
15516 Specifies how long an idle client connection remains open, in seconds.
15517
15518 Defaults to @samp{30}.
15519 @end deftypevr
15520
15521 @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
15522 Specifies the maximum size of print files, IPP requests, and HTML form
15523 data. A limit of 0 disables the limit check.
15524
15525 Defaults to @samp{0}.
15526 @end deftypevr
15527
15528 @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
15529 Listens on the specified interfaces for connections. Valid values are
15530 of the form @var{address}:@var{port}, where @var{address} is either an
15531 IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
15532 indicate all addresses. Values can also be file names of local UNIX
15533 domain sockets. The Listen directive is similar to the Port directive
15534 but allows you to restrict access to specific interfaces or networks.
15535 @end deftypevr
15536
15537 @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
15538 Specifies the number of pending connections that will be allowed. This
15539 normally only affects very busy servers that have reached the MaxClients
15540 limit, but can also be triggered by large numbers of simultaneous
15541 connections. When the limit is reached, the operating system will
15542 refuse additional connections until the scheduler can accept the pending
15543 ones.
15544
15545 Defaults to @samp{128}.
15546 @end deftypevr
15547
15548 @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
15549 Specifies a set of additional access controls.
15550
15551 Available @code{location-access-controls} fields are:
15552
15553 @deftypevr {@code{location-access-controls} parameter} file-name path
15554 Specifies the URI path to which the access control applies.
15555 @end deftypevr
15556
15557 @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
15558 Access controls for all access to this path, in the same format as the
15559 @code{access-controls} of @code{operation-access-control}.
15560
15561 Defaults to @samp{()}.
15562 @end deftypevr
15563
15564 @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
15565 Access controls for method-specific access to this path.
15566
15567 Defaults to @samp{()}.
15568
15569 Available @code{method-access-controls} fields are:
15570
15571 @deftypevr {@code{method-access-controls} parameter} boolean reverse?
15572 If @code{#t}, apply access controls to all methods except the listed
15573 methods. Otherwise apply to only the listed methods.
15574
15575 Defaults to @samp{#f}.
15576 @end deftypevr
15577
15578 @deftypevr {@code{method-access-controls} parameter} method-list methods
15579 Methods to which this access control applies.
15580
15581 Defaults to @samp{()}.
15582 @end deftypevr
15583
15584 @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
15585 Access control directives, as a list of strings. Each string should be
15586 one directive, such as @samp{"Order allow,deny"}.
15587
15588 Defaults to @samp{()}.
15589 @end deftypevr
15590 @end deftypevr
15591 @end deftypevr
15592
15593 @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
15594 Specifies the number of debugging messages that are retained for logging
15595 if an error occurs in a print job. Debug messages are logged regardless
15596 of the LogLevel setting.
15597
15598 Defaults to @samp{100}.
15599 @end deftypevr
15600
15601 @deftypevr {@code{cups-configuration} parameter} log-level log-level
15602 Specifies the level of logging for the ErrorLog file. The value
15603 @code{none} stops all logging while @code{debug2} logs everything.
15604
15605 Defaults to @samp{info}.
15606 @end deftypevr
15607
15608 @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
15609 Specifies the format of the date and time in the log files. The value
15610 @code{standard} logs whole seconds while @code{usecs} logs microseconds.
15611
15612 Defaults to @samp{standard}.
15613 @end deftypevr
15614
15615 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
15616 Specifies the maximum number of simultaneous clients that are allowed by
15617 the scheduler.
15618
15619 Defaults to @samp{100}.
15620 @end deftypevr
15621
15622 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
15623 Specifies the maximum number of simultaneous clients that are allowed
15624 from a single address.
15625
15626 Defaults to @samp{100}.
15627 @end deftypevr
15628
15629 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
15630 Specifies the maximum number of copies that a user can print of each
15631 job.
15632
15633 Defaults to @samp{9999}.
15634 @end deftypevr
15635
15636 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
15637 Specifies the maximum time a job may remain in the @code{indefinite}
15638 hold state before it is canceled. A value of 0 disables cancellation of
15639 held jobs.
15640
15641 Defaults to @samp{0}.
15642 @end deftypevr
15643
15644 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
15645 Specifies the maximum number of simultaneous jobs that are allowed. Set
15646 to 0 to allow an unlimited number of jobs.
15647
15648 Defaults to @samp{500}.
15649 @end deftypevr
15650
15651 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
15652 Specifies the maximum number of simultaneous jobs that are allowed per
15653 printer. A value of 0 allows up to MaxJobs jobs per printer.
15654
15655 Defaults to @samp{0}.
15656 @end deftypevr
15657
15658 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
15659 Specifies the maximum number of simultaneous jobs that are allowed per
15660 user. A value of 0 allows up to MaxJobs jobs per user.
15661
15662 Defaults to @samp{0}.
15663 @end deftypevr
15664
15665 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
15666 Specifies the maximum time a job may take to print before it is
15667 canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
15668
15669 Defaults to @samp{10800}.
15670 @end deftypevr
15671
15672 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
15673 Specifies the maximum size of the log files before they are rotated, in
15674 bytes. The value 0 disables log rotation.
15675
15676 Defaults to @samp{1048576}.
15677 @end deftypevr
15678
15679 @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
15680 Specifies the maximum amount of time to allow between files in a
15681 multiple file print job, in seconds.
15682
15683 Defaults to @samp{300}.
15684 @end deftypevr
15685
15686 @deftypevr {@code{cups-configuration} parameter} string page-log-format
15687 Specifies the format of PageLog lines. Sequences beginning with percent
15688 (@samp{%}) characters are replaced with the corresponding information,
15689 while all other characters are copied literally. The following percent
15690 sequences are recognized:
15691
15692 @table @samp
15693 @item %%
15694 insert a single percent character
15695
15696 @item %@{name@}
15697 insert the value of the specified IPP attribute
15698
15699 @item %C
15700 insert the number of copies for the current page
15701
15702 @item %P
15703 insert the current page number
15704
15705 @item %T
15706 insert the current date and time in common log format
15707
15708 @item %j
15709 insert the job ID
15710
15711 @item %p
15712 insert the printer name
15713
15714 @item %u
15715 insert the username
15716 @end table
15717
15718 A value of the empty string disables page logging. The string @code{%p
15719 %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
15720 %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
15721 standard items.
15722
15723 Defaults to @samp{""}.
15724 @end deftypevr
15725
15726 @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
15727 Passes the specified environment variable(s) to child processes; a list
15728 of strings.
15729
15730 Defaults to @samp{()}.
15731 @end deftypevr
15732
15733 @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
15734 Specifies named access control policies.
15735
15736 Available @code{policy-configuration} fields are:
15737
15738 @deftypevr {@code{policy-configuration} parameter} string name
15739 Name of the policy.
15740 @end deftypevr
15741
15742 @deftypevr {@code{policy-configuration} parameter} string job-private-access
15743 Specifies an access list for a job's private values. @code{@@ACL} maps
15744 to the printer's requesting-user-name-allowed or
15745 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
15746 owner. @code{@@SYSTEM} maps to the groups listed for the
15747 @code{system-group} field of the @code{files-config} configuration,
15748 which is reified into the @code{cups-files.conf(5)} file. Other
15749 possible elements of the access list include specific user names, and
15750 @code{@@@var{group}} to indicate members of a specific group. The
15751 access list may also be simply @code{all} or @code{default}.
15752
15753 Defaults to @samp{"@@OWNER @@SYSTEM"}.
15754 @end deftypevr
15755
15756 @deftypevr {@code{policy-configuration} parameter} string job-private-values
15757 Specifies the list of job values to make private, or @code{all},
15758 @code{default}, or @code{none}.
15759
15760 Defaults to @samp{"job-name job-originating-host-name
15761 job-originating-user-name phone"}.
15762 @end deftypevr
15763
15764 @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
15765 Specifies an access list for a subscription's private values.
15766 @code{@@ACL} maps to the printer's requesting-user-name-allowed or
15767 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
15768 owner. @code{@@SYSTEM} maps to the groups listed for the
15769 @code{system-group} field of the @code{files-config} configuration,
15770 which is reified into the @code{cups-files.conf(5)} file. Other
15771 possible elements of the access list include specific user names, and
15772 @code{@@@var{group}} to indicate members of a specific group. The
15773 access list may also be simply @code{all} or @code{default}.
15774
15775 Defaults to @samp{"@@OWNER @@SYSTEM"}.
15776 @end deftypevr
15777
15778 @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
15779 Specifies the list of job values to make private, or @code{all},
15780 @code{default}, or @code{none}.
15781
15782 Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
15783 notify-subscriber-user-name notify-user-data"}.
15784 @end deftypevr
15785
15786 @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
15787 Access control by IPP operation.
15788
15789 Defaults to @samp{()}.
15790 @end deftypevr
15791 @end deftypevr
15792
15793 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
15794 Specifies whether job files (documents) are preserved after a job is
15795 printed. If a numeric value is specified, job files are preserved for
15796 the indicated number of seconds after printing. Otherwise a boolean
15797 value applies indefinitely.
15798
15799 Defaults to @samp{86400}.
15800 @end deftypevr
15801
15802 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
15803 Specifies whether the job history is preserved after a job is printed.
15804 If a numeric value is specified, the job history is preserved for the
15805 indicated number of seconds after printing. If @code{#t}, the job
15806 history is preserved until the MaxJobs limit is reached.
15807
15808 Defaults to @samp{#t}.
15809 @end deftypevr
15810
15811 @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
15812 Specifies the amount of time to wait for job completion before
15813 restarting the scheduler.
15814
15815 Defaults to @samp{30}.
15816 @end deftypevr
15817
15818 @deftypevr {@code{cups-configuration} parameter} string rip-cache
15819 Specifies the maximum amount of memory to use when converting documents
15820 into bitmaps for a printer.
15821
15822 Defaults to @samp{"128m"}.
15823 @end deftypevr
15824
15825 @deftypevr {@code{cups-configuration} parameter} string server-admin
15826 Specifies the email address of the server administrator.
15827
15828 Defaults to @samp{"root@@localhost.localdomain"}.
15829 @end deftypevr
15830
15831 @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
15832 The ServerAlias directive is used for HTTP Host header validation when
15833 clients connect to the scheduler from external interfaces. Using the
15834 special name @code{*} can expose your system to known browser-based DNS
15835 rebinding attacks, even when accessing sites through a firewall. If the
15836 auto-discovery of alternate names does not work, we recommend listing
15837 each alternate name with a ServerAlias directive instead of using
15838 @code{*}.
15839
15840 Defaults to @samp{*}.
15841 @end deftypevr
15842
15843 @deftypevr {@code{cups-configuration} parameter} string server-name
15844 Specifies the fully-qualified host name of the server.
15845
15846 Defaults to @samp{"localhost"}.
15847 @end deftypevr
15848
15849 @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
15850 Specifies what information is included in the Server header of HTTP
15851 responses. @code{None} disables the Server header. @code{ProductOnly}
15852 reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
15853 reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
15854 @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
15855 the output of the @code{uname} command. @code{Full} reports @code{CUPS
15856 2.0.0 (@var{uname}) IPP/2.0}.
15857
15858 Defaults to @samp{Minimal}.
15859 @end deftypevr
15860
15861 @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
15862 Listens on the specified interfaces for encrypted connections. Valid
15863 values are of the form @var{address}:@var{port}, where @var{address} is
15864 either an IPv6 address enclosed in brackets, an IPv4 address, or
15865 @code{*} to indicate all addresses.
15866
15867 Defaults to @samp{()}.
15868 @end deftypevr
15869
15870 @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
15871 Sets encryption options. By default, CUPS only supports encryption
15872 using TLS v1.0 or higher using known secure cipher suites. Security is
15873 reduced when @code{Allow} options are used, and enhanced when @code{Deny}
15874 options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
15875 suites, which are required for some older clients. The @code{AllowSSL3} option
15876 enables SSL v3.0, which is required for some older clients that do not support
15877 TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
15878 @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
15879 protocol version to TLS v1.1.
15880
15881 Defaults to @samp{()}.
15882 @end deftypevr
15883
15884 @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
15885 Specifies whether the scheduler requires clients to strictly adhere to
15886 the IPP specifications.
15887
15888 Defaults to @samp{#f}.
15889 @end deftypevr
15890
15891 @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
15892 Specifies the HTTP request timeout, in seconds.
15893
15894 Defaults to @samp{300}.
15895
15896 @end deftypevr
15897
15898 @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
15899 Specifies whether the web interface is enabled.
15900
15901 Defaults to @samp{#f}.
15902 @end deftypevr
15903
15904 At this point you're probably thinking ``oh dear, Guix manual, I like
15905 you but you can stop already with the configuration options''. Indeed.
15906 However, one more point: it could be that you have an existing
15907 @code{cupsd.conf} that you want to use. In that case, you can pass an
15908 @code{opaque-cups-configuration} as the configuration of a
15909 @code{cups-service-type}.
15910
15911 Available @code{opaque-cups-configuration} fields are:
15912
15913 @deftypevr {@code{opaque-cups-configuration} parameter} package cups
15914 The CUPS package.
15915 @end deftypevr
15916
15917 @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
15918 The contents of the @code{cupsd.conf}, as a string.
15919 @end deftypevr
15920
15921 @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
15922 The contents of the @code{cups-files.conf} file, as a string.
15923 @end deftypevr
15924
15925 For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
15926 strings of the same name, you could instantiate a CUPS service like
15927 this:
15928
15929 @lisp
15930 (service cups-service-type
15931 (opaque-cups-configuration
15932 (cupsd.conf cupsd.conf)
15933 (cups-files.conf cups-files.conf)))
15934 @end lisp
15935
15936
15937 @node Desktop Services
15938 @subsection Desktop Services
15939
15940 The @code{(gnu services desktop)} module provides services that are
15941 usually useful in the context of a ``desktop'' setup---that is, on a
15942 machine running a graphical display server, possibly with graphical user
15943 interfaces, etc. It also defines services that provide specific desktop
15944 environments like GNOME, Xfce or MATE.
15945
15946 To simplify things, the module defines a variable containing the set of
15947 services that users typically expect on a machine with a graphical
15948 environment and networking:
15949
15950 @defvr {Scheme Variable} %desktop-services
15951 This is a list of services that builds upon @code{%base-services} and
15952 adds or adjusts services for a typical ``desktop'' setup.
15953
15954 In particular, it adds a graphical login manager (@pxref{X Window,
15955 @code{gdm-service-type}}), screen lockers, a network management tool
15956 (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
15957 support (@pxref{Networking Services, @code{modem-manager-service-type}}),
15958 energy and color management services, the @code{elogind} login and seat
15959 manager, the Polkit privilege service, the GeoClue location service, the
15960 AccountsService daemon that allows authorized users change system passwords,
15961 an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
15962 name service switch service configured to be able to use @code{nss-mdns}
15963 (@pxref{Name Service Switch, mDNS}).
15964 @end defvr
15965
15966 The @code{%desktop-services} variable can be used as the @code{services}
15967 field of an @code{operating-system} declaration (@pxref{operating-system
15968 Reference, @code{services}}).
15969
15970 Additionally, the @code{gnome-desktop-service-type},
15971 @code{xfce-desktop-service}, @code{mate-desktop-service-type} and
15972 @code{enlightenment-desktop-service-type} procedures can add GNOME, Xfce, MATE
15973 and/or Enlightenment to a system. To ``add GNOME'' means that system-level
15974 services like the backlight adjustment helpers and the power management
15975 utilities are added to the system, extending @code{polkit} and @code{dbus}
15976 appropriately, allowing GNOME to operate with elevated privileges on a
15977 limited number of special-purpose system interfaces. Additionally,
15978 adding a service made by @code{gnome-desktop-service-type} adds the GNOME
15979 metapackage to the system profile. Likewise, adding the Xfce service
15980 not only adds the @code{xfce} metapackage to the system profile, but it
15981 also gives the Thunar file manager the ability to open a ``root-mode''
15982 file management window, if the user authenticates using the
15983 administrator's password via the standard polkit graphical interface.
15984 To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
15985 appropriately, allowing MATE to operate with elevated privileges on a
15986 limited number of special-purpose system interfaces. Additionally,
15987 adding a service of type @code{mate-desktop-service-type} adds the MATE
15988 metapackage to the system profile. ``Adding Enlightenment'' means that
15989 @code{dbus} is extended appropriately, and several of Enlightenment's binaries
15990 are set as setuid, allowing Enlightenment's screen locker and other
15991 functionality to work as expected.
15992
15993 The desktop environments in Guix use the Xorg display server by
15994 default. If you'd like to use the newer display server protocol
15995 called Wayland, you need to use the @code{sddm-service} instead of
15996 GDM as the graphical login manager. You should then
15997 select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
15998 also try starting GNOME on Wayland manually from a TTY with the
15999 command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
16000 gnome-session``. Currently only GNOME has support for Wayland.
16001
16002 @defvr {Scheme Variable} gnome-desktop-service-type
16003 This is the type of the service that adds the @uref{https://www.gnome.org,
16004 GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
16005 object (see below.)
16006
16007 This service adds the @code{gnome} package to the system profile, and extends
16008 polkit with the actions from @code{gnome-settings-daemon}.
16009 @end defvr
16010
16011 @deftp {Data Type} gnome-desktop-configuration
16012 Configuration record for the GNOME desktop environment.
16013
16014 @table @asis
16015 @item @code{gnome} (default: @code{gnome})
16016 The GNOME package to use.
16017 @end table
16018 @end deftp
16019
16020 @defvr {Scheme Variable} xfce-desktop-service-type
16021 This is the type of a service to run the @uref{Xfce, https://xfce.org/}
16022 desktop environment. Its value is an @code{xfce-desktop-configuration} object
16023 (see below.)
16024
16025 This service adds the @code{xfce} package to the system profile, and
16026 extends polkit with the ability for @code{thunar} to manipulate the file
16027 system as root from within a user session, after the user has authenticated
16028 with the administrator's password.
16029 @end defvr
16030
16031 @deftp {Data Type} xfce-desktop-configuration
16032 Configuration record for the Xfce desktop environment.
16033
16034 @table @asis
16035 @item @code{xfce} (default: @code{xfce})
16036 The Xfce package to use.
16037 @end table
16038 @end deftp
16039
16040 @deffn {Scheme Variable} mate-desktop-service-type
16041 This is the type of the service that runs the @uref{https://mate-desktop.org/,
16042 MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
16043 object (see below.)
16044
16045 This service adds the @code{mate} package to the system
16046 profile, and extends polkit with the actions from
16047 @code{mate-settings-daemon}.
16048 @end deffn
16049
16050 @deftp {Data Type} mate-desktop-configuration
16051 Configuration record for the MATE desktop environment.
16052
16053 @table @asis
16054 @item @code{mate} (default: @code{mate})
16055 The MATE package to use.
16056 @end table
16057 @end deftp
16058
16059 @deffn {Scheme Variable} enlightenment-desktop-service-type
16060 Return a service that adds the @code{enlightenment} package to the system
16061 profile, and extends dbus with actions from @code{efl}.
16062 @end deffn
16063
16064 @deftp {Data Type} enlightenment-desktop-service-configuration
16065 @table @asis
16066 @item @code{enlightenment} (default: @code{enlightenment})
16067 The enlightenment package to use.
16068 @end table
16069 @end deftp
16070
16071 Because the GNOME, Xfce and MATE desktop services pull in so many packages,
16072 the default @code{%desktop-services} variable doesn't include any of
16073 them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
16074 @code{%desktop-services} in the @code{services} field of your
16075 @code{operating-system}:
16076
16077 @lisp
16078 (use-modules (gnu))
16079 (use-service-modules desktop)
16080 (operating-system
16081 ...
16082 ;; cons* adds items to the list given as its last argument.
16083 (services (cons* (service gnome-desktop-service-type)
16084 (service xfce-desktop-service)
16085 %desktop-services))
16086 ...)
16087 @end lisp
16088
16089 These desktop environments will then be available as options in the
16090 graphical login window.
16091
16092 The actual service definitions included in @code{%desktop-services} and
16093 provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
16094 are described below.
16095
16096 @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
16097 Return a service that runs the ``system bus'', using @var{dbus}, with
16098 support for @var{services}.
16099
16100 @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
16101 facility. Its system bus is used to allow system services to communicate
16102 and to be notified of system-wide events.
16103
16104 @var{services} must be a list of packages that provide an
16105 @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
16106 and policy files. For example, to allow avahi-daemon to use the system bus,
16107 @var{services} must be equal to @code{(list avahi)}.
16108 @end deffn
16109
16110 @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
16111 Return a service that runs the @code{elogind} login and
16112 seat management daemon. @uref{https://github.com/elogind/elogind,
16113 Elogind} exposes a D-Bus interface that can be used to know which users
16114 are logged in, know what kind of sessions they have open, suspend the
16115 system, inhibit system suspend, reboot the system, and other tasks.
16116
16117 Elogind handles most system-level power events for a computer, for
16118 example suspending the system when a lid is closed, or shutting it down
16119 when the power button is pressed.
16120
16121 The @var{config} keyword argument specifies the configuration for
16122 elogind, and should be the result of an @code{(elogind-configuration
16123 (@var{parameter} @var{value})...)} invocation. Available parameters and
16124 their default values are:
16125
16126 @table @code
16127 @item kill-user-processes?
16128 @code{#f}
16129 @item kill-only-users
16130 @code{()}
16131 @item kill-exclude-users
16132 @code{("root")}
16133 @item inhibit-delay-max-seconds
16134 @code{5}
16135 @item handle-power-key
16136 @code{poweroff}
16137 @item handle-suspend-key
16138 @code{suspend}
16139 @item handle-hibernate-key
16140 @code{hibernate}
16141 @item handle-lid-switch
16142 @code{suspend}
16143 @item handle-lid-switch-docked
16144 @code{ignore}
16145 @item power-key-ignore-inhibited?
16146 @code{#f}
16147 @item suspend-key-ignore-inhibited?
16148 @code{#f}
16149 @item hibernate-key-ignore-inhibited?
16150 @code{#f}
16151 @item lid-switch-ignore-inhibited?
16152 @code{#t}
16153 @item holdoff-timeout-seconds
16154 @code{30}
16155 @item idle-action
16156 @code{ignore}
16157 @item idle-action-seconds
16158 @code{(* 30 60)}
16159 @item runtime-directory-size-percent
16160 @code{10}
16161 @item runtime-directory-size
16162 @code{#f}
16163 @item remove-ipc?
16164 @code{#t}
16165 @item suspend-state
16166 @code{("mem" "standby" "freeze")}
16167 @item suspend-mode
16168 @code{()}
16169 @item hibernate-state
16170 @code{("disk")}
16171 @item hibernate-mode
16172 @code{("platform" "shutdown")}
16173 @item hybrid-sleep-state
16174 @code{("disk")}
16175 @item hybrid-sleep-mode
16176 @code{("suspend" "platform" "shutdown")}
16177 @end table
16178 @end deffn
16179
16180 @deffn {Scheme Procedure} accountsservice-service @
16181 [#:accountsservice @var{accountsservice}]
16182 Return a service that runs AccountsService, a system service that can
16183 list available accounts, change their passwords, and so on.
16184 AccountsService integrates with PolicyKit to enable unprivileged users
16185 to acquire the capability to modify their system configuration.
16186 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
16187 accountsservice web site} for more information.
16188
16189 The @var{accountsservice} keyword argument is the @code{accountsservice}
16190 package to expose as a service.
16191 @end deffn
16192
16193 @deffn {Scheme Procedure} polkit-service @
16194 [#:polkit @var{polkit}]
16195 Return a service that runs the
16196 @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
16197 management service}, which allows system administrators to grant access to
16198 privileged operations in a structured way. By querying the Polkit service, a
16199 privileged system component can know when it should grant additional
16200 capabilities to ordinary users. For example, an ordinary user can be granted
16201 the capability to suspend the system if the user is logged in locally.
16202 @end deffn
16203
16204 @defvr {Scheme Variable} polkit-wheel-service
16205 Service that adds the @code{wheel} group as admins to the Polkit
16206 service. This makes it so that users in the @code{wheel} group are queried
16207 for their own passwords when performing administrative actions instead of
16208 @code{root}'s, similar to the behaviour used by @code{sudo}.
16209 @end defvr
16210
16211 @defvr {Scheme Variable} upower-service-type
16212 Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
16213 system-wide monitor for power consumption and battery levels, with the given
16214 configuration settings.
16215
16216 It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
16217 notably used by GNOME.
16218 @end defvr
16219
16220 @deftp {Data Type} upower-configuration
16221 Data type representation the configuration for UPower.
16222
16223 @table @asis
16224
16225 @item @code{upower} (default: @var{upower})
16226 Package to use for @code{upower}.
16227
16228 @item @code{watts-up-pro?} (default: @code{#f})
16229 Enable the Watts Up Pro device.
16230
16231 @item @code{poll-batteries?} (default: @code{#t})
16232 Enable polling the kernel for battery level changes.
16233
16234 @item @code{ignore-lid?} (default: @code{#f})
16235 Ignore the lid state, this can be useful if it's incorrect on a device.
16236
16237 @item @code{use-percentage-for-policy?} (default: @code{#f})
16238 Whether battery percentage based policy should be used. The default is to use
16239 the time left, change to @code{#t} to use the percentage.
16240
16241 @item @code{percentage-low} (default: @code{10})
16242 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
16243 at which the battery is considered low.
16244
16245 @item @code{percentage-critical} (default: @code{3})
16246 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
16247 at which the battery is considered critical.
16248
16249 @item @code{percentage-action} (default: @code{2})
16250 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
16251 at which action will be taken.
16252
16253 @item @code{time-low} (default: @code{1200})
16254 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
16255 seconds at which the battery is considered low.
16256
16257 @item @code{time-critical} (default: @code{300})
16258 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
16259 seconds at which the battery is considered critical.
16260
16261 @item @code{time-action} (default: @code{120})
16262 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
16263 seconds at which action will be taken.
16264
16265 @item @code{critical-power-action} (default: @code{'hybrid-sleep})
16266 The action taken when @code{percentage-action} or @code{time-action} is
16267 reached (depending on the configuration of @code{use-percentage-for-policy?}).
16268
16269 Possible values are:
16270
16271 @itemize @bullet
16272 @item
16273 @code{'power-off}
16274
16275 @item
16276 @code{'hibernate}
16277
16278 @item
16279 @code{'hybrid-sleep}.
16280 @end itemize
16281
16282 @end table
16283 @end deftp
16284
16285 @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
16286 Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
16287 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
16288 notifications and ways to mount/unmount disks. Programs that talk to UDisks
16289 include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
16290 @end deffn
16291
16292 @deffn {Scheme Variable} colord-service-type
16293 This is the type of the service that runs @command{colord}, a system
16294 service with a D-Bus
16295 interface to manage the color profiles of input and output devices such as
16296 screens and scanners. It is notably used by the GNOME Color Manager graphical
16297 tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
16298 site} for more information.
16299 @end deffn
16300
16301 @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
16302 Return a configuration allowing an application to access GeoClue
16303 location data. @var{name} is the Desktop ID of the application, without
16304 the @code{.desktop} part. If @var{allowed?} is true, the application
16305 will have access to location information by default. The boolean
16306 @var{system?} value indicates whether an application is a system component
16307 or not. Finally @var{users} is a list of UIDs of all users for which
16308 this application is allowed location info access. An empty users list
16309 means that all users are allowed.
16310 @end deffn
16311
16312 @cindex scanner access
16313 @deffn {Scheme Procedure} sane-service-type
16314 This service provides access to scanners @i{via}
16315 @uref{http://www.sane-project.org, SANE} by installing the necessary udev
16316 rules.
16317 @end deffn
16318
16319 @defvr {Scheme Variable} %standard-geoclue-applications
16320 The standard list of well-known GeoClue application configurations,
16321 granting authority to the GNOME date-and-time utility to ask for the
16322 current location in order to set the time zone, and allowing the
16323 IceCat and Epiphany web browsers to request location information.
16324 IceCat and Epiphany both query the user before allowing a web page to
16325 know the user's location.
16326 @end defvr
16327
16328 @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
16329 [#:whitelist '()] @
16330 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
16331 [#:submit-data? #f]
16332 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
16333 [#:submission-nick "geoclue"] @
16334 [#:applications %standard-geoclue-applications]
16335 Return a service that runs the GeoClue location service. This service
16336 provides a D-Bus interface to allow applications to request access to a
16337 user's physical location, and optionally to add information to online
16338 location databases. See
16339 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
16340 web site} for more information.
16341 @end deffn
16342
16343 @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
16344 [@w{#:auto-enable? #f}]
16345 Return a service that runs the @command{bluetoothd} daemon, which
16346 manages all the Bluetooth devices and provides a number of D-Bus
16347 interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
16348 powered automatically at boot, which can be useful when using a
16349 bluetooth keyboard or mouse.
16350
16351 Users need to be in the @code{lp} group to access the D-Bus service.
16352 @end deffn
16353
16354 @defvr {Scheme Variable} gnome-keyring-service-type
16355 This is the type of the service that adds the
16356 @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
16357 value is a @code{gnome-keyring-configuration} object (see below.)
16358
16359 This service adds the @code{gnome-keyring} package to the system profile
16360 and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
16361 a user's login keyring when they log in or setting its password with passwd.
16362 @end defvr
16363
16364 @deftp {Data Type} gnome-keyring-configuration
16365 Configuration record for the GNOME Keyring service.
16366
16367 @table @asis
16368 @item @code{keyring} (default: @code{gnome-keyring})
16369 The GNOME keyring package to use.
16370
16371 @item @code{pam-services}
16372 A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
16373 services to extend, where @var{service} is the name of an existing
16374 service to extend and @var{kind} is one of @code{login} or
16375 @code{passwd}.
16376
16377 If @code{login} is given, it adds an optional
16378 @code{pam_gnome_keyring.so} to the auth block without arguments and to
16379 the session block with @code{auto_start}. If @code{passwd} is given, it
16380 adds an optional @code{pam_gnome_keyring.so} to the password block
16381 without arguments.
16382
16383 By default, this field contains ``gdm-password'' with the value @code{login}
16384 and ``passwd'' is with the value @code{passwd}.
16385 @end table
16386 @end deftp
16387
16388
16389 @node Sound Services
16390 @subsection Sound Services
16391
16392 @cindex sound support
16393 @cindex ALSA
16394 @cindex PulseAudio, sound support
16395
16396 The @code{(gnu services sound)} module provides a service to configure the
16397 Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
16398 preferred ALSA output driver.
16399
16400 @deffn {Scheme Variable} alsa-service-type
16401 This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
16402 Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
16403 configuration file. The value for this type is a @command{alsa-configuration}
16404 record as in this example:
16405
16406 @lisp
16407 (service alsa-service-type)
16408 @end lisp
16409
16410 See below for details about @code{alsa-configuration}.
16411 @end deffn
16412
16413 @deftp {Data Type} alsa-configuration
16414 Data type representing the configuration for @code{alsa-service}.
16415
16416 @table @asis
16417 @item @code{alsa-plugins} (default: @var{alsa-plugins})
16418 @code{alsa-plugins} package to use.
16419
16420 @item @code{pulseaudio?} (default: @var{#t})
16421 Whether ALSA applications should transparently be made to use the
16422 @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
16423
16424 Using PulseAudio allows you to run several sound-producing applications
16425 at the same time and to individual control them @i{via}
16426 @command{pavucontrol}, among other things.
16427
16428 @item @code{extra-options} (default: @var{""})
16429 String to append to the @file{/etc/asound.conf} file.
16430
16431 @end table
16432 @end deftp
16433
16434 Individual users who want to override the system configuration of ALSA can do
16435 it with the @file{~/.asoundrc} file:
16436
16437 @example
16438 # In guix, we have to specify the absolute path for plugins.
16439 pcm_type.jack @{
16440 lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
16441 @}
16442
16443 # Routing ALSA to jack:
16444 # <http://jackaudio.org/faq/routing_alsa.html>.
16445 pcm.rawjack @{
16446 type jack
16447 playback_ports @{
16448 0 system:playback_1
16449 1 system:playback_2
16450 @}
16451
16452 capture_ports @{
16453 0 system:capture_1
16454 1 system:capture_2
16455 @}
16456 @}
16457
16458 pcm.!default @{
16459 type plug
16460 slave @{
16461 pcm "rawjack"
16462 @}
16463 @}
16464 @end example
16465
16466 See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
16467 details.
16468
16469 @deffn {Scheme Variable} pulseaudio-service-type
16470 This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
16471 sound server. It exists to allow system overrides of the default settings
16472 via @code{pulseaudio-configuration}, see below.
16473
16474 @quotation Warning
16475 This service overrides per-user configuration files. If you want
16476 PulseAudio to honor configuraton files in @file{~/.config/pulse} you
16477 have to unset the environment variables @env{PULSE_CONFIG} and
16478 @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
16479 @end quotation
16480
16481 @quotation Warning
16482 This service on its own does not ensure, that the @code{pulseaudio} package
16483 exists on your machine. It merely adds configuration files for it, as
16484 detailed below. In the (admittedly unlikely) case, that you find yourself
16485 without a @code{pulseaudio} package, consider enabling it through the
16486 @code{alsa-service-type} above.
16487 @end quotation
16488 @end deffn
16489
16490 @deftp {Data Type} pulseaudio-configuration
16491 Data type representing the configuration for @code{pulseaudio-service}.
16492
16493 @table @asis
16494 @item @var{client-conf} (default: @code{'()})
16495 List of settings to set in @file{client.conf}.
16496 Accepts a list of strings or a symbol-value pairs. A string will be
16497 inserted as-is with a newline added. A pair will be formatted as
16498 ``key = value'', again with a newline added.
16499
16500 @item @var{daemon-conf} (default: @code{'((flat-volumes . no))})
16501 List of settings to set in @file{daemon.conf}, formatted just like
16502 @var{client-conf}.
16503
16504 @item @var{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
16505 Script file to use as as @file{default.pa}.
16506
16507 @item @var{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
16508 Script file to use as as @file{system.pa}.
16509 @end table
16510 @end deftp
16511
16512 @deffn {Scheme Variable} ladspa-service-type
16513 This service sets the @var{LADSPA_PATH} variable, so that programs, which
16514 respect it, e.g. PulseAudio, can load LADSPA plugins.
16515
16516 The following example will setup the service to enable modules from the
16517 @code{swh-plugins} package:
16518
16519 @lisp
16520 (service ladspa-service-type
16521 (ladspa-configuration (plugins (list swh-plugins))))
16522 @end lisp
16523
16524 See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
16525 details.
16526
16527 @end deffn
16528
16529 @node Database Services
16530 @subsection Database Services
16531
16532 @cindex database
16533 @cindex SQL
16534 The @code{(gnu services databases)} module provides the following services.
16535
16536 @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
16537 [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
16538 [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
16539 Return a service that runs @var{postgresql}, the PostgreSQL database
16540 server.
16541
16542 The PostgreSQL daemon loads its runtime configuration from @var{config-file},
16543 creates a database cluster with @var{locale} as the default
16544 locale, stored in @var{data-directory}. It then listens on @var{port}.
16545
16546 @cindex postgresql extension-packages
16547 Additional extensions are loaded from packages listed in
16548 @var{extension-packages}. Extensions are available at runtime. For instance,
16549 to create a geographic database using the @code{postgis} extension, a user can
16550 configure the postgresql-service as in this example:
16551
16552 @cindex postgis
16553 @lisp
16554 (use-package-modules databases geo)
16555
16556 (operating-system
16557 ...
16558 ;; postgresql is required to run `psql' but postgis is not required for
16559 ;; proper operation.
16560 (packages (cons* postgresql %base-packages))
16561 (services
16562 (cons*
16563 (postgresql-service #:extension-packages (list postgis))
16564 %base-services)))
16565 @end lisp
16566
16567 Then the extension becomes visible and you can initialise an empty geographic
16568 database in this way:
16569
16570 @example
16571 psql -U postgres
16572 > create database postgistest;
16573 > \connect postgistest;
16574 > create extension postgis;
16575 > create extension postgis_topology;
16576 @end example
16577
16578 There is no need to add this field for contrib extensions such as hstore or
16579 dblink as they are already loadable by postgresql. This field is only
16580 required to add extensions provided by other packages.
16581 @end deffn
16582
16583 @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
16584 Return a service that runs @command{mysqld}, the MySQL or MariaDB
16585 database server.
16586
16587 The optional @var{config} argument specifies the configuration for
16588 @command{mysqld}, which should be a @code{<mysql-configuration>} object.
16589 @end deffn
16590
16591 @deftp {Data Type} mysql-configuration
16592 Data type representing the configuration of @var{mysql-service}.
16593
16594 @table @asis
16595 @item @code{mysql} (default: @var{mariadb})
16596 Package object of the MySQL database server, can be either @var{mariadb}
16597 or @var{mysql}.
16598
16599 For MySQL, a temporary root password will be displayed at activation time.
16600 For MariaDB, the root password is empty.
16601
16602 @item @code{port} (default: @code{3306})
16603 TCP port on which the database server listens for incoming connections.
16604 @end table
16605 @end deftp
16606
16607 @defvr {Scheme Variable} memcached-service-type
16608 This is the service type for the @uref{https://memcached.org/,
16609 Memcached} service, which provides a distributed in memory cache. The
16610 value for the service type is a @code{memcached-configuration} object.
16611 @end defvr
16612
16613 @lisp
16614 (service memcached-service-type)
16615 @end lisp
16616
16617 @deftp {Data Type} memcached-configuration
16618 Data type representing the configuration of memcached.
16619
16620 @table @asis
16621 @item @code{memcached} (default: @code{memcached})
16622 The Memcached package to use.
16623
16624 @item @code{interfaces} (default: @code{'("0.0.0.0")})
16625 Network interfaces on which to listen.
16626
16627 @item @code{tcp-port} (default: @code{11211})
16628 Port on which to accept connections on,
16629
16630 @item @code{udp-port} (default: @code{11211})
16631 Port on which to accept UDP connections on, a value of 0 will disable
16632 listening on a UDP socket.
16633
16634 @item @code{additional-options} (default: @code{'()})
16635 Additional command line options to pass to @code{memcached}.
16636 @end table
16637 @end deftp
16638
16639 @defvr {Scheme Variable} mongodb-service-type
16640 This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
16641 The value for the service type is a @code{mongodb-configuration} object.
16642 @end defvr
16643
16644 @lisp
16645 (service mongodb-service-type)
16646 @end lisp
16647
16648 @deftp {Data Type} mongodb-configuration
16649 Data type representing the configuration of mongodb.
16650
16651 @table @asis
16652 @item @code{mongodb} (default: @code{mongodb})
16653 The MongoDB package to use.
16654
16655 @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
16656 The configuration file for MongoDB.
16657
16658 @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
16659 This value is used to create the directory, so that it exists and is
16660 owned by the mongodb user. It should match the data-directory which
16661 MongoDB is configured to use through the configuration file.
16662 @end table
16663 @end deftp
16664
16665 @defvr {Scheme Variable} redis-service-type
16666 This is the service type for the @uref{https://redis.io/, Redis}
16667 key/value store, whose value is a @code{redis-configuration} object.
16668 @end defvr
16669
16670 @deftp {Data Type} redis-configuration
16671 Data type representing the configuration of redis.
16672
16673 @table @asis
16674 @item @code{redis} (default: @code{redis})
16675 The Redis package to use.
16676
16677 @item @code{bind} (default: @code{"127.0.0.1"})
16678 Network interface on which to listen.
16679
16680 @item @code{port} (default: @code{6379})
16681 Port on which to accept connections on, a value of 0 will disable
16682 listening on a TCP socket.
16683
16684 @item @code{working-directory} (default: @code{"/var/lib/redis"})
16685 Directory in which to store the database and related files.
16686 @end table
16687 @end deftp
16688
16689 @node Mail Services
16690 @subsection Mail Services
16691
16692 @cindex mail
16693 @cindex email
16694 The @code{(gnu services mail)} module provides Guix service definitions
16695 for email services: IMAP, POP3, and LMTP servers, as well as mail
16696 transport agents (MTAs). Lots of acronyms! These services are detailed
16697 in the subsections below.
16698
16699 @subsubheading Dovecot Service
16700
16701 @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
16702 Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
16703 @end deffn
16704
16705 By default, Dovecot does not need much configuration; the default
16706 configuration object created by @code{(dovecot-configuration)} will
16707 suffice if your mail is delivered to @code{~/Maildir}. A self-signed
16708 certificate will be generated for TLS-protected connections, though
16709 Dovecot will also listen on cleartext ports by default. There are a
16710 number of options, though, which mail administrators might need to change,
16711 and as is the case with other services, Guix allows the system
16712 administrator to specify these parameters via a uniform Scheme interface.
16713
16714 For example, to specify that mail is located at @code{maildir~/.mail},
16715 one would instantiate the Dovecot service like this:
16716
16717 @lisp
16718 (dovecot-service #:config
16719 (dovecot-configuration
16720 (mail-location "maildir:~/.mail")))
16721 @end lisp
16722
16723 The available configuration parameters follow. Each parameter
16724 definition is preceded by its type; for example, @samp{string-list foo}
16725 indicates that the @code{foo} parameter should be specified as a list of
16726 strings. There is also a way to specify the configuration as a string,
16727 if you have an old @code{dovecot.conf} file that you want to port over
16728 from some other system; see the end for more details.
16729
16730 @c The following documentation was initially generated by
16731 @c (generate-documentation) in (gnu services mail). Manually maintained
16732 @c documentation is better, so we shouldn't hesitate to edit below as
16733 @c needed. However if the change you want to make to this documentation
16734 @c can be done in an automated way, it's probably easier to change
16735 @c (generate-documentation) than to make it below and have to deal with
16736 @c the churn as dovecot updates.
16737
16738 Available @code{dovecot-configuration} fields are:
16739
16740 @deftypevr {@code{dovecot-configuration} parameter} package dovecot
16741 The dovecot package.
16742 @end deftypevr
16743
16744 @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
16745 A list of IPs or hosts where to listen for connections. @samp{*}
16746 listens on all IPv4 interfaces, @samp{::} listens on all IPv6
16747 interfaces. If you want to specify non-default ports or anything more
16748 complex, customize the address and port fields of the
16749 @samp{inet-listener} of the specific services you are interested in.
16750 @end deftypevr
16751
16752 @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
16753 List of protocols we want to serve. Available protocols include
16754 @samp{imap}, @samp{pop3}, and @samp{lmtp}.
16755
16756 Available @code{protocol-configuration} fields are:
16757
16758 @deftypevr {@code{protocol-configuration} parameter} string name
16759 The name of the protocol.
16760 @end deftypevr
16761
16762 @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
16763 UNIX socket path to the master authentication server to find users.
16764 This is used by imap (for shared users) and lda.
16765 It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
16766 @end deftypevr
16767
16768 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
16769 Space separated list of plugins to load.
16770 @end deftypevr
16771
16772 @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
16773 Maximum number of IMAP connections allowed for a user from each IP
16774 address. NOTE: The username is compared case-sensitively.
16775 Defaults to @samp{10}.
16776 @end deftypevr
16777
16778 @end deftypevr
16779
16780 @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
16781 List of services to enable. Available services include @samp{imap},
16782 @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
16783 @samp{lmtp}.
16784
16785 Available @code{service-configuration} fields are:
16786
16787 @deftypevr {@code{service-configuration} parameter} string kind
16788 The service kind. Valid values include @code{director},
16789 @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
16790 @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
16791 @code{tcpwrap}, @code{quota-warning}, or anything else.
16792 @end deftypevr
16793
16794 @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
16795 Listeners for the service. A listener is either a
16796 @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
16797 an @code{inet-listener-configuration}.
16798 Defaults to @samp{()}.
16799
16800 Available @code{unix-listener-configuration} fields are:
16801
16802 @deftypevr {@code{unix-listener-configuration} parameter} string path
16803 Path to the file, relative to @code{base-dir} field. This is also used as
16804 the section name.
16805 @end deftypevr
16806
16807 @deftypevr {@code{unix-listener-configuration} parameter} string mode
16808 The access mode for the socket.
16809 Defaults to @samp{"0600"}.
16810 @end deftypevr
16811
16812 @deftypevr {@code{unix-listener-configuration} parameter} string user
16813 The user to own the socket.
16814 Defaults to @samp{""}.
16815 @end deftypevr
16816
16817 @deftypevr {@code{unix-listener-configuration} parameter} string group
16818 The group to own the socket.
16819 Defaults to @samp{""}.
16820 @end deftypevr
16821
16822
16823 Available @code{fifo-listener-configuration} fields are:
16824
16825 @deftypevr {@code{fifo-listener-configuration} parameter} string path
16826 Path to the file, relative to @code{base-dir} field. This is also used as
16827 the section name.
16828 @end deftypevr
16829
16830 @deftypevr {@code{fifo-listener-configuration} parameter} string mode
16831 The access mode for the socket.
16832 Defaults to @samp{"0600"}.
16833 @end deftypevr
16834
16835 @deftypevr {@code{fifo-listener-configuration} parameter} string user
16836 The user to own the socket.
16837 Defaults to @samp{""}.
16838 @end deftypevr
16839
16840 @deftypevr {@code{fifo-listener-configuration} parameter} string group
16841 The group to own the socket.
16842 Defaults to @samp{""}.
16843 @end deftypevr
16844
16845
16846 Available @code{inet-listener-configuration} fields are:
16847
16848 @deftypevr {@code{inet-listener-configuration} parameter} string protocol
16849 The protocol to listen for.
16850 @end deftypevr
16851
16852 @deftypevr {@code{inet-listener-configuration} parameter} string address
16853 The address on which to listen, or empty for all addresses.
16854 Defaults to @samp{""}.
16855 @end deftypevr
16856
16857 @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
16858 The port on which to listen.
16859 @end deftypevr
16860
16861 @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
16862 Whether to use SSL for this service; @samp{yes}, @samp{no}, or
16863 @samp{required}.
16864 Defaults to @samp{#t}.
16865 @end deftypevr
16866
16867 @end deftypevr
16868
16869 @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
16870 Maximum number of simultaneous client connections per process. Once
16871 this number of connections is received, the next incoming connection
16872 will prompt Dovecot to spawn another process. If set to 0,
16873 @code{default-client-limit} is used instead.
16874
16875 Defaults to @samp{0}.
16876
16877 @end deftypevr
16878
16879 @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
16880 Number of connections to handle before starting a new process.
16881 Typically the only useful values are 0 (unlimited) or 1. 1 is more
16882 secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
16883 Defaults to @samp{1}.
16884
16885 @end deftypevr
16886
16887 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
16888 Maximum number of processes that can exist for this service. If set to
16889 0, @code{default-process-limit} is used instead.
16890
16891 Defaults to @samp{0}.
16892
16893 @end deftypevr
16894
16895 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
16896 Number of processes to always keep waiting for more connections.
16897 Defaults to @samp{0}.
16898 @end deftypevr
16899
16900 @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
16901 If you set @samp{service-count 0}, you probably need to grow
16902 this.
16903 Defaults to @samp{256000000}.
16904 @end deftypevr
16905
16906 @end deftypevr
16907
16908 @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
16909 Dict configuration, as created by the @code{dict-configuration}
16910 constructor.
16911
16912 Available @code{dict-configuration} fields are:
16913
16914 @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
16915 A list of key-value pairs that this dict should hold.
16916 Defaults to @samp{()}.
16917 @end deftypevr
16918
16919 @end deftypevr
16920
16921 @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
16922 A list of passdb configurations, each one created by the
16923 @code{passdb-configuration} constructor.
16924
16925 Available @code{passdb-configuration} fields are:
16926
16927 @deftypevr {@code{passdb-configuration} parameter} string driver
16928 The driver that the passdb should use. Valid values include
16929 @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
16930 @samp{static}.
16931 Defaults to @samp{"pam"}.
16932 @end deftypevr
16933
16934 @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
16935 Space separated list of arguments to the passdb driver.
16936 Defaults to @samp{""}.
16937 @end deftypevr
16938
16939 @end deftypevr
16940
16941 @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
16942 List of userdb configurations, each one created by the
16943 @code{userdb-configuration} constructor.
16944
16945 Available @code{userdb-configuration} fields are:
16946
16947 @deftypevr {@code{userdb-configuration} parameter} string driver
16948 The driver that the userdb should use. Valid values include
16949 @samp{passwd} and @samp{static}.
16950 Defaults to @samp{"passwd"}.
16951 @end deftypevr
16952
16953 @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
16954 Space separated list of arguments to the userdb driver.
16955 Defaults to @samp{""}.
16956 @end deftypevr
16957
16958 @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
16959 Override fields from passwd.
16960 Defaults to @samp{()}.
16961 @end deftypevr
16962
16963 @end deftypevr
16964
16965 @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
16966 Plug-in configuration, created by the @code{plugin-configuration}
16967 constructor.
16968 @end deftypevr
16969
16970 @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
16971 List of namespaces. Each item in the list is created by the
16972 @code{namespace-configuration} constructor.
16973
16974 Available @code{namespace-configuration} fields are:
16975
16976 @deftypevr {@code{namespace-configuration} parameter} string name
16977 Name for this namespace.
16978 @end deftypevr
16979
16980 @deftypevr {@code{namespace-configuration} parameter} string type
16981 Namespace type: @samp{private}, @samp{shared} or @samp{public}.
16982 Defaults to @samp{"private"}.
16983 @end deftypevr
16984
16985 @deftypevr {@code{namespace-configuration} parameter} string separator
16986 Hierarchy separator to use. You should use the same separator for
16987 all namespaces or some clients get confused. @samp{/} is usually a good
16988 one. The default however depends on the underlying mail storage
16989 format.
16990 Defaults to @samp{""}.
16991 @end deftypevr
16992
16993 @deftypevr {@code{namespace-configuration} parameter} string prefix
16994 Prefix required to access this namespace. This needs to be
16995 different for all namespaces. For example @samp{Public/}.
16996 Defaults to @samp{""}.
16997 @end deftypevr
16998
16999 @deftypevr {@code{namespace-configuration} parameter} string location
17000 Physical location of the mailbox. This is in the same format as
17001 mail_location, which is also the default for it.
17002 Defaults to @samp{""}.
17003 @end deftypevr
17004
17005 @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
17006 There can be only one INBOX, and this setting defines which
17007 namespace has it.
17008 Defaults to @samp{#f}.
17009 @end deftypevr
17010
17011 @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
17012 If namespace is hidden, it's not advertised to clients via NAMESPACE
17013 extension. You'll most likely also want to set @samp{list? #f}. This is mostly
17014 useful when converting from another server with different namespaces
17015 which you want to deprecate but still keep working. For example you can
17016 create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
17017 and @samp{mail/}.
17018 Defaults to @samp{#f}.
17019 @end deftypevr
17020
17021 @deftypevr {@code{namespace-configuration} parameter} boolean list?
17022 Show the mailboxes under this namespace with the LIST command. This
17023 makes the namespace visible for clients that do not support the NAMESPACE
17024 extension. The special @code{children} value lists child mailboxes, but
17025 hides the namespace prefix.
17026 Defaults to @samp{#t}.
17027 @end deftypevr
17028
17029 @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
17030 Namespace handles its own subscriptions. If set to @code{#f}, the
17031 parent namespace handles them. The empty prefix should always have this
17032 as @code{#t}).
17033 Defaults to @samp{#t}.
17034 @end deftypevr
17035
17036 @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
17037 List of predefined mailboxes in this namespace.
17038 Defaults to @samp{()}.
17039
17040 Available @code{mailbox-configuration} fields are:
17041
17042 @deftypevr {@code{mailbox-configuration} parameter} string name
17043 Name for this mailbox.
17044 @end deftypevr
17045
17046 @deftypevr {@code{mailbox-configuration} parameter} string auto
17047 @samp{create} will automatically create this mailbox.
17048 @samp{subscribe} will both create and subscribe to the mailbox.
17049 Defaults to @samp{"no"}.
17050 @end deftypevr
17051
17052 @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
17053 List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
17054 Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
17055 @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
17056 Defaults to @samp{()}.
17057 @end deftypevr
17058
17059 @end deftypevr
17060
17061 @end deftypevr
17062
17063 @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
17064 Base directory where to store runtime data.
17065 Defaults to @samp{"/var/run/dovecot/"}.
17066 @end deftypevr
17067
17068 @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
17069 Greeting message for clients.
17070 Defaults to @samp{"Dovecot ready."}.
17071 @end deftypevr
17072
17073 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
17074 List of trusted network ranges. Connections from these IPs are
17075 allowed to override their IP addresses and ports (for logging and for
17076 authentication checks). @samp{disable-plaintext-auth} is also ignored
17077 for these networks. Typically you would specify your IMAP proxy servers
17078 here.
17079 Defaults to @samp{()}.
17080 @end deftypevr
17081
17082 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
17083 List of login access check sockets (e.g.@: tcpwrap).
17084 Defaults to @samp{()}.
17085 @end deftypevr
17086
17087 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
17088 Show more verbose process titles (in ps). Currently shows user name
17089 and IP address. Useful for seeing who is actually using the IMAP
17090 processes (e.g.@: shared mailboxes or if the same uid is used for multiple
17091 accounts).
17092 Defaults to @samp{#f}.
17093 @end deftypevr
17094
17095 @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
17096 Should all processes be killed when Dovecot master process shuts down.
17097 Setting this to @code{#f} means that Dovecot can be upgraded without
17098 forcing existing client connections to close (although that could also
17099 be a problem if the upgrade is e.g.@: due to a security fix).
17100 Defaults to @samp{#t}.
17101 @end deftypevr
17102
17103 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
17104 If non-zero, run mail commands via this many connections to doveadm
17105 server, instead of running them directly in the same process.
17106 Defaults to @samp{0}.
17107 @end deftypevr
17108
17109 @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
17110 UNIX socket or host:port used for connecting to doveadm server.
17111 Defaults to @samp{"doveadm-server"}.
17112 @end deftypevr
17113
17114 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
17115 List of environment variables that are preserved on Dovecot startup
17116 and passed down to all of its child processes. You can also give
17117 key=value pairs to always set specific settings.
17118 @end deftypevr
17119
17120 @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
17121 Disable LOGIN command and all other plaintext authentications unless
17122 SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
17123 matches the local IP (i.e.@: you're connecting from the same computer),
17124 the connection is considered secure and plaintext authentication is
17125 allowed. See also ssl=required setting.
17126 Defaults to @samp{#t}.
17127 @end deftypevr
17128
17129 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
17130 Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
17131 Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
17132 for caching to be used.
17133 Defaults to @samp{0}.
17134 @end deftypevr
17135
17136 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
17137 Time to live for cached data. After TTL expires the cached record
17138 is no longer used, *except* if the main database lookup returns internal
17139 failure. We also try to handle password changes automatically: If
17140 user's previous authentication was successful, but this one wasn't, the
17141 cache isn't used. For now this works only with plaintext
17142 authentication.
17143 Defaults to @samp{"1 hour"}.
17144 @end deftypevr
17145
17146 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
17147 TTL for negative hits (user not found, password mismatch).
17148 0 disables caching them completely.
17149 Defaults to @samp{"1 hour"}.
17150 @end deftypevr
17151
17152 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
17153 List of realms for SASL authentication mechanisms that need them.
17154 You can leave it empty if you don't want to support multiple realms.
17155 Many clients simply use the first one listed here, so keep the default
17156 realm first.
17157 Defaults to @samp{()}.
17158 @end deftypevr
17159
17160 @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
17161 Default realm/domain to use if none was specified. This is used for
17162 both SASL realms and appending @@domain to username in plaintext
17163 logins.
17164 Defaults to @samp{""}.
17165 @end deftypevr
17166
17167 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
17168 List of allowed characters in username. If the user-given username
17169 contains a character not listed in here, the login automatically fails.
17170 This is just an extra check to make sure user can't exploit any
17171 potential quote escaping vulnerabilities with SQL/LDAP databases. If
17172 you want to allow all characters, set this value to empty.
17173 Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
17174 @end deftypevr
17175
17176 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
17177 Username character translations before it's looked up from
17178 databases. The value contains series of from -> to characters. For
17179 example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
17180 translated to @samp{@@}.
17181 Defaults to @samp{""}.
17182 @end deftypevr
17183
17184 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
17185 Username formatting before it's looked up from databases. You can
17186 use the standard variables here, e.g.@: %Lu would lowercase the username,
17187 %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
17188 change the @samp{@@} into @samp{-AT-}. This translation is done after
17189 @samp{auth-username-translation} changes.
17190 Defaults to @samp{"%Lu"}.
17191 @end deftypevr
17192
17193 @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
17194 If you want to allow master users to log in by specifying the master
17195 username within the normal username string (i.e.@: not using SASL
17196 mechanism's support for it), you can specify the separator character
17197 here. The format is then <username><separator><master username>.
17198 UW-IMAP uses @samp{*} as the separator, so that could be a good
17199 choice.
17200 Defaults to @samp{""}.
17201 @end deftypevr
17202
17203 @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
17204 Username to use for users logging in with ANONYMOUS SASL
17205 mechanism.
17206 Defaults to @samp{"anonymous"}.
17207 @end deftypevr
17208
17209 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
17210 Maximum number of dovecot-auth worker processes. They're used to
17211 execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
17212 They're automatically created and destroyed as needed.
17213 Defaults to @samp{30}.
17214 @end deftypevr
17215
17216 @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
17217 Host name to use in GSSAPI principal names. The default is to use
17218 the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
17219 allow all keytab entries.
17220 Defaults to @samp{""}.
17221 @end deftypevr
17222
17223 @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
17224 Kerberos keytab to use for the GSSAPI mechanism. Will use the
17225 system default (usually @file{/etc/krb5.keytab}) if not specified. You may
17226 need to change the auth service to run as root to be able to read this
17227 file.
17228 Defaults to @samp{""}.
17229 @end deftypevr
17230
17231 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
17232 Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
17233 and @samp{ntlm-auth} helper.
17234 <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
17235 Defaults to @samp{#f}.
17236 @end deftypevr
17237
17238 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
17239 Path for Samba's @samp{ntlm-auth} helper binary.
17240 Defaults to @samp{"/usr/bin/ntlm_auth"}.
17241 @end deftypevr
17242
17243 @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
17244 Time to delay before replying to failed authentications.
17245 Defaults to @samp{"2 secs"}.
17246 @end deftypevr
17247
17248 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
17249 Require a valid SSL client certificate or the authentication
17250 fails.
17251 Defaults to @samp{#f}.
17252 @end deftypevr
17253
17254 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
17255 Take the username from client's SSL certificate, using
17256 @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
17257 CommonName.
17258 Defaults to @samp{#f}.
17259 @end deftypevr
17260
17261 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
17262 List of wanted authentication mechanisms. Supported mechanisms are:
17263 @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
17264 @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
17265 @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
17266 @samp{disable-plaintext-auth} setting.
17267 @end deftypevr
17268
17269 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
17270 List of IPs or hostnames to all director servers, including ourself.
17271 Ports can be specified as ip:port. The default port is the same as what
17272 director service's @samp{inet-listener} is using.
17273 Defaults to @samp{()}.
17274 @end deftypevr
17275
17276 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
17277 List of IPs or hostnames to all backend mail servers. Ranges are
17278 allowed too, like 10.0.0.10-10.0.0.30.
17279 Defaults to @samp{()}.
17280 @end deftypevr
17281
17282 @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
17283 How long to redirect users to a specific server after it no longer
17284 has any connections.
17285 Defaults to @samp{"15 min"}.
17286 @end deftypevr
17287
17288 @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
17289 How the username is translated before being hashed. Useful values
17290 include %Ln if user can log in with or without @@domain, %Ld if mailboxes
17291 are shared within domain.
17292 Defaults to @samp{"%Lu"}.
17293 @end deftypevr
17294
17295 @deftypevr {@code{dovecot-configuration} parameter} string log-path
17296 Log file to use for error messages. @samp{syslog} logs to syslog,
17297 @samp{/dev/stderr} logs to stderr.
17298 Defaults to @samp{"syslog"}.
17299 @end deftypevr
17300
17301 @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
17302 Log file to use for informational messages. Defaults to
17303 @samp{log-path}.
17304 Defaults to @samp{""}.
17305 @end deftypevr
17306
17307 @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
17308 Log file to use for debug messages. Defaults to
17309 @samp{info-log-path}.
17310 Defaults to @samp{""}.
17311 @end deftypevr
17312
17313 @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
17314 Syslog facility to use if you're logging to syslog. Usually if you
17315 don't want to use @samp{mail}, you'll use local0..local7. Also other
17316 standard facilities are supported.
17317 Defaults to @samp{"mail"}.
17318 @end deftypevr
17319
17320 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
17321 Log unsuccessful authentication attempts and the reasons why they
17322 failed.
17323 Defaults to @samp{#f}.
17324 @end deftypevr
17325
17326 @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
17327 In case of password mismatches, log the attempted password. Valid
17328 values are no, plain and sha1. sha1 can be useful for detecting brute
17329 force password attempts vs. user simply trying the same password over
17330 and over again. You can also truncate the value to n chars by appending
17331 ":n" (e.g.@: sha1:6).
17332 Defaults to @samp{"no"}.
17333 @end deftypevr
17334
17335 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
17336 Even more verbose logging for debugging purposes. Shows for example
17337 SQL queries.
17338 Defaults to @samp{#f}.
17339 @end deftypevr
17340
17341 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
17342 In case of password mismatches, log the passwords and used scheme so
17343 the problem can be debugged. Enabling this also enables
17344 @samp{auth-debug}.
17345 Defaults to @samp{#f}.
17346 @end deftypevr
17347
17348 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
17349 Enable mail process debugging. This can help you figure out why
17350 Dovecot isn't finding your mails.
17351 Defaults to @samp{#f}.
17352 @end deftypevr
17353
17354 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
17355 Show protocol level SSL errors.
17356 Defaults to @samp{#f}.
17357 @end deftypevr
17358
17359 @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
17360 Prefix for each line written to log file. % codes are in
17361 strftime(3) format.
17362 Defaults to @samp{"\"%b %d %H:%M:%S \""}.
17363 @end deftypevr
17364
17365 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
17366 List of elements we want to log. The elements which have a
17367 non-empty variable value are joined together to form a comma-separated
17368 string.
17369 @end deftypevr
17370
17371 @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
17372 Login log format. %s contains @samp{login-log-format-elements}
17373 string, %$ contains the data we want to log.
17374 Defaults to @samp{"%$: %s"}.
17375 @end deftypevr
17376
17377 @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
17378 Log prefix for mail processes. See doc/wiki/Variables.txt for list
17379 of possible variables you can use.
17380 Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
17381 @end deftypevr
17382
17383 @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
17384 Format to use for logging mail deliveries. You can use variables:
17385 @table @code
17386 @item %$
17387 Delivery status message (e.g.@: @samp{saved to INBOX})
17388 @item %m
17389 Message-ID
17390 @item %s
17391 Subject
17392 @item %f
17393 From address
17394 @item %p
17395 Physical size
17396 @item %w
17397 Virtual size.
17398 @end table
17399 Defaults to @samp{"msgid=%m: %$"}.
17400 @end deftypevr
17401
17402 @deftypevr {@code{dovecot-configuration} parameter} string mail-location
17403 Location for users' mailboxes. The default is empty, which means
17404 that Dovecot tries to find the mailboxes automatically. This won't work
17405 if the user doesn't yet have any mail, so you should explicitly tell
17406 Dovecot the full location.
17407
17408 If you're using mbox, giving a path to the INBOX
17409 file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
17410 where the other mailboxes are kept. This is called the @emph{root mail
17411 directory}, and it must be the first path given in the
17412 @samp{mail-location} setting.
17413
17414 There are a few special variables you can use, e.g.:
17415
17416 @table @samp
17417 @item %u
17418 username
17419 @item %n
17420 user part in user@@domain, same as %u if there's no domain
17421 @item %d
17422 domain part in user@@domain, empty if there's no domain
17423 @item %h
17424 home director
17425 @end table
17426
17427 See doc/wiki/Variables.txt for full list. Some examples:
17428 @table @samp
17429 @item maildir:~/Maildir
17430 @item mbox:~/mail:INBOX=/var/mail/%u
17431 @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
17432 @end table
17433 Defaults to @samp{""}.
17434 @end deftypevr
17435
17436 @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
17437 System user and group used to access mails. If you use multiple,
17438 userdb can override these by returning uid or gid fields. You can use
17439 either numbers or names. <doc/wiki/UserIds.txt>.
17440 Defaults to @samp{""}.
17441 @end deftypevr
17442
17443 @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
17444
17445 Defaults to @samp{""}.
17446 @end deftypevr
17447
17448 @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
17449 Group to enable temporarily for privileged operations. Currently
17450 this is used only with INBOX when either its initial creation or
17451 dotlocking fails. Typically this is set to @samp{"mail"} to give access to
17452 @file{/var/mail}.
17453 Defaults to @samp{""}.
17454 @end deftypevr
17455
17456 @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
17457 Grant access to these supplementary groups for mail processes.
17458 Typically these are used to set up access to shared mailboxes. Note
17459 that it may be dangerous to set these if users can create symlinks
17460 (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
17461 could allow a user to delete others' mailboxes, or @code{ln -s
17462 /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
17463 @samp{""}.
17464 @end deftypevr
17465
17466 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
17467 Allow full file system access to clients. There's no access checks
17468 other than what the operating system does for the active UID/GID. It
17469 works with both maildir and mboxes, allowing you to prefix mailboxes
17470 names with e.g.@: @file{/path/} or @file{~user/}.
17471 Defaults to @samp{#f}.
17472 @end deftypevr
17473
17474 @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
17475 Don't use @code{mmap()} at all. This is required if you store indexes to
17476 shared file systems (NFS or clustered file system).
17477 Defaults to @samp{#f}.
17478 @end deftypevr
17479
17480 @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
17481 Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
17482 supports @samp{O_EXCL} since version 3, so this should be safe to use
17483 nowadays by default.
17484 Defaults to @samp{#t}.
17485 @end deftypevr
17486
17487 @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
17488 When to use fsync() or fdatasync() calls:
17489 @table @code
17490 @item optimized
17491 Whenever necessary to avoid losing important data
17492 @item always
17493 Useful with e.g.@: NFS when @code{write()}s are delayed
17494 @item never
17495 Never use it (best performance, but crashes can lose data).
17496 @end table
17497 Defaults to @samp{"optimized"}.
17498 @end deftypevr
17499
17500 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
17501 Mail storage exists in NFS. Set this to yes to make Dovecot flush
17502 NFS caches whenever needed. If you're using only a single mail server
17503 this isn't needed.
17504 Defaults to @samp{#f}.
17505 @end deftypevr
17506
17507 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
17508 Mail index files also exist in NFS. Setting this to yes requires
17509 @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
17510 Defaults to @samp{#f}.
17511 @end deftypevr
17512
17513 @deftypevr {@code{dovecot-configuration} parameter} string lock-method
17514 Locking method for index files. Alternatives are fcntl, flock and
17515 dotlock. Dotlocking uses some tricks which may create more disk I/O
17516 than other locking methods. NFS users: flock doesn't work, remember to
17517 change @samp{mmap-disable}.
17518 Defaults to @samp{"fcntl"}.
17519 @end deftypevr
17520
17521 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
17522 Directory in which LDA/LMTP temporarily stores incoming mails >128
17523 kB.
17524 Defaults to @samp{"/tmp"}.
17525 @end deftypevr
17526
17527 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
17528 Valid UID range for users. This is mostly to make sure that users can't
17529 log in as daemons or other system users. Note that denying root logins is
17530 hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
17531 is set to 0.
17532 Defaults to @samp{500}.
17533 @end deftypevr
17534
17535 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
17536
17537 Defaults to @samp{0}.
17538 @end deftypevr
17539
17540 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
17541 Valid GID range for users. Users having non-valid GID as primary group ID
17542 aren't allowed to log in. If user belongs to supplementary groups with
17543 non-valid GIDs, those groups are not set.
17544 Defaults to @samp{1}.
17545 @end deftypevr
17546
17547 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
17548
17549 Defaults to @samp{0}.
17550 @end deftypevr
17551
17552 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
17553 Maximum allowed length for mail keyword name. It's only forced when
17554 trying to create new keywords.
17555 Defaults to @samp{50}.
17556 @end deftypevr
17557
17558 @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
17559 List of directories under which chrooting is allowed for mail
17560 processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
17561 too). This setting doesn't affect @samp{login-chroot}
17562 @samp{mail-chroot} or auth chroot settings. If this setting is empty,
17563 @samp{/./} in home dirs are ignored. WARNING: Never add directories here
17564 which local users can modify, that may lead to root exploit. Usually
17565 this should be done only if you don't allow shell access for users.
17566 <doc/wiki/Chrooting.txt>.
17567 Defaults to @samp{()}.
17568 @end deftypevr
17569
17570 @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
17571 Default chroot directory for mail processes. This can be overridden
17572 for specific users in user database by giving @samp{/./} in user's home
17573 directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
17574 there is no real need to do chrooting, Dovecot doesn't allow users to
17575 access files outside their mail directory anyway. If your home
17576 directories are prefixed with the chroot directory, append @samp{/.} to
17577 @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
17578 Defaults to @samp{""}.
17579 @end deftypevr
17580
17581 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
17582 UNIX socket path to master authentication server to find users.
17583 This is used by imap (for shared users) and lda.
17584 Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
17585 @end deftypevr
17586
17587 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
17588 Directory where to look up mail plugins.
17589 Defaults to @samp{"/usr/lib/dovecot"}.
17590 @end deftypevr
17591
17592 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
17593 List of plugins to load for all services. Plugins specific to IMAP,
17594 LDA, etc.@: are added to this list in their own .conf files.
17595 Defaults to @samp{()}.
17596 @end deftypevr
17597
17598 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
17599 The minimum number of mails in a mailbox before updates are done to
17600 cache file. This allows optimizing Dovecot's behavior to do less disk
17601 writes at the cost of more disk reads.
17602 Defaults to @samp{0}.
17603 @end deftypevr
17604
17605 @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
17606 When IDLE command is running, mailbox is checked once in a while to
17607 see if there are any new mails or other changes. This setting defines
17608 the minimum time to wait between those checks. Dovecot can also use
17609 dnotify, inotify and kqueue to find out immediately when changes
17610 occur.
17611 Defaults to @samp{"30 secs"}.
17612 @end deftypevr
17613
17614 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
17615 Save mails with CR+LF instead of plain LF. This makes sending those
17616 mails take less CPU, especially with sendfile() syscall with Linux and
17617 FreeBSD. But it also creates a bit more disk I/O which may just make it
17618 slower. Also note that if other software reads the mboxes/maildirs,
17619 they may handle the extra CRs wrong and cause problems.
17620 Defaults to @samp{#f}.
17621 @end deftypevr
17622
17623 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
17624 By default LIST command returns all entries in maildir beginning
17625 with a dot. Enabling this option makes Dovecot return only entries
17626 which are directories. This is done by stat()ing each entry, so it
17627 causes more disk I/O.
17628 (For systems setting struct @samp{dirent->d_type} this check is free
17629 and it's done always regardless of this setting).
17630 Defaults to @samp{#f}.
17631 @end deftypevr
17632
17633 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
17634 When copying a message, do it with hard links whenever possible.
17635 This makes the performance much better, and it's unlikely to have any
17636 side effects.
17637 Defaults to @samp{#t}.
17638 @end deftypevr
17639
17640 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
17641 Assume Dovecot is the only MUA accessing Maildir: Scan cur/
17642 directory only when its mtime changes unexpectedly or when we can't find
17643 the mail otherwise.
17644 Defaults to @samp{#f}.
17645 @end deftypevr
17646
17647 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
17648 Which locking methods to use for locking mbox. There are four
17649 available:
17650
17651 @table @code
17652 @item dotlock
17653 Create <mailbox>.lock file. This is the oldest and most NFS-safe
17654 solution. If you want to use /var/mail/ like directory, the users will
17655 need write access to that directory.
17656 @item dotlock-try
17657 Same as dotlock, but if it fails because of permissions or because there
17658 isn't enough disk space, just skip it.
17659 @item fcntl
17660 Use this if possible. Works with NFS too if lockd is used.
17661 @item flock
17662 May not exist in all systems. Doesn't work with NFS.
17663 @item lockf
17664 May not exist in all systems. Doesn't work with NFS.
17665 @end table
17666
17667 You can use multiple locking methods; if you do the order they're declared
17668 in is important to avoid deadlocks if other MTAs/MUAs are using multiple
17669 locking methods as well. Some operating systems don't allow using some of
17670 them simultaneously.
17671 @end deftypevr
17672
17673 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
17674
17675 @end deftypevr
17676
17677 @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
17678 Maximum time to wait for lock (all of them) before aborting.
17679 Defaults to @samp{"5 mins"}.
17680 @end deftypevr
17681
17682 @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
17683 If dotlock exists but the mailbox isn't modified in any way,
17684 override the lock file after this much time.
17685 Defaults to @samp{"2 mins"}.
17686 @end deftypevr
17687
17688 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
17689 When mbox changes unexpectedly we have to fully read it to find out
17690 what changed. If the mbox is large this can take a long time. Since
17691 the change is usually just a newly appended mail, it'd be faster to
17692 simply read the new mails. If this setting is enabled, Dovecot does
17693 this but still safely fallbacks to re-reading the whole mbox file
17694 whenever something in mbox isn't how it's expected to be. The only real
17695 downside to this setting is that if some other MUA changes message
17696 flags, Dovecot doesn't notice it immediately. Note that a full sync is
17697 done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
17698 Defaults to @samp{#t}.
17699 @end deftypevr
17700
17701 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
17702 Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
17703 EXAMINE, EXPUNGE or CHECK commands. If this is set,
17704 @samp{mbox-dirty-syncs} is ignored.
17705 Defaults to @samp{#f}.
17706 @end deftypevr
17707
17708 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
17709 Delay writing mbox headers until doing a full write sync (EXPUNGE
17710 and CHECK commands and when closing the mailbox). This is especially
17711 useful for POP3 where clients often delete all mails. The downside is
17712 that our changes aren't immediately visible to other MUAs.
17713 Defaults to @samp{#t}.
17714 @end deftypevr
17715
17716 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
17717 If mbox size is smaller than this (e.g.@: 100k), don't write index
17718 files. If an index file already exists it's still read, just not
17719 updated.
17720 Defaults to @samp{0}.
17721 @end deftypevr
17722
17723 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
17724 Maximum dbox file size until it's rotated.
17725 Defaults to @samp{10000000}.
17726 @end deftypevr
17727
17728 @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
17729 Maximum dbox file age until it's rotated. Typically in days. Day
17730 begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
17731 disabled.
17732 Defaults to @samp{"1d"}.
17733 @end deftypevr
17734
17735 @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
17736 When creating new mdbox files, immediately preallocate their size to
17737 @samp{mdbox-rotate-size}. This setting currently works only in Linux
17738 with some file systems (ext4, xfs).
17739 Defaults to @samp{#f}.
17740 @end deftypevr
17741
17742 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
17743 sdbox and mdbox support saving mail attachments to external files,
17744 which also allows single instance storage for them. Other backends
17745 don't support this for now.
17746
17747 WARNING: This feature hasn't been tested much yet. Use at your own risk.
17748
17749 Directory root where to store mail attachments. Disabled, if empty.
17750 Defaults to @samp{""}.
17751 @end deftypevr
17752
17753 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
17754 Attachments smaller than this aren't saved externally. It's also
17755 possible to write a plugin to disable saving specific attachments
17756 externally.
17757 Defaults to @samp{128000}.
17758 @end deftypevr
17759
17760 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
17761 File system backend to use for saving attachments:
17762 @table @code
17763 @item posix
17764 No SiS done by Dovecot (but this might help FS's own deduplication)
17765 @item sis posix
17766 SiS with immediate byte-by-byte comparison during saving
17767 @item sis-queue posix
17768 SiS with delayed comparison and deduplication.
17769 @end table
17770 Defaults to @samp{"sis posix"}.
17771 @end deftypevr
17772
17773 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
17774 Hash format to use in attachment filenames. You can add any text and
17775 variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
17776 @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
17777 truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
17778 Defaults to @samp{"%@{sha1@}"}.
17779 @end deftypevr
17780
17781 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
17782
17783 Defaults to @samp{100}.
17784 @end deftypevr
17785
17786 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
17787
17788 Defaults to @samp{1000}.
17789 @end deftypevr
17790
17791 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
17792 Default VSZ (virtual memory size) limit for service processes.
17793 This is mainly intended to catch and kill processes that leak memory
17794 before they eat up everything.
17795 Defaults to @samp{256000000}.
17796 @end deftypevr
17797
17798 @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
17799 Login user is internally used by login processes. This is the most
17800 untrusted user in Dovecot system. It shouldn't have access to anything
17801 at all.
17802 Defaults to @samp{"dovenull"}.
17803 @end deftypevr
17804
17805 @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
17806 Internal user is used by unprivileged processes. It should be
17807 separate from login user, so that login processes can't disturb other
17808 processes.
17809 Defaults to @samp{"dovecot"}.
17810 @end deftypevr
17811
17812 @deftypevr {@code{dovecot-configuration} parameter} string ssl?
17813 SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
17814 Defaults to @samp{"required"}.
17815 @end deftypevr
17816
17817 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
17818 PEM encoded X.509 SSL/TLS certificate (public key).
17819 Defaults to @samp{"</etc/dovecot/default.pem"}.
17820 @end deftypevr
17821
17822 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
17823 PEM encoded SSL/TLS private key. The key is opened before
17824 dropping root privileges, so keep the key file unreadable by anyone but
17825 root.
17826 Defaults to @samp{"</etc/dovecot/private/default.pem"}.
17827 @end deftypevr
17828
17829 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
17830 If key file is password protected, give the password here.
17831 Alternatively give it when starting dovecot with -p parameter. Since
17832 this file is often world-readable, you may want to place this setting
17833 instead to a different.
17834 Defaults to @samp{""}.
17835 @end deftypevr
17836
17837 @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
17838 PEM encoded trusted certificate authority. Set this only if you
17839 intend to use @samp{ssl-verify-client-cert? #t}. The file should
17840 contain the CA certificate(s) followed by the matching
17841 CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
17842 Defaults to @samp{""}.
17843 @end deftypevr
17844
17845 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
17846 Require that CRL check succeeds for client certificates.
17847 Defaults to @samp{#t}.
17848 @end deftypevr
17849
17850 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
17851 Request client to send a certificate. If you also want to require
17852 it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
17853 Defaults to @samp{#f}.
17854 @end deftypevr
17855
17856 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
17857 Which field from certificate to use for username. commonName and
17858 x500UniqueIdentifier are the usual choices. You'll also need to set
17859 @samp{auth-ssl-username-from-cert? #t}.
17860 Defaults to @samp{"commonName"}.
17861 @end deftypevr
17862
17863 @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
17864 Minimum SSL protocol version to accept.
17865 Defaults to @samp{"TLSv1"}.
17866 @end deftypevr
17867
17868 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
17869 SSL ciphers to use.
17870 Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
17871 @end deftypevr
17872
17873 @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
17874 SSL crypto device to use, for valid values run "openssl engine".
17875 Defaults to @samp{""}.
17876 @end deftypevr
17877
17878 @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
17879 Address to use when sending rejection mails.
17880 %d expands to recipient domain.
17881 Defaults to @samp{"postmaster@@%d"}.
17882 @end deftypevr
17883
17884 @deftypevr {@code{dovecot-configuration} parameter} string hostname
17885 Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
17886 and in LMTP replies. Default is the system's real hostname@@domain.
17887 Defaults to @samp{""}.
17888 @end deftypevr
17889
17890 @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
17891 If user is over quota, return with temporary failure instead of
17892 bouncing the mail.
17893 Defaults to @samp{#f}.
17894 @end deftypevr
17895
17896 @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
17897 Binary to use for sending mails.
17898 Defaults to @samp{"/usr/sbin/sendmail"}.
17899 @end deftypevr
17900
17901 @deftypevr {@code{dovecot-configuration} parameter} string submission-host
17902 If non-empty, send mails via this SMTP host[:port] instead of
17903 sendmail.
17904 Defaults to @samp{""}.
17905 @end deftypevr
17906
17907 @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
17908 Subject: header to use for rejection mails. You can use the same
17909 variables as for @samp{rejection-reason} below.
17910 Defaults to @samp{"Rejected: %s"}.
17911 @end deftypevr
17912
17913 @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
17914 Human readable error message for rejection mails. You can use
17915 variables:
17916
17917 @table @code
17918 @item %n
17919 CRLF
17920 @item %r
17921 reason
17922 @item %s
17923 original subject
17924 @item %t
17925 recipient
17926 @end table
17927 Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
17928 @end deftypevr
17929
17930 @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
17931 Delimiter character between local-part and detail in email
17932 address.
17933 Defaults to @samp{"+"}.
17934 @end deftypevr
17935
17936 @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
17937 Header where the original recipient address (SMTP's RCPT TO:
17938 address) is taken from if not available elsewhere. With dovecot-lda -a
17939 parameter overrides this. A commonly used header for this is
17940 X-Original-To.
17941 Defaults to @samp{""}.
17942 @end deftypevr
17943
17944 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
17945 Should saving a mail to a nonexistent mailbox automatically create
17946 it?.
17947 Defaults to @samp{#f}.
17948 @end deftypevr
17949
17950 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
17951 Should automatically created mailboxes be also automatically
17952 subscribed?.
17953 Defaults to @samp{#f}.
17954 @end deftypevr
17955
17956 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
17957 Maximum IMAP command line length. Some clients generate very long
17958 command lines with huge mailboxes, so you may need to raise this if you
17959 get "Too long argument" or "IMAP command line too large" errors
17960 often.
17961 Defaults to @samp{64000}.
17962 @end deftypevr
17963
17964 @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
17965 IMAP logout format string:
17966 @table @code
17967 @item %i
17968 total number of bytes read from client
17969 @item %o
17970 total number of bytes sent to client.
17971 @end table
17972 See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
17973 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@}"}.
17974 @end deftypevr
17975
17976 @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
17977 Override the IMAP CAPABILITY response. If the value begins with '+',
17978 add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
17979 Defaults to @samp{""}.
17980 @end deftypevr
17981
17982 @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
17983 How long to wait between "OK Still here" notifications when client
17984 is IDLEing.
17985 Defaults to @samp{"2 mins"}.
17986 @end deftypevr
17987
17988 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
17989 ID field names and values to send to clients. Using * as the value
17990 makes Dovecot use the default value. The following fields have default
17991 values currently: name, version, os, os-version, support-url,
17992 support-email.
17993 Defaults to @samp{""}.
17994 @end deftypevr
17995
17996 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
17997 ID fields sent by client to log. * means everything.
17998 Defaults to @samp{""}.
17999 @end deftypevr
18000
18001 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
18002 Workarounds for various client bugs:
18003
18004 @table @code
18005 @item delay-newmail
18006 Send EXISTS/RECENT new mail notifications only when replying to NOOP and
18007 CHECK commands. Some clients ignore them otherwise, for example OSX
18008 Mail (<v2.1). Outlook Express breaks more badly though, without this it
18009 may show user "Message no longer in server" errors. Note that OE6
18010 still breaks even with this workaround if synchronization is set to
18011 "Headers Only".
18012
18013 @item tb-extra-mailbox-sep
18014 Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
18015 adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
18016 ignore the extra @samp{/} instead of treating it as invalid mailbox name.
18017
18018 @item tb-lsub-flags
18019 Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
18020 This makes Thunderbird realize they aren't selectable and show them
18021 greyed out, instead of only later giving "not selectable" popup error.
18022 @end table
18023 Defaults to @samp{()}.
18024 @end deftypevr
18025
18026 @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
18027 Host allowed in URLAUTH URLs sent by client. "*" allows all.
18028 Defaults to @samp{""}.
18029 @end deftypevr
18030
18031
18032 Whew! Lots of configuration options. The nice thing about it though is
18033 that Guix has a complete interface to Dovecot's configuration
18034 language. This allows not only a nice way to declare configurations,
18035 but also offers reflective capabilities as well: users can write code to
18036 inspect and transform configurations from within Scheme.
18037
18038 However, it could be that you just want to get a @code{dovecot.conf} up
18039 and running. In that case, you can pass an
18040 @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
18041 @code{dovecot-service}. As its name indicates, an opaque configuration
18042 does not have easy reflective capabilities.
18043
18044 Available @code{opaque-dovecot-configuration} fields are:
18045
18046 @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
18047 The dovecot package.
18048 @end deftypevr
18049
18050 @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
18051 The contents of the @code{dovecot.conf}, as a string.
18052 @end deftypevr
18053
18054 For example, if your @code{dovecot.conf} is just the empty string, you
18055 could instantiate a dovecot service like this:
18056
18057 @lisp
18058 (dovecot-service #:config
18059 (opaque-dovecot-configuration
18060 (string "")))
18061 @end lisp
18062
18063 @subsubheading OpenSMTPD Service
18064
18065 @deffn {Scheme Variable} opensmtpd-service-type
18066 This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
18067 service, whose value should be an @code{opensmtpd-configuration} object
18068 as in this example:
18069
18070 @lisp
18071 (service opensmtpd-service-type
18072 (opensmtpd-configuration
18073 (config-file (local-file "./my-smtpd.conf"))))
18074 @end lisp
18075 @end deffn
18076
18077 @deftp {Data Type} opensmtpd-configuration
18078 Data type representing the configuration of opensmtpd.
18079
18080 @table @asis
18081 @item @code{package} (default: @var{opensmtpd})
18082 Package object of the OpenSMTPD SMTP server.
18083
18084 @item @code{config-file} (default: @code{%default-opensmtpd-file})
18085 File-like object of the OpenSMTPD configuration file to use. By default
18086 it listens on the loopback network interface, and allows for mail from
18087 users and daemons on the local machine, as well as permitting email to
18088 remote servers. Run @command{man smtpd.conf} for more information.
18089
18090 @end table
18091 @end deftp
18092
18093 @subsubheading Exim Service
18094
18095 @cindex mail transfer agent (MTA)
18096 @cindex MTA (mail transfer agent)
18097 @cindex SMTP
18098
18099 @deffn {Scheme Variable} exim-service-type
18100 This is the type of the @uref{https://exim.org, Exim} mail transfer
18101 agent (MTA), whose value should be an @code{exim-configuration} object
18102 as in this example:
18103
18104 @lisp
18105 (service exim-service-type
18106 (exim-configuration
18107 (config-file (local-file "./my-exim.conf"))))
18108 @end lisp
18109 @end deffn
18110
18111 In order to use an @code{exim-service-type} service you must also have a
18112 @code{mail-aliases-service-type} service present in your
18113 @code{operating-system} (even if it has no aliases).
18114
18115 @deftp {Data Type} exim-configuration
18116 Data type representing the configuration of exim.
18117
18118 @table @asis
18119 @item @code{package} (default: @var{exim})
18120 Package object of the Exim server.
18121
18122 @item @code{config-file} (default: @code{#f})
18123 File-like object of the Exim configuration file to use. If its value is
18124 @code{#f} then use the default configuration file from the package
18125 provided in @code{package}. The resulting configuration file is loaded
18126 after setting the @code{exim_user} and @code{exim_group} configuration
18127 variables.
18128
18129 @end table
18130 @end deftp
18131
18132 @subsubheading Getmail service
18133
18134 @cindex IMAP
18135 @cindex POP
18136
18137 @deffn {Scheme Variable} getmail-service-type
18138 This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
18139 mail retriever, whose value should be an @code{getmail-configuration}.
18140 @end deffn
18141
18142 Available @code{getmail-configuration} fields are:
18143
18144 @deftypevr {@code{getmail-configuration} parameter} symbol name
18145 A symbol to identify the getmail service.
18146
18147 Defaults to @samp{"unset"}.
18148
18149 @end deftypevr
18150
18151 @deftypevr {@code{getmail-configuration} parameter} package package
18152 The getmail package to use.
18153
18154 @end deftypevr
18155
18156 @deftypevr {@code{getmail-configuration} parameter} string user
18157 The user to run getmail as.
18158
18159 Defaults to @samp{"getmail"}.
18160
18161 @end deftypevr
18162
18163 @deftypevr {@code{getmail-configuration} parameter} string group
18164 The group to run getmail as.
18165
18166 Defaults to @samp{"getmail"}.
18167
18168 @end deftypevr
18169
18170 @deftypevr {@code{getmail-configuration} parameter} string directory
18171 The getmail directory to use.
18172
18173 Defaults to @samp{"/var/lib/getmail/default"}.
18174
18175 @end deftypevr
18176
18177 @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
18178 The getmail configuration file to use.
18179
18180 Available @code{getmail-configuration-file} fields are:
18181
18182 @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
18183 What mail account to retrieve mail from, and how to access that account.
18184
18185 Available @code{getmail-retriever-configuration} fields are:
18186
18187 @deftypevr {@code{getmail-retriever-configuration} parameter} string type
18188 The type of mail retriever to use. Valid values include @samp{passwd}
18189 and @samp{static}.
18190
18191 Defaults to @samp{"SimpleIMAPSSLRetriever"}.
18192
18193 @end deftypevr
18194
18195 @deftypevr {@code{getmail-retriever-configuration} parameter} string server
18196 Username to login to the mail server with.
18197
18198 Defaults to @samp{unset}.
18199
18200 @end deftypevr
18201
18202 @deftypevr {@code{getmail-retriever-configuration} parameter} string username
18203 Username to login to the mail server with.
18204
18205 Defaults to @samp{unset}.
18206
18207 @end deftypevr
18208
18209 @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
18210 Port number to connect to.
18211
18212 Defaults to @samp{#f}.
18213
18214 @end deftypevr
18215
18216 @deftypevr {@code{getmail-retriever-configuration} parameter} string password
18217 Override fields from passwd.
18218
18219 Defaults to @samp{""}.
18220
18221 @end deftypevr
18222
18223 @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
18224 Override fields from passwd.
18225
18226 Defaults to @samp{()}.
18227
18228 @end deftypevr
18229
18230 @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
18231 PEM-formatted key file to use for the TLS negotiation.
18232
18233 Defaults to @samp{""}.
18234
18235 @end deftypevr
18236
18237 @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
18238 PEM-formatted certificate file to use for the TLS negotiation.
18239
18240 Defaults to @samp{""}.
18241
18242 @end deftypevr
18243
18244 @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
18245 CA certificates to use.
18246
18247 Defaults to @samp{""}.
18248
18249 @end deftypevr
18250
18251 @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
18252 Extra retriever parameters.
18253
18254 Defaults to @samp{()}.
18255
18256 @end deftypevr
18257
18258 @end deftypevr
18259
18260 @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
18261 What to do with retrieved messages.
18262
18263 Available @code{getmail-destination-configuration} fields are:
18264
18265 @deftypevr {@code{getmail-destination-configuration} parameter} string type
18266 The type of mail destination. Valid values include @samp{Maildir},
18267 @samp{Mboxrd} and @samp{MDA_external}.
18268
18269 Defaults to @samp{unset}.
18270
18271 @end deftypevr
18272
18273 @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
18274 The path option for the mail destination. The behaviour depends on the
18275 chosen type.
18276
18277 Defaults to @samp{""}.
18278
18279 @end deftypevr
18280
18281 @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
18282 Extra destination parameters
18283
18284 Defaults to @samp{()}.
18285
18286 @end deftypevr
18287
18288 @end deftypevr
18289
18290 @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
18291 Configure getmail.
18292
18293 Available @code{getmail-options-configuration} fields are:
18294
18295 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
18296 If set to @samp{0}, getmail will only print warnings and errors. A
18297 value of @samp{1} means that messages will be printed about retrieving
18298 and deleting messages. If set to @samp{2}, getmail will print messages
18299 about each of it's actions.
18300
18301 Defaults to @samp{1}.
18302
18303 @end deftypevr
18304
18305 @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
18306 If true, getmail will retrieve all available messages. Otherwise it
18307 will only retrieve messages it hasn't seen previously.
18308
18309 Defaults to @samp{#t}.
18310
18311 @end deftypevr
18312
18313 @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
18314 If set to true, messages will be deleted from the server after
18315 retrieving and successfully delivering them. Otherwise, messages will
18316 be left on the server.
18317
18318 Defaults to @samp{#f}.
18319
18320 @end deftypevr
18321
18322 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
18323 Getmail will delete messages this number of days after seeing them, if
18324 they have been delivered. This means messages will be left on the
18325 server this number of days after delivering them. A value of @samp{0}
18326 disabled this feature.
18327
18328 Defaults to @samp{0}.
18329
18330 @end deftypevr
18331
18332 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
18333 Delete messages larger than this of bytes after retrieving them, even if
18334 the delete and delete-after options are disabled. A value of @samp{0}
18335 disables this feature.
18336
18337 Defaults to @samp{0}.
18338
18339 @end deftypevr
18340
18341 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
18342 Retrieve messages totalling up to this number of bytes before closing
18343 the session with the server. A value of @samp{0} disables this feature.
18344
18345 Defaults to @samp{0}.
18346
18347 @end deftypevr
18348
18349 @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
18350 Don't retrieve messages larger than this number of bytes. A value of
18351 @samp{0} disables this feature.
18352
18353 Defaults to @samp{0}.
18354
18355 @end deftypevr
18356
18357 @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
18358 If true, getmail will add a Delivered-To header to messages.
18359
18360 Defaults to @samp{#t}.
18361
18362 @end deftypevr
18363
18364 @deftypevr {@code{getmail-options-configuration} parameter} boolean received
18365 If set, getmail adds a Received header to the messages.
18366
18367 Defaults to @samp{#t}.
18368
18369 @end deftypevr
18370
18371 @deftypevr {@code{getmail-options-configuration} parameter} string message-log
18372 Getmail will record a log of its actions to the named file. A value of
18373 @samp{""} disables this feature.
18374
18375 Defaults to @samp{""}.
18376
18377 @end deftypevr
18378
18379 @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
18380 If true, getmail will record a log of its actions using the system
18381 logger.
18382
18383 Defaults to @samp{#f}.
18384
18385 @end deftypevr
18386
18387 @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
18388 If true, getmail will log information about messages not retrieved and
18389 the reason for not retrieving them, as well as starting and ending
18390 information lines.
18391
18392 Defaults to @samp{#f}.
18393
18394 @end deftypevr
18395
18396 @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
18397 Extra options to include.
18398
18399 Defaults to @samp{()}.
18400
18401 @end deftypevr
18402
18403 @end deftypevr
18404
18405 @end deftypevr
18406
18407 @deftypevr {@code{getmail-configuration} parameter} list idle
18408 A list of mailboxes that getmail should wait on the server for new mail
18409 notifications. This depends on the server supporting the IDLE
18410 extension.
18411
18412 Defaults to @samp{()}.
18413
18414 @end deftypevr
18415
18416 @deftypevr {@code{getmail-configuration} parameter} list environment-variables
18417 Environment variables to set for getmail.
18418
18419 Defaults to @samp{()}.
18420
18421 @end deftypevr
18422
18423 @subsubheading Mail Aliases Service
18424
18425 @cindex email aliases
18426 @cindex aliases, for email addresses
18427
18428 @deffn {Scheme Variable} mail-aliases-service-type
18429 This is the type of the service which provides @code{/etc/aliases},
18430 specifying how to deliver mail to users on this system.
18431
18432 @lisp
18433 (service mail-aliases-service-type
18434 '(("postmaster" "bob")
18435 ("bob" "bob@@example.com" "bob@@example2.com")))
18436 @end lisp
18437 @end deffn
18438
18439 The configuration for a @code{mail-aliases-service-type} service is an
18440 association list denoting how to deliver mail that comes to this
18441 system. Each entry is of the form @code{(alias addresses ...)}, with
18442 @code{alias} specifying the local alias and @code{addresses} specifying
18443 where to deliver this user's mail.
18444
18445 The aliases aren't required to exist as users on the local system. In
18446 the above example, there doesn't need to be a @code{postmaster} entry in
18447 the @code{operating-system}'s @code{user-accounts} in order to deliver
18448 the @code{postmaster} mail to @code{bob} (which subsequently would
18449 deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
18450
18451 @subsubheading GNU Mailutils IMAP4 Daemon
18452 @cindex GNU Mailutils IMAP4 Daemon
18453
18454 @deffn {Scheme Variable} imap4d-service-type
18455 This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
18456 mailutils, GNU Mailutils Manual}), whose value should be an
18457 @code{imap4d-configuration} object as in this example:
18458
18459 @lisp
18460 (service imap4d-service-type
18461 (imap4d-configuration
18462 (config-file (local-file "imap4d.conf"))))
18463 @end lisp
18464 @end deffn
18465
18466 @deftp {Data Type} imap4d-configuration
18467 Data type representing the configuration of @command{imap4d}.
18468
18469 @table @asis
18470 @item @code{package} (default: @code{mailutils})
18471 The package that provides @command{imap4d}.
18472
18473 @item @code{config-file} (default: @code{%default-imap4d-config-file})
18474 File-like object of the configuration file to use, by default it will listen
18475 on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
18476 Mailutils Manual}, for details.
18477
18478 @end table
18479 @end deftp
18480
18481 @node Messaging Services
18482 @subsection Messaging Services
18483
18484 @cindex messaging
18485 @cindex jabber
18486 @cindex XMPP
18487 The @code{(gnu services messaging)} module provides Guix service
18488 definitions for messaging services: currently only Prosody is supported.
18489
18490 @subsubheading Prosody Service
18491
18492 @deffn {Scheme Variable} prosody-service-type
18493 This is the type for the @uref{https://prosody.im, Prosody XMPP
18494 communication server}. Its value must be a @code{prosody-configuration}
18495 record as in this example:
18496
18497 @lisp
18498 (service prosody-service-type
18499 (prosody-configuration
18500 (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
18501 (int-components
18502 (list
18503 (int-component-configuration
18504 (hostname "conference.example.net")
18505 (plugin "muc")
18506 (mod-muc (mod-muc-configuration)))))
18507 (virtualhosts
18508 (list
18509 (virtualhost-configuration
18510 (domain "example.net"))))))
18511 @end lisp
18512
18513 See below for details about @code{prosody-configuration}.
18514
18515 @end deffn
18516
18517 By default, Prosody does not need much configuration. Only one
18518 @code{virtualhosts} field is needed: it specifies the domain you wish
18519 Prosody to serve.
18520
18521 You can perform various sanity checks on the generated configuration
18522 with the @code{prosodyctl check} command.
18523
18524 Prosodyctl will also help you to import certificates from the
18525 @code{letsencrypt} directory so that the @code{prosody} user can access
18526 them. See @url{https://prosody.im/doc/letsencrypt}.
18527
18528 @example
18529 prosodyctl --root cert import /etc/letsencrypt/live
18530 @end example
18531
18532 The available configuration parameters follow. Each parameter
18533 definition is preceded by its type; for example, @samp{string-list foo}
18534 indicates that the @code{foo} parameter should be specified as a list of
18535 strings. Types starting with @code{maybe-} denote parameters that won't
18536 show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
18537
18538 There is also a way to specify the configuration as a string, if you
18539 have an old @code{prosody.cfg.lua} file that you want to port over from
18540 some other system; see the end for more details.
18541
18542 The @code{file-object} type designates either a file-like object
18543 (@pxref{G-Expressions, file-like objects}) or a file name.
18544
18545 @c The following documentation was initially generated by
18546 @c (generate-documentation) in (gnu services messaging). Manually maintained
18547 @c documentation is better, so we shouldn't hesitate to edit below as
18548 @c needed. However if the change you want to make to this documentation
18549 @c can be done in an automated way, it's probably easier to change
18550 @c (generate-documentation) than to make it below and have to deal with
18551 @c the churn as Prosody updates.
18552
18553 Available @code{prosody-configuration} fields are:
18554
18555 @deftypevr {@code{prosody-configuration} parameter} package prosody
18556 The Prosody package.
18557 @end deftypevr
18558
18559 @deftypevr {@code{prosody-configuration} parameter} file-name data-path
18560 Location of the Prosody data storage directory. See
18561 @url{https://prosody.im/doc/configure}.
18562 Defaults to @samp{"/var/lib/prosody"}.
18563 @end deftypevr
18564
18565 @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
18566 Additional plugin directories. They are searched in all the specified
18567 paths in order. See @url{https://prosody.im/doc/plugins_directory}.
18568 Defaults to @samp{()}.
18569 @end deftypevr
18570
18571 @deftypevr {@code{prosody-configuration} parameter} file-name certificates
18572 Every virtual host and component needs a certificate so that clients and
18573 servers can securely verify its identity. Prosody will automatically load
18574 certificates/keys from the directory specified here.
18575 Defaults to @samp{"/etc/prosody/certs"}.
18576 @end deftypevr
18577
18578 @deftypevr {@code{prosody-configuration} parameter} string-list admins
18579 This is a list of accounts that are admins for the server. Note that you
18580 must create the accounts separately. See @url{https://prosody.im/doc/admins} and
18581 @url{https://prosody.im/doc/creating_accounts}.
18582 Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
18583 Defaults to @samp{()}.
18584 @end deftypevr
18585
18586 @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
18587 Enable use of libevent for better performance under high load. See
18588 @url{https://prosody.im/doc/libevent}.
18589 Defaults to @samp{#f}.
18590 @end deftypevr
18591
18592 @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
18593 This is the list of modules Prosody will load on startup. It looks for
18594 @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
18595 Documentation on modules can be found at:
18596 @url{https://prosody.im/doc/modules}.
18597 Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
18598 @end deftypevr
18599
18600 @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
18601 @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
18602 should you want to disable them then add them to this list.
18603 Defaults to @samp{()}.
18604 @end deftypevr
18605
18606 @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
18607 Path to a text file where the shared groups are defined. If this path is
18608 empty then @samp{mod_groups} does nothing. See
18609 @url{https://prosody.im/doc/modules/mod_groups}.
18610 Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
18611 @end deftypevr
18612
18613 @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
18614 Disable account creation by default, for security. See
18615 @url{https://prosody.im/doc/creating_accounts}.
18616 Defaults to @samp{#f}.
18617 @end deftypevr
18618
18619 @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
18620 These are the SSL/TLS-related settings. Most of them are disabled so to
18621 use Prosody's defaults. If you do not completely understand these options, do
18622 not add them to your config, it is easy to lower the security of your server
18623 using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
18624
18625 Available @code{ssl-configuration} fields are:
18626
18627 @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
18628 This determines what handshake to use.
18629 @end deftypevr
18630
18631 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
18632 Path to your private key file.
18633 @end deftypevr
18634
18635 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
18636 Path to your certificate file.
18637 @end deftypevr
18638
18639 @deftypevr {@code{ssl-configuration} parameter} file-object capath
18640 Path to directory containing root certificates that you wish Prosody to
18641 trust when verifying the certificates of remote servers.
18642 Defaults to @samp{"/etc/ssl/certs"}.
18643 @end deftypevr
18644
18645 @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
18646 Path to a file containing root certificates that you wish Prosody to trust.
18647 Similar to @code{capath} but with all certificates concatenated together.
18648 @end deftypevr
18649
18650 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
18651 A list of verification options (these mostly map to OpenSSL's
18652 @code{set_verify()} flags).
18653 @end deftypevr
18654
18655 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
18656 A list of general options relating to SSL/TLS. These map to OpenSSL's
18657 @code{set_options()}. For a full list of options available in LuaSec, see the
18658 LuaSec source.
18659 @end deftypevr
18660
18661 @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
18662 How long a chain of certificate authorities to check when looking for a
18663 trusted root certificate.
18664 @end deftypevr
18665
18666 @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
18667 An OpenSSL cipher string. This selects what ciphers Prosody will offer to
18668 clients, and in what order.
18669 @end deftypevr
18670
18671 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
18672 A path to a file containing parameters for Diffie-Hellman key exchange. You
18673 can create such a file with:
18674 @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
18675 @end deftypevr
18676
18677 @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
18678 Curve for Elliptic curve Diffie-Hellman. Prosody's default is
18679 @samp{"secp384r1"}.
18680 @end deftypevr
18681
18682 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
18683 A list of ``extra'' verification options.
18684 @end deftypevr
18685
18686 @deftypevr {@code{ssl-configuration} parameter} maybe-string password
18687 Password for encrypted private keys.
18688 @end deftypevr
18689
18690 @end deftypevr
18691
18692 @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
18693 Whether to force all client-to-server connections to be encrypted or not.
18694 See @url{https://prosody.im/doc/modules/mod_tls}.
18695 Defaults to @samp{#f}.
18696 @end deftypevr
18697
18698 @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
18699 Set of mechanisms that will never be offered. See
18700 @url{https://prosody.im/doc/modules/mod_saslauth}.
18701 Defaults to @samp{("DIGEST-MD5")}.
18702 @end deftypevr
18703
18704 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
18705 Whether to force all server-to-server connections to be encrypted or not.
18706 See @url{https://prosody.im/doc/modules/mod_tls}.
18707 Defaults to @samp{#f}.
18708 @end deftypevr
18709
18710 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
18711 Whether to require encryption and certificate authentication. This
18712 provides ideal security, but requires servers you communicate with to support
18713 encryption AND present valid, trusted certificates. See
18714 @url{https://prosody.im/doc/s2s#security}.
18715 Defaults to @samp{#f}.
18716 @end deftypevr
18717
18718 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
18719 Many servers don't support encryption or have invalid or self-signed
18720 certificates. You can list domains here that will not be required to
18721 authenticate using certificates. They will be authenticated using DNS. See
18722 @url{https://prosody.im/doc/s2s#security}.
18723 Defaults to @samp{()}.
18724 @end deftypevr
18725
18726 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
18727 Even if you leave @code{s2s-secure-auth?} disabled, you can still require
18728 valid certificates for some domains by specifying a list here. See
18729 @url{https://prosody.im/doc/s2s#security}.
18730 Defaults to @samp{()}.
18731 @end deftypevr
18732
18733 @deftypevr {@code{prosody-configuration} parameter} string authentication
18734 Select the authentication backend to use. The default provider stores
18735 passwords in plaintext and uses Prosody's configured data storage to store the
18736 authentication data. If you do not trust your server please see
18737 @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
18738 about using the hashed backend. See also
18739 @url{https://prosody.im/doc/authentication}
18740 Defaults to @samp{"internal_plain"}.
18741 @end deftypevr
18742
18743 @deftypevr {@code{prosody-configuration} parameter} maybe-string log
18744 Set logging options. Advanced logging configuration is not yet supported
18745 by the Prosody service. See @url{https://prosody.im/doc/logging}.
18746 Defaults to @samp{"*syslog"}.
18747 @end deftypevr
18748
18749 @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
18750 File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
18751 Defaults to @samp{"/var/run/prosody/prosody.pid"}.
18752 @end deftypevr
18753
18754 @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
18755 Maximum allowed size of the HTTP body (in bytes).
18756 @end deftypevr
18757
18758 @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
18759 Some modules expose their own URL in various ways. This URL is built
18760 from the protocol, host and port used. If Prosody sits behind a proxy, the
18761 public URL will be @code{http-external-url} instead. See
18762 @url{https://prosody.im/doc/http#external_url}.
18763 @end deftypevr
18764
18765 @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
18766 A host in Prosody is a domain on which user accounts can be created. For
18767 example if you want your users to have addresses like
18768 @samp{"john.smith@@example.com"} then you need to add a host
18769 @samp{"example.com"}. All options in this list will apply only to this host.
18770
18771 Note: the name @emph{virtual} host is used in configuration to avoid confusion with
18772 the actual physical host that Prosody is installed on. A single Prosody
18773 instance can serve many domains, each one defined as a VirtualHost entry in
18774 Prosody's configuration. Conversely a server that hosts a single domain would
18775 have just one VirtualHost entry.
18776
18777 See @url{https://prosody.im/doc/configure#virtual_host_settings}.
18778
18779 Available @code{virtualhost-configuration} fields are:
18780
18781 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:
18782 @deftypevr {@code{virtualhost-configuration} parameter} string domain
18783 Domain you wish Prosody to serve.
18784 @end deftypevr
18785
18786 @end deftypevr
18787
18788 @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
18789 Components are extra services on a server which are available to clients,
18790 usually on a subdomain of the main server (such as
18791 @samp{"mycomponent.example.com"}). Example components might be chatroom
18792 servers, user directories, or gateways to other protocols.
18793
18794 Internal components are implemented with Prosody-specific plugins. To add an
18795 internal component, you simply fill the hostname field, and the plugin you wish
18796 to use for the component.
18797
18798 See @url{https://prosody.im/doc/components}.
18799 Defaults to @samp{()}.
18800
18801 Available @code{int-component-configuration} fields are:
18802
18803 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:
18804 @deftypevr {@code{int-component-configuration} parameter} string hostname
18805 Hostname of the component.
18806 @end deftypevr
18807
18808 @deftypevr {@code{int-component-configuration} parameter} string plugin
18809 Plugin you wish to use for the component.
18810 @end deftypevr
18811
18812 @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
18813 Multi-user chat (MUC) is Prosody's module for allowing you to create
18814 hosted chatrooms/conferences for XMPP users.
18815
18816 General information on setting up and using multi-user chatrooms can be found
18817 in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
18818 which you should read if you are new to XMPP chatrooms.
18819
18820 See also @url{https://prosody.im/doc/modules/mod_muc}.
18821
18822 Available @code{mod-muc-configuration} fields are:
18823
18824 @deftypevr {@code{mod-muc-configuration} parameter} string name
18825 The name to return in service discovery responses.
18826 Defaults to @samp{"Prosody Chatrooms"}.
18827 @end deftypevr
18828
18829 @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
18830 If @samp{#t}, this will only allow admins to create new chatrooms.
18831 Otherwise anyone can create a room. The value @samp{"local"} restricts room
18832 creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
18833 can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
18834 restricts to service administrators only.
18835 Defaults to @samp{#f}.
18836 @end deftypevr
18837
18838 @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
18839 Maximum number of history messages that will be sent to the member that has
18840 just joined the room.
18841 Defaults to @samp{20}.
18842 @end deftypevr
18843
18844 @end deftypevr
18845
18846 @end deftypevr
18847
18848 @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
18849 External components use XEP-0114, which most standalone components
18850 support. To add an external component, you simply fill the hostname field. See
18851 @url{https://prosody.im/doc/components}.
18852 Defaults to @samp{()}.
18853
18854 Available @code{ext-component-configuration} fields are:
18855
18856 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:
18857 @deftypevr {@code{ext-component-configuration} parameter} string component-secret
18858 Password which the component will use to log in.
18859 @end deftypevr
18860
18861 @deftypevr {@code{ext-component-configuration} parameter} string hostname
18862 Hostname of the component.
18863 @end deftypevr
18864
18865 @end deftypevr
18866
18867 @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
18868 Port(s) Prosody listens on for component connections.
18869 Defaults to @samp{(5347)}.
18870 @end deftypevr
18871
18872 @deftypevr {@code{prosody-configuration} parameter} string component-interface
18873 Interface Prosody listens on for component connections.
18874 Defaults to @samp{"127.0.0.1"}.
18875 @end deftypevr
18876
18877 @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
18878 Raw content that will be added to the configuration file.
18879 @end deftypevr
18880
18881 It could be that you just want to get a @code{prosody.cfg.lua}
18882 up and running. In that case, you can pass an
18883 @code{opaque-prosody-configuration} record as the value of
18884 @code{prosody-service-type}. As its name indicates, an opaque configuration
18885 does not have easy reflective capabilities.
18886 Available @code{opaque-prosody-configuration} fields are:
18887
18888 @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
18889 The prosody package.
18890 @end deftypevr
18891
18892 @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
18893 The contents of the @code{prosody.cfg.lua} to use.
18894 @end deftypevr
18895
18896 For example, if your @code{prosody.cfg.lua} is just the empty
18897 string, you could instantiate a prosody service like this:
18898
18899 @lisp
18900 (service prosody-service-type
18901 (opaque-prosody-configuration
18902 (prosody.cfg.lua "")))
18903 @end lisp
18904
18905 @c end of Prosody auto-generated documentation
18906
18907 @subsubheading BitlBee Service
18908
18909 @cindex IRC (Internet Relay Chat)
18910 @cindex IRC gateway
18911 @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
18912 interface to a variety of messaging protocols such as XMPP.
18913
18914 @defvr {Scheme Variable} bitlbee-service-type
18915 This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
18916 gateway daemon. Its value is a @code{bitlbee-configuration} (see
18917 below).
18918
18919 To have BitlBee listen on port 6667 on localhost, add this line to your
18920 services:
18921
18922 @lisp
18923 (service bitlbee-service-type)
18924 @end lisp
18925 @end defvr
18926
18927 @deftp {Data Type} bitlbee-configuration
18928 This is the configuration for BitlBee, with the following fields:
18929
18930 @table @asis
18931 @item @code{interface} (default: @code{"127.0.0.1"})
18932 @itemx @code{port} (default: @code{6667})
18933 Listen on the network interface corresponding to the IP address
18934 specified in @var{interface}, on @var{port}.
18935
18936 When @var{interface} is @code{127.0.0.1}, only local clients can
18937 connect; when it is @code{0.0.0.0}, connections can come from any
18938 networking interface.
18939
18940 @item @code{bitlbee} (default: @code{bitlbee})
18941 The BitlBee package to use.
18942
18943 @item @code{plugins} (default: @code{'()})
18944 List of plugin packages to use---e.g., @code{bitlbee-discord}.
18945
18946 @item @code{extra-settings} (default: @code{""})
18947 Configuration snippet added as-is to the BitlBee configuration file.
18948 @end table
18949 @end deftp
18950
18951 @subsubheading Quassel Service
18952
18953 @cindex IRC (Internet Relay Chat)
18954 @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
18955 meaning that one or more clients can attach to and detach from the
18956 central core.
18957
18958 @defvr {Scheme Variable} quassel-service-type
18959 This is the service type for the @url{https://quassel-irc.org/,Quassel}
18960 IRC backend daemon. Its value is a @code{quassel-configuration}
18961 (see below).
18962 @end defvr
18963
18964 @deftp {Data Type} quassel-configuration
18965 This is the configuration for Quassel, with the following fields:
18966
18967 @table @asis
18968 @item @code{quassel} (default: @code{quassel})
18969 The Quassel package to use.
18970
18971 @item @code{interface} (default: @code{"::,0.0.0.0"})
18972 @item @code{port} (default: @code{4242})
18973 Listen on the network interface(s) corresponding to the IPv4 or IPv6
18974 interfaces specified in the comma delimited @var{interface}, on
18975 @var{port}.
18976
18977 @item @code{loglevel} (default: @code{"Info"})
18978 The level of logging desired. Accepted values are Debug, Info, Warning
18979 and Error.
18980 @end table
18981 @end deftp
18982
18983 @node Telephony Services
18984 @subsection Telephony Services
18985
18986 @cindex Murmur (VoIP server)
18987 @cindex VoIP server
18988 This section describes how to set up and run a Murmur server. Murmur is
18989 the server of the @uref{https://mumble.info, Mumble} voice-over-IP
18990 (VoIP) suite.
18991
18992 @deftp {Data Type} murmur-configuration
18993 The service type for the Murmur server. An example configuration can
18994 look like this:
18995
18996 @lisp
18997 (service murmur-service-type
18998 (murmur-configuration
18999 (welcome-text
19000 "Welcome to this Mumble server running on Guix!")
19001 (cert-required? #t) ;disallow text password logins
19002 (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
19003 (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
19004 @end lisp
19005
19006 After reconfiguring your system, you can manually set the murmur @code{SuperUser}
19007 password with the command that is printed during the activation phase.
19008
19009 It is recommended to register a normal Mumble user account
19010 and grant it admin or moderator rights.
19011 You can use the @code{mumble} client to
19012 login as new normal user, register yourself, and log out.
19013 For the next step login with the name @code{SuperUser} use
19014 the @code{SuperUser} password that you set previously,
19015 and grant your newly registered mumble user administrator or moderator
19016 rights and create some channels.
19017
19018 Available @code{murmur-configuration} fields are:
19019
19020 @table @asis
19021 @item @code{package} (default: @code{mumble})
19022 Package that contains @code{bin/murmurd}.
19023
19024 @item @code{user} (default: @code{"murmur"})
19025 User who will run the Murmur server.
19026
19027 @item @code{group} (default: @code{"murmur"})
19028 Group of the user who will run the murmur server.
19029
19030 @item @code{port} (default: @code{64738})
19031 Port on which the server will listen.
19032
19033 @item @code{welcome-text} (default: @code{""})
19034 Welcome text sent to clients when they connect.
19035
19036 @item @code{server-password} (default: @code{""})
19037 Password the clients have to enter in order to connect.
19038
19039 @item @code{max-users} (default: @code{100})
19040 Maximum of users that can be connected to the server at once.
19041
19042 @item @code{max-user-bandwidth} (default: @code{#f})
19043 Maximum voice traffic a user can send per second.
19044
19045 @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
19046 File name of the sqlite database.
19047 The service's user will become the owner of the directory.
19048
19049 @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
19050 File name of the log file.
19051 The service's user will become the owner of the directory.
19052
19053 @item @code{autoban-attempts} (default: @code{10})
19054 Maximum number of logins a user can make in @code{autoban-timeframe}
19055 without getting auto banned for @code{autoban-time}.
19056
19057 @item @code{autoban-timeframe} (default: @code{120})
19058 Timeframe for autoban in seconds.
19059
19060 @item @code{autoban-time} (default: @code{300})
19061 Amount of time in seconds for which a client gets banned
19062 when violating the autoban limits.
19063
19064 @item @code{opus-threshold} (default: @code{100})
19065 Percentage of clients that need to support opus
19066 before switching over to opus audio codec.
19067
19068 @item @code{channel-nesting-limit} (default: @code{10})
19069 How deep channels can be nested at maximum.
19070
19071 @item @code{channelname-regex} (default: @code{#f})
19072 A string in form of a Qt regular expression that channel names must conform to.
19073
19074 @item @code{username-regex} (default: @code{#f})
19075 A string in form of a Qt regular expression that user names must conform to.
19076
19077 @item @code{text-message-length} (default: @code{5000})
19078 Maximum size in bytes that a user can send in one text chat message.
19079
19080 @item @code{image-message-length} (default: @code{(* 128 1024)})
19081 Maximum size in bytes that a user can send in one image message.
19082
19083 @item @code{cert-required?} (default: @code{#f})
19084 If it is set to @code{#t} clients that use weak password authentication
19085 will not be accepted. Users must have completed the certificate wizard to join.
19086
19087 @item @code{remember-channel?} (default: @code{#f})
19088 Should murmur remember the last channel each user was in when they disconnected
19089 and put them into the remembered channel when they rejoin.
19090
19091 @item @code{allow-html?} (default: @code{#f})
19092 Should html be allowed in text messages, user comments, and channel descriptions.
19093
19094 @item @code{allow-ping?} (default: @code{#f})
19095 Setting to true exposes the current user count, the maximum user count, and
19096 the server's maximum bandwidth per client to unauthenticated users. In the
19097 Mumble client, this information is shown in the Connect dialog.
19098
19099 Disabling this setting will prevent public listing of the server.
19100
19101 @item @code{bonjour?} (default: @code{#f})
19102 Should the server advertise itself in the local network through the bonjour protocol.
19103
19104 @item @code{send-version?} (default: @code{#f})
19105 Should the murmur server version be exposed in ping requests.
19106
19107 @item @code{log-days} (default: @code{31})
19108 Murmur also stores logs in the database, which are accessible via RPC.
19109 The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
19110 or -1 to disable logging to the database.
19111
19112 @item @code{obfuscate-ips?} (default: @code{#t})
19113 Should logged ips be obfuscated to protect the privacy of users.
19114
19115 @item @code{ssl-cert} (default: @code{#f})
19116 File name of the SSL/TLS certificate used for encrypted connections.
19117
19118 @lisp
19119 (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
19120 @end lisp
19121 @item @code{ssl-key} (default: @code{#f})
19122 Filepath to the ssl private key used for encrypted connections.
19123 @lisp
19124 (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
19125 @end lisp
19126
19127 @item @code{ssl-dh-params} (default: @code{#f})
19128 File name of a PEM-encoded file with Diffie-Hellman parameters
19129 for the SSL/TLS encryption. Alternatively you set it to
19130 @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
19131 or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
19132
19133 @item @code{ssl-ciphers} (default: @code{#f})
19134 The @code{ssl-ciphers} option chooses the cipher suites to make available for use
19135 in SSL/TLS.
19136
19137 This option is specified using
19138 @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
19139 OpenSSL cipher list notation}.
19140
19141 It is recommended that you try your cipher string using 'openssl ciphers <string>'
19142 before setting it here, to get a feel for which cipher suites you will get.
19143 After setting this option, it is recommend that you inspect your Murmur log
19144 to ensure that Murmur is using the cipher suites that you expected it to.
19145
19146 Note: Changing this option may impact the backwards compatibility of your
19147 Murmur server, and can remove the ability for older Mumble clients to be able
19148 to connect to it.
19149
19150 @item @code{public-registration} (default: @code{#f})
19151 Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
19152
19153 You can optionally register your server in the public server list that the
19154 @code{mumble} client shows on startup.
19155 You cannot register your server if you have set a @code{server-password},
19156 or set @code{allow-ping} to @code{#f}.
19157
19158 It might take a few hours until it shows up in the public list.
19159
19160 @item @code{file} (default: @code{#f})
19161 Optional alternative override for this configuration.
19162 @end table
19163 @end deftp
19164
19165 @deftp {Data Type} murmur-public-registration-configuration
19166 Configuration for public registration of a murmur service.
19167
19168 @table @asis
19169 @item @code{name}
19170 This is a display name for your server. Not to be confused with the hostname.
19171
19172 @item @code{password}
19173 A password to identify your registration.
19174 Subsequent updates will need the same password. Don't lose your password.
19175
19176 @item @code{url}
19177 This should be a @code{http://} or @code{https://} link to your web
19178 site.
19179
19180 @item @code{hostname} (default: @code{#f})
19181 By default your server will be listed by its IP address.
19182 If it is set your server will be linked by this host name instead.
19183 @end table
19184 @end deftp
19185
19186
19187
19188 @node Monitoring Services
19189 @subsection Monitoring Services
19190
19191 @subsubheading Tailon Service
19192
19193 @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
19194 viewing and searching log files.
19195
19196 The following example will configure the service with default values.
19197 By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
19198
19199 @lisp
19200 (service tailon-service-type)
19201 @end lisp
19202
19203 The following example customises more of the Tailon configuration,
19204 adding @command{sed} to the list of allowed commands.
19205
19206 @lisp
19207 (service tailon-service-type
19208 (tailon-configuration
19209 (config-file
19210 (tailon-configuration-file
19211 (allowed-commands '("tail" "grep" "awk" "sed"))))))
19212 @end lisp
19213
19214
19215 @deftp {Data Type} tailon-configuration
19216 Data type representing the configuration of Tailon.
19217 This type has the following parameters:
19218
19219 @table @asis
19220 @item @code{config-file} (default: @code{(tailon-configuration-file)})
19221 The configuration file to use for Tailon. This can be set to a
19222 @dfn{tailon-configuration-file} record value, or any gexp
19223 (@pxref{G-Expressions}).
19224
19225 For example, to instead use a local file, the @code{local-file} function
19226 can be used:
19227
19228 @lisp
19229 (service tailon-service-type
19230 (tailon-configuration
19231 (config-file (local-file "./my-tailon.conf"))))
19232 @end lisp
19233
19234 @item @code{package} (default: @code{tailon})
19235 The tailon package to use.
19236
19237 @end table
19238 @end deftp
19239
19240 @deftp {Data Type} tailon-configuration-file
19241 Data type representing the configuration options for Tailon.
19242 This type has the following parameters:
19243
19244 @table @asis
19245 @item @code{files} (default: @code{(list "/var/log")})
19246 List of files to display. The list can include strings for a single file
19247 or directory, or a list, where the first item is the name of a
19248 subsection, and the remaining items are the files or directories in that
19249 subsection.
19250
19251 @item @code{bind} (default: @code{"localhost:8080"})
19252 Address and port to which Tailon should bind on.
19253
19254 @item @code{relative-root} (default: @code{#f})
19255 URL path to use for Tailon, set to @code{#f} to not use a path.
19256
19257 @item @code{allow-transfers?} (default: @code{#t})
19258 Allow downloading the log files in the web interface.
19259
19260 @item @code{follow-names?} (default: @code{#t})
19261 Allow tailing of not-yet existent files.
19262
19263 @item @code{tail-lines} (default: @code{200})
19264 Number of lines to read initially from each file.
19265
19266 @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
19267 Commands to allow running. By default, @code{sed} is disabled.
19268
19269 @item @code{debug?} (default: @code{#f})
19270 Set @code{debug?} to @code{#t} to show debug messages.
19271
19272 @item @code{wrap-lines} (default: @code{#t})
19273 Initial line wrapping state in the web interface. Set to @code{#t} to
19274 initially wrap lines (the default), or to @code{#f} to initially not
19275 wrap lines.
19276
19277 @item @code{http-auth} (default: @code{#f})
19278 HTTP authentication type to use. Set to @code{#f} to disable
19279 authentication (the default). Supported values are @code{"digest"} or
19280 @code{"basic"}.
19281
19282 @item @code{users} (default: @code{#f})
19283 If HTTP authentication is enabled (see @code{http-auth}), access will be
19284 restricted to the credentials provided here. To configure users, use a
19285 list of pairs, where the first element of the pair is the username, and
19286 the 2nd element of the pair is the password.
19287
19288 @lisp
19289 (tailon-configuration-file
19290 (http-auth "basic")
19291 (users '(("user1" . "password1")
19292 ("user2" . "password2"))))
19293 @end lisp
19294
19295 @end table
19296 @end deftp
19297
19298
19299 @subsubheading Darkstat Service
19300 @cindex darkstat
19301 Darkstat is a packet sniffer that captures network traffic, calculates
19302 statistics about usage, and serves reports over HTTP.
19303
19304 @defvar {Scheme Variable} darkstat-service-type
19305 This is the service type for the
19306 @uref{https://unix4lyfe.org/darkstat/, darkstat}
19307 service, its value must be a @code{darkstat-configuration} record as in
19308 this example:
19309
19310 @lisp
19311 (service darkstat-service-type
19312 (darkstat-configuration
19313 (interface "eno1")))
19314 @end lisp
19315 @end defvar
19316
19317 @deftp {Data Type} darkstat-configuration
19318 Data type representing the configuration of @command{darkstat}.
19319
19320 @table @asis
19321 @item @code{package} (default: @code{darkstat})
19322 The darkstat package to use.
19323
19324 @item @code{interface}
19325 Capture traffic on the specified network interface.
19326
19327 @item @code{port} (default: @code{"667"})
19328 Bind the web interface to the specified port.
19329
19330 @item @code{bind-address} (default: @code{"127.0.0.1"})
19331 Bind the web interface to the specified address.
19332
19333 @item @code{base} (default: @code{"/"})
19334 Specify the path of the base URL. This can be useful if
19335 @command{darkstat} is accessed via a reverse proxy.
19336
19337 @end table
19338 @end deftp
19339
19340 @subsubheading Prometheus Node Exporter Service
19341
19342 @cindex prometheus-node-exporter
19343 The Prometheus ``node exporter'' makes hardware and operating system statistics
19344 provided by the Linux kernel available for the Prometheus monitoring system.
19345 This service should be deployed on all physical nodes and virtual machines,
19346 where monitoring these statistics is desirable.
19347
19348 @defvar {Scheme variable} prometheus-node-exporter-service-type
19349 This is the service type for the
19350 @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
19351 service, its value must be a @code{prometheus-node-exporter-configuration}
19352 record as in this example:
19353
19354 @lisp
19355 (service prometheus-node-exporter-service-type
19356 (prometheus-node-exporter-configuration
19357 (web-listen-address ":9100")))
19358 @end lisp
19359 @end defvar
19360
19361 @deftp {Data Type} prometheus-node-exporter-configuration
19362 Data type representing the configuration of @command{node_exporter}.
19363
19364 @table @asis
19365 @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
19366 The prometheus-node-exporter package to use.
19367
19368 @item @code{web-listen-address} (default: @code{":9100"})
19369 Bind the web interface to the specified address.
19370
19371 @end table
19372 @end deftp
19373
19374 @subsubheading Zabbix server
19375 @cindex zabbix zabbix-server
19376 Zabbix provides monitoring metrics, among others network utilization, CPU load
19377 and disk space consumption:
19378
19379 @itemize
19380 @item High performance, high capacity (able to monitor hundreds of thousands of devices).
19381 @item Auto-discovery of servers and network devices and interfaces.
19382 @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
19383 @item Distributed monitoring with centralized web administration.
19384 @item Native high performance agents.
19385 @item SLA, and ITIL KPI metrics on reporting.
19386 @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
19387 @item Remote command execution through Zabbix proxies.
19388 @end itemize
19389
19390 @c %start of fragment
19391
19392 Available @code{zabbix-server-configuration} fields are:
19393
19394 @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
19395 The zabbix-server package.
19396
19397 @end deftypevr
19398
19399 @deftypevr {@code{zabbix-server-configuration} parameter} string user
19400 User who will run the Zabbix server.
19401
19402 Defaults to @samp{"zabbix"}.
19403
19404 @end deftypevr
19405
19406 @deftypevr {@code{zabbix-server-configuration} parameter} group group
19407 Group who will run the Zabbix server.
19408
19409 Defaults to @samp{"zabbix"}.
19410
19411 @end deftypevr
19412
19413 @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
19414 Database host name.
19415
19416 Defaults to @samp{"127.0.0.1"}.
19417
19418 @end deftypevr
19419
19420 @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
19421 Database name.
19422
19423 Defaults to @samp{"zabbix"}.
19424
19425 @end deftypevr
19426
19427 @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
19428 Database user.
19429
19430 Defaults to @samp{"zabbix"}.
19431
19432 @end deftypevr
19433
19434 @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
19435 Database password. Please, use @code{include-files} with
19436 @code{DBPassword=SECRET} inside a specified file instead.
19437
19438 Defaults to @samp{""}.
19439
19440 @end deftypevr
19441
19442 @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
19443 Database port.
19444
19445 Defaults to @samp{5432}.
19446
19447 @end deftypevr
19448
19449 @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
19450 Specifies where log messages are written to:
19451
19452 @itemize @bullet
19453 @item
19454 @code{system} - syslog.
19455
19456 @item
19457 @code{file} - file specified with @code{log-file} parameter.
19458
19459 @item
19460 @code{console} - standard output.
19461
19462 @end itemize
19463
19464 Defaults to @samp{""}.
19465
19466 @end deftypevr
19467
19468 @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
19469 Log file name for @code{log-type} @code{file} parameter.
19470
19471 Defaults to @samp{"/var/log/zabbix/server.log"}.
19472
19473 @end deftypevr
19474
19475 @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
19476 Name of PID file.
19477
19478 Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
19479
19480 @end deftypevr
19481
19482 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
19483 The location of certificate authority (CA) files for SSL server
19484 certificate verification.
19485
19486 Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
19487
19488 @end deftypevr
19489
19490 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
19491 Location of SSL client certificates.
19492
19493 Defaults to @samp{"/etc/ssl/certs"}.
19494
19495 @end deftypevr
19496
19497 @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
19498 Extra options will be appended to Zabbix server configuration file.
19499
19500 Defaults to @samp{""}.
19501
19502 @end deftypevr
19503
19504 @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
19505 You may include individual files or all files in a directory in the
19506 configuration file.
19507
19508 Defaults to @samp{()}.
19509
19510 @end deftypevr
19511
19512 @c %end of fragment
19513
19514 @subsubheading Zabbix agent
19515 @cindex zabbix zabbix-agent
19516
19517 Zabbix agent gathers information for Zabbix server.
19518
19519 @c %start of fragment
19520
19521 Available @code{zabbix-agent-configuration} fields are:
19522
19523 @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
19524 The zabbix-agent package.
19525
19526 @end deftypevr
19527
19528 @deftypevr {@code{zabbix-agent-configuration} parameter} string user
19529 User who will run the Zabbix agent.
19530
19531 Defaults to @samp{"zabbix"}.
19532
19533 @end deftypevr
19534
19535 @deftypevr {@code{zabbix-agent-configuration} parameter} group group
19536 Group who will run the Zabbix agent.
19537
19538 Defaults to @samp{"zabbix"}.
19539
19540 @end deftypevr
19541
19542 @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
19543 Unique, case sensitive hostname which is required for active checks and
19544 must match hostname as configured on the server.
19545
19546 Defaults to @samp{"Zabbix server"}.
19547
19548 @end deftypevr
19549
19550 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
19551 Specifies where log messages are written to:
19552
19553 @itemize @bullet
19554 @item
19555 @code{system} - syslog.
19556
19557 @item
19558 @code{file} - file specified with @code{log-file} parameter.
19559
19560 @item
19561 @code{console} - standard output.
19562
19563 @end itemize
19564
19565 Defaults to @samp{""}.
19566
19567 @end deftypevr
19568
19569 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
19570 Log file name for @code{log-type} @code{file} parameter.
19571
19572 Defaults to @samp{"/var/log/zabbix/agent.log"}.
19573
19574 @end deftypevr
19575
19576 @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
19577 Name of PID file.
19578
19579 Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
19580
19581 @end deftypevr
19582
19583 @deftypevr {@code{zabbix-agent-configuration} parameter} list server
19584 List of IP addresses, optionally in CIDR notation, or hostnames of
19585 Zabbix servers and Zabbix proxies. Incoming connections will be
19586 accepted only from the hosts listed here.
19587
19588 Defaults to @samp{("127.0.0.1")}.
19589
19590 @end deftypevr
19591
19592 @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
19593 List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
19594 proxies for active checks. If port is not specified, default port is
19595 used. If this parameter is not specified, active checks are disabled.
19596
19597 Defaults to @samp{("127.0.0.1")}.
19598
19599 @end deftypevr
19600
19601 @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
19602 Extra options will be appended to Zabbix server configuration file.
19603
19604 Defaults to @samp{""}.
19605
19606 @end deftypevr
19607
19608 @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
19609 You may include individual files or all files in a directory in the
19610 configuration file.
19611
19612 Defaults to @samp{()}.
19613
19614 @end deftypevr
19615
19616 @c %end of fragment
19617
19618 @subsubheading Zabbix front-end
19619 @cindex zabbix zabbix-front-end
19620
19621 This service provides a WEB interface to Zabbix server.
19622
19623 @c %start of fragment
19624
19625 Available @code{zabbix-front-end-configuration} fields are:
19626
19627 @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
19628 NGINX configuration.
19629
19630 @end deftypevr
19631
19632 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
19633 Database host name.
19634
19635 Defaults to @samp{"localhost"}.
19636
19637 @end deftypevr
19638
19639 @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
19640 Database port.
19641
19642 Defaults to @samp{5432}.
19643
19644 @end deftypevr
19645
19646 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
19647 Database name.
19648
19649 Defaults to @samp{"zabbix"}.
19650
19651 @end deftypevr
19652
19653 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
19654 Database user.
19655
19656 Defaults to @samp{"zabbix"}.
19657
19658 @end deftypevr
19659
19660 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
19661 Database password. Please, use @code{db-secret-file} instead.
19662
19663 Defaults to @samp{""}.
19664
19665 @end deftypevr
19666
19667 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
19668 Secret file which will be appended to @file{zabbix.conf.php} file. This
19669 file contains credentials for use by Zabbix front-end. You are expected
19670 to create it manually.
19671
19672 Defaults to @samp{""}.
19673
19674 @end deftypevr
19675
19676 @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
19677 Zabbix server hostname.
19678
19679 Defaults to @samp{"localhost"}.
19680
19681 @end deftypevr
19682
19683 @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
19684 Zabbix server port.
19685
19686 Defaults to @samp{10051}.
19687
19688 @end deftypevr
19689
19690
19691 @c %end of fragment
19692
19693 @node Kerberos Services
19694 @subsection Kerberos Services
19695 @cindex Kerberos
19696
19697 The @code{(gnu services kerberos)} module provides services relating to
19698 the authentication protocol @dfn{Kerberos}.
19699
19700 @subsubheading Krb5 Service
19701
19702 Programs using a Kerberos client library normally
19703 expect a configuration file in @file{/etc/krb5.conf}.
19704 This service generates such a file from a definition provided in the
19705 operating system declaration.
19706 It does not cause any daemon to be started.
19707
19708 No ``keytab'' files are provided by this service---you must explicitly create them.
19709 This service is known to work with the MIT client library, @code{mit-krb5}.
19710 Other implementations have not been tested.
19711
19712 @defvr {Scheme Variable} krb5-service-type
19713 A service type for Kerberos 5 clients.
19714 @end defvr
19715
19716 @noindent
19717 Here is an example of its use:
19718 @lisp
19719 (service krb5-service-type
19720 (krb5-configuration
19721 (default-realm "EXAMPLE.COM")
19722 (allow-weak-crypto? #t)
19723 (realms (list
19724 (krb5-realm
19725 (name "EXAMPLE.COM")
19726 (admin-server "groucho.example.com")
19727 (kdc "karl.example.com"))
19728 (krb5-realm
19729 (name "ARGRX.EDU")
19730 (admin-server "kerb-admin.argrx.edu")
19731 (kdc "keys.argrx.edu"))))))
19732 @end lisp
19733
19734 @noindent
19735 This example provides a Kerberos@tie{}5 client configuration which:
19736 @itemize
19737 @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
19738 of which have distinct administration servers and key distribution centers;
19739 @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
19740 specified by clients;
19741 @item Accepts services which only support encryption types known to be weak.
19742 @end itemize
19743
19744 The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
19745 Only the most commonly used ones are described here.
19746 For a full list, and more detailed explanation of each, see the MIT
19747 @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
19748 documentation.
19749
19750
19751 @deftp {Data Type} krb5-realm
19752 @cindex realm, kerberos
19753 @table @asis
19754 @item @code{name}
19755 This field is a string identifying the name of the realm.
19756 A common convention is to use the fully qualified DNS name of your organization,
19757 converted to upper case.
19758
19759 @item @code{admin-server}
19760 This field is a string identifying the host where the administration server is
19761 running.
19762
19763 @item @code{kdc}
19764 This field is a string identifying the key distribution center
19765 for the realm.
19766 @end table
19767 @end deftp
19768
19769 @deftp {Data Type} krb5-configuration
19770
19771 @table @asis
19772 @item @code{allow-weak-crypto?} (default: @code{#f})
19773 If this flag is @code{#t} then services which only offer encryption algorithms
19774 known to be weak will be accepted.
19775
19776 @item @code{default-realm} (default: @code{#f})
19777 This field should be a string identifying the default Kerberos
19778 realm for the client.
19779 You should set this field to the name of your Kerberos realm.
19780 If this value is @code{#f}
19781 then a realm must be specified with every Kerberos principal when invoking programs
19782 such as @command{kinit}.
19783
19784 @item @code{realms}
19785 This should be a non-empty list of @code{krb5-realm} objects, which clients may
19786 access.
19787 Normally, one of them will have a @code{name} field matching the @code{default-realm}
19788 field.
19789 @end table
19790 @end deftp
19791
19792
19793 @subsubheading PAM krb5 Service
19794 @cindex pam-krb5
19795
19796 The @code{pam-krb5} service allows for login authentication and password
19797 management via Kerberos.
19798 You will need this service if you want PAM enabled applications to authenticate
19799 users using Kerberos.
19800
19801 @defvr {Scheme Variable} pam-krb5-service-type
19802 A service type for the Kerberos 5 PAM module.
19803 @end defvr
19804
19805 @deftp {Data Type} pam-krb5-configuration
19806 Data type representing the configuration of the Kerberos 5 PAM module.
19807 This type has the following parameters:
19808 @table @asis
19809 @item @code{pam-krb5} (default: @code{pam-krb5})
19810 The pam-krb5 package to use.
19811
19812 @item @code{minimum-uid} (default: @code{1000})
19813 The smallest user ID for which Kerberos authentications should be attempted.
19814 Local accounts with lower values will silently fail to authenticate.
19815 @end table
19816 @end deftp
19817
19818
19819 @node LDAP Services
19820 @subsection LDAP Services
19821 @cindex LDAP
19822 @cindex nslcd, LDAP service
19823
19824 The @code{(gnu services authentication)} module provides the
19825 @code{nslcd-service-type}, which can be used to authenticate against an LDAP
19826 server. In addition to configuring the service itself, you may want to add
19827 @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
19828 Switch} for detailed information.
19829
19830 Here is a simple operating system declaration with a default configuration of
19831 the @code{nslcd-service-type} and a Name Service Switch configuration that
19832 consults the @code{ldap} name service last:
19833
19834 @lisp
19835 (use-service-modules authentication)
19836 (use-modules (gnu system nss))
19837 ...
19838 (operating-system
19839 ...
19840 (services
19841 (cons*
19842 (service nslcd-service-type)
19843 (service dhcp-client-service-type)
19844 %base-services))
19845 (name-service-switch
19846 (let ((services (list (name-service (name "db"))
19847 (name-service (name "files"))
19848 (name-service (name "ldap")))))
19849 (name-service-switch
19850 (inherit %mdns-host-lookup-nss)
19851 (password services)
19852 (shadow services)
19853 (group services)
19854 (netgroup services)
19855 (gshadow services)))))
19856 @end lisp
19857
19858 @c %start of generated documentation for nslcd-configuration
19859
19860 Available @code{nslcd-configuration} fields are:
19861
19862 @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
19863 The @code{nss-pam-ldapd} package to use.
19864
19865 @end deftypevr
19866
19867 @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
19868 The number of threads to start that can handle requests and perform LDAP
19869 queries. Each thread opens a separate connection to the LDAP server.
19870 The default is to start 5 threads.
19871
19872 Defaults to @samp{disabled}.
19873
19874 @end deftypevr
19875
19876 @deftypevr {@code{nslcd-configuration} parameter} string uid
19877 This specifies the user id with which the daemon should be run.
19878
19879 Defaults to @samp{"nslcd"}.
19880
19881 @end deftypevr
19882
19883 @deftypevr {@code{nslcd-configuration} parameter} string gid
19884 This specifies the group id with which the daemon should be run.
19885
19886 Defaults to @samp{"nslcd"}.
19887
19888 @end deftypevr
19889
19890 @deftypevr {@code{nslcd-configuration} parameter} log-option log
19891 This option controls the way logging is done via a list containing
19892 SCHEME and LEVEL. The SCHEME argument may either be the symbols
19893 @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
19894 argument is optional and specifies the log level. The log level may be
19895 one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
19896 @samp{notice}, @samp{info} or @samp{debug}. All messages with the
19897 specified log level or higher are logged.
19898
19899 Defaults to @samp{("/var/log/nslcd" info)}.
19900
19901 @end deftypevr
19902
19903 @deftypevr {@code{nslcd-configuration} parameter} list uri
19904 The list of LDAP server URIs. Normally, only the first server will be
19905 used with the following servers as fall-back.
19906
19907 Defaults to @samp{("ldap://localhost:389/")}.
19908
19909 @end deftypevr
19910
19911 @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
19912 The version of the LDAP protocol to use. The default is to use the
19913 maximum version supported by the LDAP library.
19914
19915 Defaults to @samp{disabled}.
19916
19917 @end deftypevr
19918
19919 @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
19920 Specifies the distinguished name with which to bind to the directory
19921 server for lookups. The default is to bind anonymously.
19922
19923 Defaults to @samp{disabled}.
19924
19925 @end deftypevr
19926
19927 @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
19928 Specifies the credentials with which to bind. This option is only
19929 applicable when used with binddn.
19930
19931 Defaults to @samp{disabled}.
19932
19933 @end deftypevr
19934
19935 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
19936 Specifies the distinguished name to use when the root user tries to
19937 modify a user's password using the PAM module.
19938
19939 Defaults to @samp{disabled}.
19940
19941 @end deftypevr
19942
19943 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
19944 Specifies the credentials with which to bind if the root user tries to
19945 change a user's password. This option is only applicable when used with
19946 rootpwmoddn
19947
19948 Defaults to @samp{disabled}.
19949
19950 @end deftypevr
19951
19952 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
19953 Specifies the SASL mechanism to be used when performing SASL
19954 authentication.
19955
19956 Defaults to @samp{disabled}.
19957
19958 @end deftypevr
19959
19960 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
19961 Specifies the SASL realm to be used when performing SASL authentication.
19962
19963 Defaults to @samp{disabled}.
19964
19965 @end deftypevr
19966
19967 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
19968 Specifies the authentication identity to be used when performing SASL
19969 authentication.
19970
19971 Defaults to @samp{disabled}.
19972
19973 @end deftypevr
19974
19975 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
19976 Specifies the authorization identity to be used when performing SASL
19977 authentication.
19978
19979 Defaults to @samp{disabled}.
19980
19981 @end deftypevr
19982
19983 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
19984 Determines whether the LDAP server host name should be canonicalised. If
19985 this is enabled the LDAP library will do a reverse host name lookup. By
19986 default, it is left up to the LDAP library whether this check is
19987 performed or not.
19988
19989 Defaults to @samp{disabled}.
19990
19991 @end deftypevr
19992
19993 @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
19994 Set the name for the GSS-API Kerberos credentials cache.
19995
19996 Defaults to @samp{disabled}.
19997
19998 @end deftypevr
19999
20000 @deftypevr {@code{nslcd-configuration} parameter} string base
20001 The directory search base.
20002
20003 Defaults to @samp{"dc=example,dc=com"}.
20004
20005 @end deftypevr
20006
20007 @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
20008 Specifies the search scope (subtree, onelevel, base or children). The
20009 default scope is subtree; base scope is almost never useful for name
20010 service lookups; children scope is not supported on all servers.
20011
20012 Defaults to @samp{(subtree)}.
20013
20014 @end deftypevr
20015
20016 @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
20017 Specifies the policy for dereferencing aliases. The default policy is
20018 to never dereference aliases.
20019
20020 Defaults to @samp{disabled}.
20021
20022 @end deftypevr
20023
20024 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
20025 Specifies whether automatic referral chasing should be enabled. The
20026 default behaviour is to chase referrals.
20027
20028 Defaults to @samp{disabled}.
20029
20030 @end deftypevr
20031
20032 @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
20033 This option allows for custom attributes to be looked up instead of the
20034 default RFC 2307 attributes. It is a list of maps, each consisting of
20035 the name of a map, the RFC 2307 attribute to match and the query
20036 expression for the attribute as it is available in the directory.
20037
20038 Defaults to @samp{()}.
20039
20040 @end deftypevr
20041
20042 @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
20043 A list of filters consisting of the name of a map to which the filter
20044 applies and an LDAP search filter expression.
20045
20046 Defaults to @samp{()}.
20047
20048 @end deftypevr
20049
20050 @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
20051 Specifies the time limit in seconds to use when connecting to the
20052 directory server. The default value is 10 seconds.
20053
20054 Defaults to @samp{disabled}.
20055
20056 @end deftypevr
20057
20058 @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
20059 Specifies the time limit (in seconds) to wait for a response from the
20060 LDAP server. A value of zero, which is the default, is to wait
20061 indefinitely for searches to be completed.
20062
20063 Defaults to @samp{disabled}.
20064
20065 @end deftypevr
20066
20067 @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
20068 Specifies the period if inactivity (in seconds) after which the con‐
20069 nection to the LDAP server will be closed. The default is not to time
20070 out connections.
20071
20072 Defaults to @samp{disabled}.
20073
20074 @end deftypevr
20075
20076 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
20077 Specifies the number of seconds to sleep when connecting to all LDAP
20078 servers fails. By default one second is waited between the first
20079 failure and the first retry.
20080
20081 Defaults to @samp{disabled}.
20082
20083 @end deftypevr
20084
20085 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
20086 Specifies the time after which the LDAP server is considered to be
20087 permanently unavailable. Once this time is reached retries will be done
20088 only once per this time period. The default value is 10 seconds.
20089
20090 Defaults to @samp{disabled}.
20091
20092 @end deftypevr
20093
20094 @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
20095 Specifies whether to use SSL/TLS or not (the default is not to). If
20096 'start-tls is specified then StartTLS is used rather than raw LDAP over
20097 SSL.
20098
20099 Defaults to @samp{disabled}.
20100
20101 @end deftypevr
20102
20103 @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
20104 Specifies what checks to perform on a server-supplied certificate. The
20105 meaning of the values is described in the ldap.conf(5) manual page.
20106
20107 Defaults to @samp{disabled}.
20108
20109 @end deftypevr
20110
20111 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
20112 Specifies the directory containing X.509 certificates for peer authen‐
20113 tication. This parameter is ignored when using GnuTLS.
20114
20115 Defaults to @samp{disabled}.
20116
20117 @end deftypevr
20118
20119 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
20120 Specifies the path to the X.509 certificate for peer authentication.
20121
20122 Defaults to @samp{disabled}.
20123
20124 @end deftypevr
20125
20126 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
20127 Specifies the path to an entropy source. This parameter is ignored when
20128 using GnuTLS.
20129
20130 Defaults to @samp{disabled}.
20131
20132 @end deftypevr
20133
20134 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
20135 Specifies the ciphers to use for TLS as a string.
20136
20137 Defaults to @samp{disabled}.
20138
20139 @end deftypevr
20140
20141 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
20142 Specifies the path to the file containing the local certificate for
20143 client TLS authentication.
20144
20145 Defaults to @samp{disabled}.
20146
20147 @end deftypevr
20148
20149 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
20150 Specifies the path to the file containing the private key for client TLS
20151 authentication.
20152
20153 Defaults to @samp{disabled}.
20154
20155 @end deftypevr
20156
20157 @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
20158 Set this to a number greater than 0 to request paged results from the
20159 LDAP server in accordance with RFC2696. The default (0) is to not
20160 request paged results.
20161
20162 Defaults to @samp{disabled}.
20163
20164 @end deftypevr
20165
20166 @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
20167 This option prevents group membership lookups through LDAP for the
20168 specified users. Alternatively, the value 'all-local may be used. With
20169 that value nslcd builds a full list of non-LDAP users on startup.
20170
20171 Defaults to @samp{disabled}.
20172
20173 @end deftypevr
20174
20175 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
20176 This option ensures that LDAP users with a numeric user id lower than
20177 the specified value are ignored.
20178
20179 Defaults to @samp{disabled}.
20180
20181 @end deftypevr
20182
20183 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
20184 This option specifies an offset that is added to all LDAP numeric user
20185 ids. This can be used to avoid user id collisions with local users.
20186
20187 Defaults to @samp{disabled}.
20188
20189 @end deftypevr
20190
20191 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
20192 This option specifies an offset that is added to all LDAP numeric group
20193 ids. This can be used to avoid user id collisions with local groups.
20194
20195 Defaults to @samp{disabled}.
20196
20197 @end deftypevr
20198
20199 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
20200 If this option is set, the member attribute of a group may point to
20201 another group. Members of nested groups are also returned in the higher
20202 level group and parent groups are returned when finding groups for a
20203 specific user. The default is not to perform extra searches for nested
20204 groups.
20205
20206 Defaults to @samp{disabled}.
20207
20208 @end deftypevr
20209
20210 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
20211 If this option is set, the group member list is not retrieved when
20212 looking up groups. Lookups for finding which groups a user belongs to
20213 will remain functional so the user will likely still get the correct
20214 groups assigned on login.
20215
20216 Defaults to @samp{disabled}.
20217
20218 @end deftypevr
20219
20220 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
20221 If this option is set, functions which cause all user/group entries to
20222 be loaded from the directory will not succeed in doing so. This can
20223 dramatically reduce LDAP server load in situations where there are a
20224 great number of users and/or groups. This option is not recommended for
20225 most configurations.
20226
20227 Defaults to @samp{disabled}.
20228
20229 @end deftypevr
20230
20231 @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
20232 This option can be used to specify how user and group names are verified
20233 within the system. This pattern is used to check all user and group
20234 names that are requested and returned from LDAP.
20235
20236 Defaults to @samp{disabled}.
20237
20238 @end deftypevr
20239
20240 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
20241 This specifies whether or not to perform searches using case-insensitive
20242 matching. Enabling this could open up the system to authorization
20243 bypass vulnerabilities and introduce nscd cache poisoning
20244 vulnerabilities which allow denial of service.
20245
20246 Defaults to @samp{disabled}.
20247
20248 @end deftypevr
20249
20250 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
20251 This option specifies whether password policy controls are requested and
20252 handled from the LDAP server when performing user authentication.
20253
20254 Defaults to @samp{disabled}.
20255
20256 @end deftypevr
20257
20258 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
20259 By default nslcd performs an LDAP search with the user's credentials
20260 after BIND (authentication) to ensure that the BIND operation was
20261 successful. The default search is a simple check to see if the user's
20262 DN exists. A search filter can be specified that will be used instead.
20263 It should return at least one entry.
20264
20265 Defaults to @samp{disabled}.
20266
20267 @end deftypevr
20268
20269 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
20270 This option allows flexible fine tuning of the authorisation check that
20271 should be performed. The search filter specified is executed and if any
20272 entries match, access is granted, otherwise access is denied.
20273
20274 Defaults to @samp{disabled}.
20275
20276 @end deftypevr
20277
20278 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
20279 If this option is set password modification using pam_ldap will be
20280 denied and the specified message will be presented to the user instead.
20281 The message can be used to direct the user to an alternative means of
20282 changing their password.
20283
20284 Defaults to @samp{disabled}.
20285
20286 @end deftypevr
20287
20288 @deftypevr {@code{nslcd-configuration} parameter} list pam-services
20289 List of pam service names for which LDAP authentication should suffice.
20290
20291 Defaults to @samp{()}.
20292
20293 @end deftypevr
20294
20295 @c %end of generated documentation for nslcd-configuration
20296
20297
20298 @node Web Services
20299 @subsection Web Services
20300
20301 @cindex web
20302 @cindex www
20303 @cindex HTTP
20304 The @code{(gnu services web)} module provides the Apache HTTP Server,
20305 the nginx web server, and also a fastcgi wrapper daemon.
20306
20307 @subsubheading Apache HTTP Server
20308
20309 @deffn {Scheme Variable} httpd-service-type
20310 Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
20311 (@dfn{httpd}). The value for this service type is a
20312 @code{httpd-configuration} record.
20313
20314 A simple example configuration is given below.
20315
20316 @lisp
20317 (service httpd-service-type
20318 (httpd-configuration
20319 (config
20320 (httpd-config-file
20321 (server-name "www.example.com")
20322 (document-root "/srv/http/www.example.com")))))
20323 @end lisp
20324
20325 Other services can also extend the @code{httpd-service-type} to add to
20326 the configuration.
20327
20328 @lisp
20329 (simple-service 'www.example.com-server httpd-service-type
20330 (list
20331 (httpd-virtualhost
20332 "*:80"
20333 (list (string-join '("ServerName www.example.com"
20334 "DocumentRoot /srv/http/www.example.com")
20335 "\n")))))
20336 @end lisp
20337 @end deffn
20338
20339 The details for the @code{httpd-configuration}, @code{httpd-module},
20340 @code{httpd-config-file} and @code{httpd-virtualhost} record types are
20341 given below.
20342
20343 @deffn {Data Type} httpd-configuration
20344 This data type represents the configuration for the httpd service.
20345
20346 @table @asis
20347 @item @code{package} (default: @code{httpd})
20348 The httpd package to use.
20349
20350 @item @code{pid-file} (default: @code{"/var/run/httpd"})
20351 The pid file used by the shepherd-service.
20352
20353 @item @code{config} (default: @code{(httpd-config-file)})
20354 The configuration file to use with the httpd service. The default value
20355 is a @code{httpd-config-file} record, but this can also be a different
20356 G-expression that generates a file, for example a @code{plain-file}. A
20357 file outside of the store can also be specified through a string.
20358
20359 @end table
20360 @end deffn
20361
20362 @deffn {Data Type} httpd-module
20363 This data type represents a module for the httpd service.
20364
20365 @table @asis
20366 @item @code{name}
20367 The name of the module.
20368
20369 @item @code{file}
20370 The file for the module. This can be relative to the httpd package being
20371 used, the absolute location of a file, or a G-expression for a file
20372 within the store, for example @code{(file-append mod-wsgi
20373 "/modules/mod_wsgi.so")}.
20374
20375 @end table
20376 @end deffn
20377
20378 @defvr {Scheme Variable} %default-httpd-modules
20379 A default list of @code{httpd-module} objects.
20380 @end defvr
20381
20382 @deffn {Data Type} httpd-config-file
20383 This data type represents a configuration file for the httpd service.
20384
20385 @table @asis
20386 @item @code{modules} (default: @code{%default-httpd-modules})
20387 The modules to load. Additional modules can be added here, or loaded by
20388 additional configuration.
20389
20390 For example, in order to handle requests for PHP files, you can use Apache’s
20391 @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
20392
20393 @lisp
20394 (service httpd-service-type
20395 (httpd-configuration
20396 (config
20397 (httpd-config-file
20398 (modules (cons*
20399 (httpd-module
20400 (name "proxy_module")
20401 (file "modules/mod_proxy.so"))
20402 (httpd-module
20403 (name "proxy_fcgi_module")
20404 (file "modules/mod_proxy_fcgi.so"))
20405 %default-httpd-modules))
20406 (extra-config (list "\
20407 <FilesMatch \\.php$>
20408 SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
20409 </FilesMatch>"))))))
20410 (service php-fpm-service-type
20411 (php-fpm-configuration
20412 (socket "/var/run/php-fpm.sock")
20413 (socket-group "httpd")))
20414 @end lisp
20415
20416 @item @code{server-root} (default: @code{httpd})
20417 The @code{ServerRoot} in the configuration file, defaults to the httpd
20418 package. Directives including @code{Include} and @code{LoadModule} are
20419 taken as relative to the server root.
20420
20421 @item @code{server-name} (default: @code{#f})
20422 The @code{ServerName} in the configuration file, used to specify the
20423 request scheme, hostname and port that the server uses to identify
20424 itself.
20425
20426 This doesn't need to be set in the server config, and can be specified
20427 in virtual hosts. The default is @code{#f} to not specify a
20428 @code{ServerName}.
20429
20430 @item @code{document-root} (default: @code{"/srv/http"})
20431 The @code{DocumentRoot} from which files will be served.
20432
20433 @item @code{listen} (default: @code{'("80")})
20434 The list of values for the @code{Listen} directives in the config
20435 file. The value should be a list of strings, when each string can
20436 specify the port number to listen on, and optionally the IP address and
20437 protocol to use.
20438
20439 @item @code{pid-file} (default: @code{"/var/run/httpd"})
20440 The @code{PidFile} to use. This should match the @code{pid-file} set in
20441 the @code{httpd-configuration} so that the Shepherd service is
20442 configured correctly.
20443
20444 @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
20445 The @code{ErrorLog} to which the server will log errors.
20446
20447 @item @code{user} (default: @code{"httpd"})
20448 The @code{User} which the server will answer requests as.
20449
20450 @item @code{group} (default: @code{"httpd"})
20451 The @code{Group} which the server will answer requests as.
20452
20453 @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
20454 A flat list of strings and G-expressions which will be added to the end
20455 of the configuration file.
20456
20457 Any values which the service is extended with will be appended to this
20458 list.
20459
20460 @end table
20461 @end deffn
20462
20463 @deffn {Data Type} httpd-virtualhost
20464 This data type represents a virtualhost configuration block for the httpd service.
20465
20466 These should be added to the extra-config for the httpd-service.
20467
20468 @lisp
20469 (simple-service 'www.example.com-server httpd-service-type
20470 (list
20471 (httpd-virtualhost
20472 "*:80"
20473 (list (string-join '("ServerName www.example.com"
20474 "DocumentRoot /srv/http/www.example.com")
20475 "\n")))))
20476 @end lisp
20477
20478 @table @asis
20479 @item @code{addresses-and-ports}
20480 The addresses and ports for the @code{VirtualHost} directive.
20481
20482 @item @code{contents}
20483 The contents of the @code{VirtualHost} directive, this should be a list
20484 of strings and G-expressions.
20485
20486 @end table
20487 @end deffn
20488
20489 @subsubheading NGINX
20490
20491 @deffn {Scheme Variable} nginx-service-type
20492 Service type for the @uref{https://nginx.org/,NGinx} web server. The
20493 value for this service type is a @code{<nginx-configuration>} record.
20494
20495 A simple example configuration is given below.
20496
20497 @lisp
20498 (service nginx-service-type
20499 (nginx-configuration
20500 (server-blocks
20501 (list (nginx-server-configuration
20502 (server-name '("www.example.com"))
20503 (root "/srv/http/www.example.com"))))))
20504 @end lisp
20505
20506 In addition to adding server blocks to the service configuration
20507 directly, this service can be extended by other services to add server
20508 blocks, as in this example:
20509
20510 @lisp
20511 (simple-service 'my-extra-server nginx-service-type
20512 (list (nginx-server-configuration
20513 (root "/srv/http/extra-website")
20514 (try-files (list "$uri" "$uri/index.html")))))
20515 @end lisp
20516 @end deffn
20517
20518 At startup, @command{nginx} has not yet read its configuration file, so
20519 it uses a default file to log error messages. If it fails to load its
20520 configuration file, that is where error messages are logged. After the
20521 configuration file is loaded, the default error log file changes as per
20522 configuration. In our case, startup error messages can be found in
20523 @file{/var/run/nginx/logs/error.log}, and after configuration in
20524 @file{/var/log/nginx/error.log}. The second location can be changed
20525 with the @var{log-directory} configuration option.
20526
20527 @deffn {Data Type} nginx-configuration
20528 This data type represents the configuration for NGinx. Some
20529 configuration can be done through this and the other provided record
20530 types, or alternatively, a config file can be provided.
20531
20532 @table @asis
20533 @item @code{nginx} (default: @code{nginx})
20534 The nginx package to use.
20535
20536 @item @code{log-directory} (default: @code{"/var/log/nginx"})
20537 The directory to which NGinx will write log files.
20538
20539 @item @code{run-directory} (default: @code{"/var/run/nginx"})
20540 The directory in which NGinx will create a pid file, and write temporary
20541 files.
20542
20543 @item @code{server-blocks} (default: @code{'()})
20544 A list of @dfn{server blocks} to create in the generated configuration
20545 file, the elements should be of type
20546 @code{<nginx-server-configuration>}.
20547
20548 The following example would setup NGinx to serve @code{www.example.com}
20549 from the @code{/srv/http/www.example.com} directory, without using
20550 HTTPS.
20551 @lisp
20552 (service nginx-service-type
20553 (nginx-configuration
20554 (server-blocks
20555 (list (nginx-server-configuration
20556 (server-name '("www.example.com"))
20557 (root "/srv/http/www.example.com"))))))
20558 @end lisp
20559
20560 @item @code{upstream-blocks} (default: @code{'()})
20561 A list of @dfn{upstream blocks} to create in the generated configuration
20562 file, the elements should be of type
20563 @code{<nginx-upstream-configuration>}.
20564
20565 Configuring upstreams through the @code{upstream-blocks} can be useful
20566 when combined with @code{locations} in the
20567 @code{<nginx-server-configuration>} records. The following example
20568 creates a server configuration with one location configuration, that
20569 will proxy requests to a upstream configuration, which will handle
20570 requests with two servers.
20571
20572 @lisp
20573 (service
20574 nginx-service-type
20575 (nginx-configuration
20576 (server-blocks
20577 (list (nginx-server-configuration
20578 (server-name '("www.example.com"))
20579 (root "/srv/http/www.example.com")
20580 (locations
20581 (list
20582 (nginx-location-configuration
20583 (uri "/path1")
20584 (body '("proxy_pass http://server-proxy;"))))))))
20585 (upstream-blocks
20586 (list (nginx-upstream-configuration
20587 (name "server-proxy")
20588 (servers (list "server1.example.com"
20589 "server2.example.com")))))))
20590 @end lisp
20591
20592 @item @code{file} (default: @code{#f})
20593 If a configuration @var{file} is provided, this will be used, rather than
20594 generating a configuration file from the provided @code{log-directory},
20595 @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
20596 proper operation, these arguments should match what is in @var{file} to ensure
20597 that the directories are created when the service is activated.
20598
20599 This can be useful if you have an existing configuration file, or it's
20600 not possible to do what is required through the other parts of the
20601 nginx-configuration record.
20602
20603 @item @code{server-names-hash-bucket-size} (default: @code{#f})
20604 Bucket size for the server names hash tables, defaults to @code{#f} to
20605 use the size of the processors cache line.
20606
20607 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
20608 Maximum bucket size for the server names hash tables.
20609
20610 @item @code{modules} (default: @code{'()})
20611 List of nginx dynamic modules to load. This should be a list of file
20612 names of loadable modules, as in this example:
20613
20614 @lisp
20615 (modules
20616 (list
20617 (file-append nginx-accept-language-module "\
20618 /etc/nginx/modules/ngx_http_accept_language_module.so")))
20619 @end lisp
20620
20621 @item @code{global-directives} (default: @code{'((events . ()))})
20622 Association list of global directives for the top level of the nginx
20623 configuration. Values may themselves be association lists.
20624
20625 @lisp
20626 (global-directives
20627 `((worker_processes . 16)
20628 (pcre_jit . on)
20629 (events . ((worker_connections . 1024)))))
20630 @end lisp
20631
20632 @item @code{extra-content} (default: @code{""})
20633 Extra content for the @code{http} block. Should be string or a string
20634 valued G-expression.
20635
20636 @end table
20637 @end deffn
20638
20639 @deftp {Data Type} nginx-server-configuration
20640 Data type representing the configuration of an nginx server block.
20641 This type has the following parameters:
20642
20643 @table @asis
20644 @item @code{listen} (default: @code{'("80" "443 ssl")})
20645 Each @code{listen} directive sets the address and port for IP, or the
20646 path for a UNIX-domain socket on which the server will accept requests.
20647 Both address and port, or only address or only port can be specified.
20648 An address may also be a hostname, for example:
20649
20650 @lisp
20651 '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
20652 @end lisp
20653
20654 @item @code{server-name} (default: @code{(list 'default)})
20655 A list of server names this server represents. @code{'default} represents the
20656 default server for connections matching no other server.
20657
20658 @item @code{root} (default: @code{"/srv/http"})
20659 Root of the website nginx will serve.
20660
20661 @item @code{locations} (default: @code{'()})
20662 A list of @dfn{nginx-location-configuration} or
20663 @dfn{nginx-named-location-configuration} records to use within this
20664 server block.
20665
20666 @item @code{index} (default: @code{(list "index.html")})
20667 Index files to look for when clients ask for a directory. If it cannot be found,
20668 Nginx will send the list of files in the directory.
20669
20670 @item @code{try-files} (default: @code{'()})
20671 A list of files whose existence is checked in the specified order.
20672 @code{nginx} will use the first file it finds to process the request.
20673
20674 @item @code{ssl-certificate} (default: @code{#f})
20675 Where to find the certificate for secure connections. Set it to @code{#f} if
20676 you don't have a certificate or you don't want to use HTTPS.
20677
20678 @item @code{ssl-certificate-key} (default: @code{#f})
20679 Where to find the private key for secure connections. Set it to @code{#f} if
20680 you don't have a key or you don't want to use HTTPS.
20681
20682 @item @code{server-tokens?} (default: @code{#f})
20683 Whether the server should add its configuration to response.
20684
20685 @item @code{raw-content} (default: @code{'()})
20686 A list of raw lines added to the server block.
20687
20688 @end table
20689 @end deftp
20690
20691 @deftp {Data Type} nginx-upstream-configuration
20692 Data type representing the configuration of an nginx @code{upstream}
20693 block. This type has the following parameters:
20694
20695 @table @asis
20696 @item @code{name}
20697 Name for this group of servers.
20698
20699 @item @code{servers}
20700 Specify the addresses of the servers in the group. The address can be
20701 specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
20702 (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
20703 prefix @samp{unix:}. For addresses using an IP address or domain name,
20704 the default port is 80, and a different port can be specified
20705 explicitly.
20706
20707 @end table
20708 @end deftp
20709
20710 @deftp {Data Type} nginx-location-configuration
20711 Data type representing the configuration of an nginx @code{location}
20712 block. This type has the following parameters:
20713
20714 @table @asis
20715 @item @code{uri}
20716 URI which this location block matches.
20717
20718 @anchor{nginx-location-configuration body}
20719 @item @code{body}
20720 Body of the location block, specified as a list of strings. This can contain
20721 many
20722 configuration directives. For example, to pass requests to a upstream
20723 server group defined using an @code{nginx-upstream-configuration} block,
20724 the following directive would be specified in the body @samp{(list "proxy_pass
20725 http://upstream-name;")}.
20726
20727 @end table
20728 @end deftp
20729
20730 @deftp {Data Type} nginx-named-location-configuration
20731 Data type representing the configuration of an nginx named location
20732 block. Named location blocks are used for request redirection, and not
20733 used for regular request processing. This type has the following
20734 parameters:
20735
20736 @table @asis
20737 @item @code{name}
20738 Name to identify this location block.
20739
20740 @item @code{body}
20741 @xref{nginx-location-configuration body}, as the body for named location
20742 blocks can be used in a similar way to the
20743 @code{nginx-location-configuration body}. One restriction is that the
20744 body of a named location block cannot contain location blocks.
20745
20746 @end table
20747 @end deftp
20748
20749 @subsubheading Varnish Cache
20750 @cindex Varnish
20751 Varnish is a fast cache server that sits in between web applications
20752 and end users. It proxies requests from clients and caches the
20753 accessed URLs such that multiple requests for the same resource only
20754 creates one request to the back-end.
20755
20756 @defvr {Scheme Variable} varnish-service-type
20757 Service type for the Varnish daemon.
20758 @end defvr
20759
20760 @deftp {Data Type} varnish-configuration
20761 Data type representing the @code{varnish} service configuration.
20762 This type has the following parameters:
20763
20764 @table @asis
20765 @item @code{package} (default: @code{varnish})
20766 The Varnish package to use.
20767
20768 @item @code{name} (default: @code{"default"})
20769 A name for this Varnish instance. Varnish will create a directory in
20770 @file{/var/varnish/} with this name and keep temporary files there. If
20771 the name starts with a forward slash, it is interpreted as an absolute
20772 directory name.
20773
20774 Pass the @code{-n} argument to other Varnish programs to connect to the
20775 named instance, e.g.@: @command{varnishncsa -n default}.
20776
20777 @item @code{backend} (default: @code{"localhost:8080"})
20778 The backend to use. This option has no effect if @code{vcl} is set.
20779
20780 @item @code{vcl} (default: #f)
20781 The @dfn{VCL} (Varnish Configuration Language) program to run. If this
20782 is @code{#f}, Varnish will proxy @code{backend} using the default
20783 configuration. Otherwise this must be a file-like object with valid
20784 VCL syntax.
20785
20786 @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
20787 For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
20788 can do something along these lines:
20789
20790 @lisp
20791 (define %gnu-mirror
20792 (plain-file "gnu.vcl"
20793 "vcl 4.1;
20794 backend gnu @{ .host = \"www.gnu.org\"; @}"))
20795
20796 (operating-system
20797 ;; @dots{}
20798 (services (cons (service varnish-service-type
20799 (varnish-configuration
20800 (listen '(":80"))
20801 (vcl %gnu-mirror)))
20802 %base-services)))
20803 @end lisp
20804
20805 The configuration of an already running Varnish instance can be inspected
20806 and changed using the @command{varnishadm} program.
20807
20808 Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
20809 @url{https://book.varnish-software.com/4.0/,Varnish Book} for
20810 comprehensive documentation on Varnish and its configuration language.
20811
20812 @item @code{listen} (default: @code{'("localhost:80")})
20813 List of addresses Varnish will listen on.
20814
20815 @item @code{storage} (default: @code{'("malloc,128m")})
20816 List of storage backends that will be available in VCL.
20817
20818 @item @code{parameters} (default: @code{'()})
20819 List of run-time parameters in the form @code{'(("parameter" . "value"))}.
20820
20821 @item @code{extra-options} (default: @code{'()})
20822 Additional arguments to pass to the @command{varnishd} process.
20823
20824 @end table
20825 @end deftp
20826
20827 @subsubheading Patchwork
20828 @cindex Patchwork
20829 Patchwork is a patch tracking system. It can collect patches sent to a
20830 mailing list, and display them in a web interface.
20831
20832 @defvr {Scheme Variable} patchwork-service-type
20833 Service type for Patchwork.
20834 @end defvr
20835
20836 The following example is an example of a minimal service for Patchwork, for
20837 the @code{patchwork.example.com} domain.
20838
20839 @lisp
20840 (service patchwork-service-type
20841 (patchwork-configuration
20842 (domain "patchwork.example.com")
20843 (settings-module
20844 (patchwork-settings-module
20845 (allowed-hosts (list domain))
20846 (default-from-email "patchwork@@patchwork.example.com")))
20847 (getmail-retriever-config
20848 (getmail-retriever-configuration
20849 (type "SimpleIMAPSSLRetriever")
20850 (server "imap.example.com")
20851 (port 993)
20852 (username "patchwork")
20853 (password-command
20854 (list (file-append coreutils "/bin/cat")
20855 "/etc/getmail-patchwork-imap-password"))
20856 (extra-parameters
20857 '((mailboxes . ("Patches"))))))))
20858
20859 @end lisp
20860
20861 There are three records for configuring the Patchwork service. The
20862 @code{<patchwork-configuration>} relates to the configuration for Patchwork
20863 within the HTTPD service.
20864
20865 The @code{settings-module} field within the @code{<patchwork-configuration>}
20866 record can be populated with the @code{<patchwork-settings-module>} record,
20867 which describes a settings module that is generated within the Guix store.
20868
20869 For the @code{database-configuration} field within the
20870 @code{<patchwork-settings-module>}, the
20871 @code{<patchwork-database-configuration>} must be used.
20872
20873 @deftp {Data Type} patchwork-configuration
20874 Data type representing the Patchwork service configuration. This type has the
20875 following parameters:
20876
20877 @table @asis
20878 @item @code{patchwork} (default: @code{patchwork})
20879 The Patchwork package to use.
20880
20881 @item @code{domain}
20882 The domain to use for Patchwork, this is used in the HTTPD service virtual
20883 host.
20884
20885 @item @code{settings-module}
20886 The settings module to use for Patchwork. As a Django application, Patchwork
20887 is configured with a Python module containing the settings. This can either be
20888 an instance of the @code{<patchwork-settings-module>} record, any other record
20889 that represents the settings in the store, or a directory outside of the
20890 store.
20891
20892 @item @code{static-path} (default: @code{"/static/"})
20893 The path under which the HTTPD service should serve the static files.
20894
20895 @item @code{getmail-retriever-config}
20896 The getmail-retriever-configuration record value to use with
20897 Patchwork. Getmail will be configured with this value, the messages will be
20898 delivered to Patchwork.
20899
20900 @end table
20901 @end deftp
20902
20903 @deftp {Data Type} patchwork-settings-module
20904 Data type representing a settings module for Patchwork. Some of these
20905 settings relate directly to Patchwork, but others relate to Django, the web
20906 framework used by Patchwork, or the Django Rest Framework library. This type
20907 has the following parameters:
20908
20909 @table @asis
20910 @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
20911 The database connection settings used for Patchwork. See the
20912 @code{<patchwork-database-configuration>} record type for more information.
20913
20914 @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
20915 Patchwork, as a Django web application uses a secret key for cryptographically
20916 signing values. This file should contain a unique unpredictable value.
20917
20918 If this file does not exist, it will be created and populated with a random
20919 value by the patchwork-setup shepherd service.
20920
20921 This setting relates to Django.
20922
20923 @item @code{allowed-hosts}
20924 A list of valid hosts for this Patchwork service. This should at least include
20925 the domain specified in the @code{<patchwork-configuration>} record.
20926
20927 This is a Django setting.
20928
20929 @item @code{default-from-email}
20930 The email address from which Patchwork should send email by default.
20931
20932 This is a Patchwork setting.
20933
20934 @item @code{static-url} (default: @code{#f})
20935 The URL to use when serving static assets. It can be part of a URL, or a full
20936 URL, but must end in a @code{/}.
20937
20938 If the default value is used, the @code{static-path} value from the
20939 @code{<patchwork-configuration>} record will be used.
20940
20941 This is a Django setting.
20942
20943 @item @code{admins} (default: @code{'()})
20944 Email addresses to send the details of errors that occur. Each value should
20945 be a list containing two elements, the name and then the email address.
20946
20947 This is a Django setting.
20948
20949 @item @code{debug?} (default: @code{#f})
20950 Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
20951 messages will be shown.
20952
20953 This is a Django setting.
20954
20955 @item @code{enable-rest-api?} (default: @code{#t})
20956 Whether to enable the Patchwork REST API.
20957
20958 This is a Patchwork setting.
20959
20960 @item @code{enable-xmlrpc?} (default: @code{#t})
20961 Whether to enable the XML RPC API.
20962
20963 This is a Patchwork setting.
20964
20965 @item @code{force-https-links?} (default: @code{#t})
20966 Whether to use HTTPS links on Patchwork pages.
20967
20968 This is a Patchwork setting.
20969
20970 @item @code{extra-settings} (default: @code{""})
20971 Extra code to place at the end of the Patchwork settings module.
20972
20973 @end table
20974 @end deftp
20975
20976 @deftp {Data Type} patchwork-database-configuration
20977 Data type representing the database configuration for Patchwork.
20978
20979 @table @asis
20980 @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
20981 The database engine to use.
20982
20983 @item @code{name} (default: @code{"patchwork"})
20984 The name of the database to use.
20985
20986 @item @code{user} (default: @code{"httpd"})
20987 The user to connect to the database as.
20988
20989 @item @code{password} (default: @code{""})
20990 The password to use when connecting to the database.
20991
20992 @item @code{host} (default: @code{""})
20993 The host to make the database connection to.
20994
20995 @item @code{port} (default: @code{""})
20996 The port on which to connect to the database.
20997
20998 @end table
20999 @end deftp
21000
21001 @subsubheading Mumi
21002
21003 @cindex Mumi, Debbugs Web interface
21004 @cindex Debbugs, Mumi Web interface
21005 @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
21006 Web interface to the Debbugs bug tracker, by default for
21007 @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
21008 but it also fetches and indexes mail retrieved from Debbugs.
21009
21010 @defvr {Scheme Variable} mumi-service-type
21011 This is the service type for Mumi.
21012 @end defvr
21013
21014 @deftp {Data Type} mumi-configuration
21015 Data type representing the Mumi service configuration. This type has the
21016 following fields:
21017
21018 @table @asis
21019 @item @code{mumi} (default: @code{mumi})
21020 The Mumi package to use.
21021
21022 @item @code{mailer?} (default: @code{#true})
21023 Whether to enable or disable the mailer component.
21024
21025 @item @code{mumi-configuration-sender}
21026 The email address used as the sender for comments.
21027
21028 @item @code{mumi-configuration-smtp}
21029 A URI to configure the SMTP settings for Mailutils. This could be
21030 something like @code{sendmail:///path/to/bin/msmtp} or any other URI
21031 supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
21032 mailutils, GNU@tie{}Mailutils}.
21033
21034 @end table
21035 @end deftp
21036
21037
21038 @subsubheading FastCGI
21039 @cindex fastcgi
21040 @cindex fcgiwrap
21041 FastCGI is an interface between the front-end and the back-end of a web
21042 service. It is a somewhat legacy facility; new web services should
21043 generally just talk HTTP between the front-end and the back-end.
21044 However there are a number of back-end services such as PHP or the
21045 optimized HTTP Git repository access that use FastCGI, so we have
21046 support for it in Guix.
21047
21048 To use FastCGI, you configure the front-end web server (e.g., nginx) to
21049 dispatch some subset of its requests to the fastcgi backend, which
21050 listens on a local TCP or UNIX socket. There is an intermediary
21051 @code{fcgiwrap} program that sits between the actual backend process and
21052 the web server. The front-end indicates which backend program to run,
21053 passing that information to the @code{fcgiwrap} process.
21054
21055 @defvr {Scheme Variable} fcgiwrap-service-type
21056 A service type for the @code{fcgiwrap} FastCGI proxy.
21057 @end defvr
21058
21059 @deftp {Data Type} fcgiwrap-configuration
21060 Data type representing the configuration of the @code{fcgiwrap} service.
21061 This type has the following parameters:
21062 @table @asis
21063 @item @code{package} (default: @code{fcgiwrap})
21064 The fcgiwrap package to use.
21065
21066 @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
21067 The socket on which the @code{fcgiwrap} process should listen, as a
21068 string. Valid @var{socket} values include
21069 @code{unix:@var{/path/to/unix/socket}},
21070 @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
21071 @code{tcp6:[@var{ipv6_addr}]:port}.
21072
21073 @item @code{user} (default: @code{fcgiwrap})
21074 @itemx @code{group} (default: @code{fcgiwrap})
21075 The user and group names, as strings, under which to run the
21076 @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
21077 the user asks for the specific user or group names @code{fcgiwrap} that
21078 the corresponding user and/or group is present on the system.
21079
21080 It is possible to configure a FastCGI-backed web service to pass HTTP
21081 authentication information from the front-end to the back-end, and to
21082 allow @code{fcgiwrap} to run the back-end process as a corresponding
21083 local user. To enable this capability on the back-end, run
21084 @code{fcgiwrap} as the @code{root} user and group. Note that this
21085 capability also has to be configured on the front-end as well.
21086 @end table
21087 @end deftp
21088
21089 @cindex php-fpm
21090 PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
21091 with some additional features useful for sites of any size.
21092
21093 These features include:
21094 @itemize @bullet
21095 @item Adaptive process spawning
21096 @item Basic statistics (similar to Apache's mod_status)
21097 @item Advanced process management with graceful stop/start
21098 @item Ability to start workers with different uid/gid/chroot/environment
21099 and different php.ini (replaces safe_mode)
21100 @item Stdout & stderr logging
21101 @item Emergency restart in case of accidental opcode cache destruction
21102 @item Accelerated upload support
21103 @item Support for a "slowlog"
21104 @item Enhancements to FastCGI, such as fastcgi_finish_request() -
21105 a special function to finish request & flush all data while continuing to do
21106 something time-consuming (video converting, stats processing, etc.)
21107 @end itemize
21108 ...@: and much more.
21109
21110 @defvr {Scheme Variable} php-fpm-service-type
21111 A Service type for @code{php-fpm}.
21112 @end defvr
21113
21114 @deftp {Data Type} php-fpm-configuration
21115 Data Type for php-fpm service configuration.
21116 @table @asis
21117 @item @code{php} (default: @code{php})
21118 The php package to use.
21119 @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
21120 The address on which to accept FastCGI requests. Valid syntaxes are:
21121 @table @asis
21122 @item @code{"ip.add.re.ss:port"}
21123 Listen on a TCP socket to a specific address on a specific port.
21124 @item @code{"port"}
21125 Listen on a TCP socket to all addresses on a specific port.
21126 @item @code{"/path/to/unix/socket"}
21127 Listen on a unix socket.
21128 @end table
21129
21130 @item @code{user} (default: @code{php-fpm})
21131 User who will own the php worker processes.
21132 @item @code{group} (default: @code{php-fpm})
21133 Group of the worker processes.
21134 @item @code{socket-user} (default: @code{php-fpm})
21135 User who can speak to the php-fpm socket.
21136 @item @code{socket-group} (default: @code{nginx})
21137 Group that can speak to the php-fpm socket.
21138 @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
21139 The process id of the php-fpm process is written to this file
21140 once the service has started.
21141 @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
21142 Log for the php-fpm master process.
21143 @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
21144 Detailed settings for the php-fpm process manager.
21145 Must be one of:
21146 @table @asis
21147 @item @code{<php-fpm-dynamic-process-manager-configuration>}
21148 @item @code{<php-fpm-static-process-manager-configuration>}
21149 @item @code{<php-fpm-on-demand-process-manager-configuration>}
21150 @end table
21151 @item @code{display-errors} (default @code{#f})
21152 Determines whether php errors and warning should be sent to clients
21153 and displayed in their browsers.
21154 This is useful for local php development, but a security risk for public sites,
21155 as error messages can reveal passwords and personal data.
21156 @item @code{timezone} (default @code{#f})
21157 Specifies @code{php_admin_value[date.timezone]} parameter.
21158 @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
21159 This file will log the @code{stderr} outputs of php worker processes.
21160 Can be set to @code{#f} to disable logging.
21161 @item @code{file} (default @code{#f})
21162 An optional override of the whole configuration.
21163 You can use the @code{mixed-text-file} function or an absolute filepath for it.
21164 @end table
21165 @end deftp
21166
21167 @deftp {Data type} php-fpm-dynamic-process-manager-configuration
21168 Data Type for the @code{dynamic} php-fpm process manager. With the
21169 @code{dynamic} process manager, spare worker processes are kept around
21170 based on it's configured limits.
21171 @table @asis
21172 @item @code{max-children} (default: @code{5})
21173 Maximum of worker processes.
21174 @item @code{start-servers} (default: @code{2})
21175 How many worker processes should be started on start-up.
21176 @item @code{min-spare-servers} (default: @code{1})
21177 How many spare worker processes should be kept around at minimum.
21178 @item @code{max-spare-servers} (default: @code{3})
21179 How many spare worker processes should be kept around at maximum.
21180 @end table
21181 @end deftp
21182
21183 @deftp {Data type} php-fpm-static-process-manager-configuration
21184 Data Type for the @code{static} php-fpm process manager. With the
21185 @code{static} process manager, an unchanging number of worker processes
21186 are created.
21187 @table @asis
21188 @item @code{max-children} (default: @code{5})
21189 Maximum of worker processes.
21190 @end table
21191 @end deftp
21192
21193 @deftp {Data type} php-fpm-on-demand-process-manager-configuration
21194 Data Type for the @code{on-demand} php-fpm process manager. With the
21195 @code{on-demand} process manager, worker processes are only created as
21196 requests arrive.
21197 @table @asis
21198 @item @code{max-children} (default: @code{5})
21199 Maximum of worker processes.
21200 @item @code{process-idle-timeout} (default: @code{10})
21201 The time in seconds after which a process with no requests is killed.
21202 @end table
21203 @end deftp
21204
21205
21206 @deffn {Scheme Procedure} nginx-php-location @
21207 [#:nginx-package nginx] @
21208 [socket (string-append "/var/run/php" @
21209 (version-major (package-version php)) @
21210 "-fpm.sock")]
21211 A helper function to quickly add php to an @code{nginx-server-configuration}.
21212 @end deffn
21213
21214 A simple services setup for nginx with php can look like this:
21215 @lisp
21216 (services (cons* (service dhcp-client-service-type)
21217 (service php-fpm-service-type)
21218 (service nginx-service-type
21219 (nginx-server-configuration
21220 (server-name '("example.com"))
21221 (root "/srv/http/")
21222 (locations
21223 (list (nginx-php-location)))
21224 (listen '("80"))
21225 (ssl-certificate #f)
21226 (ssl-certificate-key #f)))
21227 %base-services))
21228 @end lisp
21229
21230 @cindex cat-avatar-generator
21231 The cat avatar generator is a simple service to demonstrate the use of php-fpm
21232 in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
21233 the hash of a user's email address.
21234
21235 @deffn {Scheme Procedure} cat-avatar-generator-service @
21236 [#:cache-dir "/var/cache/cat-avatar-generator"] @
21237 [#:package cat-avatar-generator] @
21238 [#:configuration (nginx-server-configuration)]
21239 Returns an nginx-server-configuration that inherits @code{configuration}. It
21240 extends the nginx configuration to add a server block that serves @code{package},
21241 a version of cat-avatar-generator. During execution, cat-avatar-generator will
21242 be able to use @code{cache-dir} as its cache directory.
21243 @end deffn
21244
21245 A simple setup for cat-avatar-generator can look like this:
21246 @lisp
21247 (services (cons* (cat-avatar-generator-service
21248 #:configuration
21249 (nginx-server-configuration
21250 (server-name '("example.com"))))
21251 ...
21252 %base-services))
21253 @end lisp
21254
21255 @subsubheading Hpcguix-web
21256
21257 @cindex hpcguix-web
21258 The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
21259 program is a customizable web interface to browse Guix packages,
21260 initially designed for users of high-performance computing (HPC)
21261 clusters.
21262
21263 @defvr {Scheme Variable} hpcguix-web-service-type
21264 The service type for @code{hpcguix-web}.
21265 @end defvr
21266
21267 @deftp {Data Type} hpcguix-web-configuration
21268 Data type for the hpcguix-web service configuration.
21269
21270 @table @asis
21271 @item @code{specs}
21272 A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
21273 configuration. The main items available in this spec are:
21274
21275 @table @asis
21276 @item @code{title-prefix} (default: @code{"hpcguix | "})
21277 The page title prefix.
21278
21279 @item @code{guix-command} (default: @code{"guix"})
21280 The @command{guix} command.
21281
21282 @item @code{package-filter-proc} (default: @code{(const #t)})
21283 A procedure specifying how to filter packages that are displayed.
21284
21285 @item @code{package-page-extension-proc} (default: @code{(const '())})
21286 Extension package for @code{hpcguix-web}.
21287
21288 @item @code{menu} (default: @code{'()})
21289 Additional entry in page @code{menu}.
21290
21291 @item @code{channels} (default: @code{%default-channels})
21292 List of channels from which the package list is built (@pxref{Channels}).
21293
21294 @item @code{package-list-expiration} (default: @code{(* 12 3600)})
21295 The expiration time, in seconds, after which the package list is rebuilt from
21296 the latest instances of the given channels.
21297 @end table
21298
21299 See the hpcguix-web repository for a
21300 @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
21301 complete example}.
21302
21303 @item @code{package} (default: @code{hpcguix-web})
21304 The hpcguix-web package to use.
21305 @end table
21306 @end deftp
21307
21308 A typical hpcguix-web service declaration looks like this:
21309
21310 @lisp
21311 (service hpcguix-web-service-type
21312 (hpcguix-web-configuration
21313 (specs
21314 #~(define site-config
21315 (hpcweb-configuration
21316 (title-prefix "Guix-HPC - ")
21317 (menu '(("/about" "ABOUT"))))))))
21318 @end lisp
21319
21320 @quotation Note
21321 The hpcguix-web service periodically updates the package list it publishes by
21322 pulling channels from Git. To that end, it needs to access X.509 certificates
21323 so that it can authenticate Git servers when communicating over HTTPS, and it
21324 assumes that @file{/etc/ssl/certs} contains those certificates.
21325
21326 Thus, make sure to add @code{nss-certs} or another certificate package to the
21327 @code{packages} field of your configuration. @ref{X.509 Certificates}, for
21328 more information on X.509 certificates.
21329 @end quotation
21330
21331 @node Certificate Services
21332 @subsection Certificate Services
21333
21334 @cindex Web
21335 @cindex HTTP, HTTPS
21336 @cindex Let's Encrypt
21337 @cindex TLS certificates
21338 The @code{(gnu services certbot)} module provides a service to
21339 automatically obtain a valid TLS certificate from the Let's Encrypt
21340 certificate authority. These certificates can then be used to serve
21341 content securely over HTTPS or other TLS-based protocols, with the
21342 knowledge that the client will be able to verify the server's
21343 authenticity.
21344
21345 @url{https://letsencrypt.org/, Let's Encrypt} provides the
21346 @code{certbot} tool to automate the certification process. This tool
21347 first securely generates a key on the server. It then makes a request
21348 to the Let's Encrypt certificate authority (CA) to sign the key. The CA
21349 checks that the request originates from the host in question by using a
21350 challenge-response protocol, requiring the server to provide its
21351 response over HTTP. If that protocol completes successfully, the CA
21352 signs the key, resulting in a certificate. That certificate is valid
21353 for a limited period of time, and therefore to continue to provide TLS
21354 services, the server needs to periodically ask the CA to renew its
21355 signature.
21356
21357 The certbot service automates this process: the initial key
21358 generation, the initial certification request to the Let's Encrypt
21359 service, the web server challenge/response integration, writing the
21360 certificate to disk, the automated periodic renewals, and the deployment
21361 tasks associated with the renewal (e.g.@: reloading services, copying keys
21362 with different permissions).
21363
21364 Certbot is run twice a day, at a random minute within the hour. It
21365 won't do anything until your certificates are due for renewal or
21366 revoked, but running it regularly would give your service a chance of
21367 staying online in case a Let's Encrypt-initiated revocation happened for
21368 some reason.
21369
21370 By using this service, you agree to the ACME Subscriber Agreement, which
21371 can be found there:
21372 @url{https://acme-v01.api.letsencrypt.org/directory}.
21373
21374 @defvr {Scheme Variable} certbot-service-type
21375 A service type for the @code{certbot} Let's Encrypt client. Its value
21376 must be a @code{certbot-configuration} record as in this example:
21377
21378 @lisp
21379 (define %nginx-deploy-hook
21380 (program-file
21381 "nginx-deploy-hook"
21382 #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
21383 (kill pid SIGHUP))))
21384
21385 (service certbot-service-type
21386 (certbot-configuration
21387 (email "foo@@example.net")
21388 (certificates
21389 (list
21390 (certificate-configuration
21391 (domains '("example.net" "www.example.net"))
21392 (deploy-hook %nginx-deploy-hook))
21393 (certificate-configuration
21394 (domains '("bar.example.net")))))))
21395 @end lisp
21396
21397 See below for details about @code{certbot-configuration}.
21398 @end defvr
21399
21400 @deftp {Data Type} certbot-configuration
21401 Data type representing the configuration of the @code{certbot} service.
21402 This type has the following parameters:
21403
21404 @table @asis
21405 @item @code{package} (default: @code{certbot})
21406 The certbot package to use.
21407
21408 @item @code{webroot} (default: @code{/var/www})
21409 The directory from which to serve the Let's Encrypt challenge/response
21410 files.
21411
21412 @item @code{certificates} (default: @code{()})
21413 A list of @code{certificates-configuration}s for which to generate
21414 certificates and request signatures. Each certificate has a @code{name}
21415 and several @code{domains}.
21416
21417 @item @code{email}
21418 Mandatory email used for registration, recovery contact, and important
21419 account notifications.
21420
21421 @item @code{server} (default: @code{#f})
21422 Optional URL of ACME server. Setting this overrides certbot's default,
21423 which is the Let's Encrypt server.
21424
21425 @item @code{rsa-key-size} (default: @code{2048})
21426 Size of the RSA key.
21427
21428 @item @code{default-location} (default: @i{see below})
21429 The default @code{nginx-location-configuration}. Because @code{certbot}
21430 needs to be able to serve challenges and responses, it needs to be able
21431 to run a web server. It does so by extending the @code{nginx} web
21432 service with an @code{nginx-server-configuration} listening on the
21433 @var{domains} on port 80, and which has a
21434 @code{nginx-location-configuration} for the @code{/.well-known/} URI
21435 path subspace used by Let's Encrypt. @xref{Web Services}, for more on
21436 these nginx configuration data types.
21437
21438 Requests to other URL paths will be matched by the
21439 @code{default-location}, which if present is added to all
21440 @code{nginx-server-configuration}s.
21441
21442 By default, the @code{default-location} will issue a redirect from
21443 @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
21444 you to define what to serve on your site via @code{https}.
21445
21446 Pass @code{#f} to not issue a default location.
21447 @end table
21448 @end deftp
21449
21450 @deftp {Data Type} certificate-configuration
21451 Data type representing the configuration of a certificate.
21452 This type has the following parameters:
21453
21454 @table @asis
21455 @item @code{name} (default: @i{see below})
21456 This name is used by Certbot for housekeeping and in file paths; it
21457 doesn't affect the content of the certificate itself. To see
21458 certificate names, run @code{certbot certificates}.
21459
21460 Its default is the first provided domain.
21461
21462 @item @code{domains} (default: @code{()})
21463 The first domain provided will be the subject CN of the certificate, and
21464 all domains will be Subject Alternative Names on the certificate.
21465
21466 @item @code{challenge} (default: @code{#f})
21467 The challenge type that has to be run by certbot. If @code{#f} is specified,
21468 default to the HTTP challenge. If a value is specified, defaults to the
21469 manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
21470 the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
21471 and gives Let's Encrypt permission to log the public IP address of the
21472 requesting machine.
21473
21474 @item @code{authentication-hook} (default: @code{#f})
21475 Command to be run in a shell once for each certificate challenge to be
21476 answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
21477 will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
21478 contains the validation string and @code{$CERTBOT_TOKEN} contains the
21479 file name of the resource requested when performing an HTTP-01 challenge.
21480
21481 @item @code{cleanup-hook} (default: @code{#f})
21482 Command to be run in a shell once for each certificate challenge that
21483 have been answered by the @code{auth-hook}. For this command, the shell
21484 variables available in the @code{auth-hook} script are still available, and
21485 additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
21486 of the @code{auth-hook} script.
21487
21488 @item @code{deploy-hook} (default: @code{#f})
21489 Command to be run in a shell once for each successfully issued
21490 certificate. For this command, the shell variable
21491 @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
21492 example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
21493 certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
21494 contain a space-delimited list of renewed certificate domains (for
21495 example, @samp{"example.com www.example.com"}.
21496
21497 @end table
21498 @end deftp
21499
21500 For each @code{certificate-configuration}, the certificate is saved to
21501 @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
21502 saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
21503 @node DNS Services
21504 @subsection DNS Services
21505 @cindex DNS (domain name system)
21506 @cindex domain name system (DNS)
21507
21508 The @code{(gnu services dns)} module provides services related to the
21509 @dfn{domain name system} (DNS). It provides a server service for hosting
21510 an @emph{authoritative} DNS server for multiple zones, slave or master.
21511 This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
21512 caching and forwarding DNS server for the LAN, which uses
21513 @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
21514
21515 @subsubheading Knot Service
21516
21517 An example configuration of an authoritative server for two zones, one master
21518 and one slave, is:
21519
21520 @lisp
21521 (define-zone-entries example.org.zone
21522 ;; Name TTL Class Type Data
21523 ("@@" "" "IN" "A" "127.0.0.1")
21524 ("@@" "" "IN" "NS" "ns")
21525 ("ns" "" "IN" "A" "127.0.0.1"))
21526
21527 (define master-zone
21528 (knot-zone-configuration
21529 (domain "example.org")
21530 (zone (zone-file
21531 (origin "example.org")
21532 (entries example.org.zone)))))
21533
21534 (define slave-zone
21535 (knot-zone-configuration
21536 (domain "plop.org")
21537 (dnssec-policy "default")
21538 (master (list "plop-master"))))
21539
21540 (define plop-master
21541 (knot-remote-configuration
21542 (id "plop-master")
21543 (address (list "208.76.58.171"))))
21544
21545 (operating-system
21546 ;; ...
21547 (services (cons* (service knot-service-type
21548 (knot-configuration
21549 (remotes (list plop-master))
21550 (zones (list master-zone slave-zone))))
21551 ;; ...
21552 %base-services)))
21553 @end lisp
21554
21555 @deffn {Scheme Variable} knot-service-type
21556 This is the type for the Knot DNS server.
21557
21558 Knot DNS is an authoritative DNS server, meaning that it can serve multiple
21559 zones, that is to say domain names you would buy from a registrar. This server
21560 is not a resolver, meaning that it can only resolve names for which it is
21561 authoritative. This server can be configured to serve zones as a master server
21562 or a slave server as a per-zone basis. Slave zones will get their data from
21563 masters, and will serve it as an authoritative server. From the point of view
21564 of a resolver, there is no difference between master and slave.
21565
21566 The following data types are used to configure the Knot DNS server:
21567 @end deffn
21568
21569 @deftp {Data Type} knot-key-configuration
21570 Data type representing a key.
21571 This type has the following parameters:
21572
21573 @table @asis
21574 @item @code{id} (default: @code{""})
21575 An identifier for other configuration fields to refer to this key. IDs must
21576 be unique and must not be empty.
21577
21578 @item @code{algorithm} (default: @code{#f})
21579 The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
21580 @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
21581 and @code{'hmac-sha512}.
21582
21583 @item @code{secret} (default: @code{""})
21584 The secret key itself.
21585
21586 @end table
21587 @end deftp
21588
21589 @deftp {Data Type} knot-acl-configuration
21590 Data type representing an Access Control List (ACL) configuration.
21591 This type has the following parameters:
21592
21593 @table @asis
21594 @item @code{id} (default: @code{""})
21595 An identifier for ether configuration fields to refer to this key. IDs must be
21596 unique and must not be empty.
21597
21598 @item @code{address} (default: @code{'()})
21599 An ordered list of IP addresses, network subnets, or network ranges represented
21600 with strings. The query must match one of them. Empty value means that
21601 address match is not required.
21602
21603 @item @code{key} (default: @code{'()})
21604 An ordered list of references to keys represented with strings. The string
21605 must match a key ID defined in a @code{knot-key-configuration}. No key means
21606 that a key is not require to match that ACL.
21607
21608 @item @code{action} (default: @code{'()})
21609 An ordered list of actions that are permitted or forbidden by this ACL. Possible
21610 values are lists of zero or more elements from @code{'transfer}, @code{'notify}
21611 and @code{'update}.
21612
21613 @item @code{deny?} (default: @code{#f})
21614 When true, the ACL defines restrictions. Listed actions are forbidden. When
21615 false, listed actions are allowed.
21616
21617 @end table
21618 @end deftp
21619
21620 @deftp {Data Type} zone-entry
21621 Data type representing a record entry in a zone file.
21622 This type has the following parameters:
21623
21624 @table @asis
21625 @item @code{name} (default: @code{"@@"})
21626 The name of the record. @code{"@@"} refers to the origin of the zone. Names
21627 are relative to the origin of the zone. For example, in the @code{example.org}
21628 zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
21629 Names ending with a dot are absolute, which means that @code{"ns.example.org."}
21630 refers to @code{ns.example.org}.
21631
21632 @item @code{ttl} (default: @code{""})
21633 The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
21634
21635 @item @code{class} (default: @code{"IN"})
21636 The class of the record. Knot currently supports only @code{"IN"} and
21637 partially @code{"CH"}.
21638
21639 @item @code{type} (default: @code{"A"})
21640 The type of the record. Common types include A (IPv4 address), AAAA (IPv6
21641 address), NS (Name Server) and MX (Mail eXchange). Many other types are
21642 defined.
21643
21644 @item @code{data} (default: @code{""})
21645 The data contained in the record. For instance an IP address associated with
21646 an A record, or a domain name associated with an NS record. Remember that
21647 domain names are relative to the origin unless they end with a dot.
21648
21649 @end table
21650 @end deftp
21651
21652 @deftp {Data Type} zone-file
21653 Data type representing the content of a zone file.
21654 This type has the following parameters:
21655
21656 @table @asis
21657 @item @code{entries} (default: @code{'()})
21658 The list of entries. The SOA record is taken care of, so you don't need to
21659 put it in the list of entries. This list should probably contain an entry
21660 for your primary authoritative DNS server. Other than using a list of entries
21661 directly, you can use @code{define-zone-entries} to define a object containing
21662 the list of entries more easily, that you can later pass to the @code{entries}
21663 field of the @code{zone-file}.
21664
21665 @item @code{origin} (default: @code{""})
21666 The name of your zone. This parameter cannot be empty.
21667
21668 @item @code{ns} (default: @code{"ns"})
21669 The domain of your primary authoritative DNS server. The name is relative to
21670 the origin, unless it ends with a dot. It is mandatory that this primary
21671 DNS server corresponds to an NS record in the zone and that it is associated
21672 to an IP address in the list of entries.
21673
21674 @item @code{mail} (default: @code{"hostmaster"})
21675 An email address people can contact you at, as the owner of the zone. This
21676 is translated as @code{<mail>@@<origin>}.
21677
21678 @item @code{serial} (default: @code{1})
21679 The serial number of the zone. As this is used to keep track of changes by
21680 both slaves and resolvers, it is mandatory that it @emph{never} decreases.
21681 Always increment it when you make a change in your zone.
21682
21683 @item @code{refresh} (default: @code{(* 2 24 3600)})
21684 The frequency at which slaves will do a zone transfer. This value is a number
21685 of seconds. It can be computed by multiplications or with
21686 @code{(string->duration)}.
21687
21688 @item @code{retry} (default: @code{(* 15 60)})
21689 The period after which a slave will retry to contact its master when it fails
21690 to do so a first time.
21691
21692 @item @code{expiry} (default: @code{(* 14 24 3600)})
21693 Default TTL of records. Existing records are considered correct for at most
21694 this amount of time. After this period, resolvers will invalidate their cache
21695 and check again that it still exists.
21696
21697 @item @code{nx} (default: @code{3600})
21698 Default TTL of inexistant records. This delay is usually short because you want
21699 your new domains to reach everyone quickly.
21700
21701 @end table
21702 @end deftp
21703
21704 @deftp {Data Type} knot-remote-configuration
21705 Data type representing a remote configuration.
21706 This type has the following parameters:
21707
21708 @table @asis
21709 @item @code{id} (default: @code{""})
21710 An identifier for other configuration fields to refer to this remote. IDs must
21711 be unique and must not be empty.
21712
21713 @item @code{address} (default: @code{'()})
21714 An ordered list of destination IP addresses. Addresses are tried in sequence.
21715 An optional port can be given with the @@ separator. For instance:
21716 @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
21717
21718 @item @code{via} (default: @code{'()})
21719 An ordered list of source IP addresses. An empty list will have Knot choose
21720 an appropriate source IP. An optional port can be given with the @@ separator.
21721 The default is to choose at random.
21722
21723 @item @code{key} (default: @code{#f})
21724 A reference to a key, that is a string containing the identifier of a key
21725 defined in a @code{knot-key-configuration} field.
21726
21727 @end table
21728 @end deftp
21729
21730 @deftp {Data Type} knot-keystore-configuration
21731 Data type representing a keystore to hold dnssec keys.
21732 This type has the following parameters:
21733
21734 @table @asis
21735 @item @code{id} (default: @code{""})
21736 The id of the keystore. It must not be empty.
21737
21738 @item @code{backend} (default: @code{'pem})
21739 The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
21740
21741 @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
21742 The configuration string of the backend. An example for the PKCS#11 is:
21743 @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
21744 For the pem backend, the string represents a path in the file system.
21745
21746 @end table
21747 @end deftp
21748
21749 @deftp {Data Type} knot-policy-configuration
21750 Data type representing a dnssec policy. Knot DNS is able to automatically
21751 sign your zones. It can either generate and manage your keys automatically or
21752 use keys that you generate.
21753
21754 Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
21755 used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
21756 zone. In order to be trusted, the KSK needs to be present in the parent zone
21757 (usually a top-level domain). If your registrar supports dnssec, you will
21758 have to send them your KSK's hash so they can add a DS record in their zone.
21759 This is not automated and need to be done each time you change your KSK.
21760
21761 The policy also defines the lifetime of keys. Usually, ZSK can be changed
21762 easily and use weaker cryptographic functions (they use lower parameters) in
21763 order to sign records quickly, so they are changed often. The KSK however
21764 requires manual interaction with the registrar, so they are changed less often
21765 and use stronger parameters because they sign only one record.
21766
21767 This type has the following parameters:
21768
21769 @table @asis
21770 @item @code{id} (default: @code{""})
21771 The id of the policy. It must not be empty.
21772
21773 @item @code{keystore} (default: @code{"default"})
21774 A reference to a keystore, that is a string containing the identifier of a
21775 keystore defined in a @code{knot-keystore-configuration} field. The
21776 @code{"default"} identifier means the default keystore (a kasp database that
21777 was setup by this service).
21778
21779 @item @code{manual?} (default: @code{#f})
21780 Whether the key management is manual or automatic.
21781
21782 @item @code{single-type-signing?} (default: @code{#f})
21783 When @code{#t}, use the Single-Type Signing Scheme.
21784
21785 @item @code{algorithm} (default: @code{"ecdsap256sha256"})
21786 An algorithm of signing keys and issued signatures.
21787
21788 @item @code{ksk-size} (default: @code{256})
21789 The length of the KSK. Note that this value is correct for the default
21790 algorithm, but would be unsecure for other algorithms.
21791
21792 @item @code{zsk-size} (default: @code{256})
21793 The length of the ZSK. Note that this value is correct for the default
21794 algorithm, but would be unsecure for other algorithms.
21795
21796 @item @code{dnskey-ttl} (default: @code{'default})
21797 The TTL value for DNSKEY records added into zone apex. The special
21798 @code{'default} value means same as the zone SOA TTL.
21799
21800 @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
21801 The period between ZSK publication and the next rollover initiation.
21802
21803 @item @code{propagation-delay} (default: @code{(* 24 3600)})
21804 An extra delay added for each key rollover step. This value should be high
21805 enough to cover propagation of data from the master server to all slaves.
21806
21807 @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
21808 A validity period of newly issued signatures.
21809
21810 @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
21811 A period how long before a signature expiration the signature will be refreshed.
21812
21813 @item @code{nsec3?} (default: @code{#f})
21814 When @code{#t}, NSEC3 will be used instead of NSEC.
21815
21816 @item @code{nsec3-iterations} (default: @code{5})
21817 The number of additional times the hashing is performed.
21818
21819 @item @code{nsec3-salt-length} (default: @code{8})
21820 The length of a salt field in octets, which is appended to the original owner
21821 name before hashing.
21822
21823 @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
21824 The validity period of newly issued salt field.
21825
21826 @end table
21827 @end deftp
21828
21829 @deftp {Data Type} knot-zone-configuration
21830 Data type representing a zone served by Knot.
21831 This type has the following parameters:
21832
21833 @table @asis
21834 @item @code{domain} (default: @code{""})
21835 The domain served by this configuration. It must not be empty.
21836
21837 @item @code{file} (default: @code{""})
21838 The file where this zone is saved. This parameter is ignored by master zones.
21839 Empty means default location that depends on the domain name.
21840
21841 @item @code{zone} (default: @code{(zone-file)})
21842 The content of the zone file. This parameter is ignored by slave zones. It
21843 must contain a zone-file record.
21844
21845 @item @code{master} (default: @code{'()})
21846 A list of master remotes. When empty, this zone is a master. When set, this
21847 zone is a slave. This is a list of remotes identifiers.
21848
21849 @item @code{ddns-master} (default: @code{#f})
21850 The main master. When empty, it defaults to the first master in the list of
21851 masters.
21852
21853 @item @code{notify} (default: @code{'()})
21854 A list of slave remote identifiers.
21855
21856 @item @code{acl} (default: @code{'()})
21857 A list of acl identifiers.
21858
21859 @item @code{semantic-checks?} (default: @code{#f})
21860 When set, this adds more semantic checks to the zone.
21861
21862 @item @code{disable-any?} (default: @code{#f})
21863 When set, this forbids queries of the ANY type.
21864
21865 @item @code{zonefile-sync} (default: @code{0})
21866 The delay between a modification in memory and on disk. 0 means immediate
21867 synchronization.
21868
21869 @item @code{zonefile-load} (default: @code{#f})
21870 The way the zone file contents are applied during zone load. Possible values
21871 are:
21872
21873 @itemize
21874 @item @code{#f} for using the default value from Knot,
21875 @item @code{'none} for not using the zone file at all,
21876 @item @code{'difference} for computing the difference between already available
21877 contents and zone contents and applying it to the current zone contents,
21878 @item @code{'difference-no-serial} for the same as @code{'difference}, but
21879 ignoring the SOA serial in the zone file, while the server takes care of it
21880 automatically.
21881 @item @code{'whole} for loading zone contents from the zone file.
21882 @end itemize
21883
21884 @item @code{journal-content} (default: @code{#f})
21885 The way the journal is used to store zone and its changes. Possible values
21886 are @code{'none} to not use it at all, @code{'changes} to store changes and
21887 @code{'all} to store contents. @code{#f} does not set this option, so the
21888 default value from Knot is used.
21889
21890 @item @code{max-journal-usage} (default: @code{#f})
21891 The maximum size for the journal on disk. @code{#f} does not set this option,
21892 so the default value from Knot is used.
21893
21894 @item @code{max-journal-depth} (default: @code{#f})
21895 The maximum size of the history. @code{#f} does not set this option, so the
21896 default value from Knot is used.
21897
21898 @item @code{max-zone-size} (default: @code{#f})
21899 The maximum size of the zone file. This limit is enforced for incoming
21900 transfer and updates. @code{#f} does not set this option, so the default
21901 value from Knot is used.
21902
21903 @item @code{dnssec-policy} (default: @code{#f})
21904 A reference to a @code{knot-policy-configuration} record, or the special
21905 name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
21906 on this zone.
21907
21908 @item @code{serial-policy} (default: @code{'increment})
21909 A policy between @code{'increment} and @code{'unixtime}.
21910
21911 @end table
21912 @end deftp
21913
21914 @deftp {Data Type} knot-configuration
21915 Data type representing the Knot configuration.
21916 This type has the following parameters:
21917
21918 @table @asis
21919 @item @code{knot} (default: @code{knot})
21920 The Knot package.
21921
21922 @item @code{run-directory} (default: @code{"/var/run/knot"})
21923 The run directory. This directory will be used for pid file and sockets.
21924
21925 @item @code{includes} (default: @code{'()})
21926 A list of strings or file-like objects denoting other files that must be
21927 included at the top of the configuration file.
21928
21929 @cindex secrets, Knot service
21930 This can be used to manage secrets out-of-band. For example, secret
21931 keys may be stored in an out-of-band file not managed by Guix, and
21932 thus not visible in @file{/gnu/store}---e.g., you could store secret
21933 key configuration in @file{/etc/knot/secrets.conf} and add this file
21934 to the @code{includes} list.
21935
21936 One can generate a secret tsig key (for nsupdate and zone transfers with the
21937 keymgr command from the knot package. Note that the package is not automatically
21938 installed by the service. The following example shows how to generate a new
21939 tsig key:
21940
21941 @example
21942 keymgr -t mysecret > /etc/knot/secrets.conf
21943 chmod 600 /etc/knot/secrets.conf
21944 @end example
21945
21946 Also note that the generated key will be named @var{mysecret}, so it is the
21947 name that needs to be used in the @var{key} field of the
21948 @code{knot-acl-configuration} record and in other places that need to refer
21949 to that key.
21950
21951 It can also be used to add configuration not supported by this interface.
21952
21953 @item @code{listen-v4} (default: @code{"0.0.0.0"})
21954 An ip address on which to listen.
21955
21956 @item @code{listen-v6} (default: @code{"::"})
21957 An ip address on which to listen.
21958
21959 @item @code{listen-port} (default: @code{53})
21960 A port on which to listen.
21961
21962 @item @code{keys} (default: @code{'()})
21963 The list of knot-key-configuration used by this configuration.
21964
21965 @item @code{acls} (default: @code{'()})
21966 The list of knot-acl-configuration used by this configuration.
21967
21968 @item @code{remotes} (default: @code{'()})
21969 The list of knot-remote-configuration used by this configuration.
21970
21971 @item @code{zones} (default: @code{'()})
21972 The list of knot-zone-configuration used by this configuration.
21973
21974 @end table
21975 @end deftp
21976
21977 @subsubheading Knot Resolver Service
21978
21979 @deffn {Scheme Variable} knot-resolver-service-type
21980 This this the type of the knot resolver service, whose value should be
21981 an @code{knot-resolver-configuration} object as in this example:
21982
21983 @lisp
21984 (service knot-resolver-service-type
21985 (knot-resolver-configuration
21986 (kresd-config-file (plain-file "kresd.conf" "
21987 net.listen('192.168.0.1', 5353)
21988 user('knot-resolver', 'knot-resolver')
21989 modules = @{ 'hints > iterate', 'stats', 'predict' @}
21990 cache.size = 100 * MB
21991 "))))
21992 @end lisp
21993
21994 For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
21995 @end deffn
21996
21997 @deftp {Data Type} knot-resolver-configuration
21998 Data type representing the configuration of knot-resolver.
21999
22000 @table @asis
22001 @item @code{package} (default: @var{knot-resolver})
22002 Package object of the knot DNS resolver.
22003
22004 @item @code{kresd-config-file} (default: %kresd.conf)
22005 File-like object of the kresd configuration file to use, by default it
22006 will listen on @code{127.0.0.1} and @code{::1}.
22007
22008 @item @code{garbage-collection-interval} (default: 1000)
22009 Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
22010
22011 @end table
22012 @end deftp
22013
22014
22015 @subsubheading Dnsmasq Service
22016
22017 @deffn {Scheme Variable} dnsmasq-service-type
22018 This is the type of the dnsmasq service, whose value should be an
22019 @code{dnsmasq-configuration} object as in this example:
22020
22021 @lisp
22022 (service dnsmasq-service-type
22023 (dnsmasq-configuration
22024 (no-resolv? #t)
22025 (servers '("192.168.1.1"))))
22026 @end lisp
22027 @end deffn
22028
22029 @deftp {Data Type} dnsmasq-configuration
22030 Data type representing the configuration of dnsmasq.
22031
22032 @table @asis
22033 @item @code{package} (default: @var{dnsmasq})
22034 Package object of the dnsmasq server.
22035
22036 @item @code{no-hosts?} (default: @code{#f})
22037 When true, don't read the hostnames in /etc/hosts.
22038
22039 @item @code{port} (default: @code{53})
22040 The port to listen on. Setting this to zero completely disables DNS
22041 responses, leaving only DHCP and/or TFTP functions.
22042
22043 @item @code{local-service?} (default: @code{#t})
22044 Accept DNS queries only from hosts whose address is on a local subnet,
22045 ie a subnet for which an interface exists on the server.
22046
22047 @item @code{listen-addresses} (default: @code{'()})
22048 Listen on the given IP addresses.
22049
22050 @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
22051 The file to read the IP address of the upstream nameservers from.
22052
22053 @item @code{no-resolv?} (default: @code{#f})
22054 When true, don't read @var{resolv-file}.
22055
22056 @item @code{servers} (default: @code{'()})
22057 Specify IP address of upstream servers directly.
22058
22059 @item @code{addresses} (default: @code{'()})
22060 For each entry, specify an IP address to return for any host in the
22061 given domains. Queries in the domains are never forwarded and always
22062 replied to with the specified IP address.
22063
22064 This is useful for redirecting hosts locally, for example:
22065
22066 @lisp
22067 (service dnsmasq-service-type
22068 (dnsmasq-configuration
22069 (addresses
22070 '(; Redirect to a local web-server.
22071 "/example.org/127.0.0.1"
22072 ; Redirect subdomain to a specific IP.
22073 "/subdomain.example.org/192.168.1.42"))))
22074 @end lisp
22075
22076 Note that rules in @file{/etc/hosts} take precedence over this.
22077
22078 @item @code{cache-size} (default: @code{150})
22079 Set the size of dnsmasq's cache. Setting the cache size to zero
22080 disables caching.
22081
22082 @item @code{negative-cache?} (default: @code{#t})
22083 When false, disable negative caching.
22084
22085 @end table
22086 @end deftp
22087
22088 @subsubheading ddclient Service
22089
22090 @cindex ddclient
22091 The ddclient service described below runs the ddclient daemon, which takes
22092 care of automatically updating DNS entries for service providers such as
22093 @uref{https://dyn.com/dns/, Dyn}.
22094
22095 The following example show instantiates the service with its default
22096 configuration:
22097
22098 @lisp
22099 (service ddclient-service-type)
22100 @end lisp
22101
22102 Note that ddclient needs to access credentials that are stored in a
22103 @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
22104 @code{secret-file} below.) You are expected to create this file manually, in
22105 an ``out-of-band'' fashion (you @emph{could} make this file part of the
22106 service configuration, for instance by using @code{plain-file}, but it will be
22107 world-readable @i{via} @file{/gnu/store}.) See the examples in the
22108 @file{share/ddclient} directory of the @code{ddclient} package.
22109
22110 @c %start of fragment
22111
22112 Available @code{ddclient-configuration} fields are:
22113
22114 @deftypevr {@code{ddclient-configuration} parameter} package ddclient
22115 The ddclient package.
22116
22117 @end deftypevr
22118
22119 @deftypevr {@code{ddclient-configuration} parameter} integer daemon
22120 The period after which ddclient will retry to check IP and domain name.
22121
22122 Defaults to @samp{300}.
22123
22124 @end deftypevr
22125
22126 @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
22127 Use syslog for the output.
22128
22129 Defaults to @samp{#t}.
22130
22131 @end deftypevr
22132
22133 @deftypevr {@code{ddclient-configuration} parameter} string mail
22134 Mail to user.
22135
22136 Defaults to @samp{"root"}.
22137
22138 @end deftypevr
22139
22140 @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
22141 Mail failed update to user.
22142
22143 Defaults to @samp{"root"}.
22144
22145 @end deftypevr
22146
22147 @deftypevr {@code{ddclient-configuration} parameter} string pid
22148 The ddclient PID file.
22149
22150 Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
22151
22152 @end deftypevr
22153
22154 @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
22155 Enable SSL support.
22156
22157 Defaults to @samp{#t}.
22158
22159 @end deftypevr
22160
22161 @deftypevr {@code{ddclient-configuration} parameter} string user
22162 Specifies the user name or ID that is used when running ddclient
22163 program.
22164
22165 Defaults to @samp{"ddclient"}.
22166
22167 @end deftypevr
22168
22169 @deftypevr {@code{ddclient-configuration} parameter} string group
22170 Group of the user who will run the ddclient program.
22171
22172 Defaults to @samp{"ddclient"}.
22173
22174 @end deftypevr
22175
22176 @deftypevr {@code{ddclient-configuration} parameter} string secret-file
22177 Secret file which will be appended to @file{ddclient.conf} file. This
22178 file contains credentials for use by ddclient. You are expected to
22179 create it manually.
22180
22181 Defaults to @samp{"/etc/ddclient/secrets.conf"}.
22182
22183 @end deftypevr
22184
22185 @deftypevr {@code{ddclient-configuration} parameter} list extra-options
22186 Extra options will be appended to @file{ddclient.conf} file.
22187
22188 Defaults to @samp{()}.
22189
22190 @end deftypevr
22191
22192
22193 @c %end of fragment
22194
22195
22196 @node VPN Services
22197 @subsection VPN Services
22198 @cindex VPN (virtual private network)
22199 @cindex virtual private network (VPN)
22200
22201 The @code{(gnu services vpn)} module provides services related to
22202 @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
22203 your machine to connect to a VPN, and a @emph{server} service for your machine
22204 to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
22205
22206 @deffn {Scheme Procedure} openvpn-client-service @
22207 [#:config (openvpn-client-configuration)]
22208
22209 Return a service that runs @command{openvpn}, a VPN daemon, as a client.
22210 @end deffn
22211
22212 @deffn {Scheme Procedure} openvpn-server-service @
22213 [#:config (openvpn-server-configuration)]
22214
22215 Return a service that runs @command{openvpn}, a VPN daemon, as a server.
22216
22217 Both can be run simultaneously.
22218 @end deffn
22219
22220 @c %automatically generated documentation
22221
22222 Available @code{openvpn-client-configuration} fields are:
22223
22224 @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
22225 The OpenVPN package.
22226
22227 @end deftypevr
22228
22229 @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
22230 The OpenVPN pid file.
22231
22232 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
22233
22234 @end deftypevr
22235
22236 @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
22237 The protocol (UDP or TCP) used to open a channel between clients and
22238 servers.
22239
22240 Defaults to @samp{udp}.
22241
22242 @end deftypevr
22243
22244 @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
22245 The device type used to represent the VPN connection.
22246
22247 Defaults to @samp{tun}.
22248
22249 @end deftypevr
22250
22251 @deftypevr {@code{openvpn-client-configuration} parameter} string ca
22252 The certificate authority to check connections against.
22253
22254 Defaults to @samp{"/etc/openvpn/ca.crt"}.
22255
22256 @end deftypevr
22257
22258 @deftypevr {@code{openvpn-client-configuration} parameter} string cert
22259 The certificate of the machine the daemon is running on. It should be
22260 signed by the authority given in @code{ca}.
22261
22262 Defaults to @samp{"/etc/openvpn/client.crt"}.
22263
22264 @end deftypevr
22265
22266 @deftypevr {@code{openvpn-client-configuration} parameter} string key
22267 The key of the machine the daemon is running on. It must be the key whose
22268 certificate is @code{cert}.
22269
22270 Defaults to @samp{"/etc/openvpn/client.key"}.
22271
22272 @end deftypevr
22273
22274 @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
22275 Whether to use the lzo compression algorithm.
22276
22277 Defaults to @samp{#t}.
22278
22279 @end deftypevr
22280
22281 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
22282 Don't re-read key files across SIGUSR1 or --ping-restart.
22283
22284 Defaults to @samp{#t}.
22285
22286 @end deftypevr
22287
22288 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
22289 Don't close and reopen TUN/TAP device or run up/down scripts across
22290 SIGUSR1 or --ping-restart restarts.
22291
22292 Defaults to @samp{#t}.
22293
22294 @end deftypevr
22295
22296 @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
22297 (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
22298 poll/epoll/select prior to the write operation.
22299
22300 Defaults to @samp{#f}.
22301 @end deftypevr
22302
22303 @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
22304 Verbosity level.
22305
22306 Defaults to @samp{3}.
22307
22308 @end deftypevr
22309
22310 @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
22311 Add an additional layer of HMAC authentication on top of the TLS control
22312 channel to protect against DoS attacks.
22313
22314 Defaults to @samp{#f}.
22315
22316 @end deftypevr
22317
22318 @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
22319 Authenticate with server using username/password. The option is a file
22320 containing username/password on 2 lines. Do not use a file-like object as it
22321 would be added to the store and readable by any user.
22322
22323 Defaults to @samp{'disabled}.
22324 @end deftypevr
22325
22326 @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
22327 Whether to check the server certificate has server usage extension.
22328
22329 Defaults to @samp{#t}.
22330
22331 @end deftypevr
22332
22333 @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
22334 Bind to a specific local port number.
22335
22336 Defaults to @samp{#f}.
22337
22338 @end deftypevr
22339
22340 @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
22341 Retry resolving server address.
22342
22343 Defaults to @samp{#t}.
22344
22345 @end deftypevr
22346
22347 @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
22348 A list of remote servers to connect to.
22349
22350 Defaults to @samp{()}.
22351
22352 Available @code{openvpn-remote-configuration} fields are:
22353
22354 @deftypevr {@code{openvpn-remote-configuration} parameter} string name
22355 Server name.
22356
22357 Defaults to @samp{"my-server"}.
22358
22359 @end deftypevr
22360
22361 @deftypevr {@code{openvpn-remote-configuration} parameter} number port
22362 Port number the server listens to.
22363
22364 Defaults to @samp{1194}.
22365
22366 @end deftypevr
22367
22368 @end deftypevr
22369 @c %end of automatic openvpn-client documentation
22370
22371 @c %automatically generated documentation
22372
22373 Available @code{openvpn-server-configuration} fields are:
22374
22375 @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
22376 The OpenVPN package.
22377
22378 @end deftypevr
22379
22380 @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
22381 The OpenVPN pid file.
22382
22383 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
22384
22385 @end deftypevr
22386
22387 @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
22388 The protocol (UDP or TCP) used to open a channel between clients and
22389 servers.
22390
22391 Defaults to @samp{udp}.
22392
22393 @end deftypevr
22394
22395 @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
22396 The device type used to represent the VPN connection.
22397
22398 Defaults to @samp{tun}.
22399
22400 @end deftypevr
22401
22402 @deftypevr {@code{openvpn-server-configuration} parameter} string ca
22403 The certificate authority to check connections against.
22404
22405 Defaults to @samp{"/etc/openvpn/ca.crt"}.
22406
22407 @end deftypevr
22408
22409 @deftypevr {@code{openvpn-server-configuration} parameter} string cert
22410 The certificate of the machine the daemon is running on. It should be
22411 signed by the authority given in @code{ca}.
22412
22413 Defaults to @samp{"/etc/openvpn/client.crt"}.
22414
22415 @end deftypevr
22416
22417 @deftypevr {@code{openvpn-server-configuration} parameter} string key
22418 The key of the machine the daemon is running on. It must be the key whose
22419 certificate is @code{cert}.
22420
22421 Defaults to @samp{"/etc/openvpn/client.key"}.
22422
22423 @end deftypevr
22424
22425 @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
22426 Whether to use the lzo compression algorithm.
22427
22428 Defaults to @samp{#t}.
22429
22430 @end deftypevr
22431
22432 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
22433 Don't re-read key files across SIGUSR1 or --ping-restart.
22434
22435 Defaults to @samp{#t}.
22436
22437 @end deftypevr
22438
22439 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
22440 Don't close and reopen TUN/TAP device or run up/down scripts across
22441 SIGUSR1 or --ping-restart restarts.
22442
22443 Defaults to @samp{#t}.
22444
22445 @end deftypevr
22446
22447 @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
22448 (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
22449 poll/epoll/select prior to the write operation.
22450
22451 Defaults to @samp{#f}.
22452 @end deftypevr
22453
22454 @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
22455 Verbosity level.
22456
22457 Defaults to @samp{3}.
22458
22459 @end deftypevr
22460
22461 @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
22462 Add an additional layer of HMAC authentication on top of the TLS control
22463 channel to protect against DoS attacks.
22464
22465 Defaults to @samp{#f}.
22466
22467 @end deftypevr
22468
22469 @deftypevr {@code{openvpn-server-configuration} parameter} number port
22470 Specifies the port number on which the server listens.
22471
22472 Defaults to @samp{1194}.
22473
22474 @end deftypevr
22475
22476 @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
22477 An ip and mask specifying the subnet inside the virtual network.
22478
22479 Defaults to @samp{"10.8.0.0 255.255.255.0"}.
22480
22481 @end deftypevr
22482
22483 @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
22484 A CIDR notation specifying the IPv6 subnet inside the virtual network.
22485
22486 Defaults to @samp{#f}.
22487
22488 @end deftypevr
22489
22490 @deftypevr {@code{openvpn-server-configuration} parameter} string dh
22491 The Diffie-Hellman parameters file.
22492
22493 Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
22494
22495 @end deftypevr
22496
22497 @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
22498 The file that records client IPs.
22499
22500 Defaults to @samp{"/etc/openvpn/ipp.txt"}.
22501
22502 @end deftypevr
22503
22504 @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
22505 When true, the server will act as a gateway for its clients.
22506
22507 Defaults to @samp{#f}.
22508
22509 @end deftypevr
22510
22511 @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
22512 When true, clients are allowed to talk to each other inside the VPN.
22513
22514 Defaults to @samp{#f}.
22515
22516 @end deftypevr
22517
22518 @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
22519 Causes ping-like messages to be sent back and forth over the link so
22520 that each side knows when the other side has gone down. @code{keepalive}
22521 requires a pair. The first element is the period of the ping sending,
22522 and the second element is the timeout before considering the other side
22523 down.
22524
22525 @end deftypevr
22526
22527 @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
22528 The maximum number of clients.
22529
22530 Defaults to @samp{100}.
22531
22532 @end deftypevr
22533
22534 @deftypevr {@code{openvpn-server-configuration} parameter} string status
22535 The status file. This file shows a small report on current connection.
22536 It is truncated and rewritten every minute.
22537
22538 Defaults to @samp{"/var/run/openvpn/status"}.
22539
22540 @end deftypevr
22541
22542 @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
22543 The list of configuration for some clients.
22544
22545 Defaults to @samp{()}.
22546
22547 Available @code{openvpn-ccd-configuration} fields are:
22548
22549 @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
22550 Client name.
22551
22552 Defaults to @samp{"client"}.
22553
22554 @end deftypevr
22555
22556 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
22557 Client own network
22558
22559 Defaults to @samp{#f}.
22560
22561 @end deftypevr
22562
22563 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
22564 Client VPN IP.
22565
22566 Defaults to @samp{#f}.
22567
22568 @end deftypevr
22569
22570 @end deftypevr
22571
22572
22573 @c %end of automatic openvpn-server documentation
22574
22575
22576 @node Network File System
22577 @subsection Network File System
22578 @cindex NFS
22579
22580 The @code{(gnu services nfs)} module provides the following services,
22581 which are most commonly used in relation to mounting or exporting
22582 directory trees as @dfn{network file systems} (NFS).
22583
22584 While it is possible to use the individual components that together make
22585 up a Network File System service, we recommended to configure an NFS
22586 server with the @code{nfs-service-type}.
22587
22588 @subsubheading NFS Service
22589 @cindex NFS, server
22590
22591 The NFS service takes care of setting up all NFS component services,
22592 kernel configuration file systems, and installs configuration files in
22593 the locations that NFS expects.
22594
22595 @defvr {Scheme Variable} nfs-service-type
22596 A service type for a complete NFS server.
22597 @end defvr
22598
22599 @deftp {Data Type} nfs-configuration
22600 This data type represents the configuration of the NFS service and all
22601 of its subsystems.
22602
22603 It has the following parameters:
22604 @table @asis
22605 @item @code{nfs-utils} (default: @code{nfs-utils})
22606 The nfs-utils package to use.
22607
22608 @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
22609 If a list of string values is provided, the @command{rpc.nfsd} daemon
22610 will be limited to supporting the given versions of the NFS protocol.
22611
22612 @item @code{exports} (default: @code{'()})
22613 This is a list of directories the NFS server should export. Each entry
22614 is a list consisting of two elements: a directory name and a string
22615 containing all options. This is an example in which the directory
22616 @file{/export} is served to all NFS clients as a read-only share:
22617
22618 @lisp
22619 (nfs-configuration
22620 (exports
22621 '(("/export"
22622 "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
22623 @end lisp
22624
22625 @item @code{rpcmountd-port} (default: @code{#f})
22626 The network port that the @command{rpc.mountd} daemon should use.
22627
22628 @item @code{rpcstatd-port} (default: @code{#f})
22629 The network port that the @command{rpc.statd} daemon should use.
22630
22631 @item @code{rpcbind} (default: @code{rpcbind})
22632 The rpcbind package to use.
22633
22634 @item @code{idmap-domain} (default: @code{"localdomain"})
22635 The local NFSv4 domain name.
22636
22637 @item @code{nfsd-port} (default: @code{2049})
22638 The network port that the @command{nfsd} daemon should use.
22639
22640 @item @code{nfsd-threads} (default: @code{8})
22641 The number of threads used by the @command{nfsd} daemon.
22642
22643 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
22644 The directory where the pipefs file system is mounted.
22645
22646 @item @code{debug} (default: @code{'()"})
22647 A list of subsystems for which debugging output should be enabled. This
22648 is a list of symbols. Any of these symbols are valid: @code{nfsd},
22649 @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
22650 @end table
22651 @end deftp
22652
22653 If you don't need a complete NFS service or prefer to build it yourself
22654 you can use the individual component services that are documented below.
22655
22656 @subsubheading RPC Bind Service
22657 @cindex rpcbind
22658
22659 The RPC Bind service provides a facility to map program numbers into
22660 universal addresses.
22661 Many NFS related services use this facility. Hence it is automatically
22662 started when a dependent service starts.
22663
22664 @defvr {Scheme Variable} rpcbind-service-type
22665 A service type for the RPC portmapper daemon.
22666 @end defvr
22667
22668
22669 @deftp {Data Type} rpcbind-configuration
22670 Data type representing the configuration of the RPC Bind Service.
22671 This type has the following parameters:
22672 @table @asis
22673 @item @code{rpcbind} (default: @code{rpcbind})
22674 The rpcbind package to use.
22675
22676 @item @code{warm-start?} (default: @code{#t})
22677 If this parameter is @code{#t}, then the daemon will read a
22678 state file on startup thus reloading state information saved by a previous
22679 instance.
22680 @end table
22681 @end deftp
22682
22683
22684 @subsubheading Pipefs Pseudo File System
22685 @cindex pipefs
22686 @cindex rpc_pipefs
22687
22688 The pipefs file system is used to transfer NFS related data
22689 between the kernel and user space programs.
22690
22691 @defvr {Scheme Variable} pipefs-service-type
22692 A service type for the pipefs pseudo file system.
22693 @end defvr
22694
22695 @deftp {Data Type} pipefs-configuration
22696 Data type representing the configuration of the pipefs pseudo file system service.
22697 This type has the following parameters:
22698 @table @asis
22699 @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
22700 The directory to which the file system is to be attached.
22701 @end table
22702 @end deftp
22703
22704
22705 @subsubheading GSS Daemon Service
22706 @cindex GSSD
22707 @cindex GSS
22708 @cindex global security system
22709
22710 The @dfn{global security system} (GSS) daemon provides strong security for RPC
22711 based protocols.
22712 Before exchanging RPC requests an RPC client must establish a security
22713 context. Typically this is done using the Kerberos command @command{kinit}
22714 or automatically at login time using PAM services (@pxref{Kerberos Services}).
22715
22716 @defvr {Scheme Variable} gss-service-type
22717 A service type for the Global Security System (GSS) daemon.
22718 @end defvr
22719
22720 @deftp {Data Type} gss-configuration
22721 Data type representing the configuration of the GSS daemon service.
22722 This type has the following parameters:
22723 @table @asis
22724 @item @code{nfs-utils} (default: @code{nfs-utils})
22725 The package in which the @command{rpc.gssd} command is to be found.
22726
22727 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
22728 The directory where the pipefs file system is mounted.
22729
22730 @end table
22731 @end deftp
22732
22733
22734 @subsubheading IDMAP Daemon Service
22735 @cindex idmapd
22736 @cindex name mapper
22737
22738 The idmap daemon service provides mapping between user IDs and user names.
22739 Typically it is required in order to access file systems mounted via NFSv4.
22740
22741 @defvr {Scheme Variable} idmap-service-type
22742 A service type for the Identity Mapper (IDMAP) daemon.
22743 @end defvr
22744
22745 @deftp {Data Type} idmap-configuration
22746 Data type representing the configuration of the IDMAP daemon service.
22747 This type has the following parameters:
22748 @table @asis
22749 @item @code{nfs-utils} (default: @code{nfs-utils})
22750 The package in which the @command{rpc.idmapd} command is to be found.
22751
22752 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
22753 The directory where the pipefs file system is mounted.
22754
22755 @item @code{domain} (default: @code{#f})
22756 The local NFSv4 domain name.
22757 This must be a string or @code{#f}.
22758 If it is @code{#f} then the daemon will use the host's fully qualified domain name.
22759
22760 @item @code{verbosity} (default: @code{0})
22761 The verbosity level of the daemon.
22762
22763 @end table
22764 @end deftp
22765
22766 @node Continuous Integration
22767 @subsection Continuous Integration
22768
22769 @cindex continuous integration
22770 @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
22771 continuous integration tool for Guix. It can be used both for development and
22772 for providing substitutes to others (@pxref{Substitutes}).
22773
22774 The @code{(gnu services cuirass)} module provides the following service.
22775
22776 @defvr {Scheme Procedure} cuirass-service-type
22777 The type of the Cuirass service. Its value must be a
22778 @code{cuirass-configuration} object, as described below.
22779 @end defvr
22780
22781 To add build jobs, you have to set the @code{specifications} field of the
22782 configuration. Here is an example of a service that polls the Guix repository
22783 and builds the packages from a manifest. Some of the packages are defined in
22784 the @code{"custom-packages"} input, which is the equivalent of
22785 @env{GUIX_PACKAGE_PATH}.
22786
22787 @lisp
22788 (define %cuirass-specs
22789 #~(list
22790 '((#:name . "my-manifest")
22791 (#:load-path-inputs . ("guix"))
22792 (#:package-path-inputs . ("custom-packages"))
22793 (#:proc-input . "guix")
22794 (#:proc-file . "build-aux/cuirass/gnu-system.scm")
22795 (#:proc . cuirass-jobs)
22796 (#:proc-args . ((subset . "manifests")
22797 (systems . ("x86_64-linux"))
22798 (manifests . (("config" . "guix/manifest.scm")))))
22799 (#:inputs . (((#:name . "guix")
22800 (#:url . "git://git.savannah.gnu.org/guix.git")
22801 (#:load-path . ".")
22802 (#:branch . "master")
22803 (#:no-compile? . #t))
22804 ((#:name . "config")
22805 (#:url . "https://git.example.org/config.git")
22806 (#:load-path . ".")
22807 (#:branch . "master")
22808 (#:no-compile? . #t))
22809 ((#:name . "custom-packages")
22810 (#:url . "https://git.example.org/custom-packages.git")
22811 (#:load-path . ".")
22812 (#:branch . "master")
22813 (#:no-compile? . #t)))))))
22814
22815 (service cuirass-service-type
22816 (cuirass-configuration
22817 (specifications %cuirass-specs)))
22818 @end lisp
22819
22820 While information related to build jobs is located directly in the
22821 specifications, global settings for the @command{cuirass} process are
22822 accessible in other @code{cuirass-configuration} fields.
22823
22824 @deftp {Data Type} cuirass-configuration
22825 Data type representing the configuration of Cuirass.
22826
22827 @table @asis
22828 @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
22829 Location of the log file.
22830
22831 @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
22832 Location of the log file used by the web interface.
22833
22834 @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
22835 Location of the repository cache.
22836
22837 @item @code{user} (default: @code{"cuirass"})
22838 Owner of the @code{cuirass} process.
22839
22840 @item @code{group} (default: @code{"cuirass"})
22841 Owner's group of the @code{cuirass} process.
22842
22843 @item @code{interval} (default: @code{60})
22844 Number of seconds between the poll of the repositories followed by the
22845 Cuirass jobs.
22846
22847 @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
22848 Location of sqlite database which contains the build results and previously
22849 added specifications.
22850
22851 @item @code{ttl} (default: @code{(* 30 24 3600)})
22852 Specifies the time-to-live (TTL) in seconds of garbage collector roots that
22853 are registered for build results. This means that build results are protected
22854 from garbage collection for at least @var{ttl} seconds.
22855
22856 @item @code{port} (default: @code{8081})
22857 Port number used by the HTTP server.
22858
22859 @item @code{host} (default: @code{"localhost"})
22860 Listen on the network interface for @var{host}. The default is to
22861 accept connections from localhost.
22862
22863 @item @code{specifications} (default: @code{#~'()})
22864 A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
22865 where a specification is an association list
22866 (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
22867 keys are keywords (@code{#:keyword-example}) as shown in the example
22868 above.
22869
22870 @item @code{use-substitutes?} (default: @code{#f})
22871 This allows using substitutes to avoid building every dependencies of a job
22872 from source.
22873
22874 @item @code{one-shot?} (default: @code{#f})
22875 Only evaluate specifications and build derivations once.
22876
22877 @item @code{fallback?} (default: @code{#f})
22878 When substituting a pre-built binary fails, fall back to building
22879 packages locally.
22880
22881 @item @code{extra-options} (default: @code{'()})
22882 Extra options to pass when running the Cuirass processes.
22883
22884 @item @code{cuirass} (default: @code{cuirass})
22885 The Cuirass package to use.
22886 @end table
22887 @end deftp
22888
22889 @node Power Management Services
22890 @subsection Power Management Services
22891
22892 @cindex tlp
22893 @cindex power management with TLP
22894 @subsubheading TLP daemon
22895
22896 The @code{(gnu services pm)} module provides a Guix service definition
22897 for the Linux power management tool TLP.
22898
22899 TLP enables various powersaving modes in userspace and kernel.
22900 Contrary to @code{upower-service}, it is not a passive,
22901 monitoring tool, as it will apply custom settings each time a new power
22902 source is detected. More information can be found at
22903 @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
22904
22905 @deffn {Scheme Variable} tlp-service-type
22906 The service type for the TLP tool. Its value should be a valid
22907 TLP configuration (see below). To use the default settings, simply
22908 write:
22909 @lisp
22910 (service tlp-service-type)
22911 @end lisp
22912 @end deffn
22913
22914 By default TLP does not need much configuration but most TLP parameters
22915 can be tweaked using @code{tlp-configuration}.
22916
22917 Each parameter definition is preceded by its type; for example,
22918 @samp{boolean foo} indicates that the @code{foo} parameter
22919 should be specified as a boolean. Types starting with
22920 @code{maybe-} denote parameters that won't show up in TLP config file
22921 when their value is @code{'disabled}.
22922
22923 @c The following documentation was initially generated by
22924 @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
22925 @c documentation is better, so we shouldn't hesitate to edit below as
22926 @c needed. However if the change you want to make to this documentation
22927 @c can be done in an automated way, it's probably easier to change
22928 @c (generate-documentation) than to make it below and have to deal with
22929 @c the churn as TLP updates.
22930
22931 Available @code{tlp-configuration} fields are:
22932
22933 @deftypevr {@code{tlp-configuration} parameter} package tlp
22934 The TLP package.
22935
22936 @end deftypevr
22937
22938 @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
22939 Set to true if you wish to enable TLP.
22940
22941 Defaults to @samp{#t}.
22942
22943 @end deftypevr
22944
22945 @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
22946 Default mode when no power supply can be detected. Alternatives are AC
22947 and BAT.
22948
22949 Defaults to @samp{"AC"}.
22950
22951 @end deftypevr
22952
22953 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
22954 Number of seconds Linux kernel has to wait after the disk goes idle,
22955 before syncing on AC.
22956
22957 Defaults to @samp{0}.
22958
22959 @end deftypevr
22960
22961 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
22962 Same as @code{disk-idle-ac} but on BAT mode.
22963
22964 Defaults to @samp{2}.
22965
22966 @end deftypevr
22967
22968 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
22969 Dirty pages flushing periodicity, expressed in seconds.
22970
22971 Defaults to @samp{15}.
22972
22973 @end deftypevr
22974
22975 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
22976 Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
22977
22978 Defaults to @samp{60}.
22979
22980 @end deftypevr
22981
22982 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
22983 CPU frequency scaling governor on AC mode. With intel_pstate driver,
22984 alternatives are powersave and performance. With acpi-cpufreq driver,
22985 alternatives are ondemand, powersave, performance and conservative.
22986
22987 Defaults to @samp{disabled}.
22988
22989 @end deftypevr
22990
22991 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
22992 Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
22993
22994 Defaults to @samp{disabled}.
22995
22996 @end deftypevr
22997
22998 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
22999 Set the min available frequency for the scaling governor on AC.
23000
23001 Defaults to @samp{disabled}.
23002
23003 @end deftypevr
23004
23005 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
23006 Set the max available frequency for the scaling governor on AC.
23007
23008 Defaults to @samp{disabled}.
23009
23010 @end deftypevr
23011
23012 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
23013 Set the min available frequency for the scaling governor on BAT.
23014
23015 Defaults to @samp{disabled}.
23016
23017 @end deftypevr
23018
23019 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
23020 Set the max available frequency for the scaling governor on BAT.
23021
23022 Defaults to @samp{disabled}.
23023
23024 @end deftypevr
23025
23026 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
23027 Limit the min P-state to control the power dissipation of the CPU, in AC
23028 mode. Values are stated as a percentage of the available performance.
23029
23030 Defaults to @samp{disabled}.
23031
23032 @end deftypevr
23033
23034 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
23035 Limit the max P-state to control the power dissipation of the CPU, in AC
23036 mode. Values are stated as a percentage of the available performance.
23037
23038 Defaults to @samp{disabled}.
23039
23040 @end deftypevr
23041
23042 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
23043 Same as @code{cpu-min-perf-on-ac} on BAT mode.
23044
23045 Defaults to @samp{disabled}.
23046
23047 @end deftypevr
23048
23049 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
23050 Same as @code{cpu-max-perf-on-ac} on BAT mode.
23051
23052 Defaults to @samp{disabled}.
23053
23054 @end deftypevr
23055
23056 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
23057 Enable CPU turbo boost feature on AC mode.
23058
23059 Defaults to @samp{disabled}.
23060
23061 @end deftypevr
23062
23063 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
23064 Same as @code{cpu-boost-on-ac?} on BAT mode.
23065
23066 Defaults to @samp{disabled}.
23067
23068 @end deftypevr
23069
23070 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
23071 Allow Linux kernel to minimize the number of CPU cores/hyper-threads
23072 used under light load conditions.
23073
23074 Defaults to @samp{#f}.
23075
23076 @end deftypevr
23077
23078 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
23079 Same as @code{sched-powersave-on-ac?} but on BAT mode.
23080
23081 Defaults to @samp{#t}.
23082
23083 @end deftypevr
23084
23085 @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
23086 Enable Linux kernel NMI watchdog.
23087
23088 Defaults to @samp{#f}.
23089
23090 @end deftypevr
23091
23092 @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
23093 For Linux kernels with PHC patch applied, change CPU voltages. An
23094 example value would be @samp{"F:V F:V F:V F:V"}.
23095
23096 Defaults to @samp{disabled}.
23097
23098 @end deftypevr
23099
23100 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
23101 Set CPU performance versus energy saving policy on AC. Alternatives are
23102 performance, normal, powersave.
23103
23104 Defaults to @samp{"performance"}.
23105
23106 @end deftypevr
23107
23108 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
23109 Same as @code{energy-perf-policy-ac} but on BAT mode.
23110
23111 Defaults to @samp{"powersave"}.
23112
23113 @end deftypevr
23114
23115 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
23116 Hard disk devices.
23117
23118 @end deftypevr
23119
23120 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
23121 Hard disk advanced power management level.
23122
23123 @end deftypevr
23124
23125 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
23126 Same as @code{disk-apm-bat} but on BAT mode.
23127
23128 @end deftypevr
23129
23130 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
23131 Hard disk spin down timeout. One value has to be specified for each
23132 declared hard disk.
23133
23134 Defaults to @samp{disabled}.
23135
23136 @end deftypevr
23137
23138 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
23139 Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
23140
23141 Defaults to @samp{disabled}.
23142
23143 @end deftypevr
23144
23145 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
23146 Select IO scheduler for disk devices. One value has to be specified for
23147 each declared hard disk. Example alternatives are cfq, deadline and
23148 noop.
23149
23150 Defaults to @samp{disabled}.
23151
23152 @end deftypevr
23153
23154 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
23155 SATA aggressive link power management (ALPM) level. Alternatives are
23156 min_power, medium_power, max_performance.
23157
23158 Defaults to @samp{"max_performance"}.
23159
23160 @end deftypevr
23161
23162 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
23163 Same as @code{sata-linkpwr-ac} but on BAT mode.
23164
23165 Defaults to @samp{"min_power"}.
23166
23167 @end deftypevr
23168
23169 @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
23170 Exclude specified SATA host devices for link power management.
23171
23172 Defaults to @samp{disabled}.
23173
23174 @end deftypevr
23175
23176 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
23177 Enable Runtime Power Management for AHCI controller and disks on AC
23178 mode.
23179
23180 Defaults to @samp{disabled}.
23181
23182 @end deftypevr
23183
23184 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
23185 Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
23186
23187 Defaults to @samp{disabled}.
23188
23189 @end deftypevr
23190
23191 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
23192 Seconds of inactivity before disk is suspended.
23193
23194 Defaults to @samp{15}.
23195
23196 @end deftypevr
23197
23198 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
23199 PCI Express Active State Power Management level. Alternatives are
23200 default, performance, powersave.
23201
23202 Defaults to @samp{"performance"}.
23203
23204 @end deftypevr
23205
23206 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
23207 Same as @code{pcie-aspm-ac} but on BAT mode.
23208
23209 Defaults to @samp{"powersave"}.
23210
23211 @end deftypevr
23212
23213 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
23214 Radeon graphics clock speed level. Alternatives are low, mid, high,
23215 auto, default.
23216
23217 Defaults to @samp{"high"}.
23218
23219 @end deftypevr
23220
23221 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
23222 Same as @code{radeon-power-ac} but on BAT mode.
23223
23224 Defaults to @samp{"low"}.
23225
23226 @end deftypevr
23227
23228 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
23229 Radeon dynamic power management method (DPM). Alternatives are battery,
23230 performance.
23231
23232 Defaults to @samp{"performance"}.
23233
23234 @end deftypevr
23235
23236 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
23237 Same as @code{radeon-dpm-state-ac} but on BAT mode.
23238
23239 Defaults to @samp{"battery"}.
23240
23241 @end deftypevr
23242
23243 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
23244 Radeon DPM performance level. Alternatives are auto, low, high.
23245
23246 Defaults to @samp{"auto"}.
23247
23248 @end deftypevr
23249
23250 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
23251 Same as @code{radeon-dpm-perf-ac} but on BAT mode.
23252
23253 Defaults to @samp{"auto"}.
23254
23255 @end deftypevr
23256
23257 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
23258 Wifi power saving mode.
23259
23260 Defaults to @samp{#f}.
23261
23262 @end deftypevr
23263
23264 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
23265 Same as @code{wifi-power-ac?} but on BAT mode.
23266
23267 Defaults to @samp{#t}.
23268
23269 @end deftypevr
23270
23271 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
23272 Disable wake on LAN.
23273
23274 Defaults to @samp{#t}.
23275
23276 @end deftypevr
23277
23278 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
23279 Timeout duration in seconds before activating audio power saving on
23280 Intel HDA and AC97 devices. A value of 0 disables power saving.
23281
23282 Defaults to @samp{0}.
23283
23284 @end deftypevr
23285
23286 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
23287 Same as @code{sound-powersave-ac} but on BAT mode.
23288
23289 Defaults to @samp{1}.
23290
23291 @end deftypevr
23292
23293 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
23294 Disable controller in powersaving mode on Intel HDA devices.
23295
23296 Defaults to @samp{#t}.
23297
23298 @end deftypevr
23299
23300 @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
23301 Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
23302 powered on again by releasing (and reinserting) the eject lever or by
23303 pressing the disc eject button on newer models.
23304
23305 Defaults to @samp{#f}.
23306
23307 @end deftypevr
23308
23309 @deftypevr {@code{tlp-configuration} parameter} string bay-device
23310 Name of the optical drive device to power off.
23311
23312 Defaults to @samp{"sr0"}.
23313
23314 @end deftypevr
23315
23316 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
23317 Runtime Power Management for PCI(e) bus devices. Alternatives are on
23318 and auto.
23319
23320 Defaults to @samp{"on"}.
23321
23322 @end deftypevr
23323
23324 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
23325 Same as @code{runtime-pm-ac} but on BAT mode.
23326
23327 Defaults to @samp{"auto"}.
23328
23329 @end deftypevr
23330
23331 @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
23332 Runtime Power Management for all PCI(e) bus devices, except blacklisted
23333 ones.
23334
23335 Defaults to @samp{#t}.
23336
23337 @end deftypevr
23338
23339 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
23340 Exclude specified PCI(e) device addresses from Runtime Power Management.
23341
23342 Defaults to @samp{disabled}.
23343
23344 @end deftypevr
23345
23346 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
23347 Exclude PCI(e) devices assigned to the specified drivers from Runtime
23348 Power Management.
23349
23350 @end deftypevr
23351
23352 @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
23353 Enable USB autosuspend feature.
23354
23355 Defaults to @samp{#t}.
23356
23357 @end deftypevr
23358
23359 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
23360 Exclude specified devices from USB autosuspend.
23361
23362 Defaults to @samp{disabled}.
23363
23364 @end deftypevr
23365
23366 @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
23367 Exclude WWAN devices from USB autosuspend.
23368
23369 Defaults to @samp{#t}.
23370
23371 @end deftypevr
23372
23373 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
23374 Include specified devices into USB autosuspend, even if they are already
23375 excluded by the driver or via @code{usb-blacklist-wwan?}.
23376
23377 Defaults to @samp{disabled}.
23378
23379 @end deftypevr
23380
23381 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
23382 Enable USB autosuspend before shutdown.
23383
23384 Defaults to @samp{disabled}.
23385
23386 @end deftypevr
23387
23388 @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
23389 Restore radio device state (bluetooth, wifi, wwan) from previous
23390 shutdown on system startup.
23391
23392 Defaults to @samp{#f}.
23393
23394 @end deftypevr
23395
23396 @cindex thermald
23397 @cindex CPU frequency scaling with thermald
23398 @subsubheading Thermald daemon
23399
23400 The @code{(gnu services pm)} module provides an interface to
23401 thermald, a CPU frequency scaling service which helps prevent overheating.
23402
23403 @defvr {Scheme Variable} thermald-service-type
23404 This is the service type for
23405 @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
23406 Thermal Daemon, which is responsible for controlling the thermal state
23407 of processors and preventing overheating.
23408 @end defvr
23409
23410 @deftp {Data Type} thermald-configuration
23411 Data type representing the configuration of @code{thermald-service-type}.
23412
23413 @table @asis
23414 @item @code{ignore-cpuid-check?} (default: @code{#f})
23415 Ignore cpuid check for supported CPU models.
23416
23417 @item @code{thermald} (default: @var{thermald})
23418 Package object of thermald.
23419
23420 @end table
23421 @end deftp
23422
23423 @node Audio Services
23424 @subsection Audio Services
23425
23426 The @code{(gnu services audio)} module provides a service to start MPD
23427 (the Music Player Daemon).
23428
23429 @cindex mpd
23430 @subsubheading Music Player Daemon
23431
23432 The Music Player Daemon (MPD) is a service that can play music while
23433 being controlled from the local machine or over the network by a variety
23434 of clients.
23435
23436 The following example shows how one might run @code{mpd} as user
23437 @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
23438
23439 @lisp
23440 (service mpd-service-type
23441 (mpd-configuration
23442 (user "bob")
23443 (port "6666")))
23444 @end lisp
23445
23446 @defvr {Scheme Variable} mpd-service-type
23447 The service type for @command{mpd}
23448 @end defvr
23449
23450 @deftp {Data Type} mpd-configuration
23451 Data type representing the configuration of @command{mpd}.
23452
23453 @table @asis
23454 @item @code{user} (default: @code{"mpd"})
23455 The user to run mpd as.
23456
23457 @item @code{music-dir} (default: @code{"~/Music"})
23458 The directory to scan for music files.
23459
23460 @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
23461 The directory to store playlists.
23462
23463 @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
23464 The location of the music database.
23465
23466 @item @code{state-file} (default: @code{"~/.mpd/state"})
23467 The location of the file that stores current MPD's state.
23468
23469 @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
23470 The location of the sticker database.
23471
23472 @item @code{port} (default: @code{"6600"})
23473 The port to run mpd on.
23474
23475 @item @code{address} (default: @code{"any"})
23476 The address that mpd will bind to. To use a Unix domain socket,
23477 an absolute path can be specified here.
23478
23479 @item @code{outputs} (default: @code{"(list (mpd-output))"})
23480 The audio outputs that MPD can use. By default this is a single output using pulseaudio.
23481
23482 @end table
23483 @end deftp
23484
23485 @deftp {Data Type} mpd-output
23486 Data type representing an @command{mpd} audio output.
23487
23488 @table @asis
23489 @item @code{name} (default: @code{"MPD"})
23490 The name of the audio output.
23491
23492 @item @code{type} (default: @code{"pulse"})
23493 The type of audio output.
23494
23495 @item @code{enabled?} (default: @code{#t})
23496 Specifies whether this audio output is enabled when MPD is started. By
23497 default, all audio outputs are enabled. This is just the default
23498 setting when there is no state file; with a state file, the previous
23499 state is restored.
23500
23501 @item @code{tags?} (default: @code{#t})
23502 If set to @code{#f}, then MPD will not send tags to this output. This
23503 is only useful for output plugins that can receive tags, for example the
23504 @code{httpd} output plugin.
23505
23506 @item @code{always-on?} (default: @code{#f})
23507 If set to @code{#t}, then MPD attempts to keep this audio output always
23508 open. This may be useful for streaming servers, when you don’t want to
23509 disconnect all listeners even when playback is accidentally stopped.
23510
23511 @item @code{mixer-type}
23512 This field accepts a symbol that specifies which mixer should be used
23513 for this audio output: the @code{hardware} mixer, the @code{software}
23514 mixer, the @code{null} mixer (allows setting the volume, but with no
23515 effect; this can be used as a trick to implement an external mixer
23516 External Mixer) or no mixer (@code{none}).
23517
23518 @item @code{extra-options} (default: @code{'()"})
23519 An association list of option symbols to string values to be appended to
23520 the audio output configuration.
23521
23522 @end table
23523 @end deftp
23524
23525 The following example shows a configuration of @code{mpd} that provides
23526 an HTTP audio streaming output.
23527
23528 @lisp
23529 (service mpd-service-type
23530 (mpd-configuration
23531 (outputs
23532 (list (mpd-output
23533 (name "streaming")
23534 (type "httpd")
23535 (mixer-type 'null)
23536 (extra-options
23537 `((encoder . "vorbis")
23538 (port . "8080"))))))))
23539 @end lisp
23540
23541
23542 @node Virtualization Services
23543 @subsection Virtualization services
23544
23545 The @code{(gnu services virtualization)} module provides services for
23546 the libvirt and virtlog daemons, as well as other virtualization-related
23547 services.
23548
23549 @subsubheading Libvirt daemon
23550 @code{libvirtd} is the server side daemon component of the libvirt
23551 virtualization management system. This daemon runs on host servers
23552 and performs required management tasks for virtualized guests.
23553
23554 @deffn {Scheme Variable} libvirt-service-type
23555 This is the type of the @uref{https://libvirt.org, libvirt daemon}.
23556 Its value must be a @code{libvirt-configuration}.
23557
23558 @lisp
23559 (service libvirt-service-type
23560 (libvirt-configuration
23561 (unix-sock-group "libvirt")
23562 (tls-port "16555")))
23563 @end lisp
23564 @end deffn
23565
23566 @c Auto-generated with (generate-libvirt-documentation)
23567 Available @code{libvirt-configuration} fields are:
23568
23569 @deftypevr {@code{libvirt-configuration} parameter} package libvirt
23570 Libvirt package.
23571
23572 @end deftypevr
23573
23574 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
23575 Flag listening for secure TLS connections on the public TCP/IP port.
23576 must set @code{listen} for this to have any effect.
23577
23578 It is necessary to setup a CA and issue server certificates before using
23579 this capability.
23580
23581 Defaults to @samp{#t}.
23582
23583 @end deftypevr
23584
23585 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
23586 Listen for unencrypted TCP connections on the public TCP/IP port. must
23587 set @code{listen} for this to have any effect.
23588
23589 Using the TCP socket requires SASL authentication by default. Only SASL
23590 mechanisms which support data encryption are allowed. This is
23591 DIGEST_MD5 and GSSAPI (Kerberos5)
23592
23593 Defaults to @samp{#f}.
23594
23595 @end deftypevr
23596
23597 @deftypevr {@code{libvirt-configuration} parameter} string tls-port
23598 Port for accepting secure TLS connections This can be a port number, or
23599 service name
23600
23601 Defaults to @samp{"16514"}.
23602
23603 @end deftypevr
23604
23605 @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
23606 Port for accepting insecure TCP connections This can be a port number,
23607 or service name
23608
23609 Defaults to @samp{"16509"}.
23610
23611 @end deftypevr
23612
23613 @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
23614 IP address or hostname used for client connections.
23615
23616 Defaults to @samp{"0.0.0.0"}.
23617
23618 @end deftypevr
23619
23620 @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
23621 Flag toggling mDNS advertisement of the libvirt service.
23622
23623 Alternatively can disable for all services on a host by stopping the
23624 Avahi daemon.
23625
23626 Defaults to @samp{#f}.
23627
23628 @end deftypevr
23629
23630 @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
23631 Default mDNS advertisement name. This must be unique on the immediate
23632 broadcast network.
23633
23634 Defaults to @samp{"Virtualization Host <hostname>"}.
23635
23636 @end deftypevr
23637
23638 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
23639 UNIX domain socket group ownership. This can be used to allow a
23640 'trusted' set of users access to management capabilities without
23641 becoming root.
23642
23643 Defaults to @samp{"root"}.
23644
23645 @end deftypevr
23646
23647 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
23648 UNIX socket permissions for the R/O socket. This is used for monitoring
23649 VM status only.
23650
23651 Defaults to @samp{"0777"}.
23652
23653 @end deftypevr
23654
23655 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
23656 UNIX socket permissions for the R/W socket. Default allows only root.
23657 If PolicyKit is enabled on the socket, the default will change to allow
23658 everyone (eg, 0777)
23659
23660 Defaults to @samp{"0770"}.
23661
23662 @end deftypevr
23663
23664 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
23665 UNIX socket permissions for the admin socket. Default allows only owner
23666 (root), do not change it unless you are sure to whom you are exposing
23667 the access to.
23668
23669 Defaults to @samp{"0777"}.
23670
23671 @end deftypevr
23672
23673 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
23674 The directory in which sockets will be found/created.
23675
23676 Defaults to @samp{"/var/run/libvirt"}.
23677
23678 @end deftypevr
23679
23680 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
23681 Authentication scheme for UNIX read-only sockets. By default socket
23682 permissions allow anyone to connect
23683
23684 Defaults to @samp{"polkit"}.
23685
23686 @end deftypevr
23687
23688 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
23689 Authentication scheme for UNIX read-write sockets. By default socket
23690 permissions only allow root. If PolicyKit support was compiled into
23691 libvirt, the default will be to use 'polkit' auth.
23692
23693 Defaults to @samp{"polkit"}.
23694
23695 @end deftypevr
23696
23697 @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
23698 Authentication scheme for TCP sockets. If you don't enable SASL, then
23699 all TCP traffic is cleartext. Don't do this outside of a dev/test
23700 scenario.
23701
23702 Defaults to @samp{"sasl"}.
23703
23704 @end deftypevr
23705
23706 @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
23707 Authentication scheme for TLS sockets. TLS sockets already have
23708 encryption provided by the TLS layer, and limited authentication is done
23709 by certificates.
23710
23711 It is possible to make use of any SASL authentication mechanism as well,
23712 by using 'sasl' for this option
23713
23714 Defaults to @samp{"none"}.
23715
23716 @end deftypevr
23717
23718 @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
23719 API access control scheme.
23720
23721 By default an authenticated user is allowed access to all APIs. Access
23722 drivers can place restrictions on this.
23723
23724 Defaults to @samp{()}.
23725
23726 @end deftypevr
23727
23728 @deftypevr {@code{libvirt-configuration} parameter} string key-file
23729 Server key file path. If set to an empty string, then no private key is
23730 loaded.
23731
23732 Defaults to @samp{""}.
23733
23734 @end deftypevr
23735
23736 @deftypevr {@code{libvirt-configuration} parameter} string cert-file
23737 Server key file path. If set to an empty string, then no certificate is
23738 loaded.
23739
23740 Defaults to @samp{""}.
23741
23742 @end deftypevr
23743
23744 @deftypevr {@code{libvirt-configuration} parameter} string ca-file
23745 Server key file path. If set to an empty string, then no CA certificate
23746 is loaded.
23747
23748 Defaults to @samp{""}.
23749
23750 @end deftypevr
23751
23752 @deftypevr {@code{libvirt-configuration} parameter} string crl-file
23753 Certificate revocation list path. If set to an empty string, then no
23754 CRL is loaded.
23755
23756 Defaults to @samp{""}.
23757
23758 @end deftypevr
23759
23760 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
23761 Disable verification of our own server certificates.
23762
23763 When libvirtd starts it performs some sanity checks against its own
23764 certificates.
23765
23766 Defaults to @samp{#f}.
23767
23768 @end deftypevr
23769
23770 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
23771 Disable verification of client certificates.
23772
23773 Client certificate verification is the primary authentication mechanism.
23774 Any client which does not present a certificate signed by the CA will be
23775 rejected.
23776
23777 Defaults to @samp{#f}.
23778
23779 @end deftypevr
23780
23781 @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
23782 Whitelist of allowed x509 Distinguished Name.
23783
23784 Defaults to @samp{()}.
23785
23786 @end deftypevr
23787
23788 @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
23789 Whitelist of allowed SASL usernames. The format for username depends on
23790 the SASL authentication mechanism.
23791
23792 Defaults to @samp{()}.
23793
23794 @end deftypevr
23795
23796 @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
23797 Override the compile time default TLS priority string. The default is
23798 usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
23799 is desired for libvirt to deviate from the global default settings.
23800
23801 Defaults to @samp{"NORMAL"}.
23802
23803 @end deftypevr
23804
23805 @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
23806 Maximum number of concurrent client connections to allow over all
23807 sockets combined.
23808
23809 Defaults to @samp{5000}.
23810
23811 @end deftypevr
23812
23813 @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
23814 Maximum length of queue of connections waiting to be accepted by the
23815 daemon. Note, that some protocols supporting retransmission may obey
23816 this so that a later reattempt at connection succeeds.
23817
23818 Defaults to @samp{1000}.
23819
23820 @end deftypevr
23821
23822 @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
23823 Maximum length of queue of accepted but not yet authenticated clients.
23824 Set this to zero to turn this feature off
23825
23826 Defaults to @samp{20}.
23827
23828 @end deftypevr
23829
23830 @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
23831 Number of workers to start up initially.
23832
23833 Defaults to @samp{5}.
23834
23835 @end deftypevr
23836
23837 @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
23838 Maximum number of worker threads.
23839
23840 If the number of active clients exceeds @code{min-workers}, then more
23841 threads are spawned, up to max_workers limit. Typically you'd want
23842 max_workers to equal maximum number of clients allowed.
23843
23844 Defaults to @samp{20}.
23845
23846 @end deftypevr
23847
23848 @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
23849 Number of priority workers. If all workers from above pool are stuck,
23850 some calls marked as high priority (notably domainDestroy) can be
23851 executed in this pool.
23852
23853 Defaults to @samp{5}.
23854
23855 @end deftypevr
23856
23857 @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
23858 Total global limit on concurrent RPC calls.
23859
23860 Defaults to @samp{20}.
23861
23862 @end deftypevr
23863
23864 @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
23865 Limit on concurrent requests from a single client connection. To avoid
23866 one client monopolizing the server this should be a small fraction of
23867 the global max_requests and max_workers parameter.
23868
23869 Defaults to @samp{5}.
23870
23871 @end deftypevr
23872
23873 @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
23874 Same as @code{min-workers} but for the admin interface.
23875
23876 Defaults to @samp{1}.
23877
23878 @end deftypevr
23879
23880 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
23881 Same as @code{max-workers} but for the admin interface.
23882
23883 Defaults to @samp{5}.
23884
23885 @end deftypevr
23886
23887 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
23888 Same as @code{max-clients} but for the admin interface.
23889
23890 Defaults to @samp{5}.
23891
23892 @end deftypevr
23893
23894 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
23895 Same as @code{max-queued-clients} but for the admin interface.
23896
23897 Defaults to @samp{5}.
23898
23899 @end deftypevr
23900
23901 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
23902 Same as @code{max-client-requests} but for the admin interface.
23903
23904 Defaults to @samp{5}.
23905
23906 @end deftypevr
23907
23908 @deftypevr {@code{libvirt-configuration} parameter} integer log-level
23909 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
23910
23911 Defaults to @samp{3}.
23912
23913 @end deftypevr
23914
23915 @deftypevr {@code{libvirt-configuration} parameter} string log-filters
23916 Logging filters.
23917
23918 A filter allows to select a different logging level for a given category
23919 of logs The format for a filter is one of:
23920
23921 @itemize @bullet
23922 @item
23923 x:name
23924
23925 @item
23926 x:+name
23927
23928 @end itemize
23929
23930 where @code{name} is a string which is matched against the category
23931 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
23932 file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
23933 name in the filter can be a substring of the full category name, in
23934 order to match multiple similar categories), the optional @samp{"+"}
23935 prefix tells libvirt to log stack trace for each message matching name,
23936 and @code{x} is the minimal level where matching messages should be
23937 logged:
23938
23939 @itemize @bullet
23940 @item
23941 1: DEBUG
23942
23943 @item
23944 2: INFO
23945
23946 @item
23947 3: WARNING
23948
23949 @item
23950 4: ERROR
23951
23952 @end itemize
23953
23954 Multiple filters can be defined in a single filters statement, they just
23955 need to be separated by spaces.
23956
23957 Defaults to @samp{"3:remote 4:event"}.
23958
23959 @end deftypevr
23960
23961 @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
23962 Logging outputs.
23963
23964 An output is one of the places to save logging information. The format
23965 for an output can be:
23966
23967 @table @code
23968 @item x:stderr
23969 output goes to stderr
23970
23971 @item x:syslog:name
23972 use syslog for the output and use the given name as the ident
23973
23974 @item x:file:file_path
23975 output to a file, with the given filepath
23976
23977 @item x:journald
23978 output to journald logging system
23979
23980 @end table
23981
23982 In all case the x prefix is the minimal level, acting as a filter
23983
23984 @itemize @bullet
23985 @item
23986 1: DEBUG
23987
23988 @item
23989 2: INFO
23990
23991 @item
23992 3: WARNING
23993
23994 @item
23995 4: ERROR
23996
23997 @end itemize
23998
23999 Multiple outputs can be defined, they just need to be separated by
24000 spaces.
24001
24002 Defaults to @samp{"3:stderr"}.
24003
24004 @end deftypevr
24005
24006 @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
24007 Allows usage of the auditing subsystem to be altered
24008
24009 @itemize @bullet
24010 @item
24011 0: disable all auditing
24012
24013 @item
24014 1: enable auditing, only if enabled on host
24015
24016 @item
24017 2: enable auditing, and exit if disabled on host.
24018
24019 @end itemize
24020
24021 Defaults to @samp{1}.
24022
24023 @end deftypevr
24024
24025 @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
24026 Send audit messages via libvirt logging infrastructure.
24027
24028 Defaults to @samp{#f}.
24029
24030 @end deftypevr
24031
24032 @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
24033 Host UUID. UUID must not have all digits be the same.
24034
24035 Defaults to @samp{""}.
24036
24037 @end deftypevr
24038
24039 @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
24040 Source to read host UUID.
24041
24042 @itemize @bullet
24043 @item
24044 @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
24045
24046 @item
24047 @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
24048
24049 @end itemize
24050
24051 If @code{dmidecode} does not provide a valid UUID a temporary UUID will
24052 be generated.
24053
24054 Defaults to @samp{"smbios"}.
24055
24056 @end deftypevr
24057
24058 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
24059 A keepalive message is sent to a client after @code{keepalive_interval}
24060 seconds of inactivity to check if the client is still responding. If
24061 set to -1, libvirtd will never send keepalive requests; however clients
24062 can still send them and the daemon will send responses.
24063
24064 Defaults to @samp{5}.
24065
24066 @end deftypevr
24067
24068 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
24069 Maximum number of keepalive messages that are allowed to be sent to the
24070 client without getting any response before the connection is considered
24071 broken.
24072
24073 In other words, the connection is automatically closed approximately
24074 after @code{keepalive_interval * (keepalive_count + 1)} seconds since
24075 the last message received from the client. When @code{keepalive-count}
24076 is set to 0, connections will be automatically closed after
24077 @code{keepalive-interval} seconds of inactivity without sending any
24078 keepalive messages.
24079
24080 Defaults to @samp{5}.
24081
24082 @end deftypevr
24083
24084 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
24085 Same as above but for admin interface.
24086
24087 Defaults to @samp{5}.
24088
24089 @end deftypevr
24090
24091 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
24092 Same as above but for admin interface.
24093
24094 Defaults to @samp{5}.
24095
24096 @end deftypevr
24097
24098 @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
24099 Timeout for Open vSwitch calls.
24100
24101 The @code{ovs-vsctl} utility is used for the configuration and its
24102 timeout option is set by default to 5 seconds to avoid potential
24103 infinite waits blocking libvirt.
24104
24105 Defaults to @samp{5}.
24106
24107 @end deftypevr
24108
24109 @c %end of autogenerated docs
24110
24111 @subsubheading Virtlog daemon
24112 The virtlogd service is a server side daemon component of libvirt that is
24113 used to manage logs from virtual machine consoles.
24114
24115 This daemon is not used directly by libvirt client applications, rather it
24116 is called on their behalf by @code{libvirtd}. By maintaining the logs in a
24117 standalone daemon, the main @code{libvirtd} daemon can be restarted without
24118 risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
24119 itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
24120
24121 @deffn {Scheme Variable} virtlog-service-type
24122 This is the type of the virtlog daemon.
24123 Its value must be a @code{virtlog-configuration}.
24124
24125 @lisp
24126 (service virtlog-service-type
24127 (virtlog-configuration
24128 (max-clients 1000)))
24129 @end lisp
24130 @end deffn
24131
24132 @deftypevr {@code{virtlog-configuration} parameter} integer log-level
24133 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
24134
24135 Defaults to @samp{3}.
24136
24137 @end deftypevr
24138
24139 @deftypevr {@code{virtlog-configuration} parameter} string log-filters
24140 Logging filters.
24141
24142 A filter allows to select a different logging level for a given category
24143 of logs The format for a filter is one of:
24144
24145 @itemize @bullet
24146 @item
24147 x:name
24148
24149 @item
24150 x:+name
24151
24152 @end itemize
24153
24154 where @code{name} is a string which is matched against the category
24155 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
24156 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
24157 be a substring of the full category name, in order to match multiple
24158 similar categories), the optional "+" prefix tells libvirt to log stack
24159 trace for each message matching name, and @code{x} is the minimal level
24160 where matching messages should be logged:
24161
24162 @itemize @bullet
24163 @item
24164 1: DEBUG
24165
24166 @item
24167 2: INFO
24168
24169 @item
24170 3: WARNING
24171
24172 @item
24173 4: ERROR
24174
24175 @end itemize
24176
24177 Multiple filters can be defined in a single filters statement, they just
24178 need to be separated by spaces.
24179
24180 Defaults to @samp{"3:remote 4:event"}.
24181
24182 @end deftypevr
24183
24184 @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
24185 Logging outputs.
24186
24187 An output is one of the places to save logging information The format
24188 for an output can be:
24189
24190 @table @code
24191 @item x:stderr
24192 output goes to stderr
24193
24194 @item x:syslog:name
24195 use syslog for the output and use the given name as the ident
24196
24197 @item x:file:file_path
24198 output to a file, with the given filepath
24199
24200 @item x:journald
24201 output to journald logging system
24202
24203 @end table
24204
24205 In all case the x prefix is the minimal level, acting as a filter
24206
24207 @itemize @bullet
24208 @item
24209 1: DEBUG
24210
24211 @item
24212 2: INFO
24213
24214 @item
24215 3: WARNING
24216
24217 @item
24218 4: ERROR
24219
24220 @end itemize
24221
24222 Multiple outputs can be defined, they just need to be separated by
24223 spaces.
24224
24225 Defaults to @samp{"3:stderr"}.
24226
24227 @end deftypevr
24228
24229 @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
24230 Maximum number of concurrent client connections to allow over all
24231 sockets combined.
24232
24233 Defaults to @samp{1024}.
24234
24235 @end deftypevr
24236
24237 @deftypevr {@code{virtlog-configuration} parameter} integer max-size
24238 Maximum file size before rolling over.
24239
24240 Defaults to @samp{2MB}
24241
24242 @end deftypevr
24243
24244 @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
24245 Maximum number of backup files to keep.
24246
24247 Defaults to @samp{3}
24248
24249 @end deftypevr
24250
24251 @subsubheading Transparent Emulation with QEMU
24252
24253 @cindex emulation
24254 @cindex @code{binfmt_misc}
24255 @code{qemu-binfmt-service-type} provides support for transparent
24256 emulation of program binaries built for different architectures---e.g.,
24257 it allows you to transparently execute an ARMv7 program on an x86_64
24258 machine. It achieves this by combining the @uref{https://www.qemu.org,
24259 QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
24260
24261 @defvr {Scheme Variable} qemu-binfmt-service-type
24262 This is the type of the QEMU/binfmt service for transparent emulation.
24263 Its value must be a @code{qemu-binfmt-configuration} object, which
24264 specifies the QEMU package to use as well as the architecture we want to
24265 emulated:
24266
24267 @lisp
24268 (service qemu-binfmt-service-type
24269 (qemu-binfmt-configuration
24270 (platforms (lookup-qemu-platforms "arm" "aarch64" "mips64el"))))
24271 @end lisp
24272
24273 In this example, we enable transparent emulation for the ARM and aarch64
24274 platforms. Running @code{herd stop qemu-binfmt} turns it off, and
24275 running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
24276 herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
24277 @end defvr
24278
24279 @deftp {Data Type} qemu-binfmt-configuration
24280 This is the configuration for the @code{qemu-binfmt} service.
24281
24282 @table @asis
24283 @item @code{platforms} (default: @code{'()})
24284 The list of emulated QEMU platforms. Each item must be a @dfn{platform
24285 object} as returned by @code{lookup-qemu-platforms} (see below).
24286
24287 @item @code{guix-support?} (default: @code{#f})
24288 When it is true, QEMU and all its dependencies are added to the build
24289 environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
24290 @option{--chroot-directory} option}). This allows the @code{binfmt_misc}
24291 handlers to be used within the build environment, which in turn means
24292 that you can transparently build programs for another architecture.
24293
24294 For example, let's suppose you're on an x86_64 machine and you have this
24295 service:
24296
24297 @lisp
24298 (service qemu-binfmt-service-type
24299 (qemu-binfmt-configuration
24300 (platforms (lookup-qemu-platforms "arm"))
24301 (guix-support? #t)))
24302 @end lisp
24303
24304 You can run:
24305
24306 @example
24307 guix build -s armhf-linux inkscape
24308 @end example
24309
24310 @noindent
24311 and it will build Inkscape for ARMv7 @emph{as if it were a native
24312 build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
24313 if you'd like to test a package build for an architecture you don't have
24314 access to!
24315
24316 @item @code{qemu} (default: @code{qemu})
24317 The QEMU package to use.
24318 @end table
24319 @end deftp
24320
24321 @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
24322 Return the list of QEMU platform objects corresponding to
24323 @var{platforms}@dots{}. @var{platforms} must be a list of strings
24324 corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
24325 @code{"mips64el"}, and so on.
24326 @end deffn
24327
24328 @deffn {Scheme Procedure} qemu-platform? @var{obj}
24329 Return true if @var{obj} is a platform object.
24330 @end deffn
24331
24332 @deffn {Scheme Procedure} qemu-platform-name @var{platform}
24333 Return the name of @var{platform}---a string such as @code{"arm"}.
24334 @end deffn
24335
24336 @node Version Control Services
24337 @subsection Version Control Services
24338
24339 The @code{(gnu services version-control)} module provides a service to
24340 allow remote access to local Git repositories. There are three options:
24341 the @code{git-daemon-service}, which provides access to repositories via
24342 the @code{git://} unsecured TCP-based protocol, extending the
24343 @code{nginx} web server to proxy some requests to
24344 @code{git-http-backend}, or providing a web interface with
24345 @code{cgit-service-type}.
24346
24347 @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
24348
24349 Return a service that runs @command{git daemon}, a simple TCP server to
24350 expose repositories over the Git protocol for anonymous access.
24351
24352 The optional @var{config} argument should be a
24353 @code{<git-daemon-configuration>} object, by default it allows read-only
24354 access to exported@footnote{By creating the magic file
24355 @file{git-daemon-export-ok} in the repository directory.} repositories under
24356 @file{/srv/git}.
24357
24358 @end deffn
24359
24360 @deftp {Data Type} git-daemon-configuration
24361 Data type representing the configuration for @code{git-daemon-service}.
24362
24363 @table @asis
24364 @item @code{package} (default: @var{git})
24365 Package object of the Git distributed version control system.
24366
24367 @item @code{export-all?} (default: @var{#f})
24368 Whether to allow access for all Git repositories, even if they do not
24369 have the @file{git-daemon-export-ok} file.
24370
24371 @item @code{base-path} (default: @file{/srv/git})
24372 Whether to remap all the path requests as relative to the given path.
24373 If you run git daemon with @var{(base-path "/srv/git")} on example.com,
24374 then if you later try to pull @code{git://example.com/hello.git}, git
24375 daemon will interpret the path as @code{/srv/git/hello.git}.
24376
24377 @item @code{user-path} (default: @var{#f})
24378 Whether to allow @code{~user} notation to be used in requests. When
24379 specified with empty string, requests to @code{git://host/~alice/foo} is
24380 taken as a request to access @code{foo} repository in the home directory
24381 of user @code{alice}. If @var{(user-path "path")} is specified, the
24382 same request is taken as a request to access @code{path/foo} repository
24383 in the home directory of user @code{alice}.
24384
24385 @item @code{listen} (default: @var{'()})
24386 Whether to listen on specific IP addresses or hostnames, defaults to
24387 all.
24388
24389 @item @code{port} (default: @var{#f})
24390 Whether to listen on an alternative port, which defaults to 9418.
24391
24392 @item @code{whitelist} (default: @var{'()})
24393 If not empty, only allow access to this list of directories.
24394
24395 @item @code{extra-options} (default: @var{'()})
24396 Extra options will be passed to @code{git daemon}, please run
24397 @command{man git-daemon} for more information.
24398
24399 @end table
24400 @end deftp
24401
24402 The @code{git://} protocol lacks authentication. When you pull from a
24403 repository fetched via @code{git://}, you don't know whether the data you
24404 receive was modified or is even coming from the specified host, and your
24405 connection is subject to eavesdropping. It's better to use an authenticated
24406 and encrypted transport, such as @code{https}. Although Git allows you
24407 to serve repositories using unsophisticated file-based web servers,
24408 there is a faster protocol implemented by the @code{git-http-backend}
24409 program. This program is the back-end of a proper Git web service. It
24410 is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
24411 on running the necessary @code{fcgiwrap} daemon.
24412
24413 Guix has a separate configuration data type for serving Git repositories
24414 over HTTP.
24415
24416 @deftp {Data Type} git-http-configuration
24417 Data type representing the configuration for a future
24418 @code{git-http-service-type}; can currently be used to configure Nginx
24419 trough @code{git-http-nginx-location-configuration}.
24420
24421 @table @asis
24422 @item @code{package} (default: @var{git})
24423 Package object of the Git distributed version control system.
24424
24425 @item @code{git-root} (default: @file{/srv/git})
24426 Directory containing the Git repositories to expose to the world.
24427
24428 @item @code{export-all?} (default: @var{#f})
24429 Whether to expose access for all Git repositories in @var{git-root},
24430 even if they do not have the @file{git-daemon-export-ok} file.
24431
24432 @item @code{uri-path} (default: @file{/git/})
24433 Path prefix for Git access. With the default @code{/git/} prefix, this
24434 will map @code{http://@var{server}/git/@var{repo}.git} to
24435 @code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
24436 with this prefix are not passed on to this Git instance.
24437
24438 @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
24439 The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
24440 Services}.
24441 @end table
24442 @end deftp
24443
24444 There is no @code{git-http-service-type}, currently; instead you can
24445 create an @code{nginx-location-configuration} from a
24446 @code{git-http-configuration} and then add that location to a web
24447 server.
24448
24449 @deffn {Scheme Procedure} git-http-nginx-location-configuration @
24450 [config=(git-http-configuration)]
24451 Compute an @code{nginx-location-configuration} that corresponds to the
24452 given Git http configuration. An example nginx service definition to
24453 serve the default @file{/srv/git} over HTTPS might be:
24454
24455 @lisp
24456 (service nginx-service-type
24457 (nginx-configuration
24458 (server-blocks
24459 (list
24460 (nginx-server-configuration
24461 (listen '("443 ssl"))
24462 (server-name "git.my-host.org")
24463 (ssl-certificate
24464 "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
24465 (ssl-certificate-key
24466 "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
24467 (locations
24468 (list
24469 (git-http-nginx-location-configuration
24470 (git-http-configuration (uri-path "/"))))))))))
24471 @end lisp
24472
24473 This example assumes that you are using Let's Encrypt to get your TLS
24474 certificate. @xref{Certificate Services}. The default @code{certbot}
24475 service will redirect all HTTP traffic on @code{git.my-host.org} to
24476 HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
24477 system services. @xref{Web Services}.
24478 @end deffn
24479
24480 @subsubheading Cgit Service
24481
24482 @cindex Cgit service
24483 @cindex Git, web interface
24484 @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
24485 repositories written in C.
24486
24487 The following example will configure the service with default values.
24488 By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
24489
24490 @lisp
24491 (service cgit-service-type)
24492 @end lisp
24493
24494 The @code{file-object} type designates either a file-like object
24495 (@pxref{G-Expressions, file-like objects}) or a string.
24496
24497 @c %start of fragment
24498
24499 Available @code{cgit-configuration} fields are:
24500
24501 @deftypevr {@code{cgit-configuration} parameter} package package
24502 The CGIT package.
24503
24504 @end deftypevr
24505
24506 @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
24507 NGINX configuration.
24508
24509 @end deftypevr
24510
24511 @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
24512 Specifies a command which will be invoked to format the content of about
24513 pages (both top-level and for each repository).
24514
24515 Defaults to @samp{""}.
24516
24517 @end deftypevr
24518
24519 @deftypevr {@code{cgit-configuration} parameter} string agefile
24520 Specifies a path, relative to each repository path, which can be used to
24521 specify the date and time of the youngest commit in the repository.
24522
24523 Defaults to @samp{""}.
24524
24525 @end deftypevr
24526
24527 @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
24528 Specifies a command that will be invoked for authenticating repository
24529 access.
24530
24531 Defaults to @samp{""}.
24532
24533 @end deftypevr
24534
24535 @deftypevr {@code{cgit-configuration} parameter} string branch-sort
24536 Flag which, when set to @samp{age}, enables date ordering in the branch
24537 ref list, and when set @samp{name} enables ordering by branch name.
24538
24539 Defaults to @samp{"name"}.
24540
24541 @end deftypevr
24542
24543 @deftypevr {@code{cgit-configuration} parameter} string cache-root
24544 Path used to store the cgit cache entries.
24545
24546 Defaults to @samp{"/var/cache/cgit"}.
24547
24548 @end deftypevr
24549
24550 @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
24551 Number which specifies the time-to-live, in minutes, for the cached
24552 version of repository pages accessed with a fixed SHA1.
24553
24554 Defaults to @samp{-1}.
24555
24556 @end deftypevr
24557
24558 @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
24559 Number which specifies the time-to-live, in minutes, for the cached
24560 version of repository pages accessed without a fixed SHA1.
24561
24562 Defaults to @samp{5}.
24563
24564 @end deftypevr
24565
24566 @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
24567 Number which specifies the time-to-live, in minutes, for the cached
24568 version of the repository summary page.
24569
24570 Defaults to @samp{5}.
24571
24572 @end deftypevr
24573
24574 @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
24575 Number which specifies the time-to-live, in minutes, for the cached
24576 version of the repository index page.
24577
24578 Defaults to @samp{5}.
24579
24580 @end deftypevr
24581
24582 @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
24583 Number which specifies the time-to-live, in minutes, for the result of
24584 scanning a path for Git repositories.
24585
24586 Defaults to @samp{15}.
24587
24588 @end deftypevr
24589
24590 @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
24591 Number which specifies the time-to-live, in minutes, for the cached
24592 version of the repository about page.
24593
24594 Defaults to @samp{15}.
24595
24596 @end deftypevr
24597
24598 @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
24599 Number which specifies the time-to-live, in minutes, for the cached
24600 version of snapshots.
24601
24602 Defaults to @samp{5}.
24603
24604 @end deftypevr
24605
24606 @deftypevr {@code{cgit-configuration} parameter} integer cache-size
24607 The maximum number of entries in the cgit cache. When set to @samp{0},
24608 caching is disabled.
24609
24610 Defaults to @samp{0}.
24611
24612 @end deftypevr
24613
24614 @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
24615 Sort items in the repo list case sensitively.
24616
24617 Defaults to @samp{#t}.
24618
24619 @end deftypevr
24620
24621 @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
24622 List of common prefixes which, when combined with a repository URL,
24623 generates valid clone URLs for the repository.
24624
24625 Defaults to @samp{()}.
24626
24627 @end deftypevr
24628
24629 @deftypevr {@code{cgit-configuration} parameter} list clone-url
24630 List of @code{clone-url} templates.
24631
24632 Defaults to @samp{()}.
24633
24634 @end deftypevr
24635
24636 @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
24637 Command which will be invoked to format commit messages.
24638
24639 Defaults to @samp{""}.
24640
24641 @end deftypevr
24642
24643 @deftypevr {@code{cgit-configuration} parameter} string commit-sort
24644 Flag which, when set to @samp{date}, enables strict date ordering in the
24645 commit log, and when set to @samp{topo} enables strict topological
24646 ordering.
24647
24648 Defaults to @samp{"git log"}.
24649
24650 @end deftypevr
24651
24652 @deftypevr {@code{cgit-configuration} parameter} file-object css
24653 URL which specifies the css document to include in all cgit pages.
24654
24655 Defaults to @samp{"/share/cgit/cgit.css"}.
24656
24657 @end deftypevr
24658
24659 @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
24660 Specifies a command which will be invoked to format names and email
24661 address of committers, authors, and taggers, as represented in various
24662 places throughout the cgit interface.
24663
24664 Defaults to @samp{""}.
24665
24666 @end deftypevr
24667
24668 @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
24669 Flag which, when set to @samp{#t}, will make cgit generate a HTML
24670 fragment suitable for embedding in other HTML pages.
24671
24672 Defaults to @samp{#f}.
24673
24674 @end deftypevr
24675
24676 @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
24677 Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
24678 commit history graph to the left of the commit messages in the
24679 repository log page.
24680
24681 Defaults to @samp{#f}.
24682
24683 @end deftypevr
24684
24685 @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
24686 Flag which, when set to @samp{#t}, allows all filter settings to be
24687 overridden in repository-specific cgitrc files.
24688
24689 Defaults to @samp{#f}.
24690
24691 @end deftypevr
24692
24693 @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
24694 Flag which, when set to @samp{#t}, allows users to follow a file in the
24695 log view.
24696
24697 Defaults to @samp{#f}.
24698
24699 @end deftypevr
24700
24701 @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
24702 If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
24703 clones.
24704
24705 Defaults to @samp{#t}.
24706
24707 @end deftypevr
24708
24709 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
24710 Flag which, when set to @samp{#t}, will make cgit generate extra links
24711 "summary", "commit", "tree" for each repo in the repository index.
24712
24713 Defaults to @samp{#f}.
24714
24715 @end deftypevr
24716
24717 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
24718 Flag which, when set to @samp{#t}, will make cgit display the owner of
24719 each repo in the repository index.
24720
24721 Defaults to @samp{#t}.
24722
24723 @end deftypevr
24724
24725 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
24726 Flag which, when set to @samp{#t}, will make cgit print the number of
24727 modified files for each commit on the repository log page.
24728
24729 Defaults to @samp{#f}.
24730
24731 @end deftypevr
24732
24733 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
24734 Flag which, when set to @samp{#t}, will make cgit print the number of
24735 added and removed lines for each commit on the repository log page.
24736
24737 Defaults to @samp{#f}.
24738
24739 @end deftypevr
24740
24741 @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
24742 Flag which, when set to @code{#t}, will make cgit display remote
24743 branches in the summary and refs views.
24744
24745 Defaults to @samp{#f}.
24746
24747 @end deftypevr
24748
24749 @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
24750 Flag which, when set to @code{1}, will make cgit use the subject of the
24751 parent commit as link text when generating links to parent commits in
24752 commit view.
24753
24754 Defaults to @samp{#f}.
24755
24756 @end deftypevr
24757
24758 @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
24759 Flag which, when set to @samp{#t}, will make cgit use the subject of the
24760 parent commit as link text when generating links to parent commits in
24761 commit view.
24762
24763 Defaults to @samp{#f}.
24764
24765 @end deftypevr
24766
24767 @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
24768 Flag which, when set to @samp{#t}, will make cgit generate linenumber
24769 links for plaintext blobs printed in the tree view.
24770
24771 Defaults to @samp{#t}.
24772
24773 @end deftypevr
24774
24775 @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
24776 Flag which, when set to @samp{#f}, will allow cgit to use Git config to
24777 set any repo specific settings.
24778
24779 Defaults to @samp{#f}.
24780
24781 @end deftypevr
24782
24783 @deftypevr {@code{cgit-configuration} parameter} file-object favicon
24784 URL used as link to a shortcut icon for cgit.
24785
24786 Defaults to @samp{"/favicon.ico"}.
24787
24788 @end deftypevr
24789
24790 @deftypevr {@code{cgit-configuration} parameter} string footer
24791 The content of the file specified with this option will be included
24792 verbatim at the bottom of all pages (i.e.@: it replaces the standard
24793 "generated by..."@: message).
24794
24795 Defaults to @samp{""}.
24796
24797 @end deftypevr
24798
24799 @deftypevr {@code{cgit-configuration} parameter} string head-include
24800 The content of the file specified with this option will be included
24801 verbatim in the HTML HEAD section on all pages.
24802
24803 Defaults to @samp{""}.
24804
24805 @end deftypevr
24806
24807 @deftypevr {@code{cgit-configuration} parameter} string header
24808 The content of the file specified with this option will be included
24809 verbatim at the top of all pages.
24810
24811 Defaults to @samp{""}.
24812
24813 @end deftypevr
24814
24815 @deftypevr {@code{cgit-configuration} parameter} file-object include
24816 Name of a configfile to include before the rest of the current config-
24817 file is parsed.
24818
24819 Defaults to @samp{""}.
24820
24821 @end deftypevr
24822
24823 @deftypevr {@code{cgit-configuration} parameter} string index-header
24824 The content of the file specified with this option will be included
24825 verbatim above the repository index.
24826
24827 Defaults to @samp{""}.
24828
24829 @end deftypevr
24830
24831 @deftypevr {@code{cgit-configuration} parameter} string index-info
24832 The content of the file specified with this option will be included
24833 verbatim below the heading on the repository index page.
24834
24835 Defaults to @samp{""}.
24836
24837 @end deftypevr
24838
24839 @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
24840 Flag which, if set to @samp{#t}, makes cgit print commit and tag times
24841 in the servers timezone.
24842
24843 Defaults to @samp{#f}.
24844
24845 @end deftypevr
24846
24847 @deftypevr {@code{cgit-configuration} parameter} file-object logo
24848 URL which specifies the source of an image which will be used as a logo
24849 on all cgit pages.
24850
24851 Defaults to @samp{"/share/cgit/cgit.png"}.
24852
24853 @end deftypevr
24854
24855 @deftypevr {@code{cgit-configuration} parameter} string logo-link
24856 URL loaded when clicking on the cgit logo image.
24857
24858 Defaults to @samp{""}.
24859
24860 @end deftypevr
24861
24862 @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
24863 Command which will be invoked to format the Owner column of the main
24864 page.
24865
24866 Defaults to @samp{""}.
24867
24868 @end deftypevr
24869
24870 @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
24871 Number of items to display in atom feeds view.
24872
24873 Defaults to @samp{10}.
24874
24875 @end deftypevr
24876
24877 @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
24878 Number of entries to list per page in "log" view.
24879
24880 Defaults to @samp{50}.
24881
24882 @end deftypevr
24883
24884 @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
24885 Number of commit message characters to display in "log" view.
24886
24887 Defaults to @samp{80}.
24888
24889 @end deftypevr
24890
24891 @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
24892 Specifies the number of entries to list per page on the repository index
24893 page.
24894
24895 Defaults to @samp{50}.
24896
24897 @end deftypevr
24898
24899 @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
24900 Specifies the maximum number of repo description characters to display
24901 on the repository index page.
24902
24903 Defaults to @samp{80}.
24904
24905 @end deftypevr
24906
24907 @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
24908 Specifies the maximum size of a blob to display HTML for in KBytes.
24909
24910 Defaults to @samp{0}.
24911
24912 @end deftypevr
24913
24914 @deftypevr {@code{cgit-configuration} parameter} string max-stats
24915 Maximum statistics period. Valid values are @samp{week},@samp{month},
24916 @samp{quarter} and @samp{year}.
24917
24918 Defaults to @samp{""}.
24919
24920 @end deftypevr
24921
24922 @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
24923 Mimetype for the specified filename extension.
24924
24925 Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
24926 "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
24927 "image/png") (svg "image/svg+xml"))}.
24928
24929 @end deftypevr
24930
24931 @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
24932 Specifies the file to use for automatic mimetype lookup.
24933
24934 Defaults to @samp{""}.
24935
24936 @end deftypevr
24937
24938 @deftypevr {@code{cgit-configuration} parameter} string module-link
24939 Text which will be used as the formatstring for a hyperlink when a
24940 submodule is printed in a directory listing.
24941
24942 Defaults to @samp{""}.
24943
24944 @end deftypevr
24945
24946 @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
24947 If set to the value @samp{#t} caching will be disabled.
24948
24949 Defaults to @samp{#f}.
24950
24951 @end deftypevr
24952
24953 @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
24954 If set to @samp{#t} showing full author email addresses will be
24955 disabled.
24956
24957 Defaults to @samp{#f}.
24958
24959 @end deftypevr
24960
24961 @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
24962 Flag which, when set to @samp{#t}, will make cgit omit the standard
24963 header on all pages.
24964
24965 Defaults to @samp{#f}.
24966
24967 @end deftypevr
24968
24969 @deftypevr {@code{cgit-configuration} parameter} project-list project-list
24970 A list of subdirectories inside of @code{repository-directory}, relative
24971 to it, that should loaded as Git repositories. An empty list means that
24972 all subdirectories will be loaded.
24973
24974 Defaults to @samp{()}.
24975
24976 @end deftypevr
24977
24978 @deftypevr {@code{cgit-configuration} parameter} file-object readme
24979 Text which will be used as default value for @code{cgit-repo-readme}.
24980
24981 Defaults to @samp{""}.
24982
24983 @end deftypevr
24984
24985 @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
24986 If set to @code{#t} and @code{repository-directory} is enabled, if any
24987 repositories are found with a suffix of @code{.git}, this suffix will be
24988 removed for the URL and name.
24989
24990 Defaults to @samp{#f}.
24991
24992 @end deftypevr
24993
24994 @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
24995 Maximum number of files to consider when detecting renames.
24996
24997 Defaults to @samp{-1}.
24998
24999 @end deftypevr
25000
25001 @deftypevr {@code{cgit-configuration} parameter} string repository-sort
25002 The way in which repositories in each section are sorted.
25003
25004 Defaults to @samp{""}.
25005
25006 @end deftypevr
25007
25008 @deftypevr {@code{cgit-configuration} parameter} robots-list robots
25009 Text used as content for the @code{robots} meta-tag.
25010
25011 Defaults to @samp{("noindex" "nofollow")}.
25012
25013 @end deftypevr
25014
25015 @deftypevr {@code{cgit-configuration} parameter} string root-desc
25016 Text printed below the heading on the repository index page.
25017
25018 Defaults to @samp{"a fast webinterface for the git dscm"}.
25019
25020 @end deftypevr
25021
25022 @deftypevr {@code{cgit-configuration} parameter} string root-readme
25023 The content of the file specified with this option will be included
25024 verbatim below the ``about'' link on the repository index page.
25025
25026 Defaults to @samp{""}.
25027
25028 @end deftypevr
25029
25030 @deftypevr {@code{cgit-configuration} parameter} string root-title
25031 Text printed as heading on the repository index page.
25032
25033 Defaults to @samp{""}.
25034
25035 @end deftypevr
25036
25037 @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
25038 If set to @samp{#t} and repository-directory is enabled,
25039 repository-directory will recurse into directories whose name starts
25040 with a period. Otherwise, repository-directory will stay away from such
25041 directories, considered as ``hidden''. Note that this does not apply to
25042 the @file{.git} directory in non-bare repos.
25043
25044 Defaults to @samp{#f}.
25045
25046 @end deftypevr
25047
25048 @deftypevr {@code{cgit-configuration} parameter} list snapshots
25049 Text which specifies the default set of snapshot formats that cgit
25050 generates links for.
25051
25052 Defaults to @samp{()}.
25053
25054 @end deftypevr
25055
25056 @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
25057 Name of the directory to scan for repositories (represents
25058 @code{scan-path}).
25059
25060 Defaults to @samp{"/srv/git"}.
25061
25062 @end deftypevr
25063
25064 @deftypevr {@code{cgit-configuration} parameter} string section
25065 The name of the current repository section - all repositories defined
25066 after this option will inherit the current section name.
25067
25068 Defaults to @samp{""}.
25069
25070 @end deftypevr
25071
25072 @deftypevr {@code{cgit-configuration} parameter} string section-sort
25073 Flag which, when set to @samp{1}, will sort the sections on the
25074 repository listing by name.
25075
25076 Defaults to @samp{""}.
25077
25078 @end deftypevr
25079
25080 @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
25081 A number which, if defined prior to repository-directory, specifies how
25082 many path elements from each repo path to use as a default section name.
25083
25084 Defaults to @samp{0}.
25085
25086 @end deftypevr
25087
25088 @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
25089 If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
25090 default.
25091
25092 Defaults to @samp{#f}.
25093
25094 @end deftypevr
25095
25096 @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
25097 Specifies a command which will be invoked to format plaintext blobs in
25098 the tree view.
25099
25100 Defaults to @samp{""}.
25101
25102 @end deftypevr
25103
25104 @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
25105 Specifies the number of branches to display in the repository ``summary''
25106 view.
25107
25108 Defaults to @samp{10}.
25109
25110 @end deftypevr
25111
25112 @deftypevr {@code{cgit-configuration} parameter} integer summary-log
25113 Specifies the number of log entries to display in the repository
25114 ``summary'' view.
25115
25116 Defaults to @samp{10}.
25117
25118 @end deftypevr
25119
25120 @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
25121 Specifies the number of tags to display in the repository ``summary''
25122 view.
25123
25124 Defaults to @samp{10}.
25125
25126 @end deftypevr
25127
25128 @deftypevr {@code{cgit-configuration} parameter} string strict-export
25129 Filename which, if specified, needs to be present within the repository
25130 for cgit to allow access to that repository.
25131
25132 Defaults to @samp{""}.
25133
25134 @end deftypevr
25135
25136 @deftypevr {@code{cgit-configuration} parameter} string virtual-root
25137 URL which, if specified, will be used as root for all cgit links.
25138
25139 Defaults to @samp{"/"}.
25140
25141 @end deftypevr
25142
25143 @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
25144 A list of @dfn{cgit-repo} records to use with config.
25145
25146 Defaults to @samp{()}.
25147
25148 Available @code{repository-cgit-configuration} fields are:
25149
25150 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
25151 A mask of snapshot formats for this repo that cgit generates links for,
25152 restricted by the global @code{snapshots} setting.
25153
25154 Defaults to @samp{()}.
25155
25156 @end deftypevr
25157
25158 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
25159 Override the default @code{source-filter}.
25160
25161 Defaults to @samp{""}.
25162
25163 @end deftypevr
25164
25165 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
25166 The relative URL used to access the repository.
25167
25168 Defaults to @samp{""}.
25169
25170 @end deftypevr
25171
25172 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
25173 Override the default @code{about-filter}.
25174
25175 Defaults to @samp{""}.
25176
25177 @end deftypevr
25178
25179 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
25180 Flag which, when set to @samp{age}, enables date ordering in the branch
25181 ref list, and when set to @samp{name} enables ordering by branch name.
25182
25183 Defaults to @samp{""}.
25184
25185 @end deftypevr
25186
25187 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
25188 A list of URLs which can be used to clone repo.
25189
25190 Defaults to @samp{()}.
25191
25192 @end deftypevr
25193
25194 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
25195 Override the default @code{commit-filter}.
25196
25197 Defaults to @samp{""}.
25198
25199 @end deftypevr
25200
25201 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
25202 Flag which, when set to @samp{date}, enables strict date ordering in the
25203 commit log, and when set to @samp{topo} enables strict topological
25204 ordering.
25205
25206 Defaults to @samp{""}.
25207
25208 @end deftypevr
25209
25210 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
25211 The name of the default branch for this repository. If no such branch
25212 exists in the repository, the first branch name (when sorted) is used as
25213 default instead. By default branch pointed to by HEAD, or ``master'' if
25214 there is no suitable HEAD.
25215
25216 Defaults to @samp{""}.
25217
25218 @end deftypevr
25219
25220 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
25221 The value to show as repository description.
25222
25223 Defaults to @samp{""}.
25224
25225 @end deftypevr
25226
25227 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
25228 The value to show as repository homepage.
25229
25230 Defaults to @samp{""}.
25231
25232 @end deftypevr
25233
25234 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
25235 Override the default @code{email-filter}.
25236
25237 Defaults to @samp{""}.
25238
25239 @end deftypevr
25240
25241 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
25242 A flag which can be used to disable the global setting
25243 @code{enable-commit-graph?}.
25244
25245 Defaults to @samp{disabled}.
25246
25247 @end deftypevr
25248
25249 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
25250 A flag which can be used to disable the global setting
25251 @code{enable-log-filecount?}.
25252
25253 Defaults to @samp{disabled}.
25254
25255 @end deftypevr
25256
25257 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
25258 A flag which can be used to disable the global setting
25259 @code{enable-log-linecount?}.
25260
25261 Defaults to @samp{disabled}.
25262
25263 @end deftypevr
25264
25265 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
25266 Flag which, when set to @code{#t}, will make cgit display remote
25267 branches in the summary and refs views.
25268
25269 Defaults to @samp{disabled}.
25270
25271 @end deftypevr
25272
25273 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
25274 A flag which can be used to override the global setting
25275 @code{enable-subject-links?}.
25276
25277 Defaults to @samp{disabled}.
25278
25279 @end deftypevr
25280
25281 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
25282 A flag which can be used to override the global setting
25283 @code{enable-html-serving?}.
25284
25285 Defaults to @samp{disabled}.
25286
25287 @end deftypevr
25288
25289 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
25290 Flag which, when set to @code{#t}, hides the repository from the
25291 repository index.
25292
25293 Defaults to @samp{#f}.
25294
25295 @end deftypevr
25296
25297 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
25298 Flag which, when set to @samp{#t}, ignores the repository.
25299
25300 Defaults to @samp{#f}.
25301
25302 @end deftypevr
25303
25304 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
25305 URL which specifies the source of an image which will be used as a logo
25306 on this repo’s pages.
25307
25308 Defaults to @samp{""}.
25309
25310 @end deftypevr
25311
25312 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
25313 URL loaded when clicking on the cgit logo image.
25314
25315 Defaults to @samp{""}.
25316
25317 @end deftypevr
25318
25319 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
25320 Override the default @code{owner-filter}.
25321
25322 Defaults to @samp{""}.
25323
25324 @end deftypevr
25325
25326 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
25327 Text which will be used as the formatstring for a hyperlink when a
25328 submodule is printed in a directory listing. The arguments for the
25329 formatstring are the path and SHA1 of the submodule commit.
25330
25331 Defaults to @samp{""}.
25332
25333 @end deftypevr
25334
25335 @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
25336 Text which will be used as the formatstring for a hyperlink when a
25337 submodule with the specified subdirectory path is printed in a directory
25338 listing.
25339
25340 Defaults to @samp{()}.
25341
25342 @end deftypevr
25343
25344 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
25345 Override the default maximum statistics period.
25346
25347 Defaults to @samp{""}.
25348
25349 @end deftypevr
25350
25351 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
25352 The value to show as repository name.
25353
25354 Defaults to @samp{""}.
25355
25356 @end deftypevr
25357
25358 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
25359 A value used to identify the owner of the repository.
25360
25361 Defaults to @samp{""}.
25362
25363 @end deftypevr
25364
25365 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
25366 An absolute path to the repository directory.
25367
25368 Defaults to @samp{""}.
25369
25370 @end deftypevr
25371
25372 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
25373 A path (relative to repo) which specifies a file to include verbatim as
25374 the ``About'' page for this repo.
25375
25376 Defaults to @samp{""}.
25377
25378 @end deftypevr
25379
25380 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
25381 The name of the current repository section - all repositories defined
25382 after this option will inherit the current section name.
25383
25384 Defaults to @samp{""}.
25385
25386 @end deftypevr
25387
25388 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
25389 Extra options will be appended to cgitrc file.
25390
25391 Defaults to @samp{()}.
25392
25393 @end deftypevr
25394
25395 @end deftypevr
25396
25397 @deftypevr {@code{cgit-configuration} parameter} list extra-options
25398 Extra options will be appended to cgitrc file.
25399
25400 Defaults to @samp{()}.
25401
25402 @end deftypevr
25403
25404
25405 @c %end of fragment
25406
25407 However, it could be that you just want to get a @code{cgitrc} up and
25408 running. In that case, you can pass an @code{opaque-cgit-configuration}
25409 as a record to @code{cgit-service-type}. As its name indicates, an
25410 opaque configuration does not have easy reflective capabilities.
25411
25412 Available @code{opaque-cgit-configuration} fields are:
25413
25414 @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
25415 The cgit package.
25416 @end deftypevr
25417
25418 @deftypevr {@code{opaque-cgit-configuration} parameter} string string
25419 The contents of the @code{cgitrc}, as a string.
25420 @end deftypevr
25421
25422 For example, if your @code{cgitrc} is just the empty string, you
25423 could instantiate a cgit service like this:
25424
25425 @lisp
25426 (service cgit-service-type
25427 (opaque-cgit-configuration
25428 (cgitrc "")))
25429 @end lisp
25430
25431 @subsubheading Gitolite Service
25432
25433 @cindex Gitolite service
25434 @cindex Git, hosting
25435 @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
25436 repositories on a central server.
25437
25438 Gitolite can handle multiple repositories and users, and supports flexible
25439 configuration of the permissions for the users on the repositories.
25440
25441 The following example will configure Gitolite using the default @code{git}
25442 user, and the provided SSH public key.
25443
25444 @lisp
25445 (service gitolite-service-type
25446 (gitolite-configuration
25447 (admin-pubkey (plain-file
25448 "yourname.pub"
25449 "ssh-rsa AAAA... guix@@example.com"))))
25450 @end lisp
25451
25452 Gitolite is configured through a special admin repository which you can clone,
25453 for example, if you setup Gitolite on @code{example.com}, you would run the
25454 following command to clone the admin repository.
25455
25456 @example
25457 git clone git@@example.com:gitolite-admin
25458 @end example
25459
25460 When the Gitolite service is activated, the provided @code{admin-pubkey} will
25461 be inserted in to the @file{keydir} directory in the gitolite-admin
25462 repository. If this results in a change in the repository, it will be
25463 committed using the message ``gitolite setup by GNU Guix''.
25464
25465 @deftp {Data Type} gitolite-configuration
25466 Data type representing the configuration for @code{gitolite-service-type}.
25467
25468 @table @asis
25469 @item @code{package} (default: @var{gitolite})
25470 Gitolite package to use.
25471
25472 @item @code{user} (default: @var{git})
25473 User to use for Gitolite. This will be user that you use when accessing
25474 Gitolite over SSH.
25475
25476 @item @code{group} (default: @var{git})
25477 Group to use for Gitolite.
25478
25479 @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
25480 Directory in which to store the Gitolite configuration and repositories.
25481
25482 @item @code{rc-file} (default: @var{(gitolite-rc-file)})
25483 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
25484 representing the configuration for Gitolite.
25485
25486 @item @code{admin-pubkey} (default: @var{#f})
25487 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
25488 setup Gitolite. This will be inserted in to the @file{keydir} directory
25489 within the gitolite-admin repository.
25490
25491 To specify the SSH key as a string, use the @code{plain-file} function.
25492
25493 @lisp
25494 (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
25495 @end lisp
25496
25497 @end table
25498 @end deftp
25499
25500 @deftp {Data Type} gitolite-rc-file
25501 Data type representing the Gitolite RC file.
25502
25503 @table @asis
25504 @item @code{umask} (default: @code{#o0077})
25505 This controls the permissions Gitolite sets on the repositories and their
25506 contents.
25507
25508 A value like @code{#o0027} will give read access to the group used by Gitolite
25509 (by default: @code{git}). This is necessary when using Gitolite with software
25510 like cgit or gitweb.
25511
25512 @item @code{git-config-keys} (default: @code{""})
25513 Gitolite allows you to set git config values using the @samp{config} keyword. This
25514 setting allows control over the config keys to accept.
25515
25516 @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
25517 Set the role names allowed to be used by users running the perms command.
25518
25519 @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
25520 This setting controls the commands and features to enable within Gitolite.
25521
25522 @end table
25523 @end deftp
25524
25525
25526 @node Game Services
25527 @subsection Game Services
25528
25529 @subsubheading The Battle for Wesnoth Service
25530 @cindex wesnothd
25531 @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
25532 based tactical strategy game, with several single player campaigns, and
25533 multiplayer games (both networked and local).
25534
25535 @defvar {Scheme Variable} wesnothd-service-type
25536 Service type for the wesnothd service. Its value must be a
25537 @code{wesnothd-configuration} object. To run wesnothd in the default
25538 configuration, instantiate it as:
25539
25540 @lisp
25541 (service wesnothd-service-type)
25542 @end lisp
25543 @end defvar
25544
25545 @deftp {Data Type} wesnothd-configuration
25546 Data type representing the configuration of @command{wesnothd}.
25547
25548 @table @asis
25549 @item @code{package} (default: @code{wesnoth-server})
25550 The wesnoth server package to use.
25551
25552 @item @code{port} (default: @code{15000})
25553 The port to bind the server to.
25554 @end table
25555 @end deftp
25556
25557
25558 @node PAM Mount Service
25559 @subsection PAM Mount Service
25560 @cindex pam-mount
25561
25562 The @code{(gnu services pam-mount)} module provides a service allowing
25563 users to mount volumes when they log in. It should be able to mount any
25564 volume format supported by the system.
25565
25566 @defvar {Scheme Variable} pam-mount-service-type
25567 Service type for PAM Mount support.
25568 @end defvar
25569
25570 @deftp {Data Type} pam-mount-configuration
25571 Data type representing the configuration of PAM Mount.
25572
25573 It takes the following parameters:
25574
25575 @table @asis
25576 @item @code{rules}
25577 The configuration rules that will be used to generate
25578 @file{/etc/security/pam_mount.conf.xml}.
25579
25580 The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
25581 Guile Reference Manual}), and the the default ones don't mount anything
25582 for anyone at login:
25583
25584 @lisp
25585 `((debug (@@ (enable "0")))
25586 (mntoptions (@@ (allow ,(string-join
25587 '("nosuid" "nodev" "loop"
25588 "encryption" "fsck" "nonempty"
25589 "allow_root" "allow_other")
25590 ","))))
25591 (mntoptions (@@ (require "nosuid,nodev")))
25592 (logout (@@ (wait "0")
25593 (hup "0")
25594 (term "no")
25595 (kill "no")))
25596 (mkmountpoint (@@ (enable "1")
25597 (remove "true"))))
25598 @end lisp
25599
25600 Some @code{volume} elements must be added to automatically mount volumes
25601 at login. Here's an example allowing the user @code{alice} to mount her
25602 encrypted @env{HOME} directory and allowing the user @code{bob} to mount
25603 the partition where he stores his data:
25604
25605 @lisp
25606 (define pam-mount-rules
25607 `((debug (@@ (enable "0")))
25608 (volume (@@ (user "alice")
25609 (fstype "crypt")
25610 (path "/dev/sda2")
25611 (mountpoint "/home/alice")))
25612 (volume (@@ (user "bob")
25613 (fstype "auto")
25614 (path "/dev/sdb3")
25615 (mountpoint "/home/bob/data")
25616 (options "defaults,autodefrag,compress")))
25617 (mntoptions (@@ (allow ,(string-join
25618 '("nosuid" "nodev" "loop"
25619 "encryption" "fsck" "nonempty"
25620 "allow_root" "allow_other")
25621 ","))))
25622 (mntoptions (@@ (require "nosuid,nodev")))
25623 (logout (@@ (wait "0")
25624 (hup "0")
25625 (term "no")
25626 (kill "no")))
25627 (mkmountpoint (@@ (enable "1")
25628 (remove "true")))))
25629
25630 (service pam-mount-service-type
25631 (pam-mount-configuration
25632 (rules pam-mount-rules)))
25633 @end lisp
25634
25635 The complete list of possible options can be found in the man page for
25636 @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
25637 @end table
25638 @end deftp
25639
25640
25641 @node Guix Services
25642 @subsection Guix Services
25643
25644 @subsubheading Guix Data Service
25645 The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
25646 and provides data about GNU Guix. This includes information about
25647 packages, derivations and lint warnings.
25648
25649 The data is stored in a PostgreSQL database, and available through a web
25650 interface.
25651
25652 @defvar {Scheme Variable} guix-data-service-type
25653 Service type for the Guix Data Service. Its value must be a
25654 @code{guix-data-service-configuration} object. The service optionally
25655 extends the getmail service, as the guix-commits mailing list is used to
25656 find out about changes in the Guix git repository.
25657 @end defvar
25658
25659 @deftp {Data Type} guix-data-service-configuration
25660 Data type representing the configuration of the Guix Data Service.
25661
25662 @table @asis
25663 @item @code{package} (default: @code{guix-data-service})
25664 The Guix Data Service package to use.
25665
25666 @item @code{user} (default: @code{"guix-data-service"})
25667 The system user to run the service as.
25668
25669 @item @code{group} (default: @code{"guix-data-service"})
25670 The system group to run the service as.
25671
25672 @item @code{port} (default: @code{8765})
25673 The port to bind the web service to.
25674
25675 @item @code{host} (default: @code{"127.0.0.1"})
25676 The host to bind the web service to.
25677
25678 @item @code{getmail-idle-mailboxes} (default: @code{#f})
25679 If set, this is the list of mailboxes that the getmail service will be
25680 configured to listen to.
25681
25682 @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
25683 If set, this is the @code{getmail-retriever-configuration} object with
25684 which to configure getmail to fetch mail from the guix-commits mailing
25685 list.
25686
25687 @item @code{extra-options} (default: @var{'()})
25688 Extra command line options for @code{guix-data-service}.
25689
25690 @item @code{extra-process-jobs-options} (default: @var{'()})
25691 Extra command line options for @code{guix-data-service-process-jobs}.
25692
25693 @end table
25694 @end deftp
25695
25696 @node Linux Services
25697 @subsection Linux Services
25698
25699 @cindex oom
25700 @cindex out of memory killer
25701 @cindex earlyoom
25702 @cindex early out of memory daemon
25703 @subsubheading Early OOM Service
25704
25705 @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
25706 Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
25707 space and provides a more responsive and configurable alternative to the
25708 in-kernel OOM killer. It is useful to prevent the system from becoming
25709 unresponsive when it runs out of memory.
25710
25711 @deffn {Scheme Variable} earlyoom-service-type
25712 The service type for running @command{earlyoom}, the Early OOM daemon.
25713 Its value must be a @code{earlyoom-configuration} object, described
25714 below. The service can be instantiated in its default configuration
25715 with:
25716
25717 @lisp
25718 (service earlyoom-service-type)
25719 @end lisp
25720 @end deffn
25721
25722 @deftp {Data Type} earlyoom-configuration
25723 This is the configuration record for the @code{earlyoom-service-type}.
25724
25725 @table @asis
25726 @item @code{earlyoom} (default: @var{earlyoom})
25727 The Earlyoom package to use.
25728
25729 @item @code{minimum-available-memory} (default: @code{10})
25730 The threshold for the minimum @emph{available} memory, in percentages.
25731
25732 @item @code{minimum-free-swap} (default: @code{10})
25733 The threshold for the minimum free swap memory, in percentages.
25734
25735 @item @code{prefer-regexp} (default: @code{#f})
25736 A regular expression (as a string) to match the names of the processes
25737 that should be preferably killed.
25738
25739 @item @code{avoid-regexp} (default: @code{#f})
25740 A regular expression (as a string) to match the names of the processes
25741 that should @emph{not} be killed.
25742
25743 @item @code{memory-report-interval} (default: @code{0})
25744 The interval in seconds at which a memory report is printed. It is
25745 disabled by default.
25746
25747 @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
25748 A boolean indicating whether the positive adjustments set in
25749 @file{/proc/*/oom_score_adj}.
25750
25751 @item @code{show-debug-messages?} (default: @code{#f})
25752 A boolean indicating whether debug messages should be printed. The logs
25753 are saved at @file{/var/log/earlyoom.log}.
25754
25755 @item @code{send-notification-command} (default: @code{#f})
25756 This can be used to provide a custom command used for sending
25757 notifications.
25758 @end table
25759 @end deftp
25760
25761 @cindex modprobe
25762 @cindex kernel module loader
25763 @subsubheading Kernel Module Loader Service
25764
25765 The kernel module loader service allows one to load loadable kernel
25766 modules at boot. This is especially useful for modules that don't
25767 autoload and need to be manually loaded, as it's the case with
25768 @code{ddcci}.
25769
25770 @deffn {Scheme Variable} kernel-module-loader-service-type
25771 The service type for loading loadable kernel modules at boot with
25772 @command{modprobe}. Its value must be a list of strings representing
25773 module names. For example loading the drivers provided by
25774 @code{ddcci-driver-linux}, in debugging mode by passing some module
25775 parameters, can be done as follow:
25776
25777 @lisp
25778 (use-modules (gnu) (gnu services))
25779 (use-package-modules linux)
25780 (use-service-modules linux)
25781
25782 (define ddcci-config
25783 (plain-file "ddcci.conf"
25784 "options ddcci dyndbg delay=120"))
25785
25786 (operating-system
25787 ...
25788 (services (cons* (service kernel-module-loader-service-type
25789 '("ddcci" "ddcci_backlight"))
25790 (simple-service 'ddcci-config etc-service-type
25791 (list `("modprobe.d/ddcci.conf"
25792 ,ddcci-config)))
25793 %base-services))
25794 (kernel-loadable-modules (list ddcci-driver-linux)))
25795 @end lisp
25796 @end deffn
25797
25798 @node Miscellaneous Services
25799 @subsection Miscellaneous Services
25800
25801 @cindex fingerprint
25802 @subsubheading Fingerprint Service
25803
25804 The @code{(gnu services authentication)} module provides a DBus service to
25805 read and identify fingerprints via a fingerprint sensor.
25806
25807 @defvr {Scheme Variable} fprintd-service-type
25808 The service type for @command{fprintd}, which provides the fingerprint
25809 reading capability.
25810
25811 @lisp
25812 (service fprintd-service-type)
25813 @end lisp
25814 @end defvr
25815
25816 @cindex sysctl
25817 @subsubheading System Control Service
25818
25819 The @code{(gnu services sysctl)} provides a service to configure kernel
25820 parameters at boot.
25821
25822 @defvr {Scheme Variable} sysctl-service-type
25823 The service type for @command{sysctl}, which modifies kernel parameters
25824 under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
25825 instantiated as:
25826
25827 @lisp
25828 (service sysctl-service-type
25829 (sysctl-configuration
25830 (settings '(("net.ipv4.ip_forward" . "1")))))
25831 @end lisp
25832 @end defvr
25833
25834 @deftp {Data Type} sysctl-configuration
25835 The data type representing the configuration of @command{sysctl}.
25836
25837 @table @asis
25838 @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
25839 The @command{sysctl} executable to use.
25840
25841 @item @code{settings} (default: @code{'()})
25842 An association list specifies kernel parameters and their values.
25843 @end table
25844 @end deftp
25845
25846 @cindex pcscd
25847 @subsubheading PC/SC Smart Card Daemon Service
25848
25849 The @code{(gnu services security-token)} module provides the following service
25850 to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
25851 daemon program for pcsc-lite and the MuscleCard framework. It is a resource
25852 manager that coordinates communications with smart card readers, smart cards
25853 and cryptographic tokens that are connected to the system.
25854
25855 @defvr {Scheme Variable} pcscd-service-type
25856 Service type for the @command{pcscd} service. Its value must be a
25857 @code{pcscd-configuration} object. To run pcscd in the default
25858 configuration, instantiate it as:
25859
25860 @lisp
25861 (service pcscd-service-type)
25862 @end lisp
25863 @end defvr
25864
25865 @deftp {Data Type} pcscd-configuration
25866 The data type representing the configuration of @command{pcscd}.
25867
25868 @table @asis
25869 @item @code{pcsc-lite} (default: @code{pcsc-lite})
25870 The pcsc-lite package that provides pcscd.
25871 @item @code{usb-drivers} (default: @code{(list ccid)})
25872 List of packages that provide USB drivers to pcscd. Drivers are expected to be
25873 under @file{pcsc/drivers} in the store directory of the package.
25874 @end table
25875 @end deftp
25876
25877 @cindex lirc
25878 @subsubheading Lirc Service
25879
25880 The @code{(gnu services lirc)} module provides the following service.
25881
25882 @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
25883 [#:device #f] [#:driver #f] [#:config-file #f] @
25884 [#:extra-options '()]
25885 Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
25886 decodes infrared signals from remote controls.
25887
25888 Optionally, @var{device}, @var{driver} and @var{config-file}
25889 (configuration file name) may be specified. See @command{lircd} manual
25890 for details.
25891
25892 Finally, @var{extra-options} is a list of additional command-line options
25893 passed to @command{lircd}.
25894 @end deffn
25895
25896 @cindex spice
25897 @subsubheading Spice Service
25898
25899 The @code{(gnu services spice)} module provides the following service.
25900
25901 @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
25902 Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
25903 that enables sharing the clipboard with a vm and setting the guest display
25904 resolution when the graphical console window resizes.
25905 @end deffn
25906
25907 @cindex inputattach
25908 @subsubheading inputattach Service
25909
25910 @cindex tablet input, for Xorg
25911 @cindex touchscreen input, for Xorg
25912 The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
25913 use input devices such as Wacom tablets, touchscreens, or joysticks with the
25914 Xorg display server.
25915
25916 @deffn {Scheme Variable} inputattach-service-type
25917 Type of a service that runs @command{inputattach} on a device and
25918 dispatches events from it.
25919 @end deffn
25920
25921 @deftp {Data Type} inputattach-configuration
25922 @table @asis
25923 @item @code{device-type} (default: @code{"wacom"})
25924 The type of device to connect to. Run @command{inputattach --help}, from the
25925 @code{inputattach} package, to see the list of supported device types.
25926
25927 @item @code{device} (default: @code{"/dev/ttyS0"})
25928 The device file to connect to the device.
25929
25930 @item @code{baud-rate} (default: @code{#f})
25931 Baud rate to use for the serial connection.
25932 Should be a number or @code{#f}.
25933
25934 @item @code{log-file} (default: @code{#f})
25935 If true, this must be the name of a file to log messages to.
25936 @end table
25937 @end deftp
25938
25939 @subsubheading Dictionary Service
25940 @cindex dictionary
25941 The @code{(gnu services dict)} module provides the following service:
25942
25943 @defvr {Scheme Variable} dicod-service-type
25944 This is the type of the service that runs the @command{dicod} daemon, an
25945 implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
25946 @end defvr
25947
25948 @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
25949 Return a service that runs the @command{dicod} daemon, an implementation
25950 of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
25951
25952 The optional @var{config} argument specifies the configuration for
25953 @command{dicod}, which should be a @code{<dicod-configuration>} object, by
25954 default it serves the GNU Collaborative International Dictionary of English.
25955
25956 You can add @command{open localhost} to your @file{~/.dico} file to make
25957 @code{localhost} the default server for @command{dico} client
25958 (@pxref{Initialization File,,, dico, GNU Dico Manual}).
25959 @end deffn
25960
25961 @deftp {Data Type} dicod-configuration
25962 Data type representing the configuration of dicod.
25963
25964 @table @asis
25965 @item @code{dico} (default: @var{dico})
25966 Package object of the GNU Dico dictionary server.
25967
25968 @item @code{interfaces} (default: @var{'("localhost")})
25969 This is the list of IP addresses and ports and possibly socket file
25970 names to listen to (@pxref{Server Settings, @code{listen} directive,,
25971 dico, GNU Dico Manual}).
25972
25973 @item @code{handlers} (default: @var{'()})
25974 List of @code{<dicod-handler>} objects denoting handlers (module instances).
25975
25976 @item @code{databases} (default: @var{(list %dicod-database:gcide)})
25977 List of @code{<dicod-database>} objects denoting dictionaries to be served.
25978 @end table
25979 @end deftp
25980
25981 @deftp {Data Type} dicod-handler
25982 Data type representing a dictionary handler (module instance).
25983
25984 @table @asis
25985 @item @code{name}
25986 Name of the handler (module instance).
25987
25988 @item @code{module} (default: @var{#f})
25989 Name of the dicod module of the handler (instance). If it is @code{#f},
25990 the module has the same name as the handler.
25991 (@pxref{Modules,,, dico, GNU Dico Manual}).
25992
25993 @item @code{options}
25994 List of strings or gexps representing the arguments for the module handler
25995 @end table
25996 @end deftp
25997
25998 @deftp {Data Type} dicod-database
25999 Data type representing a dictionary database.
26000
26001 @table @asis
26002 @item @code{name}
26003 Name of the database, will be used in DICT commands.
26004
26005 @item @code{handler}
26006 Name of the dicod handler (module instance) used by this database
26007 (@pxref{Handlers,,, dico, GNU Dico Manual}).
26008
26009 @item @code{complex?} (default: @var{#f})
26010 Whether the database configuration complex. The complex configuration
26011 will need a corresponding @code{<dicod-handler>} object, otherwise not.
26012
26013 @item @code{options}
26014 List of strings or gexps representing the arguments for the database
26015 (@pxref{Databases,,, dico, GNU Dico Manual}).
26016 @end table
26017 @end deftp
26018
26019 @defvr {Scheme Variable} %dicod-database:gcide
26020 A @code{<dicod-database>} object serving the GNU Collaborative International
26021 Dictionary of English using the @code{gcide} package.
26022 @end defvr
26023
26024 The following is an example @code{dicod-service} configuration.
26025
26026 @lisp
26027 (dicod-service #:config
26028 (dicod-configuration
26029 (handlers (list (dicod-handler
26030 (name "wordnet")
26031 (module "dictorg")
26032 (options
26033 (list #~(string-append "dbdir=" #$wordnet))))))
26034 (databases (list (dicod-database
26035 (name "wordnet")
26036 (complex? #t)
26037 (handler "wordnet")
26038 (options '("database=wn")))
26039 %dicod-database:gcide))))
26040 @end lisp
26041
26042 @cindex Docker
26043 @subsubheading Docker Service
26044
26045 The @code{(gnu services docker)} module provides the following services.
26046
26047 @defvr {Scheme Variable} docker-service-type
26048
26049 This is the type of the service that runs @url{https://www.docker.com,Docker},
26050 a daemon that can execute application bundles (sometimes referred to as
26051 ``containers'') in isolated environments.
26052
26053 @end defvr
26054
26055 @deftp {Data Type} docker-configuration
26056 This is the data type representing the configuration of Docker and Containerd.
26057
26058 @table @asis
26059
26060 @item @code{package} (default: @code{docker})
26061 The Docker package to use.
26062
26063 @item @code{containerd} (default: @var{containerd})
26064 The Containerd package to use.
26065
26066 @end table
26067 @end deftp
26068
26069 @cindex Audit
26070 @subsubheading Auditd Service
26071
26072 The @code{(gnu services auditd)} module provides the following service.
26073
26074 @defvr {Scheme Variable} auditd-service-type
26075
26076 This is the type of the service that runs
26077 @url{https://people.redhat.com/sgrubb/audit/,auditd},
26078 a daemon that tracks security-relevant information on your system.
26079
26080 Examples of things that can be tracked:
26081
26082 @enumerate
26083 @item
26084 File accesses
26085 @item
26086 System calls
26087 @item
26088 Invoked commands
26089 @item
26090 Failed login attempts
26091 @item
26092 Firewall filtering
26093 @item
26094 Network access
26095 @end enumerate
26096
26097 @command{auditctl} from the @code{audit} package can be used in order
26098 to add or remove events to be tracked (until the next reboot).
26099 In order to permanently track events, put the command line arguments
26100 of auditctl into @file{/etc/audit/audit.rules}.
26101 @command{aureport} from the @code{audit} package can be used in order
26102 to view a report of all recorded events.
26103 The audit daemon usually logs into the directory @file{/var/log/audit}.
26104
26105 @end defvr
26106
26107 @deftp {Data Type} auditd-configuration
26108 This is the data type representing the configuration of auditd.
26109
26110 @table @asis
26111
26112 @item @code{audit} (default: @code{audit})
26113 The audit package to use.
26114
26115 @end table
26116 @end deftp
26117
26118 @defvr {Scheme Variable} singularity-service-type
26119 This is the type of the service that allows you to run
26120 @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
26121 create and run application bundles (aka. ``containers''). The value for this
26122 service is the Singularity package to use.
26123
26124 The service does not install a daemon; instead, it installs helper programs as
26125 setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
26126 @command{singularity run} and similar commands.
26127 @end defvr
26128
26129 @cindex Nix
26130 @subsubheading Nix service
26131
26132 The @code{(gnu services nix)} module provides the following service.
26133
26134 @defvr {Scheme Variable} nix-service-type
26135
26136 This is the type of the service that runs build daemon of the
26137 @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
26138 how to use it:
26139
26140 @lisp
26141 (use-modules (gnu))
26142 (use-service-modules nix)
26143 (use-package-modules package-management)
26144
26145 (operating-system
26146 ;; @dots{}
26147 (packages (append (list nix)
26148 %base-packages))
26149
26150 (services (append (list (service nix-service-type))
26151 %base-services)))
26152 @end lisp
26153
26154 After @command{guix system reconfigure} configure Nix for your user:
26155
26156 @itemize
26157 @item Add a Nix channel and update it. See
26158 @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
26159
26160 @item Create a symlink to your profile and activate Nix profile:
26161 @end itemize
26162
26163 @example
26164 $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
26165 $ source /run/current-system/profile/etc/profile.d/nix.sh
26166 @end example
26167
26168 @end defvr
26169
26170 @node Setuid Programs
26171 @section Setuid Programs
26172
26173 @cindex setuid programs
26174 Some programs need to run with ``root'' privileges, even when they are
26175 launched by unprivileged users. A notorious example is the
26176 @command{passwd} program, which users can run to change their
26177 password, and which needs to access the @file{/etc/passwd} and
26178 @file{/etc/shadow} files---something normally restricted to root, for
26179 obvious security reasons. To address that, these executables are
26180 @dfn{setuid-root}, meaning that they always run with root privileges
26181 (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
26182 for more info about the setuid mechanism.)
26183
26184 The store itself @emph{cannot} contain setuid programs: that would be a
26185 security issue since any user on the system can write derivations that
26186 populate the store (@pxref{The Store}). Thus, a different mechanism is
26187 used: instead of changing the setuid bit directly on files that are in
26188 the store, we let the system administrator @emph{declare} which programs
26189 should be setuid root.
26190
26191 The @code{setuid-programs} field of an @code{operating-system}
26192 declaration contains a list of G-expressions denoting the names of
26193 programs to be setuid-root (@pxref{Using the Configuration System}).
26194 For instance, the @command{passwd} program, which is part of the Shadow
26195 package, can be designated by this G-expression (@pxref{G-Expressions}):
26196
26197 @example
26198 #~(string-append #$shadow "/bin/passwd")
26199 @end example
26200
26201 A default set of setuid programs is defined by the
26202 @code{%setuid-programs} variable of the @code{(gnu system)} module.
26203
26204 @defvr {Scheme Variable} %setuid-programs
26205 A list of G-expressions denoting common programs that are setuid-root.
26206
26207 The list includes commands such as @command{passwd}, @command{ping},
26208 @command{su}, and @command{sudo}.
26209 @end defvr
26210
26211 Under the hood, the actual setuid programs are created in the
26212 @file{/run/setuid-programs} directory at system activation time. The
26213 files in this directory refer to the ``real'' binaries, which are in the
26214 store.
26215
26216 @node X.509 Certificates
26217 @section X.509 Certificates
26218
26219 @cindex HTTPS, certificates
26220 @cindex X.509 certificates
26221 @cindex TLS
26222 Web servers available over HTTPS (that is, HTTP over the transport-layer
26223 security mechanism, TLS) send client programs an @dfn{X.509 certificate}
26224 that the client can then use to @emph{authenticate} the server. To do
26225 that, clients verify that the server's certificate is signed by a
26226 so-called @dfn{certificate authority} (CA). But to verify the CA's
26227 signature, clients must have first acquired the CA's certificate.
26228
26229 Web browsers such as GNU@tie{}IceCat include their own set of CA
26230 certificates, such that they are able to verify CA signatures
26231 out-of-the-box.
26232
26233 However, most other programs that can talk HTTPS---@command{wget},
26234 @command{git}, @command{w3m}, etc.---need to be told where CA
26235 certificates can be found.
26236
26237 @cindex @code{nss-certs}
26238 In Guix, this is done by adding a package that provides certificates
26239 to the @code{packages} field of the @code{operating-system} declaration
26240 (@pxref{operating-system Reference}). Guix includes one such package,
26241 @code{nss-certs}, which is a set of CA certificates provided as part of
26242 Mozilla's Network Security Services.
26243
26244 Note that it is @emph{not} part of @code{%base-packages}, so you need to
26245 explicitly add it. The @file{/etc/ssl/certs} directory, which is where
26246 most applications and libraries look for certificates by default, points
26247 to the certificates installed globally.
26248
26249 Unprivileged users, including users of Guix on a foreign distro,
26250 can also install their own certificate package in
26251 their profile. A number of environment variables need to be defined so
26252 that applications and libraries know where to find them. Namely, the
26253 OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
26254 variables. Some applications add their own environment variables; for
26255 instance, the Git version control system honors the certificate bundle
26256 pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
26257 would typically run something like:
26258
26259 @example
26260 guix install nss-certs
26261 export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
26262 export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
26263 export GIT_SSL_CAINFO="$SSL_CERT_FILE"
26264 @end example
26265
26266 As another example, R requires the @env{CURL_CA_BUNDLE} environment
26267 variable to point to a certificate bundle, so you would have to run
26268 something like this:
26269
26270 @example
26271 guix install nss-certs
26272 export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
26273 @end example
26274
26275 For other applications you may want to look up the required environment
26276 variable in the relevant documentation.
26277
26278
26279 @node Name Service Switch
26280 @section Name Service Switch
26281
26282 @cindex name service switch
26283 @cindex NSS
26284 The @code{(gnu system nss)} module provides bindings to the
26285 configuration file of the libc @dfn{name service switch} or @dfn{NSS}
26286 (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
26287 Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
26288 extended with new ``name'' lookup methods for system databases, which
26289 includes host names, service names, user accounts, and more (@pxref{Name
26290 Service Switch, System Databases and Name Service Switch,, libc, The GNU
26291 C Library Reference Manual}).
26292
26293 The NSS configuration specifies, for each system database, which lookup
26294 method is to be used, and how the various methods are chained
26295 together---for instance, under which circumstances NSS should try the
26296 next method in the list. The NSS configuration is given in the
26297 @code{name-service-switch} field of @code{operating-system} declarations
26298 (@pxref{operating-system Reference, @code{name-service-switch}}).
26299
26300 @cindex nss-mdns
26301 @cindex .local, host name lookup
26302 As an example, the declaration below configures the NSS to use the
26303 @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
26304 back-end}, which supports host name lookups over multicast DNS (mDNS)
26305 for host names ending in @code{.local}:
26306
26307 @lisp
26308 (name-service-switch
26309 (hosts (list %files ;first, check /etc/hosts
26310
26311 ;; If the above did not succeed, try
26312 ;; with 'mdns_minimal'.
26313 (name-service
26314 (name "mdns_minimal")
26315
26316 ;; 'mdns_minimal' is authoritative for
26317 ;; '.local'. When it returns "not found",
26318 ;; no need to try the next methods.
26319 (reaction (lookup-specification
26320 (not-found => return))))
26321
26322 ;; Then fall back to DNS.
26323 (name-service
26324 (name "dns"))
26325
26326 ;; Finally, try with the "full" 'mdns'.
26327 (name-service
26328 (name "mdns")))))
26329 @end lisp
26330
26331 Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
26332 contains this configuration, so you will not have to type it if all you
26333 want is to have @code{.local} host lookup working.
26334
26335 Note that, in this case, in addition to setting the
26336 @code{name-service-switch} of the @code{operating-system} declaration,
26337 you also need to use @code{avahi-service-type} (@pxref{Networking Services,
26338 @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
26339 (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
26340 to the name service cache daemon (@pxref{Base Services,
26341 @code{nscd-service}}).
26342
26343 For convenience, the following variables provide typical NSS
26344 configurations.
26345
26346 @defvr {Scheme Variable} %default-nss
26347 This is the default name service switch configuration, a
26348 @code{name-service-switch} object.
26349 @end defvr
26350
26351 @defvr {Scheme Variable} %mdns-host-lookup-nss
26352 This is the name service switch configuration with support for host name
26353 lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
26354 @end defvr
26355
26356 The reference for name service switch configuration is given below. It
26357 is a direct mapping of the configuration file format of the C library , so
26358 please refer to the C library manual for more information (@pxref{NSS
26359 Configuration File,,, libc, The GNU C Library Reference Manual}).
26360 Compared to the configuration file format of libc NSS, it has the advantage
26361 not only of adding this warm parenthetic feel that we like, but also
26362 static checks: you will know about syntax errors and typos as soon as you
26363 run @command{guix system}.
26364
26365 @deftp {Data Type} name-service-switch
26366
26367 This is the data type representation the configuration of libc's name
26368 service switch (NSS). Each field below represents one of the supported
26369 system databases.
26370
26371 @table @code
26372 @item aliases
26373 @itemx ethers
26374 @itemx group
26375 @itemx gshadow
26376 @itemx hosts
26377 @itemx initgroups
26378 @itemx netgroup
26379 @itemx networks
26380 @itemx password
26381 @itemx public-key
26382 @itemx rpc
26383 @itemx services
26384 @itemx shadow
26385 The system databases handled by the NSS. Each of these fields must be a
26386 list of @code{<name-service>} objects (see below).
26387 @end table
26388 @end deftp
26389
26390 @deftp {Data Type} name-service
26391
26392 This is the data type representing an actual name service and the
26393 associated lookup action.
26394
26395 @table @code
26396 @item name
26397 A string denoting the name service (@pxref{Services in the NSS
26398 configuration,,, libc, The GNU C Library Reference Manual}).
26399
26400 Note that name services listed here must be visible to nscd. This is
26401 achieved by passing the @code{#:name-services} argument to
26402 @code{nscd-service} the list of packages providing the needed name
26403 services (@pxref{Base Services, @code{nscd-service}}).
26404
26405 @item reaction
26406 An action specified using the @code{lookup-specification} macro
26407 (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
26408 Reference Manual}). For example:
26409
26410 @lisp
26411 (lookup-specification (unavailable => continue)
26412 (success => return))
26413 @end lisp
26414 @end table
26415 @end deftp
26416
26417 @node Initial RAM Disk
26418 @section Initial RAM Disk
26419
26420 @cindex initrd
26421 @cindex initial RAM disk
26422 For bootstrapping purposes, the Linux-Libre kernel is passed an
26423 @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
26424 root file system as well as an initialization script. The latter is
26425 responsible for mounting the real root file system, and for loading any
26426 kernel modules that may be needed to achieve that.
26427
26428 The @code{initrd-modules} field of an @code{operating-system}
26429 declaration allows you to specify Linux-libre kernel modules that must
26430 be available in the initrd. In particular, this is where you would list
26431 modules needed to actually drive the hard disk where your root partition
26432 is---although the default value of @code{initrd-modules} should cover
26433 most use cases. For example, assuming you need the @code{megaraid_sas}
26434 module in addition to the default modules to be able to access your root
26435 file system, you would write:
26436
26437 @lisp
26438 (operating-system
26439 ;; @dots{}
26440 (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
26441 @end lisp
26442
26443 @defvr {Scheme Variable} %base-initrd-modules
26444 This is the list of kernel modules included in the initrd by default.
26445 @end defvr
26446
26447 Furthermore, if you need lower-level customization, the @code{initrd}
26448 field of an @code{operating-system} declaration allows
26449 you to specify which initrd you would like to use. The @code{(gnu
26450 system linux-initrd)} module provides three ways to build an initrd: the
26451 high-level @code{base-initrd} procedure and the low-level
26452 @code{raw-initrd} and @code{expression->initrd} procedures.
26453
26454 The @code{base-initrd} procedure is intended to cover most common uses.
26455 For example, if you want to add a bunch of kernel modules to be loaded
26456 at boot time, you can define the @code{initrd} field of the operating
26457 system declaration like this:
26458
26459 @lisp
26460 (initrd (lambda (file-systems . rest)
26461 ;; Create a standard initrd but set up networking
26462 ;; with the parameters QEMU expects by default.
26463 (apply base-initrd file-systems
26464 #:qemu-networking? #t
26465 rest)))
26466 @end lisp
26467
26468 The @code{base-initrd} procedure also handles common use cases that
26469 involves using the system as a QEMU guest, or as a ``live'' system with
26470 volatile root file system.
26471
26472 The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
26473 Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
26474 such as trying to guess which kernel modules and packages should be included
26475 to the initrd. An example use of @code{raw-initrd} is when a user has
26476 a custom Linux kernel configuration and default kernel modules included by
26477 @code{base-initrd} are not available.
26478
26479 The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
26480 honors several options passed on the Linux kernel command line
26481 (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
26482 @code{-append} option of QEMU), notably:
26483
26484 @table @code
26485 @item --load=@var{boot}
26486 Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
26487 program, once it has mounted the root file system.
26488
26489 Guix uses this option to yield control to a boot program that runs the
26490 service activation programs and then spawns the GNU@tie{}Shepherd, the
26491 initialization system.
26492
26493 @item --root=@var{root}
26494 Mount @var{root} as the root file system. @var{root} can be a
26495 device name like @code{/dev/sda1}, a file system label, or a file system
26496 UUID.
26497
26498 @item --system=@var{system}
26499 Have @file{/run/booted-system} and @file{/run/current-system} point to
26500 @var{system}.
26501
26502 @item modprobe.blacklist=@var{modules}@dots{}
26503 @cindex module, black-listing
26504 @cindex black list, of kernel modules
26505 Instruct the initial RAM disk as well as the @command{modprobe} command
26506 (from the kmod package) to refuse to load @var{modules}. @var{modules}
26507 must be a comma-separated list of module names---e.g.,
26508 @code{usbkbd,9pnet}.
26509
26510 @item --repl
26511 Start a read-eval-print loop (REPL) from the initial RAM disk before it
26512 tries to load kernel modules and to mount the root file system. Our
26513 marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
26514 love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
26515 Manual}, for more information on Guile's REPL.
26516
26517 @end table
26518
26519 Now that you know all the features that initial RAM disks produced by
26520 @code{base-initrd} and @code{raw-initrd} provide,
26521 here is how to use it and customize it further.
26522
26523 @cindex initrd
26524 @cindex initial RAM disk
26525 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
26526 [#:linux-modules '()] [#:mapped-devices '()] @
26527 [#:keyboard-layout #f] @
26528 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
26529 Return a derivation that builds a raw initrd. @var{file-systems} is
26530 a list of file systems to be mounted by the initrd, possibly in addition to
26531 the root file system specified on the kernel command line via @option{--root}.
26532 @var{linux-modules} is a list of kernel modules to be loaded at boot time.
26533 @var{mapped-devices} is a list of device mappings to realize before
26534 @var{file-systems} are mounted (@pxref{Mapped Devices}).
26535 @var{helper-packages} is a list of packages to be copied in the initrd. It may
26536 include @code{e2fsck/static} or other packages needed by the initrd to check
26537 the root file system.
26538
26539 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
26540 the desired console keyboard layout. This is done before @var{mapped-devices}
26541 are set up and before @var{file-systems} are mounted such that, should the
26542 user need to enter a passphrase or use the REPL, this happens using the
26543 intended keyboard layout.
26544
26545 When @var{qemu-networking?} is true, set up networking with the standard QEMU
26546 parameters. When @var{virtio?} is true, load additional modules so that the
26547 initrd can be used as a QEMU guest with para-virtualized I/O drivers.
26548
26549 When @var{volatile-root?} is true, the root file system is writable but any changes
26550 to it are lost.
26551 @end deffn
26552
26553 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
26554 [#:mapped-devices '()] [#:keyboard-layout #f] @
26555 [#:qemu-networking? #f] [#:volatile-root? #f] @
26556 [#:linux-modules '()]
26557 Return as a file-like object a generic initrd, with kernel
26558 modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
26559 mounted by the initrd, possibly in addition to the root file system specified
26560 on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
26561 mappings to realize before @var{file-systems} are mounted.
26562
26563 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
26564 the desired console keyboard layout. This is done before @var{mapped-devices}
26565 are set up and before @var{file-systems} are mounted such that, should the
26566 user need to enter a passphrase or use the REPL, this happens using the
26567 intended keyboard layout.
26568
26569 @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
26570
26571 The initrd is automatically populated with all the kernel modules necessary
26572 for @var{file-systems} and for the given options. Additional kernel
26573 modules can be listed in @var{linux-modules}. They will be added to the initrd, and
26574 loaded at boot time in the order in which they appear.
26575 @end deffn
26576
26577 Needless to say, the initrds we produce and use embed a
26578 statically-linked Guile, and the initialization program is a Guile
26579 program. That gives a lot of flexibility. The
26580 @code{expression->initrd} procedure builds such an initrd, given the
26581 program to run in that initrd.
26582
26583 @deffn {Scheme Procedure} expression->initrd @var{exp} @
26584 [#:guile %guile-3.0-static-stripped] [#:name "guile-initrd"]
26585 Return as a file-like object a Linux initrd (a gzipped cpio archive)
26586 containing @var{guile} and that evaluates @var{exp}, a G-expression,
26587 upon booting. All the derivations referenced by @var{exp} are
26588 automatically copied to the initrd.
26589 @end deffn
26590
26591 @node Bootloader Configuration
26592 @section Bootloader Configuration
26593
26594 @cindex bootloader
26595 @cindex boot loader
26596
26597 The operating system supports multiple bootloaders. The bootloader is
26598 configured using @code{bootloader-configuration} declaration. All the
26599 fields of this structure are bootloader agnostic except for one field,
26600 @code{bootloader} that indicates the bootloader to be configured and
26601 installed.
26602
26603 Some of the bootloaders do not honor every field of
26604 @code{bootloader-configuration}. For instance, the extlinux
26605 bootloader does not support themes and thus ignores the @code{theme}
26606 field.
26607
26608 @deftp {Data Type} bootloader-configuration
26609 The type of a bootloader configuration declaration.
26610
26611 @table @asis
26612
26613 @item @code{bootloader}
26614 @cindex EFI, bootloader
26615 @cindex UEFI, bootloader
26616 @cindex BIOS, bootloader
26617 The bootloader to use, as a @code{bootloader} object. For now
26618 @code{grub-bootloader}, @code{grub-efi-bootloader},
26619 @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
26620
26621 @vindex grub-efi-bootloader
26622 @code{grub-efi-bootloader} allows to boot on modern systems using the
26623 @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
26624 use if the installation image contains a @file{/sys/firmware/efi} directory
26625 when you boot it on your system.
26626
26627 @vindex grub-bootloader
26628 @code{grub-bootloader} allows you to boot in particular Intel-based machines
26629 in ``legacy'' BIOS mode.
26630
26631 @cindex ARM, bootloaders
26632 @cindex AArch64, bootloaders
26633 Available bootloaders are described in @code{(gnu bootloader @dots{})}
26634 modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
26635 of bootloaders for a wide range of ARM and AArch64 systems, using the
26636 @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
26637
26638 @item @code{target}
26639 This is a string denoting the target onto which to install the
26640 bootloader.
26641
26642 The interpretation depends on the bootloader in question. For
26643 @code{grub-bootloader}, for example, it should be a device name understood by
26644 the bootloader @command{installer} command, such as @code{/dev/sda} or
26645 @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
26646 @code{grub-efi-bootloader}, it should be the mount point of the EFI file
26647 system, usually @file{/boot/efi}.
26648
26649 @item @code{menu-entries} (default: @code{()})
26650 A possibly empty list of @code{menu-entry} objects (see below), denoting
26651 entries to appear in the bootloader menu, in addition to the current
26652 system entry and the entry pointing to previous system generations.
26653
26654 @item @code{default-entry} (default: @code{0})
26655 The index of the default boot menu entry. Index 0 is for the entry of the
26656 current system.
26657
26658 @item @code{timeout} (default: @code{5})
26659 The number of seconds to wait for keyboard input before booting. Set to
26660 0 to boot immediately, and to -1 to wait indefinitely.
26661
26662 @cindex keyboard layout, for the bootloader
26663 @item @code{keyboard-layout} (default: @code{#f})
26664 If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
26665 layout, usually US@tie{}English (``qwerty'').
26666
26667 Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
26668 Layout}).
26669
26670 @quotation Note
26671 This option is currently ignored by bootloaders other than @code{grub} and
26672 @code{grub-efi}.
26673 @end quotation
26674
26675 @item @code{theme} (default: @var{#f})
26676 The bootloader theme object describing the theme to use. If no theme
26677 is provided, some bootloaders might use a default theme, that's true
26678 for GRUB.
26679
26680 @item @code{terminal-outputs} (default: @code{'(gfxterm)})
26681 The output terminals used for the bootloader boot menu, as a list of
26682 symbols. GRUB accepts the values: @code{console}, @code{serial},
26683 @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
26684 @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
26685 corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
26686 configuration,,, grub,GNU GRUB manual}).
26687
26688 @item @code{terminal-inputs} (default: @code{'()})
26689 The input terminals used for the bootloader boot menu, as a list of
26690 symbols. For GRUB, the default is the native platform terminal as
26691 determined at run-time. GRUB accepts the values: @code{console},
26692 @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
26693 @code{usb_keyboard}. This field corresponds to the GRUB variable
26694 @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
26695 manual}).
26696
26697 @item @code{serial-unit} (default: @code{#f})
26698 The serial unit used by the bootloader, as an integer from 0 to 3.
26699 For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
26700 corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
26701
26702 @item @code{serial-speed} (default: @code{#f})
26703 The speed of the serial interface, as an integer. For GRUB, the
26704 default value is chosen at run-time; currently GRUB chooses
26705 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
26706 @end table
26707
26708 @end deftp
26709
26710 @cindex dual boot
26711 @cindex boot menu
26712 Should you want to list additional boot menu entries @i{via} the
26713 @code{menu-entries} field above, you will need to create them with the
26714 @code{menu-entry} form. For example, imagine you want to be able to
26715 boot another distro (hard to imagine!), you can define a menu entry
26716 along these lines:
26717
26718 @lisp
26719 (menu-entry
26720 (label "The Other Distro")
26721 (linux "/boot/old/vmlinux-2.6.32")
26722 (linux-arguments '("root=/dev/sda2"))
26723 (initrd "/boot/old/initrd"))
26724 @end lisp
26725
26726 Details below.
26727
26728 @deftp {Data Type} menu-entry
26729 The type of an entry in the bootloader menu.
26730
26731 @table @asis
26732
26733 @item @code{label}
26734 The label to show in the menu---e.g., @code{"GNU"}.
26735
26736 @item @code{linux}
26737 The Linux kernel image to boot, for example:
26738
26739 @lisp
26740 (file-append linux-libre "/bzImage")
26741 @end lisp
26742
26743 For GRUB, it is also possible to specify a device explicitly in the
26744 file path using GRUB's device naming convention (@pxref{Naming
26745 convention,,, grub, GNU GRUB manual}), for example:
26746
26747 @example
26748 "(hd0,msdos1)/boot/vmlinuz"
26749 @end example
26750
26751 If the device is specified explicitly as above, then the @code{device}
26752 field is ignored entirely.
26753
26754 @item @code{linux-arguments} (default: @code{()})
26755 The list of extra Linux kernel command-line arguments---e.g.,
26756 @code{("console=ttyS0")}.
26757
26758 @item @code{initrd}
26759 A G-Expression or string denoting the file name of the initial RAM disk
26760 to use (@pxref{G-Expressions}).
26761 @item @code{device} (default: @code{#f})
26762 The device where the kernel and initrd are to be found---i.e., for GRUB,
26763 @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
26764
26765 This may be a file system label (a string), a file system UUID (a
26766 bytevector, @pxref{File Systems}), or @code{#f}, in which case
26767 the bootloader will search the device containing the file specified by
26768 the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
26769 must @emph{not} be an OS device name such as @file{/dev/sda1}.
26770
26771 @end table
26772 @end deftp
26773
26774 @cindex HDPI
26775 @cindex HiDPI
26776 @cindex resolution
26777 @c FIXME: Write documentation once it's stable.
26778 For now only GRUB has theme support. GRUB themes are created using
26779 the @code{grub-theme} form, which is not fully documented yet.
26780
26781 @deftp {Data Type} grub-theme
26782 Data type representing the configuration of the GRUB theme.
26783
26784 @table @asis
26785 @item @code{gfxmode} (default: @code{'("auto")})
26786 The GRUB @code{gfxmode} to set (a list of screen resolution strings, see
26787 @pxref{gfxmode,,, grub, GNU GRUB manual}).
26788 @end table
26789 @end deftp
26790
26791 @defvr {Scheme Variable} %default-theme
26792 This is the default GRUB theme used by the operating system if no
26793 @code{theme} field is specified in @code{bootloader-configuration}
26794 record.
26795
26796 It comes with a fancy background image displaying the GNU and Guix
26797 logos.
26798 @end defvr
26799
26800 For example, to override the default resolution, you may use something
26801 like
26802
26803 @lisp
26804 (bootloader
26805 (bootloader-configuration
26806 ;; @dots{}
26807 (theme (grub-theme
26808 (inherit %default-theme)
26809 (gfxmode '("1024x786x32" "auto"))))))
26810 @end lisp
26811
26812 @node Invoking guix system
26813 @section Invoking @code{guix system}
26814
26815 Once you have written an operating system declaration as seen in the
26816 previous section, it can be @dfn{instantiated} using the @command{guix
26817 system} command. The synopsis is:
26818
26819 @example
26820 guix system @var{options}@dots{} @var{action} @var{file}
26821 @end example
26822
26823 @var{file} must be the name of a file containing an
26824 @code{operating-system} declaration. @var{action} specifies how the
26825 operating system is instantiated. Currently the following values are
26826 supported:
26827
26828 @table @code
26829 @item search
26830 Display available service type definitions that match the given regular
26831 expressions, sorted by relevance:
26832
26833 @cindex HDPI
26834 @cindex HiDPI
26835 @cindex resolution
26836 @example
26837 $ guix system search console
26838 name: console-fonts
26839 location: gnu/services/base.scm:806:2
26840 extends: shepherd-root
26841 description: Install the given fonts on the specified ttys (fonts are per
26842 + virtual console on GNU/Linux). The value of this service is a list of
26843 + tty/font pairs. The font can be the name of a font provided by the `kbd'
26844 + package or any valid argument to `setfont', as in this example:
26845 +
26846 + '(("tty1" . "LatGrkCyr-8x16")
26847 + ("tty2" . (file-append
26848 + font-tamzen
26849 + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
26850 + ("tty3" . (file-append
26851 + font-terminus
26852 + "/share/consolefonts/ter-132n"))) ; for HDPI
26853 relevance: 9
26854
26855 name: mingetty
26856 location: gnu/services/base.scm:1190:2
26857 extends: shepherd-root
26858 description: Provide console login using the `mingetty' program.
26859 relevance: 2
26860
26861 name: login
26862 location: gnu/services/base.scm:860:2
26863 extends: pam
26864 description: Provide a console log-in service as specified by its
26865 + configuration value, a `login-configuration' object.
26866 relevance: 2
26867
26868 @dots{}
26869 @end example
26870
26871 As for @command{guix package --search}, the result is written in
26872 @code{recutils} format, which makes it easy to filter the output
26873 (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
26874
26875 @item reconfigure
26876 Build the operating system described in @var{file}, activate it, and
26877 switch to it@footnote{This action (and the related actions
26878 @code{switch-generation} and @code{roll-back}) are usable only on
26879 systems already running Guix System.}.
26880
26881 @quotation Note
26882 @c The paragraph below refers to the problem discussed at
26883 @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
26884 It is highly recommended to run @command{guix pull} once before you run
26885 @command{guix system reconfigure} for the first time (@pxref{Invoking
26886 guix pull}). Failing to do that you would see an older version of Guix
26887 once @command{reconfigure} has completed.
26888 @end quotation
26889
26890 This effects all the configuration specified in @var{file}: user
26891 accounts, system services, global package list, setuid programs, etc.
26892 The command starts system services specified in @var{file} that are not
26893 currently running; if a service is currently running this command will
26894 arrange for it to be upgraded the next time it is stopped (e.g.@: by
26895 @code{herd stop X} or @code{herd restart X}).
26896
26897 This command creates a new generation whose number is one greater than
26898 the current generation (as reported by @command{guix system
26899 list-generations}). If that generation already exists, it will be
26900 overwritten. This behavior mirrors that of @command{guix package}
26901 (@pxref{Invoking guix package}).
26902
26903 It also adds a bootloader menu entry for the new OS configuration,
26904 ---unless @option{--no-bootloader} is passed. For GRUB, it moves
26905 entries for older configurations to a submenu, allowing you to choose
26906 an older system generation at boot time should you need it.
26907
26908 @cindex provenance tracking, of the operating system
26909 Upon completion, the new system is deployed under
26910 @file{/run/current-system}. This directory contains @dfn{provenance
26911 meta-data}: the list of channels in use (@pxref{Channels}) and
26912 @var{file} itself, when available. This information is useful should
26913 you later want to inspect how this particular generation was built.
26914
26915 In fact, assuming @var{file} is self-contained, you can later rebuild
26916 generation @var{n} of your operating system with:
26917
26918 @example
26919 guix time-machine \
26920 -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
26921 system reconfigure \
26922 /var/guix/profiles/system-@var{n}-link/configuration.scm
26923 @end example
26924
26925 You can think of it as some sort of built-in version control! Your
26926 system is not just a binary artifact: @emph{it carries its own source}.
26927 @xref{Service Reference, @code{provenance-service-type}}, for more
26928 information on provenance tracking.
26929
26930 @item switch-generation
26931 @cindex generations
26932 Switch to an existing system generation. This action atomically
26933 switches the system profile to the specified system generation. It
26934 also rearranges the system's existing bootloader menu entries. It
26935 makes the menu entry for the specified system generation the default,
26936 and it moves the entries for the other generations to a submenu, if
26937 supported by the bootloader being used. The next time the system
26938 boots, it will use the specified system generation.
26939
26940 The bootloader itself is not being reinstalled when using this
26941 command. Thus, the installed bootloader is used with an updated
26942 configuration file.
26943
26944 The target generation can be specified explicitly by its generation
26945 number. For example, the following invocation would switch to system
26946 generation 7:
26947
26948 @example
26949 guix system switch-generation 7
26950 @end example
26951
26952 The target generation can also be specified relative to the current
26953 generation with the form @code{+N} or @code{-N}, where @code{+3} means
26954 ``3 generations ahead of the current generation,'' and @code{-1} means
26955 ``1 generation prior to the current generation.'' When specifying a
26956 negative value such as @code{-1}, you must precede it with @code{--} to
26957 prevent it from being parsed as an option. For example:
26958
26959 @example
26960 guix system switch-generation -- -1
26961 @end example
26962
26963 Currently, the effect of invoking this action is @emph{only} to switch
26964 the system profile to an existing generation and rearrange the
26965 bootloader menu entries. To actually start using the target system
26966 generation, you must reboot after running this action. In the future,
26967 it will be updated to do the same things as @command{reconfigure},
26968 like activating and deactivating services.
26969
26970 This action will fail if the specified generation does not exist.
26971
26972 @item roll-back
26973 @cindex rolling back
26974 Switch to the preceding system generation. The next time the system
26975 boots, it will use the preceding system generation. This is the inverse
26976 of @command{reconfigure}, and it is exactly the same as invoking
26977 @command{switch-generation} with an argument of @code{-1}.
26978
26979 Currently, as with @command{switch-generation}, you must reboot after
26980 running this action to actually start using the preceding system
26981 generation.
26982
26983 @item delete-generations
26984 @cindex deleting system generations
26985 @cindex saving space
26986 Delete system generations, making them candidates for garbage collection
26987 (@pxref{Invoking guix gc}, for information on how to run the ``garbage
26988 collector'').
26989
26990 This works in the same way as @samp{guix package --delete-generations}
26991 (@pxref{Invoking guix package, @option{--delete-generations}}). With no
26992 arguments, all system generations but the current one are deleted:
26993
26994 @example
26995 guix system delete-generations
26996 @end example
26997
26998 You can also select the generations you want to delete. The example below
26999 deletes all the system generations that are more than two month old:
27000
27001 @example
27002 guix system delete-generations 2m
27003 @end example
27004
27005 Running this command automatically reinstalls the bootloader with an updated
27006 list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
27007 longer lists the generations that have been deleted.
27008
27009 @item build
27010 Build the derivation of the operating system, which includes all the
27011 configuration files and programs needed to boot and run the system.
27012 This action does not actually install anything.
27013
27014 @item init
27015 Populate the given directory with all the files necessary to run the
27016 operating system specified in @var{file}. This is useful for first-time
27017 installations of Guix System. For instance:
27018
27019 @example
27020 guix system init my-os-config.scm /mnt
27021 @end example
27022
27023 copies to @file{/mnt} all the store items required by the configuration
27024 specified in @file{my-os-config.scm}. This includes configuration
27025 files, packages, and so on. It also creates other essential files
27026 needed for the system to operate correctly---e.g., the @file{/etc},
27027 @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
27028
27029 This command also installs bootloader on the target specified in
27030 @file{my-os-config}, unless the @option{--no-bootloader} option was
27031 passed.
27032
27033 @item vm
27034 @cindex virtual machine
27035 @cindex VM
27036 @anchor{guix system vm}
27037 Build a virtual machine that contains the operating system declared in
27038 @var{file}, and return a script to run that virtual machine (VM).
27039
27040 @quotation Note
27041 The @code{vm} action and others below
27042 can use KVM support in the Linux-libre kernel. Specifically, if the
27043 machine has hardware virtualization support, the corresponding
27044 KVM kernel module should be loaded, and the @file{/dev/kvm} device node
27045 must exist and be readable and writable by the user and by the
27046 build users of the daemon (@pxref{Build Environment Setup}).
27047 @end quotation
27048
27049 Arguments given to the script are passed to QEMU as in the example
27050 below, which enables networking and requests 1@tie{}GiB of RAM for the
27051 emulated machine:
27052
27053 @example
27054 $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -net user,model=virtio-net-pci
27055 @end example
27056
27057 The VM shares its store with the host system.
27058
27059 Additional file systems can be shared between the host and the VM using
27060 the @option{--share} and @option{--expose} command-line options: the former
27061 specifies a directory to be shared with write access, while the latter
27062 provides read-only access to the shared directory.
27063
27064 The example below creates a VM in which the user's home directory is
27065 accessible read-only, and where the @file{/exchange} directory is a
27066 read-write mapping of @file{$HOME/tmp} on the host:
27067
27068 @example
27069 guix system vm my-config.scm \
27070 --expose=$HOME --share=$HOME/tmp=/exchange
27071 @end example
27072
27073 On GNU/Linux, the default is to boot directly to the kernel; this has
27074 the advantage of requiring only a very tiny root disk image since the
27075 store of the host can then be mounted.
27076
27077 The @option{--full-boot} option forces a complete boot sequence, starting
27078 with the bootloader. This requires more disk space since a root image
27079 containing at least the kernel, initrd, and bootloader data files must
27080 be created. The @option{--image-size} option can be used to specify the
27081 size of the image.
27082
27083 @cindex System images, creation in various formats
27084 @cindex Creating system images in various formats
27085 @item vm-image
27086 @itemx disk-image
27087 @itemx docker-image
27088 Return a virtual machine, disk image, or Docker image of the operating
27089 system declared in @var{file} that stands alone. By default,
27090 @command{guix system} estimates the size of the image needed to store
27091 the system, but you can use the @option{--image-size} option to specify
27092 a value. Docker images are built to contain exactly what they need, so
27093 the @option{--image-size} option is ignored in the case of
27094 @code{docker-image}.
27095
27096 You can specify the root file system type by using the
27097 @option{--file-system-type} option. It defaults to @code{ext4}.
27098
27099 When using @code{vm-image}, the returned image is in qcow2 format, which
27100 the QEMU emulator can efficiently use. @xref{Running Guix in a VM},
27101 for more information on how to run the image in a virtual machine.
27102
27103 When using @code{disk-image}, a raw disk image is produced; it can be
27104 copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
27105 the device corresponding to a USB stick, one can copy the image to it
27106 using the following command:
27107
27108 @example
27109 # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
27110 @end example
27111
27112 When using @code{docker-image}, a Docker image is produced. Guix builds
27113 the image from scratch, not from a pre-existing Docker base image. As a
27114 result, it contains @emph{exactly} what you define in the operating
27115 system configuration file. You can then load the image and launch a
27116 Docker container using commands like the following:
27117
27118 @example
27119 image_id="`docker load < guix-system-docker-image.tar.gz`"
27120 container_id="`docker create $image_id`"
27121 docker start $container_id
27122 @end example
27123
27124 This command starts a new Docker container from the specified image. It
27125 will boot the Guix system in the usual manner, which means it will
27126 start any services you have defined in the operating system
27127 configuration. You can get an interactive shell running in the container
27128 using @command{docker exec}:
27129
27130 @example
27131 docker exec -ti $container_id /run/current-system/profile/bin/bash --login
27132 @end example
27133
27134 Depending on what you run in the Docker container, it
27135 may be necessary to give the container additional permissions. For
27136 example, if you intend to build software using Guix inside of the Docker
27137 container, you may need to pass the @option{--privileged} option to
27138 @code{docker create}.
27139
27140 Last, the @option{--network} option applies to @command{guix system
27141 docker-image}: it produces an image where network is supposedly shared
27142 with the host, and thus without services like nscd or NetworkManager.
27143
27144 @item container
27145 Return a script to run the operating system declared in @var{file}
27146 within a container. Containers are a set of lightweight isolation
27147 mechanisms provided by the kernel Linux-libre. Containers are
27148 substantially less resource-demanding than full virtual machines since
27149 the kernel, shared objects, and other resources can be shared with the
27150 host system; this also means they provide thinner isolation.
27151
27152 Currently, the script must be run as root in order to support more than
27153 a single user and group. The container shares its store with the host
27154 system.
27155
27156 As with the @code{vm} action (@pxref{guix system vm}), additional file
27157 systems to be shared between the host and container can be specified
27158 using the @option{--share} and @option{--expose} options:
27159
27160 @example
27161 guix system container my-config.scm \
27162 --expose=$HOME --share=$HOME/tmp=/exchange
27163 @end example
27164
27165 @quotation Note
27166 This option requires Linux-libre 3.19 or newer.
27167 @end quotation
27168
27169 @end table
27170
27171 @var{options} can contain any of the common build options (@pxref{Common
27172 Build Options}). In addition, @var{options} can contain one of the
27173 following:
27174
27175 @table @option
27176 @item --expression=@var{expr}
27177 @itemx -e @var{expr}
27178 Consider the operating-system @var{expr} evaluates to.
27179 This is an alternative to specifying a file which evaluates to an
27180 operating system.
27181 This is used to generate the Guix system installer @pxref{Building the
27182 Installation Image}).
27183
27184 @item --system=@var{system}
27185 @itemx -s @var{system}
27186 Attempt to build for @var{system} instead of the host system type.
27187 This works as per @command{guix build} (@pxref{Invoking guix build}).
27188
27189 @item --derivation
27190 @itemx -d
27191 Return the derivation file name of the given operating system without
27192 building anything.
27193
27194 @cindex provenance tracking, of the operating system
27195 @item --save-provenance
27196 As discussed above, @command{guix system init} and @command{guix system
27197 reconfigure} always save provenance information @i{via} a dedicated
27198 service (@pxref{Service Reference, @code{provenance-service-type}}).
27199 However, other commands don't do that by default. If you wish to, say,
27200 create a virtual machine image that contains provenance information, you
27201 can run:
27202
27203 @example
27204 guix system vm-image --save-provenance config.scm
27205 @end example
27206
27207 That way, the resulting image will effectively ``embed its own source''
27208 in the form of meta-data in @file{/run/current-system}. With that
27209 information, one can rebuild the image to make sure it really contains
27210 what it pretends to contain; or they could use that to derive a variant
27211 of the image.
27212
27213 @item --file-system-type=@var{type}
27214 @itemx -t @var{type}
27215 For the @code{disk-image} action, create a file system of the given
27216 @var{type} on the image.
27217
27218 When this option is omitted, @command{guix system} uses @code{ext4}.
27219
27220 @cindex ISO-9660 format
27221 @cindex CD image format
27222 @cindex DVD image format
27223 @option{--file-system-type=iso9660} produces an ISO-9660 image, suitable
27224 for burning on CDs and DVDs.
27225
27226 @item --image-size=@var{size}
27227 For the @code{vm-image} and @code{disk-image} actions, create an image
27228 of the given @var{size}. @var{size} may be a number of bytes, or it may
27229 include a unit as a suffix (@pxref{Block size, size specifications,,
27230 coreutils, GNU Coreutils}).
27231
27232 When this option is omitted, @command{guix system} computes an estimate
27233 of the image size as a function of the size of the system declared in
27234 @var{file}.
27235
27236 @item --network
27237 @itemx -N
27238 For the @code{container} action, allow containers to access the host network,
27239 that is, do not create a network namespace.
27240
27241 @item --root=@var{file}
27242 @itemx -r @var{file}
27243 Make @var{file} a symlink to the result, and register it as a garbage
27244 collector root.
27245
27246 @item --skip-checks
27247 Skip pre-installation safety checks.
27248
27249 By default, @command{guix system init} and @command{guix system
27250 reconfigure} perform safety checks: they make sure the file systems that
27251 appear in the @code{operating-system} declaration actually exist
27252 (@pxref{File Systems}), and that any Linux kernel modules that may be
27253 needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
27254 RAM Disk}). Passing this option skips these tests altogether.
27255
27256 @cindex on-error
27257 @cindex on-error strategy
27258 @cindex error strategy
27259 @item --on-error=@var{strategy}
27260 Apply @var{strategy} when an error occurs when reading @var{file}.
27261 @var{strategy} may be one of the following:
27262
27263 @table @code
27264 @item nothing-special
27265 Report the error concisely and exit. This is the default strategy.
27266
27267 @item backtrace
27268 Likewise, but also display a backtrace.
27269
27270 @item debug
27271 Report the error and enter Guile's debugger. From there, you can run
27272 commands such as @code{,bt} to get a backtrace, @code{,locals} to
27273 display local variable values, and more generally inspect the state of the
27274 program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
27275 a list of available debugging commands.
27276 @end table
27277 @end table
27278
27279 Once you have built, configured, re-configured, and re-re-configured
27280 your Guix installation, you may find it useful to list the operating
27281 system generations available on disk---and that you can choose from the
27282 bootloader boot menu:
27283
27284 @table @code
27285
27286 @item describe
27287 Describe the current system generation: its file name, the kernel and
27288 bootloader used, etc., as well as provenance information when available.
27289
27290 @item list-generations
27291 List a summary of each generation of the operating system available on
27292 disk, in a human-readable way. This is similar to the
27293 @option{--list-generations} option of @command{guix package}
27294 (@pxref{Invoking guix package}).
27295
27296 Optionally, one can specify a pattern, with the same syntax that is used
27297 in @command{guix package --list-generations}, to restrict the list of
27298 generations displayed. For instance, the following command displays
27299 generations that are up to 10 days old:
27300
27301 @example
27302 $ guix system list-generations 10d
27303 @end example
27304
27305 @end table
27306
27307 The @command{guix system} command has even more to offer! The following
27308 sub-commands allow you to visualize how your system services relate to
27309 each other:
27310
27311 @anchor{system-extension-graph}
27312 @table @code
27313
27314 @item extension-graph
27315 Emit in Dot/Graphviz format to standard output the @dfn{service
27316 extension graph} of the operating system defined in @var{file}
27317 (@pxref{Service Composition}, for more information on service
27318 extensions.)
27319
27320 The command:
27321
27322 @example
27323 $ guix system extension-graph @var{file} | xdot -
27324 @end example
27325
27326 shows the extension relations among services.
27327
27328 @anchor{system-shepherd-graph}
27329 @item shepherd-graph
27330 Emit in Dot/Graphviz format to standard output the @dfn{dependency
27331 graph} of shepherd services of the operating system defined in
27332 @var{file}. @xref{Shepherd Services}, for more information and for an
27333 example graph.
27334
27335 @end table
27336
27337 @node Invoking guix deploy
27338 @section Invoking @code{guix deploy}
27339
27340 We've already seen @code{operating-system} declarations used to manage a
27341 machine's configuration locally. Suppose you need to configure multiple
27342 machines, though---perhaps you're managing a service on the web that's
27343 comprised of several servers. @command{guix deploy} enables you to use those
27344 same @code{operating-system} declarations to manage multiple remote hosts at
27345 once as a logical ``deployment''.
27346
27347 @quotation Note
27348 The functionality described in this section is still under development
27349 and is subject to change. Get in touch with us on
27350 @email{guix-devel@@gnu.org}!
27351 @end quotation
27352
27353 @example
27354 guix deploy @var{file}
27355 @end example
27356
27357 Such an invocation will deploy the machines that the code within @var{file}
27358 evaluates to. As an example, @var{file} might contain a definition like this:
27359
27360 @lisp
27361 ;; This is a Guix deployment of a "bare bones" setup, with
27362 ;; no X11 display server, to a machine with an SSH daemon
27363 ;; listening on localhost:2222. A configuration such as this
27364 ;; may be appropriate for virtual machine with ports
27365 ;; forwarded to the host's loopback interface.
27366
27367 (use-service-modules networking ssh)
27368 (use-package-modules bootloaders)
27369
27370 (define %system
27371 (operating-system
27372 (host-name "gnu-deployed")
27373 (timezone "Etc/UTC")
27374 (bootloader (bootloader-configuration
27375 (bootloader grub-bootloader)
27376 (target "/dev/vda")
27377 (terminal-outputs '(console))))
27378 (file-systems (cons (file-system
27379 (mount-point "/")
27380 (device "/dev/vda1")
27381 (type "ext4"))
27382 %base-file-systems))
27383 (services
27384 (append (list (service dhcp-client-service-type)
27385 (service openssh-service-type
27386 (openssh-configuration
27387 (permit-root-login #t)
27388 (allow-empty-passwords? #t))))
27389 %base-services))))
27390
27391 (list (machine
27392 (operating-system %system)
27393 (environment managed-host-environment-type)
27394 (configuration (machine-ssh-configuration
27395 (host-name "localhost")
27396 (system "x86_64-linux")
27397 (user "alice")
27398 (identity "./id_rsa")
27399 (port 2222)))))
27400 @end lisp
27401
27402 The file should evaluate to a list of @var{machine} objects. This example,
27403 upon being deployed, will create a new generation on the remote system
27404 realizing the @code{operating-system} declaration @code{%system}.
27405 @code{environment} and @code{configuration} specify how the machine should be
27406 provisioned---that is, how the computing resources should be created and
27407 managed. The above example does not create any resources, as a
27408 @code{'managed-host} is a machine that is already running the Guix system and
27409 available over the network. This is a particularly simple case; a more
27410 complex deployment may involve, for example, starting virtual machines through
27411 a Virtual Private Server (VPS) provider. In such a case, a different
27412 @var{environment} type would be used.
27413
27414 Do note that you first need to generate a key pair on the coordinator machine
27415 to allow the daemon to export signed archives of files from the store
27416 (@pxref{Invoking guix archive}).
27417
27418 @example
27419 # guix archive --generate-key
27420 @end example
27421
27422 @noindent
27423 Each target machine must authorize the key of the master machine so that it
27424 accepts store items it receives from the coordinator:
27425
27426 @example
27427 # guix archive --authorize < coordinator-public-key.txt
27428 @end example
27429
27430 @code{user}, in this example, specifies the name of the user account to log in
27431 as to perform the deployment. Its default value is @code{root}, but root
27432 login over SSH may be forbidden in some cases. To work around this,
27433 @command{guix deploy} can log in as an unprivileged user and employ
27434 @code{sudo} to escalate privileges. This will only work if @code{sudo} is
27435 currently installed on the remote and can be invoked non-interactively as
27436 @code{user}. That is, the line in @code{sudoers} granting @code{user} the
27437 ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
27438 be accomplished with the following operating system configuration snippet:
27439
27440 @lisp
27441 (use-modules ...
27442 (gnu system)) ;for %sudoers-specification
27443
27444 (define %user "username")
27445
27446 (operating-system
27447 ...
27448 (sudoers-file
27449 (plain-file "sudoers"
27450 (string-append (plain-file-content %sudoers-specification)
27451 (format #f "~a ALL = NOPASSWD: ALL~%"
27452 %user)))))
27453
27454 @end lisp
27455
27456 For more information regarding the format of the @file{sudoers} file,
27457 consult @command{man sudoers}.
27458
27459 @deftp {Data Type} machine
27460 This is the data type representing a single machine in a heterogeneous Guix
27461 deployment.
27462
27463 @table @asis
27464 @item @code{operating-system}
27465 The object of the operating system configuration to deploy.
27466
27467 @item @code{environment}
27468 An @code{environment-type} describing how the machine should be provisioned.
27469
27470 @item @code{configuration} (default: @code{#f})
27471 An object describing the configuration for the machine's @code{environment}.
27472 If the @code{environment} has a default configuration, @code{#f} may be used.
27473 If @code{#f} is used for an environment with no default configuration,
27474 however, an error will be thrown.
27475 @end table
27476 @end deftp
27477
27478 @deftp {Data Type} machine-ssh-configuration
27479 This is the data type representing the SSH client parameters for a machine
27480 with an @code{environment} of @code{managed-host-environment-type}.
27481
27482 @table @asis
27483 @item @code{host-name}
27484 @item @code{build-locally?} (default: @code{#t})
27485 If false, system derivations will be built on the machine being deployed to.
27486 @item @code{system}
27487 The system type describing the architecture of the machine being deployed
27488 to---e.g., @code{"x86_64-linux"}.
27489 @item @code{authorize?} (default: @code{#t})
27490 If true, the coordinator's signing key will be added to the remote's ACL
27491 keyring.
27492 @item @code{port} (default: @code{22})
27493 @item @code{user} (default: @code{"root"})
27494 @item @code{identity} (default: @code{#f})
27495 If specified, the path to the SSH private key to use to authenticate with the
27496 remote host.
27497
27498 @item @code{host-key} (default: @code{#f})
27499 This should be the SSH host key of the machine, which looks like this:
27500
27501 @example
27502 ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
27503 @end example
27504
27505 When @code{host-key} is @code{#f}, the server is authenticated against
27506 the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
27507 client does.
27508
27509 @end table
27510 @end deftp
27511
27512 @deftp {Data Type} digital-ocean-configuration
27513 This is the data type describing the Droplet that should be created for a
27514 machine with an @code{environment} of @code{digital-ocean-environment-type}.
27515
27516 @table @asis
27517 @item @code{ssh-key}
27518 The path to the SSH private key to use to authenticate with the remote
27519 host. In the future, this field may not exist.
27520 @item @code{tags}
27521 A list of string ``tags'' that uniquely identify the machine. Must be given
27522 such that no two machines in the deployment have the same set of tags.
27523 @item @code{region}
27524 A Digital Ocean region slug, such as @code{"nyc3"}.
27525 @item @code{size}
27526 A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
27527 @item @code{enable-ipv6?}
27528 Whether or not the droplet should be created with IPv6 networking.
27529 @end table
27530 @end deftp
27531
27532 @node Running Guix in a VM
27533 @section Running Guix in a Virtual Machine
27534
27535 @cindex virtual machine
27536 To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
27537 distributed at
27538 @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.xz}.
27539 This image is a compressed image in QCOW format. You will first need to
27540 decompress with @command{xz -d}, and then you can pass it to an emulator such
27541 as QEMU (see below for details).
27542
27543 This image boots the Xfce graphical environment and it contains some
27544 commonly-used tools. You can install more software in the image by running
27545 @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
27546 also reconfigure the system based on its initial configuration file available
27547 as @file{/run/current-system/configuration.scm} (@pxref{Using the
27548 Configuration System}).
27549
27550 Instead of using this pre-built image, one can also build their own virtual
27551 machine image using @command{guix system vm-image} (@pxref{Invoking guix
27552 system}). The returned image is in qcow2 format, which the
27553 @uref{https://qemu.org/, QEMU emulator} can efficiently use.
27554
27555 @cindex QEMU
27556 If you built your own image, you must copy it out of the store
27557 (@pxref{The Store}) and give yourself permission to write to the copy
27558 before you can use it. When invoking QEMU, you must choose a system
27559 emulator that is suitable for your hardware platform. Here is a minimal
27560 QEMU invocation that will boot the result of @command{guix system
27561 vm-image} on x86_64 hardware:
27562
27563 @example
27564 $ qemu-system-x86_64 \
27565 -nic user,model=virtio-net-pci \
27566 -enable-kvm -m 1024 \
27567 -device virtio-blk,drive=myhd \
27568 -drive if=none,file=/tmp/qemu-image,id=myhd
27569 @end example
27570
27571 Here is what each of these options means:
27572
27573 @table @code
27574 @item qemu-system-x86_64
27575 This specifies the hardware platform to emulate. This should match the
27576 host.
27577
27578 @item -nic user,model=virtio-net-pci
27579 Enable the unprivileged user-mode network stack. The guest OS can
27580 access the host but not vice versa. This is the simplest way to get the
27581 guest OS online. @code{model} specifies which network device to emulate:
27582 @code{virtio-net-pci} is a special device made for virtualized operating
27583 systems and recommended for most uses. Assuming your hardware platform is
27584 x86_64, you can get a list of available NIC models by running
27585 @command{qemu-system-x86_64 -nic model=help}.
27586
27587 @item -enable-kvm
27588 If your system has hardware virtualization extensions, enabling the
27589 virtual machine support (KVM) of the Linux kernel will make things run
27590 faster.
27591
27592 @c To run Xfce + 'guix pull', we need at least 1G of RAM.
27593 @item -m 1024
27594 RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
27595 which may be insufficient for some operations.
27596
27597 @item -device virtio-blk,drive=myhd
27598 Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
27599 ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
27600 better performance than if it were emulating a complete disk drive. See the
27601 QEMU and KVM documentation for more info.
27602
27603 @item -drive if=none,file=/tmp/qemu-image,id=myhd
27604 Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing store the
27605 the ``myhd'' drive.
27606 @end table
27607
27608 The default @command{run-vm.sh} script that is returned by an invocation of
27609 @command{guix system vm} does not add a @command{-nic user} flag by default.
27610 To get network access from within the vm add the @code{(dhcp-client-service)}
27611 to your system definition and start the VM using
27612 @command{`guix system vm config.scm` -nic user}. An important caveat of using
27613 @command{-nic user} for networking is that @command{ping} will not work, because
27614 it uses the ICMP protocol. You'll have to use a different command to check for
27615 network connectivity, for example @command{guix download}.
27616
27617 @subsection Connecting Through SSH
27618
27619 @cindex SSH
27620 @cindex SSH server
27621 To enable SSH inside a VM you need to add an SSH server like
27622 @code{openssh-service-type} to your VM (@pxref{Networking Services,
27623 @code{openssh-service-type}}). In addition you need to forward the SSH port,
27624 22 by default, to the host. You can do this with
27625
27626 @example
27627 `guix system vm config.scm` -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
27628 @end example
27629
27630 To connect to the VM you can run
27631
27632 @example
27633 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
27634 @end example
27635
27636 The @command{-p} tells @command{ssh} the port you want to connect to.
27637 @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
27638 every time you modify your @command{config.scm} file and the
27639 @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
27640 connection to an unknown host every time you connect.
27641
27642 @subsection Using @command{virt-viewer} with Spice
27643
27644 As an alternative to the default @command{qemu} graphical client you can
27645 use the @command{remote-viewer} from the @command{virt-viewer} package. To
27646 connect pass the @command{-spice port=5930,disable-ticketing} flag to
27647 @command{qemu}. See previous section for further information on how to do this.
27648
27649 Spice also allows you to do some nice stuff like share your clipboard with your
27650 VM. To enable that you'll also have to pass the following flags to @command{qemu}:
27651
27652 @example
27653 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
27654 -chardev spicevmc,name=vdagent,id=vdagent
27655 -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
27656 name=com.redhat.spice.0
27657 @end example
27658
27659 You'll also need to add the @code{(spice-vdagent-service)} to your
27660 system definition (@pxref{Miscellaneous Services, Spice service}).
27661
27662 @node Defining Services
27663 @section Defining Services
27664
27665 The previous sections show the available services and how one can combine
27666 them in an @code{operating-system} declaration. But how do we define
27667 them in the first place? And what is a service anyway?
27668
27669 @menu
27670 * Service Composition:: The model for composing services.
27671 * Service Types and Services:: Types and services.
27672 * Service Reference:: API reference.
27673 * Shepherd Services:: A particular type of service.
27674 @end menu
27675
27676 @node Service Composition
27677 @subsection Service Composition
27678
27679 @cindex services
27680 @cindex daemons
27681 Here we define a @dfn{service} as, broadly, something that extends the
27682 functionality of the operating system. Often a service is a process---a
27683 @dfn{daemon}---started when the system boots: a secure shell server, a
27684 Web server, the Guix build daemon, etc. Sometimes a service is a daemon
27685 whose execution can be triggered by another daemon---e.g., an FTP server
27686 started by @command{inetd} or a D-Bus service activated by
27687 @command{dbus-daemon}. Occasionally, a service does not map to a
27688 daemon. For instance, the ``account'' service collects user accounts
27689 and makes sure they exist when the system runs; the ``udev'' service
27690 collects device management rules and makes them available to the eudev
27691 daemon; the @file{/etc} service populates the @file{/etc} directory
27692 of the system.
27693
27694 @cindex service extensions
27695 Guix system services are connected by @dfn{extensions}. For instance, the
27696 secure shell service @emph{extends} the Shepherd---the
27697 initialization system, running as PID@tie{}1---by giving it the command
27698 lines to start and stop the secure shell daemon (@pxref{Networking
27699 Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
27700 service by passing it its @file{.service} specification, and extends the
27701 udev service by passing it device management rules (@pxref{Desktop
27702 Services, @code{upower-service}}); the Guix daemon service extends the
27703 Shepherd by passing it the command lines to start and stop the daemon,
27704 and extends the account service by passing it a list of required build
27705 user accounts (@pxref{Base Services}).
27706
27707 All in all, services and their ``extends'' relations form a directed
27708 acyclic graph (DAG). If we represent services as boxes and extensions
27709 as arrows, a typical system might provide something like this:
27710
27711 @image{images/service-graph,,5in,Typical service extension graph.}
27712
27713 @cindex system service
27714 At the bottom, we see the @dfn{system service}, which produces the
27715 directory containing everything to run and boot the system, as returned
27716 by the @command{guix system build} command. @xref{Service Reference},
27717 to learn about the other service types shown here.
27718 @xref{system-extension-graph, the @command{guix system extension-graph}
27719 command}, for information on how to generate this representation for a
27720 particular operating system definition.
27721
27722 @cindex service types
27723 Technically, developers can define @dfn{service types} to express these
27724 relations. There can be any number of services of a given type on the
27725 system---for instance, a system running two instances of the GNU secure
27726 shell server (lsh) has two instances of @code{lsh-service-type}, with
27727 different parameters.
27728
27729 The following section describes the programming interface for service
27730 types and services.
27731
27732 @node Service Types and Services
27733 @subsection Service Types and Services
27734
27735 A @dfn{service type} is a node in the DAG described above. Let us start
27736 with a simple example, the service type for the Guix build daemon
27737 (@pxref{Invoking guix-daemon}):
27738
27739 @lisp
27740 (define guix-service-type
27741 (service-type
27742 (name 'guix)
27743 (extensions
27744 (list (service-extension shepherd-root-service-type guix-shepherd-service)
27745 (service-extension account-service-type guix-accounts)
27746 (service-extension activation-service-type guix-activation)))
27747 (default-value (guix-configuration))))
27748 @end lisp
27749
27750 @noindent
27751 It defines three things:
27752
27753 @enumerate
27754 @item
27755 A name, whose sole purpose is to make inspection and debugging easier.
27756
27757 @item
27758 A list of @dfn{service extensions}, where each extension designates the
27759 target service type and a procedure that, given the parameters of the
27760 service, returns a list of objects to extend the service of that type.
27761
27762 Every service type has at least one service extension. The only
27763 exception is the @dfn{boot service type}, which is the ultimate service.
27764
27765 @item
27766 Optionally, a default value for instances of this type.
27767 @end enumerate
27768
27769 In this example, @code{guix-service-type} extends three services:
27770
27771 @table @code
27772 @item shepherd-root-service-type
27773 The @code{guix-shepherd-service} procedure defines how the Shepherd
27774 service is extended. Namely, it returns a @code{<shepherd-service>}
27775 object that defines how @command{guix-daemon} is started and stopped
27776 (@pxref{Shepherd Services}).
27777
27778 @item account-service-type
27779 This extension for this service is computed by @code{guix-accounts},
27780 which returns a list of @code{user-group} and @code{user-account}
27781 objects representing the build user accounts (@pxref{Invoking
27782 guix-daemon}).
27783
27784 @item activation-service-type
27785 Here @code{guix-activation} is a procedure that returns a gexp, which is
27786 a code snippet to run at ``activation time''---e.g., when the service is
27787 booted.
27788 @end table
27789
27790 A service of this type is instantiated like this:
27791
27792 @lisp
27793 (service guix-service-type
27794 (guix-configuration
27795 (build-accounts 5)
27796 (use-substitutes? #f)))
27797 @end lisp
27798
27799 The second argument to the @code{service} form is a value representing
27800 the parameters of this specific service instance.
27801 @xref{guix-configuration-type, @code{guix-configuration}}, for
27802 information about the @code{guix-configuration} data type. When the
27803 value is omitted, the default value specified by
27804 @code{guix-service-type} is used:
27805
27806 @lisp
27807 (service guix-service-type)
27808 @end lisp
27809
27810 @code{guix-service-type} is quite simple because it extends other
27811 services but is not extensible itself.
27812
27813 @c @subsubsubsection Extensible Service Types
27814
27815 The service type for an @emph{extensible} service looks like this:
27816
27817 @lisp
27818 (define udev-service-type
27819 (service-type (name 'udev)
27820 (extensions
27821 (list (service-extension shepherd-root-service-type
27822 udev-shepherd-service)))
27823
27824 (compose concatenate) ;concatenate the list of rules
27825 (extend (lambda (config rules)
27826 (match config
27827 (($ <udev-configuration> udev initial-rules)
27828 (udev-configuration
27829 (udev udev) ;the udev package to use
27830 (rules (append initial-rules rules)))))))))
27831 @end lisp
27832
27833 This is the service type for the
27834 @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
27835 management daemon}. Compared to the previous example, in addition to an
27836 extension of @code{shepherd-root-service-type}, we see two new fields:
27837
27838 @table @code
27839 @item compose
27840 This is the procedure to @dfn{compose} the list of extensions to
27841 services of this type.
27842
27843 Services can extend the udev service by passing it lists of rules; we
27844 compose those extensions simply by concatenating them.
27845
27846 @item extend
27847 This procedure defines how the value of the service is @dfn{extended} with
27848 the composition of the extensions.
27849
27850 Udev extensions are composed into a list of rules, but the udev service
27851 value is itself a @code{<udev-configuration>} record. So here, we
27852 extend that record by appending the list of rules it contains to the
27853 list of contributed rules.
27854
27855 @item description
27856 This is a string giving an overview of the service type. The string can
27857 contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
27858 @command{guix system search} command searches these strings and displays
27859 them (@pxref{Invoking guix system}).
27860 @end table
27861
27862 There can be only one instance of an extensible service type such as
27863 @code{udev-service-type}. If there were more, the
27864 @code{service-extension} specifications would be ambiguous.
27865
27866 Still here? The next section provides a reference of the programming
27867 interface for services.
27868
27869 @node Service Reference
27870 @subsection Service Reference
27871
27872 We have seen an overview of service types (@pxref{Service Types and
27873 Services}). This section provides a reference on how to manipulate
27874 services and service types. This interface is provided by the
27875 @code{(gnu services)} module.
27876
27877 @deffn {Scheme Procedure} service @var{type} [@var{value}]
27878 Return a new service of @var{type}, a @code{<service-type>} object (see
27879 below.) @var{value} can be any object; it represents the parameters of
27880 this particular service instance.
27881
27882 When @var{value} is omitted, the default value specified by @var{type}
27883 is used; if @var{type} does not specify a default value, an error is
27884 raised.
27885
27886 For instance, this:
27887
27888 @lisp
27889 (service openssh-service-type)
27890 @end lisp
27891
27892 @noindent
27893 is equivalent to this:
27894
27895 @lisp
27896 (service openssh-service-type
27897 (openssh-configuration))
27898 @end lisp
27899
27900 In both cases the result is an instance of @code{openssh-service-type}
27901 with the default configuration.
27902 @end deffn
27903
27904 @deffn {Scheme Procedure} service? @var{obj}
27905 Return true if @var{obj} is a service.
27906 @end deffn
27907
27908 @deffn {Scheme Procedure} service-kind @var{service}
27909 Return the type of @var{service}---i.e., a @code{<service-type>} object.
27910 @end deffn
27911
27912 @deffn {Scheme Procedure} service-value @var{service}
27913 Return the value associated with @var{service}. It represents its
27914 parameters.
27915 @end deffn
27916
27917 Here is an example of how a service is created and manipulated:
27918
27919 @lisp
27920 (define s
27921 (service nginx-service-type
27922 (nginx-configuration
27923 (nginx nginx)
27924 (log-directory log-directory)
27925 (run-directory run-directory)
27926 (file config-file))))
27927
27928 (service? s)
27929 @result{} #t
27930
27931 (eq? (service-kind s) nginx-service-type)
27932 @result{} #t
27933 @end lisp
27934
27935 The @code{modify-services} form provides a handy way to change the
27936 parameters of some of the services of a list such as
27937 @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
27938 evaluates to a list of services. Of course, you could always use
27939 standard list combinators such as @code{map} and @code{fold} to do that
27940 (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
27941 @code{modify-services} simply provides a more concise form for this
27942 common pattern.
27943
27944 @deffn {Scheme Syntax} modify-services @var{services} @
27945 (@var{type} @var{variable} => @var{body}) @dots{}
27946
27947 Modify the services listed in @var{services} according to the given
27948 clauses. Each clause has the form:
27949
27950 @example
27951 (@var{type} @var{variable} => @var{body})
27952 @end example
27953
27954 where @var{type} is a service type---e.g.,
27955 @code{guix-service-type}---and @var{variable} is an identifier that is
27956 bound within the @var{body} to the service parameters---e.g., a
27957 @code{guix-configuration} instance---of the original service of that
27958 @var{type}.
27959
27960 The @var{body} should evaluate to the new service parameters, which will
27961 be used to configure the new service. This new service will replace the
27962 original in the resulting list. Because a service's service parameters
27963 are created using @code{define-record-type*}, you can write a succinct
27964 @var{body} that evaluates to the new service parameters by using the
27965 @code{inherit} feature that @code{define-record-type*} provides.
27966
27967 @xref{Using the Configuration System}, for example usage.
27968
27969 @end deffn
27970
27971 Next comes the programming interface for service types. This is
27972 something you want to know when writing new service definitions, but not
27973 necessarily when simply looking for ways to customize your
27974 @code{operating-system} declaration.
27975
27976 @deftp {Data Type} service-type
27977 @cindex service type
27978 This is the representation of a @dfn{service type} (@pxref{Service Types
27979 and Services}).
27980
27981 @table @asis
27982 @item @code{name}
27983 This is a symbol, used only to simplify inspection and debugging.
27984
27985 @item @code{extensions}
27986 A non-empty list of @code{<service-extension>} objects (see below).
27987
27988 @item @code{compose} (default: @code{#f})
27989 If this is @code{#f}, then the service type denotes services that cannot
27990 be extended---i.e., services that do not receive ``values'' from other
27991 services.
27992
27993 Otherwise, it must be a one-argument procedure. The procedure is called
27994 by @code{fold-services} and is passed a list of values collected from
27995 extensions. It may return any single value.
27996
27997 @item @code{extend} (default: @code{#f})
27998 If this is @code{#f}, services of this type cannot be extended.
27999
28000 Otherwise, it must be a two-argument procedure: @code{fold-services}
28001 calls it, passing it the initial value of the service as the first
28002 argument and the result of applying @code{compose} to the extension
28003 values as the second argument. It must return a value that is a valid
28004 parameter value for the service instance.
28005 @end table
28006
28007 @xref{Service Types and Services}, for examples.
28008 @end deftp
28009
28010 @deffn {Scheme Procedure} service-extension @var{target-type} @
28011 @var{compute}
28012 Return a new extension for services of type @var{target-type}.
28013 @var{compute} must be a one-argument procedure: @code{fold-services}
28014 calls it, passing it the value associated with the service that provides
28015 the extension; it must return a valid value for the target service.
28016 @end deffn
28017
28018 @deffn {Scheme Procedure} service-extension? @var{obj}
28019 Return true if @var{obj} is a service extension.
28020 @end deffn
28021
28022 Occasionally, you might want to simply extend an existing service. This
28023 involves creating a new service type and specifying the extension of
28024 interest, which can be verbose; the @code{simple-service} procedure
28025 provides a shorthand for this.
28026
28027 @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
28028 Return a service that extends @var{target} with @var{value}. This works
28029 by creating a singleton service type @var{name}, of which the returned
28030 service is an instance.
28031
28032 For example, this extends mcron (@pxref{Scheduled Job Execution}) with
28033 an additional job:
28034
28035 @lisp
28036 (simple-service 'my-mcron-job mcron-service-type
28037 #~(job '(next-hour (3)) "guix gc -F 2G"))
28038 @end lisp
28039 @end deffn
28040
28041 At the core of the service abstraction lies the @code{fold-services}
28042 procedure, which is responsible for ``compiling'' a list of services
28043 down to a single directory that contains everything needed to boot and
28044 run the system---the directory shown by the @command{guix system build}
28045 command (@pxref{Invoking guix system}). In essence, it propagates
28046 service extensions down the service graph, updating each node parameters
28047 on the way, until it reaches the root node.
28048
28049 @deffn {Scheme Procedure} fold-services @var{services} @
28050 [#:target-type @var{system-service-type}]
28051 Fold @var{services} by propagating their extensions down to the root of
28052 type @var{target-type}; return the root service adjusted accordingly.
28053 @end deffn
28054
28055 Lastly, the @code{(gnu services)} module also defines several essential
28056 service types, some of which are listed below.
28057
28058 @defvr {Scheme Variable} system-service-type
28059 This is the root of the service graph. It produces the system directory
28060 as returned by the @command{guix system build} command.
28061 @end defvr
28062
28063 @defvr {Scheme Variable} boot-service-type
28064 The type of the ``boot service'', which produces the @dfn{boot script}.
28065 The boot script is what the initial RAM disk runs when booting.
28066 @end defvr
28067
28068 @defvr {Scheme Variable} etc-service-type
28069 The type of the @file{/etc} service. This service is used to create
28070 files under @file{/etc} and can be extended by
28071 passing it name/file tuples such as:
28072
28073 @lisp
28074 (list `("issue" ,(plain-file "issue" "Welcome!\n")))
28075 @end lisp
28076
28077 In this example, the effect would be to add an @file{/etc/issue} file
28078 pointing to the given file.
28079 @end defvr
28080
28081 @defvr {Scheme Variable} setuid-program-service-type
28082 Type for the ``setuid-program service''. This service collects lists of
28083 executable file names, passed as gexps, and adds them to the set of
28084 setuid-root programs on the system (@pxref{Setuid Programs}).
28085 @end defvr
28086
28087 @defvr {Scheme Variable} profile-service-type
28088 Type of the service that populates the @dfn{system profile}---i.e., the
28089 programs under @file{/run/current-system/profile}. Other services can
28090 extend it by passing it lists of packages to add to the system profile.
28091 @end defvr
28092
28093 @cindex provenance tracking, of the operating system
28094 @defvr {Scheme Variable} provenance-service-type
28095 This is the type of the service that records @dfn{provenance meta-data}
28096 in the system itself. It creates several files under
28097 @file{/run/current-system}:
28098
28099 @table @file
28100 @item channels.scm
28101 This is a ``channel file'' that can be passed to @command{guix pull -C}
28102 or @command{guix time-machine -C}, and which describes the channels used
28103 to build the system, if that information was available
28104 (@pxref{Channels}).
28105
28106 @item configuration.scm
28107 This is the file that was passed as the value for this
28108 @code{provenance-service-type} service. By default, @command{guix
28109 system reconfigure} automatically passes the OS configuration file it
28110 received on the command line.
28111
28112 @item provenance
28113 This contains the same information as the two other files but in a
28114 format that is more readily processable.
28115 @end table
28116
28117 In general, these two pieces of information (channels and configuration
28118 file) are enough to reproduce the operating system ``from source''.
28119
28120 @quotation Caveats
28121 This information is necessary to rebuild your operating system, but it
28122 is not always sufficient. In particular, @file{configuration.scm}
28123 itself is insufficient if it is not self-contained---if it refers to
28124 external Guile modules or to extra files. If you want
28125 @file{configuration.scm} to be self-contained, we recommend that modules
28126 or files it refers to be part of a channel.
28127
28128 Besides, provenance meta-data is ``silent'' in the sense that it does
28129 not change the bits contained in your system, @emph{except for the
28130 meta-data bits themselves}. Two different OS configurations or sets of
28131 channels can lead to the same system, bit-for-bit; when
28132 @code{provenance-service-type} is used, these two systems will have
28133 different meta-data and thus different store file names, which makes
28134 comparison less trivial.
28135 @end quotation
28136
28137 This service is automatically added to your operating system
28138 configuration when you use @command{guix system reconfigure},
28139 @command{guix system init}, or @command{guix deploy}.
28140 @end defvr
28141
28142 @node Shepherd Services
28143 @subsection Shepherd Services
28144
28145 @cindex shepherd services
28146 @cindex PID 1
28147 @cindex init system
28148 The @code{(gnu services shepherd)} module provides a way to define
28149 services managed by the GNU@tie{}Shepherd, which is the
28150 initialization system---the first process that is started when the
28151 system boots, also known as PID@tie{}1
28152 (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
28153
28154 Services in the Shepherd can depend on each other. For instance, the
28155 SSH daemon may need to be started after the syslog daemon has been
28156 started, which in turn can only happen once all the file systems have
28157 been mounted. The simple operating system defined earlier (@pxref{Using
28158 the Configuration System}) results in a service graph like this:
28159
28160 @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
28161
28162 You can actually generate such a graph for any operating system
28163 definition using the @command{guix system shepherd-graph} command
28164 (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
28165
28166 The @code{%shepherd-root-service} is a service object representing
28167 PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
28168 by passing it lists of @code{<shepherd-service>} objects.
28169
28170 @deftp {Data Type} shepherd-service
28171 The data type representing a service managed by the Shepherd.
28172
28173 @table @asis
28174 @item @code{provision}
28175 This is a list of symbols denoting what the service provides.
28176
28177 These are the names that may be passed to @command{herd start},
28178 @command{herd status}, and similar commands (@pxref{Invoking herd,,,
28179 shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
28180 @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
28181
28182 @item @code{requirement} (default: @code{'()})
28183 List of symbols denoting the Shepherd services this one depends on.
28184
28185 @cindex one-shot services, for the Shepherd
28186 @item @code{one-shot?} (default: @code{#f})
28187 Whether this service is @dfn{one-shot}. One-shot services stop immediately
28188 after their @code{start} action has completed. @xref{Slots of services,,,
28189 shepherd, The GNU Shepherd Manual}, for more info.
28190
28191 @item @code{respawn?} (default: @code{#t})
28192 Whether to restart the service when it stops, for instance when the
28193 underlying process dies.
28194
28195 @item @code{start}
28196 @itemx @code{stop} (default: @code{#~(const #f)})
28197 The @code{start} and @code{stop} fields refer to the Shepherd's
28198 facilities to start and stop processes (@pxref{Service De- and
28199 Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
28200 G-expressions that get expanded in the Shepherd configuration file
28201 (@pxref{G-Expressions}).
28202
28203 @item @code{actions} (default: @code{'()})
28204 @cindex actions, of Shepherd services
28205 This is a list of @code{shepherd-action} objects (see below) defining
28206 @dfn{actions} supported by the service, in addition to the standard
28207 @code{start} and @code{stop} actions. Actions listed here become available as
28208 @command{herd} sub-commands:
28209
28210 @example
28211 herd @var{action} @var{service} [@var{arguments}@dots{}]
28212 @end example
28213
28214 @item @code{auto-start?} (default: @code{#t})
28215 Whether this service should be started automatically by the Shepherd. If it
28216 is @code{#f} the service has to be started manually with @code{herd start}.
28217
28218 @item @code{documentation}
28219 A documentation string, as shown when running:
28220
28221 @example
28222 herd doc @var{service-name}
28223 @end example
28224
28225 where @var{service-name} is one of the symbols in @code{provision}
28226 (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
28227
28228 @item @code{modules} (default: @code{%default-modules})
28229 This is the list of modules that must be in scope when @code{start} and
28230 @code{stop} are evaluated.
28231
28232 @end table
28233 @end deftp
28234
28235 @deftp {Data Type} shepherd-action
28236 This is the data type that defines additional actions implemented by a
28237 Shepherd service (see above).
28238
28239 @table @code
28240 @item name
28241 Symbol naming the action.
28242
28243 @item documentation
28244 This is a documentation string for the action. It can be viewed by running:
28245
28246 @example
28247 herd doc @var{service} action @var{action}
28248 @end example
28249
28250 @item procedure
28251 This should be a gexp that evaluates to a procedure of at least one argument,
28252 which is the ``running value'' of the service (@pxref{Slots of services,,,
28253 shepherd, The GNU Shepherd Manual}).
28254 @end table
28255
28256 The following example defines an action called @code{say-hello} that kindly
28257 greets the user:
28258
28259 @lisp
28260 (shepherd-action
28261 (name 'say-hello)
28262 (documentation "Say hi!")
28263 (procedure #~(lambda (running . args)
28264 (format #t "Hello, friend! arguments: ~s\n"
28265 args)
28266 #t)))
28267 @end lisp
28268
28269 Assuming this action is added to the @code{example} service, then you can do:
28270
28271 @example
28272 # herd say-hello example
28273 Hello, friend! arguments: ()
28274 # herd say-hello example a b c
28275 Hello, friend! arguments: ("a" "b" "c")
28276 @end example
28277
28278 This, as you can see, is a fairly sophisticated way to say hello.
28279 @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
28280 info on actions.
28281 @end deftp
28282
28283 @defvr {Scheme Variable} shepherd-root-service-type
28284 The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
28285
28286 This is the service type that extensions target when they want to create
28287 shepherd services (@pxref{Service Types and Services}, for an example).
28288 Each extension must pass a list of @code{<shepherd-service>}.
28289 @end defvr
28290
28291 @defvr {Scheme Variable} %shepherd-root-service
28292 This service represents PID@tie{}1.
28293 @end defvr
28294
28295
28296 @node Documentation
28297 @chapter Documentation
28298
28299 @cindex documentation, searching for
28300 @cindex searching for documentation
28301 @cindex Info, documentation format
28302 @cindex man pages
28303 @cindex manual pages
28304 In most cases packages installed with Guix come with documentation.
28305 There are two main documentation formats: ``Info'', a browseable
28306 hypertext format used for GNU software, and ``manual pages'' (or ``man
28307 pages''), the linear documentation format traditionally found on Unix.
28308 Info manuals are accessed with the @command{info} command or with Emacs,
28309 and man pages are accessed using @command{man}.
28310
28311 You can look for documentation of software installed on your system by
28312 keyword. For example, the following command searches for information
28313 about ``TLS'' in Info manuals:
28314
28315 @example
28316 $ info -k TLS
28317 "(emacs)Network Security" -- STARTTLS
28318 "(emacs)Network Security" -- TLS
28319 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
28320 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
28321 @dots{}
28322 @end example
28323
28324 @noindent
28325 The command below searches for the same keyword in man pages:
28326
28327 @example
28328 $ man -k TLS
28329 SSL (7) - OpenSSL SSL/TLS library
28330 certtool (1) - GnuTLS certificate tool
28331 @dots {}
28332 @end example
28333
28334 These searches are purely local to your computer so you have the
28335 guarantee that documentation you find corresponds to what you have
28336 actually installed, you can access it off-line, and your privacy is
28337 respected.
28338
28339 Once you have these results, you can view the relevant documentation by
28340 running, say:
28341
28342 @example
28343 $ info "(gnutls)Core TLS API"
28344 @end example
28345
28346 @noindent
28347 or:
28348
28349 @example
28350 $ man certtool
28351 @end example
28352
28353 Info manuals contain sections and indices as well as hyperlinks like
28354 those found in Web pages. The @command{info} reader (@pxref{Top, Info
28355 reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
28356 (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
28357 bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
28358 Introduction}, for an introduction to Info navigation.
28359
28360 @node Installing Debugging Files
28361 @chapter Installing Debugging Files
28362
28363 @cindex debugging files
28364 Program binaries, as produced by the GCC compilers for instance, are
28365 typically written in the ELF format, with a section containing
28366 @dfn{debugging information}. Debugging information is what allows the
28367 debugger, GDB, to map binary code to source code; it is required to
28368 debug a compiled program in good conditions.
28369
28370 The problem with debugging information is that is takes up a fair amount
28371 of disk space. For example, debugging information for the GNU C Library
28372 weighs in at more than 60 MiB. Thus, as a user, keeping all the
28373 debugging info of all the installed programs is usually not an option.
28374 Yet, space savings should not come at the cost of an impediment to
28375 debugging---especially in the GNU system, which should make it easier
28376 for users to exert their computing freedom (@pxref{GNU Distribution}).
28377
28378 Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
28379 mechanism that allows users to get the best of both worlds: debugging
28380 information can be stripped from the binaries and stored in separate
28381 files. GDB is then able to load debugging information from those files,
28382 when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
28383 with GDB}).
28384
28385 The GNU distribution takes advantage of this by storing debugging
28386 information in the @code{lib/debug} sub-directory of a separate package
28387 output unimaginatively called @code{debug} (@pxref{Packages with
28388 Multiple Outputs}). Users can choose to install the @code{debug} output
28389 of a package when they need it. For instance, the following command
28390 installs the debugging information for the GNU C Library and for GNU
28391 Guile:
28392
28393 @example
28394 guix install glibc:debug guile:debug
28395 @end example
28396
28397 GDB must then be told to look for debug files in the user's profile, by
28398 setting the @code{debug-file-directory} variable (consider setting it
28399 from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
28400 GDB}):
28401
28402 @example
28403 (gdb) set debug-file-directory ~/.guix-profile/lib/debug
28404 @end example
28405
28406 From there on, GDB will pick up debugging information from the
28407 @file{.debug} files under @file{~/.guix-profile/lib/debug}.
28408
28409 In addition, you will most likely want GDB to be able to show the source
28410 code being debugged. To do that, you will have to unpack the source
28411 code of the package of interest (obtained with @code{guix build
28412 --source}, @pxref{Invoking guix build}), and to point GDB to that source
28413 directory using the @code{directory} command (@pxref{Source Path,
28414 @code{directory},, gdb, Debugging with GDB}).
28415
28416 @c XXX: keep me up-to-date
28417 The @code{debug} output mechanism in Guix is implemented by the
28418 @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
28419 opt-in---debugging information is available only for the packages
28420 with definitions explicitly declaring a @code{debug} output. This may be
28421 changed to opt-out in the future if our build farm servers can handle
28422 the load. To check whether a package has a @code{debug} output, use
28423 @command{guix package --list-available} (@pxref{Invoking guix package}).
28424
28425
28426 @node Security Updates
28427 @chapter Security Updates
28428
28429 @cindex security updates
28430 @cindex security vulnerabilities
28431 Occasionally, important security vulnerabilities are discovered in software
28432 packages and must be patched. Guix developers try hard to keep track of
28433 known vulnerabilities and to apply fixes as soon as possible in the
28434 @code{master} branch of Guix (we do not yet provide a ``stable'' branch
28435 containing only security updates.) The @command{guix lint} tool helps
28436 developers find out about vulnerable versions of software packages in the
28437 distribution:
28438
28439 @smallexample
28440 $ guix lint -c cve
28441 gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
28442 gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
28443 gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
28444 @dots{}
28445 @end smallexample
28446
28447 @xref{Invoking guix lint}, for more information.
28448
28449 Guix follows a functional
28450 package management discipline (@pxref{Introduction}), which implies
28451 that, when a package is changed, @emph{every package that depends on it}
28452 must be rebuilt. This can significantly slow down the deployment of
28453 fixes in core packages such as libc or Bash, since basically the whole
28454 distribution would need to be rebuilt. Using pre-built binaries helps
28455 (@pxref{Substitutes}), but deployment may still take more time than
28456 desired.
28457
28458 @cindex grafts
28459 To address this, Guix implements @dfn{grafts}, a mechanism that allows
28460 for fast deployment of critical updates without the costs associated
28461 with a whole-distribution rebuild. The idea is to rebuild only the
28462 package that needs to be patched, and then to ``graft'' it onto packages
28463 explicitly installed by the user and that were previously referring to
28464 the original package. The cost of grafting is typically very low, and
28465 order of magnitudes lower than a full rebuild of the dependency chain.
28466
28467 @cindex replacements of packages, for grafts
28468 For instance, suppose a security update needs to be applied to Bash.
28469 Guix developers will provide a package definition for the ``fixed''
28470 Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
28471 Packages}). Then, the original package definition is augmented with a
28472 @code{replacement} field pointing to the package containing the bug fix:
28473
28474 @lisp
28475 (define bash
28476 (package
28477 (name "bash")
28478 ;; @dots{}
28479 (replacement bash-fixed)))
28480 @end lisp
28481
28482 From there on, any package depending directly or indirectly on Bash---as
28483 reported by @command{guix gc --requisites} (@pxref{Invoking guix
28484 gc})---that is installed is automatically ``rewritten'' to refer to
28485 @code{bash-fixed} instead of @code{bash}. This grafting process takes
28486 time proportional to the size of the package, usually less than a
28487 minute for an ``average'' package on a recent machine. Grafting is
28488 recursive: when an indirect dependency requires grafting, then grafting
28489 ``propagates'' up to the package that the user is installing.
28490
28491 Currently, the length of the name and version of the graft and that of
28492 the package it replaces (@code{bash-fixed} and @code{bash} in the example
28493 above) must be equal. This restriction mostly comes from the fact that
28494 grafting works by patching files, including binary files, directly.
28495 Other restrictions may apply: for instance, when adding a graft to a
28496 package providing a shared library, the original shared library and its
28497 replacement must have the same @code{SONAME} and be binary-compatible.
28498
28499 The @option{--no-grafts} command-line option allows you to forcefully
28500 avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
28501 Thus, the command:
28502
28503 @example
28504 guix build bash --no-grafts
28505 @end example
28506
28507 @noindent
28508 returns the store file name of the original Bash, whereas:
28509
28510 @example
28511 guix build bash
28512 @end example
28513
28514 @noindent
28515 returns the store file name of the ``fixed'', replacement Bash. This
28516 allows you to distinguish between the two variants of Bash.
28517
28518 To verify which Bash your whole profile refers to, you can run
28519 (@pxref{Invoking guix gc}):
28520
28521 @example
28522 guix gc -R `readlink -f ~/.guix-profile` | grep bash
28523 @end example
28524
28525 @noindent
28526 @dots{} and compare the store file names that you get with those above.
28527 Likewise for a complete Guix system generation:
28528
28529 @example
28530 guix gc -R `guix system build my-config.scm` | grep bash
28531 @end example
28532
28533 Lastly, to check which Bash running processes are using, you can use the
28534 @command{lsof} command:
28535
28536 @example
28537 lsof | grep /gnu/store/.*bash
28538 @end example
28539
28540
28541 @node Bootstrapping
28542 @chapter Bootstrapping
28543
28544 @c Adapted from the ELS 2013 paper.
28545
28546 @cindex bootstrapping
28547
28548 Bootstrapping in our context refers to how the distribution gets built
28549 ``from nothing''. Remember that the build environment of a derivation
28550 contains nothing but its declared inputs (@pxref{Introduction}). So
28551 there's an obvious chicken-and-egg problem: how does the first package
28552 get built? How does the first compiler get compiled? Note that this is
28553 a question of interest only to the curious hacker, not to the regular
28554 user, so you can shamelessly skip this section if you consider yourself
28555 a ``regular user''.
28556
28557 @cindex bootstrap binaries
28558 The GNU system is primarily made of C code, with libc at its core. The
28559 GNU build system itself assumes the availability of a Bourne shell and
28560 command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
28561 `grep'. Furthermore, build programs---programs that run
28562 @code{./configure}, @code{make}, etc.---are written in Guile Scheme
28563 (@pxref{Derivations}). Consequently, to be able to build anything at
28564 all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
28565 Binutils, libc, and the other packages mentioned above---the
28566 @dfn{bootstrap binaries}.
28567
28568 These bootstrap binaries are ``taken for granted'', though we can also
28569 re-create them if needed (more on that later).
28570
28571 For @code{i686-linux} and @code{x86_64-linux} the Guix bootstrap process is
28572 more elaborate, @pxref{Reduced Binary Seed Bootstrap}.
28573
28574 @menu
28575 * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
28576 * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
28577 @end menu
28578
28579 @node Reduced Binary Seed Bootstrap
28580 @section The Reduced Binary Seed Bootstrap
28581
28582 Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
28583 a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
28584 Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
28585 GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
28586 ``taken for granted.''
28587
28588 Taking these binaries for granted means that we consider them to be a correct
28589 and trustworthy `seed' for building the complete system. Therein lies a
28590 problem: the current combined size of these bootstrap binaries is about 250MB
28591 (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing or even inspecting
28592 these is next to impossible.
28593
28594 For @code{i686-linux} and @code{x86_64-linux}, Guix now features a ``Reduced
28595 Binary Seed'' bootstrap @footnote{We would like to say: ``Full Source
28596 Bootstrap'' and while we are working towards that goal it would be hyperbole
28597 to use that term for what we do now.}.
28598
28599 The Reduced Binary Seed bootstrap removes the most critical tools---from a
28600 trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
28601 Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
28602 linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
28603 written in Scheme and the Mes C Library, built for TinyCC and for GCC). Using
28604 these new binary seeds and a new set of
28605 @c
28606 packages@footnote{@c
28607 nyacc-boot,
28608 mes-boot,
28609 tcc-boot0,
28610 tcc-boot,
28611 make-mesboot0,
28612 diffutils-mesboot,
28613 binutils-mesboot0,
28614 gcc-core-mesboot,
28615 mesboot-headers,
28616 glibc-mesboot0,
28617 gcc-mesboot0,
28618 binutils-mesboot,
28619 make-mesboot,
28620 gcc-mesboot1,
28621 gcc-mesboot1-wrapper,
28622 glibc-headers-mesboot,
28623 glibc-mesboot,
28624 gcc-mesboot,
28625 and
28626 gcc-mesboot-wrapper.
28627 }
28628 @c
28629 the ``missing'' Binutils, GCC, and the GNU C Library are built from source.
28630 From here on the more traditional bootstrap process resumes. This approach
28631 has reduced the bootstrap binaries in size to about 130MB. Work is ongoing to
28632 reduce this further. If you are interested, join us on @code{#bootstrappable}
28633 on the Freenode IRC network.
28634
28635 @c ./pre-inst-env guix graph --type=bag -e '(begin (use-modules (guix packages)) (%current-system "i686-linux") (@@ (gnu packages commencement) gcc-mesboot))' > doc/images/gcc-mesboot-bag-graph.dot
28636 @c dot -T png doc/images/gcc-mesboot-bag-graph.dot > doc/images/gcc-mesboot-bag-graph.png
28637
28638 Below is the generated dependency graph for @code{gcc-mesboot}, the bootstrap
28639 compiler used to build the rest of GuixSD.
28640
28641 @image{images/gcc-mesboot-bag-graph,6in,,Dependency graph of the gcc-mesboot}
28642
28643 @node Preparing to Use the Bootstrap Binaries
28644 @section Preparing to Use the Bootstrap Binaries
28645
28646 @c As of Emacs 24.3, Info-mode displays the image, but since it's a
28647 @c large image, it's hard to scroll. Oh well.
28648 @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
28649
28650 The figure above shows the very beginning of the dependency graph of the
28651 distribution, corresponding to the package definitions of the @code{(gnu
28652 packages bootstrap)} module. A similar figure can be generated with
28653 @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
28654
28655 @example
28656 guix graph -t derivation \
28657 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
28658 | dot -Tps > gcc.ps
28659 @end example
28660
28661 or, for the Reduced Binary Seed bootstrap
28662
28663 @example
28664 guix graph -t derivation \
28665 -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
28666 | dot -Tps > mes.ps
28667 @end example
28668
28669 At this level of detail, things are
28670 slightly complex. First, Guile itself consists of an ELF executable,
28671 along with many source and compiled Scheme files that are dynamically
28672 loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
28673 tarball shown in this graph. This tarball is part of Guix's ``source''
28674 distribution, and gets inserted into the store with @code{add-to-store}
28675 (@pxref{The Store}).
28676
28677 But how do we write a derivation that unpacks this tarball and adds it
28678 to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
28679 derivation---the first one that gets built---uses @code{bash} as its
28680 builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
28681 @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
28682 @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
28683 the Guix source distribution, whose sole purpose is to allow the Guile
28684 tarball to be unpacked.
28685
28686 Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
28687 Guile that can be used to run subsequent build programs. Its first task
28688 is to download tarballs containing the other pre-built binaries---this
28689 is what the @file{.tar.xz.drv} derivations do. Guix modules such as
28690 @code{ftp-client.scm} are used for this purpose. The
28691 @code{module-import.drv} derivations import those modules in a directory
28692 in the store, using the original layout. The
28693 @code{module-import-compiled.drv} derivations compile those modules, and
28694 write them in an output directory with the right layout. This
28695 corresponds to the @code{#:modules} argument of
28696 @code{build-expression->derivation} (@pxref{Derivations}).
28697
28698 Finally, the various tarballs are unpacked by the derivations
28699 @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
28700 @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
28701 point we have a working C tool chain.
28702
28703 @unnumberedsec Building the Build Tools
28704
28705 Bootstrapping is complete when we have a full tool chain that does not
28706 depend on the pre-built bootstrap tools discussed above. This
28707 no-dependency requirement is verified by checking whether the files of
28708 the final tool chain contain references to the @file{/gnu/store}
28709 directories of the bootstrap inputs. The process that leads to this
28710 ``final'' tool chain is described by the package definitions found in
28711 the @code{(gnu packages commencement)} module.
28712
28713 The @command{guix graph} command allows us to ``zoom out'' compared to
28714 the graph above, by looking at the level of package objects instead of
28715 individual derivations---remember that a package may translate to
28716 several derivations, typically one derivation to download its source,
28717 one to build the Guile modules it needs, and one to actually build the
28718 package from source. The command:
28719
28720 @example
28721 guix graph -t bag \
28722 -e '(@@@@ (gnu packages commencement)
28723 glibc-final-with-bootstrap-bash)' | xdot -
28724 @end example
28725
28726 @noindent
28727 displays the dependency graph leading to the ``final'' C
28728 library@footnote{You may notice the @code{glibc-intermediate} label,
28729 suggesting that it is not @emph{quite} final, but as a good
28730 approximation, we will consider it final.}, depicted below.
28731
28732 @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
28733
28734 @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
28735 The first tool that gets built with the bootstrap binaries is
28736 GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
28737 for all the following packages. From there Findutils and Diffutils get
28738 built.
28739
28740 Then come the first-stage Binutils and GCC, built as pseudo cross
28741 tools---i.e., with @option{--target} equal to @option{--host}. They are
28742 used to build libc. Thanks to this cross-build trick, this libc is
28743 guaranteed not to hold any reference to the initial tool chain.
28744
28745 From there the final Binutils and GCC (not shown above) are built. GCC
28746 uses @command{ld} from the final Binutils, and links programs against
28747 the just-built libc. This tool chain is used to build the other
28748 packages used by Guix and by the GNU Build System: Guile, Bash,
28749 Coreutils, etc.
28750
28751 And voilà! At this point we have the complete set of build tools that
28752 the GNU Build System expects. These are in the @code{%final-inputs}
28753 variable of the @code{(gnu packages commencement)} module, and are
28754 implicitly used by any package that uses @code{gnu-build-system}
28755 (@pxref{Build Systems, @code{gnu-build-system}}).
28756
28757
28758 @unnumberedsec Building the Bootstrap Binaries
28759
28760 @cindex bootstrap binaries
28761 Because the final tool chain does not depend on the bootstrap binaries,
28762 those rarely need to be updated. Nevertheless, it is useful to have an
28763 automated way to produce them, should an update occur, and this is what
28764 the @code{(gnu packages make-bootstrap)} module provides.
28765
28766 The following command builds the tarballs containing the bootstrap binaries
28767 (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
28768 bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
28769 and Guile, and a tarball containing a mixture of Coreutils and other basic
28770 command-line tools):
28771
28772 @example
28773 guix build bootstrap-tarballs
28774 @end example
28775
28776 The generated tarballs are those that should be referred to in the
28777 @code{(gnu packages bootstrap)} module mentioned at the beginning of
28778 this section.
28779
28780 Still here? Then perhaps by now you've started to wonder: when do we
28781 reach a fixed point? That is an interesting question! The answer is
28782 unknown, but if you would like to investigate further (and have
28783 significant computational and storage resources to do so), then let us
28784 know.
28785
28786 @unnumberedsec Reducing the Set of Bootstrap Binaries
28787
28788 Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
28789 binary code! Why is that a problem? It's a problem because these big chunks
28790 of binary code are practically non-auditable, which makes it hard to establish
28791 what source code produced them. Every unauditable binary also leaves us
28792 vulnerable to compiler backdoors as described by Ken Thompson in the 1984
28793 paper @emph{Reflections on Trusting Trust}.
28794
28795 This is mitigated by the fact that our bootstrap binaries were generated
28796 from an earlier Guix revision. Nevertheless it lacks the level of
28797 transparency that we get in the rest of the package dependency graph,
28798 where Guix always gives us a source-to-binary mapping. Thus, our goal
28799 is to reduce the set of bootstrap binaries to the bare minimum.
28800
28801 The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
28802 on-going projects to do that. One of these is about replacing the
28803 bootstrap GCC with a sequence of assemblers, interpreters, and compilers
28804 of increasing complexity, which could be built from source starting from
28805 a simple and auditable assembler.
28806
28807 Our first major achievement is the replacement of of GCC, the GNU C Library
28808 and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
28809 (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
28810 and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
28811 bootstrapped yet and thus we inject them as binary seeds. We call this the
28812 Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
28813 binaries! Also, it has eliminated the C compiler binary; i686-linux and
28814 x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
28815
28816 Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
28817 also looking at any other bootstrap binaries. Your help is welcome!
28818
28819 @node Porting
28820 @chapter Porting to a New Platform
28821
28822 As discussed above, the GNU distribution is self-contained, and
28823 self-containment is achieved by relying on pre-built ``bootstrap
28824 binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
28825 operating system kernel, CPU architecture, and application binary
28826 interface (ABI). Thus, to port the distribution to a platform that is
28827 not yet supported, one must build those bootstrap binaries, and update
28828 the @code{(gnu packages bootstrap)} module to use them on that platform.
28829
28830 Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
28831 When everything goes well, and assuming the GNU tool chain supports the
28832 target platform, this can be as simple as running a command like this
28833 one:
28834
28835 @example
28836 guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
28837 @end example
28838
28839 For this to work, the @code{glibc-dynamic-linker} procedure in
28840 @code{(gnu packages bootstrap)} must be augmented to return the right
28841 file name for libc's dynamic linker on that platform; likewise,
28842 @code{system->linux-architecture} in @code{(gnu packages linux)} must be
28843 taught about the new platform.
28844
28845 Once these are built, the @code{(gnu packages bootstrap)} module needs
28846 to be updated to refer to these binaries on the target platform. That
28847 is, the hashes and URLs of the bootstrap tarballs for the new platform
28848 must be added alongside those of the currently supported platforms. The
28849 bootstrap Guile tarball is treated specially: it is expected to be
28850 available locally, and @file{gnu/local.mk} has rules to download it for
28851 the supported architectures; a rule for the new platform must be added
28852 as well.
28853
28854 In practice, there may be some complications. First, it may be that the
28855 extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
28856 above) is not recognized by all the GNU tools. Typically, glibc
28857 recognizes some of these, whereas GCC uses an extra @option{--with-abi}
28858 configure flag (see @code{gcc.scm} for examples of how to handle this).
28859 Second, some of the required packages could fail to build for that
28860 platform. Lastly, the generated binaries could be broken for some
28861 reason.
28862
28863 @c *********************************************************************
28864 @include contributing.texi
28865
28866 @c *********************************************************************
28867 @node Acknowledgments
28868 @chapter Acknowledgments
28869
28870 Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
28871 which was designed and
28872 implemented by Eelco Dolstra, with contributions from other people (see
28873 the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
28874 management, and promoted unprecedented features, such as transactional
28875 package upgrades and rollbacks, per-user profiles, and referentially
28876 transparent build processes. Without this work, Guix would not exist.
28877
28878 The Nix-based software distributions, Nixpkgs and NixOS, have also been
28879 an inspiration for Guix.
28880
28881 GNU@tie{}Guix itself is a collective work with contributions from a
28882 number of people. See the @file{AUTHORS} file in Guix for more
28883 information on these fine people. The @file{THANKS} file lists people
28884 who have helped by reporting bugs, taking care of the infrastructure,
28885 providing artwork and themes, making suggestions, and more---thank you!
28886
28887
28888 @c *********************************************************************
28889 @node GNU Free Documentation License
28890 @appendix GNU Free Documentation License
28891 @cindex license, GNU Free Documentation License
28892 @include fdl-1.3.texi
28893
28894 @c *********************************************************************
28895 @node Concept Index
28896 @unnumbered Concept Index
28897 @printindex cp
28898
28899 @node Programming Index
28900 @unnumbered Programming Index
28901 @syncodeindex tp fn
28902 @syncodeindex vr fn
28903 @printindex fn
28904
28905 @bye
28906
28907 @c Local Variables:
28908 @c ispell-local-dictionary: "american";
28909 @c End: