system: Provide a new VM image configuration.
[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 KEY-SERVER pool.sks-keyservers.net
15
16 @c The official substitute server used by default.
17 @set SUBSTITUTE-SERVER ci.guix.info
18
19 @copying
20 Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès@*
21 Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
22 Copyright @copyright{} 2013 Nikita Karetnikov@*
23 Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
24 Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
25 Copyright @copyright{} 2014 Pierre-Antoine Rault@*
26 Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
27 Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
28 Copyright @copyright{} 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus@*
29 Copyright @copyright{} 2016 Ben Woodcroft@*
30 Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
31 Copyright @copyright{} 2016, 2017, 2018, 2019 Efraim Flashner@*
32 Copyright @copyright{} 2016 John Darrington@*
33 Copyright @copyright{} 2016, 2017 ng0@*
34 Copyright @copyright{} 2016, 2017, 2018, 2019 Jan Nieuwenhuizen@*
35 Copyright @copyright{} 2016 Julien Lepiller@*
36 Copyright @copyright{} 2016 Alex ter Weele@*
37 Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@*
38 Copyright @copyright{} 2017, 2018 Clément Lassieur@*
39 Copyright @copyright{} 2017, 2018 Mathieu Othacehe@*
40 Copyright @copyright{} 2017 Federico Beffa@*
41 Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
42 Copyright @copyright{} 2017 Thomas Danckaert@*
43 Copyright @copyright{} 2017 humanitiesNerd@*
44 Copyright @copyright{} 2017 Christopher Allan Webber@*
45 Copyright @copyright{} 2017, 2018 Marius Bakke@*
46 Copyright @copyright{} 2017 Hartmut Goebel@*
47 Copyright @copyright{} 2017 Maxim Cournoyer@*
48 Copyright @copyright{} 2017, 2018 Tobias Geerinckx-Rice@*
49 Copyright @copyright{} 2017 George Clemmer@*
50 Copyright @copyright{} 2017 Andy Wingo@*
51 Copyright @copyright{} 2017, 2018, 2019 Arun Isaac@*
52 Copyright @copyright{} 2017 nee@*
53 Copyright @copyright{} 2018 Rutger Helling@*
54 Copyright @copyright{} 2018 Oleg Pykhalov@*
55 Copyright @copyright{} 2018 Mike Gerwitz@*
56 Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
57 Copyright @copyright{} 2018 Gábor Boskovits@*
58 Copyright @copyright{} 2018 Florian Pelz@*
59 Copyright @copyright{} 2018 Laura Lazzati@*
60 Copyright @copyright{} 2018 Alex Vong@*
61
62 Permission is granted to copy, distribute and/or modify this document
63 under the terms of the GNU Free Documentation License, Version 1.3 or
64 any later version published by the Free Software Foundation; with no
65 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
66 copy of the license is included in the section entitled ``GNU Free
67 Documentation License''.
68 @end copying
69
70 @dircategory System administration
71 @direntry
72 * Guix: (guix). Manage installed software and system configuration.
73 * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
74 * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
75 * guix pull: (guix)Invoking guix pull. Update the list of available packages.
76 * guix system: (guix)Invoking guix system. Manage the operating system configuration.
77 @end direntry
78
79 @dircategory Software development
80 @direntry
81 * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
82 * guix build: (guix)Invoking guix build. Building packages.
83 * guix pack: (guix)Invoking guix pack. Creating binary bundles.
84 @end direntry
85
86 @titlepage
87 @title GNU Guix Reference Manual
88 @subtitle Using the GNU Guix Functional Package Manager
89 @author The GNU Guix Developers
90
91 @page
92 @vskip 0pt plus 1filll
93 Edition @value{EDITION} @*
94 @value{UPDATED} @*
95
96 @insertcopying
97 @end titlepage
98
99 @contents
100
101 @c *********************************************************************
102 @node Top
103 @top GNU Guix
104
105 This document describes GNU Guix version @value{VERSION}, a functional
106 package management tool written for the GNU system.
107
108 @c TRANSLATORS: You can replace the following paragraph with information on
109 @c how to join your own translation team and how to report issues with the
110 @c translation.
111 This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
112 GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
113 Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}), and
114 Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}). If you
115 would like to translate it in your native language, consider joining the
116 @uref{https://translationproject.org/domain/guix-manual.html, Translation
117 Project}.
118
119 @menu
120 * Introduction:: What is Guix about?
121 * Installation:: Installing Guix.
122 * System Installation:: Installing the whole operating system.
123 * Package Management:: Package installation, upgrade, etc.
124 * Development:: Guix-aided software development.
125 * Programming Interface:: Using Guix in Scheme.
126 * Utilities:: Package management commands.
127 * System Configuration:: Configuring the operating system.
128 * Documentation:: Browsing software user manuals.
129 * Installing Debugging Files:: Feeding the debugger.
130 * Security Updates:: Deploying security fixes quickly.
131 * Bootstrapping:: GNU/Linux built from scratch.
132 * Porting:: Targeting another platform or kernel.
133 * Contributing:: Your help needed!
134
135 * Acknowledgments:: Thanks!
136 * GNU Free Documentation License:: The license of this manual.
137 * Concept Index:: Concepts.
138 * Programming Index:: Data types, functions, and variables.
139
140 @detailmenu
141 --- The Detailed Node Listing ---
142
143 Introduction
144
145 * Managing Software the Guix Way:: What's special.
146 * GNU Distribution:: The packages and tools.
147
148 Installation
149
150 * Binary Installation:: Getting Guix running in no time!
151 * Requirements:: Software needed to build and run Guix.
152 * Running the Test Suite:: Testing Guix.
153 * Setting Up the Daemon:: Preparing the build daemon's environment.
154 * Invoking guix-daemon:: Running the build daemon.
155 * Application Setup:: Application-specific setup.
156
157 Setting Up the Daemon
158
159 * Build Environment Setup:: Preparing the isolated build environment.
160 * Daemon Offload Setup:: Offloading builds to remote machines.
161 * SELinux Support:: Using an SELinux policy for the daemon.
162
163 System Installation
164
165 * Limitations:: What you can expect.
166 * Hardware Considerations:: Supported hardware.
167 * USB Stick and DVD Installation:: Preparing the installation medium.
168 * Preparing for Installation:: Networking, partitioning, etc.
169 * Guided Graphical Installation:: Easy graphical installation.
170 * Manual Installation:: Manual installation for wizards.
171 * After System Installation:: When installation succeeded.
172 * Installing Guix in a VM:: Guix System playground.
173 * Building the Installation Image:: How this comes to be.
174
175 Manual Installation
176
177 * Keyboard Layout and Networking and Partitioning:: Initial setup.
178 * Proceeding with the Installation:: Installing.
179
180 Package Management
181
182 * Features:: How Guix will make your life brighter.
183 * Invoking guix package:: Package installation, removal, etc.
184 * Substitutes:: Downloading pre-built binaries.
185 * Packages with Multiple Outputs:: Single source package, multiple outputs.
186 * Invoking guix gc:: Running the garbage collector.
187 * Invoking guix pull:: Fetching the latest Guix and distribution.
188 * Channels:: Customizing the package collection.
189 * Inferiors:: Interacting with another revision of Guix.
190 * Invoking guix describe:: Display information about your Guix revision.
191 * Invoking guix archive:: Exporting and importing store files.
192
193 Substitutes
194
195 * Official Substitute Server:: One particular source of substitutes.
196 * Substitute Server Authorization:: How to enable or disable substitutes.
197 * Substitute Authentication:: How Guix verifies substitutes.
198 * Proxy Settings:: How to get substitutes via proxy.
199 * Substitution Failure:: What happens when substitution fails.
200 * On Trusting Binaries:: How can you trust that binary blob?
201
202 Development
203
204 * Invoking guix environment:: Setting up development environments.
205 * Invoking guix pack:: Creating software bundles.
206
207 Programming Interface
208
209 * Package Modules:: Packages from the programmer's viewpoint.
210 * Defining Packages:: Defining new packages.
211 * Build Systems:: Specifying how packages are built.
212 * The Store:: Manipulating the package store.
213 * Derivations:: Low-level interface to package derivations.
214 * The Store Monad:: Purely functional interface to the store.
215 * G-Expressions:: Manipulating build expressions.
216 * Invoking guix repl:: Fiddling with Guix interactively.
217
218 Defining Packages
219
220 * package Reference:: The package data type.
221 * origin Reference:: The origin data type.
222
223 Utilities
224
225 * Invoking guix build:: Building packages from the command line.
226 * Invoking guix edit:: Editing package definitions.
227 * Invoking guix download:: Downloading a file and printing its hash.
228 * Invoking guix hash:: Computing the cryptographic hash of a file.
229 * Invoking guix import:: Importing package definitions.
230 * Invoking guix refresh:: Updating package definitions.
231 * Invoking guix lint:: Finding errors in package definitions.
232 * Invoking guix size:: Profiling disk usage.
233 * Invoking guix graph:: Visualizing the graph of packages.
234 * Invoking guix publish:: Sharing substitutes.
235 * Invoking guix challenge:: Challenging substitute servers.
236 * Invoking guix copy:: Copying to and from a remote store.
237 * Invoking guix container:: Process isolation.
238 * Invoking guix weather:: Assessing substitute availability.
239 * Invoking guix processes:: Listing client processes.
240
241 Invoking @command{guix build}
242
243 * Common Build Options:: Build options for most commands.
244 * Package Transformation Options:: Creating variants of packages.
245 * Additional Build Options:: Options specific to 'guix build'.
246 * Debugging Build Failures:: Real life packaging experience.
247
248 System Configuration
249
250 * Using the Configuration System:: Customizing your GNU system.
251 * operating-system Reference:: Detail of operating-system declarations.
252 * File Systems:: Configuring file system mounts.
253 * Mapped Devices:: Block device extra processing.
254 * User Accounts:: Specifying user accounts.
255 * Keyboard Layout:: How the system interprets key strokes.
256 * Locales:: Language and cultural convention settings.
257 * Services:: Specifying system services.
258 * Setuid Programs:: Programs running with root privileges.
259 * X.509 Certificates:: Authenticating HTTPS servers.
260 * Name Service Switch:: Configuring libc's name service switch.
261 * Initial RAM Disk:: Linux-Libre bootstrapping.
262 * Bootloader Configuration:: Configuring the boot loader.
263 * Invoking guix system:: Instantiating a system configuration.
264 * Running Guix in a VM:: How to run Guix System in a virtual machine.
265 * Defining Services:: Adding new service definitions.
266
267 Services
268
269 * Base Services:: Essential system services.
270 * Scheduled Job Execution:: The mcron service.
271 * Log Rotation:: The rottlog service.
272 * Networking Services:: Network setup, SSH daemon, etc.
273 * X Window:: Graphical display.
274 * Printing Services:: Local and remote printer support.
275 * Desktop Services:: D-Bus and desktop services.
276 * Sound Services:: ALSA and Pulseaudio services.
277 * Database Services:: SQL databases, key-value stores, etc.
278 * Mail Services:: IMAP, POP3, SMTP, and all that.
279 * Messaging Services:: Messaging services.
280 * Telephony Services:: Telephony services.
281 * Monitoring Services:: Monitoring services.
282 * Kerberos Services:: Kerberos services.
283 * Web Services:: Web servers.
284 * Certificate Services:: TLS certificates via Let's Encrypt.
285 * DNS Services:: DNS daemons.
286 * VPN Services:: VPN daemons.
287 * Network File System:: NFS related services.
288 * Continuous Integration:: The Cuirass service.
289 * Power Management Services:: Extending battery life.
290 * Audio Services:: The MPD.
291 * Virtualization Services:: Virtualization services.
292 * Version Control Services:: Providing remote access to Git repositories.
293 * Game Services:: Game servers.
294 * Miscellaneous Services:: Other services.
295
296 Defining Services
297
298 * Service Composition:: The model for composing services.
299 * Service Types and Services:: Types and services.
300 * Service Reference:: API reference.
301 * Shepherd Services:: A particular type of service.
302
303 @end detailmenu
304 @end menu
305
306 @c *********************************************************************
307 @node Introduction
308 @chapter Introduction
309
310 @cindex purpose
311 GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
312 using the international phonetic alphabet (IPA).} is a package
313 management tool for and distribution of the GNU system.
314 Guix makes it easy for unprivileged
315 users to install, upgrade, or remove software packages, to roll back to a
316 previous package set, to build packages from source, and generally
317 assists with the creation and maintenance of software environments.
318
319 @cindex Guix System
320 @cindex GuixSD, now Guix System
321 @cindex Guix System Distribution, now Guix System
322 You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
323 complements the available tools without interference (@pxref{Installation}),
324 or you can use it as a standalone operating system distribution,
325 @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
326 System Distribution'' or ``GuixSD''. We now consider it makes more sense to
327 group everything under the ``Guix'' banner since, after all, Guix System is
328 readily available through the @command{guix system} command, even if you're
329 using a different distro underneath!}. @xref{GNU Distribution}.
330
331 @menu
332 * Managing Software the Guix Way:: What's special.
333 * GNU Distribution:: The packages and tools.
334 @end menu
335
336 @node Managing Software the Guix Way
337 @section Managing Software the Guix Way
338
339 @cindex user interfaces
340 Guix provides a command-line package management interface
341 (@pxref{Package Management}), tools to help with software development
342 (@pxref{Development}), command-line utilities for more advanced usage,
343 (@pxref{Utilities}), as well as Scheme programming interfaces
344 (@pxref{Programming Interface}).
345 @cindex build daemon
346 Its @dfn{build daemon} is responsible for building packages on behalf of
347 users (@pxref{Setting Up the Daemon}) and for downloading pre-built
348 binaries from authorized sources (@pxref{Substitutes}).
349
350 @cindex extensibility of the distribution
351 @cindex customization, of packages
352 Guix includes package definitions for many GNU and non-GNU packages, all
353 of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
354 user's computing freedom}. It is @emph{extensible}: users can write
355 their own package definitions (@pxref{Defining Packages}) and make them
356 available as independent package modules (@pxref{Package Modules}). It
357 is also @emph{customizable}: users can @emph{derive} specialized package
358 definitions from existing ones, including from the command line
359 (@pxref{Package Transformation Options}).
360
361 @cindex functional package management
362 @cindex isolation
363 Under the hood, Guix implements the @dfn{functional package management}
364 discipline pioneered by Nix (@pxref{Acknowledgments}).
365 In Guix, the package build and installation process is seen
366 as a @emph{function}, in the mathematical sense. That function takes inputs,
367 such as build scripts, a compiler, and libraries, and
368 returns an installed package. As a pure function, its result depends
369 solely on its inputs---for instance, it cannot refer to software or
370 scripts that were not explicitly passed as inputs. A build function
371 always produces the same result when passed a given set of inputs. It
372 cannot alter the environment of the running system in
373 any way; for instance, it cannot create, modify, or delete files outside
374 of its build and installation directories. This is achieved by running
375 build processes in isolated environments (or @dfn{containers}), where only their
376 explicit inputs are visible.
377
378 @cindex store
379 The result of package build functions is @dfn{cached} in the file
380 system, in a special directory called @dfn{the store} (@pxref{The
381 Store}). Each package is installed in a directory of its own in the
382 store---by default under @file{/gnu/store}. The directory name contains
383 a hash of all the inputs used to build that package; thus, changing an
384 input yields a different directory name.
385
386 This approach is the foundation for the salient features of Guix: support
387 for transactional package upgrade and rollback, per-user installation, and
388 garbage collection of packages (@pxref{Features}).
389
390
391 @node GNU Distribution
392 @section GNU Distribution
393
394 @cindex Guix System
395 Guix comes with a distribution of the GNU system consisting entirely of
396 free software@footnote{The term ``free'' here refers to the
397 @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
398 users of that software}.}. The
399 distribution can be installed on its own (@pxref{System Installation}),
400 but it is also possible to install Guix as a package manager on top of
401 an installed GNU/Linux system (@pxref{Installation}). When we need to
402 distinguish between the two, we refer to the standalone distribution as
403 Guix@tie{}System.
404
405 The distribution provides core GNU packages such as GNU libc, GCC, and
406 Binutils, as well as many GNU and non-GNU applications. The complete
407 list of available packages can be browsed
408 @url{http://www.gnu.org/software/guix/packages,on-line} or by
409 running @command{guix package} (@pxref{Invoking guix package}):
410
411 @example
412 guix package --list-available
413 @end example
414
415 Our goal is to provide a practical 100% free software distribution of
416 Linux-based and other variants of GNU, with a focus on the promotion and
417 tight integration of GNU components, and an emphasis on programs and
418 tools that help users exert that freedom.
419
420 Packages are currently available on the following platforms:
421
422 @table @code
423
424 @item x86_64-linux
425 Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
426
427 @item i686-linux
428 Intel 32-bit architecture (IA32), Linux-Libre kernel;
429
430 @item armhf-linux
431 ARMv7-A architecture with hard float, Thumb-2 and NEON,
432 using the EABI hard-float application binary interface (ABI),
433 and Linux-Libre kernel.
434
435 @item aarch64-linux
436 little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
437 currently in an experimental stage, with limited support.
438 @xref{Contributing}, for how to help!
439
440 @item mips64el-linux
441 little-endian 64-bit MIPS processors, specifically the Loongson series,
442 n32 ABI, and Linux-Libre kernel.
443
444 @end table
445
446 With Guix@tie{}System, you @emph{declare} all aspects of the operating system
447 configuration and Guix takes care of instantiating the configuration in a
448 transactional, reproducible, and stateless fashion (@pxref{System
449 Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
450 initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
451 Manual}), the well-known GNU utilities and tool chain, as well as the
452 graphical environment or system services of your choice.
453
454 Guix System is available on all the above platforms except
455 @code{mips64el-linux}.
456
457 @noindent
458 For information on porting to other architectures or kernels,
459 @pxref{Porting}.
460
461 Building this distribution is a cooperative effort, and you are invited
462 to join! @xref{Contributing}, for information about how you can help.
463
464
465 @c *********************************************************************
466 @node Installation
467 @chapter Installation
468
469 @cindex installing Guix
470
471 @quotation Note
472 We recommend the use of this
473 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
474 shell installer script} to install Guix on top of a running GNU/Linux system,
475 thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
476 with the installation of the package manager, which can be done on top of a
477 running GNU/Linux system. If, instead, you want to install the complete GNU
478 operating system, @pxref{System Installation}.} The script automates the
479 download, installation, and initial configuration of Guix. It should be run
480 as the root user.
481 @end quotation
482
483 @cindex foreign distro
484 @cindex directories related to foreign distro
485 When installed on a foreign distro, GNU@tie{}Guix complements the available
486 tools without interference. Its data lives exclusively in two directories,
487 usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
488 such as @file{/etc}, are left untouched.
489
490 Once installed, Guix can be updated by running @command{guix pull}
491 (@pxref{Invoking guix pull}).
492
493 If you prefer to perform the installation steps manually or want to tweak
494 them, you may find the following subsections useful. They describe the
495 software requirements of Guix, as well as how to install it manually and get
496 ready to use it.
497
498 @menu
499 * Binary Installation:: Getting Guix running in no time!
500 * Requirements:: Software needed to build and run Guix.
501 * Running the Test Suite:: Testing Guix.
502 * Setting Up the Daemon:: Preparing the build daemon's environment.
503 * Invoking guix-daemon:: Running the build daemon.
504 * Application Setup:: Application-specific setup.
505 @end menu
506
507 @node Binary Installation
508 @section Binary Installation
509
510 @cindex installing Guix from binaries
511 @cindex installer script
512 This section describes how to install Guix on an arbitrary system from a
513 self-contained tarball providing binaries for Guix and for all its
514 dependencies. This is often quicker than installing from source, which
515 is described in the next sections. The only requirement is to have
516 GNU@tie{}tar and Xz.
517
518 Installing goes along these lines:
519
520 @enumerate
521 @item
522 @cindex downloading Guix binary
523 Download the binary tarball from
524 @indicateurl{https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
525 where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
526 already running the kernel Linux, and so on.
527
528 @c The following is somewhat duplicated in ``System Installation''.
529 Make sure to download the associated @file{.sig} file and to verify the
530 authenticity of the tarball against it, along these lines:
531
532 @example
533 $ wget https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
534 $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
535 @end example
536
537 If that command fails because you do not have the required public key,
538 then run this command to import it:
539
540 @example
541 $ gpg --keyserver @value{KEY-SERVER} \
542 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
543 @end example
544
545 @noindent
546 and rerun the @code{gpg --verify} command.
547 @c end authentication part
548
549 @item
550 Now, you need to become the @code{root} user. Depending on your distribution,
551 you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
552
553 @example
554 # cd /tmp
555 # tar --warning=no-timestamp -xf \
556 guix-binary-@value{VERSION}.@var{system}.tar.xz
557 # mv var/guix /var/ && mv gnu /
558 @end example
559
560 This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
561 The latter contains a ready-to-use profile for @code{root} (see next
562 step.)
563
564 Do @emph{not} unpack the tarball on a working Guix system since that
565 would overwrite its own essential files.
566
567 The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
568 not emit warnings about ``implausibly old time stamps'' (such
569 warnings were triggered by GNU@tie{}tar 1.26 and older; recent
570 versions are fine.)
571 They stem from the fact that all the
572 files in the archive have their modification time set to zero (which
573 means January 1st, 1970.) This is done on purpose to make sure the
574 archive content is independent of its creation time, thus making it
575 reproducible.
576
577 @item
578 Make the profile available under @file{~root/.config/guix/current}, which is
579 where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
580
581 @example
582 # mkdir -p ~root/.config/guix
583 # ln -sf /var/guix/profiles/per-user/root/current-guix \
584 ~root/.config/guix/current
585 @end example
586
587 Source @file{etc/profile} to augment @code{PATH} and other relevant
588 environment variables:
589
590 @example
591 # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
592 source $GUIX_PROFILE/etc/profile
593 @end example
594
595 @item
596 Create the group and user accounts for build users as explained below
597 (@pxref{Build Environment Setup}).
598
599 @item
600 Run the daemon, and set it to automatically start on boot.
601
602 If your host distro uses the systemd init system, this can be achieved
603 with these commands:
604
605 @c Versions of systemd that supported symlinked service files are not
606 @c yet widely deployed, so we should suggest that users copy the service
607 @c files into place.
608 @c
609 @c See this thread for more information:
610 @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
611
612 @example
613 # cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
614 /etc/systemd/system/
615 # systemctl start guix-daemon && systemctl enable guix-daemon
616 @end example
617
618 If your host distro uses the Upstart init system:
619
620 @example
621 # initctl reload-configuration
622 # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
623 /etc/init/
624 # start guix-daemon
625 @end example
626
627 Otherwise, you can still start the daemon manually with:
628
629 @example
630 # ~root/.config/guix/current/bin/guix-daemon \
631 --build-users-group=guixbuild
632 @end example
633
634 @item
635 Make the @command{guix} command available to other users on the machine,
636 for instance with:
637
638 @example
639 # mkdir -p /usr/local/bin
640 # cd /usr/local/bin
641 # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
642 @end example
643
644 It is also a good idea to make the Info version of this manual available
645 there:
646
647 @example
648 # mkdir -p /usr/local/share/info
649 # cd /usr/local/share/info
650 # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
651 do ln -s $i ; done
652 @end example
653
654 That way, assuming @file{/usr/local/share/info} is in the search path,
655 running @command{info guix} will open this manual (@pxref{Other Info
656 Directories,,, texinfo, GNU Texinfo}, for more details on changing the
657 Info search path.)
658
659 @item
660 @cindex substitutes, authorization thereof
661 To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
662 (@pxref{Substitutes}), authorize them:
663
664 @example
665 # guix archive --authorize < \
666 ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
667 @end example
668
669 @item
670 Each user may need to perform a few additional steps to make their Guix
671 environment ready for use, @pxref{Application Setup}.
672 @end enumerate
673
674 Voilà, the installation is complete!
675
676 You can confirm that Guix is working by installing a sample package into
677 the root profile:
678
679 @example
680 # guix package -i hello
681 @end example
682
683 The @code{guix} package must remain available in @code{root}'s profile,
684 or it would become subject to garbage collection---in which case you
685 would find yourself badly handicapped by the lack of the @command{guix}
686 command. In other words, do not remove @code{guix} by running
687 @code{guix package -r guix}.
688
689 The binary installation tarball can be (re)produced and verified simply
690 by running the following command in the Guix source tree:
691
692 @example
693 make guix-binary.@var{system}.tar.xz
694 @end example
695
696 @noindent
697 ...@: which, in turn, runs:
698
699 @example
700 guix pack -s @var{system} --localstatedir \
701 --profile-name=current-guix guix
702 @end example
703
704 @xref{Invoking guix pack}, for more info on this handy tool.
705
706 @node Requirements
707 @section Requirements
708
709 This section lists requirements when building Guix from source. The
710 build procedure for Guix is the same as for other GNU software, and is
711 not covered here. Please see the files @file{README} and @file{INSTALL}
712 in the Guix source tree for additional details.
713
714 @cindex official website
715 GNU Guix is available for download from its website at
716 @url{https://www.gnu.org/software/guix/}.
717
718 GNU Guix depends on the following packages:
719
720 @itemize
721 @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.2.x;
722 @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
723 0.1.0 or later;
724 @item
725 @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
726 (@pxref{Guile Preparations, how to install the GnuTLS bindings for
727 Guile,, gnutls-guile, GnuTLS-Guile});
728 @item
729 @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
730 or later;
731 @item
732 @c FIXME: Specify a version number once a release has been made.
733 @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
734 2017 or later;
735 @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON};
736 @item @url{http://zlib.net, zlib};
737 @item @url{http://www.gnu.org/software/make/, GNU Make}.
738 @end itemize
739
740 The following dependencies are optional:
741
742 @itemize
743 @item
744 @c Note: We need at least 0.10.2 for 'channel-send-eof'.
745 Support for build offloading (@pxref{Daemon Offload Setup}) and
746 @command{guix copy} (@pxref{Invoking guix copy}) depends on
747 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
748 version 0.10.2 or later.
749
750 @item
751 When @url{http://www.bzip.org, libbz2} is available,
752 @command{guix-daemon} can use it to compress build logs.
753 @end itemize
754
755 Unless @code{--disable-daemon} was passed to @command{configure}, the
756 following packages are also needed:
757
758 @itemize
759 @item @url{http://gnupg.org/, GNU libgcrypt};
760 @item @url{http://sqlite.org, SQLite 3};
761 @item @url{http://gcc.gnu.org, GCC's g++}, with support for the
762 C++11 standard.
763 @end itemize
764
765 @cindex state directory
766 When configuring Guix on a system that already has a Guix installation,
767 be sure to specify the same state directory as the existing installation
768 using the @code{--localstatedir} option of the @command{configure}
769 script (@pxref{Directory Variables, @code{localstatedir},, standards,
770 GNU Coding Standards}). The @command{configure} script protects against
771 unintended misconfiguration of @var{localstatedir} so you do not
772 inadvertently corrupt your store (@pxref{The Store}).
773
774 @cindex Nix, compatibility
775 When a working installation of @url{http://nixos.org/nix/, the Nix package
776 manager} is available, you
777 can instead configure Guix with @code{--disable-daemon}. In that case,
778 Nix replaces the three dependencies above.
779
780 Guix is compatible with Nix, so it is possible to share the same store
781 between both. To do so, you must pass @command{configure} not only the
782 same @code{--with-store-dir} value, but also the same
783 @code{--localstatedir} value. The latter is essential because it
784 specifies where the database that stores metadata about the store is
785 located, among other things. The default values for Nix are
786 @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
787 Note that @code{--disable-daemon} is not required if
788 your goal is to share the store with Nix.
789
790 @node Running the Test Suite
791 @section Running the Test Suite
792
793 @cindex test suite
794 After a successful @command{configure} and @code{make} run, it is a good
795 idea to run the test suite. It can help catch issues with the setup or
796 environment, or bugs in Guix itself---and really, reporting test
797 failures is a good way to help improve the software. To run the test
798 suite, type:
799
800 @example
801 make check
802 @end example
803
804 Test cases can run in parallel: you can use the @code{-j} option of
805 GNU@tie{}make to speed things up. The first run may take a few minutes
806 on a recent machine; subsequent runs will be faster because the store
807 that is created for test purposes will already have various things in
808 cache.
809
810 It is also possible to run a subset of the tests by defining the
811 @code{TESTS} makefile variable as in this example:
812
813 @example
814 make check TESTS="tests/store.scm tests/cpio.scm"
815 @end example
816
817 By default, tests results are displayed at a file level. In order to
818 see the details of every individual test cases, it is possible to define
819 the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
820
821 @example
822 make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
823 @end example
824
825 Upon failure, please email @email{bug-guix@@gnu.org} and attach the
826 @file{test-suite.log} file. Please specify the Guix version being used
827 as well as version numbers of the dependencies (@pxref{Requirements}) in
828 your message.
829
830 Guix also comes with a whole-system test suite that tests complete
831 Guix System instances. It can only run on systems where
832 Guix is already installed, using:
833
834 @example
835 make check-system
836 @end example
837
838 @noindent
839 or, again, by defining @code{TESTS} to select a subset of tests to run:
840
841 @example
842 make check-system TESTS="basic mcron"
843 @end example
844
845 These system tests are defined in the @code{(gnu tests @dots{})}
846 modules. They work by running the operating systems under test with
847 lightweight instrumentation in a virtual machine (VM). They can be
848 computationally intensive or rather cheap, depending on whether
849 substitutes are available for their dependencies (@pxref{Substitutes}).
850 Some of them require a lot of storage space to hold VM images.
851
852 Again in case of test failures, please send @email{bug-guix@@gnu.org}
853 all the details.
854
855 @node Setting Up the Daemon
856 @section Setting Up the Daemon
857
858 @cindex daemon
859 Operations such as building a package or running the garbage collector
860 are all performed by a specialized process, the @dfn{build daemon}, on
861 behalf of clients. Only the daemon may access the store and its
862 associated database. Thus, any operation that manipulates the store
863 goes through the daemon. For instance, command-line tools such as
864 @command{guix package} and @command{guix build} communicate with the
865 daemon (@i{via} remote procedure calls) to instruct it what to do.
866
867 The following sections explain how to prepare the build daemon's
868 environment. See also @ref{Substitutes}, for information on how to allow
869 the daemon to download pre-built binaries.
870
871 @menu
872 * Build Environment Setup:: Preparing the isolated build environment.
873 * Daemon Offload Setup:: Offloading builds to remote machines.
874 * SELinux Support:: Using an SELinux policy for the daemon.
875 @end menu
876
877 @node Build Environment Setup
878 @subsection Build Environment Setup
879
880 @cindex build environment
881 In a standard multi-user setup, Guix and its daemon---the
882 @command{guix-daemon} program---are installed by the system
883 administrator; @file{/gnu/store} is owned by @code{root} and
884 @command{guix-daemon} runs as @code{root}. Unprivileged users may use
885 Guix tools to build packages or otherwise access the store, and the
886 daemon will do it on their behalf, ensuring that the store is kept in a
887 consistent state, and allowing built packages to be shared among users.
888
889 @cindex build users
890 When @command{guix-daemon} runs as @code{root}, you may not want package
891 build processes themselves to run as @code{root} too, for obvious
892 security reasons. To avoid that, a special pool of @dfn{build users}
893 should be created for use by build processes started by the daemon.
894 These build users need not have a shell and a home directory: they will
895 just be used when the daemon drops @code{root} privileges in build
896 processes. Having several such users allows the daemon to launch
897 distinct build processes under separate UIDs, which guarantees that they
898 do not interfere with each other---an essential feature since builds are
899 regarded as pure functions (@pxref{Introduction}).
900
901 On a GNU/Linux system, a build user pool may be created like this (using
902 Bash syntax and the @code{shadow} commands):
903
904 @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
905 @c for why `-G' is needed.
906 @example
907 # groupadd --system guixbuild
908 # for i in `seq -w 1 10`;
909 do
910 useradd -g guixbuild -G guixbuild \
911 -d /var/empty -s `which nologin` \
912 -c "Guix build user $i" --system \
913 guixbuilder$i;
914 done
915 @end example
916
917 @noindent
918 The number of build users determines how many build jobs may run in
919 parallel, as specified by the @option{--max-jobs} option
920 (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
921 @command{guix system vm} and related commands, you may need to add the
922 build users to the @code{kvm} group so they can access @file{/dev/kvm},
923 using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
924 (@pxref{Invoking guix system}).
925
926 The @code{guix-daemon} program may then be run as @code{root} with the
927 following command@footnote{If your machine uses the systemd init system,
928 dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
929 file in @file{/etc/systemd/system} will ensure that
930 @command{guix-daemon} is automatically started. Similarly, if your
931 machine uses the Upstart init system, drop the
932 @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
933 file in @file{/etc/init}.}:
934
935 @example
936 # guix-daemon --build-users-group=guixbuild
937 @end example
938
939 @cindex chroot
940 @noindent
941 This way, the daemon starts build processes in a chroot, under one of
942 the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
943 environment contains nothing but:
944
945 @c Keep this list in sync with libstore/build.cc! -----------------------
946 @itemize
947 @item
948 a minimal @code{/dev} directory, created mostly independently from the
949 host @code{/dev}@footnote{``Mostly'', because while the set of files
950 that appear in the chroot's @code{/dev} is fixed, most of these files
951 can only be created if the host has them.};
952
953 @item
954 the @code{/proc} directory; it only shows the processes of the container
955 since a separate PID name space is used;
956
957 @item
958 @file{/etc/passwd} with an entry for the current user and an entry for
959 user @file{nobody};
960
961 @item
962 @file{/etc/group} with an entry for the user's group;
963
964 @item
965 @file{/etc/hosts} with an entry that maps @code{localhost} to
966 @code{127.0.0.1};
967
968 @item
969 a writable @file{/tmp} directory.
970 @end itemize
971
972 You can influence the directory where the daemon stores build trees
973 @i{via} the @code{TMPDIR} environment variable. However, the build tree
974 within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
975 where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
976 This way, the value of @code{TMPDIR} does not leak inside build
977 environments, which avoids discrepancies in cases where build processes
978 capture the name of their build tree.
979
980 @vindex http_proxy
981 The daemon also honors the @code{http_proxy} environment variable for
982 HTTP downloads it performs, be it for fixed-output derivations
983 (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
984
985 If you are installing Guix as an unprivileged user, it is still possible
986 to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
987 However, build processes will not be isolated from one another, and not
988 from the rest of the system. Thus, build processes may interfere with
989 each other, and may access programs, libraries, and other files
990 available on the system---making it much harder to view them as
991 @emph{pure} functions.
992
993
994 @node Daemon Offload Setup
995 @subsection Using the Offload Facility
996
997 @cindex offloading
998 @cindex build hook
999 When desired, the build daemon can @dfn{offload} derivation builds to
1000 other machines running Guix, using the @code{offload} @dfn{build
1001 hook}@footnote{This feature is available only when
1002 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
1003 present.}. When that
1004 feature is enabled, a list of user-specified build machines is read from
1005 @file{/etc/guix/machines.scm}; every time a build is requested, for
1006 instance via @code{guix build}, the daemon attempts to offload it to one
1007 of the machines that satisfy the constraints of the derivation, in
1008 particular its system type---e.g., @file{x86_64-linux}. Missing
1009 prerequisites for the build are copied over SSH to the target machine,
1010 which then proceeds with the build; upon success the output(s) of the
1011 build are copied back to the initial machine.
1012
1013 The @file{/etc/guix/machines.scm} file typically looks like this:
1014
1015 @example
1016 (list (build-machine
1017 (name "eightysix.example.org")
1018 (system "x86_64-linux")
1019 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
1020 (user "bob")
1021 (speed 2.)) ;incredibly fast!
1022
1023 (build-machine
1024 (name "meeps.example.org")
1025 (system "mips64el-linux")
1026 (host-key "ssh-rsa AAAAB3Nza@dots{}")
1027 (user "alice")
1028 (private-key
1029 (string-append (getenv "HOME")
1030 "/.ssh/identity-for-guix"))))
1031 @end example
1032
1033 @noindent
1034 In the example above we specify a list of two build machines, one for
1035 the @code{x86_64} architecture and one for the @code{mips64el}
1036 architecture.
1037
1038 In fact, this file is---not surprisingly!---a Scheme file that is
1039 evaluated when the @code{offload} hook is started. Its return value
1040 must be a list of @code{build-machine} objects. While this example
1041 shows a fixed list of build machines, one could imagine, say, using
1042 DNS-SD to return a list of potential build machines discovered in the
1043 local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
1044 Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
1045 detailed below.
1046
1047 @deftp {Data Type} build-machine
1048 This data type represents build machines to which the daemon may offload
1049 builds. The important fields are:
1050
1051 @table @code
1052
1053 @item name
1054 The host name of the remote machine.
1055
1056 @item system
1057 The system type of the remote machine---e.g., @code{"x86_64-linux"}.
1058
1059 @item user
1060 The user account to use when connecting to the remote machine over SSH.
1061 Note that the SSH key pair must @emph{not} be passphrase-protected, to
1062 allow non-interactive logins.
1063
1064 @item host-key
1065 This must be the machine's SSH @dfn{public host key} in OpenSSH format.
1066 This is used to authenticate the machine when we connect to it. It is a
1067 long string that looks like this:
1068
1069 @example
1070 ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
1071 @end example
1072
1073 If the machine is running the OpenSSH daemon, @command{sshd}, the host
1074 key can be found in a file such as
1075 @file{/etc/ssh/ssh_host_ed25519_key.pub}.
1076
1077 If the machine is running the SSH daemon of GNU@tie{}lsh,
1078 @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
1079 similar file. It can be converted to the OpenSSH format using
1080 @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
1081
1082 @example
1083 $ lsh-export-key --openssh < /etc/lsh/host-key.pub
1084 ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
1085 @end example
1086
1087 @end table
1088
1089 A number of optional fields may be specified:
1090
1091 @table @asis
1092
1093 @item @code{port} (default: @code{22})
1094 Port number of SSH server on the machine.
1095
1096 @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
1097 The SSH private key file to use when connecting to the machine, in
1098 OpenSSH format. This key must not be protected with a passphrase.
1099
1100 Note that the default value is the private key @emph{of the root
1101 account}. Make sure it exists if you use the default.
1102
1103 @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
1104 @itemx @code{compression-level} (default: @code{3})
1105 The SSH-level compression methods and compression level requested.
1106
1107 Note that offloading relies on SSH compression to reduce bandwidth usage
1108 when transferring files to and from build machines.
1109
1110 @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
1111 File name of the Unix-domain socket @command{guix-daemon} is listening
1112 to on that machine.
1113
1114 @item @code{parallel-builds} (default: @code{1})
1115 The number of builds that may run in parallel on the machine.
1116
1117 @item @code{speed} (default: @code{1.0})
1118 A ``relative speed factor''. The offload scheduler will tend to prefer
1119 machines with a higher speed factor.
1120
1121 @item @code{features} (default: @code{'()})
1122 A list of strings denoting specific features supported by the machine.
1123 An example is @code{"kvm"} for machines that have the KVM Linux modules
1124 and corresponding hardware support. Derivations can request features by
1125 name, and they will be scheduled on matching build machines.
1126
1127 @end table
1128 @end deftp
1129
1130 The @command{guix} command must be in the search path on the build
1131 machines. You can check whether this is the case by running:
1132
1133 @example
1134 ssh build-machine guix repl --version
1135 @end example
1136
1137 There is one last thing to do once @file{machines.scm} is in place. As
1138 explained above, when offloading, files are transferred back and forth
1139 between the machine stores. For this to work, you first need to
1140 generate a key pair on each machine to allow the daemon to export signed
1141 archives of files from the store (@pxref{Invoking guix archive}):
1142
1143 @example
1144 # guix archive --generate-key
1145 @end example
1146
1147 @noindent
1148 Each build machine must authorize the key of the master machine so that
1149 it accepts store items it receives from the master:
1150
1151 @example
1152 # guix archive --authorize < master-public-key.txt
1153 @end example
1154
1155 @noindent
1156 Likewise, the master machine must authorize the key of each build machine.
1157
1158 All the fuss with keys is here to express pairwise mutual trust
1159 relations between the master and the build machines. Concretely, when
1160 the master receives files from a build machine (and @i{vice versa}), its
1161 build daemon can make sure they are genuine, have not been tampered
1162 with, and that they are signed by an authorized key.
1163
1164 @cindex offload test
1165 To test whether your setup is operational, run this command on the
1166 master node:
1167
1168 @example
1169 # guix offload test
1170 @end example
1171
1172 This will attempt to connect to each of the build machines specified in
1173 @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
1174 available on each machine, attempt to export to the machine and import
1175 from it, and report any error in the process.
1176
1177 If you want to test a different machine file, just specify it on the
1178 command line:
1179
1180 @example
1181 # guix offload test machines-qualif.scm
1182 @end example
1183
1184 Last, you can test the subset of the machines whose name matches a
1185 regular expression like this:
1186
1187 @example
1188 # guix offload test machines.scm '\.gnu\.org$'
1189 @end example
1190
1191 @cindex offload status
1192 To display the current load of all build hosts, run this command on the
1193 main node:
1194
1195 @example
1196 # guix offload status
1197 @end example
1198
1199
1200 @node SELinux Support
1201 @subsection SELinux Support
1202
1203 @cindex SELinux, daemon policy
1204 @cindex mandatory access control, SELinux
1205 @cindex security, guix-daemon
1206 Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
1207 can be installed on a system where SELinux is enabled, in order to label
1208 Guix files and to specify the expected behavior of the daemon. Since
1209 Guix System does not provide an SELinux base policy, the daemon policy cannot
1210 be used on Guix System.
1211
1212 @subsubsection Installing the SELinux policy
1213 @cindex SELinux, policy installation
1214 To install the policy run this command as root:
1215
1216 @example
1217 semodule -i etc/guix-daemon.cil
1218 @end example
1219
1220 Then relabel the file system with @code{restorecon} or by a different
1221 mechanism provided by your system.
1222
1223 Once the policy is installed, the file system has been relabeled, and
1224 the daemon has been restarted, it should be running in the
1225 @code{guix_daemon_t} context. You can confirm this with the following
1226 command:
1227
1228 @example
1229 ps -Zax | grep guix-daemon
1230 @end example
1231
1232 Monitor the SELinux log files as you run a command like @code{guix build
1233 hello} to convince yourself that SELinux permits all necessary
1234 operations.
1235
1236 @subsubsection Limitations
1237 @cindex SELinux, limitations
1238
1239 This policy is not perfect. Here is a list of limitations or quirks
1240 that should be considered when deploying the provided SELinux policy for
1241 the Guix daemon.
1242
1243 @enumerate
1244 @item
1245 @code{guix_daemon_socket_t} isn’t actually used. None of the socket
1246 operations involve contexts that have anything to do with
1247 @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
1248 but it would be preferrable to define socket rules for only this label.
1249
1250 @item
1251 @code{guix gc} cannot access arbitrary links to profiles. By design,
1252 the file label of the destination of a symlink is independent of the
1253 file label of the link itself. Although all profiles under
1254 $localstatedir are labelled, the links to these profiles inherit the
1255 label of the directory they are in. For links in the user’s home
1256 directory this will be @code{user_home_t}. But for links from the root
1257 user’s home directory, or @file{/tmp}, or the HTTP server’s working
1258 directory, etc, this won’t work. @code{guix gc} would be prevented from
1259 reading and following these links.
1260
1261 @item
1262 The daemon’s feature to listen for TCP connections might no longer work.
1263 This might require extra rules, because SELinux treats network sockets
1264 differently from files.
1265
1266 @item
1267 Currently all files with a name matching the regular expression
1268 @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
1269 label @code{guix_daemon_exec_t}; this means that @emph{any} file with
1270 that name in any profile would be permitted to run in the
1271 @code{guix_daemon_t} domain. This is not ideal. An attacker could
1272 build a package that provides this executable and convince a user to
1273 install and run it, which lifts it into the @code{guix_daemon_t} domain.
1274 At that point SELinux could not prevent it from accessing files that are
1275 allowed for processes in that domain.
1276
1277 We could generate a much more restrictive policy at installation time,
1278 so that only the @emph{exact} file name of the currently installed
1279 @code{guix-daemon} executable would be labelled with
1280 @code{guix_daemon_exec_t}, instead of using a broad regular expression.
1281 The downside is that root would have to install or upgrade the policy at
1282 installation time whenever the Guix package that provides the
1283 effectively running @code{guix-daemon} executable is upgraded.
1284 @end enumerate
1285
1286 @node Invoking guix-daemon
1287 @section Invoking @command{guix-daemon}
1288
1289 The @command{guix-daemon} program implements all the functionality to
1290 access the store. This includes launching build processes, running the
1291 garbage collector, querying the availability of a build result, etc. It
1292 is normally run as @code{root} like this:
1293
1294 @example
1295 # guix-daemon --build-users-group=guixbuild
1296 @end example
1297
1298 @noindent
1299 For details on how to set it up, @pxref{Setting Up the Daemon}.
1300
1301 @cindex chroot
1302 @cindex container, build environment
1303 @cindex build environment
1304 @cindex reproducible builds
1305 By default, @command{guix-daemon} launches build processes under
1306 different UIDs, taken from the build group specified with
1307 @code{--build-users-group}. In addition, each build process is run in a
1308 chroot environment that only contains the subset of the store that the
1309 build process depends on, as specified by its derivation
1310 (@pxref{Programming Interface, derivation}), plus a set of specific
1311 system directories. By default, the latter contains @file{/dev} and
1312 @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1313 @dfn{container}: in addition to having its own file system tree, it has
1314 a separate mount name space, its own PID name space, network name space,
1315 etc. This helps achieve reproducible builds (@pxref{Features}).
1316
1317 When the daemon performs a build on behalf of the user, it creates a
1318 build directory under @file{/tmp} or under the directory specified by
1319 its @code{TMPDIR} environment variable. This directory is shared with
1320 the container for the duration of the build, though within the container,
1321 the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
1322
1323 The build directory is automatically deleted upon completion, unless the
1324 build failed and the client specified @option{--keep-failed}
1325 (@pxref{Invoking guix build, @option{--keep-failed}}).
1326
1327 The daemon listens for connections and spawns one sub-process for each session
1328 started by a client (one of the @command{guix} sub-commands.) The
1329 @command{guix processes} command allows you to get an overview of the activity
1330 on your system by viewing each of the active sessions and clients.
1331 @xref{Invoking guix processes}, for more information.
1332
1333 The following command-line options are supported:
1334
1335 @table @code
1336 @item --build-users-group=@var{group}
1337 Take users from @var{group} to run build processes (@pxref{Setting Up
1338 the Daemon, build users}).
1339
1340 @item --no-substitutes
1341 @cindex substitutes
1342 Do not use substitutes for build products. That is, always build things
1343 locally instead of allowing downloads of pre-built binaries
1344 (@pxref{Substitutes}).
1345
1346 When the daemon runs with @code{--no-substitutes}, clients can still
1347 explicitly enable substitution @i{via} the @code{set-build-options}
1348 remote procedure call (@pxref{The Store}).
1349
1350 @item --substitute-urls=@var{urls}
1351 @anchor{daemon-substitute-urls}
1352 Consider @var{urls} the default whitespace-separated list of substitute
1353 source URLs. When this option is omitted,
1354 @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
1355
1356 This means that substitutes may be downloaded from @var{urls}, as long
1357 as they are signed by a trusted signature (@pxref{Substitutes}).
1358
1359 @cindex build hook
1360 @item --no-build-hook
1361 Do not use the @dfn{build hook}.
1362
1363 The build hook is a helper program that the daemon can start and to
1364 which it submits build requests. This mechanism is used to offload
1365 builds to other machines (@pxref{Daemon Offload Setup}).
1366
1367 @item --cache-failures
1368 Cache build failures. By default, only successful builds are cached.
1369
1370 When this option is used, @command{guix gc --list-failures} can be used
1371 to query the set of store items marked as failed; @command{guix gc
1372 --clear-failures} removes store items from the set of cached failures.
1373 @xref{Invoking guix gc}.
1374
1375 @item --cores=@var{n}
1376 @itemx -c @var{n}
1377 Use @var{n} CPU cores to build each derivation; @code{0} means as many
1378 as available.
1379
1380 The default value is @code{0}, but it may be overridden by clients, such
1381 as the @code{--cores} option of @command{guix build} (@pxref{Invoking
1382 guix build}).
1383
1384 The effect is to define the @code{NIX_BUILD_CORES} environment variable
1385 in the build process, which can then use it to exploit internal
1386 parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1387
1388 @item --max-jobs=@var{n}
1389 @itemx -M @var{n}
1390 Allow at most @var{n} build jobs in parallel. The default value is
1391 @code{1}. Setting it to @code{0} means that no builds will be performed
1392 locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1393 Setup}), or simply fail.
1394
1395 @item --max-silent-time=@var{seconds}
1396 When the build or substitution process remains silent for more than
1397 @var{seconds}, terminate it and report a build failure.
1398
1399 The default value is @code{0}, which disables the timeout.
1400
1401 The value specified here can be overridden by clients (@pxref{Common
1402 Build Options, @code{--max-silent-time}}).
1403
1404 @item --timeout=@var{seconds}
1405 Likewise, when the build or substitution process lasts for more than
1406 @var{seconds}, terminate it and report a build failure.
1407
1408 The default value is @code{0}, which disables the timeout.
1409
1410 The value specified here can be overridden by clients (@pxref{Common
1411 Build Options, @code{--timeout}}).
1412
1413 @item --rounds=@var{N}
1414 Build each derivation @var{n} times in a row, and raise an error if
1415 consecutive build results are not bit-for-bit identical. Note that this
1416 setting can be overridden by clients such as @command{guix build}
1417 (@pxref{Invoking guix build}).
1418
1419 When used in conjunction with @option{--keep-failed}, the differing
1420 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1421 This makes it easy to look for differences between the two results.
1422
1423 @item --debug
1424 Produce debugging output.
1425
1426 This is useful to debug daemon start-up issues, but then it may be
1427 overridden by clients, for example the @code{--verbosity} option of
1428 @command{guix build} (@pxref{Invoking guix build}).
1429
1430 @item --chroot-directory=@var{dir}
1431 Add @var{dir} to the build chroot.
1432
1433 Doing this may change the result of build processes---for instance if
1434 they use optional dependencies found in @var{dir} when it is available,
1435 and not otherwise. For that reason, it is not recommended to do so.
1436 Instead, make sure that each derivation declares all the inputs that it
1437 needs.
1438
1439 @item --disable-chroot
1440 Disable chroot builds.
1441
1442 Using this option is not recommended since, again, it would allow build
1443 processes to gain access to undeclared dependencies. It is necessary,
1444 though, when @command{guix-daemon} is running under an unprivileged user
1445 account.
1446
1447 @item --log-compression=@var{type}
1448 Compress build logs according to @var{type}, one of @code{gzip},
1449 @code{bzip2}, or @code{none}.
1450
1451 Unless @code{--lose-logs} is used, all the build logs are kept in the
1452 @var{localstatedir}. To save space, the daemon automatically compresses
1453 them with bzip2 by default.
1454
1455 @item --disable-deduplication
1456 @cindex deduplication
1457 Disable automatic file ``deduplication'' in the store.
1458
1459 By default, files added to the store are automatically ``deduplicated'':
1460 if a newly added file is identical to another one found in the store,
1461 the daemon makes the new file a hard link to the other file. This can
1462 noticeably reduce disk usage, at the expense of slightly increased
1463 input/output load at the end of a build process. This option disables
1464 this optimization.
1465
1466 @item --gc-keep-outputs[=yes|no]
1467 Tell whether the garbage collector (GC) must keep outputs of live
1468 derivations.
1469
1470 @cindex GC roots
1471 @cindex garbage collector roots
1472 When set to ``yes'', the GC will keep the outputs of any live derivation
1473 available in the store---the @code{.drv} files. The default is ``no'',
1474 meaning that derivation outputs are kept only if they are reachable from a GC
1475 root. @xref{Invoking guix gc}, for more on GC roots.
1476
1477 @item --gc-keep-derivations[=yes|no]
1478 Tell whether the garbage collector (GC) must keep derivations
1479 corresponding to live outputs.
1480
1481 When set to ``yes'', as is the case by default, the GC keeps
1482 derivations---i.e., @code{.drv} files---as long as at least one of their
1483 outputs is live. This allows users to keep track of the origins of
1484 items in their store. Setting it to ``no'' saves a bit of disk space.
1485
1486 In this way, setting @code{--gc-keep-derivations} to ``yes'' causes liveness
1487 to flow from outputs to derivations, and setting @code{--gc-keep-outputs} to
1488 ``yes'' causes liveness to flow from derivations to outputs. When both are
1489 set to ``yes'', the effect is to keep all the build prerequisites (the
1490 sources, compiler, libraries, and other build-time tools) of live objects in
1491 the store, regardless of whether these prerequisites are reachable from a GC
1492 root. This is convenient for developers since it saves rebuilds or downloads.
1493
1494 @item --impersonate-linux-2.6
1495 On Linux-based systems, impersonate Linux 2.6. This means that the
1496 kernel's @code{uname} system call will report 2.6 as the release number.
1497
1498 This might be helpful to build programs that (usually wrongfully) depend
1499 on the kernel version number.
1500
1501 @item --lose-logs
1502 Do not keep build logs. By default they are kept under
1503 @code{@var{localstatedir}/guix/log}.
1504
1505 @item --system=@var{system}
1506 Assume @var{system} as the current system type. By default it is the
1507 architecture/kernel pair found at configure time, such as
1508 @code{x86_64-linux}.
1509
1510 @item --listen=@var{endpoint}
1511 Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
1512 as the file name of a Unix-domain socket if it starts with
1513 @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
1514 host name or host name and port to listen to. Here are a few examples:
1515
1516 @table @code
1517 @item --listen=/gnu/var/daemon
1518 Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
1519 creating it if needed.
1520
1521 @item --listen=localhost
1522 @cindex daemon, remote access
1523 @cindex remote access to the daemon
1524 @cindex daemon, cluster setup
1525 @cindex clusters, daemon setup
1526 Listen for TCP connections on the network interface corresponding to
1527 @code{localhost}, on port 44146.
1528
1529 @item --listen=128.0.0.42:1234
1530 Listen for TCP connections on the network interface corresponding to
1531 @code{128.0.0.42}, on port 1234.
1532 @end table
1533
1534 This option can be repeated multiple times, in which case
1535 @command{guix-daemon} accepts connections on all the specified
1536 endpoints. Users can tell client commands what endpoint to connect to
1537 by setting the @code{GUIX_DAEMON_SOCKET} environment variable
1538 (@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
1539
1540 @quotation Note
1541 The daemon protocol is @emph{unauthenticated and unencrypted}. Using
1542 @code{--listen=@var{host}} is suitable on local networks, such as
1543 clusters, where only trusted nodes may connect to the build daemon. In
1544 other cases where remote access to the daemon is needed, we recommend
1545 using Unix-domain sockets along with SSH.
1546 @end quotation
1547
1548 When @code{--listen} is omitted, @command{guix-daemon} listens for
1549 connections on the Unix-domain socket located at
1550 @file{@var{localstatedir}/guix/daemon-socket/socket}.
1551 @end table
1552
1553
1554 @node Application Setup
1555 @section Application Setup
1556
1557 @cindex foreign distro
1558 When using Guix on top of GNU/Linux distribution other than Guix System---a
1559 so-called @dfn{foreign distro}---a few additional steps are needed to
1560 get everything in place. Here are some of them.
1561
1562 @subsection Locales
1563
1564 @anchor{locales-and-locpath}
1565 @cindex locales, when not on Guix System
1566 @vindex LOCPATH
1567 @vindex GUIX_LOCPATH
1568 Packages installed @i{via} Guix will not use the locale data of the
1569 host system. Instead, you must first install one of the locale packages
1570 available with Guix and then define the @code{GUIX_LOCPATH} environment
1571 variable:
1572
1573 @example
1574 $ guix package -i glibc-locales
1575 $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
1576 @end example
1577
1578 Note that the @code{glibc-locales} package contains data for all the
1579 locales supported by the GNU@tie{}libc and weighs in at around
1580 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
1581 limited to a few UTF-8 locales.
1582
1583 The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
1584 (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
1585 Manual}). There are two important differences though:
1586
1587 @enumerate
1588 @item
1589 @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
1590 provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
1591 to make sure the programs of the foreign distro will not end up loading
1592 incompatible locale data.
1593
1594 @item
1595 libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
1596 @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1597 should your Guix profile contain a mixture of programs linked against
1598 different libc version, each libc version will only try to load locale
1599 data in the right format.
1600 @end enumerate
1601
1602 This is important because the locale data format used by different libc
1603 versions may be incompatible.
1604
1605 @subsection Name Service Switch
1606
1607 @cindex name service switch, glibc
1608 @cindex NSS (name service switch), glibc
1609 @cindex nscd (name service caching daemon)
1610 @cindex name service caching daemon (nscd)
1611 When using Guix on a foreign distro, we @emph{strongly recommend} that
1612 the system run the GNU C library's @dfn{name service cache daemon},
1613 @command{nscd}, which should be listening on the
1614 @file{/var/run/nscd/socket} socket. Failing to do that, applications
1615 installed with Guix may fail to look up host names or user accounts, or
1616 may even crash. The next paragraphs explain why.
1617
1618 @cindex @file{nsswitch.conf}
1619 The GNU C library implements a @dfn{name service switch} (NSS), which is
1620 an extensible mechanism for ``name lookups'' in general: host name
1621 resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1622 The GNU C Library Reference Manual}).
1623
1624 @cindex Network information service (NIS)
1625 @cindex NIS (Network information service)
1626 Being extensible, the NSS supports @dfn{plugins}, which provide new name
1627 lookup implementations: for example, the @code{nss-mdns} plugin allow
1628 resolution of @code{.local} host names, the @code{nis} plugin allows
1629 user account lookup using the Network information service (NIS), and so
1630 on. These extra ``lookup services'' are configured system-wide in
1631 @file{/etc/nsswitch.conf}, and all the programs running on the system
1632 honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1633 Reference Manual}).
1634
1635 When they perform a name lookup---for instance by calling the
1636 @code{getaddrinfo} function in C---applications first try to connect to
1637 the nscd; on success, nscd performs name lookups on their behalf. If
1638 the nscd is not running, then they perform the name lookup by
1639 themselves, by loading the name lookup services into their own address
1640 space and running it. These name lookup services---the
1641 @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1642 the host system's C library, rather than from the C library the
1643 application is linked against (the C library coming from Guix).
1644
1645 And this is where the problem is: if your application is linked against
1646 Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1647 another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1648 likely crash or have its name lookups fail unexpectedly.
1649
1650 Running @command{nscd} on the system, among other advantages, eliminates
1651 this binary incompatibility problem because those @code{libnss_*.so}
1652 files are loaded in the @command{nscd} process, not in applications
1653 themselves.
1654
1655 @subsection X11 Fonts
1656
1657 @cindex fonts
1658 The majority of graphical applications use Fontconfig to locate and
1659 load fonts and perform X11-client-side rendering. The @code{fontconfig}
1660 package in Guix looks for fonts in @file{$HOME/.guix-profile}
1661 by default. Thus, to allow graphical applications installed with Guix
1662 to display fonts, you have to install fonts with Guix as well.
1663 Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
1664 @code{font-gnu-freefont-ttf}.
1665
1666 To display text written in Chinese languages, Japanese, or Korean in
1667 graphical applications, consider installing
1668 @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1669 has multiple outputs, one per language family (@pxref{Packages with
1670 Multiple Outputs}). For instance, the following command installs fonts
1671 for Chinese languages:
1672
1673 @example
1674 guix package -i font-adobe-source-han-sans:cn
1675 @end example
1676
1677 @cindex @code{xterm}
1678 Older programs such as @command{xterm} do not use Fontconfig and instead
1679 rely on server-side font rendering. Such programs require to specify a
1680 full name of a font using XLFD (X Logical Font Description), like this:
1681
1682 @example
1683 -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1684 @end example
1685
1686 To be able to use such full names for the TrueType fonts installed in
1687 your Guix profile, you need to extend the font path of the X server:
1688
1689 @c Note: 'xset' does not accept symlinks so the trick below arranges to
1690 @c get at the real directory. See <https://bugs.gnu.org/30655>.
1691 @example
1692 xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
1693 @end example
1694
1695 @cindex @code{xlsfonts}
1696 After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1697 to make sure your TrueType fonts are listed there.
1698
1699 @cindex @code{fc-cache}
1700 @cindex font cache
1701 After installing fonts you may have to refresh the font cache to use
1702 them in applications. The same applies when applications installed via
1703 Guix do not seem to find fonts. To force rebuilding of the font cache
1704 run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
1705 @code{fontconfig} package.
1706
1707 @subsection X.509 Certificates
1708
1709 @cindex @code{nss-certs}
1710 The @code{nss-certs} package provides X.509 certificates, which allow
1711 programs to authenticate Web servers accessed over HTTPS.
1712
1713 When using Guix on a foreign distro, you can install this package and
1714 define the relevant environment variables so that packages know where to
1715 look for certificates. @xref{X.509 Certificates}, for detailed
1716 information.
1717
1718 @subsection Emacs Packages
1719
1720 @cindex @code{emacs}
1721 When you install Emacs packages with Guix, the elisp files may be placed
1722 either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
1723 sub-directories of
1724 @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
1725 directory exists because potentially there may exist thousands of Emacs
1726 packages and storing all their files in a single directory may not be
1727 reliable (because of name conflicts). So we think using a separate
1728 directory for each package is a good idea. It is very similar to how
1729 the Emacs package system organizes the file structure (@pxref{Package
1730 Files,,, emacs, The GNU Emacs Manual}).
1731
1732 By default, Emacs (installed with Guix) ``knows'' where these packages
1733 are placed, so you do not need to perform any configuration. If, for
1734 some reason, you want to avoid auto-loading Emacs packages installed
1735 with Guix, you can do so by running Emacs with @code{--no-site-file}
1736 option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1737
1738 @subsection The GCC toolchain
1739
1740 @cindex GCC
1741 @cindex ld-wrapper
1742
1743 Guix offers individual compiler packages such as @code{gcc} but if you
1744 are in need of a complete toolchain for compiling and linking source
1745 code what you really want is the @code{gcc-toolchain} package. This
1746 package provides a complete GCC toolchain for C/C++ development,
1747 including GCC itself, the GNU C Library (headers and binaries, plus
1748 debugging symbols in the @code{debug} output), Binutils, and a linker
1749 wrapper.
1750
1751 The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
1752 passed to the linker, add corresponding @code{-rpath} arguments, and
1753 invoke the actual linker with this new set of arguments. You can instruct the
1754 wrapper to refuse to link against libraries not in the store by setting the
1755 @code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
1756
1757 @c TODO What else?
1758
1759 @c *********************************************************************
1760 @node System Installation
1761 @chapter System Installation
1762
1763 @cindex installing Guix System
1764 @cindex Guix System, installation
1765 This section explains how to install Guix System
1766 on a machine. Guix, as a package manager, can
1767 also be installed on top of a running GNU/Linux system,
1768 @pxref{Installation}.
1769
1770 @ifinfo
1771 @quotation Note
1772 @c This paragraph is for people reading this from tty2 of the
1773 @c installation image.
1774 You are reading this documentation with an Info reader. For details on
1775 how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
1776 link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
1777 Info}. Hit @kbd{l} afterwards to come back here.
1778
1779 Alternately, run @command{info info} in another tty to keep the manual
1780 available.
1781 @end quotation
1782 @end ifinfo
1783
1784 @menu
1785 * Limitations:: What you can expect.
1786 * Hardware Considerations:: Supported hardware.
1787 * USB Stick and DVD Installation:: Preparing the installation medium.
1788 * Preparing for Installation:: Networking, partitioning, etc.
1789 * Guided Graphical Installation:: Easy graphical installation.
1790 * Manual Installation:: Manual installation for wizards.
1791 * After System Installation:: When installation succeeded.
1792 * Installing Guix in a VM:: Guix System playground.
1793 * Building the Installation Image:: How this comes to be.
1794 @end menu
1795
1796 @node Limitations
1797 @section Limitations
1798
1799 We consider Guix System to be ready for a wide range of ``desktop'' and server
1800 use cases. The reliability guarantees it provides---transactional upgrades
1801 and rollbacks, reproducibility---make it a solid foundation.
1802
1803 Nevertheless, before you proceed with the installation, be aware of the
1804 following noteworthy limitations applicable to version @value{VERSION}:
1805
1806 @itemize
1807 @item
1808 Support for the Logical Volume Manager (LVM) is missing.
1809
1810 @item
1811 More and more system services are provided (@pxref{Services}), but some
1812 may be missing.
1813
1814 @item
1815 GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
1816 as well as a number of X11 window managers. However, KDE is currently
1817 missing.
1818 @end itemize
1819
1820 More than a disclaimer, this is an invitation to report issues (and success
1821 stories!), and to join us in improving it. @xref{Contributing}, for more
1822 info.
1823
1824
1825 @node Hardware Considerations
1826 @section Hardware Considerations
1827
1828 @cindex hardware support on Guix System
1829 GNU@tie{}Guix focuses on respecting the user's computing freedom. It
1830 builds around the kernel Linux-libre, which means that only hardware for
1831 which free software drivers and firmware exist is supported. Nowadays,
1832 a wide range of off-the-shelf hardware is supported on
1833 GNU/Linux-libre---from keyboards to graphics cards to scanners and
1834 Ethernet controllers. Unfortunately, there are still areas where
1835 hardware vendors deny users control over their own computing, and such
1836 hardware is not supported on Guix System.
1837
1838 @cindex WiFi, hardware support
1839 One of the main areas where free drivers or firmware are lacking is WiFi
1840 devices. WiFi devices known to work include those using Atheros chips
1841 (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
1842 driver, and those using Broadcom/AirForce chips (BCM43xx with
1843 Wireless-Core Revision 5), which corresponds to the @code{b43-open}
1844 Linux-libre driver. Free firmware exists for both and is available
1845 out-of-the-box on Guix System, as part of @code{%base-firmware}
1846 (@pxref{operating-system Reference, @code{firmware}}).
1847
1848 @cindex RYF, Respects Your Freedom
1849 The @uref{https://www.fsf.org/, Free Software Foundation} runs
1850 @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
1851 certification program for hardware products that respect your freedom
1852 and your privacy and ensure that you have control over your device. We
1853 encourage you to check the list of RYF-certified devices.
1854
1855 Another useful resource is the @uref{https://www.h-node.org/, H-Node}
1856 web site. It contains a catalog of hardware devices with information
1857 about their support in GNU/Linux.
1858
1859
1860 @node USB Stick and DVD Installation
1861 @section USB Stick and DVD Installation
1862
1863 An ISO-9660 installation image that can be written to a USB stick or
1864 burnt to a DVD can be downloaded from
1865 @indicateurl{https://alpha.gnu.org/gnu/guix/guix-system-install-@value{VERSION}.@var{system}.iso.xz},
1866 where @var{system} is one of:
1867
1868 @table @code
1869 @item x86_64-linux
1870 for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
1871
1872 @item i686-linux
1873 for a 32-bit GNU/Linux system on Intel-compatible CPUs.
1874 @end table
1875
1876 @c start duplication of authentication part from ``Binary Installation''
1877 Make sure to download the associated @file{.sig} file and to verify the
1878 authenticity of the image against it, along these lines:
1879
1880 @example
1881 $ wget https://alpha.gnu.org/gnu/guix/guix-system-install-@value{VERSION}.@var{system}.iso.xz.sig
1882 $ gpg --verify guix-system-install-@value{VERSION}.@var{system}.iso.xz.sig
1883 @end example
1884
1885 If that command fails because you do not have the required public key,
1886 then run this command to import it:
1887
1888 @example
1889 $ gpg --keyserver @value{KEY-SERVER} \
1890 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
1891 @end example
1892
1893 @noindent
1894 and rerun the @code{gpg --verify} command.
1895 @c end duplication
1896
1897 This image contains the tools necessary for an installation.
1898 It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
1899
1900 @unnumberedsubsec Copying to a USB Stick
1901
1902 To copy the image to a USB stick, follow these steps:
1903
1904 @enumerate
1905 @item
1906 Decompress the image using the @command{xz} command:
1907
1908 @example
1909 xz -d guix-system-install-@value{VERSION}.@var{system}.iso.xz
1910 @end example
1911
1912 @item
1913 Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
1914 its device name. Assuming that the USB stick is known as @file{/dev/sdX},
1915 copy the image with:
1916
1917 @example
1918 dd if=guix-system-install-@value{VERSION}.@var{system}.iso of=/dev/sdX
1919 sync
1920 @end example
1921
1922 Access to @file{/dev/sdX} usually requires root privileges.
1923 @end enumerate
1924
1925 @unnumberedsubsec Burning on a DVD
1926
1927 To copy the image to a DVD, follow these steps:
1928
1929 @enumerate
1930 @item
1931 Decompress the image using the @command{xz} command:
1932
1933 @example
1934 xz -d guix-system-install-@value{VERSION}.@var{system}.iso.xz
1935 @end example
1936
1937 @item
1938 Insert a blank DVD into your machine, and determine
1939 its device name. Assuming that the DVD drive is known as @file{/dev/srX},
1940 copy the image with:
1941
1942 @example
1943 growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.@var{system}.iso
1944 @end example
1945
1946 Access to @file{/dev/srX} usually requires root privileges.
1947 @end enumerate
1948
1949 @unnumberedsubsec Booting
1950
1951 Once this is done, you should be able to reboot the system and boot from
1952 the USB stick or DVD. The latter usually requires you to get in the
1953 BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
1954
1955 @xref{Installing Guix in a VM}, if, instead, you would like to install
1956 Guix System in a virtual machine (VM).
1957
1958
1959 @node Preparing for Installation
1960 @section Preparing for Installation
1961
1962 Once you have booted, you can use the guided graphical installer, which makes
1963 it easy to get started (@pxref{Guided Graphical Installation}). Alternately,
1964 if you are already familiar with GNU/Linux and if you want more control than
1965 what the graphical installer provides, you can choose the ``manual''
1966 installation process (@pxref{Manual Installation}).
1967
1968 The graphical installer is available on TTY1. You can obtain root shells on
1969 TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
1970 this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
1971 is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
1972 Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
1973 which allows you to select text with the left mouse button and to paste it
1974 with the middle button.
1975
1976 @quotation Note
1977 Installation requires access to the Internet so that any missing
1978 dependencies of your system configuration can be downloaded. See the
1979 ``Networking'' section below.
1980 @end quotation
1981
1982 @node Guided Graphical Installation
1983 @section Guided Graphical Installation
1984
1985 The graphical installer is a text-based user interface. It will guide you,
1986 with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
1987
1988 The first dialog boxes allow you to set up the system as you use it during the
1989 installation: you can choose the language, keyboard layout, and set up
1990 networking, which will be used during the installation. The image below shows
1991 the networking dialog.
1992
1993 @image{images/installer-network,5in,, networking setup with the graphical installer}
1994
1995 Later steps allow you to partition your hard disk, as shown in the image
1996 below, to choose whether or not to use encrypted file systems, to enter the
1997 host name and root password, and to create an additional account, among other
1998 things.
1999
2000 @image{images/installer-partitions,5in,, partitioning with the graphical installer}
2001
2002 Note that, at any time, the installer allows you to exit the current
2003 installation step and resume at a previous step, as show in the image below.
2004
2005 @image{images/installer-resume,5in,, resuming the installation process}
2006
2007 Once you're done, the installer produces an operating system configuration and
2008 displays it (@pxref{Using the Configuration System}). At that point you can
2009 hit ``OK'' and installation will proceed. On success, you can reboot into the
2010 new system and enjoy. @xref{After System Installation}, for what's next!
2011
2012
2013 @node Manual Installation
2014 @section Manual Installation
2015
2016 This section describes how you would ``manually'' install GNU@tie{}Guix System
2017 on your machine. This option requires familiarity with GNU/Linux, with the
2018 shell, and with common administration tools. If you think this is not for
2019 you, consider using the guided graphical installer (@pxref{Guided Graphical
2020 Installation}).
2021
2022 The installation system provides root shells on TTYs 3 to 6; press
2023 @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
2024 many common tools needed to install the system. But it is also a full-blown
2025 Guix System, which means that you can install additional packages, should you
2026 need it, using @command{guix package} (@pxref{Invoking guix package}).
2027
2028 @menu
2029 * Keyboard Layout and Networking and Partitioning:: Initial setup.
2030 * Proceeding with the Installation:: Installing.
2031 @end menu
2032
2033 @node Keyboard Layout and Networking and Partitioning
2034 @subsection Keyboard Layout, Networking, and Partitioning
2035
2036 Before you can install the system, you may want to adjust the keyboard layout,
2037 set up networking, and partition your target hard disk. This section will
2038 guide you through this.
2039
2040 @subsubsection Keyboard Layout
2041
2042 @cindex keyboard layout
2043 The installation image uses the US qwerty keyboard layout. If you want
2044 to change it, you can use the @command{loadkeys} command. For example,
2045 the following command selects the Dvorak keyboard layout:
2046
2047 @example
2048 loadkeys dvorak
2049 @end example
2050
2051 See the files under @file{/run/current-system/profile/share/keymaps} for
2052 a list of available keyboard layouts. Run @command{man loadkeys} for
2053 more information.
2054
2055 @subsubsection Networking
2056
2057 Run the following command to see what your network interfaces are called:
2058
2059 @example
2060 ifconfig -a
2061 @end example
2062
2063 @noindent
2064 @dots{} or, using the GNU/Linux-specific @command{ip} command:
2065
2066 @example
2067 ip a
2068 @end example
2069
2070 @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
2071 Wired interfaces have a name starting with @samp{e}; for example, the
2072 interface corresponding to the first on-board Ethernet controller is
2073 called @samp{eno1}. Wireless interfaces have a name starting with
2074 @samp{w}, like @samp{w1p2s0}.
2075
2076 @table @asis
2077 @item Wired connection
2078 To configure a wired network run the following command, substituting
2079 @var{interface} with the name of the wired interface you want to use.
2080
2081 @example
2082 ifconfig @var{interface} up
2083 @end example
2084
2085 @item Wireless connection
2086 @cindex wireless
2087 @cindex WiFi
2088 To configure wireless networking, you can create a configuration file
2089 for the @command{wpa_supplicant} configuration tool (its location is not
2090 important) using one of the available text editors such as
2091 @command{nano}:
2092
2093 @example
2094 nano wpa_supplicant.conf
2095 @end example
2096
2097 As an example, the following stanza can go to this file and will work
2098 for many wireless networks, provided you give the actual SSID and
2099 passphrase for the network you are connecting to:
2100
2101 @example
2102 network=@{
2103 ssid="@var{my-ssid}"
2104 key_mgmt=WPA-PSK
2105 psk="the network's secret passphrase"
2106 @}
2107 @end example
2108
2109 Start the wireless service and run it in the background with the
2110 following command (substitute @var{interface} with the name of the
2111 network interface you want to use):
2112
2113 @example
2114 wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
2115 @end example
2116
2117 Run @command{man wpa_supplicant} for more information.
2118 @end table
2119
2120 @cindex DHCP
2121 At this point, you need to acquire an IP address. On a network where IP
2122 addresses are automatically assigned @i{via} DHCP, you can run:
2123
2124 @example
2125 dhclient -v @var{interface}
2126 @end example
2127
2128 Try to ping a server to see if networking is up and running:
2129
2130 @example
2131 ping -c 3 gnu.org
2132 @end example
2133
2134 Setting up network access is almost always a requirement because the
2135 image does not contain all the software and tools that may be needed.
2136
2137 @cindex installing over SSH
2138 If you want to, you can continue the installation remotely by starting
2139 an SSH server:
2140
2141 @example
2142 herd start ssh-daemon
2143 @end example
2144
2145 Make sure to either set a password with @command{passwd}, or configure
2146 OpenSSH public key authentication before logging in.
2147
2148 @subsubsection Disk Partitioning
2149
2150 Unless this has already been done, the next step is to partition, and
2151 then format the target partition(s).
2152
2153 The installation image includes several partitioning tools, including
2154 Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
2155 @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
2156 the partition layout you want:
2157
2158 @example
2159 cfdisk
2160 @end example
2161
2162 If your disk uses the GUID Partition Table (GPT) format and you plan to
2163 install BIOS-based GRUB (which is the default), make sure a BIOS Boot
2164 Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
2165 manual}).
2166
2167 @cindex EFI, installation
2168 @cindex UEFI, installation
2169 @cindex ESP, EFI system partition
2170 If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
2171 (ESP) is required. This partition can be mounted at @file{/boot/efi} for
2172 instance and must have the @code{esp} flag set. E.g., for @command{parted}:
2173
2174 @example
2175 parted /dev/sda set 1 esp on
2176 @end example
2177
2178 @quotation Note
2179 @vindex grub-bootloader
2180 @vindex grub-efi-bootloader
2181 Unsure whether to use EFI- or BIOS-based GRUB? If the directory
2182 @file{/sys/firmware/efi} exists in the installation image, then you should
2183 probably perform an EFI installation, using @code{grub-efi-bootloader}.
2184 Otherwise you should use the BIOS-based GRUB, known as
2185 @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
2186 bootloaders.
2187 @end quotation
2188
2189 Once you are done partitioning the target hard disk drive, you have to
2190 create a file system on the relevant partition(s)@footnote{Currently
2191 Guix System only supports ext4 and btrfs file systems. In particular, code
2192 that reads file system UUIDs and labels only works for these file system
2193 types.}. For the ESP, if you have one and assuming it is
2194 @file{/dev/sda1}, run:
2195
2196 @example
2197 mkfs.fat -F32 /dev/sda1
2198 @end example
2199
2200 Preferably, assign file systems a label so that you can easily and
2201 reliably refer to them in @code{file-system} declarations (@pxref{File
2202 Systems}). This is typically done using the @code{-L} option of
2203 @command{mkfs.ext4} and related commands. So, assuming the target root
2204 partition lives at @file{/dev/sda2}, a file system with the label
2205 @code{my-root} can be created with:
2206
2207 @example
2208 mkfs.ext4 -L my-root /dev/sda2
2209 @end example
2210
2211 @cindex encrypted disk
2212 If you are instead planning to encrypt the root partition, you can use
2213 the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
2214 @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
2215 @code{man cryptsetup}} for more information.) Assuming you want to
2216 store the root partition on @file{/dev/sda2}, the command sequence would
2217 be along these lines:
2218
2219 @example
2220 cryptsetup luksFormat /dev/sda2
2221 cryptsetup open --type luks /dev/sda2 my-partition
2222 mkfs.ext4 -L my-root /dev/mapper/my-partition
2223 @end example
2224
2225 Once that is done, mount the target file system under @file{/mnt}
2226 with a command like (again, assuming @code{my-root} is the label of the
2227 root file system):
2228
2229 @example
2230 mount LABEL=my-root /mnt
2231 @end example
2232
2233 Also mount any other file systems you would like to use on the target
2234 system relative to this path. If you have opted for @file{/boot/efi} as an
2235 EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
2236 found by @code{guix system init} afterwards.
2237
2238 Finally, if you plan to use one or more swap partitions (@pxref{Memory
2239 Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
2240 sure to initialize them with @command{mkswap}. Assuming you have one
2241 swap partition on @file{/dev/sda3}, you would run:
2242
2243 @example
2244 mkswap /dev/sda3
2245 swapon /dev/sda3
2246 @end example
2247
2248 Alternatively, you may use a swap file. For example, assuming that in
2249 the new system you want to use the file @file{/swapfile} as a swap file,
2250 you would run@footnote{This example will work for many types of file
2251 systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
2252 btrfs), the required steps may be different. For details, see the
2253 manual pages for @command{mkswap} and @command{swapon}.}:
2254
2255 @example
2256 # This is 10 GiB of swap space. Adjust "count" to change the size.
2257 dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
2258 # For security, make the file readable and writable only by root.
2259 chmod 600 /mnt/swapfile
2260 mkswap /mnt/swapfile
2261 swapon /mnt/swapfile
2262 @end example
2263
2264 Note that if you have encrypted the root partition and created a swap
2265 file in its file system as described above, then the encryption also
2266 protects the swap file, just like any other file in that file system.
2267
2268 @node Proceeding with the Installation
2269 @subsection Proceeding with the Installation
2270
2271 With the target partitions ready and the target root mounted on
2272 @file{/mnt}, we're ready to go. First, run:
2273
2274 @example
2275 herd start cow-store /mnt
2276 @end example
2277
2278 This makes @file{/gnu/store} copy-on-write, such that packages added to it
2279 during the installation phase are written to the target disk on @file{/mnt}
2280 rather than kept in memory. This is necessary because the first phase of
2281 the @command{guix system init} command (see below) entails downloads or
2282 builds to @file{/gnu/store} which, initially, is an in-memory file system.
2283
2284 Next, you have to edit a file and
2285 provide the declaration of the operating system to be installed. To
2286 that end, the installation system comes with three text editors. We
2287 recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
2288 supports syntax highlighting and parentheses matching; other editors
2289 include GNU Zile (an Emacs clone), and
2290 nvi (a clone of the original BSD @command{vi} editor).
2291 We strongly recommend storing that file on the target root file system, say,
2292 as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
2293 configuration file once you have rebooted into the newly-installed system.
2294
2295 @xref{Using the Configuration System}, for an overview of the
2296 configuration file. The example configurations discussed in that
2297 section are available under @file{/etc/configuration} in the
2298 installation image. Thus, to get started with a system configuration
2299 providing a graphical display server (a ``desktop'' system), you can run
2300 something along these lines:
2301
2302 @example
2303 # mkdir /mnt/etc
2304 # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
2305 # nano /mnt/etc/config.scm
2306 @end example
2307
2308 You should pay attention to what your configuration file contains, and
2309 in particular:
2310
2311 @itemize
2312 @item
2313 Make sure the @code{bootloader-configuration} form refers to the target
2314 you want to install GRUB on. It should mention @code{grub-bootloader} if
2315 you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
2316 for newer UEFI systems. For legacy systems, the @code{target} field
2317 names a device, like @code{/dev/sda}; for UEFI systems it names a path
2318 to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
2319 currently mounted and a @code{file-system} entry is specified in your
2320 configuration.
2321
2322 @item
2323 Be sure that your file system labels match the value of their respective
2324 @code{device} fields in your @code{file-system} configuration, assuming
2325 your @code{file-system} configuration uses the @code{file-system-label}
2326 procedure in its @code{device} field.
2327
2328 @item
2329 If there are encrypted or RAID partitions, make sure to add a
2330 @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
2331 @end itemize
2332
2333 Once you are done preparing the configuration file, the new system must
2334 be initialized (remember that the target root file system is mounted
2335 under @file{/mnt}):
2336
2337 @example
2338 guix system init /mnt/etc/config.scm /mnt
2339 @end example
2340
2341 @noindent
2342 This copies all the necessary files and installs GRUB on
2343 @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
2344 more information, @pxref{Invoking guix system}. This command may trigger
2345 downloads or builds of missing packages, which can take some time.
2346
2347 Once that command has completed---and hopefully succeeded!---you can run
2348 @command{reboot} and boot into the new system. The @code{root} password
2349 in the new system is initially empty; other users' passwords need to be
2350 initialized by running the @command{passwd} command as @code{root},
2351 unless your configuration specifies otherwise
2352 (@pxref{user-account-password, user account passwords}).
2353 @xref{After System Installation}, for what's next!
2354
2355
2356 @node After System Installation
2357 @section After System Installation
2358
2359 Success, you've now booted into Guix System! From then on, you can update the
2360 system whenever you want by running, say:
2361
2362 @example
2363 guix pull
2364 sudo guix system reconfigure /etc/config.scm
2365 @end example
2366
2367 @noindent
2368 This builds a new system generation with the latest packages and services
2369 (@pxref{Invoking guix system}). We recommend doing that regularly so that
2370 your system includes the latest security updates (@pxref{Security Updates}).
2371
2372 @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
2373 @quotation Note
2374 @cindex sudo vs. @command{guix pull}
2375 Note that @command{sudo guix} runs your user's @command{guix} command and
2376 @emph{not} root's, because @command{sudo} leaves @code{PATH} unchanged. To
2377 explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
2378 @end quotation
2379
2380 Join us on @code{#guix} on the Freenode IRC network or on
2381 @email{guix-devel@@gnu.org} to share your experience!
2382
2383
2384 @node Installing Guix in a VM
2385 @section Installing Guix in a Virtual Machine
2386
2387 @cindex virtual machine, Guix System installation
2388 @cindex virtual private server (VPS)
2389 @cindex VPS (virtual private server)
2390 If you'd like to install Guix System in a virtual machine (VM) or on a
2391 virtual private server (VPS) rather than on your beloved machine, this
2392 section is for you.
2393
2394 To boot a @uref{http://qemu.org/,QEMU} VM for installing Guix System in a
2395 disk image, follow these steps:
2396
2397 @enumerate
2398 @item
2399 First, retrieve and decompress the Guix system installation image as
2400 described previously (@pxref{USB Stick and DVD Installation}).
2401
2402 @item
2403 Create a disk image that will hold the installed system. To make a
2404 qcow2-formatted disk image, use the @command{qemu-img} command:
2405
2406 @example
2407 qemu-img create -f qcow2 guixsd.img 50G
2408 @end example
2409
2410 The resulting file will be much smaller than 50 GB (typically less than
2411 1 MB), but it will grow as the virtualized storage device is filled up.
2412
2413 @item
2414 Boot the USB installation image in an VM:
2415
2416 @example
2417 qemu-system-x86_64 -m 1024 -smp 1 \
2418 -net user -net nic,model=virtio -boot menu=on \
2419 -drive file=guix-system-install-@value{VERSION}.@var{system}.iso \
2420 -drive file=guixsd.img
2421 @end example
2422
2423 The ordering of the drives matters.
2424
2425 In the VM console, quickly press the @kbd{F12} key to enter the boot
2426 menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
2427 selection.
2428
2429 @item
2430 You're now root in the VM, proceed with the installation process.
2431 @xref{Preparing for Installation}, and follow the instructions.
2432 @end enumerate
2433
2434 Once installation is complete, you can boot the system that's on your
2435 @file{guixsd.img} image. @xref{Running Guix in a VM}, for how to do
2436 that.
2437
2438 @node Building the Installation Image
2439 @section Building the Installation Image
2440
2441 @cindex installation image
2442 The installation image described above was built using the @command{guix
2443 system} command, specifically:
2444
2445 @example
2446 guix system disk-image --file-system-type=iso9660 \
2447 gnu/system/install.scm
2448 @end example
2449
2450 Have a look at @file{gnu/system/install.scm} in the source tree,
2451 and see also @ref{Invoking guix system} for more information
2452 about the installation image.
2453
2454 @section Building the Installation Image for ARM Boards
2455
2456 Many ARM boards require a specific variant of the
2457 @uref{http://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
2458
2459 If you build a disk image and the bootloader is not available otherwise
2460 (on another boot drive etc), it's advisable to build an image that
2461 includes the bootloader, specifically:
2462
2463 @example
2464 guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
2465 @end example
2466
2467 @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
2468 board, a list of possible boards will be printed.
2469
2470 @c *********************************************************************
2471 @node Package Management
2472 @chapter Package Management
2473
2474 @cindex packages
2475 The purpose of GNU Guix is to allow users to easily install, upgrade, and
2476 remove software packages, without having to know about their build
2477 procedures or dependencies. Guix also goes beyond this obvious set of
2478 features.
2479
2480 This chapter describes the main features of Guix, as well as the
2481 package management tools it provides. Along with the command-line
2482 interface described below (@pxref{Invoking guix package, @code{guix
2483 package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
2484 emacs-guix, The Emacs-Guix Reference Manual}), after installing
2485 @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
2486 with it):
2487
2488 @example
2489 guix package -i emacs-guix
2490 @end example
2491
2492 @menu
2493 * Features:: How Guix will make your life brighter.
2494 * Invoking guix package:: Package installation, removal, etc.
2495 * Substitutes:: Downloading pre-built binaries.
2496 * Packages with Multiple Outputs:: Single source package, multiple outputs.
2497 * Invoking guix gc:: Running the garbage collector.
2498 * Invoking guix pull:: Fetching the latest Guix and distribution.
2499 * Channels:: Customizing the package collection.
2500 * Inferiors:: Interacting with another revision of Guix.
2501 * Invoking guix describe:: Display information about your Guix revision.
2502 * Invoking guix archive:: Exporting and importing store files.
2503 @end menu
2504
2505 @node Features
2506 @section Features
2507
2508 When using Guix, each package ends up in the @dfn{package store}, in its
2509 own directory---something that resembles
2510 @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
2511
2512 Instead of referring to these directories, users have their own
2513 @dfn{profile}, which points to the packages that they actually want to
2514 use. These profiles are stored within each user's home directory, at
2515 @code{$HOME/.guix-profile}.
2516
2517 For example, @code{alice} installs GCC 4.7.2. As a result,
2518 @file{/home/alice/.guix-profile/bin/gcc} points to
2519 @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
2520 @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
2521 simply continues to point to
2522 @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
2523 coexist on the same system without any interference.
2524
2525 The @command{guix package} command is the central tool to manage
2526 packages (@pxref{Invoking guix package}). It operates on the per-user
2527 profiles, and can be used @emph{with normal user privileges}.
2528
2529 @cindex transactions
2530 The command provides the obvious install, remove, and upgrade
2531 operations. Each invocation is actually a @emph{transaction}: either
2532 the specified operation succeeds, or nothing happens. Thus, if the
2533 @command{guix package} process is terminated during the transaction,
2534 or if a power outage occurs during the transaction, then the user's
2535 profile remains in its previous state, and remains usable.
2536
2537 In addition, any package transaction may be @emph{rolled back}. So, if,
2538 for example, an upgrade installs a new version of a package that turns
2539 out to have a serious bug, users may roll back to the previous instance
2540 of their profile, which was known to work well. Similarly, the global
2541 system configuration on Guix is subject to
2542 transactional upgrades and roll-back
2543 (@pxref{Using the Configuration System}).
2544
2545 All packages in the package store may be @emph{garbage-collected}.
2546 Guix can determine which packages are still referenced by user
2547 profiles, and remove those that are provably no longer referenced
2548 (@pxref{Invoking guix gc}). Users may also explicitly remove old
2549 generations of their profile so that the packages they refer to can be
2550 collected.
2551
2552 @cindex reproducibility
2553 @cindex reproducible builds
2554 Guix takes a @dfn{purely functional} approach to package
2555 management, as described in the introduction (@pxref{Introduction}).
2556 Each @file{/gnu/store} package directory name contains a hash of all the
2557 inputs that were used to build that package---compiler, libraries, build
2558 scripts, etc. This direct correspondence allows users to make sure a
2559 given package installation matches the current state of their
2560 distribution. It also helps maximize @dfn{build reproducibility}:
2561 thanks to the isolated build environments that are used, a given build
2562 is likely to yield bit-identical files when performed on different
2563 machines (@pxref{Invoking guix-daemon, container}).
2564
2565 @cindex substitutes
2566 This foundation allows Guix to support @dfn{transparent binary/source
2567 deployment}. When a pre-built binary for a @file{/gnu/store} item is
2568 available from an external source---a @dfn{substitute}, Guix just
2569 downloads it and unpacks it;
2570 otherwise, it builds the package from source, locally
2571 (@pxref{Substitutes}). Because build results are usually bit-for-bit
2572 reproducible, users do not have to trust servers that provide
2573 substitutes: they can force a local build and @emph{challenge} providers
2574 (@pxref{Invoking guix challenge}).
2575
2576 Control over the build environment is a feature that is also useful for
2577 developers. The @command{guix environment} command allows developers of
2578 a package to quickly set up the right development environment for their
2579 package, without having to manually install the dependencies of the
2580 package into their profile (@pxref{Invoking guix environment}).
2581
2582 @cindex replication, of software environments
2583 @cindex provenance tracking, of software artifacts
2584 All of Guix and its package definitions is version-controlled, and
2585 @command{guix pull} allows you to ``travel in time'' on the history of Guix
2586 itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
2587 Guix instance on a different machine or at a later point in time, which in
2588 turn allows you to @emph{replicate complete software environments}, while
2589 retaining precise @dfn{provenance tracking} of the software.
2590
2591 @node Invoking guix package
2592 @section Invoking @command{guix package}
2593
2594 @cindex installing packages
2595 @cindex removing packages
2596 @cindex package installation
2597 @cindex package removal
2598 The @command{guix package} command is the tool that allows users to
2599 install, upgrade, and remove packages, as well as rolling back to
2600 previous configurations. It operates only on the user's own profile,
2601 and works with normal user privileges (@pxref{Features}). Its syntax
2602 is:
2603
2604 @example
2605 guix package @var{options}
2606 @end example
2607 @cindex transactions
2608 Primarily, @var{options} specifies the operations to be performed during
2609 the transaction. Upon completion, a new profile is created, but
2610 previous @dfn{generations} of the profile remain available, should the user
2611 want to roll back.
2612
2613 For example, to remove @code{lua} and install @code{guile} and
2614 @code{guile-cairo} in a single transaction:
2615
2616 @example
2617 guix package -r lua -i guile guile-cairo
2618 @end example
2619
2620 @command{guix package} also supports a @dfn{declarative approach}
2621 whereby the user specifies the exact set of packages to be available and
2622 passes it @i{via} the @option{--manifest} option
2623 (@pxref{profile-manifest, @option{--manifest}}).
2624
2625 @cindex profile
2626 For each user, a symlink to the user's default profile is automatically
2627 created in @file{$HOME/.guix-profile}. This symlink always points to the
2628 current generation of the user's default profile. Thus, users can add
2629 @file{$HOME/.guix-profile/bin} to their @code{PATH} environment
2630 variable, and so on.
2631 @cindex search paths
2632 If you are not using the Guix System Distribution, consider adding the
2633 following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
2634 Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
2635 shells get all the right environment variable definitions:
2636
2637 @example
2638 GUIX_PROFILE="$HOME/.guix-profile" ; \
2639 source "$HOME/.guix-profile/etc/profile"
2640 @end example
2641
2642 In a multi-user setup, user profiles are stored in a place registered as
2643 a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
2644 to (@pxref{Invoking guix gc}). That directory is normally
2645 @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
2646 @var{localstatedir} is the value passed to @code{configure} as
2647 @code{--localstatedir}, and @var{user} is the user name. The
2648 @file{per-user} directory is created when @command{guix-daemon} is
2649 started, and the @var{user} sub-directory is created by @command{guix
2650 package}.
2651
2652 The @var{options} can be among the following:
2653
2654 @table @code
2655
2656 @item --install=@var{package} @dots{}
2657 @itemx -i @var{package} @dots{}
2658 Install the specified @var{package}s.
2659
2660 Each @var{package} may specify either a simple package name, such as
2661 @code{guile}, or a package name followed by an at-sign and version number,
2662 such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
2663 case, the newest version prefixed by @code{1.8} is selected.)
2664
2665 If no version number is specified, the
2666 newest available version will be selected. In addition, @var{package}
2667 may contain a colon, followed by the name of one of the outputs of the
2668 package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
2669 (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
2670 name (and optionally version) are searched for among the GNU
2671 distribution modules (@pxref{Package Modules}).
2672
2673 @cindex propagated inputs
2674 Sometimes packages have @dfn{propagated inputs}: these are dependencies
2675 that automatically get installed along with the required package
2676 (@pxref{package-propagated-inputs, @code{propagated-inputs} in
2677 @code{package} objects}, for information about propagated inputs in
2678 package definitions).
2679
2680 @anchor{package-cmd-propagated-inputs}
2681 An example is the GNU MPC library: its C header files refer to those of
2682 the GNU MPFR library, which in turn refer to those of the GMP library.
2683 Thus, when installing MPC, the MPFR and GMP libraries also get installed
2684 in the profile; removing MPC also removes MPFR and GMP---unless they had
2685 also been explicitly installed by the user.
2686
2687 Besides, packages sometimes rely on the definition of environment
2688 variables for their search paths (see explanation of
2689 @code{--search-paths} below). Any missing or possibly incorrect
2690 environment variable definitions are reported here.
2691
2692 @item --install-from-expression=@var{exp}
2693 @itemx -e @var{exp}
2694 Install the package @var{exp} evaluates to.
2695
2696 @var{exp} must be a Scheme expression that evaluates to a
2697 @code{<package>} object. This option is notably useful to disambiguate
2698 between same-named variants of a package, with expressions such as
2699 @code{(@@ (gnu packages base) guile-final)}.
2700
2701 Note that this option installs the first output of the specified
2702 package, which may be insufficient when needing a specific output of a
2703 multiple-output package.
2704
2705 @item --install-from-file=@var{file}
2706 @itemx -f @var{file}
2707 Install the package that the code within @var{file} evaluates to.
2708
2709 As an example, @var{file} might contain a definition like this
2710 (@pxref{Defining Packages}):
2711
2712 @example
2713 @verbatiminclude package-hello.scm
2714 @end example
2715
2716 Developers may find it useful to include such a @file{guix.scm} file
2717 in the root of their project source tree that can be used to test
2718 development snapshots and create reproducible development environments
2719 (@pxref{Invoking guix environment}).
2720
2721 @item --remove=@var{package} @dots{}
2722 @itemx -r @var{package} @dots{}
2723 Remove the specified @var{package}s.
2724
2725 As for @code{--install}, each @var{package} may specify a version number
2726 and/or output name in addition to the package name. For instance,
2727 @code{-r glibc:debug} would remove the @code{debug} output of
2728 @code{glibc}.
2729
2730 @item --upgrade[=@var{regexp} @dots{}]
2731 @itemx -u [@var{regexp} @dots{}]
2732 @cindex upgrading packages
2733 Upgrade all the installed packages. If one or more @var{regexp}s are
2734 specified, upgrade only installed packages whose name matches a
2735 @var{regexp}. Also see the @code{--do-not-upgrade} option below.
2736
2737 Note that this upgrades package to the latest version of packages found
2738 in the distribution currently installed. To update your distribution,
2739 you should regularly run @command{guix pull} (@pxref{Invoking guix
2740 pull}).
2741
2742 @item --do-not-upgrade[=@var{regexp} @dots{}]
2743 When used together with the @code{--upgrade} option, do @emph{not}
2744 upgrade any packages whose name matches a @var{regexp}. For example, to
2745 upgrade all packages in the current profile except those containing the
2746 substring ``emacs'':
2747
2748 @example
2749 $ guix package --upgrade . --do-not-upgrade emacs
2750 @end example
2751
2752 @item @anchor{profile-manifest}--manifest=@var{file}
2753 @itemx -m @var{file}
2754 @cindex profile declaration
2755 @cindex profile manifest
2756 Create a new generation of the profile from the manifest object
2757 returned by the Scheme code in @var{file}.
2758
2759 This allows you to @emph{declare} the profile's contents rather than
2760 constructing it through a sequence of @code{--install} and similar
2761 commands. The advantage is that @var{file} can be put under version
2762 control, copied to different machines to reproduce the same profile, and
2763 so on.
2764
2765 @c FIXME: Add reference to (guix profile) documentation when available.
2766 @var{file} must return a @dfn{manifest} object, which is roughly a list
2767 of packages:
2768
2769 @findex packages->manifest
2770 @example
2771 (use-package-modules guile emacs)
2772
2773 (packages->manifest
2774 (list emacs
2775 guile-2.0
2776 ;; Use a specific package output.
2777 (list guile-2.0 "debug")))
2778 @end example
2779
2780 @findex specifications->manifest
2781 In this example we have to know which modules define the @code{emacs}
2782 and @code{guile-2.0} variables to provide the right
2783 @code{use-package-modules} line, which can be cumbersome. We can
2784 instead provide regular package specifications and let
2785 @code{specifications->manifest} look up the corresponding package
2786 objects, like this:
2787
2788 @example
2789 (specifications->manifest
2790 '("emacs" "guile@@2.2" "guile@@2.2:debug"))
2791 @end example
2792
2793 @item --roll-back
2794 @cindex rolling back
2795 @cindex undoing transactions
2796 @cindex transactions, undoing
2797 Roll back to the previous @dfn{generation} of the profile---i.e., undo
2798 the last transaction.
2799
2800 When combined with options such as @code{--install}, roll back occurs
2801 before any other actions.
2802
2803 When rolling back from the first generation that actually contains
2804 installed packages, the profile is made to point to the @dfn{zeroth
2805 generation}, which contains no files apart from its own metadata.
2806
2807 After having rolled back, installing, removing, or upgrading packages
2808 overwrites previous future generations. Thus, the history of the
2809 generations in a profile is always linear.
2810
2811 @item --switch-generation=@var{pattern}
2812 @itemx -S @var{pattern}
2813 @cindex generations
2814 Switch to a particular generation defined by @var{pattern}.
2815
2816 @var{pattern} may be either a generation number or a number prefixed
2817 with ``+'' or ``-''. The latter means: move forward/backward by a
2818 specified number of generations. For example, if you want to return to
2819 the latest generation after @code{--roll-back}, use
2820 @code{--switch-generation=+1}.
2821
2822 The difference between @code{--roll-back} and
2823 @code{--switch-generation=-1} is that @code{--switch-generation} will
2824 not make a zeroth generation, so if a specified generation does not
2825 exist, the current generation will not be changed.
2826
2827 @item --search-paths[=@var{kind}]
2828 @cindex search paths
2829 Report environment variable definitions, in Bash syntax, that may be
2830 needed in order to use the set of installed packages. These environment
2831 variables are used to specify @dfn{search paths} for files used by some
2832 of the installed packages.
2833
2834 For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
2835 environment variables to be defined so it can look for headers and
2836 libraries in the user's profile (@pxref{Environment Variables,,, gcc,
2837 Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
2838 library are installed in the profile, then @code{--search-paths} will
2839 suggest setting these variables to @code{@var{profile}/include} and
2840 @code{@var{profile}/lib}, respectively.
2841
2842 The typical use case is to define these environment variables in the
2843 shell:
2844
2845 @example
2846 $ eval `guix package --search-paths`
2847 @end example
2848
2849 @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
2850 meaning that the returned environment variable definitions will either
2851 be exact settings, or prefixes or suffixes of the current value of these
2852 variables. When omitted, @var{kind} defaults to @code{exact}.
2853
2854 This option can also be used to compute the @emph{combined} search paths
2855 of several profiles. Consider this example:
2856
2857 @example
2858 $ guix package -p foo -i guile
2859 $ guix package -p bar -i guile-json
2860 $ guix package -p foo -p bar --search-paths
2861 @end example
2862
2863 The last command above reports about the @code{GUILE_LOAD_PATH}
2864 variable, even though, taken individually, neither @file{foo} nor
2865 @file{bar} would lead to that recommendation.
2866
2867
2868 @item --profile=@var{profile}
2869 @itemx -p @var{profile}
2870 Use @var{profile} instead of the user's default profile.
2871
2872 @cindex collisions, in a profile
2873 @cindex colliding packages in profiles
2874 @cindex profile collisions
2875 @item --allow-collisions
2876 Allow colliding packages in the new profile. Use at your own risk!
2877
2878 By default, @command{guix package} reports as an error @dfn{collisions}
2879 in the profile. Collisions happen when two or more different versions
2880 or variants of a given package end up in the profile.
2881
2882 @item --bootstrap
2883 Use the bootstrap Guile to build the profile. This option is only
2884 useful to distribution developers.
2885
2886 @end table
2887
2888 In addition to these actions, @command{guix package} supports the
2889 following options to query the current state of a profile, or the
2890 availability of packages:
2891
2892 @table @option
2893
2894 @item --search=@var{regexp}
2895 @itemx -s @var{regexp}
2896 @cindex searching for packages
2897 List the available packages whose name, synopsis, or description matches
2898 @var{regexp} (in a case-insensitive fashion), sorted by relevance.
2899 Print all the metadata of matching packages in
2900 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
2901 GNU recutils manual}).
2902
2903 This allows specific fields to be extracted using the @command{recsel}
2904 command, for instance:
2905
2906 @example
2907 $ guix package -s malloc | recsel -p name,version,relevance
2908 name: jemalloc
2909 version: 4.5.0
2910 relevance: 6
2911
2912 name: glibc
2913 version: 2.25
2914 relevance: 1
2915
2916 name: libgc
2917 version: 7.6.0
2918 relevance: 1
2919 @end example
2920
2921 Similarly, to show the name of all the packages available under the
2922 terms of the GNU@tie{}LGPL version 3:
2923
2924 @example
2925 $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
2926 name: elfutils
2927
2928 name: gmp
2929 @dots{}
2930 @end example
2931
2932 It is also possible to refine search results using several @code{-s}
2933 flags. For example, the following command returns a list of board
2934 games:
2935
2936 @example
2937 $ guix package -s '\<board\>' -s game | recsel -p name
2938 name: gnubg
2939 @dots{}
2940 @end example
2941
2942 If we were to omit @code{-s game}, we would also get software packages
2943 that deal with printed circuit boards; removing the angle brackets
2944 around @code{board} would further add packages that have to do with
2945 keyboards.
2946
2947 And now for a more elaborate example. The following command searches
2948 for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
2949 libraries, and prints the name and synopsis of the matching packages:
2950
2951 @example
2952 $ guix package -s crypto -s library | \
2953 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
2954 @end example
2955
2956 @noindent
2957 @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
2958 information on @dfn{selection expressions} for @code{recsel -e}.
2959
2960 @item --show=@var{package}
2961 Show details about @var{package}, taken from the list of available packages, in
2962 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
2963 recutils manual}).
2964
2965 @example
2966 $ guix package --show=python | recsel -p name,version
2967 name: python
2968 version: 2.7.6
2969
2970 name: python
2971 version: 3.3.5
2972 @end example
2973
2974 You may also specify the full name of a package to only get details about a
2975 specific version of it:
2976 @example
2977 $ guix package --show=python@@3.4 | recsel -p name,version
2978 name: python
2979 version: 3.4.3
2980 @end example
2981
2982
2983
2984 @item --list-installed[=@var{regexp}]
2985 @itemx -I [@var{regexp}]
2986 List the currently installed packages in the specified profile, with the
2987 most recently installed packages shown last. When @var{regexp} is
2988 specified, list only installed packages whose name matches @var{regexp}.
2989
2990 For each installed package, print the following items, separated by
2991 tabs: the package name, its version string, the part of the package that
2992 is installed (for instance, @code{out} for the default output,
2993 @code{include} for its headers, etc.), and the path of this package in
2994 the store.
2995
2996 @item --list-available[=@var{regexp}]
2997 @itemx -A [@var{regexp}]
2998 List packages currently available in the distribution for this system
2999 (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
3000 installed packages whose name matches @var{regexp}.
3001
3002 For each package, print the following items separated by tabs: its name,
3003 its version string, the parts of the package (@pxref{Packages with
3004 Multiple Outputs}), and the source location of its definition.
3005
3006 @item --list-generations[=@var{pattern}]
3007 @itemx -l [@var{pattern}]
3008 @cindex generations
3009 Return a list of generations along with their creation dates; for each
3010 generation, show the installed packages, with the most recently
3011 installed packages shown last. Note that the zeroth generation is never
3012 shown.
3013
3014 For each installed package, print the following items, separated by
3015 tabs: the name of a package, its version string, the part of the package
3016 that is installed (@pxref{Packages with Multiple Outputs}), and the
3017 location of this package in the store.
3018
3019 When @var{pattern} is used, the command returns only matching
3020 generations. Valid patterns include:
3021
3022 @itemize
3023 @item @emph{Integers and comma-separated integers}. Both patterns denote
3024 generation numbers. For instance, @code{--list-generations=1} returns
3025 the first one.
3026
3027 And @code{--list-generations=1,8,2} outputs three generations in the
3028 specified order. Neither spaces nor trailing commas are allowed.
3029
3030 @item @emph{Ranges}. @code{--list-generations=2..9} prints the
3031 specified generations and everything in between. Note that the start of
3032 a range must be smaller than its end.
3033
3034 It is also possible to omit the endpoint. For example,
3035 @code{--list-generations=2..}, returns all generations starting from the
3036 second one.
3037
3038 @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
3039 or months by passing an integer along with the first letter of the
3040 duration. For example, @code{--list-generations=20d} lists generations
3041 that are up to 20 days old.
3042 @end itemize
3043
3044 @item --delete-generations[=@var{pattern}]
3045 @itemx -d [@var{pattern}]
3046 When @var{pattern} is omitted, delete all generations except the current
3047 one.
3048
3049 This command accepts the same patterns as @option{--list-generations}.
3050 When @var{pattern} is specified, delete the matching generations. When
3051 @var{pattern} specifies a duration, generations @emph{older} than the
3052 specified duration match. For instance, @code{--delete-generations=1m}
3053 deletes generations that are more than one month old.
3054
3055 If the current generation matches, it is @emph{not} deleted. Also, the
3056 zeroth generation is never deleted.
3057
3058 Note that deleting generations prevents rolling back to them.
3059 Consequently, this command must be used with care.
3060
3061 @end table
3062
3063 Finally, since @command{guix package} may actually start build
3064 processes, it supports all the common build options (@pxref{Common Build
3065 Options}). It also supports package transformation options, such as
3066 @option{--with-source} (@pxref{Package Transformation Options}).
3067 However, note that package transformations are lost when upgrading; to
3068 preserve transformations across upgrades, you should define your own
3069 package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
3070 (@pxref{Defining Packages}).
3071
3072 @node Substitutes
3073 @section Substitutes
3074
3075 @cindex substitutes
3076 @cindex pre-built binaries
3077 Guix supports transparent source/binary deployment, which means that it
3078 can either build things locally, or download pre-built items from a
3079 server, or both. We call these pre-built items @dfn{substitutes}---they
3080 are substitutes for local build results. In many cases, downloading a
3081 substitute is much faster than building things locally.
3082
3083 Substitutes can be anything resulting from a derivation build
3084 (@pxref{Derivations}). Of course, in the common case, they are
3085 pre-built package binaries, but source tarballs, for instance, which
3086 also result from derivation builds, can be available as substitutes.
3087
3088 @menu
3089 * Official Substitute Server:: One particular source of substitutes.
3090 * Substitute Server Authorization:: How to enable or disable substitutes.
3091 * Substitute Authentication:: How Guix verifies substitutes.
3092 * Proxy Settings:: How to get substitutes via proxy.
3093 * Substitution Failure:: What happens when substitution fails.
3094 * On Trusting Binaries:: How can you trust that binary blob?
3095 @end menu
3096
3097 @node Official Substitute Server
3098 @subsection Official Substitute Server
3099
3100 @cindex hydra
3101 @cindex build farm
3102 The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
3103 that builds packages from Guix continuously for some
3104 architectures, and makes them available as substitutes. This is the
3105 default source of substitutes; it can be overridden by passing the
3106 @option{--substitute-urls} option either to @command{guix-daemon}
3107 (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
3108 or to client tools such as @command{guix package}
3109 (@pxref{client-substitute-urls,, client @option{--substitute-urls}
3110 option}).
3111
3112 Substitute URLs can be either HTTP or HTTPS.
3113 HTTPS is recommended because communications are encrypted; conversely,
3114 using HTTP makes all communications visible to an eavesdropper, who
3115 could use the information gathered to determine, for instance, whether
3116 your system has unpatched security vulnerabilities.
3117
3118 Substitutes from the official build farm are enabled by default when
3119 using the Guix System Distribution (@pxref{GNU Distribution}). However,
3120 they are disabled by default when using Guix on a foreign distribution,
3121 unless you have explicitly enabled them via one of the recommended
3122 installation steps (@pxref{Installation}). The following paragraphs
3123 describe how to enable or disable substitutes for the official build
3124 farm; the same procedure can also be used to enable substitutes for any
3125 other substitute server.
3126
3127 @node Substitute Server Authorization
3128 @subsection Substitute Server Authorization
3129
3130 @cindex security
3131 @cindex substitutes, authorization thereof
3132 @cindex access control list (ACL), for substitutes
3133 @cindex ACL (access control list), for substitutes
3134 To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
3135 mirror thereof, you
3136 must add its public key to the access control list (ACL) of archive
3137 imports, using the @command{guix archive} command (@pxref{Invoking guix
3138 archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
3139 be compromised and to serve genuine substitutes.
3140
3141 The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
3142 @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
3143 the installation prefix of Guix. If you installed Guix from source,
3144 make sure you checked the GPG signature of
3145 @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
3146 Then, you can run something like this:
3147
3148 @example
3149 # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
3150 @end example
3151
3152 @quotation Note
3153 Similarly, the @file{hydra.gnu.org.pub} file contains the public key
3154 of an independent build farm also run by the project, reachable at
3155 @indicateurl{https://mirror.hydra.gnu.org}.
3156 @end quotation
3157
3158 Once this is in place, the output of a command like @code{guix build}
3159 should change from something like:
3160
3161 @example
3162 $ guix build emacs --dry-run
3163 The following derivations would be built:
3164 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
3165 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
3166 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
3167 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
3168 @dots{}
3169 @end example
3170
3171 @noindent
3172 to something like:
3173
3174 @example
3175 $ guix build emacs --dry-run
3176 112.3 MB would be downloaded:
3177 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
3178 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
3179 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
3180 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
3181 @dots{}
3182 @end example
3183
3184 @noindent
3185 This indicates that substitutes from @code{@value{SUBSTITUTE-SERVER}} are usable and
3186 will be downloaded, when possible, for future builds.
3187
3188 @cindex substitutes, how to disable
3189 The substitute mechanism can be disabled globally by running
3190 @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
3191 guix-daemon}). It can also be disabled temporarily by passing the
3192 @code{--no-substitutes} option to @command{guix package}, @command{guix
3193 build}, and other command-line tools.
3194
3195 @node Substitute Authentication
3196 @subsection Substitute Authentication
3197
3198 @cindex digital signatures
3199 Guix detects and raises an error when attempting to use a substitute
3200 that has been tampered with. Likewise, it ignores substitutes that are
3201 not signed, or that are not signed by one of the keys listed in the ACL.
3202
3203 There is one exception though: if an unauthorized server provides
3204 substitutes that are @emph{bit-for-bit identical} to those provided by
3205 an authorized server, then the unauthorized server becomes eligible for
3206 downloads. For example, assume we have chosen two substitute servers
3207 with this option:
3208
3209 @example
3210 --substitute-urls="https://a.example.org https://b.example.org"
3211 @end example
3212
3213 @noindent
3214 @cindex reproducible builds
3215 If the ACL contains only the key for @code{b.example.org}, and if
3216 @code{a.example.org} happens to serve the @emph{exact same} substitutes,
3217 then Guix will download substitutes from @code{a.example.org} because it
3218 comes first in the list and can be considered a mirror of
3219 @code{b.example.org}. In practice, independent build machines usually
3220 produce the same binaries, thanks to bit-reproducible builds (see
3221 below).
3222
3223 When using HTTPS, the server's X.509 certificate is @emph{not} validated
3224 (in other words, the server is not authenticated), contrary to what
3225 HTTPS clients such as Web browsers usually do. This is because Guix
3226 authenticates substitute information itself, as explained above, which
3227 is what we care about (whereas X.509 certificates are about
3228 authenticating bindings between domain names and public keys.)
3229
3230 @node Proxy Settings
3231 @subsection Proxy Settings
3232
3233 @vindex http_proxy
3234 Substitutes are downloaded over HTTP or HTTPS.
3235 The @code{http_proxy} environment
3236 variable can be set in the environment of @command{guix-daemon} and is
3237 honored for downloads of substitutes. Note that the value of
3238 @code{http_proxy} in the environment where @command{guix build},
3239 @command{guix package}, and other client commands are run has
3240 @emph{absolutely no effect}.
3241
3242 @node Substitution Failure
3243 @subsection Substitution Failure
3244
3245 Even when a substitute for a derivation is available, sometimes the
3246 substitution attempt will fail. This can happen for a variety of
3247 reasons: the substitute server might be offline, the substitute may
3248 recently have been deleted, the connection might have been interrupted,
3249 etc.
3250
3251 When substitutes are enabled and a substitute for a derivation is
3252 available, but the substitution attempt fails, Guix will attempt to
3253 build the derivation locally depending on whether or not
3254 @code{--fallback} was given (@pxref{fallback-option,, common build
3255 option @code{--fallback}}). Specifically, if @code{--fallback} was
3256 omitted, then no local build will be performed, and the derivation is
3257 considered to have failed. However, if @code{--fallback} was given,
3258 then Guix will attempt to build the derivation locally, and the success
3259 or failure of the derivation depends on the success or failure of the
3260 local build. Note that when substitutes are disabled or no substitute
3261 is available for the derivation in question, a local build will
3262 @emph{always} be performed, regardless of whether or not
3263 @code{--fallback} was given.
3264
3265 To get an idea of how many substitutes are available right now, you can
3266 try running the @command{guix weather} command (@pxref{Invoking guix
3267 weather}). This command provides statistics on the substitutes provided
3268 by a server.
3269
3270 @node On Trusting Binaries
3271 @subsection On Trusting Binaries
3272
3273 @cindex trust, of pre-built binaries
3274 Today, each individual's control over their own computing is at the
3275 mercy of institutions, corporations, and groups with enough power and
3276 determination to subvert the computing infrastructure and exploit its
3277 weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
3278 convenient, we encourage users to also build on their own, or even run
3279 their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
3280 interesting target. One way to help is by publishing the software you
3281 build using @command{guix publish} so that others have one more choice
3282 of server to download substitutes from (@pxref{Invoking guix publish}).
3283
3284 Guix has the foundations to maximize build reproducibility
3285 (@pxref{Features}). In most cases, independent builds of a given
3286 package or derivation should yield bit-identical results. Thus, through
3287 a diverse set of independent package builds, we can strengthen the
3288 integrity of our systems. The @command{guix challenge} command aims to
3289 help users assess substitute servers, and to assist developers in
3290 finding out about non-deterministic package builds (@pxref{Invoking guix
3291 challenge}). Similarly, the @option{--check} option of @command{guix
3292 build} allows users to check whether previously-installed substitutes
3293 are genuine by rebuilding them locally (@pxref{build-check,
3294 @command{guix build --check}}).
3295
3296 In the future, we want Guix to have support to publish and retrieve
3297 binaries to/from other users, in a peer-to-peer fashion. If you would
3298 like to discuss this project, join us on @email{guix-devel@@gnu.org}.
3299
3300 @node Packages with Multiple Outputs
3301 @section Packages with Multiple Outputs
3302
3303 @cindex multiple-output packages
3304 @cindex package outputs
3305 @cindex outputs
3306
3307 Often, packages defined in Guix have a single @dfn{output}---i.e., the
3308 source package leads to exactly one directory in the store. When running
3309 @command{guix package -i glibc}, one installs the default output of the
3310 GNU libc package; the default output is called @code{out}, but its name
3311 can be omitted as shown in this command. In this particular case, the
3312 default output of @code{glibc} contains all the C header files, shared
3313 libraries, static libraries, Info documentation, and other supporting
3314 files.
3315
3316 Sometimes it is more appropriate to separate the various types of files
3317 produced from a single source package into separate outputs. For
3318 instance, the GLib C library (used by GTK+ and related packages)
3319 installs more than 20 MiB of reference documentation as HTML pages.
3320 To save space for users who do not need it, the documentation goes to a
3321 separate output, called @code{doc}. To install the main GLib output,
3322 which contains everything but the documentation, one would run:
3323
3324 @example
3325 guix package -i glib
3326 @end example
3327
3328 @cindex documentation
3329 The command to install its documentation is:
3330
3331 @example
3332 guix package -i glib:doc
3333 @end example
3334
3335 Some packages install programs with different ``dependency footprints''.
3336 For instance, the WordNet package installs both command-line tools and
3337 graphical user interfaces (GUIs). The former depend solely on the C
3338 library, whereas the latter depend on Tcl/Tk and the underlying X
3339 libraries. In this case, we leave the command-line tools in the default
3340 output, whereas the GUIs are in a separate output. This allows users
3341 who do not need the GUIs to save space. The @command{guix size} command
3342 can help find out about such situations (@pxref{Invoking guix size}).
3343 @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
3344
3345 There are several such multiple-output packages in the GNU distribution.
3346 Other conventional output names include @code{lib} for libraries and
3347 possibly header files, @code{bin} for stand-alone programs, and
3348 @code{debug} for debugging information (@pxref{Installing Debugging
3349 Files}). The outputs of a packages are listed in the third column of
3350 the output of @command{guix package --list-available} (@pxref{Invoking
3351 guix package}).
3352
3353
3354 @node Invoking guix gc
3355 @section Invoking @command{guix gc}
3356
3357 @cindex garbage collector
3358 @cindex disk space
3359 Packages that are installed, but not used, may be @dfn{garbage-collected}.
3360 The @command{guix gc} command allows users to explicitly run the garbage
3361 collector to reclaim space from the @file{/gnu/store} directory. It is
3362 the @emph{only} way to remove files from @file{/gnu/store}---removing
3363 files or directories manually may break it beyond repair!
3364
3365 @cindex GC roots
3366 @cindex garbage collector roots
3367 The garbage collector has a set of known @dfn{roots}: any file under
3368 @file{/gnu/store} reachable from a root is considered @dfn{live} and
3369 cannot be deleted; any other file is considered @dfn{dead} and may be
3370 deleted. The set of garbage collector roots (``GC roots'' for short)
3371 includes default user profiles; by default, the symlinks under
3372 @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
3373 added with @command{guix build --root}, for example (@pxref{Invoking
3374 guix build}). The @command{guix gc --list-roots} command lists them.
3375
3376 Prior to running @code{guix gc --collect-garbage} to make space, it is
3377 often useful to remove old generations from user profiles; that way, old
3378 package builds referenced by those generations can be reclaimed. This
3379 is achieved by running @code{guix package --delete-generations}
3380 (@pxref{Invoking guix package}).
3381
3382 Our recommendation is to run a garbage collection periodically, or when
3383 you are short on disk space. For instance, to guarantee that at least
3384 5@tie{}GB are available on your disk, simply run:
3385
3386 @example
3387 guix gc -F 5G
3388 @end example
3389
3390 It is perfectly safe to run as a non-interactive periodic job
3391 (@pxref{Scheduled Job Execution}, for how to set up such a job).
3392 Running @command{guix gc} with no arguments will collect as
3393 much garbage as it can, but that is often inconvenient: you may find
3394 yourself having to rebuild or re-download software that is ``dead'' from
3395 the GC viewpoint but that is necessary to build other pieces of
3396 software---e.g., the compiler tool chain.
3397
3398 The @command{guix gc} command has three modes of operation: it can be
3399 used to garbage-collect any dead files (the default), to delete specific
3400 files (the @code{--delete} option), to print garbage-collector
3401 information, or for more advanced queries. The garbage collection
3402 options are as follows:
3403
3404 @table @code
3405 @item --collect-garbage[=@var{min}]
3406 @itemx -C [@var{min}]
3407 Collect garbage---i.e., unreachable @file{/gnu/store} files and
3408 sub-directories. This is the default operation when no option is
3409 specified.
3410
3411 When @var{min} is given, stop once @var{min} bytes have been collected.
3412 @var{min} may be a number of bytes, or it may include a unit as a
3413 suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
3414 (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
3415
3416 When @var{min} is omitted, collect all the garbage.
3417
3418 @item --free-space=@var{free}
3419 @itemx -F @var{free}
3420 Collect garbage until @var{free} space is available under
3421 @file{/gnu/store}, if possible; @var{free} denotes storage space, such
3422 as @code{500MiB}, as described above.
3423
3424 When @var{free} or more is already available in @file{/gnu/store}, do
3425 nothing and exit immediately.
3426
3427 @item --delete-generations[=@var{duration}]
3428 @itemx -d [@var{duration}]
3429 Before starting the garbage collection process, delete all the generations
3430 older than @var{duration}, for all the user profiles; when run as root, this
3431 applies to all the profiles @emph{of all the users}.
3432
3433 For example, this command deletes all the generations of all your profiles
3434 that are older than 2 months (except generations that are current), and then
3435 proceeds to free space until at least 10 GiB are available:
3436
3437 @example
3438 guix gc -d 2m -F 10G
3439 @end example
3440
3441 @item --delete
3442 @itemx -D
3443 Attempt to delete all the store files and directories specified as
3444 arguments. This fails if some of the files are not in the store, or if
3445 they are still live.
3446
3447 @item --list-failures
3448 List store items corresponding to cached build failures.
3449
3450 This prints nothing unless the daemon was started with
3451 @option{--cache-failures} (@pxref{Invoking guix-daemon,
3452 @option{--cache-failures}}).
3453
3454 @item --list-roots
3455 List the GC roots owned by the user; when run as root, list @emph{all} the GC
3456 roots.
3457
3458 @item --clear-failures
3459 Remove the specified store items from the failed-build cache.
3460
3461 Again, this option only makes sense when the daemon is started with
3462 @option{--cache-failures}. Otherwise, it does nothing.
3463
3464 @item --list-dead
3465 Show the list of dead files and directories still present in the
3466 store---i.e., files and directories no longer reachable from any root.
3467
3468 @item --list-live
3469 Show the list of live store files and directories.
3470
3471 @end table
3472
3473 In addition, the references among existing store files can be queried:
3474
3475 @table @code
3476
3477 @item --references
3478 @itemx --referrers
3479 @cindex package dependencies
3480 List the references (respectively, the referrers) of store files given
3481 as arguments.
3482
3483 @item --requisites
3484 @itemx -R
3485 @cindex closure
3486 List the requisites of the store files passed as arguments. Requisites
3487 include the store files themselves, their references, and the references
3488 of these, recursively. In other words, the returned list is the
3489 @dfn{transitive closure} of the store files.
3490
3491 @xref{Invoking guix size}, for a tool to profile the size of the closure
3492 of an element. @xref{Invoking guix graph}, for a tool to visualize
3493 the graph of references.
3494
3495 @item --derivers
3496 @cindex derivation
3497 Return the derivation(s) leading to the given store items
3498 (@pxref{Derivations}).
3499
3500 For example, this command:
3501
3502 @example
3503 guix gc --derivers `guix package -I ^emacs$ | cut -f4`
3504 @end example
3505
3506 @noindent
3507 returns the @file{.drv} file(s) leading to the @code{emacs} package
3508 installed in your profile.
3509
3510 Note that there may be zero matching @file{.drv} files, for instance
3511 because these files have been garbage-collected. There can also be more
3512 than one matching @file{.drv} due to fixed-output derivations.
3513 @end table
3514
3515 Lastly, the following options allow you to check the integrity of the
3516 store and to control disk usage.
3517
3518 @table @option
3519
3520 @item --verify[=@var{options}]
3521 @cindex integrity, of the store
3522 @cindex integrity checking
3523 Verify the integrity of the store.
3524
3525 By default, make sure that all the store items marked as valid in the
3526 database of the daemon actually exist in @file{/gnu/store}.
3527
3528 When provided, @var{options} must be a comma-separated list containing one
3529 or more of @code{contents} and @code{repair}.
3530
3531 When passing @option{--verify=contents}, the daemon computes the
3532 content hash of each store item and compares it against its hash in the
3533 database. Hash mismatches are reported as data corruptions. Because it
3534 traverses @emph{all the files in the store}, this command can take a
3535 long time, especially on systems with a slow disk drive.
3536
3537 @cindex repairing the store
3538 @cindex corruption, recovering from
3539 Using @option{--verify=repair} or @option{--verify=contents,repair}
3540 causes the daemon to try to repair corrupt store items by fetching
3541 substitutes for them (@pxref{Substitutes}). Because repairing is not
3542 atomic, and thus potentially dangerous, it is available only to the
3543 system administrator. A lightweight alternative, when you know exactly
3544 which items in the store are corrupt, is @command{guix build --repair}
3545 (@pxref{Invoking guix build}).
3546
3547 @item --optimize
3548 @cindex deduplication
3549 Optimize the store by hard-linking identical files---this is
3550 @dfn{deduplication}.
3551
3552 The daemon performs deduplication after each successful build or archive
3553 import, unless it was started with @code{--disable-deduplication}
3554 (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
3555 this option is primarily useful when the daemon was running with
3556 @code{--disable-deduplication}.
3557
3558 @end table
3559
3560 @node Invoking guix pull
3561 @section Invoking @command{guix pull}
3562
3563 @cindex upgrading Guix
3564 @cindex updating Guix
3565 @cindex @command{guix pull}
3566 @cindex pull
3567 Packages are installed or upgraded to the latest version available in
3568 the distribution currently available on your local machine. To update
3569 that distribution, along with the Guix tools, you must run @command{guix
3570 pull}: the command downloads the latest Guix source code and package
3571 descriptions, and deploys it. Source code is downloaded from a
3572 @uref{https://git-scm.com, Git} repository, by default the official
3573 GNU@tie{}Guix repository, though this can be customized.
3574
3575 On completion, @command{guix package} will use packages and package
3576 versions from this just-retrieved copy of Guix. Not only that, but all
3577 the Guix commands and Scheme modules will also be taken from that latest
3578 version. New @command{guix} sub-commands added by the update also
3579 become available.
3580
3581 Any user can update their Guix copy using @command{guix pull}, and the
3582 effect is limited to the user who run @command{guix pull}. For
3583 instance, when user @code{root} runs @command{guix pull}, this has no
3584 effect on the version of Guix that user @code{alice} sees, and vice
3585 versa.
3586
3587 The result of running @command{guix pull} is a @dfn{profile} available
3588 under @file{~/.config/guix/current} containing the latest Guix. Thus,
3589 make sure to add it to the beginning of your search path so that you use
3590 the latest version, and similarly for the Info manual
3591 (@pxref{Documentation}):
3592
3593 @example
3594 export PATH="$HOME/.config/guix/current/bin:$PATH"
3595 export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
3596 @end example
3597
3598 The @code{--list-generations} or @code{-l} option lists past generations
3599 produced by @command{guix pull}, along with details about their provenance:
3600
3601 @example
3602 $ guix pull -l
3603 Generation 1 Jun 10 2018 00:18:18
3604 guix 65956ad
3605 repository URL: https://git.savannah.gnu.org/git/guix.git
3606 branch: origin/master
3607 commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
3608
3609 Generation 2 Jun 11 2018 11:02:49
3610 guix e0cc7f6
3611 repository URL: https://git.savannah.gnu.org/git/guix.git
3612 branch: origin/master
3613 commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
3614 2 new packages: keepalived, libnfnetlink
3615 6 packages upgraded: emacs-nix-mode@@2.0.4,
3616 guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
3617 heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
3618
3619 Generation 3 Jun 13 2018 23:31:07 (current)
3620 guix 844cc1c
3621 repository URL: https://git.savannah.gnu.org/git/guix.git
3622 branch: origin/master
3623 commit: 844cc1c8f394f03b404c5bb3aee086922373490c
3624 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
3625 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
3626 @end example
3627
3628 @xref{Invoking guix describe, @command{guix describe}}, for other ways to
3629 describe the current status of Guix.
3630
3631 This @code{~/.config/guix/current} profile works like any other profile
3632 created by @command{guix package} (@pxref{Invoking guix package}). That
3633 is, you can list generations, roll back to the previous
3634 generation---i.e., the previous Guix---and so on:
3635
3636 @example
3637 $ guix package -p ~/.config/guix/current --roll-back
3638 switched from generation 3 to 2
3639 $ guix package -p ~/.config/guix/current --delete-generations=1
3640 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
3641 @end example
3642
3643 The @command{guix pull} command is usually invoked with no arguments,
3644 but it supports the following options:
3645
3646 @table @code
3647 @item --url=@var{url}
3648 @itemx --commit=@var{commit}
3649 @itemx --branch=@var{branch}
3650 Download code for the @code{guix} channel from the specified @var{url}, at the
3651 given @var{commit} (a valid Git commit ID represented as a hexadecimal
3652 string), or @var{branch}.
3653
3654 @cindex @file{channels.scm}, configuration file
3655 @cindex configuration file for channels
3656 These options are provided for convenience, but you can also specify your
3657 configuration in the @file{~/.config/guix/channels.scm} file or using the
3658 @option{--channels} option (see below).
3659
3660 @item --channels=@var{file}
3661 @itemx -C @var{file}
3662 Read the list of channels from @var{file} instead of
3663 @file{~/.config/guix/channels.scm}. @var{file} must contain Scheme code that
3664 evaluates to a list of channel objects. @xref{Channels}, for more
3665 information.
3666
3667 @item --news
3668 @itemx -N
3669 Display the list of packages added or upgraded since the previous generation.
3670
3671 This is the same information as displayed upon @command{guix pull} completion,
3672 but without ellipses; it is also similar to the output of @command{guix pull
3673 -l} for the last generation (see below).
3674
3675 @item --list-generations[=@var{pattern}]
3676 @itemx -l [@var{pattern}]
3677 List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
3678 is provided, the subset of generations that match @var{pattern}.
3679 The syntax of @var{pattern} is the same as with @code{guix package
3680 --list-generations} (@pxref{Invoking guix package}).
3681
3682 @xref{Invoking guix describe}, for a way to display information about the
3683 current generation only.
3684
3685 @item --profile=@var{profile}
3686 @itemx -p @var{profile}
3687 Use @var{profile} instead of @file{~/.config/guix/current}.
3688
3689 @item --dry-run
3690 @itemx -n
3691 Show which channel commit(s) would be used and what would be built or
3692 substituted but do not actually do it.
3693
3694 @item --system=@var{system}
3695 @itemx -s @var{system}
3696 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
3697 the system type of the build host.
3698
3699 @item --verbose
3700 Produce verbose output, writing build logs to the standard error output.
3701
3702 @item --bootstrap
3703 Use the bootstrap Guile to build the latest Guix. This option is only
3704 useful to Guix developers.
3705 @end table
3706
3707 The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
3708 repository and branch to pull from, as well as @emph{additional} repositories
3709 containing package modules that should be deployed. @xref{Channels}, for more
3710 information.
3711
3712 In addition, @command{guix pull} supports all the common build options
3713 (@pxref{Common Build Options}).
3714
3715 @node Channels
3716 @section Channels
3717
3718 @cindex channels
3719 @cindex @file{channels.scm}, configuration file
3720 @cindex configuration file for channels
3721 @cindex @command{guix pull}, configuration file
3722 @cindex configuration of @command{guix pull}
3723 Guix and its package collection are updated by running @command{guix pull}
3724 (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
3725 deploys Guix itself from the official GNU@tie{}Guix repository. This can be
3726 customized by defining @dfn{channels} in the
3727 @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
3728 of a Git repository to be deployed, and @command{guix pull} can be instructed
3729 to pull from one or more channels. In other words, channels can be used to
3730 @emph{customize} and to @emph{extend} Guix, as we will see below.
3731
3732 @subsection Using a Custom Guix Channel
3733
3734 The channel called @code{guix} specifies where Guix itself---its command-line
3735 tools as well as its package collection---should be downloaded. For instance,
3736 suppose you want to update from your own copy of the Guix repository at
3737 @code{example.org}, and specifically the @code{super-hacks} branch, you can
3738 write in @code{~/.config/guix/channels.scm} this specification:
3739
3740 @lisp
3741 ;; Tell 'guix pull' to use my own repo.
3742 (list (channel
3743 (name 'guix)
3744 (url "https://example.org/my-guix.git")
3745 (branch "super-hacks")))
3746 @end lisp
3747
3748 @noindent
3749 From there on, @command{guix pull} will fetch code from the @code{super-hacks}
3750 branch of the repository at @code{example.org}.
3751
3752 @subsection Specifying Additional Channels
3753
3754 @cindex extending the package collection (channels)
3755 @cindex personal packages (channels)
3756 @cindex channels, for personal packages
3757 You can also specify @emph{additional channels} to pull from. Let's say you
3758 have a bunch of custom package variants or personal packages that you think
3759 would make little sense to contribute to the Guix project, but would like to
3760 have these packages transparently available to you at the command line. You
3761 would first write modules containing those package definitions (@pxref{Package
3762 Modules}), maintain them in a Git repository, and then you and anyone else can
3763 use it as an additional channel to get packages from. Neat, no?
3764
3765 @c What follows stems from discussions at
3766 @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
3767 @c earlier discussions on guix-devel@gnu.org.
3768 @quotation Warning
3769 Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
3770 publish your personal channel to the world, we would like to share a few words
3771 of caution:
3772
3773 @itemize
3774 @item
3775 Before publishing a channel, please consider contributing your package
3776 definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
3777 to free software of all sorts, and packages in Guix proper are readily
3778 available to all Guix users and benefit from the project's quality assurance
3779 process.
3780
3781 @item
3782 When you maintain package definitions outside Guix, we, Guix developers,
3783 consider that @emph{the compatibility burden is on you}. Remember that
3784 package modules and package definitions are just Scheme code that uses various
3785 programming interfaces (APIs). We want to remain free to change these APIs to
3786 keep improving Guix, possibly in ways that break your channel. We never
3787 change APIs gratuitously, but we will @emph{not} commit to freezing APIs
3788 either.
3789
3790 @item
3791 Corollary: if you're using an external channel and that channel breaks, please
3792 @emph{report the issue to the channel authors}, not to the Guix project.
3793 @end itemize
3794
3795 You've been warned! Having said this, we believe external channels are a
3796 practical way to exert your freedom to augment Guix' package collection and to
3797 share your improvements, which are basic tenets of
3798 @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
3799 email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
3800 @end quotation
3801
3802 To use a channel, write @code{~/.config/guix/channels.scm} to instruct
3803 @command{guix pull} to pull from it @emph{in addition} to the default Guix
3804 channel(s):
3805
3806 @vindex %default-channels
3807 @lisp
3808 ;; Add my personal packages to those Guix provides.
3809 (cons (channel
3810 (name 'my-personal-packages)
3811 (url "https://example.org/personal-packages.git"))
3812 %default-channels)
3813 @end lisp
3814
3815 @noindent
3816 Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
3817 add a channel the list of channels that the variable @code{%default-channels}
3818 is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
3819 Manual}). With this file in place, @command{guix pull} builds not only Guix
3820 but also the package modules from your own repository. The result in
3821 @file{~/.config/guix/current} is the union of Guix with your own package
3822 modules:
3823
3824 @example
3825 $ guix pull --list-generations
3826 @dots{}
3827 Generation 19 Aug 27 2018 16:20:48
3828 guix d894ab8
3829 repository URL: https://git.savannah.gnu.org/git/guix.git
3830 branch: master
3831 commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
3832 my-personal-packages dd3df5e
3833 repository URL: https://example.org/personal-packages.git
3834 branch: master
3835 commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
3836 11 new packages: my-gimp, my-emacs-with-cool-features, @dots{}
3837 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
3838 @end example
3839
3840 @noindent
3841 The output of @command{guix pull} above shows that Generation@tie{}19 includes
3842 both Guix and packages from the @code{my-personal-packages} channel. Among
3843 the new and upgraded packages that are listed, some like @code{my-gimp} and
3844 @code{my-emacs-with-cool-features} might come from
3845 @code{my-personal-packages}, while others come from the Guix default channel.
3846
3847 To create a channel, create a Git repository containing your own package
3848 modules and make it available. The repository can contain anything, but a
3849 useful channel will contain Guile modules that export packages. Once you
3850 start using a channel, Guix will behave as if the root directory of that
3851 channel's Git repository has been added to the Guile load path (@pxref{Load
3852 Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
3853 contains a file at @file{my-packages/my-tools.scm} that defines a Guile
3854 module, then the module will be available under the name @code{(my-packages
3855 my-tools)}, and you will be able to use it like any other module
3856 (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
3857
3858 @cindex dependencies, channels
3859 @cindex meta-data, channels
3860 @subsection Declaring Channel Dependencies
3861
3862 Channel authors may decide to augment a package collection provided by other
3863 channels. They can declare their channel to be dependent on other channels in
3864 a meta-data file @file{.guix-channel}, which is to be placed in the root of
3865 the channel repository.
3866
3867 The meta-data file should contain a simple S-expression like this:
3868
3869 @lisp
3870 (channel
3871 (version 0)
3872 (dependencies
3873 (channel
3874 (name some-collection)
3875 (url "https://example.org/first-collection.git"))
3876 (channel
3877 (name some-other-collection)
3878 (url "https://example.org/second-collection.git")
3879 (branch "testing"))))
3880 @end lisp
3881
3882 In the above example this channel is declared to depend on two other channels,
3883 which will both be fetched automatically. The modules provided by the channel
3884 will be compiled in an environment where the modules of all these declared
3885 channels are available.
3886
3887 For the sake of reliability and maintainability, you should avoid dependencies
3888 on channels that you don't control, and you should aim to keep the number of
3889 dependencies to a minimum.
3890
3891 @subsection Replicating Guix
3892
3893 @cindex pinning, channels
3894 @cindex replicating Guix
3895 @cindex reproducibility, of Guix
3896 The @command{guix pull --list-generations} output above shows precisely which
3897 commits were used to build this instance of Guix. We can thus replicate it,
3898 say, on another machine, by providing a channel specification in
3899 @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
3900
3901 @lisp
3902 ;; Deploy specific commits of my channels of interest.
3903 (list (channel
3904 (name 'guix)
3905 (url "https://git.savannah.gnu.org/git/guix.git")
3906 (commit "d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300"))
3907 (channel
3908 (name 'my-personal-packages)
3909 (url "https://example.org/personal-packages.git")
3910 (branch "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
3911 @end lisp
3912
3913 The @command{guix describe --format=channels} command can even generate this
3914 list of channels directly (@pxref{Invoking guix describe}).
3915
3916 At this point the two machines run the @emph{exact same Guix}, with access to
3917 the @emph{exact same packages}. The output of @command{guix build gimp} on
3918 one machine will be exactly the same, bit for bit, as the output of the same
3919 command on the other machine. It also means both machines have access to all
3920 the source code of Guix and, transitively, to all the source code of every
3921 package it defines.
3922
3923 This gives you super powers, allowing you to track the provenance of binary
3924 artifacts with very fine grain, and to reproduce software environments at
3925 will---some sort of ``meta reproducibility'' capabilities, if you will.
3926 @xref{Inferiors}, for another way to take advantage of these super powers.
3927
3928 @node Inferiors
3929 @section Inferiors
3930
3931 @c TODO: Remove this once we're more confident about API stability.
3932 @quotation Note
3933 The functionality described here is a ``technology preview'' as of version
3934 @value{VERSION}. As such, the interface is subject to change.
3935 @end quotation
3936
3937 @cindex inferiors
3938 @cindex composition of Guix revisions
3939 Sometimes you might need to mix packages from the revision of Guix you're
3940 currently running with packages available in a different revision of Guix.
3941 Guix @dfn{inferiors} allow you to achieve that by composing different Guix
3942 revisions in arbitrary ways.
3943
3944 @cindex inferior packages
3945 Technically, an ``inferior'' is essentially a separate Guix process connected
3946 to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
3947 @code{(guix inferior)} module allows you to create inferiors and to
3948 communicate with them. It also provides a high-level interface to browse and
3949 manipulate the packages that an inferior provides---@dfn{inferior packages}.
3950
3951 When combined with channels (@pxref{Channels}), inferiors provide a simple way
3952 to interact with a separate revision of Guix. For example, let's assume you
3953 want to install in your profile the current @code{guile} package, along with
3954 the @code{guile-json} as it existed in an older revision of Guix---perhaps
3955 because the newer @code{guile-json} has an incompatible API and you want to
3956 run your code against the old API@. To do that, you could write a manifest for
3957 use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
3958 manifest, you would create an inferior for that old Guix revision you care
3959 about, and you would look up the @code{guile-json} package in the inferior:
3960
3961 @lisp
3962 (use-modules (guix inferior) (guix channels)
3963 (srfi srfi-1)) ;for 'first'
3964
3965 (define channels
3966 ;; This is the old revision from which we want to
3967 ;; extract guile-json.
3968 (list (channel
3969 (name 'guix)
3970 (url "https://git.savannah.gnu.org/git/guix.git")
3971 (commit
3972 "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
3973
3974 (define inferior
3975 ;; An inferior representing the above revision.
3976 (inferior-for-channels channels))
3977
3978 ;; Now create a manifest with the current "guile" package
3979 ;; and the old "guile-json" package.
3980 (packages->manifest
3981 (list (first (lookup-inferior-packages inferior "guile-json"))
3982 (specification->package "guile")))
3983 @end lisp
3984
3985 On its first run, @command{guix package --manifest} might have to build the
3986 channel you specified before it can create the inferior; subsequent runs will
3987 be much faster because the Guix revision will be cached.
3988
3989 The @code{(guix inferior)} module provides the following procedures to open an
3990 inferior:
3991
3992 @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
3993 [#:cache-directory] [#:ttl]
3994 Return an inferior for @var{channels}, a list of channels. Use the cache at
3995 @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
3996 This procedure opens a new connection to the build daemon.
3997
3998 As a side effect, this procedure may build or substitute binaries for
3999 @var{channels}, which can take time.
4000 @end deffn
4001
4002 @deffn {Scheme Procedure} open-inferior @var{directory} @
4003 [#:command "bin/guix"]
4004 Open the inferior Guix in @var{directory}, running
4005 @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
4006 the inferior could not be launched.
4007 @end deffn
4008
4009 @cindex inferior packages
4010 The procedures listed below allow you to obtain and manipulate inferior
4011 packages.
4012
4013 @deffn {Scheme Procedure} inferior-packages @var{inferior}
4014 Return the list of packages known to @var{inferior}.
4015 @end deffn
4016
4017 @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
4018 [@var{version}]
4019 Return the sorted list of inferior packages matching @var{name} in
4020 @var{inferior}, with highest version numbers first. If @var{version} is true,
4021 return only packages with a version number prefixed by @var{version}.
4022 @end deffn
4023
4024 @deffn {Scheme Procedure} inferior-package? @var{obj}
4025 Return true if @var{obj} is an inferior package.
4026 @end deffn
4027
4028 @deffn {Scheme Procedure} inferior-package-name @var{package}
4029 @deffnx {Scheme Procedure} inferior-package-version @var{package}
4030 @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
4031 @deffnx {Scheme Procedure} inferior-package-description @var{package}
4032 @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
4033 @deffnx {Scheme Procedure} inferior-package-location @var{package}
4034 @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
4035 @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
4036 @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
4037 @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
4038 @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
4039 @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
4040 @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
4041 These procedures are the counterpart of package record accessors
4042 (@pxref{package Reference}). Most of them work by querying the inferior
4043 @var{package} comes from, so the inferior must still be live when you call
4044 these procedures.
4045 @end deffn
4046
4047 Inferior packages can be used transparently like any other package or
4048 file-like object in G-expressions (@pxref{G-Expressions}). They are also
4049 transparently handled by the @code{packages->manifest} procedure, which is
4050 commonly use in manifests (@pxref{Invoking guix package, the
4051 @option{--manifest} option of @command{guix package}}). Thus you can insert
4052 an inferior package pretty much anywhere you would insert a regular package:
4053 in manifests, in the @code{packages} field of your @code{operating-system}
4054 declaration, and so on.
4055
4056 @node Invoking guix describe
4057 @section Invoking @command{guix describe}
4058
4059 @cindex reproducibility
4060 @cindex replicating Guix
4061 Often you may want to answer questions like: ``Which revision of Guix am I
4062 using?'' or ``Which channels am I using?'' This is useful information in many
4063 situations: if you want to @emph{replicate} an environment on a different
4064 machine or user account, if you want to report a bug or to determine what
4065 change in the channels you are using caused it, or if you want to record your
4066 system state for reproducibility purposes. The @command{guix describe}
4067 command answers these questions.
4068
4069 When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
4070 displays the channel(s) that it was built from, including their repository URL
4071 and commit IDs (@pxref{Channels}):
4072
4073 @example
4074 $ guix describe
4075 Generation 10 Sep 03 2018 17:32:44 (current)
4076 guix e0fa68c
4077 repository URL: https://git.savannah.gnu.org/git/guix.git
4078 branch: master
4079 commit: e0fa68c7718fffd33d81af415279d6ddb518f727
4080 @end example
4081
4082 If you're familiar with the Git version control system, this is similar in
4083 spirit to @command{git describe}; the output is also similar to that of
4084 @command{guix pull --list-generations}, but limited to the current generation
4085 (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
4086 the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
4087 information is all it takes to describe the revision of Guix you're using, and
4088 also to replicate it.
4089
4090 To make it easier to replicate Guix, @command{guix describe} can also be asked
4091 to return a list of channels instead of the human-readable description above:
4092
4093 @example
4094 $ guix describe -f channels
4095 (list (channel
4096 (name 'guix)
4097 (url "https://git.savannah.gnu.org/git/guix.git")
4098 (commit
4099 "e0fa68c7718fffd33d81af415279d6ddb518f727")))
4100 @end example
4101
4102 @noindent
4103 You can save this to a file and feed it to @command{guix pull -C} on some
4104 other machine or at a later point in time, which will instantiate @emph{this
4105 exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
4106 From there on, since you're able to deploy the same revision of Guix, you can
4107 just as well @emph{replicate a complete software environment}. We humbly
4108 think that this is @emph{awesome}, and we hope you'll like it too!
4109
4110 The details of the options supported by @command{guix describe} are as
4111 follows:
4112
4113 @table @code
4114 @item --format=@var{format}
4115 @itemx -f @var{format}
4116 Produce output in the specified @var{format}, one of:
4117
4118 @table @code
4119 @item human
4120 produce human-readable output;
4121 @item channels
4122 produce a list of channel specifications that can be passed to @command{guix
4123 pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
4124 guix pull});
4125 @item json
4126 @cindex JSON
4127 produce a list of channel specifications in JSON format;
4128 @item recutils
4129 produce a list of channel specifications in Recutils format.
4130 @end table
4131
4132 @item --profile=@var{profile}
4133 @itemx -p @var{profile}
4134 Display information about @var{profile}.
4135 @end table
4136
4137 @node Invoking guix archive
4138 @section Invoking @command{guix archive}
4139
4140 @cindex @command{guix archive}
4141 @cindex archive
4142 The @command{guix archive} command allows users to @dfn{export} files
4143 from the store into a single archive, and to later @dfn{import} them on
4144 a machine that runs Guix.
4145 In particular, it allows store files to be transferred from one machine
4146 to the store on another machine.
4147
4148 @quotation Note
4149 If you're looking for a way to produce archives in a format suitable for
4150 tools other than Guix, @pxref{Invoking guix pack}.
4151 @end quotation
4152
4153 @cindex exporting store items
4154 To export store files as an archive to standard output, run:
4155
4156 @example
4157 guix archive --export @var{options} @var{specifications}...
4158 @end example
4159
4160 @var{specifications} may be either store file names or package
4161 specifications, as for @command{guix package} (@pxref{Invoking guix
4162 package}). For instance, the following command creates an archive
4163 containing the @code{gui} output of the @code{git} package and the main
4164 output of @code{emacs}:
4165
4166 @example
4167 guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
4168 @end example
4169
4170 If the specified packages are not built yet, @command{guix archive}
4171 automatically builds them. The build process may be controlled with the
4172 common build options (@pxref{Common Build Options}).
4173
4174 To transfer the @code{emacs} package to a machine connected over SSH,
4175 one would run:
4176
4177 @example
4178 guix archive --export -r emacs | ssh the-machine guix archive --import
4179 @end example
4180
4181 @noindent
4182 Similarly, a complete user profile may be transferred from one machine
4183 to another like this:
4184
4185 @example
4186 guix archive --export -r $(readlink -f ~/.guix-profile) | \
4187 ssh the-machine guix-archive --import
4188 @end example
4189
4190 @noindent
4191 However, note that, in both examples, all of @code{emacs} and the
4192 profile as well as all of their dependencies are transferred (due to
4193 @code{-r}), regardless of what is already available in the store on the
4194 target machine. The @code{--missing} option can help figure out which
4195 items are missing from the target store. The @command{guix copy}
4196 command simplifies and optimizes this whole process, so this is probably
4197 what you should use in this case (@pxref{Invoking guix copy}).
4198
4199 @cindex nar, archive format
4200 @cindex normalized archive (nar)
4201 Archives are stored in the ``normalized archive'' or ``nar'' format, which is
4202 comparable in spirit to `tar', but with differences
4203 that make it more appropriate for our purposes. First, rather than
4204 recording all Unix metadata for each file, the nar format only mentions
4205 the file type (regular, directory, or symbolic link); Unix permissions
4206 and owner/group are dismissed. Second, the order in which directory
4207 entries are stored always follows the order of file names according to
4208 the C locale collation order. This makes archive production fully
4209 deterministic.
4210
4211 When exporting, the daemon digitally signs the contents of the archive,
4212 and that digital signature is appended. When importing, the daemon
4213 verifies the signature and rejects the import in case of an invalid
4214 signature or if the signing key is not authorized.
4215 @c FIXME: Add xref to daemon doc about signatures.
4216
4217 The main options are:
4218
4219 @table @code
4220 @item --export
4221 Export the specified store files or packages (see below.) Write the
4222 resulting archive to the standard output.
4223
4224 Dependencies are @emph{not} included in the output, unless
4225 @code{--recursive} is passed.
4226
4227 @item -r
4228 @itemx --recursive
4229 When combined with @code{--export}, this instructs @command{guix
4230 archive} to include dependencies of the given items in the archive.
4231 Thus, the resulting archive is self-contained: it contains the closure
4232 of the exported store items.
4233
4234 @item --import
4235 Read an archive from the standard input, and import the files listed
4236 therein into the store. Abort if the archive has an invalid digital
4237 signature, or if it is signed by a public key not among the authorized
4238 keys (see @code{--authorize} below.)
4239
4240 @item --missing
4241 Read a list of store file names from the standard input, one per line,
4242 and write on the standard output the subset of these files missing from
4243 the store.
4244
4245 @item --generate-key[=@var{parameters}]
4246 @cindex signing, archives
4247 Generate a new key pair for the daemon. This is a prerequisite before
4248 archives can be exported with @code{--export}. Note that this operation
4249 usually takes time, because it needs to gather enough entropy to
4250 generate the key pair.
4251
4252 The generated key pair is typically stored under @file{/etc/guix}, in
4253 @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
4254 key, which must be kept secret.) When @var{parameters} is omitted,
4255 an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
4256 versions before 1.6.0, it is a 4096-bit RSA key.
4257 Alternatively, @var{parameters} can specify
4258 @code{genkey} parameters suitable for Libgcrypt (@pxref{General
4259 public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
4260 Libgcrypt Reference Manual}).
4261
4262 @item --authorize
4263 @cindex authorizing, archives
4264 Authorize imports signed by the public key passed on standard input.
4265 The public key must be in ``s-expression advanced format''---i.e., the
4266 same format as the @file{signing-key.pub} file.
4267
4268 The list of authorized keys is kept in the human-editable file
4269 @file{/etc/guix/acl}. The file contains
4270 @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
4271 s-expressions''} and is structured as an access-control list in the
4272 @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
4273 (SPKI)}.
4274
4275 @item --extract=@var{directory}
4276 @itemx -x @var{directory}
4277 Read a single-item archive as served by substitute servers
4278 (@pxref{Substitutes}) and extract it to @var{directory}. This is a
4279 low-level operation needed in only very narrow use cases; see below.
4280
4281 For example, the following command extracts the substitute for Emacs
4282 served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
4283
4284 @example
4285 $ wget -O - \
4286 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-emacs-24.5 \
4287 | bunzip2 | guix archive -x /tmp/emacs
4288 @end example
4289
4290 Single-item archives are different from multiple-item archives produced
4291 by @command{guix archive --export}; they contain a single store item,
4292 and they do @emph{not} embed a signature. Thus this operation does
4293 @emph{no} signature verification and its output should be considered
4294 unsafe.
4295
4296 The primary purpose of this operation is to facilitate inspection of
4297 archive contents coming from possibly untrusted substitute servers.
4298
4299 @end table
4300
4301
4302 @c *********************************************************************
4303 @node Development
4304 @chapter Development
4305
4306 @cindex software development
4307 If you are a software developer, Guix provides tools that you should find
4308 helpful---independently of the language you're developing in. This is what
4309 this chapter is about.
4310
4311 The @command{guix environment} command provides a convenient way to set up
4312 @dfn{development environments} containing all the dependencies and tools
4313 necessary to work on the software package of your choice. The @command{guix
4314 pack} command allows you to create @dfn{application bundles} that can be
4315 easily distributed to users who do not run Guix.
4316
4317 @menu
4318 * Invoking guix environment:: Setting up development environments.
4319 * Invoking guix pack:: Creating software bundles.
4320 @end menu
4321
4322 @node Invoking guix environment
4323 @section Invoking @command{guix environment}
4324
4325 @cindex reproducible build environments
4326 @cindex development environments
4327 @cindex @command{guix environment}
4328 @cindex environment, package build environment
4329 The purpose of @command{guix environment} is to assist hackers in
4330 creating reproducible development environments without polluting their
4331 package profile. The @command{guix environment} tool takes one or more
4332 packages, builds all of their inputs, and creates a shell
4333 environment to use them.
4334
4335 The general syntax is:
4336
4337 @example
4338 guix environment @var{options} @var{package}@dots{}
4339 @end example
4340
4341 The following example spawns a new shell set up for the development of
4342 GNU@tie{}Guile:
4343
4344 @example
4345 guix environment guile
4346 @end example
4347
4348 If the needed dependencies are not built yet, @command{guix environment}
4349 automatically builds them. The environment of the new shell is an augmented
4350 version of the environment that @command{guix environment} was run in.
4351 It contains the necessary search paths for building the given package
4352 added to the existing environment variables. To create a ``pure''
4353 environment, in which the original environment variables have been unset,
4354 use the @code{--pure} option@footnote{Users sometimes wrongfully augment
4355 environment variables such as @code{PATH} in their @file{~/.bashrc}
4356 file. As a consequence, when @code{guix environment} launches it, Bash
4357 may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
4358 environment variables. It is an error to define such environment
4359 variables in @file{.bashrc}; instead, they should be defined in
4360 @file{.bash_profile}, which is sourced only by log-in shells.
4361 @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
4362 details on Bash start-up files.}.
4363
4364 @vindex GUIX_ENVIRONMENT
4365 @command{guix environment} defines the @code{GUIX_ENVIRONMENT}
4366 variable in the shell it spawns; its value is the file name of the
4367 profile of this environment. This allows users to, say, define a
4368 specific prompt for development environments in their @file{.bashrc}
4369 (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
4370
4371 @example
4372 if [ -n "$GUIX_ENVIRONMENT" ]
4373 then
4374 export PS1="\u@@\h \w [dev]\$ "
4375 fi
4376 @end example
4377
4378 @noindent
4379 ...@: or to browse the profile:
4380
4381 @example
4382 $ ls "$GUIX_ENVIRONMENT/bin"
4383 @end example
4384
4385 Additionally, more than one package may be specified, in which case the
4386 union of the inputs for the given packages are used. For example, the
4387 command below spawns a shell where all of the dependencies of both Guile
4388 and Emacs are available:
4389
4390 @example
4391 guix environment guile emacs
4392 @end example
4393
4394 Sometimes an interactive shell session is not desired. An arbitrary
4395 command may be invoked by placing the @code{--} token to separate the
4396 command from the rest of the arguments:
4397
4398 @example
4399 guix environment guile -- make -j4
4400 @end example
4401
4402 In other situations, it is more convenient to specify the list of
4403 packages needed in the environment. For example, the following command
4404 runs @command{python} from an environment containing Python@tie{}2.7 and
4405 NumPy:
4406
4407 @example
4408 guix environment --ad-hoc python2-numpy python-2.7 -- python
4409 @end example
4410
4411 Furthermore, one might want the dependencies of a package and also some
4412 additional packages that are not build-time or runtime dependencies, but
4413 are useful when developing nonetheless. Because of this, the
4414 @code{--ad-hoc} flag is positional. Packages appearing before
4415 @code{--ad-hoc} are interpreted as packages whose dependencies will be
4416 added to the environment. Packages appearing after are interpreted as
4417 packages that will be added to the environment directly. For example,
4418 the following command creates a Guix development environment that
4419 additionally includes Git and strace:
4420
4421 @example
4422 guix environment guix --ad-hoc git strace
4423 @end example
4424
4425 Sometimes it is desirable to isolate the environment as much as
4426 possible, for maximal purity and reproducibility. In particular, when
4427 using Guix on a host distro that is not Guix System, it is desirable to
4428 prevent access to @file{/usr/bin} and other system-wide resources from
4429 the development environment. For example, the following command spawns
4430 a Guile REPL in a ``container'' where only the store and the current
4431 working directory are mounted:
4432
4433 @example
4434 guix environment --ad-hoc --container guile -- guile
4435 @end example
4436
4437 @quotation Note
4438 The @code{--container} option requires Linux-libre 3.19 or newer.
4439 @end quotation
4440
4441 The available options are summarized below.
4442
4443 @table @code
4444 @item --root=@var{file}
4445 @itemx -r @var{file}
4446 @cindex persistent environment
4447 @cindex garbage collector root, for environments
4448 Make @var{file} a symlink to the profile for this environment, and
4449 register it as a garbage collector root.
4450
4451 This is useful if you want to protect your environment from garbage
4452 collection, to make it ``persistent''.
4453
4454 When this option is omitted, the environment is protected from garbage
4455 collection only for the duration of the @command{guix environment}
4456 session. This means that next time you recreate the same environment,
4457 you could have to rebuild or re-download packages. @xref{Invoking guix
4458 gc}, for more on GC roots.
4459
4460 @item --expression=@var{expr}
4461 @itemx -e @var{expr}
4462 Create an environment for the package or list of packages that
4463 @var{expr} evaluates to.
4464
4465 For example, running:
4466
4467 @example
4468 guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
4469 @end example
4470
4471 starts a shell with the environment for this specific variant of the
4472 PETSc package.
4473
4474 Running:
4475
4476 @example
4477 guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
4478 @end example
4479
4480 starts a shell with all the base system packages available.
4481
4482 The above commands only use the default output of the given packages.
4483 To select other outputs, two element tuples can be specified:
4484
4485 @example
4486 guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
4487 @end example
4488
4489 @item --load=@var{file}
4490 @itemx -l @var{file}
4491 Create an environment for the package or list of packages that the code
4492 within @var{file} evaluates to.
4493
4494 As an example, @var{file} might contain a definition like this
4495 (@pxref{Defining Packages}):
4496
4497 @example
4498 @verbatiminclude environment-gdb.scm
4499 @end example
4500
4501 @item --manifest=@var{file}
4502 @itemx -m @var{file}
4503 Create an environment for the packages contained in the manifest object
4504 returned by the Scheme code in @var{file}.
4505
4506 This is similar to the same-named option in @command{guix package}
4507 (@pxref{profile-manifest, @option{--manifest}}) and uses the same
4508 manifest files.
4509
4510 @item --ad-hoc
4511 Include all specified packages in the resulting environment, as if an
4512 @i{ad hoc} package were defined with them as inputs. This option is
4513 useful for quickly creating an environment without having to write a
4514 package expression to contain the desired inputs.
4515
4516 For instance, the command:
4517
4518 @example
4519 guix environment --ad-hoc guile guile-sdl -- guile
4520 @end example
4521
4522 runs @command{guile} in an environment where Guile and Guile-SDL are
4523 available.
4524
4525 Note that this example implicitly asks for the default output of
4526 @code{guile} and @code{guile-sdl}, but it is possible to ask for a
4527 specific output---e.g., @code{glib:bin} asks for the @code{bin} output
4528 of @code{glib} (@pxref{Packages with Multiple Outputs}).
4529
4530 This option may be composed with the default behavior of @command{guix
4531 environment}. Packages appearing before @code{--ad-hoc} are interpreted
4532 as packages whose dependencies will be added to the environment, the
4533 default behavior. Packages appearing after are interpreted as packages
4534 that will be added to the environment directly.
4535
4536 @item --pure
4537 Unset existing environment variables when building the new environment, except
4538 those specified with @option{--preserve} (see below.) This has the effect of
4539 creating an environment in which search paths only contain package inputs.
4540
4541 @item --preserve=@var{regexp}
4542 @itemx -E @var{regexp}
4543 When used alongside @option{--pure}, preserve the environment variables
4544 matching @var{regexp}---in other words, put them on a ``white list'' of
4545 environment variables that must be preserved. This option can be repeated
4546 several times.
4547
4548 @example
4549 guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
4550 -- mpirun @dots{}
4551 @end example
4552
4553 This example runs @command{mpirun} in a context where the only environment
4554 variables defined are @code{PATH}, environment variables whose name starts
4555 with @code{SLURM}, as well as the usual ``precious'' variables (@code{HOME},
4556 @code{USER}, etc.)
4557
4558 @item --search-paths
4559 Display the environment variable definitions that make up the
4560 environment.
4561
4562 @item --system=@var{system}
4563 @itemx -s @var{system}
4564 Attempt to build for @var{system}---e.g., @code{i686-linux}.
4565
4566 @item --container
4567 @itemx -C
4568 @cindex container
4569 Run @var{command} within an isolated container. The current working
4570 directory outside the container is mapped inside the container.
4571 Additionally, unless overridden with @code{--user}, a dummy home
4572 directory is created that matches the current user's home directory, and
4573 @file{/etc/passwd} is configured accordingly.
4574
4575 The spawned process runs as the current user outside the container. Inside
4576 the container, it has the same UID and GID as the current user, unless
4577 @option{--user} is passed (see below.)
4578
4579 @item --network
4580 @itemx -N
4581 For containers, share the network namespace with the host system.
4582 Containers created without this flag only have access to the loopback
4583 device.
4584
4585 @item --link-profile
4586 @itemx -P
4587 For containers, link the environment profile to
4588 @file{~/.guix-profile} within the container. This is equivalent to
4589 running the command @command{ln -s $GUIX_ENVIRONMENT ~/.guix-profile}
4590 within the container. Linking will fail and abort the environment if
4591 the directory already exists, which will certainly be the case if
4592 @command{guix environment} was invoked in the user's home directory.
4593
4594 Certain packages are configured to look in
4595 @code{~/.guix-profile} for configuration files and data;@footnote{For
4596 example, the @code{fontconfig} package inspects
4597 @file{~/.guix-profile/share/fonts} for additional fonts.}
4598 @code{--link-profile} allows these programs to behave as expected within
4599 the environment.
4600
4601 @item --user=@var{user}
4602 @itemx -u @var{user}
4603 For containers, use the username @var{user} in place of the current
4604 user. The generated @file{/etc/passwd} entry within the container will
4605 contain the name @var{user}, the home directory will be
4606 @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
4607 the UID and GID inside the container are 1000. @var{user}
4608 need not exist on the system.
4609
4610 Additionally, any shared or exposed path (see @code{--share} and
4611 @code{--expose} respectively) whose target is within the current user's
4612 home directory will be remapped relative to @file{/home/USER}; this
4613 includes the automatic mapping of the current working directory.
4614
4615 @example
4616 # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
4617 cd $HOME/wd
4618 guix environment --container --user=foo \
4619 --expose=$HOME/test \
4620 --expose=/tmp/target=$HOME/target
4621 @end example
4622
4623 While this will limit the leaking of user identity through home paths
4624 and each of the user fields, this is only one useful component of a
4625 broader privacy/anonymity solution---not one in and of itself.
4626
4627 @item --expose=@var{source}[=@var{target}]
4628 For containers, expose the file system @var{source} from the host system
4629 as the read-only file system @var{target} within the container. If
4630 @var{target} is not specified, @var{source} is used as the target mount
4631 point in the container.
4632
4633 The example below spawns a Guile REPL in a container in which the user's
4634 home directory is accessible read-only via the @file{/exchange}
4635 directory:
4636
4637 @example
4638 guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
4639 @end example
4640
4641 @item --share=@var{source}[=@var{target}]
4642 For containers, share the file system @var{source} from the host system
4643 as the writable file system @var{target} within the container. If
4644 @var{target} is not specified, @var{source} is used as the target mount
4645 point in the container.
4646
4647 The example below spawns a Guile REPL in a container in which the user's
4648 home directory is accessible for both reading and writing via the
4649 @file{/exchange} directory:
4650
4651 @example
4652 guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
4653 @end example
4654 @end table
4655
4656 @command{guix environment}
4657 also supports all of the common build options that @command{guix
4658 build} supports (@pxref{Common Build Options}) as well as package
4659 transformation options (@pxref{Package Transformation Options}).
4660
4661 @node Invoking guix pack
4662 @section Invoking @command{guix pack}
4663
4664 Occasionally you want to pass software to people who are not (yet!)
4665 lucky enough to be using Guix. You'd tell them to run @command{guix
4666 package -i @var{something}}, but that's not possible in this case. This
4667 is where @command{guix pack} comes in.
4668
4669 @quotation Note
4670 If you are looking for ways to exchange binaries among machines that
4671 already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
4672 publish}, and @ref{Invoking guix archive}.
4673 @end quotation
4674
4675 @cindex pack
4676 @cindex bundle
4677 @cindex application bundle
4678 @cindex software bundle
4679 The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
4680 @dfn{software bundle}: it creates a tarball or some other archive
4681 containing the binaries of the software you're interested in, and all
4682 its dependencies. The resulting archive can be used on any machine that
4683 does not have Guix, and people can run the exact same binaries as those
4684 you have with Guix. The pack itself is created in a bit-reproducible
4685 fashion, so anyone can verify that it really contains the build results
4686 that you pretend to be shipping.
4687
4688 For example, to create a bundle containing Guile, Emacs, Geiser, and all
4689 their dependencies, you can run:
4690
4691 @example
4692 $ guix pack guile emacs geiser
4693 @dots{}
4694 /gnu/store/@dots{}-pack.tar.gz
4695 @end example
4696
4697 The result here is a tarball containing a @file{/gnu/store} directory
4698 with all the relevant packages. The resulting tarball contains a
4699 @dfn{profile} with the three packages of interest; the profile is the
4700 same as would be created by @command{guix package -i}. It is this
4701 mechanism that is used to create Guix's own standalone binary tarball
4702 (@pxref{Binary Installation}).
4703
4704 Users of this pack would have to run
4705 @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
4706 find inconvenient. To work around it, you can create, say, a
4707 @file{/opt/gnu/bin} symlink to the profile:
4708
4709 @example
4710 guix pack -S /opt/gnu/bin=bin guile emacs geiser
4711 @end example
4712
4713 @noindent
4714 That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
4715
4716 @cindex relocatable binaries, with @command{guix pack}
4717 What if the recipient of your pack does not have root privileges on
4718 their machine, and thus cannot unpack it in the root file system? In
4719 that case, you will want to use the @code{--relocatable} option (see
4720 below). This option produces @dfn{relocatable binaries}, meaning they
4721 they can be placed anywhere in the file system hierarchy: in the example
4722 above, users can unpack your tarball in their home directory and
4723 directly run @file{./opt/gnu/bin/guile}.
4724
4725 @cindex Docker, build an image with guix pack
4726 Alternatively, you can produce a pack in the Docker image format using
4727 the following command:
4728
4729 @example
4730 guix pack -f docker guile emacs geiser
4731 @end example
4732
4733 @noindent
4734 The result is a tarball that can be passed to the @command{docker load}
4735 command. See the
4736 @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
4737 documentation} for more information.
4738
4739 @cindex Singularity, build an image with guix pack
4740 @cindex SquashFS, build an image with guix pack
4741 Yet another option is to produce a SquashFS image with the following
4742 command:
4743
4744 @example
4745 guix pack -f squashfs guile emacs geiser
4746 @end example
4747
4748 @noindent
4749 The result is a SquashFS file system image that can either be mounted or
4750 directly be used as a file system container image with the
4751 @uref{http://singularity.lbl.gov, Singularity container execution
4752 environment}, using commands like @command{singularity shell} or
4753 @command{singularity exec}.
4754
4755 Several command-line options allow you to customize your pack:
4756
4757 @table @code
4758 @item --format=@var{format}
4759 @itemx -f @var{format}
4760 Produce a pack in the given @var{format}.
4761
4762 The available formats are:
4763
4764 @table @code
4765 @item tarball
4766 This is the default format. It produces a tarball containing all the
4767 specified binaries and symlinks.
4768
4769 @item docker
4770 This produces a tarball that follows the
4771 @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
4772 Docker Image Specification}.
4773
4774 @item squashfs
4775 This produces a SquashFS image containing all the specified binaries and
4776 symlinks, as well as empty mount points for virtual file systems like
4777 procfs.
4778 @end table
4779
4780 @cindex relocatable binaries
4781 @item --relocatable
4782 @itemx -R
4783 Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
4784 anywhere in the file system hierarchy and run from there.
4785
4786 When this option is passed once, the resulting binaries require support for
4787 @dfn{user namespaces} in the kernel Linux; when passed
4788 @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
4789 PRoot support, can be thought of as the abbreviation of ``Really
4790 Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to PRoot
4791 if user namespaces are unavailable, and essentially work anywhere---see below
4792 for the implications.
4793
4794 For example, if you create a pack containing Bash with:
4795
4796 @example
4797 guix pack -RR -S /mybin=bin bash
4798 @end example
4799
4800 @noindent
4801 ...@: you can copy that pack to a machine that lacks Guix, and from your
4802 home directory as a normal user, run:
4803
4804 @example
4805 tar xf pack.tar.gz
4806 ./mybin/sh
4807 @end example
4808
4809 @noindent
4810 In that shell, if you type @code{ls /gnu/store}, you'll notice that
4811 @file{/gnu/store} shows up and contains all the dependencies of
4812 @code{bash}, even though the machine actually lacks @file{/gnu/store}
4813 altogether! That is probably the simplest way to deploy Guix-built
4814 software on a non-Guix machine.
4815
4816 @quotation Note
4817 By default, relocatable binaries rely on the @dfn{user namespace} feature of
4818 the kernel Linux, which allows unprivileged users to mount or change root.
4819 Old versions of Linux did not support it, and some GNU/Linux distributions
4820 turn it off.
4821
4822 To produce relocatable binaries that work even in the absence of user
4823 namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
4824 case, binaries will try user namespace support and fall back to PRoot if user
4825 namespaces are not supported.
4826
4827 The @uref{https://proot-me.github.io/, PRoot} program provides the necessary
4828 support for file system virtualization. It achieves that by using the
4829 @code{ptrace} system call on the running program. This approach has the
4830 advantage to work without requiring special kernel support, but it incurs
4831 run-time overhead every time a system call is made.
4832 @end quotation
4833
4834 @item --expression=@var{expr}
4835 @itemx -e @var{expr}
4836 Consider the package @var{expr} evaluates to.
4837
4838 This has the same purpose as the same-named option in @command{guix
4839 build} (@pxref{Additional Build Options, @code{--expression} in
4840 @command{guix build}}).
4841
4842 @item --manifest=@var{file}
4843 @itemx -m @var{file}
4844 Use the packages contained in the manifest object returned by the Scheme
4845 code in @var{file}.
4846
4847 This has a similar purpose as the same-named option in @command{guix
4848 package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
4849 same manifest files. It allows you to define a collection of packages
4850 once and use it both for creating profiles and for creating archives
4851 for use on machines that do not have Guix installed. Note that you can
4852 specify @emph{either} a manifest file @emph{or} a list of packages,
4853 but not both.
4854
4855 @item --system=@var{system}
4856 @itemx -s @var{system}
4857 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
4858 the system type of the build host.
4859
4860 @item --target=@var{triplet}
4861 @cindex cross-compilation
4862 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
4863 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
4864 configuration triplets,, autoconf, Autoconf}).
4865
4866 @item --compression=@var{tool}
4867 @itemx -C @var{tool}
4868 Compress the resulting tarball using @var{tool}---one of @code{gzip},
4869 @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
4870
4871 @item --symlink=@var{spec}
4872 @itemx -S @var{spec}
4873 Add the symlinks specified by @var{spec} to the pack. This option can
4874 appear several times.
4875
4876 @var{spec} has the form @code{@var{source}=@var{target}}, where
4877 @var{source} is the symlink that will be created and @var{target} is the
4878 symlink target.
4879
4880 For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
4881 symlink pointing to the @file{bin} sub-directory of the profile.
4882
4883 @item --save-provenance
4884 Save provenance information for the packages passed on the command line.
4885 Provenance information includes the URL and commit of the channels in use
4886 (@pxref{Channels}).
4887
4888 Provenance information is saved in the
4889 @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
4890 usual package metadata---the name and version of each package, their
4891 propagated inputs, and so on. It is useful information to the recipient of
4892 the pack, who then knows how the pack was (supposedly) obtained.
4893
4894 This option is not enabled by default because, like timestamps, provenance
4895 information contributes nothing to the build process. In other words, there
4896 is an infinity of channel URLs and commit IDs that can lead to the same pack.
4897 Recording such ``silent'' metadata in the output thus potentially breaks the
4898 source-to-binary bitwise reproducibility property.
4899
4900 @item --localstatedir
4901 @itemx --profile-name=@var{name}
4902 Include the ``local state directory'', @file{/var/guix}, in the resulting
4903 pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
4904 profile---by default @var{name} is @code{guix-profile}, which corresponds to
4905 @file{~root/.guix-profile}.
4906
4907 @file{/var/guix} contains the store database (@pxref{The Store}) as well
4908 as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
4909 the pack means that the store is ``complete'' and manageable by Guix;
4910 not providing it pack means that the store is ``dead'': items cannot be
4911 added to it or removed from it after extraction of the pack.
4912
4913 One use case for this is the Guix self-contained binary tarball
4914 (@pxref{Binary Installation}).
4915
4916 @item --bootstrap
4917 Use the bootstrap binaries to build the pack. This option is only
4918 useful to Guix developers.
4919 @end table
4920
4921 In addition, @command{guix pack} supports all the common build options
4922 (@pxref{Common Build Options}) and all the package transformation
4923 options (@pxref{Package Transformation Options}).
4924
4925
4926 @c *********************************************************************
4927 @node Programming Interface
4928 @chapter Programming Interface
4929
4930 GNU Guix provides several Scheme programming interfaces (APIs) to
4931 define, build, and query packages. The first interface allows users to
4932 write high-level package definitions. These definitions refer to
4933 familiar packaging concepts, such as the name and version of a package,
4934 its build system, and its dependencies. These definitions can then be
4935 turned into concrete build actions.
4936
4937 Build actions are performed by the Guix daemon, on behalf of users. In a
4938 standard setup, the daemon has write access to the store---the
4939 @file{/gnu/store} directory---whereas users do not. The recommended
4940 setup also has the daemon perform builds in chroots, under a specific
4941 build users, to minimize interference with the rest of the system.
4942
4943 @cindex derivation
4944 Lower-level APIs are available to interact with the daemon and the
4945 store. To instruct the daemon to perform a build action, users actually
4946 provide it with a @dfn{derivation}. A derivation is a low-level
4947 representation of the build actions to be taken, and the environment in
4948 which they should occur---derivations are to package definitions what
4949 assembly is to C programs. The term ``derivation'' comes from the fact
4950 that build results @emph{derive} from them.
4951
4952 This chapter describes all these APIs in turn, starting from high-level
4953 package definitions.
4954
4955 @menu
4956 * Package Modules:: Packages from the programmer's viewpoint.
4957 * Defining Packages:: Defining new packages.
4958 * Build Systems:: Specifying how packages are built.
4959 * The Store:: Manipulating the package store.
4960 * Derivations:: Low-level interface to package derivations.
4961 * The Store Monad:: Purely functional interface to the store.
4962 * G-Expressions:: Manipulating build expressions.
4963 * Invoking guix repl:: Fiddling with Guix interactively.
4964 @end menu
4965
4966 @node Package Modules
4967 @section Package Modules
4968
4969 From a programming viewpoint, the package definitions of the
4970 GNU distribution are provided by Guile modules in the @code{(gnu packages
4971 @dots{})} name space@footnote{Note that packages under the @code{(gnu
4972 packages @dots{})} module name space are not necessarily ``GNU
4973 packages''. This module naming scheme follows the usual Guile module
4974 naming convention: @code{gnu} means that these modules are distributed
4975 as part of the GNU system, and @code{packages} identifies modules that
4976 define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
4977 Reference Manual}). For instance, the @code{(gnu packages emacs)}
4978 module exports a variable named @code{emacs}, which is bound to a
4979 @code{<package>} object (@pxref{Defining Packages}).
4980
4981 The @code{(gnu packages @dots{})} module name space is
4982 automatically scanned for packages by the command-line tools. For
4983 instance, when running @code{guix package -i emacs}, all the @code{(gnu
4984 packages @dots{})} modules are scanned until one that exports a package
4985 object whose name is @code{emacs} is found. This package search
4986 facility is implemented in the @code{(gnu packages)} module.
4987
4988 @cindex customization, of packages
4989 @cindex package module search path
4990 Users can store package definitions in modules with different
4991 names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
4992 name and module name must match. For instance, the @code{(my-packages
4993 emacs)} module must be stored in a @file{my-packages/emacs.scm} file
4994 relative to the load path specified with @option{--load-path} or
4995 @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
4996 guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
4997 these package definitions visible to the user interfaces:
4998
4999 @enumerate
5000 @item
5001 By adding the directory containing your package modules to the search path
5002 with the @code{-L} flag of @command{guix package} and other commands
5003 (@pxref{Common Build Options}), or by setting the @code{GUIX_PACKAGE_PATH}
5004 environment variable described below.
5005
5006 @item
5007 By defining a @dfn{channel} and configuring @command{guix pull} so that it
5008 pulls from it. A channel is essentially a Git repository containing package
5009 modules. @xref{Channels}, for more information on how to define and use
5010 channels.
5011 @end enumerate
5012
5013 @code{GUIX_PACKAGE_PATH} works similarly to other search path variables:
5014
5015 @defvr {Environment Variable} GUIX_PACKAGE_PATH
5016 This is a colon-separated list of directories to search for additional
5017 package modules. Directories listed in this variable take precedence
5018 over the own modules of the distribution.
5019 @end defvr
5020
5021 The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
5022 each package is built based solely on other packages in the
5023 distribution. The root of this dependency graph is a small set of
5024 @dfn{bootstrap binaries}, provided by the @code{(gnu packages
5025 bootstrap)} module. For more information on bootstrapping,
5026 @pxref{Bootstrapping}.
5027
5028 @node Defining Packages
5029 @section Defining Packages
5030
5031 The high-level interface to package definitions is implemented in the
5032 @code{(guix packages)} and @code{(guix build-system)} modules. As an
5033 example, the package definition, or @dfn{recipe}, for the GNU Hello
5034 package looks like this:
5035
5036 @example
5037 (define-module (gnu packages hello)
5038 #:use-module (guix packages)
5039 #:use-module (guix download)
5040 #:use-module (guix build-system gnu)
5041 #:use-module (guix licenses)
5042 #:use-module (gnu packages gawk))
5043
5044 (define-public hello
5045 (package
5046 (name "hello")
5047 (version "2.10")
5048 (source (origin
5049 (method url-fetch)
5050 (uri (string-append "mirror://gnu/hello/hello-" version
5051 ".tar.gz"))
5052 (sha256
5053 (base32
5054 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
5055 (build-system gnu-build-system)
5056 (arguments '(#:configure-flags '("--enable-silent-rules")))
5057 (inputs `(("gawk" ,gawk)))
5058 (synopsis "Hello, GNU world: An example GNU package")
5059 (description "Guess what GNU Hello prints!")
5060 (home-page "http://www.gnu.org/software/hello/")
5061 (license gpl3+)))
5062 @end example
5063
5064 @noindent
5065 Without being a Scheme expert, the reader may have guessed the meaning
5066 of the various fields here. This expression binds the variable
5067 @code{hello} to a @code{<package>} object, which is essentially a record
5068 (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
5069 This package object can be inspected using procedures found in the
5070 @code{(guix packages)} module; for instance, @code{(package-name hello)}
5071 returns---surprise!---@code{"hello"}.
5072
5073 With luck, you may be able to import part or all of the definition of
5074 the package you are interested in from another repository, using the
5075 @code{guix import} command (@pxref{Invoking guix import}).
5076
5077 In the example above, @var{hello} is defined in a module of its own,
5078 @code{(gnu packages hello)}. Technically, this is not strictly
5079 necessary, but it is convenient to do so: all the packages defined in
5080 modules under @code{(gnu packages @dots{})} are automatically known to
5081 the command-line tools (@pxref{Package Modules}).
5082
5083 There are a few points worth noting in the above package definition:
5084
5085 @itemize
5086 @item
5087 The @code{source} field of the package is an @code{<origin>} object
5088 (@pxref{origin Reference}, for the complete reference).
5089 Here, the @code{url-fetch} method from @code{(guix download)} is used,
5090 meaning that the source is a file to be downloaded over FTP or HTTP.
5091
5092 The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
5093 the GNU mirrors defined in @code{(guix download)}.
5094
5095 The @code{sha256} field specifies the expected SHA256 hash of the file
5096 being downloaded. It is mandatory, and allows Guix to check the
5097 integrity of the file. The @code{(base32 @dots{})} form introduces the
5098 base32 representation of the hash. You can obtain this information with
5099 @code{guix download} (@pxref{Invoking guix download}) and @code{guix
5100 hash} (@pxref{Invoking guix hash}).
5101
5102 @cindex patches
5103 When needed, the @code{origin} form can also have a @code{patches} field
5104 listing patches to be applied, and a @code{snippet} field giving a
5105 Scheme expression to modify the source code.
5106
5107 @item
5108 @cindex GNU Build System
5109 The @code{build-system} field specifies the procedure to build the
5110 package (@pxref{Build Systems}). Here, @var{gnu-build-system}
5111 represents the familiar GNU Build System, where packages may be
5112 configured, built, and installed with the usual @code{./configure &&
5113 make && make check && make install} command sequence.
5114
5115 @item
5116 The @code{arguments} field specifies options for the build system
5117 (@pxref{Build Systems}). Here it is interpreted by
5118 @var{gnu-build-system} as a request run @file{configure} with the
5119 @code{--enable-silent-rules} flag.
5120
5121 @cindex quote
5122 @cindex quoting
5123 @findex '
5124 @findex quote
5125 What about these quote (@code{'}) characters? They are Scheme syntax to
5126 introduce a literal list; @code{'} is synonymous with @code{quote}.
5127 @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
5128 for details. Here the value of the @code{arguments} field is a list of
5129 arguments passed to the build system down the road, as with @code{apply}
5130 (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
5131 Manual}).
5132
5133 The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
5134 (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
5135 @code{#:configure-flags} is a keyword used to pass a keyword argument
5136 to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
5137 Reference Manual}).
5138
5139 @item
5140 The @code{inputs} field specifies inputs to the build process---i.e.,
5141 build-time or run-time dependencies of the package. Here, we define an
5142 input called @code{"gawk"} whose value is that of the @var{gawk}
5143 variable; @var{gawk} is itself bound to a @code{<package>} object.
5144
5145 @cindex backquote (quasiquote)
5146 @findex `
5147 @findex quasiquote
5148 @cindex comma (unquote)
5149 @findex ,
5150 @findex unquote
5151 @findex ,@@
5152 @findex unquote-splicing
5153 Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
5154 us to introduce a literal list in the @code{inputs} field, while
5155 @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
5156 value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
5157 Reference Manual}).
5158
5159 Note that GCC, Coreutils, Bash, and other essential tools do not need to
5160 be specified as inputs here. Instead, @var{gnu-build-system} takes care
5161 of ensuring that they are present (@pxref{Build Systems}).
5162
5163 However, any other dependencies need to be specified in the
5164 @code{inputs} field. Any dependency not specified here will simply be
5165 unavailable to the build process, possibly leading to a build failure.
5166 @end itemize
5167
5168 @xref{package Reference}, for a full description of possible fields.
5169
5170 Once a package definition is in place, the
5171 package may actually be built using the @code{guix build} command-line
5172 tool (@pxref{Invoking guix build}), troubleshooting any build failures
5173 you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
5174 package definition using the @command{guix edit} command
5175 (@pxref{Invoking guix edit}).
5176 @xref{Packaging Guidelines}, for
5177 more information on how to test package definitions, and
5178 @ref{Invoking guix lint}, for information on how to check a definition
5179 for style conformance.
5180 @vindex GUIX_PACKAGE_PATH
5181 Lastly, @pxref{Channels}, for information
5182 on how to extend the distribution by adding your own package definitions
5183 in a ``channel''.
5184
5185 Finally, updating the package definition to a new upstream version
5186 can be partly automated by the @command{guix refresh} command
5187 (@pxref{Invoking guix refresh}).
5188
5189 Behind the scenes, a derivation corresponding to the @code{<package>}
5190 object is first computed by the @code{package-derivation} procedure.
5191 That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
5192 The build actions it prescribes may then be realized by using the
5193 @code{build-derivations} procedure (@pxref{The Store}).
5194
5195 @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
5196 Return the @code{<derivation>} object of @var{package} for @var{system}
5197 (@pxref{Derivations}).
5198
5199 @var{package} must be a valid @code{<package>} object, and @var{system}
5200 must be a string denoting the target system type---e.g.,
5201 @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
5202 must be a connection to the daemon, which operates on the store
5203 (@pxref{The Store}).
5204 @end deffn
5205
5206 @noindent
5207 @cindex cross-compilation
5208 Similarly, it is possible to compute a derivation that cross-builds a
5209 package for some other system:
5210
5211 @deffn {Scheme Procedure} package-cross-derivation @var{store} @
5212 @var{package} @var{target} [@var{system}]
5213 Return the @code{<derivation>} object of @var{package} cross-built from
5214 @var{system} to @var{target}.
5215
5216 @var{target} must be a valid GNU triplet denoting the target hardware
5217 and operating system, such as @code{"mips64el-linux-gnu"}
5218 (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
5219 Configure and Build System}).
5220 @end deffn
5221
5222 @cindex package transformations
5223 @cindex input rewriting
5224 @cindex dependency tree rewriting
5225 Packages can be manipulated in arbitrary ways. An example of a useful
5226 transformation is @dfn{input rewriting}, whereby the dependency tree of
5227 a package is rewritten by replacing specific inputs by others:
5228
5229 @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
5230 [@var{rewrite-name}]
5231 Return a procedure that, when passed a package, replaces its direct and
5232 indirect dependencies (but not its implicit inputs) according to
5233 @var{replacements}. @var{replacements} is a list of package pairs; the
5234 first element of each pair is the package to replace, and the second one
5235 is the replacement.
5236
5237 Optionally, @var{rewrite-name} is a one-argument procedure that takes
5238 the name of a package and returns its new name after rewrite.
5239 @end deffn
5240
5241 @noindent
5242 Consider this example:
5243
5244 @example
5245 (define libressl-instead-of-openssl
5246 ;; This is a procedure to replace OPENSSL by LIBRESSL,
5247 ;; recursively.
5248 (package-input-rewriting `((,openssl . ,libressl))))
5249
5250 (define git-with-libressl
5251 (libressl-instead-of-openssl git))
5252 @end example
5253
5254 @noindent
5255 Here we first define a rewriting procedure that replaces @var{openssl}
5256 with @var{libressl}. Then we use it to define a @dfn{variant} of the
5257 @var{git} package that uses @var{libressl} instead of @var{openssl}.
5258 This is exactly what the @option{--with-input} command-line option does
5259 (@pxref{Package Transformation Options, @option{--with-input}}).
5260
5261 The following variant of @code{package-input-rewriting} can match packages to
5262 be replaced by name rather than by identity.
5263
5264 @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements}
5265 Return a procedure that, given a package, applies the given @var{replacements} to
5266 all the package graph (excluding implicit inputs). @var{replacements} is a list of
5267 spec/procedures pair; each spec is a package specification such as @code{"gcc"} or
5268 @code{"guile@@2"}, and each procedure takes a matching package and returns a
5269 replacement for that package.
5270 @end deffn
5271
5272 The example above could be rewritten this way:
5273
5274 @example
5275 (define libressl-instead-of-openssl
5276 ;; Replace all the packages called "openssl" with LibreSSL.
5277 (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
5278 @end example
5279
5280 The key difference here is that, this time, packages are matched by spec and
5281 not by identity. In other words, any package in the graph that is called
5282 @code{openssl} will be replaced.
5283
5284 A more generic procedure to rewrite a package dependency graph is
5285 @code{package-mapping}: it supports arbitrary changes to nodes in the
5286 graph.
5287
5288 @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
5289 Return a procedure that, given a package, applies @var{proc} to all the packages
5290 depended on and returns the resulting package. The procedure stops recursion
5291 when @var{cut?} returns true for a given package.
5292 @end deffn
5293
5294 @menu
5295 * package Reference:: The package data type.
5296 * origin Reference:: The origin data type.
5297 @end menu
5298
5299
5300 @node package Reference
5301 @subsection @code{package} Reference
5302
5303 This section summarizes all the options available in @code{package}
5304 declarations (@pxref{Defining Packages}).
5305
5306 @deftp {Data Type} package
5307 This is the data type representing a package recipe.
5308
5309 @table @asis
5310 @item @code{name}
5311 The name of the package, as a string.
5312
5313 @item @code{version}
5314 The version of the package, as a string.
5315
5316 @item @code{source}
5317 An object telling how the source code for the package should be
5318 acquired. Most of the time, this is an @code{origin} object, which
5319 denotes a file fetched from the Internet (@pxref{origin Reference}). It
5320 can also be any other ``file-like'' object such as a @code{local-file},
5321 which denotes a file from the local file system (@pxref{G-Expressions,
5322 @code{local-file}}).
5323
5324 @item @code{build-system}
5325 The build system that should be used to build the package (@pxref{Build
5326 Systems}).
5327
5328 @item @code{arguments} (default: @code{'()})
5329 The arguments that should be passed to the build system. This is a
5330 list, typically containing sequential keyword-value pairs.
5331
5332 @item @code{inputs} (default: @code{'()})
5333 @itemx @code{native-inputs} (default: @code{'()})
5334 @itemx @code{propagated-inputs} (default: @code{'()})
5335 @cindex inputs, of packages
5336 These fields list dependencies of the package. Each one is a list of
5337 tuples, where each tuple has a label for the input (a string) as its
5338 first element, a package, origin, or derivation as its second element,
5339 and optionally the name of the output thereof that should be used, which
5340 defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
5341 more on package outputs). For example, the list below specifies three
5342 inputs:
5343
5344 @example
5345 `(("libffi" ,libffi)
5346 ("libunistring" ,libunistring)
5347 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
5348 @end example
5349
5350 @cindex cross compilation, package dependencies
5351 The distinction between @code{native-inputs} and @code{inputs} is
5352 necessary when considering cross-compilation. When cross-compiling,
5353 dependencies listed in @code{inputs} are built for the @emph{target}
5354 architecture; conversely, dependencies listed in @code{native-inputs}
5355 are built for the architecture of the @emph{build} machine.
5356
5357 @code{native-inputs} is typically used to list tools needed at
5358 build time, but not at run time, such as Autoconf, Automake, pkg-config,
5359 Gettext, or Bison. @command{guix lint} can report likely mistakes in
5360 this area (@pxref{Invoking guix lint}).
5361
5362 @anchor{package-propagated-inputs}
5363 Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
5364 specified packages will be automatically installed alongside the package
5365 they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
5366 package}}, for information on how @command{guix package} deals with
5367 propagated inputs.)
5368
5369 For example this is necessary when a C/C++ library needs headers of
5370 another library to compile, or when a pkg-config file refers to another
5371 one @i{via} its @code{Requires} field.
5372
5373 Another example where @code{propagated-inputs} is useful is for languages
5374 that lack a facility to record the run-time search path akin to the
5375 @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
5376 more. To ensure that libraries written in those languages can find
5377 library code they depend on at run time, run-time dependencies must be
5378 listed in @code{propagated-inputs} rather than @code{inputs}.
5379
5380 @item @code{outputs} (default: @code{'("out")})
5381 The list of output names of the package. @xref{Packages with Multiple
5382 Outputs}, for typical uses of additional outputs.
5383
5384 @item @code{native-search-paths} (default: @code{'()})
5385 @itemx @code{search-paths} (default: @code{'()})
5386 A list of @code{search-path-specification} objects describing
5387 search-path environment variables honored by the package.
5388
5389 @item @code{replacement} (default: @code{#f})
5390 This must be either @code{#f} or a package object that will be used as a
5391 @dfn{replacement} for this package. @xref{Security Updates, grafts},
5392 for details.
5393
5394 @item @code{synopsis}
5395 A one-line description of the package.
5396
5397 @item @code{description}
5398 A more elaborate description of the package.
5399
5400 @item @code{license}
5401 @cindex license, of packages
5402 The license of the package; a value from @code{(guix licenses)},
5403 or a list of such values.
5404
5405 @item @code{home-page}
5406 The URL to the home-page of the package, as a string.
5407
5408 @item @code{supported-systems} (default: @var{%supported-systems})
5409 The list of systems supported by the package, as strings of the form
5410 @code{architecture-kernel}, for example @code{"x86_64-linux"}.
5411
5412 @item @code{maintainers} (default: @code{'()})
5413 The list of maintainers of the package, as @code{maintainer} objects.
5414
5415 @item @code{location} (default: source location of the @code{package} form)
5416 The source location of the package. It is useful to override this when
5417 inheriting from another package, in which case this field is not
5418 automatically corrected.
5419 @end table
5420 @end deftp
5421
5422 @deffn {Scheme Syntax} this-package
5423 When used in the @emph{lexical scope} of a package field definition, this
5424 identifier resolves to the package being defined.
5425
5426 The example below shows how to add a package as a native input of itself when
5427 cross-compiling:
5428
5429 @example
5430 (package
5431 (name "guile")
5432 ;; ...
5433
5434 ;; When cross-compiled, Guile, for example, depends on
5435 ;; a native version of itself. Add it here.
5436 (native-inputs (if (%current-target-system)
5437 `(("self" ,this-package))
5438 '())))
5439 @end example
5440
5441 It is an error to refer to @code{this-package} outside a package definition.
5442 @end deffn
5443
5444 @node origin Reference
5445 @subsection @code{origin} Reference
5446
5447 This section summarizes all the options available in @code{origin}
5448 declarations (@pxref{Defining Packages}).
5449
5450 @deftp {Data Type} origin
5451 This is the data type representing a source code origin.
5452
5453 @table @asis
5454 @item @code{uri}
5455 An object containing the URI of the source. The object type depends on
5456 the @code{method} (see below). For example, when using the
5457 @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
5458 values are: a URL represented as a string, or a list thereof.
5459
5460 @item @code{method}
5461 A procedure that handles the URI.
5462
5463 Examples include:
5464
5465 @table @asis
5466 @item @var{url-fetch} from @code{(guix download)}
5467 download a file from the HTTP, HTTPS, or FTP URL specified in the
5468 @code{uri} field;
5469
5470 @vindex git-fetch
5471 @item @var{git-fetch} from @code{(guix git-download)}
5472 clone the Git version control repository, and check out the revision
5473 specified in the @code{uri} field as a @code{git-reference} object; a
5474 @code{git-reference} looks like this:
5475
5476 @example
5477 (git-reference
5478 (url "git://git.debian.org/git/pkg-shadow/shadow")
5479 (commit "v4.1.5.1"))
5480 @end example
5481 @end table
5482
5483 @item @code{sha256}
5484 A bytevector containing the SHA-256 hash of the source. Typically the
5485 @code{base32} form is used here to generate the bytevector from a
5486 base-32 string.
5487
5488 You can obtain this information using @code{guix download}
5489 (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
5490 guix hash}).
5491
5492 @item @code{file-name} (default: @code{#f})
5493 The file name under which the source code should be saved. When this is
5494 @code{#f}, a sensible default value will be used in most cases. In case
5495 the source is fetched from a URL, the file name from the URL will be
5496 used. For version control checkouts, it is recommended to provide the
5497 file name explicitly because the default is not very descriptive.
5498
5499 @item @code{patches} (default: @code{'()})
5500 A list of file names, origins, or file-like objects (@pxref{G-Expressions,
5501 file-like objects}) pointing to patches to be applied to the source.
5502
5503 This list of patches must be unconditional. In particular, it cannot
5504 depend on the value of @code{%current-system} or
5505 @code{%current-target-system}.
5506
5507 @item @code{snippet} (default: @code{#f})
5508 A G-expression (@pxref{G-Expressions}) or S-expression that will be run
5509 in the source directory. This is a convenient way to modify the source,
5510 sometimes more convenient than a patch.
5511
5512 @item @code{patch-flags} (default: @code{'("-p1")})
5513 A list of command-line flags that should be passed to the @code{patch}
5514 command.
5515
5516 @item @code{patch-inputs} (default: @code{#f})
5517 Input packages or derivations to the patching process. When this is
5518 @code{#f}, the usual set of inputs necessary for patching are provided,
5519 such as GNU@tie{}Patch.
5520
5521 @item @code{modules} (default: @code{'()})
5522 A list of Guile modules that should be loaded during the patching
5523 process and while running the code in the @code{snippet} field.
5524
5525 @item @code{patch-guile} (default: @code{#f})
5526 The Guile package that should be used in the patching process. When
5527 this is @code{#f}, a sensible default is used.
5528 @end table
5529 @end deftp
5530
5531
5532 @node Build Systems
5533 @section Build Systems
5534
5535 @cindex build system
5536 Each package definition specifies a @dfn{build system} and arguments for
5537 that build system (@pxref{Defining Packages}). This @code{build-system}
5538 field represents the build procedure of the package, as well as implicit
5539 dependencies of that build procedure.
5540
5541 Build systems are @code{<build-system>} objects. The interface to
5542 create and manipulate them is provided by the @code{(guix build-system)}
5543 module, and actual build systems are exported by specific modules.
5544
5545 @cindex bag (low-level package representation)
5546 Under the hood, build systems first compile package objects to
5547 @dfn{bags}. A @dfn{bag} is like a package, but with less
5548 ornamentation---in other words, a bag is a lower-level representation of
5549 a package, which includes all the inputs of that package, including some
5550 that were implicitly added by the build system. This intermediate
5551 representation is then compiled to a derivation (@pxref{Derivations}).
5552
5553 Build systems accept an optional list of @dfn{arguments}. In package
5554 definitions, these are passed @i{via} the @code{arguments} field
5555 (@pxref{Defining Packages}). They are typically keyword arguments
5556 (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
5557 Guile Reference Manual}). The value of these arguments is usually
5558 evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
5559 by the daemon (@pxref{Derivations}).
5560
5561 The main build system is @var{gnu-build-system}, which implements the
5562 standard build procedure for GNU and many other packages. It
5563 is provided by the @code{(guix build-system gnu)} module.
5564
5565 @defvr {Scheme Variable} gnu-build-system
5566 @var{gnu-build-system} represents the GNU Build System, and variants
5567 thereof (@pxref{Configuration, configuration and makefile conventions,,
5568 standards, GNU Coding Standards}).
5569
5570 @cindex build phases
5571 In a nutshell, packages using it are configured, built, and installed with
5572 the usual @code{./configure && make && make check && make install}
5573 command sequence. In practice, a few additional steps are often needed.
5574 All these steps are split up in separate @dfn{phases},
5575 notably@footnote{Please see the @code{(guix build gnu-build-system)}
5576 modules for more details about the build phases.}:
5577
5578 @table @code
5579 @item unpack
5580 Unpack the source tarball, and change the current directory to the
5581 extracted source tree. If the source is actually a directory, copy it
5582 to the build tree, and enter that directory.
5583
5584 @item patch-source-shebangs
5585 Patch shebangs encountered in source files so they refer to the right
5586 store file names. For instance, this changes @code{#!/bin/sh} to
5587 @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
5588
5589 @item configure
5590 Run the @file{configure} script with a number of default options, such
5591 as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
5592 by the @code{#:configure-flags} argument.
5593
5594 @item build
5595 Run @code{make} with the list of flags specified with
5596 @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
5597 (the default), build with @code{make -j}.
5598
5599 @item check
5600 Run @code{make check}, or some other target specified with
5601 @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
5602 @code{#:parallel-tests?} argument is true (the default), run @code{make
5603 check -j}.
5604
5605 @item install
5606 Run @code{make install} with the flags listed in @code{#:make-flags}.
5607
5608 @item patch-shebangs
5609 Patch shebangs on the installed executable files.
5610
5611 @item strip
5612 Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
5613 is false), copying them to the @code{debug} output when available
5614 (@pxref{Installing Debugging Files}).
5615 @end table
5616
5617 @vindex %standard-phases
5618 The build-side module @code{(guix build gnu-build-system)} defines
5619 @var{%standard-phases} as the default list of build phases.
5620 @var{%standard-phases} is a list of symbol/procedure pairs, where the
5621 procedure implements the actual phase.
5622
5623 The list of phases used for a particular package can be changed with the
5624 @code{#:phases} parameter. For instance, passing:
5625
5626 @example
5627 #:phases (modify-phases %standard-phases (delete 'configure))
5628 @end example
5629
5630 means that all the phases described above will be used, except the
5631 @code{configure} phase.
5632
5633 In addition, this build system ensures that the ``standard'' environment
5634 for GNU packages is available. This includes tools such as GCC, libc,
5635 Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
5636 build-system gnu)} module for a complete list). We call these the
5637 @dfn{implicit inputs} of a package, because package definitions do not
5638 have to mention them.
5639 @end defvr
5640
5641 Other @code{<build-system>} objects are defined to support other
5642 conventions and tools used by free software packages. They inherit most
5643 of @var{gnu-build-system}, and differ mainly in the set of inputs
5644 implicitly added to the build process, and in the list of phases
5645 executed. Some of these build systems are listed below.
5646
5647 @defvr {Scheme Variable} ant-build-system
5648 This variable is exported by @code{(guix build-system ant)}. It
5649 implements the build procedure for Java packages that can be built with
5650 @url{http://ant.apache.org/, Ant build tool}.
5651
5652 It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
5653 provided by the @code{icedtea} package to the set of inputs. Different
5654 packages can be specified with the @code{#:ant} and @code{#:jdk}
5655 parameters, respectively.
5656
5657 When the original package does not provide a suitable Ant build file,
5658 the parameter @code{#:jar-name} can be used to generate a minimal Ant
5659 build file @file{build.xml} with tasks to build the specified jar
5660 archive. In this case the parameter @code{#:source-dir} can be used to
5661 specify the source sub-directory, defaulting to ``src''.
5662
5663 The @code{#:main-class} parameter can be used with the minimal ant
5664 buildfile to specify the main class of the resulting jar. This makes the
5665 jar file executable. The @code{#:test-include} parameter can be used to
5666 specify the list of junit tests to run. It defaults to
5667 @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
5668 disable some tests. It defaults to @code{(list "**/Abstract*.java")},
5669 because abstract classes cannot be run as tests.
5670
5671 The parameter @code{#:build-target} can be used to specify the Ant task
5672 that should be run during the @code{build} phase. By default the
5673 ``jar'' task will be run.
5674
5675 @end defvr
5676
5677 @defvr {Scheme Variable} android-ndk-build-system
5678 @cindex Android distribution
5679 @cindex Android NDK build system
5680 This variable is exported by @code{(guix build-system android-ndk)}. It
5681 implements a build procedure for Android NDK (native development kit)
5682 packages using a Guix-specific build process.
5683
5684 The build system assumes that packages install their public interface
5685 (header) files to the subdirectory "include" of the "out" output and
5686 their libraries to the subdirectory "lib" of the "out" output.
5687
5688 It's also assumed that the union of all the dependencies of a package
5689 has no conflicting files.
5690
5691 For the time being, cross-compilation is not supported - so right now
5692 the libraries and header files are assumed to be host tools.
5693
5694 @end defvr
5695
5696 @defvr {Scheme Variable} asdf-build-system/source
5697 @defvrx {Scheme Variable} asdf-build-system/sbcl
5698 @defvrx {Scheme Variable} asdf-build-system/ecl
5699
5700 These variables, exported by @code{(guix build-system asdf)}, implement
5701 build procedures for Common Lisp packages using
5702 @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
5703 definition facility for Common Lisp programs and libraries.
5704
5705 The @code{asdf-build-system/source} system installs the packages in
5706 source form, and can be loaded using any common lisp implementation, via
5707 ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
5708 systems in the format which a particular implementation understands.
5709 These build systems can also be used to produce executable programs, or
5710 lisp images which contain a set of packages pre-loaded.
5711
5712 The build system uses naming conventions. For binary packages, the
5713 package name should be prefixed with the lisp implementation, such as
5714 @code{sbcl-} for @code{asdf-build-system/sbcl}.
5715
5716 Additionally, the corresponding source package should be labeled using
5717 the same convention as python packages (see @ref{Python Modules}), using
5718 the @code{cl-} prefix.
5719
5720 For binary packages, each system should be defined as a Guix package.
5721 If one package @code{origin} contains several systems, package variants
5722 can be created in order to build all the systems. Source packages,
5723 which use @code{asdf-build-system/source}, may contain several systems.
5724
5725 In order to create executable programs and images, the build-side
5726 procedures @code{build-program} and @code{build-image} can be used.
5727 They should be called in a build phase after the @code{create-symlinks}
5728 phase, so that the system which was just built can be used within the
5729 resulting image. @code{build-program} requires a list of Common Lisp
5730 expressions to be passed as the @code{#:entry-program} argument.
5731
5732 If the system is not defined within its own @code{.asd} file of the same
5733 name, then the @code{#:asd-file} parameter should be used to specify
5734 which file the system is defined in. Furthermore, if the package
5735 defines a system for its tests in a separate file, it will be loaded
5736 before the tests are run if it is specified by the
5737 @code{#:test-asd-file} parameter. If it is not set, the files
5738 @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
5739 and @code{test.asd} will be tried if they exist.
5740
5741 If for some reason the package must be named in a different way than the
5742 naming conventions suggest, the @code{#:asd-system-name} parameter can
5743 be used to specify the name of the system.
5744
5745 @end defvr
5746
5747 @defvr {Scheme Variable} cargo-build-system
5748 @cindex Rust programming language
5749 @cindex Cargo (Rust build system)
5750 This variable is exported by @code{(guix build-system cargo)}. It
5751 supports builds of packages using Cargo, the build tool of the
5752 @uref{https://www.rust-lang.org, Rust programming language}.
5753
5754 In its @code{configure} phase, this build system replaces dependencies
5755 specified in the @file{Carto.toml} file with inputs to the Guix package.
5756 The @code{install} phase installs the binaries, and it also installs the
5757 source code and @file{Cargo.toml} file.
5758 @end defvr
5759
5760 @cindex Clojure (programming language)
5761 @cindex simple Clojure build system
5762 @defvr {Scheme Variable} clojure-build-system
5763 This variable is exported by @code{(guix build-system clojure)}. It implements
5764 a simple build procedure for @uref{https://clojure.org/, Clojure} packages
5765 using plain old @code{compile} in Clojure. Cross-compilation is not supported
5766 yet.
5767
5768 It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
5769 Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
5770 @code{#:zip} parameters, respectively.
5771
5772 A list of source directories, test directories and jar names can be specified
5773 with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
5774 parameters, respectively. Compile directory and main class can be specified
5775 with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
5776 Other parameters are documented below.
5777
5778 This build system is an extension of @var{ant-build-system}, but with the
5779 following phases changed:
5780
5781 @table @code
5782
5783 @item build
5784 This phase calls @code{compile} in Clojure to compile source files and runs
5785 @command{jar} to create jars from both source files and compiled files
5786 according to the include list and exclude list specified in
5787 @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
5788 has priority over the include list. These lists consist of symbols
5789 representing Clojure libraries or the special keyword @code{#:all} representing
5790 all Clojure libraries found under the source directories. The parameter
5791 @code{#:omit-source?} decides if source should be included into the jars.
5792
5793 @item check
5794 This phase runs tests according to the include list and exclude list specified
5795 in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
5796 meanings are analogous to that of @code{#:aot-include} and
5797 @code{#:aot-exclude}, except that the special keyword @code{#:all} now
5798 stands for all Clojure libraries found under the test directories. The
5799 parameter @code{#:tests?} decides if tests should be run.
5800
5801 @item install
5802 This phase installs all jars built previously.
5803 @end table
5804
5805 Apart from the above, this build system also contains an additional phase:
5806
5807 @table @code
5808
5809 @item install-doc
5810 This phase installs all top-level files with base name matching
5811 @var{%doc-regex}. A different regex can be specified with the
5812 @code{#:doc-regex} parameter. All files (recursively) inside the documentation
5813 directories specified in @code{#:doc-dirs} are installed as well.
5814 @end table
5815 @end defvr
5816
5817 @defvr {Scheme Variable} cmake-build-system
5818 This variable is exported by @code{(guix build-system cmake)}. It
5819 implements the build procedure for packages using the
5820 @url{http://www.cmake.org, CMake build tool}.
5821
5822 It automatically adds the @code{cmake} package to the set of inputs.
5823 Which package is used can be specified with the @code{#:cmake}
5824 parameter.
5825
5826 The @code{#:configure-flags} parameter is taken as a list of flags
5827 passed to the @command{cmake} command. The @code{#:build-type}
5828 parameter specifies in abstract terms the flags passed to the compiler;
5829 it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
5830 debugging information''), which roughly means that code is compiled with
5831 @code{-O2 -g}, as is the case for Autoconf-based packages by default.
5832 @end defvr
5833
5834 @defvr {Scheme Variable} dune-build-system
5835 This variable is exported by @code{(guix build-system dune)}. It
5836 supports builds of packages using @uref{https://dune.build/, Dune}, a build
5837 tool for the OCaml programming language. It is implemented as an extension
5838 of the @code{ocaml-build-system} which is described below. As such, the
5839 @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
5840 system.
5841
5842 It automatically adds the @code{dune} package to the set of inputs.
5843 Which package is used can be specified with the @code{#:dune}
5844 parameter.
5845
5846 There is no @code{configure} phase because dune packages typically don't
5847 need to be configured. The @code{#:build-flags} parameter is taken as a
5848 list of flags passed to the @code{dune} command during the build.
5849
5850 The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
5851 command instead of the more recent @code{dune} command while building
5852 a package. Its default value is @code{#f}.
5853
5854 The @code{#:package} parameter can be passed to specify a package name, which
5855 is useful when a package contains multiple packages and you want to build
5856 only one of them. This is equivalent to passing the @code{-p} argument to
5857 @code{dune}.
5858 @end defvr
5859
5860 @defvr {Scheme Variable} go-build-system
5861 This variable is exported by @code{(guix build-system go)}. It
5862 implements a build procedure for Go packages using the standard
5863 @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
5864 Go build mechanisms}.
5865
5866 The user is expected to provide a value for the key @code{#:import-path}
5867 and, in some cases, @code{#:unpack-path}. The
5868 @url{https://golang.org/doc/code.html#ImportPaths, import path}
5869 corresponds to the file system path expected by the package's build
5870 scripts and any referring packages, and provides a unique way to
5871 refer to a Go package. It is typically based on a combination of the
5872 package source code's remote URI and file system hierarchy structure. In
5873 some cases, you will need to unpack the package's source code to a
5874 different directory structure than the one indicated by the import path,
5875 and @code{#:unpack-path} should be used in such cases.
5876
5877 Packages that provide Go libraries should install their source code into
5878 the built output. The key @code{#:install-source?}, which defaults to
5879 @code{#t}, controls whether or not the source code is installed. It can
5880 be set to @code{#f} for packages that only provide executable files.
5881 @end defvr
5882
5883 @defvr {Scheme Variable} glib-or-gtk-build-system
5884 This variable is exported by @code{(guix build-system glib-or-gtk)}. It
5885 is intended for use with packages making use of GLib or GTK+.
5886
5887 This build system adds the following two phases to the ones defined by
5888 @var{gnu-build-system}:
5889
5890 @table @code
5891 @item glib-or-gtk-wrap
5892 The phase @code{glib-or-gtk-wrap} ensures that programs in
5893 @file{bin/} are able to find GLib ``schemas'' and
5894 @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
5895 modules}. This is achieved by wrapping the programs in launch scripts
5896 that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
5897 environment variables.
5898
5899 It is possible to exclude specific package outputs from that wrapping
5900 process by listing their names in the
5901 @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
5902 when an output is known not to contain any GLib or GTK+ binaries, and
5903 where wrapping would gratuitously add a dependency of that output on
5904 GLib and GTK+.
5905
5906 @item glib-or-gtk-compile-schemas
5907 The phase @code{glib-or-gtk-compile-schemas} makes sure that all
5908 @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
5909 GSettings schemas} of GLib are compiled. Compilation is performed by the
5910 @command{glib-compile-schemas} program. It is provided by the package
5911 @code{glib:bin} which is automatically imported by the build system.
5912 The @code{glib} package providing @command{glib-compile-schemas} can be
5913 specified with the @code{#:glib} parameter.
5914 @end table
5915
5916 Both phases are executed after the @code{install} phase.
5917 @end defvr
5918
5919 @defvr {Scheme Variable} guile-build-system
5920 This build system is for Guile packages that consist exclusively of Scheme
5921 code and that are so lean that they don't even have a makefile, let alone a
5922 @file{configure} script. It compiles Scheme code using @command{guild
5923 compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
5924 installs the @file{.scm} and @file{.go} files in the right place. It also
5925 installs documentation.
5926
5927 This build system supports cross-compilation by using the @code{--target}
5928 option of @command{guild compile}.
5929
5930 Packages built with @code{guile-build-system} must provide a Guile package in
5931 their @code{native-inputs} field.
5932 @end defvr
5933
5934 @defvr {Scheme Variable} minify-build-system
5935 This variable is exported by @code{(guix build-system minify)}. It
5936 implements a minification procedure for simple JavaScript packages.
5937
5938 It adds @code{uglify-js} to the set of inputs and uses it to compress
5939 all JavaScript files in the @file{src} directory. A different minifier
5940 package can be specified with the @code{#:uglify-js} parameter, but it
5941 is expected that the package writes the minified code to the standard
5942 output.
5943
5944 When the input JavaScript files are not all located in the @file{src}
5945 directory, the parameter @code{#:javascript-files} can be used to
5946 specify a list of file names to feed to the minifier.
5947 @end defvr
5948
5949 @defvr {Scheme Variable} ocaml-build-system
5950 This variable is exported by @code{(guix build-system ocaml)}. It implements
5951 a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
5952 of choosing the correct set of commands to run for each package. OCaml
5953 packages can expect many different commands to be run. This build system will
5954 try some of them.
5955
5956 When the package has a @file{setup.ml} file present at the top-level, it will
5957 run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
5958 @code{ocaml setup.ml -install}. The build system will assume that this file
5959 was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
5960 care of setting the prefix and enabling tests if they are not disabled. You
5961 can pass configure and build flags with the @code{#:configure-flags} and
5962 @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
5963 set of flags used to enable tests. The @code{#:use-make?} key can be used to
5964 bypass this system in the build and install phases.
5965
5966 When the package has a @file{configure} file, it is assumed that it is a
5967 hand-made configure script that requires a different argument format than
5968 in the @code{gnu-build-system}. You can add more flags with the
5969 @code{#:configure-flags} key.
5970
5971 When the package has a @file{Makefile} file (or @code{#:use-make?} is
5972 @code{#t}), it will be used and more flags can be passed to the build and
5973 install phases with the @code{#:make-flags} key.
5974
5975 Finally, some packages do not have these files and use a somewhat standard
5976 location for its build system. In that case, the build system will run
5977 @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
5978 providing the path to the required findlib module. Additional flags can
5979 be passed via the @code{#:build-flags} key. Install is taken care of by
5980 @command{opam-installer}. In this case, the @code{opam} package must
5981 be added to the @code{native-inputs} field of the package definition.
5982
5983 Note that most OCaml packages assume they will be installed in the same
5984 directory as OCaml, which is not what we want in guix. In particular, they
5985 will install @file{.so} files in their module's directory, which is usually
5986 fine because it is in the OCaml compiler directory. In guix though, these
5987 libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
5988 variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
5989 @file{.so} libraries should be installed.
5990 @end defvr
5991
5992 @defvr {Scheme Variable} python-build-system
5993 This variable is exported by @code{(guix build-system python)}. It
5994 implements the more or less standard build procedure used by Python
5995 packages, which consists in running @code{python setup.py build} and
5996 then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
5997
5998 For packages that install stand-alone Python programs under @code{bin/},
5999 it takes care of wrapping these programs so that their @code{PYTHONPATH}
6000 environment variable points to all the Python libraries they depend on.
6001
6002 Which Python package is used to perform the build can be specified with
6003 the @code{#:python} parameter. This is a useful way to force a package
6004 to be built for a specific version of the Python interpreter, which
6005 might be necessary if the package is only compatible with a single
6006 interpreter version.
6007
6008 By default guix calls @code{setup.py} under control of
6009 @code{setuptools}, much like @command{pip} does. Some packages are not
6010 compatible with setuptools (and pip), thus you can disable this by
6011 setting the @code{#:use-setuptools} parameter to @code{#f}.
6012 @end defvr
6013
6014 @defvr {Scheme Variable} perl-build-system
6015 This variable is exported by @code{(guix build-system perl)}. It
6016 implements the standard build procedure for Perl packages, which either
6017 consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
6018 followed by @code{Build} and @code{Build install}; or in running
6019 @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
6020 @code{make} and @code{make install}, depending on which of
6021 @code{Build.PL} or @code{Makefile.PL} is present in the package
6022 distribution. Preference is given to the former if both @code{Build.PL}
6023 and @code{Makefile.PL} exist in the package distribution. This
6024 preference can be reversed by specifying @code{#t} for the
6025 @code{#:make-maker?} parameter.
6026
6027 The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
6028 passes flags specified by the @code{#:make-maker-flags} or
6029 @code{#:module-build-flags} parameter, respectively.
6030
6031 Which Perl package is used can be specified with @code{#:perl}.
6032 @end defvr
6033
6034 @defvr {Scheme Variable} r-build-system
6035 This variable is exported by @code{(guix build-system r)}. It
6036 implements the build procedure used by @uref{http://r-project.org, R}
6037 packages, which essentially is little more than running @code{R CMD
6038 INSTALL --library=/gnu/store/@dots{}} in an environment where
6039 @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
6040 are run after installation using the R function
6041 @code{tools::testInstalledPackage}.
6042 @end defvr
6043
6044 @defvr {Scheme Variable} rakudo-build-system
6045 This variable is exported by @code{(guix build-system rakudo)} It
6046 implements the build procedure used by @uref{https://rakudo.org/,
6047 Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
6048 package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
6049 installs the binaries, library files and the resources, as well as wrap
6050 the files under the @code{bin/} directory. Tests can be skipped by
6051 passing @code{#f} to the @code{tests?} parameter.
6052
6053 Which rakudo package is used can be specified with @code{rakudo}.
6054 Which perl6-tap-harness package used for the tests can be specified with
6055 @code{#:prove6} or removed by passing @code{#f} to the
6056 @code{with-prove6?} parameter.
6057 Which perl6-zef package used for tests and installing can be specified
6058 with @code{#:zef} or removed by passing @code{#f} to the
6059 @code{with-zef?} parameter.
6060 @end defvr
6061
6062 @defvr {Scheme Variable} texlive-build-system
6063 This variable is exported by @code{(guix build-system texlive)}. It is
6064 used to build TeX packages in batch mode with a specified engine. The
6065 build system sets the @code{TEXINPUTS} variable to find all TeX source
6066 files in the inputs.
6067
6068 By default it runs @code{luatex} on all files ending on @code{ins}. A
6069 different engine and format can be specified with the
6070 @code{#:tex-format} argument. Different build targets can be specified
6071 with the @code{#:build-targets} argument, which expects a list of file
6072 names. The build system adds only @code{texlive-bin} and
6073 @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
6074 inputs. Both can be overridden with the arguments @code{#:texlive-bin}
6075 and @code{#:texlive-latex-base}, respectively.
6076
6077 The @code{#:tex-directory} parameter tells the build system where to
6078 install the built files under the texmf tree.
6079 @end defvr
6080
6081 @defvr {Scheme Variable} ruby-build-system
6082 This variable is exported by @code{(guix build-system ruby)}. It
6083 implements the RubyGems build procedure used by Ruby packages, which
6084 involves running @code{gem build} followed by @code{gem install}.
6085
6086 The @code{source} field of a package that uses this build system
6087 typically references a gem archive, since this is the format that Ruby
6088 developers use when releasing their software. The build system unpacks
6089 the gem archive, potentially patches the source, runs the test suite,
6090 repackages the gem, and installs it. Additionally, directories and
6091 tarballs may be referenced to allow building unreleased gems from Git or
6092 a traditional source release tarball.
6093
6094 Which Ruby package is used can be specified with the @code{#:ruby}
6095 parameter. A list of additional flags to be passed to the @command{gem}
6096 command can be specified with the @code{#:gem-flags} parameter.
6097 @end defvr
6098
6099 @defvr {Scheme Variable} waf-build-system
6100 This variable is exported by @code{(guix build-system waf)}. It
6101 implements a build procedure around the @code{waf} script. The common
6102 phases---@code{configure}, @code{build}, and @code{install}---are
6103 implemented by passing their names as arguments to the @code{waf}
6104 script.
6105
6106 The @code{waf} script is executed by the Python interpreter. Which
6107 Python package is used to run the script can be specified with the
6108 @code{#:python} parameter.
6109 @end defvr
6110
6111 @defvr {Scheme Variable} scons-build-system
6112 This variable is exported by @code{(guix build-system scons)}. It
6113 implements the build procedure used by the SCons software construction
6114 tool. This build system runs @code{scons} to build the package,
6115 @code{scons test} to run tests, and then @code{scons install} to install
6116 the package.
6117
6118 Additional flags to be passed to @code{scons} can be specified with the
6119 @code{#:scons-flags} parameter. The version of Python used to run SCons
6120 can be specified by selecting the appropriate SCons package with the
6121 @code{#:scons} parameter.
6122 @end defvr
6123
6124 @defvr {Scheme Variable} haskell-build-system
6125 This variable is exported by @code{(guix build-system haskell)}. It
6126 implements the Cabal build procedure used by Haskell packages, which
6127 involves running @code{runhaskell Setup.hs configure
6128 --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
6129 Instead of installing the package by running @code{runhaskell Setup.hs
6130 install}, to avoid trying to register libraries in the read-only
6131 compiler store directory, the build system uses @code{runhaskell
6132 Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
6133 addition, the build system generates the package documentation by
6134 running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
6135 is passed. Optional Haddock parameters can be passed with the help of
6136 the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
6137 not found, the build system looks for @code{Setup.lhs} instead.
6138
6139 Which Haskell compiler is used can be specified with the @code{#:haskell}
6140 parameter which defaults to @code{ghc}.
6141 @end defvr
6142
6143 @defvr {Scheme Variable} dub-build-system
6144 This variable is exported by @code{(guix build-system dub)}. It
6145 implements the Dub build procedure used by D packages, which
6146 involves running @code{dub build} and @code{dub run}.
6147 Installation is done by copying the files manually.
6148
6149 Which D compiler is used can be specified with the @code{#:ldc}
6150 parameter which defaults to @code{ldc}.
6151 @end defvr
6152
6153 @defvr {Scheme Variable} emacs-build-system
6154 This variable is exported by @code{(guix build-system emacs)}. It
6155 implements an installation procedure similar to the packaging system
6156 of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
6157
6158 It first creates the @code{@var{package}-autoloads.el} file, then it
6159 byte compiles all Emacs Lisp files. Differently from the Emacs
6160 packaging system, the Info documentation files are moved to the standard
6161 documentation directory and the @file{dir} file is deleted. Each
6162 package is installed in its own directory under
6163 @file{share/emacs/site-lisp/guix.d}.
6164 @end defvr
6165
6166 @defvr {Scheme Variable} font-build-system
6167 This variable is exported by @code{(guix build-system font)}. It
6168 implements an installation procedure for font packages where upstream
6169 provides pre-compiled TrueType, OpenType, etc.@: font files that merely
6170 need to be copied into place. It copies font files to standard
6171 locations in the output directory.
6172 @end defvr
6173
6174 @defvr {Scheme Variable} meson-build-system
6175 This variable is exported by @code{(guix build-system meson)}. It
6176 implements the build procedure for packages that use
6177 @url{http://mesonbuild.com, Meson} as their build system.
6178
6179 It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
6180 of inputs, and they can be changed with the parameters @code{#:meson}
6181 and @code{#:ninja} if needed. The default Meson is
6182 @code{meson-for-build}, which is special because it doesn't clear the
6183 @code{RUNPATH} of binaries and libraries when they are installed.
6184
6185 This build system is an extension of @var{gnu-build-system}, but with the
6186 following phases changed to some specific for Meson:
6187
6188 @table @code
6189
6190 @item configure
6191 The phase runs @code{meson} with the flags specified in
6192 @code{#:configure-flags}. The flag @code{--build-type} is always set to
6193 @code{plain} unless something else is specified in @code{#:build-type}.
6194
6195 @item build
6196 The phase runs @code{ninja} to build the package in parallel by default, but
6197 this can be changed with @code{#:parallel-build?}.
6198
6199 @item check
6200 The phase runs @code{ninja} with the target specified in @code{#:test-target},
6201 which is @code{"test"} by default.
6202
6203 @item install
6204 The phase runs @code{ninja install} and can not be changed.
6205 @end table
6206
6207 Apart from that, the build system also adds the following phases:
6208
6209 @table @code
6210
6211 @item fix-runpath
6212 This phase ensures that all binaries can find the libraries they need.
6213 It searches for required libraries in subdirectories of the package being
6214 built, and adds those to @code{RUNPATH} where needed. It also removes
6215 references to libraries left over from the build phase by
6216 @code{meson-for-build}, such as test dependencies, that aren't actually
6217 required for the program to run.
6218
6219 @item glib-or-gtk-wrap
6220 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
6221 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
6222
6223 @item glib-or-gtk-compile-schemas
6224 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
6225 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
6226 @end table
6227 @end defvr
6228
6229 @defvr {Scheme Variable} linux-module-build-system
6230 @var{linux-module-build-system} allows building Linux kernel modules.
6231
6232 @cindex build phases
6233 This build system is an extension of @var{gnu-build-system}, but with the
6234 following phases changed:
6235
6236 @table @code
6237
6238 @item configure
6239 This phase configures the environment so that the Linux kernel's Makefile
6240 can be used to build the external kernel module.
6241
6242 @item build
6243 This phase uses the Linux kernel's Makefile in order to build the external
6244 kernel module.
6245
6246 @item install
6247 This phase uses the Linux kernel's Makefile in order to install the external
6248 kernel module.
6249 @end table
6250
6251 It is possible and useful to specify the Linux kernel to use for building
6252 the module (in the "arguments" form of a package using the
6253 linux-module-build-system, use the key #:linux to specify it).
6254 @end defvr
6255
6256 Lastly, for packages that do not need anything as sophisticated, a
6257 ``trivial'' build system is provided. It is trivial in the sense that
6258 it provides basically no support: it does not pull any implicit inputs,
6259 and does not have a notion of build phases.
6260
6261 @defvr {Scheme Variable} trivial-build-system
6262 This variable is exported by @code{(guix build-system trivial)}.
6263
6264 This build system requires a @code{#:builder} argument. This argument
6265 must be a Scheme expression that builds the package output(s)---as
6266 with @code{build-expression->derivation} (@pxref{Derivations,
6267 @code{build-expression->derivation}}).
6268 @end defvr
6269
6270 @node The Store
6271 @section The Store
6272
6273 @cindex store
6274 @cindex store items
6275 @cindex store paths
6276
6277 Conceptually, the @dfn{store} is the place where derivations that have
6278 been built successfully are stored---by default, @file{/gnu/store}.
6279 Sub-directories in the store are referred to as @dfn{store items} or
6280 sometimes @dfn{store paths}. The store has an associated database that
6281 contains information such as the store paths referred to by each store
6282 path, and the list of @emph{valid} store items---results of successful
6283 builds. This database resides in @file{@var{localstatedir}/guix/db},
6284 where @var{localstatedir} is the state directory specified @i{via}
6285 @option{--localstatedir} at configure time, usually @file{/var}.
6286
6287 The store is @emph{always} accessed by the daemon on behalf of its clients
6288 (@pxref{Invoking guix-daemon}). To manipulate the store, clients
6289 connect to the daemon over a Unix-domain socket, send requests to it,
6290 and read the result---these are remote procedure calls, or RPCs.
6291
6292 @quotation Note
6293 Users must @emph{never} modify files under @file{/gnu/store} directly.
6294 This would lead to inconsistencies and break the immutability
6295 assumptions of Guix's functional model (@pxref{Introduction}).
6296
6297 @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
6298 how to check the integrity of the store and attempt recovery from
6299 accidental modifications.
6300 @end quotation
6301
6302 The @code{(guix store)} module provides procedures to connect to the
6303 daemon, and to perform RPCs. These are described below. By default,
6304 @code{open-connection}, and thus all the @command{guix} commands,
6305 connect to the local daemon or to the URI specified by the
6306 @code{GUIX_DAEMON_SOCKET} environment variable.
6307
6308 @defvr {Environment Variable} GUIX_DAEMON_SOCKET
6309 When set, the value of this variable should be a file name or a URI
6310 designating the daemon endpoint. When it is a file name, it denotes a
6311 Unix-domain socket to connect to. In addition to file names, the
6312 supported URI schemes are:
6313
6314 @table @code
6315 @item file
6316 @itemx unix
6317 These are for Unix-domain sockets.
6318 @code{file:///var/guix/daemon-socket/socket} is equivalent to
6319 @file{/var/guix/daemon-socket/socket}.
6320
6321 @item guix
6322 @cindex daemon, remote access
6323 @cindex remote access to the daemon
6324 @cindex daemon, cluster setup
6325 @cindex clusters, daemon setup
6326 These URIs denote connections over TCP/IP, without encryption nor
6327 authentication of the remote host. The URI must specify the host name
6328 and optionally a port number (by default port 44146 is used):
6329
6330 @example
6331 guix://master.guix.example.org:1234
6332 @end example
6333
6334 This setup is suitable on local networks, such as clusters, where only
6335 trusted nodes may connect to the build daemon at
6336 @code{master.guix.example.org}.
6337
6338 The @code{--listen} option of @command{guix-daemon} can be used to
6339 instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
6340 @code{--listen}}).
6341
6342 @item ssh
6343 @cindex SSH access to build daemons
6344 These URIs allow you to connect to a remote daemon over
6345 SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
6346 A typical URL might look like this:
6347
6348 @example
6349 ssh://charlie@@guix.example.org:22
6350 @end example
6351
6352 As for @command{guix copy}, the usual OpenSSH client configuration files
6353 are honored (@pxref{Invoking guix copy}).
6354 @end table
6355
6356 Additional URI schemes may be supported in the future.
6357
6358 @c XXX: Remove this note when the protocol incurs fewer round trips
6359 @c and when (guix derivations) no longer relies on file system access.
6360 @quotation Note
6361 The ability to connect to remote build daemons is considered
6362 experimental as of @value{VERSION}. Please get in touch with us to
6363 share any problems or suggestions you may have (@pxref{Contributing}).
6364 @end quotation
6365 @end defvr
6366
6367 @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
6368 Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
6369 @var{reserve-space?} is true, instruct it to reserve a little bit of
6370 extra space on the file system so that the garbage collector can still
6371 operate should the disk become full. Return a server object.
6372
6373 @var{file} defaults to @var{%default-socket-path}, which is the normal
6374 location given the options that were passed to @command{configure}.
6375 @end deffn
6376
6377 @deffn {Scheme Procedure} close-connection @var{server}
6378 Close the connection to @var{server}.
6379 @end deffn
6380
6381 @defvr {Scheme Variable} current-build-output-port
6382 This variable is bound to a SRFI-39 parameter, which refers to the port
6383 where build and error logs sent by the daemon should be written.
6384 @end defvr
6385
6386 Procedures that make RPCs all take a server object as their first
6387 argument.
6388
6389 @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
6390 @cindex invalid store items
6391 Return @code{#t} when @var{path} designates a valid store item and
6392 @code{#f} otherwise (an invalid item may exist on disk but still be
6393 invalid, for instance because it is the result of an aborted or failed
6394 build.)
6395
6396 A @code{&store-protocol-error} condition is raised if @var{path} is not
6397 prefixed by the store directory (@file{/gnu/store}).
6398 @end deffn
6399
6400 @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
6401 Add @var{text} under file @var{name} in the store, and return its store
6402 path. @var{references} is the list of store paths referred to by the
6403 resulting store path.
6404 @end deffn
6405
6406 @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
6407 Build @var{derivations} (a list of @code{<derivation>} objects or
6408 derivation paths), and return when the worker is done building them.
6409 Return @code{#t} on success.
6410 @end deffn
6411
6412 Note that the @code{(guix monads)} module provides a monad as well as
6413 monadic versions of the above procedures, with the goal of making it
6414 more convenient to work with code that accesses the store (@pxref{The
6415 Store Monad}).
6416
6417 @c FIXME
6418 @i{This section is currently incomplete.}
6419
6420 @node Derivations
6421 @section Derivations
6422
6423 @cindex derivations
6424 Low-level build actions and the environment in which they are performed
6425 are represented by @dfn{derivations}. A derivation contains the
6426 following pieces of information:
6427
6428 @itemize
6429 @item
6430 The outputs of the derivation---derivations produce at least one file or
6431 directory in the store, but may produce more.
6432
6433 @item
6434 @cindex build-time dependencies
6435 @cindex dependencies, build-time
6436 The inputs of the derivations---i.e., its build-time dependencies---which may
6437 be other derivations or plain files in the store (patches, build scripts,
6438 etc.)
6439
6440 @item
6441 The system type targeted by the derivation---e.g., @code{x86_64-linux}.
6442
6443 @item
6444 The file name of a build script in the store, along with the arguments
6445 to be passed.
6446
6447 @item
6448 A list of environment variables to be defined.
6449
6450 @end itemize
6451
6452 @cindex derivation path
6453 Derivations allow clients of the daemon to communicate build actions to
6454 the store. They exist in two forms: as an in-memory representation,
6455 both on the client- and daemon-side, and as files in the store whose
6456 name end in @code{.drv}---these files are referred to as @dfn{derivation
6457 paths}. Derivations paths can be passed to the @code{build-derivations}
6458 procedure to perform the build actions they prescribe (@pxref{The
6459 Store}).
6460
6461 @cindex fixed-output derivations
6462 Operations such as file downloads and version-control checkouts for
6463 which the expected content hash is known in advance are modeled as
6464 @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
6465 of a fixed-output derivation are independent of its inputs---e.g., a
6466 source code download produces the same result regardless of the download
6467 method and tools being used.
6468
6469 @cindex references
6470 @cindex run-time dependencies
6471 @cindex dependencies, run-time
6472 The outputs of derivations---i.e., the build results---have a set of
6473 @dfn{references}, as reported by the @code{references} RPC or the
6474 @command{guix gc --references} command (@pxref{Invoking guix gc}). References
6475 are the set of run-time dependencies of the build results. References are a
6476 subset of the inputs of the derivation; this subset is automatically computed
6477 by the build daemon by scanning all the files in the outputs.
6478
6479 The @code{(guix derivations)} module provides a representation of
6480 derivations as Scheme objects, along with procedures to create and
6481 otherwise manipulate derivations. The lowest-level primitive to create
6482 a derivation is the @code{derivation} procedure:
6483
6484 @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
6485 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
6486 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
6487 [#:system (%current-system)] [#:references-graphs #f] @
6488 [#:allowed-references #f] [#:disallowed-references #f] @
6489 [#:leaked-env-vars #f] [#:local-build? #f] @
6490 [#:substitutable? #t] [#:properties '()]
6491 Build a derivation with the given arguments, and return the resulting
6492 @code{<derivation>} object.
6493
6494 When @var{hash} and @var{hash-algo} are given, a
6495 @dfn{fixed-output derivation} is created---i.e., one whose result is
6496 known in advance, such as a file download. If, in addition,
6497 @var{recursive?} is true, then that fixed output may be an executable
6498 file or a directory and @var{hash} must be the hash of an archive
6499 containing this output.
6500
6501 When @var{references-graphs} is true, it must be a list of file
6502 name/store path pairs. In that case, the reference graph of each store
6503 path is exported in the build environment in the corresponding file, in
6504 a simple text format.
6505
6506 When @var{allowed-references} is true, it must be a list of store items
6507 or outputs that the derivation's output may refer to. Likewise,
6508 @var{disallowed-references}, if true, must be a list of things the
6509 outputs may @emph{not} refer to.
6510
6511 When @var{leaked-env-vars} is true, it must be a list of strings
6512 denoting environment variables that are allowed to ``leak'' from the
6513 daemon's environment to the build environment. This is only applicable
6514 to fixed-output derivations---i.e., when @var{hash} is true. The main
6515 use is to allow variables such as @code{http_proxy} to be passed to
6516 derivations that download files.
6517
6518 When @var{local-build?} is true, declare that the derivation is not a
6519 good candidate for offloading and should rather be built locally
6520 (@pxref{Daemon Offload Setup}). This is the case for small derivations
6521 where the costs of data transfers would outweigh the benefits.
6522
6523 When @var{substitutable?} is false, declare that substitutes of the
6524 derivation's output should not be used (@pxref{Substitutes}). This is
6525 useful, for instance, when building packages that capture details of the
6526 host CPU instruction set.
6527
6528 @var{properties} must be an association list describing ``properties'' of the
6529 derivation. It is kept as-is, uninterpreted, in the derivation.
6530 @end deffn
6531
6532 @noindent
6533 Here's an example with a shell script as its builder, assuming
6534 @var{store} is an open connection to the daemon, and @var{bash} points
6535 to a Bash executable in the store:
6536
6537 @lisp
6538 (use-modules (guix utils)
6539 (guix store)
6540 (guix derivations))
6541
6542 (let ((builder ; add the Bash script to the store
6543 (add-text-to-store store "my-builder.sh"
6544 "echo hello world > $out\n" '())))
6545 (derivation store "foo"
6546 bash `("-e" ,builder)
6547 #:inputs `((,bash) (,builder))
6548 #:env-vars '(("HOME" . "/homeless"))))
6549 @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
6550 @end lisp
6551
6552 As can be guessed, this primitive is cumbersome to use directly. A
6553 better approach is to write build scripts in Scheme, of course! The
6554 best course of action for that is to write the build code as a
6555 ``G-expression'', and to pass it to @code{gexp->derivation}. For more
6556 information, @pxref{G-Expressions}.
6557
6558 Once upon a time, @code{gexp->derivation} did not exist and constructing
6559 derivations with build code written in Scheme was achieved with
6560 @code{build-expression->derivation}, documented below. This procedure
6561 is now deprecated in favor of the much nicer @code{gexp->derivation}.
6562
6563 @deffn {Scheme Procedure} build-expression->derivation @var{store} @
6564 @var{name} @var{exp} @
6565 [#:system (%current-system)] [#:inputs '()] @
6566 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
6567 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
6568 [#:references-graphs #f] [#:allowed-references #f] @
6569 [#:disallowed-references #f] @
6570 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
6571 Return a derivation that executes Scheme expression @var{exp} as a
6572 builder for derivation @var{name}. @var{inputs} must be a list of
6573 @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
6574 @code{"out"} is assumed. @var{modules} is a list of names of Guile
6575 modules from the current search path to be copied in the store,
6576 compiled, and made available in the load path during the execution of
6577 @var{exp}---e.g., @code{((guix build utils) (guix build
6578 gnu-build-system))}.
6579
6580 @var{exp} is evaluated in an environment where @code{%outputs} is bound
6581 to a list of output/path pairs, and where @code{%build-inputs} is bound
6582 to a list of string/output-path pairs made from @var{inputs}.
6583 Optionally, @var{env-vars} is a list of string pairs specifying the name
6584 and value of environment variables visible to the builder. The builder
6585 terminates by passing the result of @var{exp} to @code{exit}; thus, when
6586 @var{exp} returns @code{#f}, the build is considered to have failed.
6587
6588 @var{exp} is built using @var{guile-for-build} (a derivation). When
6589 @var{guile-for-build} is omitted or is @code{#f}, the value of the
6590 @code{%guile-for-build} fluid is used instead.
6591
6592 See the @code{derivation} procedure for the meaning of
6593 @var{references-graphs}, @var{allowed-references},
6594 @var{disallowed-references}, @var{local-build?}, and
6595 @var{substitutable?}.
6596 @end deffn
6597
6598 @noindent
6599 Here's an example of a single-output derivation that creates a directory
6600 containing one file:
6601
6602 @lisp
6603 (let ((builder '(let ((out (assoc-ref %outputs "out")))
6604 (mkdir out) ; create /gnu/store/@dots{}-goo
6605 (call-with-output-file (string-append out "/test")
6606 (lambda (p)
6607 (display '(hello guix) p))))))
6608 (build-expression->derivation store "goo" builder))
6609
6610 @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
6611 @end lisp
6612
6613
6614 @node The Store Monad
6615 @section The Store Monad
6616
6617 @cindex monad
6618
6619 The procedures that operate on the store described in the previous
6620 sections all take an open connection to the build daemon as their first
6621 argument. Although the underlying model is functional, they either have
6622 side effects or depend on the current state of the store.
6623
6624 The former is inconvenient: the connection to the build daemon has to be
6625 carried around in all those functions, making it impossible to compose
6626 functions that do not take that parameter with functions that do. The
6627 latter can be problematic: since store operations have side effects
6628 and/or depend on external state, they have to be properly sequenced.
6629
6630 @cindex monadic values
6631 @cindex monadic functions
6632 This is where the @code{(guix monads)} module comes in. This module
6633 provides a framework for working with @dfn{monads}, and a particularly
6634 useful monad for our uses, the @dfn{store monad}. Monads are a
6635 construct that allows two things: associating ``context'' with values
6636 (in our case, the context is the store), and building sequences of
6637 computations (here computations include accesses to the store). Values
6638 in a monad---values that carry this additional context---are called
6639 @dfn{monadic values}; procedures that return such values are called
6640 @dfn{monadic procedures}.
6641
6642 Consider this ``normal'' procedure:
6643
6644 @example
6645 (define (sh-symlink store)
6646 ;; Return a derivation that symlinks the 'bash' executable.
6647 (let* ((drv (package-derivation store bash))
6648 (out (derivation->output-path drv))
6649 (sh (string-append out "/bin/bash")))
6650 (build-expression->derivation store "sh"
6651 `(symlink ,sh %output))))
6652 @end example
6653
6654 Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
6655 as a monadic function:
6656
6657 @example
6658 (define (sh-symlink)
6659 ;; Same, but return a monadic value.
6660 (mlet %store-monad ((drv (package->derivation bash)))
6661 (gexp->derivation "sh"
6662 #~(symlink (string-append #$drv "/bin/bash")
6663 #$output))))
6664 @end example
6665
6666 There are several things to note in the second version: the @code{store}
6667 parameter is now implicit and is ``threaded'' in the calls to the
6668 @code{package->derivation} and @code{gexp->derivation} monadic
6669 procedures, and the monadic value returned by @code{package->derivation}
6670 is @dfn{bound} using @code{mlet} instead of plain @code{let}.
6671
6672 As it turns out, the call to @code{package->derivation} can even be
6673 omitted since it will take place implicitly, as we will see later
6674 (@pxref{G-Expressions}):
6675
6676 @example
6677 (define (sh-symlink)
6678 (gexp->derivation "sh"
6679 #~(symlink (string-append #$bash "/bin/bash")
6680 #$output)))
6681 @end example
6682
6683 @c See
6684 @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
6685 @c for the funny quote.
6686 Calling the monadic @code{sh-symlink} has no effect. As someone once
6687 said, ``you exit a monad like you exit a building on fire: by running''.
6688 So, to exit the monad and get the desired effect, one must use
6689 @code{run-with-store}:
6690
6691 @example
6692 (run-with-store (open-connection) (sh-symlink))
6693 @result{} /gnu/store/...-sh-symlink
6694 @end example
6695
6696 Note that the @code{(guix monad-repl)} module extends the Guile REPL with
6697 new ``meta-commands'' to make it easier to deal with monadic procedures:
6698 @code{run-in-store}, and @code{enter-store-monad}. The former is used
6699 to ``run'' a single monadic value through the store:
6700
6701 @example
6702 scheme@@(guile-user)> ,run-in-store (package->derivation hello)
6703 $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
6704 @end example
6705
6706 The latter enters a recursive REPL, where all the return values are
6707 automatically run through the store:
6708
6709 @example
6710 scheme@@(guile-user)> ,enter-store-monad
6711 store-monad@@(guile-user) [1]> (package->derivation hello)
6712 $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
6713 store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
6714 $3 = "/gnu/store/@dots{}-foo"
6715 store-monad@@(guile-user) [1]> ,q
6716 scheme@@(guile-user)>
6717 @end example
6718
6719 @noindent
6720 Note that non-monadic values cannot be returned in the
6721 @code{store-monad} REPL.
6722
6723 The main syntactic forms to deal with monads in general are provided by
6724 the @code{(guix monads)} module and are described below.
6725
6726 @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
6727 Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
6728 in @var{monad}.
6729 @end deffn
6730
6731 @deffn {Scheme Syntax} return @var{val}
6732 Return a monadic value that encapsulates @var{val}.
6733 @end deffn
6734
6735 @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
6736 @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
6737 procedures @var{mproc}@dots{}@footnote{This operation is commonly
6738 referred to as ``bind'', but that name denotes an unrelated procedure in
6739 Guile. Thus we use this somewhat cryptic symbol inherited from the
6740 Haskell language.}. There can be one @var{mproc} or several of them, as
6741 in this example:
6742
6743 @example
6744 (run-with-state
6745 (with-monad %state-monad
6746 (>>= (return 1)
6747 (lambda (x) (return (+ 1 x)))
6748 (lambda (x) (return (* 2 x)))))
6749 'some-state)
6750
6751 @result{} 4
6752 @result{} some-state
6753 @end example
6754 @end deffn
6755
6756 @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
6757 @var{body} ...
6758 @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
6759 @var{body} ...
6760 Bind the variables @var{var} to the monadic values @var{mval} in
6761 @var{body}, which is a sequence of expressions. As with the bind
6762 operator, this can be thought of as ``unpacking'' the raw, non-monadic
6763 value ``contained'' in @var{mval} and making @var{var} refer to that
6764 raw, non-monadic value within the scope of the @var{body}. The form
6765 (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
6766 @var{val}, as per @code{let}. The binding operations occur in sequence
6767 from left to right. The last expression of @var{body} must be a monadic
6768 expression, and its result will become the result of the @code{mlet} or
6769 @code{mlet*} when run in the @var{monad}.
6770
6771 @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
6772 (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
6773 @end deffn
6774
6775 @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
6776 Bind @var{mexp} and the following monadic expressions in sequence,
6777 returning the result of the last expression. Every expression in the
6778 sequence must be a monadic expression.
6779
6780 This is akin to @code{mlet}, except that the return values of the
6781 monadic expressions are ignored. In that sense, it is analogous to
6782 @code{begin}, but applied to monadic expressions.
6783 @end deffn
6784
6785 @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
6786 When @var{condition} is true, evaluate the sequence of monadic
6787 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
6788 @var{condition} is false, return @code{*unspecified*} in the current
6789 monad. Every expression in the sequence must be a monadic expression.
6790 @end deffn
6791
6792 @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
6793 When @var{condition} is false, evaluate the sequence of monadic
6794 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
6795 @var{condition} is true, return @code{*unspecified*} in the current
6796 monad. Every expression in the sequence must be a monadic expression.
6797 @end deffn
6798
6799 @cindex state monad
6800 The @code{(guix monads)} module provides the @dfn{state monad}, which
6801 allows an additional value---the state---to be @emph{threaded} through
6802 monadic procedure calls.
6803
6804 @defvr {Scheme Variable} %state-monad
6805 The state monad. Procedures in the state monad can access and change
6806 the state that is threaded.
6807
6808 Consider the example below. The @code{square} procedure returns a value
6809 in the state monad. It returns the square of its argument, but also
6810 increments the current state value:
6811
6812 @example
6813 (define (square x)
6814 (mlet %state-monad ((count (current-state)))
6815 (mbegin %state-monad
6816 (set-current-state (+ 1 count))
6817 (return (* x x)))))
6818
6819 (run-with-state (sequence %state-monad (map square (iota 3))) 0)
6820 @result{} (0 1 4)
6821 @result{} 3
6822 @end example
6823
6824 When ``run'' through @var{%state-monad}, we obtain that additional state
6825 value, which is the number of @code{square} calls.
6826 @end defvr
6827
6828 @deffn {Monadic Procedure} current-state
6829 Return the current state as a monadic value.
6830 @end deffn
6831
6832 @deffn {Monadic Procedure} set-current-state @var{value}
6833 Set the current state to @var{value} and return the previous state as a
6834 monadic value.
6835 @end deffn
6836
6837 @deffn {Monadic Procedure} state-push @var{value}
6838 Push @var{value} to the current state, which is assumed to be a list,
6839 and return the previous state as a monadic value.
6840 @end deffn
6841
6842 @deffn {Monadic Procedure} state-pop
6843 Pop a value from the current state and return it as a monadic value.
6844 The state is assumed to be a list.
6845 @end deffn
6846
6847 @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
6848 Run monadic value @var{mval} starting with @var{state} as the initial
6849 state. Return two values: the resulting value, and the resulting state.
6850 @end deffn
6851
6852 The main interface to the store monad, provided by the @code{(guix
6853 store)} module, is as follows.
6854
6855 @defvr {Scheme Variable} %store-monad
6856 The store monad---an alias for @var{%state-monad}.
6857
6858 Values in the store monad encapsulate accesses to the store. When its
6859 effect is needed, a value of the store monad must be ``evaluated'' by
6860 passing it to the @code{run-with-store} procedure (see below.)
6861 @end defvr
6862
6863 @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
6864 Run @var{mval}, a monadic value in the store monad, in @var{store}, an
6865 open store connection.
6866 @end deffn
6867
6868 @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
6869 Return as a monadic value the absolute file name in the store of the file
6870 containing @var{text}, a string. @var{references} is a list of store items that the
6871 resulting text file refers to; it defaults to the empty list.
6872 @end deffn
6873
6874 @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
6875 Return as a monadic value the absolute file name in the store of the file
6876 containing @var{data}, a bytevector. @var{references} is a list of store
6877 items that the resulting binary file refers to; it defaults to the empty list.
6878 @end deffn
6879
6880 @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
6881 [#:recursive? #t] [#:select? (const #t)]
6882 Return the name of @var{file} once interned in the store. Use
6883 @var{name} as its store name, or the basename of @var{file} if
6884 @var{name} is omitted.
6885
6886 When @var{recursive?} is true, the contents of @var{file} are added
6887 recursively; if @var{file} designates a flat file and @var{recursive?}
6888 is true, its contents are added, and its permission bits are kept.
6889
6890 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
6891 @var{stat})} for each directory entry, where @var{file} is the entry's
6892 absolute file name and @var{stat} is the result of @code{lstat}; exclude
6893 entries for which @var{select?} does not return true.
6894
6895 The example below adds a file to the store, under two different names:
6896
6897 @example
6898 (run-with-store (open-connection)
6899 (mlet %store-monad ((a (interned-file "README"))
6900 (b (interned-file "README" "LEGU-MIN")))
6901 (return (list a b))))
6902
6903 @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
6904 @end example
6905
6906 @end deffn
6907
6908 The @code{(guix packages)} module exports the following package-related
6909 monadic procedures:
6910
6911 @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
6912 [#:system (%current-system)] [#:target #f] @
6913 [#:output "out"]
6914 Return as a monadic
6915 value in the absolute file name of @var{file} within the @var{output}
6916 directory of @var{package}. When @var{file} is omitted, return the name
6917 of the @var{output} directory of @var{package}. When @var{target} is
6918 true, use it as a cross-compilation target triplet.
6919 @end deffn
6920
6921 @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
6922 @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
6923 @var{target} [@var{system}]
6924 Monadic version of @code{package-derivation} and
6925 @code{package-cross-derivation} (@pxref{Defining Packages}).
6926 @end deffn
6927
6928
6929 @node G-Expressions
6930 @section G-Expressions
6931
6932 @cindex G-expression
6933 @cindex build code quoting
6934 So we have ``derivations'', which represent a sequence of build actions
6935 to be performed to produce an item in the store (@pxref{Derivations}).
6936 These build actions are performed when asking the daemon to actually
6937 build the derivations; they are run by the daemon in a container
6938 (@pxref{Invoking guix-daemon}).
6939
6940 @cindex strata of code
6941 It should come as no surprise that we like to write these build actions
6942 in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
6943 code@footnote{The term @dfn{stratum} in this context was coined by
6944 Manuel Serrano et al.@: in the context of their work on Hop. Oleg
6945 Kiselyov, who has written insightful
6946 @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
6947 on this topic}, refers to this kind of code generation as
6948 @dfn{staging}.}: the ``host code''---code that defines packages, talks
6949 to the daemon, etc.---and the ``build code''---code that actually
6950 performs build actions, such as making directories, invoking
6951 @command{make}, etc.
6952
6953 To describe a derivation and its build actions, one typically needs to
6954 embed build code inside host code. It boils down to manipulating build
6955 code as data, and the homoiconicity of Scheme---code has a direct
6956 representation as data---comes in handy for that. But we need more than
6957 the normal @code{quasiquote} mechanism in Scheme to construct build
6958 expressions.
6959
6960 The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
6961 S-expressions adapted to build expressions. G-expressions, or
6962 @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
6963 @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
6964 @code{#$}, and @code{#$@@}), which are comparable to
6965 @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
6966 respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
6967 GNU Guile Reference Manual}). However, there are major differences:
6968
6969 @itemize
6970 @item
6971 Gexps are meant to be written to a file and run or manipulated by other
6972 processes.
6973
6974 @item
6975 When a high-level object such as a package or derivation is unquoted
6976 inside a gexp, the result is as if its output file name had been
6977 introduced.
6978
6979 @item
6980 Gexps carry information about the packages or derivations they refer to,
6981 and these dependencies are automatically added as inputs to the build
6982 processes that use them.
6983 @end itemize
6984
6985 @cindex lowering, of high-level objects in gexps
6986 This mechanism is not limited to package and derivation
6987 objects: @dfn{compilers} able to ``lower'' other high-level objects to
6988 derivations or files in the store can be defined,
6989 such that these objects can also be inserted
6990 into gexps. For example, a useful type of high-level objects that can be
6991 inserted in a gexp is ``file-like objects'', which make it easy to
6992 add files to the store and to refer to them in
6993 derivations and such (see @code{local-file} and @code{plain-file}
6994 below.)
6995
6996 To illustrate the idea, here is an example of a gexp:
6997
6998 @example
6999 (define build-exp
7000 #~(begin
7001 (mkdir #$output)
7002 (chdir #$output)
7003 (symlink (string-append #$coreutils "/bin/ls")
7004 "list-files")))
7005 @end example
7006
7007 This gexp can be passed to @code{gexp->derivation}; we obtain a
7008 derivation that builds a directory containing exactly one symlink to
7009 @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
7010
7011 @example
7012 (gexp->derivation "the-thing" build-exp)
7013 @end example
7014
7015 As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
7016 substituted to the reference to the @var{coreutils} package in the
7017 actual build code, and @var{coreutils} is automatically made an input to
7018 the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
7019 output)}) is replaced by a string containing the directory name of the
7020 output of the derivation.
7021
7022 @cindex cross compilation
7023 In a cross-compilation context, it is useful to distinguish between
7024 references to the @emph{native} build of a package---that can run on the
7025 host---versus references to cross builds of a package. To that end, the
7026 @code{#+} plays the same role as @code{#$}, but is a reference to a
7027 native package build:
7028
7029 @example
7030 (gexp->derivation "vi"
7031 #~(begin
7032 (mkdir #$output)
7033 (system* (string-append #+coreutils "/bin/ln")
7034 "-s"
7035 (string-append #$emacs "/bin/emacs")
7036 (string-append #$output "/bin/vi")))
7037 #:target "mips64el-linux-gnu")
7038 @end example
7039
7040 @noindent
7041 In the example above, the native build of @var{coreutils} is used, so
7042 that @command{ln} can actually run on the host; but then the
7043 cross-compiled build of @var{emacs} is referenced.
7044
7045 @cindex imported modules, for gexps
7046 @findex with-imported-modules
7047 Another gexp feature is @dfn{imported modules}: sometimes you want to be
7048 able to use certain Guile modules from the ``host environment'' in the
7049 gexp, so those modules should be imported in the ``build environment''.
7050 The @code{with-imported-modules} form allows you to express that:
7051
7052 @example
7053 (let ((build (with-imported-modules '((guix build utils))
7054 #~(begin
7055 (use-modules (guix build utils))
7056 (mkdir-p (string-append #$output "/bin"))))))
7057 (gexp->derivation "empty-dir"
7058 #~(begin
7059 #$build
7060 (display "success!\n")
7061 #t)))
7062 @end example
7063
7064 @noindent
7065 In this example, the @code{(guix build utils)} module is automatically
7066 pulled into the isolated build environment of our gexp, such that
7067 @code{(use-modules (guix build utils))} works as expected.
7068
7069 @cindex module closure
7070 @findex source-module-closure
7071 Usually you want the @emph{closure} of the module to be imported---i.e.,
7072 the module itself and all the modules it depends on---rather than just
7073 the module; failing to do that, attempts to use the module will fail
7074 because of missing dependent modules. The @code{source-module-closure}
7075 procedure computes the closure of a module by looking at its source file
7076 headers, which comes in handy in this case:
7077
7078 @example
7079 (use-modules (guix modules)) ;for 'source-module-closure'
7080
7081 (with-imported-modules (source-module-closure
7082 '((guix build utils)
7083 (gnu build vm)))
7084 (gexp->derivation "something-with-vms"
7085 #~(begin
7086 (use-modules (guix build utils)
7087 (gnu build vm))
7088 @dots{})))
7089 @end example
7090
7091 @cindex extensions, for gexps
7092 @findex with-extensions
7093 In the same vein, sometimes you want to import not just pure-Scheme
7094 modules, but also ``extensions'' such as Guile bindings to C libraries
7095 or other ``full-blown'' packages. Say you need the @code{guile-json}
7096 package available on the build side, here's how you would do it:
7097
7098 @example
7099 (use-modules (gnu packages guile)) ;for 'guile-json'
7100
7101 (with-extensions (list guile-json)
7102 (gexp->derivation "something-with-json"
7103 #~(begin
7104 (use-modules (json))
7105 @dots{})))
7106 @end example
7107
7108 The syntactic form to construct gexps is summarized below.
7109
7110 @deffn {Scheme Syntax} #~@var{exp}
7111 @deffnx {Scheme Syntax} (gexp @var{exp})
7112 Return a G-expression containing @var{exp}. @var{exp} may contain one
7113 or more of the following forms:
7114
7115 @table @code
7116 @item #$@var{obj}
7117 @itemx (ungexp @var{obj})
7118 Introduce a reference to @var{obj}. @var{obj} may have one of the
7119 supported types, for example a package or a
7120 derivation, in which case the @code{ungexp} form is replaced by its
7121 output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
7122
7123 If @var{obj} is a list, it is traversed and references to supported
7124 objects are substituted similarly.
7125
7126 If @var{obj} is another gexp, its contents are inserted and its
7127 dependencies are added to those of the containing gexp.
7128
7129 If @var{obj} is another kind of object, it is inserted as is.
7130
7131 @item #$@var{obj}:@var{output}
7132 @itemx (ungexp @var{obj} @var{output})
7133 This is like the form above, but referring explicitly to the
7134 @var{output} of @var{obj}---this is useful when @var{obj} produces
7135 multiple outputs (@pxref{Packages with Multiple Outputs}).
7136
7137 @item #+@var{obj}
7138 @itemx #+@var{obj}:output
7139 @itemx (ungexp-native @var{obj})
7140 @itemx (ungexp-native @var{obj} @var{output})
7141 Same as @code{ungexp}, but produces a reference to the @emph{native}
7142 build of @var{obj} when used in a cross compilation context.
7143
7144 @item #$output[:@var{output}]
7145 @itemx (ungexp output [@var{output}])
7146 Insert a reference to derivation output @var{output}, or to the main
7147 output when @var{output} is omitted.
7148
7149 This only makes sense for gexps passed to @code{gexp->derivation}.
7150
7151 @item #$@@@var{lst}
7152 @itemx (ungexp-splicing @var{lst})
7153 Like the above, but splices the contents of @var{lst} inside the
7154 containing list.
7155
7156 @item #+@@@var{lst}
7157 @itemx (ungexp-native-splicing @var{lst})
7158 Like the above, but refers to native builds of the objects listed in
7159 @var{lst}.
7160
7161 @end table
7162
7163 G-expressions created by @code{gexp} or @code{#~} are run-time objects
7164 of the @code{gexp?} type (see below.)
7165 @end deffn
7166
7167 @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
7168 Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
7169 in their execution environment.
7170
7171 Each item in @var{modules} can be the name of a module, such as
7172 @code{(guix build utils)}, or it can be a module name, followed by an
7173 arrow, followed by a file-like object:
7174
7175 @example
7176 `((guix build utils)
7177 (guix gcrypt)
7178 ((guix config) => ,(scheme-file "config.scm"
7179 #~(define-module @dots{}))))
7180 @end example
7181
7182 @noindent
7183 In the example above, the first two modules are taken from the search
7184 path, and the last one is created from the given file-like object.
7185
7186 This form has @emph{lexical} scope: it has an effect on the gexps
7187 directly defined in @var{body}@dots{}, but not on those defined, say, in
7188 procedures called from @var{body}@dots{}.
7189 @end deffn
7190
7191 @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
7192 Mark the gexps defined in @var{body}@dots{} as requiring
7193 @var{extensions} in their build and execution environment.
7194 @var{extensions} is typically a list of package objects such as those
7195 defined in the @code{(gnu packages guile)} module.
7196
7197 Concretely, the packages listed in @var{extensions} are added to the
7198 load path while compiling imported modules in @var{body}@dots{}; they
7199 are also added to the load path of the gexp returned by
7200 @var{body}@dots{}.
7201 @end deffn
7202
7203 @deffn {Scheme Procedure} gexp? @var{obj}
7204 Return @code{#t} if @var{obj} is a G-expression.
7205 @end deffn
7206
7207 G-expressions are meant to be written to disk, either as code building
7208 some derivation, or as plain files in the store. The monadic procedures
7209 below allow you to do that (@pxref{The Store Monad}, for more
7210 information about monads.)
7211
7212 @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
7213 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
7214 [#:hash #f] [#:hash-algo #f] @
7215 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
7216 [#:module-path @var{%load-path}] @
7217 [#:effective-version "2.2"] @
7218 [#:references-graphs #f] [#:allowed-references #f] @
7219 [#:disallowed-references #f] @
7220 [#:leaked-env-vars #f] @
7221 [#:script-name (string-append @var{name} "-builder")] @
7222 [#:deprecation-warnings #f] @
7223 [#:local-build? #f] [#:substitutable? #t] @
7224 [#:properties '()] [#:guile-for-build #f]
7225 Return a derivation @var{name} that runs @var{exp} (a gexp) with
7226 @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
7227 stored in a file called @var{script-name}. When @var{target} is true,
7228 it is used as the cross-compilation target triplet for packages referred
7229 to by @var{exp}.
7230
7231 @var{modules} is deprecated in favor of @code{with-imported-modules}.
7232 Its meaning is to
7233 make @var{modules} available in the evaluation context of @var{exp};
7234 @var{modules} is a list of names of Guile modules searched in
7235 @var{module-path} to be copied in the store, compiled, and made available in
7236 the load path during the execution of @var{exp}---e.g., @code{((guix
7237 build utils) (guix build gnu-build-system))}.
7238
7239 @var{effective-version} determines the string to use when adding extensions of
7240 @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
7241
7242 @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
7243 applicable.
7244
7245 When @var{references-graphs} is true, it must be a list of tuples of one of the
7246 following forms:
7247
7248 @example
7249 (@var{file-name} @var{package})
7250 (@var{file-name} @var{package} @var{output})
7251 (@var{file-name} @var{derivation})
7252 (@var{file-name} @var{derivation} @var{output})
7253 (@var{file-name} @var{store-item})
7254 @end example
7255
7256 The right-hand-side of each element of @var{references-graphs} is automatically made
7257 an input of the build process of @var{exp}. In the build environment, each
7258 @var{file-name} contains the reference graph of the corresponding item, in a simple
7259 text format.
7260
7261 @var{allowed-references} must be either @code{#f} or a list of output names and packages.
7262 In the latter case, the list denotes store items that the result is allowed to
7263 refer to. Any reference to another store item will lead to a build error.
7264 Similarly for @var{disallowed-references}, which can list items that must not be
7265 referenced by the outputs.
7266
7267 @var{deprecation-warnings} determines whether to show deprecation warnings while
7268 compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
7269
7270 The other arguments are as for @code{derivation} (@pxref{Derivations}).
7271 @end deffn
7272
7273 @cindex file-like objects
7274 The @code{local-file}, @code{plain-file}, @code{computed-file},
7275 @code{program-file}, and @code{scheme-file} procedures below return
7276 @dfn{file-like objects}. That is, when unquoted in a G-expression,
7277 these objects lead to a file in the store. Consider this G-expression:
7278
7279 @example
7280 #~(system* #$(file-append glibc "/sbin/nscd") "-f"
7281 #$(local-file "/tmp/my-nscd.conf"))
7282 @end example
7283
7284 The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
7285 to the store. Once expanded, for instance @i{via}
7286 @code{gexp->derivation}, the G-expression refers to that copy under
7287 @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
7288 does not have any effect on what the G-expression does.
7289 @code{plain-file} can be used similarly; it differs in that the file
7290 content is directly passed as a string.
7291
7292 @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
7293 [#:recursive? #f] [#:select? (const #t)]
7294 Return an object representing local file @var{file} to add to the store; this
7295 object can be used in a gexp. If @var{file} is a relative file name, it is looked
7296 up relative to the source file where this form appears. @var{file} will be added to
7297 the store under @var{name}--by default the base name of @var{file}.
7298
7299 When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
7300 designates a flat file and @var{recursive?} is true, its contents are added, and its
7301 permission bits are kept.
7302
7303 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
7304 @var{stat})} for each directory entry, where @var{file} is the entry's
7305 absolute file name and @var{stat} is the result of @code{lstat}; exclude
7306 entries for which @var{select?} does not return true.
7307
7308 This is the declarative counterpart of the @code{interned-file} monadic
7309 procedure (@pxref{The Store Monad, @code{interned-file}}).
7310 @end deffn
7311
7312 @deffn {Scheme Procedure} plain-file @var{name} @var{content}
7313 Return an object representing a text file called @var{name} with the given
7314 @var{content} (a string or a bytevector) to be added to the store.
7315
7316 This is the declarative counterpart of @code{text-file}.
7317 @end deffn
7318
7319 @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
7320 [#:options '(#:local-build? #t)]
7321 Return an object representing the store item @var{name}, a file or
7322 directory computed by @var{gexp}. @var{options}
7323 is a list of additional arguments to pass to @code{gexp->derivation}.
7324
7325 This is the declarative counterpart of @code{gexp->derivation}.
7326 @end deffn
7327
7328 @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
7329 [#:guile (default-guile)] [#:module-path %load-path]
7330 Return an executable script @var{name} that runs @var{exp} using
7331 @var{guile}, with @var{exp}'s imported modules in its search path.
7332 Look up @var{exp}'s modules in @var{module-path}.
7333
7334 The example below builds a script that simply invokes the @command{ls}
7335 command:
7336
7337 @example
7338 (use-modules (guix gexp) (gnu packages base))
7339
7340 (gexp->script "list-files"
7341 #~(execl #$(file-append coreutils "/bin/ls")
7342 "ls"))
7343 @end example
7344
7345 When ``running'' it through the store (@pxref{The Store Monad,
7346 @code{run-with-store}}), we obtain a derivation that produces an
7347 executable file @file{/gnu/store/@dots{}-list-files} along these lines:
7348
7349 @example
7350 #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
7351 !#
7352 (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
7353 @end example
7354 @end deffn
7355
7356 @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
7357 [#:guile #f] [#:module-path %load-path]
7358 Return an object representing the executable store item @var{name} that
7359 runs @var{gexp}. @var{guile} is the Guile package used to execute that
7360 script. Imported modules of @var{gexp} are looked up in @var{module-path}.
7361
7362 This is the declarative counterpart of @code{gexp->script}.
7363 @end deffn
7364
7365 @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
7366 [#:set-load-path? #t] [#:module-path %load-path] @
7367 [#:splice? #f] @
7368 [#:guile (default-guile)]
7369 Return a derivation that builds a file @var{name} containing @var{exp}.
7370 When @var{splice?} is true, @var{exp} is considered to be a list of
7371 expressions that will be spliced in the resulting file.
7372
7373 When @var{set-load-path?} is true, emit code in the resulting file to
7374 set @code{%load-path} and @code{%load-compiled-path} to honor
7375 @var{exp}'s imported modules. Look up @var{exp}'s modules in
7376 @var{module-path}.
7377
7378 The resulting file holds references to all the dependencies of @var{exp}
7379 or a subset thereof.
7380 @end deffn
7381
7382 @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f]
7383 Return an object representing the Scheme file @var{name} that contains
7384 @var{exp}.
7385
7386 This is the declarative counterpart of @code{gexp->file}.
7387 @end deffn
7388
7389 @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
7390 Return as a monadic value a derivation that builds a text file
7391 containing all of @var{text}. @var{text} may list, in addition to
7392 strings, objects of any type that can be used in a gexp: packages,
7393 derivations, local file objects, etc. The resulting store file holds
7394 references to all these.
7395
7396 This variant should be preferred over @code{text-file} anytime the file
7397 to create will reference items from the store. This is typically the
7398 case when building a configuration file that embeds store file names,
7399 like this:
7400
7401 @example
7402 (define (profile.sh)
7403 ;; Return the name of a shell script in the store that
7404 ;; initializes the 'PATH' environment variable.
7405 (text-file* "profile.sh"
7406 "export PATH=" coreutils "/bin:"
7407 grep "/bin:" sed "/bin\n"))
7408 @end example
7409
7410 In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
7411 will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
7412 preventing them from being garbage-collected during its lifetime.
7413 @end deffn
7414
7415 @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
7416 Return an object representing store file @var{name} containing
7417 @var{text}. @var{text} is a sequence of strings and file-like objects,
7418 as in:
7419
7420 @example
7421 (mixed-text-file "profile"
7422 "export PATH=" coreutils "/bin:" grep "/bin")
7423 @end example
7424
7425 This is the declarative counterpart of @code{text-file*}.
7426 @end deffn
7427
7428 @deffn {Scheme Procedure} file-union @var{name} @var{files}
7429 Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
7430 Each item in @var{files} must be a two-element list where the first element is the
7431 file name to use in the new directory, and the second element is a gexp
7432 denoting the target file. Here's an example:
7433
7434 @example
7435 (file-union "etc"
7436 `(("hosts" ,(plain-file "hosts"
7437 "127.0.0.1 localhost"))
7438 ("bashrc" ,(plain-file "bashrc"
7439 "alias ls='ls --color=auto'"))))
7440 @end example
7441
7442 This yields an @code{etc} directory containing these two files.
7443 @end deffn
7444
7445 @deffn {Scheme Procedure} directory-union @var{name} @var{things}
7446 Return a directory that is the union of @var{things}, where @var{things} is a list of
7447 file-like objects denoting directories. For example:
7448
7449 @example
7450 (directory-union "guile+emacs" (list guile emacs))
7451 @end example
7452
7453 yields a directory that is the union of the @code{guile} and @code{emacs} packages.
7454 @end deffn
7455
7456 @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
7457 Return a file-like object that expands to the concatenation of @var{obj}
7458 and @var{suffix}, where @var{obj} is a lowerable object and each
7459 @var{suffix} is a string.
7460
7461 As an example, consider this gexp:
7462
7463 @example
7464 (gexp->script "run-uname"
7465 #~(system* #$(file-append coreutils
7466 "/bin/uname")))
7467 @end example
7468
7469 The same effect could be achieved with:
7470
7471 @example
7472 (gexp->script "run-uname"
7473 #~(system* (string-append #$coreutils
7474 "/bin/uname")))
7475 @end example
7476
7477 There is one difference though: in the @code{file-append} case, the
7478 resulting script contains the absolute file name as a string, whereas in
7479 the second case, the resulting script contains a @code{(string-append
7480 @dots{})} expression to construct the file name @emph{at run time}.
7481 @end deffn
7482
7483
7484 Of course, in addition to gexps embedded in ``host'' code, there are
7485 also modules containing build tools. To make it clear that they are
7486 meant to be used in the build stratum, these modules are kept in the
7487 @code{(guix build @dots{})} name space.
7488
7489 @cindex lowering, of high-level objects in gexps
7490 Internally, high-level objects are @dfn{lowered}, using their compiler,
7491 to either derivations or store items. For instance, lowering a package
7492 yields a derivation, and lowering a @code{plain-file} yields a store
7493 item. This is achieved using the @code{lower-object} monadic procedure.
7494
7495 @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
7496 [#:target #f]
7497 Return as a value in @var{%store-monad} the derivation or store item
7498 corresponding to @var{obj} for @var{system}, cross-compiling for
7499 @var{target} if @var{target} is true. @var{obj} must be an object that
7500 has an associated gexp compiler, such as a @code{<package>}.
7501 @end deffn
7502
7503 @node Invoking guix repl
7504 @section Invoking @command{guix repl}
7505
7506 @cindex REPL, read-eval-print loop
7507 The @command{guix repl} command spawns a Guile @dfn{read-eval-print loop}
7508 (REPL) for interactive programming (@pxref{Using Guile Interactively,,, guile,
7509 GNU Guile Reference Manual}). Compared to just launching the @command{guile}
7510 command, @command{guix repl} guarantees that all the Guix modules and all its
7511 dependencies are available in the search path. You can use it this way:
7512
7513 @example
7514 $ guix repl
7515 scheme@@(guile-user)> ,use (gnu packages base)
7516 scheme@@(guile-user)> coreutils
7517 $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
7518 @end example
7519
7520 @cindex inferiors
7521 In addition, @command{guix repl} implements a simple machine-readable REPL
7522 protocol for use by @code{(guix inferior)}, a facility to interact with
7523 @dfn{inferiors}, separate processes running a potentially different revision
7524 of Guix.
7525
7526 The available options are as follows:
7527
7528 @table @code
7529 @item --type=@var{type}
7530 @itemx -t @var{type}
7531 Start a REPL of the given @var{TYPE}, which can be one of the following:
7532
7533 @table @code
7534 @item guile
7535 This is default, and it spawns a standard full-featured Guile REPL.
7536 @item machine
7537 Spawn a REPL that uses the machine-readable protocol. This is the protocol
7538 that the @code{(guix inferior)} module speaks.
7539 @end table
7540
7541 @item --listen=@var{endpoint}
7542 By default, @command{guix repl} reads from standard input and writes to
7543 standard output. When this option is passed, it will instead listen for
7544 connections on @var{endpoint}. Here are examples of valid options:
7545
7546 @table @code
7547 @item --listen=tcp:37146
7548 Accept connections on localhost on port 37146.
7549
7550 @item --listen=unix:/tmp/socket
7551 Accept connections on the Unix-domain socket @file{/tmp/socket}.
7552 @end table
7553 @end table
7554
7555 @c *********************************************************************
7556 @node Utilities
7557 @chapter Utilities
7558
7559 This section describes Guix command-line utilities. Some of them are
7560 primarily targeted at developers and users who write new package
7561 definitions, while others are more generally useful. They complement
7562 the Scheme programming interface of Guix in a convenient way.
7563
7564 @menu
7565 * Invoking guix build:: Building packages from the command line.
7566 * Invoking guix edit:: Editing package definitions.
7567 * Invoking guix download:: Downloading a file and printing its hash.
7568 * Invoking guix hash:: Computing the cryptographic hash of a file.
7569 * Invoking guix import:: Importing package definitions.
7570 * Invoking guix refresh:: Updating package definitions.
7571 * Invoking guix lint:: Finding errors in package definitions.
7572 * Invoking guix size:: Profiling disk usage.
7573 * Invoking guix graph:: Visualizing the graph of packages.
7574 * Invoking guix publish:: Sharing substitutes.
7575 * Invoking guix challenge:: Challenging substitute servers.
7576 * Invoking guix copy:: Copying to and from a remote store.
7577 * Invoking guix container:: Process isolation.
7578 * Invoking guix weather:: Assessing substitute availability.
7579 * Invoking guix processes:: Listing client processes.
7580 @end menu
7581
7582 @node Invoking guix build
7583 @section Invoking @command{guix build}
7584
7585 @cindex package building
7586 @cindex @command{guix build}
7587 The @command{guix build} command builds packages or derivations and
7588 their dependencies, and prints the resulting store paths. Note that it
7589 does not modify the user's profile---this is the job of the
7590 @command{guix package} command (@pxref{Invoking guix package}). Thus,
7591 it is mainly useful for distribution developers.
7592
7593 The general syntax is:
7594
7595 @example
7596 guix build @var{options} @var{package-or-derivation}@dots{}
7597 @end example
7598
7599 As an example, the following command builds the latest versions of Emacs
7600 and of Guile, displays their build logs, and finally displays the
7601 resulting directories:
7602
7603 @example
7604 guix build emacs guile
7605 @end example
7606
7607 Similarly, the following command builds all the available packages:
7608
7609 @example
7610 guix build --quiet --keep-going \
7611 `guix package -A | cut -f1,2 --output-delimiter=@@`
7612 @end example
7613
7614 @var{package-or-derivation} may be either the name of a package found in
7615 the software distribution such as @code{coreutils} or
7616 @code{coreutils@@8.20}, or a derivation such as
7617 @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
7618 package with the corresponding name (and optionally version) is searched
7619 for among the GNU distribution modules (@pxref{Package Modules}).
7620
7621 Alternatively, the @code{--expression} option may be used to specify a
7622 Scheme expression that evaluates to a package; this is useful when
7623 disambiguating among several same-named packages or package variants is
7624 needed.
7625
7626 There may be zero or more @var{options}. The available options are
7627 described in the subsections below.
7628
7629 @menu
7630 * Common Build Options:: Build options for most commands.
7631 * Package Transformation Options:: Creating variants of packages.
7632 * Additional Build Options:: Options specific to 'guix build'.
7633 * Debugging Build Failures:: Real life packaging experience.
7634 @end menu
7635
7636 @node Common Build Options
7637 @subsection Common Build Options
7638
7639 A number of options that control the build process are common to
7640 @command{guix build} and other commands that can spawn builds, such as
7641 @command{guix package} or @command{guix archive}. These are the
7642 following:
7643
7644 @table @code
7645
7646 @item --load-path=@var{directory}
7647 @itemx -L @var{directory}
7648 Add @var{directory} to the front of the package module search path
7649 (@pxref{Package Modules}).
7650
7651 This allows users to define their own packages and make them visible to
7652 the command-line tools.
7653
7654 @item --keep-failed
7655 @itemx -K
7656 Keep the build tree of failed builds. Thus, if a build fails, its build
7657 tree is kept under @file{/tmp}, in a directory whose name is shown at
7658 the end of the build log. This is useful when debugging build issues.
7659 @xref{Debugging Build Failures}, for tips and tricks on how to debug
7660 build issues.
7661
7662 This option has no effect when connecting to a remote daemon with a
7663 @code{guix://} URI (@pxref{The Store, the @code{GUIX_DAEMON_SOCKET}
7664 variable}).
7665
7666 @item --keep-going
7667 @itemx -k
7668 Keep going when some of the derivations fail to build; return only once
7669 all the builds have either completed or failed.
7670
7671 The default behavior is to stop as soon as one of the specified
7672 derivations has failed.
7673
7674 @item --dry-run
7675 @itemx -n
7676 Do not build the derivations.
7677
7678 @anchor{fallback-option}
7679 @item --fallback
7680 When substituting a pre-built binary fails, fall back to building
7681 packages locally (@pxref{Substitution Failure}).
7682
7683 @item --substitute-urls=@var{urls}
7684 @anchor{client-substitute-urls}
7685 Consider @var{urls} the whitespace-separated list of substitute source
7686 URLs, overriding the default list of URLs of @command{guix-daemon}
7687 (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
7688
7689 This means that substitutes may be downloaded from @var{urls}, provided
7690 they are signed by a key authorized by the system administrator
7691 (@pxref{Substitutes}).
7692
7693 When @var{urls} is the empty string, substitutes are effectively
7694 disabled.
7695
7696 @item --no-substitutes
7697 Do not use substitutes for build products. That is, always build things
7698 locally instead of allowing downloads of pre-built binaries
7699 (@pxref{Substitutes}).
7700
7701 @item --no-grafts
7702 Do not ``graft'' packages. In practice, this means that package updates
7703 available as grafts are not applied. @xref{Security Updates}, for more
7704 information on grafts.
7705
7706 @item --rounds=@var{n}
7707 Build each derivation @var{n} times in a row, and raise an error if
7708 consecutive build results are not bit-for-bit identical.
7709
7710 This is a useful way to detect non-deterministic builds processes.
7711 Non-deterministic build processes are a problem because they make it
7712 practically impossible for users to @emph{verify} whether third-party
7713 binaries are genuine. @xref{Invoking guix challenge}, for more.
7714
7715 Note that, currently, the differing build results are not kept around,
7716 so you will have to manually investigate in case of an error---e.g., by
7717 stashing one of the build results with @code{guix archive --export}
7718 (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
7719 the two results.
7720
7721 @item --no-build-hook
7722 Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
7723 (@pxref{Daemon Offload Setup}). That is, always build things locally
7724 instead of offloading builds to remote machines.
7725
7726 @item --max-silent-time=@var{seconds}
7727 When the build or substitution process remains silent for more than
7728 @var{seconds}, terminate it and report a build failure.
7729
7730 By default, the daemon's setting is honored (@pxref{Invoking
7731 guix-daemon, @code{--max-silent-time}}).
7732
7733 @item --timeout=@var{seconds}
7734 Likewise, when the build or substitution process lasts for more than
7735 @var{seconds}, terminate it and report a build failure.
7736
7737 By default, the daemon's setting is honored (@pxref{Invoking
7738 guix-daemon, @code{--timeout}}).
7739
7740 @c Note: This option is actually not part of %standard-build-options but
7741 @c most programs honor it.
7742 @cindex verbosity, of the command-line tools
7743 @cindex build logs, verbosity
7744 @item -v @var{level}
7745 @itemx --verbosity=@var{level}
7746 Use the given verbosity @var{level}, an integer. Choosing 0 means that no
7747 output is produced, 1 is for quiet output, and 2 shows all the build log
7748 output on standard error.
7749
7750 @item --cores=@var{n}
7751 @itemx -c @var{n}
7752 Allow the use of up to @var{n} CPU cores for the build. The special
7753 value @code{0} means to use as many CPU cores as available.
7754
7755 @item --max-jobs=@var{n}
7756 @itemx -M @var{n}
7757 Allow at most @var{n} build jobs in parallel. @xref{Invoking
7758 guix-daemon, @code{--max-jobs}}, for details about this option and the
7759 equivalent @command{guix-daemon} option.
7760
7761 @item --debug=@var{level}
7762 Produce debugging output coming from the build daemon. @var{level} must be an
7763 integer between 0 and 5; higher means more verbose output. Setting a level of
7764 4 or more may be helpful when debugging setup issues with the build daemon.
7765
7766 @end table
7767
7768 Behind the scenes, @command{guix build} is essentially an interface to
7769 the @code{package-derivation} procedure of the @code{(guix packages)}
7770 module, and to the @code{build-derivations} procedure of the @code{(guix
7771 derivations)} module.
7772
7773 In addition to options explicitly passed on the command line,
7774 @command{guix build} and other @command{guix} commands that support
7775 building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
7776
7777 @defvr {Environment Variable} GUIX_BUILD_OPTIONS
7778 Users can define this variable to a list of command line options that
7779 will automatically be used by @command{guix build} and other
7780 @command{guix} commands that can perform builds, as in the example
7781 below:
7782
7783 @example
7784 $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
7785 @end example
7786
7787 These options are parsed independently, and the result is appended to
7788 the parsed command-line options.
7789 @end defvr
7790
7791
7792 @node Package Transformation Options
7793 @subsection Package Transformation Options
7794
7795 @cindex package variants
7796 Another set of command-line options supported by @command{guix build}
7797 and also @command{guix package} are @dfn{package transformation
7798 options}. These are options that make it possible to define @dfn{package
7799 variants}---for instance, packages built from different source code.
7800 This is a convenient way to create customized packages on the fly
7801 without having to type in the definitions of package variants
7802 (@pxref{Defining Packages}).
7803
7804 @table @code
7805
7806 @item --with-source=@var{source}
7807 @itemx --with-source=@var{package}=@var{source}
7808 @itemx --with-source=@var{package}@@@var{version}=@var{source}
7809 Use @var{source} as the source of @var{package}, and @var{version} as
7810 its version number.
7811 @var{source} must be a file name or a URL, as for @command{guix
7812 download} (@pxref{Invoking guix download}).
7813
7814 When @var{package} is omitted,
7815 it is taken to be the package name specified on the
7816 command line that matches the base of @var{source}---e.g.,
7817 if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
7818 package is @code{guile}.
7819
7820 Likewise, when @var{version} is omitted, the version string is inferred from
7821 @var{source}; in the previous example, it is @code{2.0.10}.
7822
7823 This option allows users to try out versions of packages other than the
7824 one provided by the distribution. The example below downloads
7825 @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
7826 the @code{ed} package:
7827
7828 @example
7829 guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
7830 @end example
7831
7832 As a developer, @code{--with-source} makes it easy to test release
7833 candidates:
7834
7835 @example
7836 guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
7837 @end example
7838
7839 @dots{} or to build from a checkout in a pristine environment:
7840
7841 @example
7842 $ git clone git://git.sv.gnu.org/guix.git
7843 $ guix build guix --with-source=guix@@1.0=./guix
7844 @end example
7845
7846 @item --with-input=@var{package}=@var{replacement}
7847 Replace dependency on @var{package} by a dependency on
7848 @var{replacement}. @var{package} must be a package name, and
7849 @var{replacement} must be a package specification such as @code{guile}
7850 or @code{guile@@1.8}.
7851
7852 For instance, the following command builds Guix, but replaces its
7853 dependency on the current stable version of Guile with a dependency on
7854 the legacy version of Guile, @code{guile@@2.0}:
7855
7856 @example
7857 guix build --with-input=guile=guile@@2.0 guix
7858 @end example
7859
7860 This is a recursive, deep replacement. So in this example, both
7861 @code{guix} and its dependency @code{guile-json} (which also depends on
7862 @code{guile}) get rebuilt against @code{guile@@2.0}.
7863
7864 This is implemented using the @code{package-input-rewriting} Scheme
7865 procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
7866
7867 @item --with-graft=@var{package}=@var{replacement}
7868 This is similar to @code{--with-input} but with an important difference:
7869 instead of rebuilding the whole dependency chain, @var{replacement} is
7870 built and then @dfn{grafted} onto the binaries that were initially
7871 referring to @var{package}. @xref{Security Updates}, for more
7872 information on grafts.
7873
7874 For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
7875 and all its dependencies, replacing references to the version of GnuTLS
7876 they currently refer to:
7877
7878 @example
7879 guix build --with-graft=gnutls=gnutls@@3.5.4 wget
7880 @end example
7881
7882 This has the advantage of being much faster than rebuilding everything.
7883 But there is a caveat: it works if and only if @var{package} and
7884 @var{replacement} are strictly compatible---for example, if they provide
7885 a library, the application binary interface (ABI) of those libraries
7886 must be compatible. If @var{replacement} is somehow incompatible with
7887 @var{package}, then the resulting package may be unusable. Use with
7888 care!
7889
7890 @item --with-git-url=@var{package}=@var{url}
7891 @cindex Git, using the latest commit
7892 @cindex latest commit, building
7893 Build @var{package} from the latest commit of the @code{master} branch of the
7894 Git repository at @var{url}. Git sub-modules of the repository are fetched,
7895 recursively.
7896
7897 For example, the following command builds the NumPy Python library against the
7898 latest commit of the master branch of Python itself:
7899
7900 @example
7901 guix build python-numpy \
7902 --with-git-url=python=https://github.com/python/cpython
7903 @end example
7904
7905 This option can also be combined with @code{--with-branch} or
7906 @code{--with-commit} (see below).
7907
7908 @cindex continuous integration
7909 Obviously, since it uses the latest commit of the given branch, the result of
7910 such a command varies over time. Nevertheless it is a convenient way to
7911 rebuild entire software stacks against the latest commit of one or more
7912 packages. This is particularly useful in the context of continuous
7913 integration (CI).
7914
7915 Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
7916 consecutive accesses to the same repository. You may want to clean it up once
7917 in a while to save disk space.
7918
7919 @item --with-branch=@var{package}=@var{branch}
7920 Build @var{package} from the latest commit of @var{branch}. If the
7921 @code{source} field of @var{package} is an origin with the @code{git-fetch}
7922 method (@pxref{origin Reference}) or a @code{git-checkout} object, the
7923 repository URL is taken from that @code{source}. Otherwise you have to use
7924 @code{--with-git-url} to specify the URL of the Git repository.
7925
7926 For instance, the following command builds @code{guile-sqlite3} from the
7927 latest commit of its @code{master} branch, and then builds @code{guix} (which
7928 depends on it) and @code{cuirass} (which depends on @code{guix}) against this
7929 specific @code{guile-sqlite3} build:
7930
7931 @example
7932 guix build --with-branch=guile-sqlite3=master cuirass
7933 @end example
7934
7935 @item --with-commit=@var{package}=@var{commit}
7936 This is similar to @code{--with-branch}, except that it builds from
7937 @var{commit} rather than the tip of a branch. @var{commit} must be a valid
7938 Git commit SHA1 identifier.
7939 @end table
7940
7941 @node Additional Build Options
7942 @subsection Additional Build Options
7943
7944 The command-line options presented below are specific to @command{guix
7945 build}.
7946
7947 @table @code
7948
7949 @item --quiet
7950 @itemx -q
7951 Build quietly, without displaying the build log; this is equivalent to
7952 @code{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
7953 (or similar) and can always be retrieved using the @option{--log-file} option.
7954
7955 @item --file=@var{file}
7956 @itemx -f @var{file}
7957 Build the package, derivation, or other file-like object that the code within
7958 @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
7959
7960 As an example, @var{file} might contain a package definition like this
7961 (@pxref{Defining Packages}):
7962
7963 @example
7964 @verbatiminclude package-hello.scm
7965 @end example
7966
7967 @item --expression=@var{expr}
7968 @itemx -e @var{expr}
7969 Build the package or derivation @var{expr} evaluates to.
7970
7971 For example, @var{expr} may be @code{(@@ (gnu packages guile)
7972 guile-1.8)}, which unambiguously designates this specific variant of
7973 version 1.8 of Guile.
7974
7975 Alternatively, @var{expr} may be a G-expression, in which case it is used
7976 as a build program passed to @code{gexp->derivation}
7977 (@pxref{G-Expressions}).
7978
7979 Lastly, @var{expr} may refer to a zero-argument monadic procedure
7980 (@pxref{The Store Monad}). The procedure must return a derivation as a
7981 monadic value, which is then passed through @code{run-with-store}.
7982
7983 @item --source
7984 @itemx -S
7985 Build the source derivations of the packages, rather than the packages
7986 themselves.
7987
7988 For instance, @code{guix build -S gcc} returns something like
7989 @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
7990 source tarball.
7991
7992 The returned source tarball is the result of applying any patches and
7993 code snippets specified in the package @code{origin} (@pxref{Defining
7994 Packages}).
7995
7996 @item --sources
7997 Fetch and return the source of @var{package-or-derivation} and all their
7998 dependencies, recursively. This is a handy way to obtain a local copy
7999 of all the source code needed to build @var{packages}, allowing you to
8000 eventually build them even without network access. It is an extension
8001 of the @code{--source} option and can accept one of the following
8002 optional argument values:
8003
8004 @table @code
8005 @item package
8006 This value causes the @code{--sources} option to behave in the same way
8007 as the @code{--source} option.
8008
8009 @item all
8010 Build the source derivations of all packages, including any source that
8011 might be listed as @code{inputs}. This is the default value.
8012
8013 @example
8014 $ guix build --sources tzdata
8015 The following derivations will be built:
8016 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
8017 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
8018 @end example
8019
8020 @item transitive
8021 Build the source derivations of all packages, as well of all transitive
8022 inputs to the packages. This can be used e.g.@: to
8023 prefetch package source for later offline building.
8024
8025 @example
8026 $ guix build --sources=transitive tzdata
8027 The following derivations will be built:
8028 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
8029 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
8030 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
8031 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
8032 /gnu/store/@dots{}-make-4.1.tar.xz.drv
8033 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
8034 @dots{}
8035 @end example
8036
8037 @end table
8038
8039 @item --system=@var{system}
8040 @itemx -s @var{system}
8041 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
8042 the system type of the build host. The @command{guix build} command allows
8043 you to repeat this option several times, in which case it builds for all the
8044 specified systems; other commands ignore extraneous @option{-s} options.
8045
8046 @quotation Note
8047 The @code{--system} flag is for @emph{native} compilation and must not
8048 be confused with cross-compilation. See @code{--target} below for
8049 information on cross-compilation.
8050 @end quotation
8051
8052 An example use of this is on Linux-based systems, which can emulate
8053 different personalities. For instance, passing
8054 @code{--system=i686-linux} on an @code{x86_64-linux} system or
8055 @code{--system=armhf-linux} on an @code{aarch64-linux} system allows you
8056 to build packages in a complete 32-bit environment.
8057
8058 @quotation Note
8059 Building for an @code{armhf-linux} system is unconditionally enabled on
8060 @code{aarch64-linux} machines, although certain aarch64 chipsets do not
8061 allow for this functionality, notably the ThunderX.
8062 @end quotation
8063
8064 Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
8065 is enabled (@pxref{Virtualization Services,
8066 @code{qemu-binfmt-service-type}}), you can build for any system for
8067 which a QEMU @code{binfmt_misc} handler is installed.
8068
8069 Builds for a system other than that of the machine you are using can
8070 also be offloaded to a remote machine of the right architecture.
8071 @xref{Daemon Offload Setup}, for more information on offloading.
8072
8073 @item --target=@var{triplet}
8074 @cindex cross-compilation
8075 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
8076 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
8077 configuration triplets,, autoconf, Autoconf}).
8078
8079 @anchor{build-check}
8080 @item --check
8081 @cindex determinism, checking
8082 @cindex reproducibility, checking
8083 Rebuild @var{package-or-derivation}, which are already available in the
8084 store, and raise an error if the build results are not bit-for-bit
8085 identical.
8086
8087 This mechanism allows you to check whether previously installed
8088 substitutes are genuine (@pxref{Substitutes}), or whether the build result
8089 of a package is deterministic. @xref{Invoking guix challenge}, for more
8090 background information and tools.
8091
8092 When used in conjunction with @option{--keep-failed}, the differing
8093 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
8094 This makes it easy to look for differences between the two results.
8095
8096 @item --repair
8097 @cindex repairing store items
8098 @cindex corruption, recovering from
8099 Attempt to repair the specified store items, if they are corrupt, by
8100 re-downloading or rebuilding them.
8101
8102 This operation is not atomic and thus restricted to @code{root}.
8103
8104 @item --derivations
8105 @itemx -d
8106 Return the derivation paths, not the output paths, of the given
8107 packages.
8108
8109 @item --root=@var{file}
8110 @itemx -r @var{file}
8111 @cindex GC roots, adding
8112 @cindex garbage collector roots, adding
8113 Make @var{file} a symlink to the result, and register it as a garbage
8114 collector root.
8115
8116 Consequently, the results of this @command{guix build} invocation are
8117 protected from garbage collection until @var{file} is removed. When
8118 that option is omitted, build results are eligible for garbage
8119 collection as soon as the build completes. @xref{Invoking guix gc}, for
8120 more on GC roots.
8121
8122 @item --log-file
8123 @cindex build logs, access
8124 Return the build log file names or URLs for the given
8125 @var{package-or-derivation}, or raise an error if build logs are
8126 missing.
8127
8128 This works regardless of how packages or derivations are specified. For
8129 instance, the following invocations are equivalent:
8130
8131 @example
8132 guix build --log-file `guix build -d guile`
8133 guix build --log-file `guix build guile`
8134 guix build --log-file guile
8135 guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
8136 @end example
8137
8138 If a log is unavailable locally, and unless @code{--no-substitutes} is
8139 passed, the command looks for a corresponding log on one of the
8140 substitute servers (as specified with @code{--substitute-urls}.)
8141
8142 So for instance, imagine you want to see the build log of GDB on MIPS,
8143 but you are actually on an @code{x86_64} machine:
8144
8145 @example
8146 $ guix build --log-file gdb -s mips64el-linux
8147 https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
8148 @end example
8149
8150 You can freely access a huge library of build logs!
8151 @end table
8152
8153 @node Debugging Build Failures
8154 @subsection Debugging Build Failures
8155
8156 @cindex build failures, debugging
8157 When defining a new package (@pxref{Defining Packages}), you will
8158 probably find yourself spending some time debugging and tweaking the
8159 build until it succeeds. To do that, you need to operate the build
8160 commands yourself in an environment as close as possible to the one the
8161 build daemon uses.
8162
8163 To that end, the first thing to do is to use the @option{--keep-failed}
8164 or @option{-K} option of @command{guix build}, which will keep the
8165 failed build tree in @file{/tmp} or whatever directory you specified as
8166 @code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
8167
8168 From there on, you can @command{cd} to the failed build tree and source
8169 the @file{environment-variables} file, which contains all the
8170 environment variable definitions that were in place when the build
8171 failed. So let's say you're debugging a build failure in package
8172 @code{foo}; a typical session would look like this:
8173
8174 @example
8175 $ guix build foo -K
8176 @dots{} @i{build fails}
8177 $ cd /tmp/guix-build-foo.drv-0
8178 $ source ./environment-variables
8179 $ cd foo-1.2
8180 @end example
8181
8182 Now, you can invoke commands as if you were the daemon (almost) and
8183 troubleshoot your build process.
8184
8185 Sometimes it happens that, for example, a package's tests pass when you
8186 run them manually but they fail when the daemon runs them. This can
8187 happen because the daemon runs builds in containers where, unlike in our
8188 environment above, network access is missing, @file{/bin/sh} does not
8189 exist, etc. (@pxref{Build Environment Setup}).
8190
8191 In such cases, you may need to run inspect the build process from within
8192 a container similar to the one the build daemon creates:
8193
8194 @example
8195 $ guix build -K foo
8196 @dots{}
8197 $ cd /tmp/guix-build-foo.drv-0
8198 $ guix environment --no-grafts -C foo --ad-hoc strace gdb
8199 [env]# source ./environment-variables
8200 [env]# cd foo-1.2
8201 @end example
8202
8203 Here, @command{guix environment -C} creates a container and spawns a new
8204 shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
8205 strace gdb} part adds the @command{strace} and @command{gdb} commands to
8206 the container, which would may find handy while debugging. The
8207 @option{--no-grafts} option makes sure we get the exact same
8208 environment, with ungrafted packages (@pxref{Security Updates}, for more
8209 info on grafts).
8210
8211 To get closer to a container like that used by the build daemon, we can
8212 remove @file{/bin/sh}:
8213
8214 @example
8215 [env]# rm /bin/sh
8216 @end example
8217
8218 (Don't worry, this is harmless: this is all happening in the throw-away
8219 container created by @command{guix environment}.)
8220
8221 The @command{strace} command is probably not in the search path, but we
8222 can run:
8223
8224 @example
8225 [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
8226 @end example
8227
8228 In this way, not only you will have reproduced the environment variables
8229 the daemon uses, you will also be running the build process in a container
8230 similar to the one the daemon uses.
8231
8232
8233 @node Invoking guix edit
8234 @section Invoking @command{guix edit}
8235
8236 @cindex @command{guix edit}
8237 @cindex package definition, editing
8238 So many packages, so many source files! The @command{guix edit} command
8239 facilitates the life of users and packagers by pointing their editor at
8240 the source file containing the definition of the specified packages.
8241 For instance:
8242
8243 @example
8244 guix edit gcc@@4.9 vim
8245 @end example
8246
8247 @noindent
8248 launches the program specified in the @code{VISUAL} or in the
8249 @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
8250 and that of Vim.
8251
8252 If you are using a Guix Git checkout (@pxref{Building from Git}), or
8253 have created your own packages on @code{GUIX_PACKAGE_PATH}
8254 (@pxref{Package Modules}), you will be able to edit the package
8255 recipes. In other cases, you will be able to examine the read-only recipes
8256 for packages currently in the store.
8257
8258
8259 @node Invoking guix download
8260 @section Invoking @command{guix download}
8261
8262 @cindex @command{guix download}
8263 @cindex downloading package sources
8264 When writing a package definition, developers typically need to download
8265 a source tarball, compute its SHA256 hash, and write that
8266 hash in the package definition (@pxref{Defining Packages}). The
8267 @command{guix download} tool helps with this task: it downloads a file
8268 from the given URI, adds it to the store, and prints both its file name
8269 in the store and its SHA256 hash.
8270
8271 The fact that the downloaded file is added to the store saves bandwidth:
8272 when the developer eventually tries to build the newly defined package
8273 with @command{guix build}, the source tarball will not have to be
8274 downloaded again because it is already in the store. It is also a
8275 convenient way to temporarily stash files, which may be deleted
8276 eventually (@pxref{Invoking guix gc}).
8277
8278 The @command{guix download} command supports the same URIs as used in
8279 package definitions. In particular, it supports @code{mirror://} URIs.
8280 @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
8281 Guile bindings for GnuTLS are available in the user's environment; when
8282 they are not available, an error is raised. @xref{Guile Preparations,
8283 how to install the GnuTLS bindings for Guile,, gnutls-guile,
8284 GnuTLS-Guile}, for more information.
8285
8286 @command{guix download} verifies HTTPS server certificates by loading
8287 the certificates of X.509 authorities from the directory pointed to by
8288 the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
8289 Certificates}), unless @option{--no-check-certificate} is used.
8290
8291 The following options are available:
8292
8293 @table @code
8294 @item --format=@var{fmt}
8295 @itemx -f @var{fmt}
8296 Write the hash in the format specified by @var{fmt}. For more
8297 information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
8298
8299 @item --no-check-certificate
8300 Do not validate the X.509 certificates of HTTPS servers.
8301
8302 When using this option, you have @emph{absolutely no guarantee} that you
8303 are communicating with the authentic server responsible for the given
8304 URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
8305
8306 @item --output=@var{file}
8307 @itemx -o @var{file}
8308 Save the downloaded file to @var{file} instead of adding it to the
8309 store.
8310 @end table
8311
8312 @node Invoking guix hash
8313 @section Invoking @command{guix hash}
8314
8315 @cindex @command{guix hash}
8316 The @command{guix hash} command computes the SHA256 hash of a file.
8317 It is primarily a convenience tool for anyone contributing to the
8318 distribution: it computes the cryptographic hash of a file, which can be
8319 used in the definition of a package (@pxref{Defining Packages}).
8320
8321 The general syntax is:
8322
8323 @example
8324 guix hash @var{option} @var{file}
8325 @end example
8326
8327 When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
8328 hash of data read from standard input. @command{guix hash} has the
8329 following options:
8330
8331 @table @code
8332
8333 @item --format=@var{fmt}
8334 @itemx -f @var{fmt}
8335 Write the hash in the format specified by @var{fmt}.
8336
8337 Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
8338 (@code{hex} and @code{hexadecimal} can be used as well).
8339
8340 If the @option{--format} option is not specified, @command{guix hash}
8341 will output the hash in @code{nix-base32}. This representation is used
8342 in the definitions of packages.
8343
8344 @item --recursive
8345 @itemx -r
8346 Compute the hash on @var{file} recursively.
8347
8348 In this case, the hash is computed on an archive containing @var{file},
8349 including its children if it is a directory. Some of the metadata of
8350 @var{file} is part of the archive; for instance, when @var{file} is a
8351 regular file, the hash is different depending on whether @var{file} is
8352 executable or not. Metadata such as time stamps has no impact on the
8353 hash (@pxref{Invoking guix archive}).
8354 @c FIXME: Replace xref above with xref to an ``Archive'' section when
8355 @c it exists.
8356
8357 @item --exclude-vcs
8358 @itemx -x
8359 When combined with @option{--recursive}, exclude version control system
8360 directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
8361
8362 @vindex git-fetch
8363 As an example, here is how you would compute the hash of a Git checkout,
8364 which is useful when using the @code{git-fetch} method (@pxref{origin
8365 Reference}):
8366
8367 @example
8368 $ git clone http://example.org/foo.git
8369 $ cd foo
8370 $ guix hash -rx .
8371 @end example
8372 @end table
8373
8374 @node Invoking guix import
8375 @section Invoking @command{guix import}
8376
8377 @cindex importing packages
8378 @cindex package import
8379 @cindex package conversion
8380 @cindex Invoking @command{guix import}
8381 The @command{guix import} command is useful for people who would like to
8382 add a package to the distribution with as little work as
8383 possible---a legitimate demand. The command knows of a few
8384 repositories from which it can ``import'' package metadata. The result
8385 is a package definition, or a template thereof, in the format we know
8386 (@pxref{Defining Packages}).
8387
8388 The general syntax is:
8389
8390 @example
8391 guix import @var{importer} @var{options}@dots{}
8392 @end example
8393
8394 @var{importer} specifies the source from which to import package
8395 metadata, and @var{options} specifies a package identifier and other
8396 options specific to @var{importer}. Currently, the available
8397 ``importers'' are:
8398
8399 @table @code
8400 @item gnu
8401 Import metadata for the given GNU package. This provides a template
8402 for the latest version of that GNU package, including the hash of its
8403 source tarball, and its canonical synopsis and description.
8404
8405 Additional information such as the package dependencies and its
8406 license needs to be figured out manually.
8407
8408 For example, the following command returns a package definition for
8409 GNU@tie{}Hello:
8410
8411 @example
8412 guix import gnu hello
8413 @end example
8414
8415 Specific command-line options are:
8416
8417 @table @code
8418 @item --key-download=@var{policy}
8419 As for @code{guix refresh}, specify the policy to handle missing OpenPGP
8420 keys when verifying the package signature. @xref{Invoking guix
8421 refresh, @code{--key-download}}.
8422 @end table
8423
8424 @item pypi
8425 @cindex pypi
8426 Import metadata from the @uref{https://pypi.python.org/, Python Package
8427 Index}. Information is taken from the JSON-formatted description
8428 available at @code{pypi.python.org} and usually includes all the relevant
8429 information, including package dependencies. For maximum efficiency, it
8430 is recommended to install the @command{unzip} utility, so that the
8431 importer can unzip Python wheels and gather data from them.
8432
8433 The command below imports metadata for the @code{itsdangerous} Python
8434 package:
8435
8436 @example
8437 guix import pypi itsdangerous
8438 @end example
8439
8440 @table @code
8441 @item --recursive
8442 @itemx -r
8443 Traverse the dependency graph of the given upstream package recursively
8444 and generate package expressions for all those packages that are not yet
8445 in Guix.
8446 @end table
8447
8448 @item gem
8449 @cindex gem
8450 Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
8451 is taken from the JSON-formatted description available at
8452 @code{rubygems.org} and includes most relevant information, including
8453 runtime dependencies. There are some caveats, however. The metadata
8454 doesn't distinguish between synopses and descriptions, so the same string
8455 is used for both fields. Additionally, the details of non-Ruby
8456 dependencies required to build native extensions is unavailable and left
8457 as an exercise to the packager.
8458
8459 The command below imports metadata for the @code{rails} Ruby package:
8460
8461 @example
8462 guix import gem rails
8463 @end example
8464
8465 @table @code
8466 @item --recursive
8467 @itemx -r
8468 Traverse the dependency graph of the given upstream package recursively
8469 and generate package expressions for all those packages that are not yet
8470 in Guix.
8471 @end table
8472
8473 @item cpan
8474 @cindex CPAN
8475 Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
8476 Information is taken from the JSON-formatted metadata provided through
8477 @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
8478 relevant information, such as module dependencies. License information
8479 should be checked closely. If Perl is available in the store, then the
8480 @code{corelist} utility will be used to filter core modules out of the
8481 list of dependencies.
8482
8483 The command command below imports metadata for the @code{Acme::Boolean}
8484 Perl module:
8485
8486 @example
8487 guix import cpan Acme::Boolean
8488 @end example
8489
8490 @item cran
8491 @cindex CRAN
8492 @cindex Bioconductor
8493 Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
8494 central repository for the @uref{http://r-project.org, GNU@tie{}R
8495 statistical and graphical environment}.
8496
8497 Information is extracted from the @code{DESCRIPTION} file of the package.
8498
8499 The command command below imports metadata for the @code{Cairo}
8500 R package:
8501
8502 @example
8503 guix import cran Cairo
8504 @end example
8505
8506 When @code{--recursive} is added, the importer will traverse the
8507 dependency graph of the given upstream package recursively and generate
8508 package expressions for all those packages that are not yet in Guix.
8509
8510 When @code{--archive=bioconductor} is added, metadata is imported from
8511 @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
8512 packages for for the analysis and comprehension of high-throughput
8513 genomic data in bioinformatics.
8514
8515 Information is extracted from the @code{DESCRIPTION} file of a package
8516 published on the web interface of the Bioconductor SVN repository.
8517
8518 The command below imports metadata for the @code{GenomicRanges}
8519 R package:
8520
8521 @example
8522 guix import cran --archive=bioconductor GenomicRanges
8523 @end example
8524
8525 @item texlive
8526 @cindex TeX Live
8527 @cindex CTAN
8528 Import metadata from @uref{http://www.ctan.org/, CTAN}, the
8529 comprehensive TeX archive network for TeX packages that are part of the
8530 @uref{https://www.tug.org/texlive/, TeX Live distribution}.
8531
8532 Information about the package is obtained through the XML API provided
8533 by CTAN, while the source code is downloaded from the SVN repository of
8534 the Tex Live project. This is done because the CTAN does not keep
8535 versioned archives.
8536
8537 The command command below imports metadata for the @code{fontspec}
8538 TeX package:
8539
8540 @example
8541 guix import texlive fontspec
8542 @end example
8543
8544 When @code{--archive=DIRECTORY} is added, the source code is downloaded
8545 not from the @file{latex} sub-directory of the @file{texmf-dist/source}
8546 tree in the TeX Live SVN repository, but from the specified sibling
8547 directory under the same root.
8548
8549 The command below imports metadata for the @code{ifxetex} package from
8550 CTAN while fetching the sources from the directory
8551 @file{texmf/source/generic}:
8552
8553 @example
8554 guix import texlive --archive=generic ifxetex
8555 @end example
8556
8557 @item json
8558 @cindex JSON, import
8559 Import package metadata from a local JSON file. Consider the following
8560 example package definition in JSON format:
8561
8562 @example
8563 @{
8564 "name": "hello",
8565 "version": "2.10",
8566 "source": "mirror://gnu/hello/hello-2.10.tar.gz",
8567 "build-system": "gnu",
8568 "home-page": "https://www.gnu.org/software/hello/",
8569 "synopsis": "Hello, GNU world: An example GNU package",
8570 "description": "GNU Hello prints a greeting.",
8571 "license": "GPL-3.0+",
8572 "native-inputs": ["gcc@@6"]
8573 @}
8574 @end example
8575
8576 The field names are the same as for the @code{<package>} record
8577 (@xref{Defining Packages}). References to other packages are provided
8578 as JSON lists of quoted package specification strings such as
8579 @code{guile} or @code{guile@@2.0}.
8580
8581 The importer also supports a more explicit source definition using the
8582 common fields for @code{<origin>} records:
8583
8584 @example
8585 @{
8586 @dots{}
8587 "source": @{
8588 "method": "url-fetch",
8589 "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
8590 "sha256": @{
8591 "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
8592 @}
8593 @}
8594 @dots{}
8595 @}
8596 @end example
8597
8598 The command below reads metadata from the JSON file @code{hello.json}
8599 and outputs a package expression:
8600
8601 @example
8602 guix import json hello.json
8603 @end example
8604
8605 @item nix
8606 Import metadata from a local copy of the source of the
8607 @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
8608 relies on the @command{nix-instantiate} command of
8609 @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
8610 typically written in a mixture of Nix-language and Bash code. This
8611 command only imports the high-level package structure that is written in
8612 the Nix language. It normally includes all the basic fields of a
8613 package definition.
8614
8615 When importing a GNU package, the synopsis and descriptions are replaced
8616 by their canonical upstream variant.
8617
8618 Usually, you will first need to do:
8619
8620 @example
8621 export NIX_REMOTE=daemon
8622 @end example
8623
8624 @noindent
8625 so that @command{nix-instantiate} does not try to open the Nix database.
8626
8627 As an example, the command below imports the package definition of
8628 LibreOffice (more precisely, it imports the definition of the package
8629 bound to the @code{libreoffice} top-level attribute):
8630
8631 @example
8632 guix import nix ~/path/to/nixpkgs libreoffice
8633 @end example
8634
8635 @item hackage
8636 @cindex hackage
8637 Import metadata from the Haskell community's central package archive
8638 @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
8639 Cabal files and includes all the relevant information, including package
8640 dependencies.
8641
8642 Specific command-line options are:
8643
8644 @table @code
8645 @item --stdin
8646 @itemx -s
8647 Read a Cabal file from standard input.
8648 @item --no-test-dependencies
8649 @itemx -t
8650 Do not include dependencies required only by the test suites.
8651 @item --cabal-environment=@var{alist}
8652 @itemx -e @var{alist}
8653 @var{alist} is a Scheme alist defining the environment in which the
8654 Cabal conditionals are evaluated. The accepted keys are: @code{os},
8655 @code{arch}, @code{impl} and a string representing the name of a flag.
8656 The value associated with a flag has to be either the symbol
8657 @code{true} or @code{false}. The value associated with other keys
8658 has to conform to the Cabal file format definition. The default value
8659 associated with the keys @code{os}, @code{arch} and @code{impl} is
8660 @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
8661 @item --recursive
8662 @itemx -r
8663 Traverse the dependency graph of the given upstream package recursively
8664 and generate package expressions for all those packages that are not yet
8665 in Guix.
8666 @end table
8667
8668 The command below imports metadata for the latest version of the
8669 @code{HTTP} Haskell package without including test dependencies and
8670 specifying the value of the flag @samp{network-uri} as @code{false}:
8671
8672 @example
8673 guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
8674 @end example
8675
8676 A specific package version may optionally be specified by following the
8677 package name by an at-sign and a version number as in the following example:
8678
8679 @example
8680 guix import hackage mtl@@2.1.3.1
8681 @end example
8682
8683 @item stackage
8684 @cindex stackage
8685 The @code{stackage} importer is a wrapper around the @code{hackage} one.
8686 It takes a package name, looks up the package version included in a
8687 long-term support (LTS) @uref{https://www.stackage.org, Stackage}
8688 release and uses the @code{hackage} importer to retrieve its metadata.
8689 Note that it is up to you to select an LTS release compatible with the
8690 GHC compiler used by Guix.
8691
8692 Specific command-line options are:
8693
8694 @table @code
8695 @item --no-test-dependencies
8696 @itemx -t
8697 Do not include dependencies required only by the test suites.
8698 @item --lts-version=@var{version}
8699 @itemx -l @var{version}
8700 @var{version} is the desired LTS release version. If omitted the latest
8701 release is used.
8702 @item --recursive
8703 @itemx -r
8704 Traverse the dependency graph of the given upstream package recursively
8705 and generate package expressions for all those packages that are not yet
8706 in Guix.
8707 @end table
8708
8709 The command below imports metadata for the @code{HTTP} Haskell package
8710 included in the LTS Stackage release version 7.18:
8711
8712 @example
8713 guix import stackage --lts-version=7.18 HTTP
8714 @end example
8715
8716 @item elpa
8717 @cindex elpa
8718 Import metadata from an Emacs Lisp Package Archive (ELPA) package
8719 repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
8720
8721 Specific command-line options are:
8722
8723 @table @code
8724 @item --archive=@var{repo}
8725 @itemx -a @var{repo}
8726 @var{repo} identifies the archive repository from which to retrieve the
8727 information. Currently the supported repositories and their identifiers
8728 are:
8729 @itemize -
8730 @item
8731 @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
8732 identifier. This is the default.
8733
8734 Packages from @code{elpa.gnu.org} are signed with one of the keys
8735 contained in the GnuPG keyring at
8736 @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
8737 @code{emacs} package (@pxref{Package Installation, ELPA package
8738 signatures,, emacs, The GNU Emacs Manual}).
8739
8740 @item
8741 @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
8742 @code{melpa-stable} identifier.
8743
8744 @item
8745 @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
8746 identifier.
8747 @end itemize
8748
8749 @item --recursive
8750 @itemx -r
8751 Traverse the dependency graph of the given upstream package recursively
8752 and generate package expressions for all those packages that are not yet
8753 in Guix.
8754 @end table
8755
8756 @item crate
8757 @cindex crate
8758 Import metadata from the crates.io Rust package repository
8759 @uref{https://crates.io, crates.io}.
8760
8761 @item opam
8762 @cindex OPAM
8763 @cindex OCaml
8764 Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
8765 repository used by the OCaml community.
8766 @end table
8767
8768 The structure of the @command{guix import} code is modular. It would be
8769 useful to have more importers for other package formats, and your help
8770 is welcome here (@pxref{Contributing}).
8771
8772 @node Invoking guix refresh
8773 @section Invoking @command{guix refresh}
8774
8775 @cindex @command {guix refresh}
8776 The primary audience of the @command{guix refresh} command is developers
8777 of the GNU software distribution. By default, it reports any packages
8778 provided by the distribution that are outdated compared to the latest
8779 upstream version, like this:
8780
8781 @example
8782 $ guix refresh
8783 gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
8784 gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
8785 @end example
8786
8787 Alternately, one can specify packages to consider, in which case a
8788 warning is emitted for packages that lack an updater:
8789
8790 @example
8791 $ guix refresh coreutils guile guile-ssh
8792 gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
8793 gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
8794 @end example
8795
8796 @command{guix refresh} browses the upstream repository of each package and determines
8797 the highest version number of the releases therein. The command
8798 knows how to update specific types of packages: GNU packages, ELPA
8799 packages, etc.---see the documentation for @option{--type} below. There
8800 are many packages, though, for which it lacks a method to determine
8801 whether a new upstream release is available. However, the mechanism is
8802 extensible, so feel free to get in touch with us to add a new method!
8803
8804 @table @code
8805
8806 @item --recursive
8807 Consider the packages specified, and all the packages upon which they depend.
8808
8809 @example
8810 $ guix refresh --recursive coreutils
8811 gnu/packages/acl.scm:35:2: warning: no updater for acl
8812 gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
8813 gnu/packages/xml.scm:68:2: warning: no updater for expat
8814 gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest version of gmp
8815 @dots{}
8816 @end example
8817
8818 @end table
8819
8820 Sometimes the upstream name differs from the package name used in Guix,
8821 and @command{guix refresh} needs a little help. Most updaters honor the
8822 @code{upstream-name} property in package definitions, which can be used
8823 to that effect:
8824
8825 @example
8826 (define-public network-manager
8827 (package
8828 (name "network-manager")
8829 ;; @dots{}
8830 (properties '((upstream-name . "NetworkManager")))))
8831 @end example
8832
8833 When passed @code{--update}, it modifies distribution source files to
8834 update the version numbers and source tarball hashes of those package
8835 recipes (@pxref{Defining Packages}). This is achieved by downloading
8836 each package's latest source tarball and its associated OpenPGP
8837 signature, authenticating the downloaded tarball against its signature
8838 using @command{gpg}, and finally computing its hash. When the public
8839 key used to sign the tarball is missing from the user's keyring, an
8840 attempt is made to automatically retrieve it from a public key server;
8841 when this is successful, the key is added to the user's keyring; otherwise,
8842 @command{guix refresh} reports an error.
8843
8844 The following options are supported:
8845
8846 @table @code
8847
8848 @item --expression=@var{expr}
8849 @itemx -e @var{expr}
8850 Consider the package @var{expr} evaluates to.
8851
8852 This is useful to precisely refer to a package, as in this example:
8853
8854 @example
8855 guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
8856 @end example
8857
8858 This command lists the dependents of the ``final'' libc (essentially all
8859 the packages.)
8860
8861 @item --update
8862 @itemx -u
8863 Update distribution source files (package recipes) in place. This is
8864 usually run from a checkout of the Guix source tree (@pxref{Running
8865 Guix Before It Is Installed}):
8866
8867 @example
8868 $ ./pre-inst-env guix refresh -s non-core -u
8869 @end example
8870
8871 @xref{Defining Packages}, for more information on package definitions.
8872
8873 @item --select=[@var{subset}]
8874 @itemx -s @var{subset}
8875 Select all the packages in @var{subset}, one of @code{core} or
8876 @code{non-core}.
8877
8878 The @code{core} subset refers to all the packages at the core of the
8879 distribution---i.e., packages that are used to build ``everything
8880 else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
8881 changing one of these packages in the distribution entails a rebuild of
8882 all the others. Thus, such updates are an inconvenience to users in
8883 terms of build time or bandwidth used to achieve the upgrade.
8884
8885 The @code{non-core} subset refers to the remaining packages. It is
8886 typically useful in cases where an update of the core packages would be
8887 inconvenient.
8888
8889 @item --manifest=@var{file}
8890 @itemx -m @var{file}
8891 Select all the packages from the manifest in @var{file}. This is useful to
8892 check if any packages of the user manifest can be updated.
8893
8894 @item --type=@var{updater}
8895 @itemx -t @var{updater}
8896 Select only packages handled by @var{updater} (may be a comma-separated
8897 list of updaters). Currently, @var{updater} may be one of:
8898
8899 @table @code
8900 @item gnu
8901 the updater for GNU packages;
8902 @item gnome
8903 the updater for GNOME packages;
8904 @item kde
8905 the updater for KDE packages;
8906 @item xorg
8907 the updater for X.org packages;
8908 @item kernel.org
8909 the updater for packages hosted on kernel.org;
8910 @item elpa
8911 the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
8912 @item cran
8913 the updater for @uref{https://cran.r-project.org/, CRAN} packages;
8914 @item bioconductor
8915 the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
8916 @item cpan
8917 the updater for @uref{http://www.cpan.org/, CPAN} packages;
8918 @item pypi
8919 the updater for @uref{https://pypi.python.org, PyPI} packages.
8920 @item gem
8921 the updater for @uref{https://rubygems.org, RubyGems} packages.
8922 @item github
8923 the updater for @uref{https://github.com, GitHub} packages.
8924 @item hackage
8925 the updater for @uref{https://hackage.haskell.org, Hackage} packages.
8926 @item stackage
8927 the updater for @uref{https://www.stackage.org, Stackage} packages.
8928 @item crate
8929 the updater for @uref{https://crates.io, Crates} packages.
8930 @item launchpad
8931 the updater for @uref{https://launchpad.net, Launchpad} packages.
8932 @end table
8933
8934 For instance, the following command only checks for updates of Emacs
8935 packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
8936
8937 @example
8938 $ guix refresh --type=elpa,cran
8939 gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
8940 gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
8941 @end example
8942
8943 @end table
8944
8945 In addition, @command{guix refresh} can be passed one or more package
8946 names, as in this example:
8947
8948 @example
8949 $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
8950 @end example
8951
8952 @noindent
8953 The command above specifically updates the @code{emacs} and
8954 @code{idutils} packages. The @code{--select} option would have no
8955 effect in this case.
8956
8957 When considering whether to upgrade a package, it is sometimes
8958 convenient to know which packages would be affected by the upgrade and
8959 should be checked for compatibility. For this the following option may
8960 be used when passing @command{guix refresh} one or more package names:
8961
8962 @table @code
8963
8964 @item --list-updaters
8965 @itemx -L
8966 List available updaters and exit (see @option{--type} above.)
8967
8968 For each updater, display the fraction of packages it covers; at the
8969 end, display the fraction of packages covered by all these updaters.
8970
8971 @item --list-dependent
8972 @itemx -l
8973 List top-level dependent packages that would need to be rebuilt as a
8974 result of upgrading one or more packages.
8975
8976 @xref{Invoking guix graph, the @code{reverse-package} type of
8977 @command{guix graph}}, for information on how to visualize the list of
8978 dependents of a package.
8979
8980 @end table
8981
8982 Be aware that the @code{--list-dependent} option only
8983 @emph{approximates} the rebuilds that would be required as a result of
8984 an upgrade. More rebuilds might be required under some circumstances.
8985
8986 @example
8987 $ guix refresh --list-dependent flex
8988 Building the following 120 packages would ensure 213 dependent packages are rebuilt:
8989 hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
8990 @end example
8991
8992 The command above lists a set of packages that could be built to check
8993 for compatibility with an upgraded @code{flex} package.
8994
8995 @table @code
8996
8997 @item --list-transitive
8998 List all the packages which one or more packages depend upon.
8999
9000 @example
9001 $ guix refresh --list-transitive flex
9002 flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
9003 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{}
9004 @end example
9005
9006 @end table
9007
9008 The command above lists a set of packages which, when changed, would cause
9009 @code{flex} to be rebuilt.
9010
9011 The following options can be used to customize GnuPG operation:
9012
9013 @table @code
9014
9015 @item --gpg=@var{command}
9016 Use @var{command} as the GnuPG 2.x command. @var{command} is searched
9017 for in @code{$PATH}.
9018
9019 @item --keyring=@var{file}
9020 Use @var{file} as the keyring for upstream keys. @var{file} must be in the
9021 @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
9022 and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
9023 (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
9024 information on a tool to manipulate keybox files).
9025
9026 When this option is omitted, @command{guix refresh} uses
9027 @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
9028 signing keys. OpenPGP signatures are checked against keys from this keyring;
9029 missing keys are downloaded to this keyring as well (see
9030 @option{--key-download} below.)
9031
9032 You can export keys from your default GPG keyring into a keybox file using
9033 commands like this one:
9034
9035 @example
9036 gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
9037 @end example
9038
9039 Likewise, you can fetch keys to a specific keybox file like this:
9040
9041 @example
9042 gpg --no-default-keyring --keyring mykeyring.kbx \
9043 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
9044 @end example
9045
9046 @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
9047 Privacy Guard}, for more information on GPG's @option{--keyring} option.
9048
9049 @item --key-download=@var{policy}
9050 Handle missing OpenPGP keys according to @var{policy}, which may be one
9051 of:
9052
9053 @table @code
9054 @item always
9055 Always download missing OpenPGP keys from the key server, and add them
9056 to the user's GnuPG keyring.
9057
9058 @item never
9059 Never try to download missing OpenPGP keys. Instead just bail out.
9060
9061 @item interactive
9062 When a package signed with an unknown OpenPGP key is encountered, ask
9063 the user whether to download it or not. This is the default behavior.
9064 @end table
9065
9066 @item --key-server=@var{host}
9067 Use @var{host} as the OpenPGP key server when importing a public key.
9068
9069 @end table
9070
9071 The @code{github} updater uses the
9072 @uref{https://developer.github.com/v3/, GitHub API} to query for new
9073 releases. When used repeatedly e.g.@: when refreshing all packages,
9074 GitHub will eventually refuse to answer any further API requests. By
9075 default 60 API requests per hour are allowed, and a full refresh on all
9076 GitHub packages in Guix requires more than this. Authentication with
9077 GitHub through the use of an API token alleviates these limits. To use
9078 an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
9079 token procured from @uref{https://github.com/settings/tokens} or
9080 otherwise.
9081
9082
9083 @node Invoking guix lint
9084 @section Invoking @command{guix lint}
9085
9086 @cindex @command{guix lint}
9087 @cindex package, checking for errors
9088 The @command{guix lint} command is meant to help package developers avoid
9089 common errors and use a consistent style. It runs a number of checks on
9090 a given set of packages in order to find common mistakes in their
9091 definitions. Available @dfn{checkers} include (see
9092 @code{--list-checkers} for a complete list):
9093
9094 @table @code
9095 @item synopsis
9096 @itemx description
9097 Validate certain typographical and stylistic rules about package
9098 descriptions and synopses.
9099
9100 @item inputs-should-be-native
9101 Identify inputs that should most likely be native inputs.
9102
9103 @item source
9104 @itemx home-page
9105 @itemx mirror-url
9106 @itemx github-url
9107 @itemx source-file-name
9108 Probe @code{home-page} and @code{source} URLs and report those that are
9109 invalid. Suggest a @code{mirror://} URL when applicable. If the
9110 @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
9111 URL. Check that the source file name is meaningful, e.g.@: is not just a
9112 version number or ``git-checkout'', without a declared @code{file-name}
9113 (@pxref{origin Reference}).
9114
9115 @item source-unstable-tarball
9116 Parse the @code{source} URL to determine if a tarball from GitHub is
9117 autogenerated or if it is a release tarball. Unfortunately GitHub's
9118 autogenerated tarballs are sometimes regenerated.
9119
9120 @item cve
9121 @cindex security vulnerabilities
9122 @cindex CVE, Common Vulnerabilities and Exposures
9123 Report known vulnerabilities found in the Common Vulnerabilities and
9124 Exposures (CVE) databases of the current and past year
9125 @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
9126 NIST}.
9127
9128 To view information about a particular vulnerability, visit pages such as:
9129
9130 @itemize
9131 @item
9132 @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
9133 @item
9134 @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
9135 @end itemize
9136
9137 @noindent
9138 where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
9139 @code{CVE-2015-7554}.
9140
9141 Package developers can specify in package recipes the
9142 @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
9143 name and version of the package when they differ from the name or version
9144 that Guix uses, as in this example:
9145
9146 @example
9147 (package
9148 (name "grub")
9149 ;; @dots{}
9150 ;; CPE calls this package "grub2".
9151 (properties '((cpe-name . "grub2")
9152 (cpe-version . "2.3")))
9153 @end example
9154
9155 @c See <http://www.openwall.com/lists/oss-security/2017/03/15/3>.
9156 Some entries in the CVE database do not specify which version of a
9157 package they apply to, and would thus ``stick around'' forever. Package
9158 developers who found CVE alerts and verified they can be ignored can
9159 declare them as in this example:
9160
9161 @example
9162 (package
9163 (name "t1lib")
9164 ;; @dots{}
9165 ;; These CVEs no longer apply and can be safely ignored.
9166 (properties `((lint-hidden-cve . ("CVE-2011-0433"
9167 "CVE-2011-1553"
9168 "CVE-2011-1554"
9169 "CVE-2011-5244")))))
9170 @end example
9171
9172 @item formatting
9173 Warn about obvious source code formatting issues: trailing white space,
9174 use of tabulations, etc.
9175 @end table
9176
9177 The general syntax is:
9178
9179 @example
9180 guix lint @var{options} @var{package}@dots{}
9181 @end example
9182
9183 If no package is given on the command line, then all packages are checked.
9184 The @var{options} may be zero or more of the following:
9185
9186 @table @code
9187 @item --list-checkers
9188 @itemx -l
9189 List and describe all the available checkers that will be run on packages
9190 and exit.
9191
9192 @item --checkers
9193 @itemx -c
9194 Only enable the checkers specified in a comma-separated list using the
9195 names returned by @code{--list-checkers}.
9196
9197 @end table
9198
9199 @node Invoking guix size
9200 @section Invoking @command{guix size}
9201
9202 @cindex size
9203 @cindex package size
9204 @cindex closure
9205 @cindex @command{guix size}
9206 The @command{guix size} command helps package developers profile the
9207 disk usage of packages. It is easy to overlook the impact of an
9208 additional dependency added to a package, or the impact of using a
9209 single output for a package that could easily be split (@pxref{Packages
9210 with Multiple Outputs}). Such are the typical issues that
9211 @command{guix size} can highlight.
9212
9213 The command can be passed one or more package specifications
9214 such as @code{gcc@@4.8}
9215 or @code{guile:debug}, or a file name in the store. Consider this
9216 example:
9217
9218 @example
9219 $ guix size coreutils
9220 store item total self
9221 /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
9222 /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
9223 /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
9224 /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
9225 /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
9226 /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
9227 /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
9228 /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
9229 total: 78.9 MiB
9230 @end example
9231
9232 @cindex closure
9233 The store items listed here constitute the @dfn{transitive closure} of
9234 Coreutils---i.e., Coreutils and all its dependencies, recursively---as
9235 would be returned by:
9236
9237 @example
9238 $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
9239 @end example
9240
9241 Here the output shows three columns next to store items. The first column,
9242 labeled ``total'', shows the size in mebibytes (MiB) of the closure of
9243 the store item---that is, its own size plus the size of all its
9244 dependencies. The next column, labeled ``self'', shows the size of the
9245 item itself. The last column shows the ratio of the size of the item
9246 itself to the space occupied by all the items listed here.
9247
9248 In this example, we see that the closure of Coreutils weighs in at
9249 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
9250 libraries. (That libc and GCC's libraries represent a large fraction of
9251 the closure is not a problem @i{per se} because they are always available
9252 on the system anyway.)
9253
9254 When the package(s) passed to @command{guix size} are available in the
9255 store@footnote{More precisely, @command{guix size} looks for the
9256 @emph{ungrafted} variant of the given package(s), as returned by
9257 @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
9258 for information on grafts.}, @command{guix size} queries the daemon to determine its
9259 dependencies, and measures its size in the store, similar to @command{du
9260 -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
9261 Coreutils}).
9262
9263 When the given packages are @emph{not} in the store, @command{guix size}
9264 reports information based on the available substitutes
9265 (@pxref{Substitutes}). This makes it possible it to profile disk usage of
9266 store items that are not even on disk, only available remotely.
9267
9268 You can also specify several package names:
9269
9270 @example
9271 $ guix size coreutils grep sed bash
9272 store item total self
9273 /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
9274 /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
9275 /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
9276 /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
9277 @dots{}
9278 total: 102.3 MiB
9279 @end example
9280
9281 @noindent
9282 In this example we see that the combination of the four packages takes
9283 102.3@tie{}MiB in total, which is much less than the sum of each closure
9284 since they have a lot of dependencies in common.
9285
9286 The available options are:
9287
9288 @table @option
9289
9290 @item --substitute-urls=@var{urls}
9291 Use substitute information from @var{urls}.
9292 @xref{client-substitute-urls, the same option for @code{guix build}}.
9293
9294 @item --sort=@var{key}
9295 Sort lines according to @var{key}, one of the following options:
9296
9297 @table @code
9298 @item self
9299 the size of each item (the default);
9300 @item closure
9301 the total size of the item's closure.
9302 @end table
9303
9304 @item --map-file=@var{file}
9305 Write a graphical map of disk usage in PNG format to @var{file}.
9306
9307 For the example above, the map looks like this:
9308
9309 @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
9310 produced by @command{guix size}}
9311
9312 This option requires that
9313 @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
9314 installed and visible in Guile's module search path. When that is not
9315 the case, @command{guix size} fails as it tries to load it.
9316
9317 @item --system=@var{system}
9318 @itemx -s @var{system}
9319 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
9320
9321 @end table
9322
9323 @node Invoking guix graph
9324 @section Invoking @command{guix graph}
9325
9326 @cindex DAG
9327 @cindex @command{guix graph}
9328 @cindex package dependencies
9329 Packages and their dependencies form a @dfn{graph}, specifically a
9330 directed acyclic graph (DAG). It can quickly become difficult to have a
9331 mental model of the package DAG, so the @command{guix graph} command
9332 provides a visual representation of the DAG. By default,
9333 @command{guix graph} emits a DAG representation in the input format of
9334 @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
9335 directly to the @command{dot} command of Graphviz. It can also emit an
9336 HTML page with embedded JavaScript code to display a ``chord diagram''
9337 in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
9338 emit Cypher queries to construct a graph in a graph database supporting
9339 the @uref{http://www.opencypher.org/, openCypher} query language.
9340 The general syntax is:
9341
9342 @example
9343 guix graph @var{options} @var{package}@dots{}
9344 @end example
9345
9346 For example, the following command generates a PDF file representing the
9347 package DAG for the GNU@tie{}Core Utilities, showing its build-time
9348 dependencies:
9349
9350 @example
9351 guix graph coreutils | dot -Tpdf > dag.pdf
9352 @end example
9353
9354 The output looks like this:
9355
9356 @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
9357
9358 Nice little graph, no?
9359
9360 But there is more than one graph! The one above is concise: it is the
9361 graph of package objects, omitting implicit inputs such as GCC, libc,
9362 grep, etc. It is often useful to have such a concise graph, but
9363 sometimes one may want to see more details. @command{guix graph} supports
9364 several types of graphs, allowing you to choose the level of detail:
9365
9366 @table @code
9367 @item package
9368 This is the default type used in the example above. It shows the DAG of
9369 package objects, excluding implicit dependencies. It is concise, but
9370 filters out many details.
9371
9372 @item reverse-package
9373 This shows the @emph{reverse} DAG of packages. For example:
9374
9375 @example
9376 guix graph --type=reverse-package ocaml
9377 @end example
9378
9379 ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
9380 you are also interested in cases where OCaml is an implicit dependency, see
9381 @code{reverse-bag} below.)
9382
9383 Note that for core packages this can yield huge graphs. If all you want
9384 is to know the number of packages that depend on a given package, use
9385 @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
9386 @option{--list-dependent}}).
9387
9388 @item bag-emerged
9389 This is the package DAG, @emph{including} implicit inputs.
9390
9391 For instance, the following command:
9392
9393 @example
9394 guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
9395 @end example
9396
9397 ...@: yields this bigger graph:
9398
9399 @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
9400
9401 At the bottom of the graph, we see all the implicit inputs of
9402 @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
9403
9404 Now, note that the dependencies of these implicit inputs---that is, the
9405 @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
9406 here, for conciseness.
9407
9408 @item bag
9409 Similar to @code{bag-emerged}, but this time including all the bootstrap
9410 dependencies.
9411
9412 @item bag-with-origins
9413 Similar to @code{bag}, but also showing origins and their dependencies.
9414
9415 @item reverse-bag
9416 This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
9417 it also takes implicit dependencies into account. For example:
9418
9419 @example
9420 guix graph -t reverse-bag dune
9421 @end example
9422
9423 @noindent
9424 ...@: yields the graph of all packages that depend on Dune, directly or
9425 indirectly. Since Dune is an @emph{implicit} dependency of many packages
9426 @i{via} @code{dune-build-system}, this shows a large number of packages,
9427 whereas @code{reverse-package} would show very few if any.
9428
9429 @item derivation
9430 This is the most detailed representation: It shows the DAG of
9431 derivations (@pxref{Derivations}) and plain store items. Compared to
9432 the above representation, many additional nodes are visible, including
9433 build scripts, patches, Guile modules, etc.
9434
9435 For this type of graph, it is also possible to pass a @file{.drv} file
9436 name instead of a package name, as in:
9437
9438 @example
9439 guix graph -t derivation `guix system build -d my-config.scm`
9440 @end example
9441
9442 @item module
9443 This is the graph of @dfn{package modules} (@pxref{Package Modules}).
9444 For example, the following command shows the graph for the package
9445 module that defines the @code{guile} package:
9446
9447 @example
9448 guix graph -t module guile | dot -Tpdf > module-graph.pdf
9449 @end example
9450 @end table
9451
9452 All the types above correspond to @emph{build-time dependencies}. The
9453 following graph type represents the @emph{run-time dependencies}:
9454
9455 @table @code
9456 @item references
9457 This is the graph of @dfn{references} of a package output, as returned
9458 by @command{guix gc --references} (@pxref{Invoking guix gc}).
9459
9460 If the given package output is not available in the store, @command{guix
9461 graph} attempts to obtain dependency information from substitutes.
9462
9463 Here you can also pass a store file name instead of a package name. For
9464 example, the command below produces the reference graph of your profile
9465 (which can be big!):
9466
9467 @example
9468 guix graph -t references `readlink -f ~/.guix-profile`
9469 @end example
9470
9471 @item referrers
9472 This is the graph of the @dfn{referrers} of a store item, as returned by
9473 @command{guix gc --referrers} (@pxref{Invoking guix gc}).
9474
9475 This relies exclusively on local information from your store. For
9476 instance, let us suppose that the current Inkscape is available in 10
9477 profiles on your machine; @command{guix graph -t referrers inkscape}
9478 will show a graph rooted at Inkscape and with those 10 profiles linked
9479 to it.
9480
9481 It can help determine what is preventing a store item from being garbage
9482 collected.
9483
9484 @end table
9485
9486 The available options are the following:
9487
9488 @table @option
9489 @item --type=@var{type}
9490 @itemx -t @var{type}
9491 Produce a graph output of @var{type}, where @var{type} must be one of
9492 the values listed above.
9493
9494 @item --list-types
9495 List the supported graph types.
9496
9497 @item --backend=@var{backend}
9498 @itemx -b @var{backend}
9499 Produce a graph using the selected @var{backend}.
9500
9501 @item --list-backends
9502 List the supported graph backends.
9503
9504 Currently, the available backends are Graphviz and d3.js.
9505
9506 @item --expression=@var{expr}
9507 @itemx -e @var{expr}
9508 Consider the package @var{expr} evaluates to.
9509
9510 This is useful to precisely refer to a package, as in this example:
9511
9512 @example
9513 guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
9514 @end example
9515
9516 @item --system=@var{system}
9517 @itemx -s @var{system}
9518 Display the graph for @var{system}---e.g., @code{i686-linux}.
9519
9520 The package dependency graph is largely architecture-independent, but there
9521 are some architecture-dependent bits that this option allows you to visualize.
9522 @end table
9523
9524
9525
9526 @node Invoking guix publish
9527 @section Invoking @command{guix publish}
9528
9529 @cindex @command{guix publish}
9530 The purpose of @command{guix publish} is to enable users to easily share
9531 their store with others, who can then use it as a substitute server
9532 (@pxref{Substitutes}).
9533
9534 When @command{guix publish} runs, it spawns an HTTP server which allows
9535 anyone with network access to obtain substitutes from it. This means
9536 that any machine running Guix can also act as if it were a build farm,
9537 since the HTTP interface is compatible with Hydra, the software behind
9538 the @code{@value{SUBSTITUTE-SERVER}} build farm.
9539
9540 For security, each substitute is signed, allowing recipients to check
9541 their authenticity and integrity (@pxref{Substitutes}). Because
9542 @command{guix publish} uses the signing key of the system, which is only
9543 readable by the system administrator, it must be started as root; the
9544 @code{--user} option makes it drop root privileges early on.
9545
9546 The signing key pair must be generated before @command{guix publish} is
9547 launched, using @command{guix archive --generate-key} (@pxref{Invoking
9548 guix archive}).
9549
9550 The general syntax is:
9551
9552 @example
9553 guix publish @var{options}@dots{}
9554 @end example
9555
9556 Running @command{guix publish} without any additional arguments will
9557 spawn an HTTP server on port 8080:
9558
9559 @example
9560 guix publish
9561 @end example
9562
9563 Once a publishing server has been authorized (@pxref{Invoking guix
9564 archive}), the daemon may download substitutes from it:
9565
9566 @example
9567 guix-daemon --substitute-urls=http://example.org:8080
9568 @end example
9569
9570 By default, @command{guix publish} compresses archives on the fly as it
9571 serves them. This ``on-the-fly'' mode is convenient in that it requires
9572 no setup and is immediately available. However, when serving lots of
9573 clients, we recommend using the @option{--cache} option, which enables
9574 caching of the archives before they are sent to clients---see below for
9575 details. The @command{guix weather} command provides a handy way to
9576 check what a server provides (@pxref{Invoking guix weather}).
9577
9578 As a bonus, @command{guix publish} also serves as a content-addressed
9579 mirror for source files referenced in @code{origin} records
9580 (@pxref{origin Reference}). For instance, assuming @command{guix
9581 publish} is running on @code{example.org}, the following URL returns the
9582 raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
9583 (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
9584
9585 @example
9586 http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
9587 @end example
9588
9589 Obviously, these URLs only work for files that are in the store; in
9590 other cases, they return 404 (``Not Found'').
9591
9592 @cindex build logs, publication
9593 Build logs are available from @code{/log} URLs like:
9594
9595 @example
9596 http://example.org/log/gwspk@dots{}-guile-2.2.3
9597 @end example
9598
9599 @noindent
9600 When @command{guix-daemon} is configured to save compressed build logs,
9601 as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
9602 URLs return the compressed log as-is, with an appropriate
9603 @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
9604 running @command{guix-daemon} with @code{--log-compression=gzip} since
9605 Web browsers can automatically decompress it, which is not the case with
9606 bzip2 compression.
9607
9608 The following options are available:
9609
9610 @table @code
9611 @item --port=@var{port}
9612 @itemx -p @var{port}
9613 Listen for HTTP requests on @var{port}.
9614
9615 @item --listen=@var{host}
9616 Listen on the network interface for @var{host}. The default is to
9617 accept connections from any interface.
9618
9619 @item --user=@var{user}
9620 @itemx -u @var{user}
9621 Change privileges to @var{user} as soon as possible---i.e., once the
9622 server socket is open and the signing key has been read.
9623
9624 @item --compression[=@var{level}]
9625 @itemx -C [@var{level}]
9626 Compress data using the given @var{level}. When @var{level} is zero,
9627 disable compression. The range 1 to 9 corresponds to different gzip
9628 compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
9629 The default is 3.
9630
9631 Unless @option{--cache} is used, compression occurs on the fly and
9632 the compressed streams are not
9633 cached. Thus, to reduce load on the machine that runs @command{guix
9634 publish}, it may be a good idea to choose a low compression level, to
9635 run @command{guix publish} behind a caching proxy, or to use
9636 @option{--cache}. Using @option{--cache} has the advantage that it
9637 allows @command{guix publish} to add @code{Content-Length} HTTP header
9638 to its responses.
9639
9640 @item --cache=@var{directory}
9641 @itemx -c @var{directory}
9642 Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
9643 and only serve archives that are in cache.
9644
9645 When this option is omitted, archives and meta-data are created
9646 on-the-fly. This can reduce the available bandwidth, especially when
9647 compression is enabled, since this may become CPU-bound. Another
9648 drawback of the default mode is that the length of archives is not known
9649 in advance, so @command{guix publish} does not add a
9650 @code{Content-Length} HTTP header to its responses, which in turn
9651 prevents clients from knowing the amount of data being downloaded.
9652
9653 Conversely, when @option{--cache} is used, the first request for a store
9654 item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
9655 background process to @dfn{bake} the archive---computing its
9656 @code{.narinfo} and compressing the archive, if needed. Once the
9657 archive is cached in @var{directory}, subsequent requests succeed and
9658 are served directly from the cache, which guarantees that clients get
9659 the best possible bandwidth.
9660
9661 The ``baking'' process is performed by worker threads. By default, one
9662 thread per CPU core is created, but this can be customized. See
9663 @option{--workers} below.
9664
9665 When @option{--ttl} is used, cached entries are automatically deleted
9666 when they have expired.
9667
9668 @item --workers=@var{N}
9669 When @option{--cache} is used, request the allocation of @var{N} worker
9670 threads to ``bake'' archives.
9671
9672 @item --ttl=@var{ttl}
9673 Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
9674 (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
9675 days, @code{1m} means 1 month, and so on.
9676
9677 This allows the user's Guix to keep substitute information in cache for
9678 @var{ttl}. However, note that @code{guix publish} does not itself
9679 guarantee that the store items it provides will indeed remain available
9680 for as long as @var{ttl}.
9681
9682 Additionally, when @option{--cache} is used, cached entries that have
9683 not been accessed for @var{ttl} and that no longer have a corresponding
9684 item in the store, may be deleted.
9685
9686 @item --nar-path=@var{path}
9687 Use @var{path} as the prefix for the URLs of ``nar'' files
9688 (@pxref{Invoking guix archive, normalized archives}).
9689
9690 By default, nars are served at a URL such as
9691 @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
9692 change the @code{/nar} part to @var{path}.
9693
9694 @item --public-key=@var{file}
9695 @itemx --private-key=@var{file}
9696 Use the specific @var{file}s as the public/private key pair used to sign
9697 the store items being published.
9698
9699 The files must correspond to the same key pair (the private key is used
9700 for signing and the public key is merely advertised in the signature
9701 metadata). They must contain keys in the canonical s-expression format
9702 as produced by @command{guix archive --generate-key} (@pxref{Invoking
9703 guix archive}). By default, @file{/etc/guix/signing-key.pub} and
9704 @file{/etc/guix/signing-key.sec} are used.
9705
9706 @item --repl[=@var{port}]
9707 @itemx -r [@var{port}]
9708 Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
9709 Reference Manual}) on @var{port} (37146 by default). This is used
9710 primarily for debugging a running @command{guix publish} server.
9711 @end table
9712
9713 Enabling @command{guix publish} on Guix System is a one-liner: just
9714 instantiate a @code{guix-publish-service-type} service in the @code{services} field
9715 of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
9716 @code{guix-publish-service-type}}).
9717
9718 If you are instead running Guix on a ``foreign distro'', follow these
9719 instructions:”
9720
9721 @itemize
9722 @item
9723 If your host distro uses the systemd init system:
9724
9725 @example
9726 # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
9727 /etc/systemd/system/
9728 # systemctl start guix-publish && systemctl enable guix-publish
9729 @end example
9730
9731 @item
9732 If your host distro uses the Upstart init system:
9733
9734 @example
9735 # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
9736 # start guix-publish
9737 @end example
9738
9739 @item
9740 Otherwise, proceed similarly with your distro's init system.
9741 @end itemize
9742
9743 @node Invoking guix challenge
9744 @section Invoking @command{guix challenge}
9745
9746 @cindex reproducible builds
9747 @cindex verifiable builds
9748 @cindex @command{guix challenge}
9749 @cindex challenge
9750 Do the binaries provided by this server really correspond to the source
9751 code it claims to build? Is a package build process deterministic?
9752 These are the questions the @command{guix challenge} command attempts to
9753 answer.
9754
9755 The former is obviously an important question: Before using a substitute
9756 server (@pxref{Substitutes}), one had better @emph{verify} that it
9757 provides the right binaries, and thus @emph{challenge} it. The latter
9758 is what enables the former: If package builds are deterministic, then
9759 independent builds of the package should yield the exact same result,
9760 bit for bit; if a server provides a binary different from the one
9761 obtained locally, it may be either corrupt or malicious.
9762
9763 We know that the hash that shows up in @file{/gnu/store} file names is
9764 the hash of all the inputs of the process that built the file or
9765 directory---compilers, libraries, build scripts,
9766 etc. (@pxref{Introduction}). Assuming deterministic build processes,
9767 one store file name should map to exactly one build output.
9768 @command{guix challenge} checks whether there is, indeed, a single
9769 mapping by comparing the build outputs of several independent builds of
9770 any given store item.
9771
9772 The command output looks like this:
9773
9774 @smallexample
9775 $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
9776 updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
9777 updating list of substitutes from 'https://guix.example.org'... 100.0%
9778 /gnu/store/@dots{}-openssl-1.0.2d contents differ:
9779 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
9780 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
9781 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
9782 /gnu/store/@dots{}-git-2.5.0 contents differ:
9783 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
9784 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
9785 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
9786 /gnu/store/@dots{}-pius-2.1.1 contents differ:
9787 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
9788 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
9789 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
9790
9791 @dots{}
9792
9793 6,406 store items were analyzed:
9794 - 4,749 (74.1%) were identical
9795 - 525 (8.2%) differed
9796 - 1,132 (17.7%) were inconclusive
9797 @end smallexample
9798
9799 @noindent
9800 In this example, @command{guix challenge} first scans the store to
9801 determine the set of locally-built derivations---as opposed to store
9802 items that were downloaded from a substitute server---and then queries
9803 all the substitute servers. It then reports those store items for which
9804 the servers obtained a result different from the local build.
9805
9806 @cindex non-determinism, in package builds
9807 As an example, @code{guix.example.org} always gets a different answer.
9808 Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
9809 case of Git. This might indicate that the build process of Git is
9810 non-deterministic, meaning that its output varies as a function of
9811 various things that Guix does not fully control, in spite of building
9812 packages in isolated environments (@pxref{Features}). Most common
9813 sources of non-determinism include the addition of timestamps in build
9814 results, the inclusion of random numbers, and directory listings sorted
9815 by inode number. See @uref{https://reproducible-builds.org/docs/}, for
9816 more information.
9817
9818 To find out what is wrong with this Git binary, we can do something along
9819 these lines (@pxref{Invoking guix archive}):
9820
9821 @example
9822 $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0 \
9823 | guix archive -x /tmp/git
9824 $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
9825 @end example
9826
9827 This command shows the difference between the files resulting from the
9828 local build, and the files resulting from the build on
9829 @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
9830 diffutils, Comparing and Merging Files}). The @command{diff} command
9831 works great for text files. When binary files differ, a better option
9832 is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
9833 visualize differences for all kinds of files.
9834
9835 Once you have done that work, you can tell whether the differences are due
9836 to a non-deterministic build process or to a malicious server. We try
9837 hard to remove sources of non-determinism in packages to make it easier
9838 to verify substitutes, but of course, this is a process that
9839 involves not just Guix, but a large part of the free software community.
9840 In the meantime, @command{guix challenge} is one tool to help address
9841 the problem.
9842
9843 If you are writing packages for Guix, you are encouraged to check
9844 whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
9845 same build result as you did with:
9846
9847 @example
9848 $ guix challenge @var{package}
9849 @end example
9850
9851 @noindent
9852 where @var{package} is a package specification such as
9853 @code{guile@@2.0} or @code{glibc:debug}.
9854
9855 The general syntax is:
9856
9857 @example
9858 guix challenge @var{options} [@var{packages}@dots{}]
9859 @end example
9860
9861 When a difference is found between the hash of a locally-built item and
9862 that of a server-provided substitute, or among substitutes provided by
9863 different servers, the command displays it as in the example above and
9864 its exit code is 2 (other non-zero exit codes denote other kinds of
9865 errors.)
9866
9867 The one option that matters is:
9868
9869 @table @code
9870
9871 @item --substitute-urls=@var{urls}
9872 Consider @var{urls} the whitespace-separated list of substitute source
9873 URLs to compare to.
9874
9875 @item --verbose
9876 @itemx -v
9877 Show details about matches (identical contents) in addition to
9878 information about mismatches.
9879
9880 @end table
9881
9882 @node Invoking guix copy
9883 @section Invoking @command{guix copy}
9884
9885 @cindex copy, of store items, over SSH
9886 @cindex SSH, copy of store items
9887 @cindex sharing store items across machines
9888 @cindex transferring store items across machines
9889 The @command{guix copy} command copies items from the store of one
9890 machine to that of another machine over a secure shell (SSH)
9891 connection@footnote{This command is available only when Guile-SSH was
9892 found. @xref{Requirements}, for details.}. For example, the following
9893 command copies the @code{coreutils} package, the user's profile, and all
9894 their dependencies over to @var{host}, logged in as @var{user}:
9895
9896 @example
9897 guix copy --to=@var{user}@@@var{host} \
9898 coreutils `readlink -f ~/.guix-profile`
9899 @end example
9900
9901 If some of the items to be copied are already present on @var{host},
9902 they are not actually sent.
9903
9904 The command below retrieves @code{libreoffice} and @code{gimp} from
9905 @var{host}, assuming they are available there:
9906
9907 @example
9908 guix copy --from=@var{host} libreoffice gimp
9909 @end example
9910
9911 The SSH connection is established using the Guile-SSH client, which is
9912 compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
9913 @file{~/.ssh/config}, and uses the SSH agent for authentication.
9914
9915 The key used to sign items that are sent must be accepted by the remote
9916 machine. Likewise, the key used by the remote machine to sign items you
9917 are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
9918 own daemon. @xref{Invoking guix archive}, for more information about
9919 store item authentication.
9920
9921 The general syntax is:
9922
9923 @example
9924 guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
9925 @end example
9926
9927 You must always specify one of the following options:
9928
9929 @table @code
9930 @item --to=@var{spec}
9931 @itemx --from=@var{spec}
9932 Specify the host to send to or receive from. @var{spec} must be an SSH
9933 spec such as @code{example.org}, @code{charlie@@example.org}, or
9934 @code{charlie@@example.org:2222}.
9935 @end table
9936
9937 The @var{items} can be either package names, such as @code{gimp}, or
9938 store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
9939
9940 When specifying the name of a package to send, it is first built if
9941 needed, unless @option{--dry-run} was specified. Common build options
9942 are supported (@pxref{Common Build Options}).
9943
9944
9945 @node Invoking guix container
9946 @section Invoking @command{guix container}
9947 @cindex container
9948 @cindex @command{guix container}
9949 @quotation Note
9950 As of version @value{VERSION}, this tool is experimental. The interface
9951 is subject to radical change in the future.
9952 @end quotation
9953
9954 The purpose of @command{guix container} is to manipulate processes
9955 running within an isolated environment, commonly known as a
9956 ``container'', typically created by the @command{guix environment}
9957 (@pxref{Invoking guix environment}) and @command{guix system container}
9958 (@pxref{Invoking guix system}) commands.
9959
9960 The general syntax is:
9961
9962 @example
9963 guix container @var{action} @var{options}@dots{}
9964 @end example
9965
9966 @var{action} specifies the operation to perform with a container, and
9967 @var{options} specifies the context-specific arguments for the action.
9968
9969 The following actions are available:
9970
9971 @table @code
9972 @item exec
9973 Execute a command within the context of a running container.
9974
9975 The syntax is:
9976
9977 @example
9978 guix container exec @var{pid} @var{program} @var{arguments}@dots{}
9979 @end example
9980
9981 @var{pid} specifies the process ID of the running container.
9982 @var{program} specifies an executable file name within the root file
9983 system of the container. @var{arguments} are the additional options that
9984 will be passed to @var{program}.
9985
9986 The following command launches an interactive login shell inside a
9987 Guix system container, started by @command{guix system container}, and whose
9988 process ID is 9001:
9989
9990 @example
9991 guix container exec 9001 /run/current-system/profile/bin/bash --login
9992 @end example
9993
9994 Note that the @var{pid} cannot be the parent process of a container. It
9995 must be PID 1 of the container or one of its child processes.
9996
9997 @end table
9998
9999 @node Invoking guix weather
10000 @section Invoking @command{guix weather}
10001
10002 Occasionally you're grumpy because substitutes are lacking and you end
10003 up building packages by yourself (@pxref{Substitutes}). The
10004 @command{guix weather} command reports on substitute availability on the
10005 specified servers so you can have an idea of whether you'll be grumpy
10006 today. It can sometimes be useful info as a user, but it is primarily
10007 useful to people running @command{guix publish} (@pxref{Invoking guix
10008 publish}).
10009
10010 @cindex statistics, for substitutes
10011 @cindex availability of substitutes
10012 @cindex substitute availability
10013 @cindex weather, substitute availability
10014 Here's a sample run:
10015
10016 @example
10017 $ guix weather --substitute-urls=https://guix.example.org
10018 computing 5,872 package derivations for x86_64-linux...
10019 looking for 6,128 store items on https://guix.example.org..
10020 updating list of substitutes from 'https://guix.example.org'... 100.0%
10021 https://guix.example.org
10022 43.4% substitutes available (2,658 out of 6,128)
10023 7,032.5 MiB of nars (compressed)
10024 19,824.2 MiB on disk (uncompressed)
10025 0.030 seconds per request (182.9 seconds in total)
10026 33.5 requests per second
10027
10028 9.8% (342 out of 3,470) of the missing items are queued
10029 867 queued builds
10030 x86_64-linux: 518 (59.7%)
10031 i686-linux: 221 (25.5%)
10032 aarch64-linux: 128 (14.8%)
10033 build rate: 23.41 builds per hour
10034 x86_64-linux: 11.16 builds per hour
10035 i686-linux: 6.03 builds per hour
10036 aarch64-linux: 6.41 builds per hour
10037 @end example
10038
10039 @cindex continuous integration, statistics
10040 As you can see, it reports the fraction of all the packages for which
10041 substitutes are available on the server---regardless of whether
10042 substitutes are enabled, and regardless of whether this server's signing
10043 key is authorized. It also reports the size of the compressed archives
10044 (``nars'') provided by the server, the size the corresponding store
10045 items occupy in the store (assuming deduplication is turned off), and
10046 the server's throughput. The second part gives continuous integration
10047 (CI) statistics, if the server supports it. In addition, using the
10048 @option{--coverage} option, @command{guix weather} can list ``important''
10049 package substitutes missing on the server (see below).
10050
10051 To achieve that, @command{guix weather} queries over HTTP(S) meta-data
10052 (@dfn{narinfos}) for all the relevant store items. Like @command{guix
10053 challenge}, it ignores signatures on those substitutes, which is
10054 innocuous since the command only gathers statistics and cannot install
10055 those substitutes.
10056
10057 Among other things, it is possible to query specific system types and
10058 specific package sets. The available options are listed below.
10059
10060 @table @code
10061 @item --substitute-urls=@var{urls}
10062 @var{urls} is the space-separated list of substitute server URLs to
10063 query. When this option is omitted, the default set of substitute
10064 servers is queried.
10065
10066 @item --system=@var{system}
10067 @itemx -s @var{system}
10068 Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
10069 option can be repeated, in which case @command{guix weather} will query
10070 substitutes for several system types.
10071
10072 @item --manifest=@var{file}
10073 Instead of querying substitutes for all the packages, only ask for those
10074 specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
10075 with the @code{-m} option of @command{guix package} (@pxref{Invoking
10076 guix package}).
10077
10078 @item --coverage[=@var{count}]
10079 @itemx -c [@var{count}]
10080 Report on substitute coverage for packages: list packages with at least
10081 @var{count} dependents (zero by default) for which substitutes are
10082 unavailable. Dependent packages themselves are not listed: if @var{b} depends
10083 on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
10084 @var{b} usually lacks substitutes as well. The result looks like this:
10085
10086 @example
10087 $ guix weather --substitute-urls=https://ci.guix.info -c 10
10088 computing 8,983 package derivations for x86_64-linux...
10089 looking for 9,343 store items on https://ci.guix.info...
10090 updating substitutes from 'https://ci.guix.info'... 100.0%
10091 https://ci.guix.info
10092 64.7% substitutes available (6,047 out of 9,343)
10093 @dots{}
10094 2502 packages are missing from 'https://ci.guix.info' for 'x86_64-linux', among which:
10095 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
10096 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
10097 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
10098 @dots{}
10099 @end example
10100
10101 What this example shows is that @code{kcoreaddons} and presumably the 58
10102 packages that depend on it have no substitutes at @code{ci.guix.info};
10103 likewise for @code{qgpgme} and the 46 packages that depend on it.
10104
10105 If you are a Guix developer, or if you are taking care of this build farm,
10106 you'll probably want to have a closer look at these packages: they may simply
10107 fail to build.
10108 @end table
10109
10110 @node Invoking guix processes
10111 @section Invoking @command{guix processes}
10112
10113 The @command{guix processes} command can be useful to developers and system
10114 administrators, especially on multi-user machines and on build farms: it lists
10115 the current sessions (connections to the daemon), as well as information about
10116 the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
10117 started with @option{--listen} specifying a TCP endpoint, are @emph{not}
10118 listed.}. Here's an example of the information it returns:
10119
10120 @example
10121 $ sudo guix processes
10122 SessionPID: 19002
10123 ClientPID: 19090
10124 ClientCommand: guix environment --ad-hoc python
10125
10126 SessionPID: 19402
10127 ClientPID: 19367
10128 ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
10129
10130 SessionPID: 19444
10131 ClientPID: 19419
10132 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
10133 LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
10134 LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
10135 LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
10136 ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
10137 ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
10138 ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
10139 @end example
10140
10141 In this example we see that @command{guix-daemon} has three clients:
10142 @command{guix environment}, @command{guix publish}, and the Cuirass continuous
10143 integration tool; their process identifier (PID) is given by the
10144 @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
10145 @command{guix-daemon} sub-process of this particular session.
10146
10147 The @code{LockHeld} fields show which store items are currently locked by this
10148 session, which corresponds to store items being built or substituted (the
10149 @code{LockHeld} field is not displayed when @command{guix processes} is not
10150 running as root.) Last, by looking at the @code{ChildProcess} field, we
10151 understand that these three builds are being offloaded (@pxref{Daemon Offload
10152 Setup}).
10153
10154 The output is in Recutils format so we can use the handy @command{recsel}
10155 command to select sessions of interest (@pxref{Selection Expressions,,,
10156 recutils, GNU recutils manual}). As an example, the command shows the command
10157 line and PID of the client that triggered the build of a Perl package:
10158
10159 @example
10160 $ sudo guix processes | \
10161 recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
10162 ClientPID: 19419
10163 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
10164 @end example
10165
10166
10167 @node System Configuration
10168 @chapter System Configuration
10169
10170 @cindex system configuration
10171 The Guix System Distribution supports a consistent whole-system configuration
10172 mechanism. By that we mean that all aspects of the global system
10173 configuration---such as the available system services, timezone and
10174 locale settings, user accounts---are declared in a single place. Such
10175 a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
10176
10177 One of the advantages of putting all the system configuration under the
10178 control of Guix is that it supports transactional system upgrades, and
10179 makes it possible to roll back to a previous system instantiation,
10180 should something go wrong with the new one (@pxref{Features}). Another
10181 advantage is that it makes it easy to replicate the exact same configuration
10182 across different machines, or at different points in time, without
10183 having to resort to additional administration tools layered on top of
10184 the own tools of the system.
10185 @c Yes, we're talking of Puppet, Chef, & co. here. ↑
10186
10187 This section describes this mechanism. First we focus on the system
10188 administrator's viewpoint---explaining how the system is configured and
10189 instantiated. Then we show how this mechanism can be extended, for
10190 instance to support new system services.
10191
10192 @menu
10193 * Using the Configuration System:: Customizing your GNU system.
10194 * operating-system Reference:: Detail of operating-system declarations.
10195 * File Systems:: Configuring file system mounts.
10196 * Mapped Devices:: Block device extra processing.
10197 * User Accounts:: Specifying user accounts.
10198 * Keyboard Layout:: How the system interprets key strokes.
10199 * Locales:: Language and cultural convention settings.
10200 * Services:: Specifying system services.
10201 * Setuid Programs:: Programs running with root privileges.
10202 * X.509 Certificates:: Authenticating HTTPS servers.
10203 * Name Service Switch:: Configuring libc's name service switch.
10204 * Initial RAM Disk:: Linux-Libre bootstrapping.
10205 * Bootloader Configuration:: Configuring the boot loader.
10206 * Invoking guix system:: Instantiating a system configuration.
10207 * Running Guix in a VM:: How to run Guix System in a virtual machine.
10208 * Defining Services:: Adding new service definitions.
10209 @end menu
10210
10211 @node Using the Configuration System
10212 @section Using the Configuration System
10213
10214 The operating system is configured by providing an
10215 @code{operating-system} declaration in a file that can then be passed to
10216 the @command{guix system} command (@pxref{Invoking guix system}). A
10217 simple setup, with the default system services, the default Linux-Libre
10218 kernel, initial RAM disk, and boot loader looks like this:
10219
10220 @findex operating-system
10221 @lisp
10222 @include os-config-bare-bones.texi
10223 @end lisp
10224
10225 This example should be self-describing. Some of the fields defined
10226 above, such as @code{host-name} and @code{bootloader}, are mandatory.
10227 Others, such as @code{packages} and @code{services}, can be omitted, in
10228 which case they get a default value.
10229
10230 Below we discuss the effect of some of the most important fields
10231 (@pxref{operating-system Reference}, for details about all the available
10232 fields), and how to @dfn{instantiate} the operating system using
10233 @command{guix system}.
10234
10235 @unnumberedsubsec Bootloader
10236
10237 @cindex legacy boot, on Intel machines
10238 @cindex BIOS boot, on Intel machines
10239 @cindex UEFI boot
10240 @cindex EFI boot
10241 The @code{bootloader} field describes the method that will be used to boot
10242 your system. Machines based on Intel processors can boot in ``legacy'' BIOS
10243 mode, as in the example above. However, more recent machines rely instead on
10244 the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
10245 the @code{bootloader} field should contain something along these lines:
10246
10247 @example
10248 (bootloader-configuration
10249 (bootloader grub-efi-bootloader)
10250 (target "/boot/efi"))
10251 @end example
10252
10253 @xref{Bootloader Configuration}, for more information on the available
10254 configuration options.
10255
10256 @unnumberedsubsec Globally-Visible Packages
10257
10258 @vindex %base-packages
10259 The @code{packages} field lists packages that will be globally visible
10260 on the system, for all user accounts---i.e., in every user's @code{PATH}
10261 environment variable---in addition to the per-user profiles
10262 (@pxref{Invoking guix package}). The @var{%base-packages} variable
10263 provides all the tools one would expect for basic user and administrator
10264 tasks---including the GNU Core Utilities, the GNU Networking Utilities,
10265 the GNU Zile lightweight text editor, @command{find}, @command{grep},
10266 etc. The example above adds GNU@tie{}Screen to those,
10267 taken from the @code{(gnu packages screen)}
10268 module (@pxref{Package Modules}). The
10269 @code{(list package output)} syntax can be used to add a specific output
10270 of a package:
10271
10272 @lisp
10273 (use-modules (gnu packages))
10274 (use-modules (gnu packages dns))
10275
10276 (operating-system
10277 ;; ...
10278 (packages (cons (list bind "utils")
10279 %base-packages)))
10280 @end lisp
10281
10282 @findex specification->package
10283 Referring to packages by variable name, like @code{bind} above, has
10284 the advantage of being unambiguous; it also allows typos and such to be
10285 diagnosed right away as ``unbound variables''. The downside is that one
10286 needs to know which module defines which package, and to augment the
10287 @code{use-package-modules} line accordingly. To avoid that, one can use
10288 the @code{specification->package} procedure of the @code{(gnu packages)}
10289 module, which returns the best package for a given name or name and
10290 version:
10291
10292 @lisp
10293 (use-modules (gnu packages))
10294
10295 (operating-system
10296 ;; ...
10297 (packages (append (map specification->package
10298 '("tcpdump" "htop" "gnupg@@2.0"))
10299 %base-packages)))
10300 @end lisp
10301
10302 @unnumberedsubsec System Services
10303
10304 @cindex services
10305 @vindex %base-services
10306 The @code{services} field lists @dfn{system services} to be made
10307 available when the system starts (@pxref{Services}).
10308 The @code{operating-system} declaration above specifies that, in
10309 addition to the basic services, we want the OpenSSH secure shell
10310 daemon listening on port 2222 (@pxref{Networking Services,
10311 @code{openssh-service-type}}). Under the hood,
10312 @code{openssh-service-type} arranges so that @command{sshd} is started with the
10313 right command-line options, possibly with supporting configuration files
10314 generated as needed (@pxref{Defining Services}).
10315
10316 @cindex customization, of services
10317 @findex modify-services
10318 Occasionally, instead of using the base services as is, you will want to
10319 customize them. To do this, use @code{modify-services} (@pxref{Service
10320 Reference, @code{modify-services}}) to modify the list.
10321
10322 For example, suppose you want to modify @code{guix-daemon} and Mingetty
10323 (the console log-in) in the @var{%base-services} list (@pxref{Base
10324 Services, @code{%base-services}}). To do that, you can write the
10325 following in your operating system declaration:
10326
10327 @lisp
10328 (define %my-services
10329 ;; My very own list of services.
10330 (modify-services %base-services
10331 (guix-service-type config =>
10332 (guix-configuration
10333 (inherit config)
10334 (use-substitutes? #f)
10335 (extra-options '("--gc-keep-derivations"))))
10336 (mingetty-service-type config =>
10337 (mingetty-configuration
10338 (inherit config)))))
10339
10340 (operating-system
10341 ;; @dots{}
10342 (services %my-services))
10343 @end lisp
10344
10345 This changes the configuration---i.e., the service parameters---of the
10346 @code{guix-service-type} instance, and that of all the
10347 @code{mingetty-service-type} instances in the @var{%base-services} list.
10348 Observe how this is accomplished: first, we arrange for the original
10349 configuration to be bound to the identifier @code{config} in the
10350 @var{body}, and then we write the @var{body} so that it evaluates to the
10351 desired configuration. In particular, notice how we use @code{inherit}
10352 to create a new configuration which has the same values as the old
10353 configuration, but with a few modifications.
10354
10355 @cindex encrypted disk
10356 The configuration for a typical ``desktop'' usage, with an encrypted
10357 root partition, the X11 display
10358 server, GNOME and Xfce (users can choose which of these desktop
10359 environments to use at the log-in screen by pressing @kbd{F1}), network
10360 management, power management, and more, would look like this:
10361
10362 @lisp
10363 @include os-config-desktop.texi
10364 @end lisp
10365
10366 A graphical system with a choice of lightweight window managers
10367 instead of full-blown desktop environments would look like this:
10368
10369 @lisp
10370 @include os-config-lightweight-desktop.texi
10371 @end lisp
10372
10373 This example refers to the @file{/boot/efi} file system by its UUID,
10374 @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
10375 as returned by the @command{blkid} command.
10376
10377 @xref{Desktop Services}, for the exact list of services provided by
10378 @var{%desktop-services}. @xref{X.509 Certificates}, for background
10379 information about the @code{nss-certs} package that is used here.
10380
10381 Again, @var{%desktop-services} is just a list of service objects. If
10382 you want to remove services from there, you can do so using the
10383 procedures for list filtering (@pxref{SRFI-1 Filtering and
10384 Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
10385 following expression returns a list that contains all the services in
10386 @var{%desktop-services} minus the Avahi service:
10387
10388 @example
10389 (remove (lambda (service)
10390 (eq? (service-kind service) avahi-service-type))
10391 %desktop-services)
10392 @end example
10393
10394 @unnumberedsubsec Instantiating the System
10395
10396 Assuming the @code{operating-system} declaration
10397 is stored in the @file{my-system-config.scm}
10398 file, the @command{guix system reconfigure my-system-config.scm} command
10399 instantiates that configuration, and makes it the default GRUB boot
10400 entry (@pxref{Invoking guix system}).
10401
10402 The normal way to change the system configuration is by updating this
10403 file and re-running @command{guix system reconfigure}. One should never
10404 have to touch files in @file{/etc} or to run commands that modify the
10405 system state such as @command{useradd} or @command{grub-install}. In
10406 fact, you must avoid that since that would not only void your warranty
10407 but also prevent you from rolling back to previous versions of your
10408 system, should you ever need to.
10409
10410 @cindex roll-back, of the operating system
10411 Speaking of roll-back, each time you run @command{guix system
10412 reconfigure}, a new @dfn{generation} of the system is created---without
10413 modifying or deleting previous generations. Old system generations get
10414 an entry in the bootloader boot menu, allowing you to boot them in case
10415 something went wrong with the latest generation. Reassuring, no? The
10416 @command{guix system list-generations} command lists the system
10417 generations available on disk. It is also possible to roll back the
10418 system via the commands @command{guix system roll-back} and
10419 @command{guix system switch-generation}.
10420
10421 Although the @command{guix system reconfigure} command will not modify
10422 previous generations, you must take care when the current generation is not
10423 the latest (e.g., after invoking @command{guix system roll-back}), since
10424 the operation might overwrite a later generation (@pxref{Invoking guix
10425 system}).
10426
10427 @unnumberedsubsec The Programming Interface
10428
10429 At the Scheme level, the bulk of an @code{operating-system} declaration
10430 is instantiated with the following monadic procedure (@pxref{The Store
10431 Monad}):
10432
10433 @deffn {Monadic Procedure} operating-system-derivation os
10434 Return a derivation that builds @var{os}, an @code{operating-system}
10435 object (@pxref{Derivations}).
10436
10437 The output of the derivation is a single directory that refers to all
10438 the packages, configuration files, and other supporting files needed to
10439 instantiate @var{os}.
10440 @end deffn
10441
10442 This procedure is provided by the @code{(gnu system)} module. Along
10443 with @code{(gnu services)} (@pxref{Services}), this module contains the
10444 guts of Guix System. Make sure to visit it!
10445
10446
10447 @node operating-system Reference
10448 @section @code{operating-system} Reference
10449
10450 This section summarizes all the options available in
10451 @code{operating-system} declarations (@pxref{Using the Configuration
10452 System}).
10453
10454 @deftp {Data Type} operating-system
10455 This is the data type representing an operating system configuration.
10456 By that, we mean all the global system configuration, not per-user
10457 configuration (@pxref{Using the Configuration System}).
10458
10459 @table @asis
10460 @item @code{kernel} (default: @var{linux-libre})
10461 The package object of the operating system kernel to use@footnote{Currently
10462 only the Linux-libre kernel is supported. In the future, it will be
10463 possible to use the GNU@tie{}Hurd.}.
10464
10465 @item @code{kernel-arguments} (default: @code{'("quiet")})
10466 List of strings or gexps representing additional arguments to pass on
10467 the command-line of the kernel---e.g., @code{("console=ttyS0")}.
10468
10469 @item @code{bootloader}
10470 The system bootloader configuration object. @xref{Bootloader Configuration}.
10471
10472 @item @code{label}
10473 This is the label (a string) as it appears in the bootloader's menu entry.
10474 The default label includes the kernel name and version.
10475
10476 @item @code{keyboard-layout} (default: @code{#f})
10477 This field specifies the keyboard layout to use in the console. It can be
10478 either @code{#f}, in which case the default keyboard layout is used (usually
10479 US English), or a @code{<keyboard-layout>} record.
10480
10481 This keyboard layout is in effect as soon as the kernel has booted. For
10482 instance, it is the keyboard layout in effect when you type a passphrase if
10483 your root file system is on a @code{luks-device-mapping} mapped device
10484 (@pxref{Mapped Devices}).
10485
10486 @quotation Note
10487 This does @emph{not} specify the keyboard layout used by the bootloader, nor
10488 that used by the graphical display server. @xref{Bootloader Configuration},
10489 for information on how to specify the bootloader's keyboard layout. @xref{X
10490 Window}, for information on how to specify the keyboard layout used by the X
10491 Window System.
10492 @end quotation
10493
10494 @item @code{initrd-modules} (default: @code{%base-initrd-modules})
10495 @cindex initrd
10496 @cindex initial RAM disk
10497 The list of Linux kernel modules that need to be available in the
10498 initial RAM disk. @xref{Initial RAM Disk}.
10499
10500 @item @code{initrd} (default: @code{base-initrd})
10501 A procedure that returns an initial RAM disk for the Linux
10502 kernel. This field is provided to support low-level customization and
10503 should rarely be needed for casual use. @xref{Initial RAM Disk}.
10504
10505 @item @code{firmware} (default: @var{%base-firmware})
10506 @cindex firmware
10507 List of firmware packages loadable by the operating system kernel.
10508
10509 The default includes firmware needed for Atheros- and Broadcom-based
10510 WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
10511 respectively). @xref{Hardware Considerations}, for more info on
10512 supported hardware.
10513
10514 @item @code{host-name}
10515 The host name.
10516
10517 @item @code{hosts-file}
10518 @cindex hosts file
10519 A file-like object (@pxref{G-Expressions, file-like objects}) for use as
10520 @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
10521 Reference Manual}). The default is a file with entries for
10522 @code{localhost} and @var{host-name}.
10523
10524 @item @code{mapped-devices} (default: @code{'()})
10525 A list of mapped devices. @xref{Mapped Devices}.
10526
10527 @item @code{file-systems}
10528 A list of file systems. @xref{File Systems}.
10529
10530 @item @code{swap-devices} (default: @code{'()})
10531 @cindex swap devices
10532 A list of strings identifying devices or files to be used for ``swap
10533 space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
10534 Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
10535 It is possible to specify a swap file in a file system on a mapped
10536 device, provided that the necessary device mapping and file system are
10537 also specified. @xref{Mapped Devices} and @ref{File Systems}.
10538
10539 @item @code{users} (default: @code{%base-user-accounts})
10540 @itemx @code{groups} (default: @var{%base-groups})
10541 List of user accounts and groups. @xref{User Accounts}.
10542
10543 If the @code{users} list lacks a user account with UID@tie{}0, a
10544 ``root'' account with UID@tie{}0 is automatically added.
10545
10546 @item @code{skeletons} (default: @code{(default-skeletons)})
10547 A list target file name/file-like object tuples (@pxref{G-Expressions,
10548 file-like objects}). These are the skeleton files that will be added to
10549 the home directory of newly-created user accounts.
10550
10551 For instance, a valid value may look like this:
10552
10553 @example
10554 `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
10555 (".guile" ,(plain-file "guile"
10556 "(use-modules (ice-9 readline))
10557 (activate-readline)")))
10558 @end example
10559
10560 @item @code{issue} (default: @var{%default-issue})
10561 A string denoting the contents of the @file{/etc/issue} file, which is
10562 displayed when users log in on a text console.
10563
10564 @item @code{packages} (default: @var{%base-packages})
10565 The set of packages installed in the global profile, which is accessible
10566 at @file{/run/current-system/profile}.
10567
10568 The default set includes core utilities and it is good practice to
10569 install non-core utilities in user profiles (@pxref{Invoking guix
10570 package}).
10571
10572 @item @code{timezone}
10573 A timezone identifying string---e.g., @code{"Europe/Paris"}.
10574
10575 You can run the @command{tzselect} command to find out which timezone
10576 string corresponds to your region. Choosing an invalid timezone name
10577 causes @command{guix system} to fail.
10578
10579 @item @code{locale} (default: @code{"en_US.utf8"})
10580 The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
10581 Library Reference Manual}). @xref{Locales}, for more information.
10582
10583 @item @code{locale-definitions} (default: @var{%default-locale-definitions})
10584 The list of locale definitions to be compiled and that may be used at
10585 run time. @xref{Locales}.
10586
10587 @item @code{locale-libcs} (default: @code{(list @var{glibc})})
10588 The list of GNU@tie{}libc packages whose locale data and tools are used
10589 to build the locale definitions. @xref{Locales}, for compatibility
10590 considerations that justify this option.
10591
10592 @item @code{name-service-switch} (default: @var{%default-nss})
10593 Configuration of the libc name service switch (NSS)---a
10594 @code{<name-service-switch>} object. @xref{Name Service Switch}, for
10595 details.
10596
10597 @item @code{services} (default: @var{%base-services})
10598 A list of service objects denoting system services. @xref{Services}.
10599
10600 @cindex essential services
10601 @item @code{essential-services} (default: ...)
10602 The list of ``essential services''---i.e., things like instances of
10603 @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
10604 Reference}), which are derived from the operating system definition itself.
10605 As a user you should @emph{never} need to touch this field.
10606
10607 @item @code{pam-services} (default: @code{(base-pam-services)})
10608 @cindex PAM
10609 @cindex pluggable authentication modules
10610 Linux @dfn{pluggable authentication module} (PAM) services.
10611 @c FIXME: Add xref to PAM services section.
10612
10613 @item @code{setuid-programs} (default: @var{%setuid-programs})
10614 List of string-valued G-expressions denoting setuid programs.
10615 @xref{Setuid Programs}.
10616
10617 @item @code{sudoers-file} (default: @var{%sudoers-specification})
10618 @cindex sudoers file
10619 The contents of the @file{/etc/sudoers} file as a file-like object
10620 (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
10621
10622 This file specifies which users can use the @command{sudo} command, what
10623 they are allowed to do, and what privileges they may gain. The default
10624 is that only @code{root} and members of the @code{wheel} group may use
10625 @code{sudo}.
10626
10627 @end table
10628
10629 @deffn {Scheme Syntax} this-operating-system
10630 When used in the @emph{lexical scope} of an operating system field definition,
10631 this identifier resolves to the operating system being defined.
10632
10633 The example below shows how to refer to the operating system being defined in
10634 the definition of the @code{label} field:
10635
10636 @example
10637 (use-modules (gnu) (guix))
10638
10639 (operating-system
10640 ;; ...
10641 (label (package-full-name
10642 (operating-system-kernel this-operating-system))))
10643 @end example
10644
10645 It is an error to refer to @code{this-operating-system} outside an operating
10646 system definition.
10647 @end deffn
10648
10649 @end deftp
10650
10651 @node File Systems
10652 @section File Systems
10653
10654 The list of file systems to be mounted is specified in the
10655 @code{file-systems} field of the operating system declaration
10656 (@pxref{Using the Configuration System}). Each file system is declared
10657 using the @code{file-system} form, like this:
10658
10659 @example
10660 (file-system
10661 (mount-point "/home")
10662 (device "/dev/sda3")
10663 (type "ext4"))
10664 @end example
10665
10666 As usual, some of the fields are mandatory---those shown in the example
10667 above---while others can be omitted. These are described below.
10668
10669 @deftp {Data Type} file-system
10670 Objects of this type represent file systems to be mounted. They
10671 contain the following members:
10672
10673 @table @asis
10674 @item @code{type}
10675 This is a string specifying the type of the file system---e.g.,
10676 @code{"ext4"}.
10677
10678 @item @code{mount-point}
10679 This designates the place where the file system is to be mounted.
10680
10681 @item @code{device}
10682 This names the ``source'' of the file system. It can be one of three
10683 things: a file system label, a file system UUID, or the name of a
10684 @file{/dev} node. Labels and UUIDs offer a way to refer to file
10685 systems without having to hard-code their actual device
10686 name@footnote{Note that, while it is tempting to use
10687 @file{/dev/disk/by-uuid} and similar device names to achieve the same
10688 result, this is not recommended: These special device nodes are created
10689 by the udev daemon and may be unavailable at the time the device is
10690 mounted.}.
10691
10692 @findex file-system-label
10693 File system labels are created using the @code{file-system-label}
10694 procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
10695 plain strings. Here's an example of a file system referred to by its
10696 label, as shown by the @command{e2label} command:
10697
10698 @example
10699 (file-system
10700 (mount-point "/home")
10701 (type "ext4")
10702 (device (file-system-label "my-home")))
10703 @end example
10704
10705 @findex uuid
10706 UUIDs are converted from their string representation (as shown by the
10707 @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
10708 @code{uuid} form expects 16-byte UUIDs as defined in
10709 @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
10710 form of UUID used by the ext2 family of file systems and others, but it
10711 is different from ``UUIDs'' found in FAT file systems, for instance.},
10712 like this:
10713
10714 @example
10715 (file-system
10716 (mount-point "/home")
10717 (type "ext4")
10718 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
10719 @end example
10720
10721 When the source of a file system is a mapped device (@pxref{Mapped
10722 Devices}), its @code{device} field @emph{must} refer to the mapped
10723 device name---e.g., @file{"/dev/mapper/root-partition"}.
10724 This is required so that
10725 the system knows that mounting the file system depends on having the
10726 corresponding device mapping established.
10727
10728 @item @code{flags} (default: @code{'()})
10729 This is a list of symbols denoting mount flags. Recognized flags
10730 include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
10731 access to special files), @code{no-suid} (ignore setuid and setgid
10732 bits), and @code{no-exec} (disallow program execution.)
10733
10734 @item @code{options} (default: @code{#f})
10735 This is either @code{#f}, or a string denoting mount options.
10736
10737 @item @code{mount?} (default: @code{#t})
10738 This value indicates whether to automatically mount the file system when
10739 the system is brought up. When set to @code{#f}, the file system gets
10740 an entry in @file{/etc/fstab} (read by the @command{mount} command) but
10741 is not automatically mounted.
10742
10743 @item @code{needed-for-boot?} (default: @code{#f})
10744 This Boolean value indicates whether the file system is needed when
10745 booting. If that is true, then the file system is mounted when the
10746 initial RAM disk (initrd) is loaded. This is always the case, for
10747 instance, for the root file system.
10748
10749 @item @code{check?} (default: @code{#t})
10750 This Boolean indicates whether the file system needs to be checked for
10751 errors before being mounted.
10752
10753 @item @code{create-mount-point?} (default: @code{#f})
10754 When true, the mount point is created if it does not exist yet.
10755
10756 @item @code{dependencies} (default: @code{'()})
10757 This is a list of @code{<file-system>} or @code{<mapped-device>} objects
10758 representing file systems that must be mounted or mapped devices that
10759 must be opened before (and unmounted or closed after) this one.
10760
10761 As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
10762 a dependency of @file{/sys/fs/cgroup/cpu} and
10763 @file{/sys/fs/cgroup/memory}.
10764
10765 Another example is a file system that depends on a mapped device, for
10766 example for an encrypted partition (@pxref{Mapped Devices}).
10767 @end table
10768 @end deftp
10769
10770 The @code{(gnu system file-systems)} exports the following useful
10771 variables.
10772
10773 @defvr {Scheme Variable} %base-file-systems
10774 These are essential file systems that are required on normal systems,
10775 such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
10776 below.) Operating system declarations should always contain at least
10777 these.
10778 @end defvr
10779
10780 @defvr {Scheme Variable} %pseudo-terminal-file-system
10781 This is the file system to be mounted as @file{/dev/pts}. It supports
10782 @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
10783 functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
10784 Manual}). Pseudo-terminals are used by terminal emulators such as
10785 @command{xterm}.
10786 @end defvr
10787
10788 @defvr {Scheme Variable} %shared-memory-file-system
10789 This file system is mounted as @file{/dev/shm} and is used to support
10790 memory sharing across processes (@pxref{Memory-mapped I/O,
10791 @code{shm_open},, libc, The GNU C Library Reference Manual}).
10792 @end defvr
10793
10794 @defvr {Scheme Variable} %immutable-store
10795 This file system performs a read-only ``bind mount'' of
10796 @file{/gnu/store}, making it read-only for all the users including
10797 @code{root}. This prevents against accidental modification by software
10798 running as @code{root} or by system administrators.
10799
10800 The daemon itself is still able to write to the store: it remounts it
10801 read-write in its own ``name space.''
10802 @end defvr
10803
10804 @defvr {Scheme Variable} %binary-format-file-system
10805 The @code{binfmt_misc} file system, which allows handling of arbitrary
10806 executable file types to be delegated to user space. This requires the
10807 @code{binfmt.ko} kernel module to be loaded.
10808 @end defvr
10809
10810 @defvr {Scheme Variable} %fuse-control-file-system
10811 The @code{fusectl} file system, which allows unprivileged users to mount
10812 and unmount user-space FUSE file systems. This requires the
10813 @code{fuse.ko} kernel module to be loaded.
10814 @end defvr
10815
10816 @node Mapped Devices
10817 @section Mapped Devices
10818
10819 @cindex device mapping
10820 @cindex mapped devices
10821 The Linux kernel has a notion of @dfn{device mapping}: a block device,
10822 such as a hard disk partition, can be @dfn{mapped} into another device,
10823 usually in @code{/dev/mapper/},
10824 with additional processing over the data that flows through
10825 it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
10826 concept of a ``mapped device'' and that of a file system: both boil down
10827 to @emph{translating} input/output operations made on a file to
10828 operations on its backing store. Thus, the Hurd implements mapped
10829 devices, like file systems, using the generic @dfn{translator} mechanism
10830 (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
10831 typical example is encryption device mapping: all writes to the mapped
10832 device are encrypted, and all reads are deciphered, transparently.
10833 Guix extends this notion by considering any device or set of devices that
10834 are @dfn{transformed} in some way to create a new device; for instance,
10835 RAID devices are obtained by @dfn{assembling} several other devices, such
10836 as hard disks or partitions, into a new one that behaves as one partition.
10837 Other examples, not yet implemented, are LVM logical volumes.
10838
10839 Mapped devices are declared using the @code{mapped-device} form,
10840 defined as follows; for examples, see below.
10841
10842 @deftp {Data Type} mapped-device
10843 Objects of this type represent device mappings that will be made when
10844 the system boots up.
10845
10846 @table @code
10847 @item source
10848 This is either a string specifying the name of the block device to be mapped,
10849 such as @code{"/dev/sda3"}, or a list of such strings when several devices
10850 need to be assembled for creating a new one.
10851
10852 @item target
10853 This string specifies the name of the resulting mapped device. For
10854 kernel mappers such as encrypted devices of type @code{luks-device-mapping},
10855 specifying @code{"my-partition"} leads to the creation of
10856 the @code{"/dev/mapper/my-partition"} device.
10857 For RAID devices of type @code{raid-device-mapping}, the full device name
10858 such as @code{"/dev/md0"} needs to be given.
10859
10860 @item type
10861 This must be a @code{mapped-device-kind} object, which specifies how
10862 @var{source} is mapped to @var{target}.
10863 @end table
10864 @end deftp
10865
10866 @defvr {Scheme Variable} luks-device-mapping
10867 This defines LUKS block device encryption using the @command{cryptsetup}
10868 command from the package with the same name. It relies on the
10869 @code{dm-crypt} Linux kernel module.
10870 @end defvr
10871
10872 @defvr {Scheme Variable} raid-device-mapping
10873 This defines a RAID device, which is assembled using the @code{mdadm}
10874 command from the package with the same name. It requires a Linux kernel
10875 module for the appropriate RAID level to be loaded, such as @code{raid456}
10876 for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
10877 @end defvr
10878
10879 @cindex disk encryption
10880 @cindex LUKS
10881 The following example specifies a mapping from @file{/dev/sda3} to
10882 @file{/dev/mapper/home} using LUKS---the
10883 @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
10884 standard mechanism for disk encryption.
10885 The @file{/dev/mapper/home}
10886 device can then be used as the @code{device} of a @code{file-system}
10887 declaration (@pxref{File Systems}).
10888
10889 @example
10890 (mapped-device
10891 (source "/dev/sda3")
10892 (target "home")
10893 (type luks-device-mapping))
10894 @end example
10895
10896 Alternatively, to become independent of device numbering, one may obtain
10897 the LUKS UUID (@dfn{unique identifier}) of the source device by a
10898 command like:
10899
10900 @example
10901 cryptsetup luksUUID /dev/sda3
10902 @end example
10903
10904 and use it as follows:
10905
10906 @example
10907 (mapped-device
10908 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
10909 (target "home")
10910 (type luks-device-mapping))
10911 @end example
10912
10913 @cindex swap encryption
10914 It is also desirable to encrypt swap space, since swap space may contain
10915 sensitive data. One way to accomplish that is to use a swap file in a
10916 file system on a device mapped via LUKS encryption. In this way, the
10917 swap file is encrypted because the entire device is encrypted.
10918 @xref{Preparing for Installation,,Disk Partitioning}, for an example.
10919
10920 A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
10921 may be declared as follows:
10922
10923 @example
10924 (mapped-device
10925 (source (list "/dev/sda1" "/dev/sdb1"))
10926 (target "/dev/md0")
10927 (type raid-device-mapping))
10928 @end example
10929
10930 The @file{/dev/md0} device can then be used as the @code{device} of a
10931 @code{file-system} declaration (@pxref{File Systems}).
10932 Note that the RAID level need not be given; it is chosen during the
10933 initial creation and formatting of the RAID device and is determined
10934 automatically later.
10935
10936
10937 @node User Accounts
10938 @section User Accounts
10939
10940 @cindex users
10941 @cindex accounts
10942 @cindex user accounts
10943 User accounts and groups are entirely managed through the
10944 @code{operating-system} declaration. They are specified with the
10945 @code{user-account} and @code{user-group} forms:
10946
10947 @example
10948 (user-account
10949 (name "alice")
10950 (group "users")
10951 (supplementary-groups '("wheel" ;allow use of sudo, etc.
10952 "audio" ;sound card
10953 "video" ;video devices such as webcams
10954 "cdrom")) ;the good ol' CD-ROM
10955 (comment "Bob's sister")
10956 (home-directory "/home/alice"))
10957 @end example
10958
10959 When booting or upon completion of @command{guix system reconfigure},
10960 the system ensures that only the user accounts and groups specified in
10961 the @code{operating-system} declaration exist, and with the specified
10962 properties. Thus, account or group creations or modifications made by
10963 directly invoking commands such as @command{useradd} are lost upon
10964 reconfiguration or reboot. This ensures that the system remains exactly
10965 as declared.
10966
10967 @deftp {Data Type} user-account
10968 Objects of this type represent user accounts. The following members may
10969 be specified:
10970
10971 @table @asis
10972 @item @code{name}
10973 The name of the user account.
10974
10975 @item @code{group}
10976 @cindex groups
10977 This is the name (a string) or identifier (a number) of the user group
10978 this account belongs to.
10979
10980 @item @code{supplementary-groups} (default: @code{'()})
10981 Optionally, this can be defined as a list of group names that this
10982 account belongs to.
10983
10984 @item @code{uid} (default: @code{#f})
10985 This is the user ID for this account (a number), or @code{#f}. In the
10986 latter case, a number is automatically chosen by the system when the
10987 account is created.
10988
10989 @item @code{comment} (default: @code{""})
10990 A comment about the account, such as the account owner's full name.
10991
10992 @item @code{home-directory}
10993 This is the name of the home directory for the account.
10994
10995 @item @code{create-home-directory?} (default: @code{#t})
10996 Indicates whether the home directory of this account should be created
10997 if it does not exist yet.
10998
10999 @item @code{shell} (default: Bash)
11000 This is a G-expression denoting the file name of a program to be used as
11001 the shell (@pxref{G-Expressions}).
11002
11003 @item @code{system?} (default: @code{#f})
11004 This Boolean value indicates whether the account is a ``system''
11005 account. System accounts are sometimes treated specially; for instance,
11006 graphical login managers do not list them.
11007
11008 @anchor{user-account-password}
11009 @cindex password, for user accounts
11010 @item @code{password} (default: @code{#f})
11011 You would normally leave this field to @code{#f}, initialize user
11012 passwords as @code{root} with the @command{passwd} command, and then let
11013 users change it with @command{passwd}. Passwords set with
11014 @command{passwd} are of course preserved across reboot and
11015 reconfiguration.
11016
11017 If you @emph{do} want to set an initial password for an account, then
11018 this field must contain the encrypted password, as a string. You can use the
11019 @code{crypt} procedure for this purpose:
11020
11021 @example
11022 (user-account
11023 (name "charlie")
11024 (group "users")
11025
11026 ;; Specify a SHA-512-hashed initial password.
11027 (password (crypt "InitialPassword!" "$6$abc")))
11028 @end example
11029
11030 @quotation Note
11031 The hash of this initial password will be available in a file in
11032 @file{/gnu/store}, readable by all the users, so this method must be used with
11033 care.
11034 @end quotation
11035
11036 @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
11037 more information on password encryption, and @ref{Encryption,,, guile, GNU
11038 Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
11039
11040 @end table
11041 @end deftp
11042
11043 @cindex groups
11044 User group declarations are even simpler:
11045
11046 @example
11047 (user-group (name "students"))
11048 @end example
11049
11050 @deftp {Data Type} user-group
11051 This type is for, well, user groups. There are just a few fields:
11052
11053 @table @asis
11054 @item @code{name}
11055 The name of the group.
11056
11057 @item @code{id} (default: @code{#f})
11058 The group identifier (a number). If @code{#f}, a new number is
11059 automatically allocated when the group is created.
11060
11061 @item @code{system?} (default: @code{#f})
11062 This Boolean value indicates whether the group is a ``system'' group.
11063 System groups have low numerical IDs.
11064
11065 @item @code{password} (default: @code{#f})
11066 What, user groups can have a password? Well, apparently yes. Unless
11067 @code{#f}, this field specifies the password of the group.
11068
11069 @end table
11070 @end deftp
11071
11072 For convenience, a variable lists all the basic user groups one may
11073 expect:
11074
11075 @defvr {Scheme Variable} %base-groups
11076 This is the list of basic user groups that users and/or packages expect
11077 to be present on the system. This includes groups such as ``root'',
11078 ``wheel'', and ``users'', as well as groups used to control access to
11079 specific devices such as ``audio'', ``disk'', and ``cdrom''.
11080 @end defvr
11081
11082 @defvr {Scheme Variable} %base-user-accounts
11083 This is the list of basic system accounts that programs may expect to
11084 find on a GNU/Linux system, such as the ``nobody'' account.
11085
11086 Note that the ``root'' account is not included here. It is a
11087 special-case and is automatically added whether or not it is specified.
11088 @end defvr
11089
11090 @node Keyboard Layout
11091 @section Keyboard Layout
11092
11093 @cindex keyboard layout
11094 @cindex keymap
11095 To specify what each key of your keyboard does, you need to tell the operating
11096 system what @dfn{keyboard layout} you want to use. The default, when nothing
11097 is specified, is the US English QWERTY layout for 105-key PC keyboards.
11098 However, German speakers will usually prefer the German QWERTZ layout, French
11099 speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
11100 or bépo, and they might even want to further customize the effect of some of
11101 the keys. This section explains how to get that done.
11102
11103 @cindex keyboard layout, definition
11104 There are three components that will want to know about your keyboard layout:
11105
11106 @itemize
11107 @item
11108 The @emph{bootloader} may want to know what keyboard layout you want to use
11109 (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
11110 you want, for instance, to make sure that you can type the passphrase of your
11111 encrypted root partition using the right layout.
11112
11113 @item
11114 The @emph{operating system kernel}, Linux, will need that so that the console
11115 is properly configured (@pxref{operating-system Reference,
11116 @code{keyboard-layout}}).
11117
11118 @item
11119 The @emph{graphical display server}, usually Xorg, also has its own idea of
11120 the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
11121 @end itemize
11122
11123 Guix allows you to configure all three separately but, fortunately, it allows
11124 you to share the same keyboard layout for all three components.
11125
11126 @cindex XKB, keyboard layouts
11127 Keyboard layouts are represented by records created by the
11128 @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
11129 the X Keyboard extension (XKB), each layout has four attributes: a name (often
11130 a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
11131 optional variant name, an optional keyboard model name, and a possibly empty
11132 list of additional options. In most cases the layout name is all you care
11133 about. Here are a few example:
11134
11135 @example
11136 ;; The German QWERTZ layout. Here we assume a standard
11137 ;; "pc105" keyboard model.
11138 (keyboard-layout "de")
11139
11140 ;; The bépo variant of the French layout.
11141 (keyboard-layout "fr" "bepo")
11142
11143 ;; The Catalan layout.
11144 (keyboard-layout "es" "cat")
11145
11146 ;; The Latin American Spanish layout. In addition, the
11147 ;; "Caps Lock" key is used as an additional "Ctrl" key,
11148 ;; and the "Menu" key is used as a "Compose" key to enter
11149 ;; accented letters.
11150 (keyboard-layout "latam"
11151 #:options '("ctrl:nocaps" "compose:menu"))
11152
11153 ;; The Russian layout for a ThinkPad keyboard.
11154 (keyboard-layout "ru" #:model "thinkpad")
11155
11156 ;; The "US international" layout, which is the US layout plus
11157 ;; dead keys to enter accented characters. This is for an
11158 ;; Apple MacBook keyboard.
11159 (keyboard-layout "us" "intl" #:model "macbook78")
11160 @end example
11161
11162 See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
11163 for a complete list of supported layouts, variants, and models.
11164
11165 @cindex keyboard layout, configuration
11166 Let's say you want your system to use the Turkish keyboard layout throughout
11167 your system---bootloader, console, and Xorg. Here's what your system
11168 configuration would look like:
11169
11170 @findex set-xorg-configuration
11171 @lisp
11172 ;; Using the Turkish layout for the bootloader, the console,
11173 ;; and for Xorg.
11174
11175 (operating-system
11176 ;; ...
11177 (keyboard-layout (keyboard-layout "tr")) ;for the console
11178 (bootloader (bootloader-configuration
11179 (bootloader grub-efi-bootloader)
11180 (target "/boot/efi")
11181 (keyboard-layout keyboard-layout))) ;for GRUB
11182 (services (cons (set-xorg-configuration
11183 (xorg-configuration ;for Xorg
11184 (keyboard-layout keyboard-layout)))
11185 %desktop-services)))
11186 @end lisp
11187
11188 In the example above, for GRUB and for Xorg, we just refer to the
11189 @code{keyboard-layout} field defined above, but we could just as well refer to
11190 a different layout. The @code{set-xorg-configuration} procedure communicates
11191 the desired Xorg configuration to the graphical log-in manager, by default
11192 GDM.
11193
11194 We've discussed how to specify the @emph{default} keyboard layout of your
11195 system when it starts, but you can also adjust it at run time:
11196
11197 @itemize
11198 @item
11199 If you're using GNOME, its settings panel has a ``Region & Language'' entry
11200 where you can select one or more keyboard layouts.
11201
11202 @item
11203 Under Xorg, the @command{setxkbmap} command (from the same-named package)
11204 allows you to change the current layout. For example, this is how you would
11205 change the layout to US Dvorak:
11206
11207 @example
11208 setxkbmap us dvorak
11209 @end example
11210
11211 @item
11212 The @code{loadkeys} command changes the keyboard layout in effect in the Linux
11213 console. However, note that @code{loadkeys} does @emph{not} use the XKB
11214 keyboard layout categorization described above. The command below loads the
11215 French bépo layout:
11216
11217 @example
11218 loadkeys fr-bepo
11219 @end example
11220 @end itemize
11221
11222 @node Locales
11223 @section Locales
11224
11225 @cindex locale
11226 A @dfn{locale} defines cultural conventions for a particular language
11227 and region of the world (@pxref{Locales,,, libc, The GNU C Library
11228 Reference Manual}). Each locale has a name that typically has the form
11229 @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
11230 @code{fr_LU.utf8} designates the locale for the French language, with
11231 cultural conventions from Luxembourg, and using the UTF-8 encoding.
11232
11233 @cindex locale definition
11234 Usually, you will want to specify the default locale for the machine
11235 using the @code{locale} field of the @code{operating-system} declaration
11236 (@pxref{operating-system Reference, @code{locale}}).
11237
11238 The selected locale is automatically added to the @dfn{locale
11239 definitions} known to the system if needed, with its codeset inferred
11240 from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
11241 @code{UTF-8} codeset. Additional locale definitions can be specified in
11242 the @code{locale-definitions} slot of @code{operating-system}---this is
11243 useful, for instance, if the codeset could not be inferred from the
11244 locale name. The default set of locale definitions includes some widely
11245 used locales, but not all the available locales, in order to save space.
11246
11247 For instance, to add the North Frisian locale for Germany, the value of
11248 that field may be:
11249
11250 @example
11251 (cons (locale-definition
11252 (name "fy_DE.utf8") (source "fy_DE"))
11253 %default-locale-definitions)
11254 @end example
11255
11256 Likewise, to save space, one might want @code{locale-definitions} to
11257 list only the locales that are actually used, as in:
11258
11259 @example
11260 (list (locale-definition
11261 (name "ja_JP.eucjp") (source "ja_JP")
11262 (charset "EUC-JP")))
11263 @end example
11264
11265 @vindex LOCPATH
11266 The compiled locale definitions are available at
11267 @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
11268 version, which is the default location where the GNU@tie{}libc provided
11269 by Guix looks for locale data. This can be overridden using the
11270 @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
11271 @code{LOCPATH} and locale packages}).
11272
11273 The @code{locale-definition} form is provided by the @code{(gnu system
11274 locale)} module. Details are given below.
11275
11276 @deftp {Data Type} locale-definition
11277 This is the data type of a locale definition.
11278
11279 @table @asis
11280
11281 @item @code{name}
11282 The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
11283 Reference Manual}, for more information on locale names.
11284
11285 @item @code{source}
11286 The name of the source for that locale. This is typically the
11287 @code{@var{language}_@var{territory}} part of the locale name.
11288
11289 @item @code{charset} (default: @code{"UTF-8"})
11290 The ``character set'' or ``code set'' for that locale,
11291 @uref{http://www.iana.org/assignments/character-sets, as defined by
11292 IANA}.
11293
11294 @end table
11295 @end deftp
11296
11297 @defvr {Scheme Variable} %default-locale-definitions
11298 A list of commonly used UTF-8 locales, used as the default
11299 value of the @code{locale-definitions} field of @code{operating-system}
11300 declarations.
11301
11302 @cindex locale name
11303 @cindex normalized codeset in locale names
11304 These locale definitions use the @dfn{normalized codeset} for the part
11305 that follows the dot in the name (@pxref{Using gettextized software,
11306 normalized codeset,, libc, The GNU C Library Reference Manual}). So for
11307 instance it has @code{uk_UA.utf8} but @emph{not}, say,
11308 @code{uk_UA.UTF-8}.
11309 @end defvr
11310
11311 @subsection Locale Data Compatibility Considerations
11312
11313 @cindex incompatibility, of locale data
11314 @code{operating-system} declarations provide a @code{locale-libcs} field
11315 to specify the GNU@tie{}libc packages that are used to compile locale
11316 declarations (@pxref{operating-system Reference}). ``Why would I
11317 care?'', you may ask. Well, it turns out that the binary format of
11318 locale data is occasionally incompatible from one libc version to
11319 another.
11320
11321 @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
11322 @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
11323 For instance, a program linked against libc version 2.21 is unable to
11324 read locale data produced with libc 2.22; worse, that program
11325 @emph{aborts} instead of simply ignoring the incompatible locale
11326 data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
11327 the incompatible locale data, which is already an improvement.}.
11328 Similarly, a program linked against libc 2.22 can read most, but not
11329 all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
11330 data is incompatible); thus calls to @code{setlocale} may fail, but
11331 programs will not abort.
11332
11333 The ``problem'' with Guix is that users have a lot of freedom: They can
11334 choose whether and when to upgrade software in their profiles, and might
11335 be using a libc version different from the one the system administrator
11336 used to build the system-wide locale data.
11337
11338 Fortunately, unprivileged users can also install their own locale data
11339 and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
11340 @code{GUIX_LOCPATH} and locale packages}).
11341
11342 Still, it is best if the system-wide locale data at
11343 @file{/run/current-system/locale} is built for all the libc versions
11344 actually in use on the system, so that all the programs can access
11345 it---this is especially crucial on a multi-user system. To do that, the
11346 administrator can specify several libc packages in the
11347 @code{locale-libcs} field of @code{operating-system}:
11348
11349 @example
11350 (use-package-modules base)
11351
11352 (operating-system
11353 ;; @dots{}
11354 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
11355 @end example
11356
11357 This example would lead to a system containing locale definitions for
11358 both libc 2.21 and the current version of libc in
11359 @file{/run/current-system/locale}.
11360
11361
11362 @node Services
11363 @section Services
11364
11365 @cindex system services
11366 An important part of preparing an @code{operating-system} declaration is
11367 listing @dfn{system services} and their configuration (@pxref{Using the
11368 Configuration System}). System services are typically daemons launched
11369 when the system boots, or other actions needed at that time---e.g.,
11370 configuring network access.
11371
11372 Guix has a broad definition of ``service'' (@pxref{Service
11373 Composition}), but many services are managed by the GNU@tie{}Shepherd
11374 (@pxref{Shepherd Services}). On a running system, the @command{herd}
11375 command allows you to list the available services, show their status,
11376 start and stop them, or do other specific operations (@pxref{Jump
11377 Start,,, shepherd, The GNU Shepherd Manual}). For example:
11378
11379 @example
11380 # herd status
11381 @end example
11382
11383 The above command, run as @code{root}, lists the currently defined
11384 services. The @command{herd doc} command shows a synopsis of the given
11385 service and its associated actions:
11386
11387 @example
11388 # herd doc nscd
11389 Run libc's name service cache daemon (nscd).
11390
11391 # herd doc nscd action invalidate
11392 invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
11393 @end example
11394
11395 The @command{start}, @command{stop}, and @command{restart} sub-commands
11396 have the effect you would expect. For instance, the commands below stop
11397 the nscd service and restart the Xorg display server:
11398
11399 @example
11400 # herd stop nscd
11401 Service nscd has been stopped.
11402 # herd restart xorg-server
11403 Service xorg-server has been stopped.
11404 Service xorg-server has been started.
11405 @end example
11406
11407 The following sections document the available services, starting with
11408 the core services, that may be used in an @code{operating-system}
11409 declaration.
11410
11411 @menu
11412 * Base Services:: Essential system services.
11413 * Scheduled Job Execution:: The mcron service.
11414 * Log Rotation:: The rottlog service.
11415 * Networking Services:: Network setup, SSH daemon, etc.
11416 * X Window:: Graphical display.
11417 * Printing Services:: Local and remote printer support.
11418 * Desktop Services:: D-Bus and desktop services.
11419 * Sound Services:: ALSA and Pulseaudio services.
11420 * Database Services:: SQL databases, key-value stores, etc.
11421 * Mail Services:: IMAP, POP3, SMTP, and all that.
11422 * Messaging Services:: Messaging services.
11423 * Telephony Services:: Telephony services.
11424 * Monitoring Services:: Monitoring services.
11425 * Kerberos Services:: Kerberos services.
11426 * LDAP Services:: LDAP services.
11427 * Web Services:: Web servers.
11428 * Certificate Services:: TLS certificates via Let's Encrypt.
11429 * DNS Services:: DNS daemons.
11430 * VPN Services:: VPN daemons.
11431 * Network File System:: NFS related services.
11432 * Continuous Integration:: The Cuirass service.
11433 * Power Management Services:: Extending battery life.
11434 * Audio Services:: The MPD.
11435 * Virtualization Services:: Virtualization services.
11436 * Version Control Services:: Providing remote access to Git repositories.
11437 * Game Services:: Game servers.
11438 * Miscellaneous Services:: Other services.
11439 @end menu
11440
11441 @node Base Services
11442 @subsection Base Services
11443
11444 The @code{(gnu services base)} module provides definitions for the basic
11445 services that one expects from the system. The services exported by
11446 this module are listed below.
11447
11448 @defvr {Scheme Variable} %base-services
11449 This variable contains a list of basic services (@pxref{Service Types
11450 and Services}, for more information on service objects) one would
11451 expect from the system: a login service (mingetty) on each tty, syslogd,
11452 the libc name service cache daemon (nscd), the udev device manager, and
11453 more.
11454
11455 This is the default value of the @code{services} field of
11456 @code{operating-system} declarations. Usually, when customizing a
11457 system, you will want to append services to @var{%base-services}, like
11458 this:
11459
11460 @example
11461 (append (list (service avahi-service-type)
11462 (service openssh-service-type))
11463 %base-services)
11464 @end example
11465 @end defvr
11466
11467 @defvr {Scheme Variable} special-files-service-type
11468 This is the service that sets up ``special files'' such as
11469 @file{/bin/sh}; an instance of it is part of @code{%base-services}.
11470
11471 The value associated with @code{special-files-service-type} services
11472 must be a list of tuples where the first element is the ``special file''
11473 and the second element is its target. By default it is:
11474
11475 @cindex @file{/bin/sh}
11476 @cindex @file{sh}, in @file{/bin}
11477 @example
11478 `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
11479 @end example
11480
11481 @cindex @file{/usr/bin/env}
11482 @cindex @file{env}, in @file{/usr/bin}
11483 If you want to add, say, @code{/usr/bin/env} to your system, you can
11484 change it to:
11485
11486 @example
11487 `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
11488 ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
11489 @end example
11490
11491 Since this is part of @code{%base-services}, you can use
11492 @code{modify-services} to customize the set of special files
11493 (@pxref{Service Reference, @code{modify-services}}). But the simple way
11494 to add a special file is @i{via} the @code{extra-special-file} procedure
11495 (see below.)
11496 @end defvr
11497
11498 @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
11499 Use @var{target} as the ``special file'' @var{file}.
11500
11501 For example, adding the following lines to the @code{services} field of
11502 your operating system declaration leads to a @file{/usr/bin/env}
11503 symlink:
11504
11505 @example
11506 (extra-special-file "/usr/bin/env"
11507 (file-append coreutils "/bin/env"))
11508 @end example
11509 @end deffn
11510
11511 @deffn {Scheme Procedure} host-name-service @var{name}
11512 Return a service that sets the host name to @var{name}.
11513 @end deffn
11514
11515 @deffn {Scheme Procedure} login-service @var{config}
11516 Return a service to run login according to @var{config}, a
11517 @code{<login-configuration>} object, which specifies the message of the day,
11518 among other things.
11519 @end deffn
11520
11521 @deftp {Data Type} login-configuration
11522 This is the data type representing the configuration of login.
11523
11524 @table @asis
11525
11526 @item @code{motd}
11527 @cindex message of the day
11528 A file-like object containing the ``message of the day''.
11529
11530 @item @code{allow-empty-passwords?} (default: @code{#t})
11531 Allow empty passwords by default so that first-time users can log in when
11532 the 'root' account has just been created.
11533
11534 @end table
11535 @end deftp
11536
11537 @deffn {Scheme Procedure} mingetty-service @var{config}
11538 Return a service to run mingetty according to @var{config}, a
11539 @code{<mingetty-configuration>} object, which specifies the tty to run, among
11540 other things.
11541 @end deffn
11542
11543 @deftp {Data Type} mingetty-configuration
11544 This is the data type representing the configuration of Mingetty, which
11545 provides the default implementation of virtual console log-in.
11546
11547 @table @asis
11548
11549 @item @code{tty}
11550 The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
11551
11552 @item @code{auto-login} (default: @code{#f})
11553 When true, this field must be a string denoting the user name under
11554 which the system automatically logs in. When it is @code{#f}, a
11555 user name and password must be entered to log in.
11556
11557 @item @code{login-program} (default: @code{#f})
11558 This must be either @code{#f}, in which case the default log-in program
11559 is used (@command{login} from the Shadow tool suite), or a gexp denoting
11560 the name of the log-in program.
11561
11562 @item @code{login-pause?} (default: @code{#f})
11563 When set to @code{#t} in conjunction with @var{auto-login}, the user
11564 will have to press a key before the log-in shell is launched.
11565
11566 @item @code{mingetty} (default: @var{mingetty})
11567 The Mingetty package to use.
11568
11569 @end table
11570 @end deftp
11571
11572 @deffn {Scheme Procedure} agetty-service @var{config}
11573 Return a service to run agetty according to @var{config}, an
11574 @code{<agetty-configuration>} object, which specifies the tty to run,
11575 among other things.
11576 @end deffn
11577
11578 @deftp {Data Type} agetty-configuration
11579 This is the data type representing the configuration of agetty, which
11580 implements virtual and serial console log-in. See the @code{agetty(8)}
11581 man page for more information.
11582
11583 @table @asis
11584
11585 @item @code{tty}
11586 The name of the console this agetty runs on, as a string---e.g.,
11587 @code{"ttyS0"}. This argument is optional, it will default to
11588 a reasonable default serial port used by the kernel Linux.
11589
11590 For this, if there is a value for an option @code{agetty.tty} in the kernel
11591 command line, agetty will extract the device name of the serial port
11592 from it and use that.
11593
11594 If not and if there is a value for an option @code{console} with a tty in
11595 the Linux command line, agetty will extract the device name of the
11596 serial port from it and use that.
11597
11598 In both cases, agetty will leave the other serial device settings
11599 (baud rate etc.)@: alone---in the hope that Linux pinned them to the
11600 correct values.
11601
11602 @item @code{baud-rate} (default: @code{#f})
11603 A string containing a comma-separated list of one or more baud rates, in
11604 descending order.
11605
11606 @item @code{term} (default: @code{#f})
11607 A string containing the value used for the @code{TERM} environment
11608 variable.
11609
11610 @item @code{eight-bits?} (default: @code{#f})
11611 When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
11612 disabled.
11613
11614 @item @code{auto-login} (default: @code{#f})
11615 When passed a login name, as a string, the specified user will be logged
11616 in automatically without prompting for their login name or password.
11617
11618 @item @code{no-reset?} (default: @code{#f})
11619 When @code{#t}, don't reset terminal cflags (control modes).
11620
11621 @item @code{host} (default: @code{#f})
11622 This accepts a string containing the "login_host", which will be written
11623 into the @file{/var/run/utmpx} file.
11624
11625 @item @code{remote?} (default: @code{#f})
11626 When set to @code{#t} in conjunction with @var{host}, this will add an
11627 @code{-r} fakehost option to the command line of the login program
11628 specified in @var{login-program}.
11629
11630 @item @code{flow-control?} (default: @code{#f})
11631 When set to @code{#t}, enable hardware (RTS/CTS) flow control.
11632
11633 @item @code{no-issue?} (default: @code{#f})
11634 When set to @code{#t}, the contents of the @file{/etc/issue} file will
11635 not be displayed before presenting the login prompt.
11636
11637 @item @code{init-string} (default: @code{#f})
11638 This accepts a string that will be sent to the tty or modem before
11639 sending anything else. It can be used to initialize a modem.
11640
11641 @item @code{no-clear?} (default: @code{#f})
11642 When set to @code{#t}, agetty will not clear the screen before showing
11643 the login prompt.
11644
11645 @item @code{login-program} (default: (file-append shadow "/bin/login"))
11646 This must be either a gexp denoting the name of a log-in program, or
11647 unset, in which case the default value is the @command{login} from the
11648 Shadow tool suite.
11649
11650 @item @code{local-line} (default: @code{#f})
11651 Control the CLOCAL line flag. This accepts one of three symbols as
11652 arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
11653 the default value chosen by agetty is @code{'auto}.
11654
11655 @item @code{extract-baud?} (default: @code{#f})
11656 When set to @code{#t}, instruct agetty to try to extract the baud rate
11657 from the status messages produced by certain types of modems.
11658
11659 @item @code{skip-login?} (default: @code{#f})
11660 When set to @code{#t}, do not prompt the user for a login name. This
11661 can be used with @var{login-program} field to use non-standard login
11662 systems.
11663
11664 @item @code{no-newline?} (default: @code{#f})
11665 When set to @code{#t}, do not print a newline before printing the
11666 @file{/etc/issue} file.
11667
11668 @c Is this dangerous only when used with login-program, or always?
11669 @item @code{login-options} (default: @code{#f})
11670 This option accepts a string containing options that are passed to the
11671 login program. When used with the @var{login-program}, be aware that a
11672 malicious user could try to enter a login name containing embedded
11673 options that could be parsed by the login program.
11674
11675 @item @code{login-pause} (default: @code{#f})
11676 When set to @code{#t}, wait for any key before showing the login prompt.
11677 This can be used in conjunction with @var{auto-login} to save memory by
11678 lazily spawning shells.
11679
11680 @item @code{chroot} (default: @code{#f})
11681 Change root to the specified directory. This option accepts a directory
11682 path as a string.
11683
11684 @item @code{hangup?} (default: @code{#f})
11685 Use the Linux system call @code{vhangup} to do a virtual hangup of the
11686 specified terminal.
11687
11688 @item @code{keep-baud?} (default: @code{#f})
11689 When set to @code{#t}, try to keep the existing baud rate. The baud
11690 rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
11691 character.
11692
11693 @item @code{timeout} (default: @code{#f})
11694 When set to an integer value, terminate if no user name could be read
11695 within @var{timeout} seconds.
11696
11697 @item @code{detect-case?} (default: @code{#f})
11698 When set to @code{#t}, turn on support for detecting an uppercase-only
11699 terminal. This setting will detect a login name containing only
11700 uppercase letters as indicating an uppercase-only terminal and turn on
11701 some upper-to-lower case conversions. Note that this will not support
11702 Unicode characters.
11703
11704 @item @code{wait-cr?} (default: @code{#f})
11705 When set to @code{#t}, wait for the user or modem to send a
11706 carriage-return or linefeed character before displaying
11707 @file{/etc/issue} or login prompt. This is typically used with the
11708 @var{init-string} option.
11709
11710 @item @code{no-hints?} (default: @code{#f})
11711 When set to @code{#t}, do not print hints about Num, Caps, and Scroll
11712 locks.
11713
11714 @item @code{no-hostname?} (default: @code{#f})
11715 By default, the hostname is printed. When this option is set to
11716 @code{#t}, no hostname will be shown at all.
11717
11718 @item @code{long-hostname?} (default: @code{#f})
11719 By default, the hostname is only printed until the first dot. When this
11720 option is set to @code{#t}, the fully qualified hostname by
11721 @code{gethostname} or @code{getaddrinfo} is shown.
11722
11723 @item @code{erase-characters} (default: @code{#f})
11724 This option accepts a string of additional characters that should be
11725 interpreted as backspace when the user types their login name.
11726
11727 @item @code{kill-characters} (default: @code{#f})
11728 This option accepts a string that should be interpreted to mean "ignore
11729 all previous characters" (also called a "kill" character) when the types
11730 their login name.
11731
11732 @item @code{chdir} (default: @code{#f})
11733 This option accepts, as a string, a directory path that will be changed
11734 to before login.
11735
11736 @item @code{delay} (default: @code{#f})
11737 This options accepts, as an integer, the number of seconds to sleep
11738 before opening the tty and displaying the login prompt.
11739
11740 @item @code{nice} (default: @code{#f})
11741 This option accepts, as an integer, the nice value with which to run the
11742 @command{login} program.
11743
11744 @item @code{extra-options} (default: @code{'()})
11745 This option provides an "escape hatch" for the user to provide arbitrary
11746 command-line arguments to @command{agetty} as a list of strings.
11747
11748 @end table
11749 @end deftp
11750
11751 @deffn {Scheme Procedure} kmscon-service-type @var{config}
11752 Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
11753 according to @var{config}, a @code{<kmscon-configuration>} object, which
11754 specifies the tty to run, among other things.
11755 @end deffn
11756
11757 @deftp {Data Type} kmscon-configuration
11758 This is the data type representing the configuration of Kmscon, which
11759 implements virtual console log-in.
11760
11761 @table @asis
11762
11763 @item @code{virtual-terminal}
11764 The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
11765
11766 @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
11767 A gexp denoting the name of the log-in program. The default log-in program is
11768 @command{login} from the Shadow tool suite.
11769
11770 @item @code{login-arguments} (default: @code{'("-p")})
11771 A list of arguments to pass to @command{login}.
11772
11773 @item @code{auto-login} (default: @code{#f})
11774 When passed a login name, as a string, the specified user will be logged
11775 in automatically without prompting for their login name or password.
11776
11777 @item @code{hardware-acceleration?} (default: #f)
11778 Whether to use hardware acceleration.
11779
11780 @item @code{kmscon} (default: @var{kmscon})
11781 The Kmscon package to use.
11782
11783 @end table
11784 @end deftp
11785
11786 @cindex name service cache daemon
11787 @cindex nscd
11788 @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
11789 [#:name-services '()]
11790 Return a service that runs the libc name service cache daemon (nscd) with the
11791 given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
11792 Service Switch}, for an example.
11793
11794 For convenience, the Shepherd service for nscd provides the following actions:
11795
11796 @table @code
11797 @item invalidate
11798 @cindex cache invalidation, nscd
11799 @cindex nscd, cache invalidation
11800 This invalidate the given cache. For instance, running:
11801
11802 @example
11803 herd invalidate nscd hosts
11804 @end example
11805
11806 @noindent
11807 invalidates the host name lookup cache of nscd.
11808
11809 @item statistics
11810 Running @command{herd statistics nscd} displays information about nscd usage
11811 and caches.
11812 @end table
11813
11814 @end deffn
11815
11816 @defvr {Scheme Variable} %nscd-default-configuration
11817 This is the default @code{<nscd-configuration>} value (see below) used
11818 by @code{nscd-service}. It uses the caches defined by
11819 @var{%nscd-default-caches}; see below.
11820 @end defvr
11821
11822 @deftp {Data Type} nscd-configuration
11823 This is the data type representing the name service cache daemon (nscd)
11824 configuration.
11825
11826 @table @asis
11827
11828 @item @code{name-services} (default: @code{'()})
11829 List of packages denoting @dfn{name services} that must be visible to
11830 the nscd---e.g., @code{(list @var{nss-mdns})}.
11831
11832 @item @code{glibc} (default: @var{glibc})
11833 Package object denoting the GNU C Library providing the @command{nscd}
11834 command.
11835
11836 @item @code{log-file} (default: @code{"/var/log/nscd.log"})
11837 Name of the nscd log file. This is where debugging output goes when
11838 @code{debug-level} is strictly positive.
11839
11840 @item @code{debug-level} (default: @code{0})
11841 Integer denoting the debugging levels. Higher numbers mean that more
11842 debugging output is logged.
11843
11844 @item @code{caches} (default: @var{%nscd-default-caches})
11845 List of @code{<nscd-cache>} objects denoting things to be cached; see
11846 below.
11847
11848 @end table
11849 @end deftp
11850
11851 @deftp {Data Type} nscd-cache
11852 Data type representing a cache database of nscd and its parameters.
11853
11854 @table @asis
11855
11856 @item @code{database}
11857 This is a symbol representing the name of the database to be cached.
11858 Valid values are @code{passwd}, @code{group}, @code{hosts}, and
11859 @code{services}, which designate the corresponding NSS database
11860 (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
11861
11862 @item @code{positive-time-to-live}
11863 @itemx @code{negative-time-to-live} (default: @code{20})
11864 A number representing the number of seconds during which a positive or
11865 negative lookup result remains in cache.
11866
11867 @item @code{check-files?} (default: @code{#t})
11868 Whether to check for updates of the files corresponding to
11869 @var{database}.
11870
11871 For instance, when @var{database} is @code{hosts}, setting this flag
11872 instructs nscd to check for updates in @file{/etc/hosts} and to take
11873 them into account.
11874
11875 @item @code{persistent?} (default: @code{#t})
11876 Whether the cache should be stored persistently on disk.
11877
11878 @item @code{shared?} (default: @code{#t})
11879 Whether the cache should be shared among users.
11880
11881 @item @code{max-database-size} (default: 32@tie{}MiB)
11882 Maximum size in bytes of the database cache.
11883
11884 @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
11885 @c settings, so leave them out.
11886
11887 @end table
11888 @end deftp
11889
11890 @defvr {Scheme Variable} %nscd-default-caches
11891 List of @code{<nscd-cache>} objects used by default by
11892 @code{nscd-configuration} (see above).
11893
11894 It enables persistent and aggressive caching of service and host name
11895 lookups. The latter provides better host name lookup performance,
11896 resilience in the face of unreliable name servers, and also better
11897 privacy---often the result of host name lookups is in local cache, so
11898 external name servers do not even need to be queried.
11899 @end defvr
11900
11901 @anchor{syslog-configuration-type}
11902 @cindex syslog
11903 @cindex logging
11904 @deftp {Data Type} syslog-configuration
11905 This data type represents the configuration of the syslog daemon.
11906
11907 @table @asis
11908 @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
11909 The syslog daemon to use.
11910
11911 @item @code{config-file} (default: @code{%default-syslog.conf})
11912 The syslog configuration file to use.
11913
11914 @end table
11915 @end deftp
11916
11917 @anchor{syslog-service}
11918 @cindex syslog
11919 @deffn {Scheme Procedure} syslog-service @var{config}
11920 Return a service that runs a syslog daemon according to @var{config}.
11921
11922 @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
11923 information on the configuration file syntax.
11924 @end deffn
11925
11926 @defvr {Scheme Variable} guix-service-type
11927 This is the type of the service that runs the build daemon,
11928 @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
11929 @code{guix-configuration} record as described below.
11930 @end defvr
11931
11932 @anchor{guix-configuration-type}
11933 @deftp {Data Type} guix-configuration
11934 This data type represents the configuration of the Guix build daemon.
11935 @xref{Invoking guix-daemon}, for more information.
11936
11937 @table @asis
11938 @item @code{guix} (default: @var{guix})
11939 The Guix package to use.
11940
11941 @item @code{build-group} (default: @code{"guixbuild"})
11942 Name of the group for build user accounts.
11943
11944 @item @code{build-accounts} (default: @code{10})
11945 Number of build user accounts to create.
11946
11947 @item @code{authorize-key?} (default: @code{#t})
11948 @cindex substitutes, authorization thereof
11949 Whether to authorize the substitute keys listed in
11950 @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
11951 (@pxref{Substitutes}).
11952
11953 @vindex %default-authorized-guix-keys
11954 @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
11955 The list of authorized key files for archive imports, as a list of
11956 string-valued gexps (@pxref{Invoking guix archive}). By default, it
11957 contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
11958
11959 @item @code{use-substitutes?} (default: @code{#t})
11960 Whether to use substitutes.
11961
11962 @item @code{substitute-urls} (default: @var{%default-substitute-urls})
11963 The list of URLs where to look for substitutes by default.
11964
11965 @item @code{max-silent-time} (default: @code{0})
11966 @itemx @code{timeout} (default: @code{0})
11967 The number of seconds of silence and the number of seconds of activity,
11968 respectively, after which a build process times out. A value of zero
11969 disables the timeout.
11970
11971 @item @code{log-compression} (default: @code{'bzip2})
11972 The type of compression used for build logs---one of @code{gzip},
11973 @code{bzip2}, or @code{none}.
11974
11975 @item @code{extra-options} (default: @code{'()})
11976 List of extra command-line options for @command{guix-daemon}.
11977
11978 @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
11979 File where @command{guix-daemon}'s standard output and standard error
11980 are written.
11981
11982 @item @code{http-proxy} (default: @code{#f})
11983 The HTTP proxy used for downloading fixed-output derivations and
11984 substitutes.
11985
11986 @item @code{tmpdir} (default: @code{#f})
11987 A directory path where the @command{guix-daemon} will perform builds.
11988
11989 @end table
11990 @end deftp
11991
11992 @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
11993 Run @var{udev}, which populates the @file{/dev} directory dynamically.
11994 udev rules can be provided as a list of files through the @var{rules}
11995 variable. The procedures @var{udev-rule} and @var{file->udev-rule} from
11996 @code{(gnu services base)} simplify the creation of such rule files.
11997 @end deffn
11998
11999 @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
12000 Return a udev-rule file named @var{file-name} containing the rules
12001 defined by the @var{contents} literal.
12002
12003 In the following example, a rule for a USB device is defined to be
12004 stored in the file @file{90-usb-thing.rules}. The rule runs a script
12005 upon detecting a USB device with a given product identifier.
12006
12007 @example
12008 (define %example-udev-rule
12009 (udev-rule
12010 "90-usb-thing.rules"
12011 (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
12012 "ATTR@{product@}==\"Example\", "
12013 "RUN+=\"/path/to/script\"")))
12014 @end example
12015
12016 The @command{herd rules udev} command, as root, returns the name of the
12017 directory containing all the active udev rules.
12018 @end deffn
12019
12020 Here we show how the default @var{udev-service} can be extended with it.
12021
12022 @example
12023 (operating-system
12024 ;; @dots{}
12025 (services
12026 (modify-services %desktop-services
12027 (udev-service-type config =>
12028 (udev-configuration (inherit config)
12029 (rules (append (udev-configuration-rules config)
12030 (list %example-udev-rule))))))))
12031 @end example
12032
12033 @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
12034 Return a udev file named @var{file-name} containing the rules defined
12035 within @var{file}, a file-like object.
12036
12037 The following example showcases how we can use an existing rule file.
12038
12039 @example
12040 (use-modules (guix download) ;for url-fetch
12041 (guix packages) ;for origin
12042 ;; @dots{})
12043
12044 (define %android-udev-rules
12045 (file->udev-rule
12046 "51-android-udev.rules"
12047 (let ((version "20170910"))
12048 (origin
12049 (method url-fetch)
12050 (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
12051 "android-udev-rules/" version "/51-android.rules"))
12052 (sha256
12053 (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
12054 @end example
12055 @end deffn
12056
12057 Additionally, Guix package definitions can be included in @var{rules} in
12058 order to extend the udev rules with the definitions found under their
12059 @file{lib/udev/rules.d} sub-directory. In lieu of the previous
12060 @var{file->udev-rule} example, we could have used the
12061 @var{android-udev-rules} package which exists in Guix in the @code{(gnu
12062 packages android)} module.
12063
12064 The following example shows how to use the @var{android-udev-rules}
12065 package so that the Android tool @command{adb} can detect devices
12066 without root privileges. It also details how to create the
12067 @code{adbusers} group, which is required for the proper functioning of
12068 the rules defined within the @var{android-udev-rules} package. To
12069 create such a group, we must define it both as part of the
12070 @var{supplementary-groups} of our @var{user-account} declaration, as
12071 well as in the @var{groups} field of the @var{operating-system} record.
12072
12073 @example
12074 (use-modules (gnu packages android) ;for android-udev-rules
12075 (gnu system shadow) ;for user-group
12076 ;; @dots{})
12077
12078 (operating-system
12079 ;; @dots{}
12080 (users (cons (user-acount
12081 ;; @dots{}
12082 (supplementary-groups
12083 '("adbusers" ;for adb
12084 "wheel" "netdev" "audio" "video"))
12085 ;; @dots{})))
12086
12087 (groups (cons (user-group (system? #t) (name "adbusers"))
12088 %base-groups))
12089
12090 ;; @dots{}
12091
12092 (services
12093 (modify-services %desktop-services
12094 (udev-service-type
12095 config =>
12096 (udev-configuration (inherit config)
12097 (rules (cons android-udev-rules
12098 (udev-configuration-rules config))))))))
12099 @end example
12100
12101 @defvr {Scheme Variable} urandom-seed-service-type
12102 Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
12103 when rebooting. It also tries to seed @file{/dev/urandom} from
12104 @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
12105 readable.
12106 @end defvr
12107
12108 @defvr {Scheme Variable} %random-seed-file
12109 This is the name of the file where some random bytes are saved by
12110 @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
12111 It defaults to @file{/var/lib/random-seed}.
12112 @end defvr
12113
12114 @cindex mouse
12115 @cindex gpm
12116 @defvr {Scheme Variable} gpm-service-type
12117 This is the type of the service that runs GPM, the @dfn{general-purpose
12118 mouse daemon}, which provides mouse support to the Linux console. GPM
12119 allows users to use the mouse in the console, notably to select, copy,
12120 and paste text.
12121
12122 The value for services of this type must be a @code{gpm-configuration}
12123 (see below). This service is not part of @var{%base-services}.
12124 @end defvr
12125
12126 @deftp {Data Type} gpm-configuration
12127 Data type representing the configuration of GPM.
12128
12129 @table @asis
12130 @item @code{options} (default: @code{%default-gpm-options})
12131 Command-line options passed to @command{gpm}. The default set of
12132 options instruct @command{gpm} to listen to mouse events on
12133 @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
12134 more information.
12135
12136 @item @code{gpm} (default: @code{gpm})
12137 The GPM package to use.
12138
12139 @end table
12140 @end deftp
12141
12142 @anchor{guix-publish-service-type}
12143 @deffn {Scheme Variable} guix-publish-service-type
12144 This is the service type for @command{guix publish} (@pxref{Invoking
12145 guix publish}). Its value must be a @code{guix-configuration}
12146 object, as described below.
12147
12148 This assumes that @file{/etc/guix} already contains a signing key pair as
12149 created by @command{guix archive --generate-key} (@pxref{Invoking guix
12150 archive}). If that is not the case, the service will fail to start.
12151 @end deffn
12152
12153 @deftp {Data Type} guix-publish-configuration
12154 Data type representing the configuration of the @code{guix publish}
12155 service.
12156
12157 @table @asis
12158 @item @code{guix} (default: @code{guix})
12159 The Guix package to use.
12160
12161 @item @code{port} (default: @code{80})
12162 The TCP port to listen for connections.
12163
12164 @item @code{host} (default: @code{"localhost"})
12165 The host (and thus, network interface) to listen to. Use
12166 @code{"0.0.0.0"} to listen on all the network interfaces.
12167
12168 @item @code{compression-level} (default: @code{3})
12169 The gzip compression level at which substitutes are compressed. Use
12170 @code{0} to disable compression altogether, and @code{9} to get the best
12171 compression ratio at the expense of increased CPU usage.
12172
12173 @item @code{nar-path} (default: @code{"nar"})
12174 The URL path at which ``nars'' can be fetched. @xref{Invoking guix
12175 publish, @code{--nar-path}}, for details.
12176
12177 @item @code{cache} (default: @code{#f})
12178 When it is @code{#f}, disable caching and instead generate archives on
12179 demand. Otherwise, this should be the name of a directory---e.g.,
12180 @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
12181 archives and meta-data ready to be sent. @xref{Invoking guix publish,
12182 @option{--cache}}, for more information on the tradeoffs involved.
12183
12184 @item @code{workers} (default: @code{#f})
12185 When it is an integer, this is the number of worker threads used for
12186 caching; when @code{#f}, the number of processors is used.
12187 @xref{Invoking guix publish, @option{--workers}}, for more information.
12188
12189 @item @code{ttl} (default: @code{#f})
12190 When it is an integer, this denotes the @dfn{time-to-live} in seconds
12191 of the published archives. @xref{Invoking guix publish, @option{--ttl}},
12192 for more information.
12193 @end table
12194 @end deftp
12195
12196 @anchor{rngd-service}
12197 @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
12198 [#:device "/dev/hwrng"]
12199 Return a service that runs the @command{rngd} program from @var{rng-tools}
12200 to add @var{device} to the kernel's entropy pool. The service will fail if
12201 @var{device} does not exist.
12202 @end deffn
12203
12204 @anchor{pam-limits-service}
12205 @cindex session limits
12206 @cindex ulimit
12207 @cindex priority
12208 @cindex realtime
12209 @cindex jackd
12210 @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
12211
12212 Return a service that installs a configuration file for the
12213 @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
12214 @code{pam_limits} module}. The procedure optionally takes a list of
12215 @code{pam-limits-entry} values, which can be used to specify
12216 @code{ulimit} limits and nice priority limits to user sessions.
12217
12218 The following limits definition sets two hard and soft limits for all
12219 login sessions of users in the @code{realtime} group:
12220
12221 @example
12222 (pam-limits-service
12223 (list
12224 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
12225 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
12226 @end example
12227
12228 The first entry increases the maximum realtime priority for
12229 non-privileged processes; the second entry lifts any restriction of the
12230 maximum address space that can be locked in memory. These settings are
12231 commonly used for real-time audio systems.
12232 @end deffn
12233
12234 @node Scheduled Job Execution
12235 @subsection Scheduled Job Execution
12236
12237 @cindex cron
12238 @cindex mcron
12239 @cindex scheduling jobs
12240 The @code{(gnu services mcron)} module provides an interface to
12241 GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
12242 mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
12243 Unix @command{cron} daemon; the main difference is that it is
12244 implemented in Guile Scheme, which provides a lot of flexibility when
12245 specifying the scheduling of jobs and their actions.
12246
12247 The example below defines an operating system that runs the
12248 @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
12249 and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
12250 well as the @command{mkid} command on behalf of an unprivileged user
12251 (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
12252 gexps to introduce job definitions that are passed to mcron
12253 (@pxref{G-Expressions}).
12254
12255 @lisp
12256 (use-modules (guix) (gnu) (gnu services mcron))
12257 (use-package-modules base idutils)
12258
12259 (define updatedb-job
12260 ;; Run 'updatedb' at 3AM every day. Here we write the
12261 ;; job's action as a Scheme procedure.
12262 #~(job '(next-hour '(3))
12263 (lambda ()
12264 (execl (string-append #$findutils "/bin/updatedb")
12265 "updatedb"
12266 "--prunepaths=/tmp /var/tmp /gnu/store"))))
12267
12268 (define garbage-collector-job
12269 ;; Collect garbage 5 minutes after midnight every day.
12270 ;; The job's action is a shell command.
12271 #~(job "5 0 * * *" ;Vixie cron syntax
12272 "guix gc -F 1G"))
12273
12274 (define idutils-job
12275 ;; Update the index database as user "charlie" at 12:15PM
12276 ;; and 19:15PM. This runs from the user's home directory.
12277 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
12278 (string-append #$idutils "/bin/mkid src")
12279 #:user "charlie"))
12280
12281 (operating-system
12282 ;; @dots{}
12283 (services (cons (service mcron-service-type
12284 (mcron-configuration
12285 (jobs (list garbage-collector-job
12286 updatedb-job
12287 idutils-job))))
12288 %base-services)))
12289 @end lisp
12290
12291 @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
12292 for more information on mcron job specifications. Below is the
12293 reference of the mcron service.
12294
12295 On a running system, you can use the @code{schedule} action of the service to
12296 visualize the mcron jobs that will be executed next:
12297
12298 @example
12299 # herd schedule mcron
12300 @end example
12301
12302 @noindent
12303 The example above lists the next five tasks that will be executed, but you can
12304 also specify the number of tasks to display:
12305
12306 @example
12307 # herd schedule mcron 10
12308 @end example
12309
12310 @defvr {Scheme Variable} mcron-service-type
12311 This is the type of the @code{mcron} service, whose value is an
12312 @code{mcron-configuration} object.
12313
12314 This service type can be the target of a service extension that provides
12315 it additional job specifications (@pxref{Service Composition}). In
12316 other words, it is possible to define services that provide additional
12317 mcron jobs to run.
12318 @end defvr
12319
12320 @deftp {Data Type} mcron-configuration
12321 Data type representing the configuration of mcron.
12322
12323 @table @asis
12324 @item @code{mcron} (default: @var{mcron})
12325 The mcron package to use.
12326
12327 @item @code{jobs}
12328 This is a list of gexps (@pxref{G-Expressions}), where each gexp
12329 corresponds to an mcron job specification (@pxref{Syntax, mcron job
12330 specifications,, mcron, GNU@tie{}mcron}).
12331 @end table
12332 @end deftp
12333
12334
12335 @node Log Rotation
12336 @subsection Log Rotation
12337
12338 @cindex rottlog
12339 @cindex log rotation
12340 @cindex logging
12341 Log files such as those found in @file{/var/log} tend to grow endlessly,
12342 so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
12343 their contents in separate files, possibly compressed. The @code{(gnu
12344 services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
12345 log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
12346
12347 The example below defines an operating system that provides log rotation
12348 with the default settings, for commonly encountered log files.
12349
12350 @lisp
12351 (use-modules (guix) (gnu))
12352 (use-service-modules admin mcron)
12353 (use-package-modules base idutils)
12354
12355 (operating-system
12356 ;; @dots{}
12357 (services (cons (service rottlog-service-type)
12358 %base-services)))
12359 @end lisp
12360
12361 @defvr {Scheme Variable} rottlog-service-type
12362 This is the type of the Rottlog service, whose value is a
12363 @code{rottlog-configuration} object.
12364
12365 Other services can extend this one with new @code{log-rotation} objects
12366 (see below), thereby augmenting the set of files to be rotated.
12367
12368 This service type can define mcron jobs (@pxref{Scheduled Job
12369 Execution}) to run the rottlog service.
12370 @end defvr
12371
12372 @deftp {Data Type} rottlog-configuration
12373 Data type representing the configuration of rottlog.
12374
12375 @table @asis
12376 @item @code{rottlog} (default: @code{rottlog})
12377 The Rottlog package to use.
12378
12379 @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
12380 The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
12381 rottlog, GNU Rot[t]log Manual}).
12382
12383 @item @code{rotations} (default: @code{%default-rotations})
12384 A list of @code{log-rotation} objects as defined below.
12385
12386 @item @code{jobs}
12387 This is a list of gexps where each gexp corresponds to an mcron job
12388 specification (@pxref{Scheduled Job Execution}).
12389 @end table
12390 @end deftp
12391
12392 @deftp {Data Type} log-rotation
12393 Data type representing the rotation of a group of log files.
12394
12395 Taking an example from the Rottlog manual (@pxref{Period Related File
12396 Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
12397 defined like this:
12398
12399 @example
12400 (log-rotation
12401 (frequency 'daily)
12402 (files '("/var/log/apache/*"))
12403 (options '("storedir apache-archives"
12404 "rotate 6"
12405 "notifempty"
12406 "nocompress")))
12407 @end example
12408
12409 The list of fields is as follows:
12410
12411 @table @asis
12412 @item @code{frequency} (default: @code{'weekly})
12413 The log rotation frequency, a symbol.
12414
12415 @item @code{files}
12416 The list of files or file glob patterns to rotate.
12417
12418 @item @code{options} (default: @code{'()})
12419 The list of rottlog options for this rotation (@pxref{Configuration
12420 parameters,,, rottlog, GNU Rot[t]lg Manual}).
12421
12422 @item @code{post-rotate} (default: @code{#f})
12423 Either @code{#f} or a gexp to execute once the rotation has completed.
12424 @end table
12425 @end deftp
12426
12427 @defvr {Scheme Variable} %default-rotations
12428 Specifies weekly rotation of @var{%rotated-files} and
12429 a couple of other files.
12430 @end defvr
12431
12432 @defvr {Scheme Variable} %rotated-files
12433 The list of syslog-controlled files to be rotated. By default it is:
12434 @code{'("/var/log/messages" "/var/log/secure")}.
12435 @end defvr
12436
12437 @node Networking Services
12438 @subsection Networking Services
12439
12440 The @code{(gnu services networking)} module provides services to configure
12441 the network interface.
12442
12443 @cindex DHCP, networking service
12444 @defvr {Scheme Variable} dhcp-client-service-type
12445 This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
12446 Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
12447 is the DHCP client package to use, @code{isc-dhcp} by default.
12448 @end defvr
12449
12450 @deffn {Scheme Procedure} dhcpd-service-type
12451 This type defines a service that runs a DHCP daemon. To create a
12452 service of this type, you must supply a @code{<dhcpd-configuration>}.
12453 For example:
12454
12455 @example
12456 (service dhcpd-service-type
12457 (dhcpd-configuration
12458 (config-file (local-file "my-dhcpd.conf"))
12459 (interfaces '("enp0s25"))))
12460 @end example
12461 @end deffn
12462
12463 @deftp {Data Type} dhcpd-configuration
12464 @table @asis
12465 @item @code{package} (default: @code{isc-dhcp})
12466 The package that provides the DHCP daemon. This package is expected to
12467 provide the daemon at @file{sbin/dhcpd} relative to its output
12468 directory. The default package is the
12469 @uref{http://www.isc.org/products/DHCP, ISC's DHCP server}.
12470 @item @code{config-file} (default: @code{#f})
12471 The configuration file to use. This is required. It will be passed to
12472 @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
12473 object (@pxref{G-Expressions, file-like objects}). See @code{man
12474 dhcpd.conf} for details on the configuration file syntax.
12475 @item @code{version} (default: @code{"4"})
12476 The DHCP version to use. The ISC DHCP server supports the values ``4'',
12477 ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
12478 options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
12479 details.
12480 @item @code{run-directory} (default: @code{"/run/dhcpd"})
12481 The run directory to use. At service activation time, this directory
12482 will be created if it does not exist.
12483 @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
12484 The PID file to use. This corresponds to the @code{-pf} option of
12485 @code{dhcpd}. See @code{man dhcpd} for details.
12486 @item @code{interfaces} (default: @code{'()})
12487 The names of the network interfaces on which dhcpd should listen for
12488 broadcasts. If this list is not empty, then its elements (which must be
12489 strings) will be appended to the @code{dhcpd} invocation when starting
12490 the daemon. It may not be necessary to explicitly specify any
12491 interfaces here; see @code{man dhcpd} for details.
12492 @end table
12493 @end deftp
12494
12495 @defvr {Scheme Variable} static-networking-service-type
12496 This is the type for statically-configured network interfaces.
12497 @c TODO Document <static-networking> data structures.
12498 @end defvr
12499
12500 @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
12501 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
12502 [#:requirement @code{'(udev)}]
12503 Return a service that starts @var{interface} with address @var{ip}. If
12504 @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
12505 it must be a string specifying the default network gateway. @var{requirement}
12506 can be used to declare a dependency on another service before configuring the
12507 interface.
12508
12509 This procedure can be called several times, one for each network
12510 interface of interest. Behind the scenes what it does is extend
12511 @code{static-networking-service-type} with additional network interfaces
12512 to handle.
12513
12514 For example:
12515
12516 @example
12517 (static-networking-service "eno1" "192.168.1.82"
12518 #:gateway "192.168.1.2"
12519 #:name-servers '("192.168.1.2"))
12520 @end example
12521 @end deffn
12522
12523 @cindex wicd
12524 @cindex wireless
12525 @cindex WiFi
12526 @cindex network management
12527 @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
12528 Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
12529 management daemon that aims to simplify wired and wireless networking.
12530
12531 This service adds the @var{wicd} package to the global profile, providing
12532 several commands to interact with the daemon and configure networking:
12533 @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
12534 and @command{wicd-curses} user interfaces.
12535 @end deffn
12536
12537 @cindex ModemManager
12538
12539 @defvr {Scheme Variable} modem-manager-service-type
12540 This is the service type for the
12541 @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
12542 service. The value for this service type is a
12543 @code{modem-manager-configuration} record.
12544
12545 This service is part of @code{%desktop-services} (@pxref{Desktop
12546 Services}).
12547 @end defvr
12548
12549 @deftp {Data Type} modem-manager-configuration
12550 Data type representing the configuration of ModemManager.
12551
12552 @table @asis
12553 @item @code{modem-manager} (default: @code{modem-manager})
12554 The ModemManager package to use.
12555
12556 @end table
12557 @end deftp
12558
12559 @cindex NetworkManager
12560
12561 @defvr {Scheme Variable} network-manager-service-type
12562 This is the service type for the
12563 @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
12564 service. The value for this service type is a
12565 @code{network-manager-configuration} record.
12566
12567 This service is part of @code{%desktop-services} (@pxref{Desktop
12568 Services}).
12569 @end defvr
12570
12571 @deftp {Data Type} network-manager-configuration
12572 Data type representing the configuration of NetworkManager.
12573
12574 @table @asis
12575 @item @code{network-manager} (default: @code{network-manager})
12576 The NetworkManager package to use.
12577
12578 @item @code{dns} (default: @code{"default"})
12579 Processing mode for DNS, which affects how NetworkManager uses the
12580 @code{resolv.conf} configuration file.
12581
12582 @table @samp
12583 @item default
12584 NetworkManager will update @code{resolv.conf} to reflect the nameservers
12585 provided by currently active connections.
12586
12587 @item dnsmasq
12588 NetworkManager will run @code{dnsmasq} as a local caching nameserver,
12589 using a "split DNS" configuration if you are connected to a VPN, and
12590 then update @code{resolv.conf} to point to the local nameserver.
12591
12592 @item none
12593 NetworkManager will not modify @code{resolv.conf}.
12594 @end table
12595
12596 @item @code{vpn-plugins} (default: @code{'()})
12597 This is the list of available plugins for virtual private networks
12598 (VPNs). An example of this is the @code{network-manager-openvpn}
12599 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
12600
12601 @end table
12602 @end deftp
12603
12604 @cindex Connman
12605 @deffn {Scheme Variable} connman-service-type
12606 This is the service type to run @url{https://01.org/connman,Connman},
12607 a network connection manager.
12608
12609 Its value must be an
12610 @code{connman-configuration} record as in this example:
12611
12612 @example
12613 (service connman-service-type
12614 (connman-configuration
12615 (disable-vpn? #t)))
12616 @end example
12617
12618 See below for details about @code{connman-configuration}.
12619 @end deffn
12620
12621 @deftp {Data Type} connman-configuration
12622 Data Type representing the configuration of connman.
12623
12624 @table @asis
12625 @item @code{connman} (default: @var{connman})
12626 The connman package to use.
12627
12628 @item @code{disable-vpn?} (default: @code{#f})
12629 When true, disable connman's vpn plugin.
12630 @end table
12631 @end deftp
12632
12633 @cindex WPA Supplicant
12634 @defvr {Scheme Variable} wpa-supplicant-service-type
12635 This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
12636 supplicant}, an authentication daemon required to authenticate against
12637 encrypted WiFi or ethernet networks.
12638 @end defvr
12639
12640 @deftp {Data Type} wpa-supplicant-configuration
12641 Data type representing the configuration of WPA Supplicant.
12642
12643 It takes the following parameters:
12644
12645 @table @asis
12646 @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
12647 The WPA Supplicant package to use.
12648
12649 @item @code{dbus?} (default: @code{#t})
12650 Whether to listen for requests on D-Bus.
12651
12652 @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
12653 Where to store the PID file.
12654
12655 @item @code{interface} (default: @code{#f})
12656 If this is set, it must specify the name of a network interface that
12657 WPA supplicant will control.
12658
12659 @item @code{config-file} (default: @code{#f})
12660 Optional configuration file to use.
12661
12662 @item @code{extra-options} (default: @code{'()})
12663 List of additional command-line arguments to pass to the daemon.
12664 @end table
12665 @end deftp
12666
12667 @cindex iptables
12668 @defvr {Scheme Variable} iptables-service-type
12669 This is the service type to set up an iptables configuration. iptables is a
12670 packet filtering framework supported by the Linux kernel. This service
12671 supports configuring iptables for both IPv4 and IPv6. A simple example
12672 configuration rejecting all incoming connections except those to the ssh port
12673 22 is shown below.
12674
12675 @lisp
12676 (service iptables-service-type
12677 (iptables-configuration
12678 (ipv4-rules (plain-file "iptables.rules" "*filter
12679 :INPUT ACCEPT
12680 :FORWARD ACCEPT
12681 :OUTPUT ACCEPT
12682 -A INPUT -p tcp --dport 22 -j ACCEPT
12683 -A INPUT -j REJECT --reject-with icmp-port-unreachable
12684 COMMIT
12685 "))
12686 (ipv6-rules (plain-file "ip6tables.rules" "*filter
12687 :INPUT ACCEPT
12688 :FORWARD ACCEPT
12689 :OUTPUT ACCEPT
12690 -A INPUT -p tcp --dport 22 -j ACCEPT
12691 -A INPUT -j REJECT --reject-with icmp6-port-unreachable
12692 COMMIT
12693 "))))
12694 @end lisp
12695 @end defvr
12696
12697 @deftp {Data Type} iptables-configuration
12698 The data type representing the configuration of iptables.
12699
12700 @table @asis
12701 @item @code{iptables} (default: @code{iptables})
12702 The iptables package that provides @code{iptables-restore} and
12703 @code{ip6tables-restore}.
12704 @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
12705 The iptables rules to use. It will be passed to @code{iptables-restore}.
12706 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
12707 objects}).
12708 @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
12709 The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
12710 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
12711 objects}).
12712 @end table
12713 @end deftp
12714
12715 @cindex NTP (Network Time Protocol), service
12716 @cindex real time clock
12717 @defvr {Scheme Variable} ntp-service-type
12718 This is the type of the service running the @uref{http://www.ntp.org,
12719 Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
12720 system clock synchronized with that of the specified NTP servers.
12721
12722 The value of this service is an @code{ntpd-configuration} object, as described
12723 below.
12724 @end defvr
12725
12726 @deftp {Data Type} ntp-configuration
12727 This is the data type for the NTP service configuration.
12728
12729 @table @asis
12730 @item @code{servers} (default: @code{%ntp-servers})
12731 This is the list of servers (host names) with which @command{ntpd} will be
12732 synchronized.
12733
12734 @item @code{allow-large-adjustment?} (default: @code{#f})
12735 This determines whether @command{ntpd} is allowed to make an initial
12736 adjustment of more than 1,000 seconds.
12737
12738 @item @code{ntp} (default: @code{ntp})
12739 The NTP package to use.
12740 @end table
12741 @end deftp
12742
12743 @defvr {Scheme Variable} %ntp-servers
12744 List of host names used as the default NTP servers. These are servers of the
12745 @uref{https://www.ntppool.org/en/, NTP Pool Project}.
12746 @end defvr
12747
12748 @cindex OpenNTPD
12749 @deffn {Scheme Procedure} openntpd-service-type
12750 Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
12751 by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
12752 clock synchronized with that of the given servers.
12753
12754 @example
12755 (service
12756 openntpd-service-type
12757 (openntpd-configuration
12758 (listen-on '("127.0.0.1" "::1"))
12759 (sensor '("udcf0 correction 70000"))
12760 (constraint-from '("www.gnu.org"))
12761 (constraints-from '("https://www.google.com/"))
12762 (allow-large-adjustment? #t)))
12763
12764 @end example
12765 @end deffn
12766
12767 @deftp {Data Type} openntpd-configuration
12768 @table @asis
12769 @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
12770 The openntpd executable to use.
12771 @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
12772 A list of local IP addresses or hostnames the ntpd daemon should listen on.
12773 @item @code{query-from} (default: @code{'()})
12774 A list of local IP address the ntpd daemon should use for outgoing queries.
12775 @item @code{sensor} (default: @code{'()})
12776 Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
12777 will listen to each sensor that acutally exists and ignore non-existant ones.
12778 See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
12779 information.
12780 @item @code{server} (default: @var{%ntp-servers})
12781 Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
12782 @item @code{servers} (default: @code{'()})
12783 Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
12784 @item @code{constraint-from} (default: @code{'()})
12785 @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
12786 This time information is not used for precision but acts as an authenticated
12787 constraint, thereby reducing the impact of unauthenticated NTP
12788 man-in-the-middle attacks.
12789 Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
12790 a constraint.
12791 @item @code{constraints-from} (default: @code{'()})
12792 As with constraint from, specify a list of URLs, IP addresses or hostnames of
12793 HTTPS servers to provide a constraint. Should the hostname resolve to multiple
12794 IP addresses, @code{ntpd} will calculate a median constraint from all of them.
12795 @item @code{allow-large-adjustment?} (default: @code{#f})
12796 Determines if @code{ntpd} is allowed to make an initial adjustment of more
12797 than 180 seconds.
12798 @end table
12799 @end deftp
12800
12801 @cindex inetd
12802 @deffn {Scheme variable} inetd-service-type
12803 This service runs the @command{inetd} (@pxref{inetd invocation,,,
12804 inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
12805 connections on internet sockets, and lazily starts the specified server
12806 program when a connection is made on one of these sockets.
12807
12808 The value of this service is an @code{inetd-configuration} object. The
12809 following example configures the @command{inetd} daemon to provide the
12810 built-in @command{echo} service, as well as an smtp service which
12811 forwards smtp traffic over ssh to a server @code{smtp-server} behind a
12812 gateway @code{hostname}:
12813
12814 @example
12815 (service
12816 inetd-service-type
12817 (inetd-configuration
12818 (entries (list
12819 (inetd-entry
12820 (name "echo")
12821 (socket-type 'stream)
12822 (protocol "tcp")
12823 (wait? #f)
12824 (user "root"))
12825 (inetd-entry
12826 (node "127.0.0.1")
12827 (name "smtp")
12828 (socket-type 'stream)
12829 (protocol "tcp")
12830 (wait? #f)
12831 (user "root")
12832 (program (file-append openssh "/bin/ssh"))
12833 (arguments
12834 '("ssh" "-qT" "-i" "/path/to/ssh_key"
12835 "-W" "smtp-server:25" "user@@hostname")))))
12836 @end example
12837
12838 See below for more details about @code{inetd-configuration}.
12839 @end deffn
12840
12841 @deftp {Data Type} inetd-configuration
12842 Data type representing the configuration of @command{inetd}.
12843
12844 @table @asis
12845 @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
12846 The @command{inetd} executable to use.
12847
12848 @item @code{entries} (default: @code{'()})
12849 A list of @command{inetd} service entries. Each entry should be created
12850 by the @code{inetd-entry} constructor.
12851 @end table
12852 @end deftp
12853
12854 @deftp {Data Type} inetd-entry
12855 Data type representing an entry in the @command{inetd} configuration.
12856 Each entry corresponds to a socket where @command{inetd} will listen for
12857 requests.
12858
12859 @table @asis
12860 @item @code{node} (default: @code{#f})
12861 Optional string, a comma-separated list of local addresses
12862 @command{inetd} should use when listening for this service.
12863 @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
12864 description of all options.
12865 @item @code{name}
12866 A string, the name must correspond to an entry in @code{/etc/services}.
12867 @item @code{socket-type}
12868 One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
12869 @code{'seqpacket}.
12870 @item @code{protocol}
12871 A string, must correspond to an entry in @code{/etc/protocols}.
12872 @item @code{wait?} (default: @code{#t})
12873 Whether @command{inetd} should wait for the server to exit before
12874 listening to new service requests.
12875 @item @code{user}
12876 A string containing the user (and, optionally, group) name of the user
12877 as whom the server should run. The group name can be specified in a
12878 suffix, separated by a colon or period, i.e.@: @code{"user"},
12879 @code{"user:group"} or @code{"user.group"}.
12880 @item @code{program} (default: @code{"internal"})
12881 The server program which will serve the requests, or @code{"internal"}
12882 if @command{inetd} should use a built-in service.
12883 @item @code{arguments} (default: @code{'()})
12884 A list strings or file-like objects, which are the server program's
12885 arguments, starting with the zeroth argument, i.e.@: the name of the
12886 program itself. For @command{inetd}'s internal services, this entry
12887 must be @code{'()} or @code{'("internal")}.
12888 @end table
12889
12890 @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
12891 detailed discussion of each configuration field.
12892 @end deftp
12893
12894 @cindex Tor
12895 @defvr {Scheme Variable} tor-service-type
12896 This is the type for a service that runs the @uref{https://torproject.org,
12897 Tor} anonymous networking daemon. The service is configured using a
12898 @code{<tor-configuration>} record. By default, the Tor daemon runs as the
12899 @code{tor} unprivileged user, which is a member of the @code{tor} group.
12900
12901 @end defvr
12902
12903 @deftp {Data Type} tor-configuration
12904 @table @asis
12905 @item @code{tor} (default: @code{tor})
12906 The package that provides the Tor daemon. This package is expected to provide
12907 the daemon at @file{bin/tor} relative to its output directory. The default
12908 package is the @uref{https://www.torproject.org, Tor Project's}
12909 implementation.
12910
12911 @item @code{config-file} (default: @code{(plain-file "empty" "")})
12912 The configuration file to use. It will be appended to a default configuration
12913 file, and the final configuration file will be passed to @code{tor} via its
12914 @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
12915 file-like objects}). See @code{man tor} for details on the configuration file
12916 syntax.
12917
12918 @item @code{hidden-services} (default: @code{'()})
12919 The list of @code{<hidden-service>} records to use. For any hidden service
12920 you include in this list, appropriate configuration to enable the hidden
12921 service will be automatically added to the default configuration file. You
12922 may conveniently create @code{<hidden-service>} records using the
12923 @code{tor-hidden-service} procedure described below.
12924
12925 @item @code{socks-socket-type} (default: @code{'tcp})
12926 The default socket type that Tor should use for its SOCKS socket. This must
12927 be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
12928 Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
12929 If it is @code{'unix}, then Tor will listen on the UNIX domain socket
12930 @file{/var/run/tor/socks-sock}, which will be made writable by members of the
12931 @code{tor} group.
12932
12933 If you want to customize the SOCKS socket in more detail, leave
12934 @code{socks-socket-type} at its default value of @code{'tcp} and use
12935 @code{config-file} to override the default by providing your own
12936 @code{SocksPort} option.
12937 @end table
12938 @end deftp
12939
12940 @cindex hidden service
12941 @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
12942 Define a new Tor @dfn{hidden service} called @var{name} and implementing
12943 @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
12944
12945 @example
12946 '((22 "127.0.0.1:22")
12947 (80 "127.0.0.1:8080"))
12948 @end example
12949
12950 In this example, port 22 of the hidden service is mapped to local port 22, and
12951 port 80 is mapped to local port 8080.
12952
12953 This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
12954 the @file{hostname} file contains the @code{.onion} host name for the hidden
12955 service.
12956
12957 See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
12958 project's documentation} for more information.
12959 @end deffn
12960
12961 The @code{(gnu services rsync)} module provides the following services:
12962
12963 You might want an rsync daemon if you have files that you want available
12964 so anyone (or just yourself) can download existing files or upload new
12965 files.
12966
12967 @deffn {Scheme Variable} rsync-service-type
12968 This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
12969 @command{rsync-configuration} record as in this example:
12970
12971 @example
12972 (service rsync-service-type)
12973 @end example
12974
12975 See below for details about @code{rsync-configuration}.
12976 @end deffn
12977
12978 @deftp {Data Type} rsync-configuration
12979 Data type representing the configuration for @code{rsync-service}.
12980
12981 @table @asis
12982 @item @code{package} (default: @var{rsync})
12983 @code{rsync} package to use.
12984
12985 @item @code{port-number} (default: @code{873})
12986 TCP port on which @command{rsync} listens for incoming connections. If port
12987 is less than @code{1024} @command{rsync} needs to be started as the
12988 @code{root} user and group.
12989
12990 @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
12991 Name of the file where @command{rsync} writes its PID.
12992
12993 @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
12994 Name of the file where @command{rsync} writes its lock file.
12995
12996 @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
12997 Name of the file where @command{rsync} writes its log file.
12998
12999 @item @code{use-chroot?} (default: @var{#t})
13000 Whether to use chroot for @command{rsync} shared directory.
13001
13002 @item @code{share-path} (default: @file{/srv/rsync})
13003 Location of the @command{rsync} shared directory.
13004
13005 @item @code{share-comment} (default: @code{"Rsync share"})
13006 Comment of the @command{rsync} shared directory.
13007
13008 @item @code{read-only?} (default: @var{#f})
13009 Read-write permissions to shared directory.
13010
13011 @item @code{timeout} (default: @code{300})
13012 I/O timeout in seconds.
13013
13014 @item @code{user} (default: @var{"root"})
13015 Owner of the @code{rsync} process.
13016
13017 @item @code{group} (default: @var{"root"})
13018 Group of the @code{rsync} process.
13019
13020 @item @code{uid} (default: @var{"rsyncd"})
13021 User name or user ID that file transfers to and from that module should take
13022 place as when the daemon was run as @code{root}.
13023
13024 @item @code{gid} (default: @var{"rsyncd"})
13025 Group name or group ID that will be used when accessing the module.
13026
13027 @end table
13028 @end deftp
13029
13030 Furthermore, @code{(gnu services ssh)} provides the following services.
13031 @cindex SSH
13032 @cindex SSH server
13033
13034 @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
13035 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
13036 [#:allow-empty-passwords? #f] [#:root-login? #f] @
13037 [#:syslog-output? #t] [#:x11-forwarding? #t] @
13038 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
13039 [#:public-key-authentication? #t] [#:initialize? #t]
13040 Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
13041 @var{host-key} must designate a file containing the host key, and readable
13042 only by root.
13043
13044 When @var{daemonic?} is true, @command{lshd} will detach from the
13045 controlling terminal and log its output to syslogd, unless one sets
13046 @var{syslog-output?} to false. Obviously, it also makes lsh-service
13047 depend on existence of syslogd service. When @var{pid-file?} is true,
13048 @command{lshd} writes its PID to the file called @var{pid-file}.
13049
13050 When @var{initialize?} is true, automatically create the seed and host key
13051 upon service activation if they do not exist yet. This may take long and
13052 require interaction.
13053
13054 When @var{initialize?} is false, it is up to the user to initialize the
13055 randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
13056 a key pair with the private key stored in file @var{host-key} (@pxref{lshd
13057 basics,,, lsh, LSH Manual}).
13058
13059 When @var{interfaces} is empty, lshd listens for connections on all the
13060 network interfaces; otherwise, @var{interfaces} must be a list of host names
13061 or addresses.
13062
13063 @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
13064 passwords, and @var{root-login?} specifies whether to accept log-ins as
13065 root.
13066
13067 The other options should be self-descriptive.
13068 @end deffn
13069
13070 @cindex SSH
13071 @cindex SSH server
13072 @deffn {Scheme Variable} openssh-service-type
13073 This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
13074 shell daemon, @command{sshd}. Its value must be an
13075 @code{openssh-configuration} record as in this example:
13076
13077 @example
13078 (service openssh-service-type
13079 (openssh-configuration
13080 (x11-forwarding? #t)
13081 (permit-root-login 'without-password)
13082 (authorized-keys
13083 `(("alice" ,(local-file "alice.pub"))
13084 ("bob" ,(local-file "bob.pub"))))))
13085 @end example
13086
13087 See below for details about @code{openssh-configuration}.
13088
13089 This service can be extended with extra authorized keys, as in this
13090 example:
13091
13092 @example
13093 (service-extension openssh-service-type
13094 (const `(("charlie"
13095 ,(local-file "charlie.pub")))))
13096 @end example
13097 @end deffn
13098
13099 @deftp {Data Type} openssh-configuration
13100 This is the configuration record for OpenSSH's @command{sshd}.
13101
13102 @table @asis
13103 @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
13104 Name of the file where @command{sshd} writes its PID.
13105
13106 @item @code{port-number} (default: @code{22})
13107 TCP port on which @command{sshd} listens for incoming connections.
13108
13109 @item @code{permit-root-login} (default: @code{#f})
13110 This field determines whether and when to allow logins as root. If
13111 @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
13112 If it's the symbol @code{'without-password}, then root logins are
13113 permitted but not with password-based authentication.
13114
13115 @item @code{allow-empty-passwords?} (default: @code{#f})
13116 When true, users with empty passwords may log in. When false, they may
13117 not.
13118
13119 @item @code{password-authentication?} (default: @code{#t})
13120 When true, users may log in with their password. When false, they have
13121 other authentication methods.
13122
13123 @item @code{public-key-authentication?} (default: @code{#t})
13124 When true, users may log in using public key authentication. When
13125 false, users have to use other authentication method.
13126
13127 Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
13128 This is used only by protocol version 2.
13129
13130 @item @code{x11-forwarding?} (default: @code{#f})
13131 When true, forwarding of X11 graphical client connections is
13132 enabled---in other words, @command{ssh} options @option{-X} and
13133 @option{-Y} will work.
13134
13135 @item @code{allow-agent-forwarding?} (default: @code{#t})
13136 Whether to allow agent forwarding.
13137
13138 @item @code{allow-tcp-forwarding?} (default: @code{#t})
13139 Whether to allow TCP forwarding.
13140
13141 @item @code{gateway-ports?} (default: @code{#f})
13142 Whether to allow gateway ports.
13143
13144 @item @code{challenge-response-authentication?} (default: @code{#f})
13145 Specifies whether challenge response authentication is allowed (e.g.@: via
13146 PAM).
13147
13148 @item @code{use-pam?} (default: @code{#t})
13149 Enables the Pluggable Authentication Module interface. If set to
13150 @code{#t}, this will enable PAM authentication using
13151 @code{challenge-response-authentication?} and
13152 @code{password-authentication?}, in addition to PAM account and session
13153 module processing for all authentication types.
13154
13155 Because PAM challenge response authentication usually serves an
13156 equivalent role to password authentication, you should disable either
13157 @code{challenge-response-authentication?} or
13158 @code{password-authentication?}.
13159
13160 @item @code{print-last-log?} (default: @code{#t})
13161 Specifies whether @command{sshd} should print the date and time of the
13162 last user login when a user logs in interactively.
13163
13164 @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
13165 Configures external subsystems (e.g.@: file transfer daemon).
13166
13167 This is a list of two-element lists, each of which containing the
13168 subsystem name and a command (with optional arguments) to execute upon
13169 subsystem request.
13170
13171 The command @command{internal-sftp} implements an in-process SFTP
13172 server. Alternately, one can specify the @command{sftp-server} command:
13173 @example
13174 (service openssh-service-type
13175 (openssh-configuration
13176 (subsystems
13177 `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
13178 @end example
13179
13180 @item @code{accepted-environment} (default: @code{'()})
13181 List of strings describing which environment variables may be exported.
13182
13183 Each string gets on its own line. See the @code{AcceptEnv} option in
13184 @code{man sshd_config}.
13185
13186 This example allows ssh-clients to export the @code{COLORTERM} variable.
13187 It is set by terminal emulators, which support colors. You can use it in
13188 your shell's ressource file to enable colors for the prompt and commands
13189 if this variable is set.
13190
13191 @example
13192 (service openssh-service-type
13193 (openssh-configuration
13194 (accepted-environment '("COLORTERM"))))
13195 @end example
13196
13197 @item @code{authorized-keys} (default: @code{'()})
13198 @cindex authorized keys, SSH
13199 @cindex SSH authorized keys
13200 This is the list of authorized keys. Each element of the list is a user
13201 name followed by one or more file-like objects that represent SSH public
13202 keys. For example:
13203
13204 @example
13205 (openssh-configuration
13206 (authorized-keys
13207 `(("rekado" ,(local-file "rekado.pub"))
13208 ("chris" ,(local-file "chris.pub"))
13209 ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
13210 @end example
13211
13212 @noindent
13213 registers the specified public keys for user accounts @code{rekado},
13214 @code{chris}, and @code{root}.
13215
13216 Additional authorized keys can be specified @i{via}
13217 @code{service-extension}.
13218
13219 Note that this does @emph{not} interfere with the use of
13220 @file{~/.ssh/authorized_keys}.
13221
13222 @item @code{log-level} (default: @code{'info})
13223 This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
13224 @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
13225 page for @file{sshd_config} for the full list of level names.
13226
13227 @item @code{extra-content} (default: @code{""})
13228 This field can be used to append arbitrary text to the configuration file. It
13229 is especially useful for elaborate configurations that cannot be expressed
13230 otherwise. This configuration, for example, would generally disable root
13231 logins, but permit them from one specific IP address:
13232
13233 @example
13234 (openssh-configuration
13235 (extra-content "\
13236 Match Address 192.168.0.1
13237 PermitRootLogin yes"))
13238 @end example
13239
13240 @end table
13241 @end deftp
13242
13243 @deffn {Scheme Procedure} dropbear-service [@var{config}]
13244 Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
13245 daemon} with the given @var{config}, a @code{<dropbear-configuration>}
13246 object.
13247
13248 For example, to specify a Dropbear service listening on port 1234, add
13249 this call to the operating system's @code{services} field:
13250
13251 @example
13252 (dropbear-service (dropbear-configuration
13253 (port-number 1234)))
13254 @end example
13255 @end deffn
13256
13257 @deftp {Data Type} dropbear-configuration
13258 This data type represents the configuration of a Dropbear SSH daemon.
13259
13260 @table @asis
13261 @item @code{dropbear} (default: @var{dropbear})
13262 The Dropbear package to use.
13263
13264 @item @code{port-number} (default: 22)
13265 The TCP port where the daemon waits for incoming connections.
13266
13267 @item @code{syslog-output?} (default: @code{#t})
13268 Whether to enable syslog output.
13269
13270 @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
13271 File name of the daemon's PID file.
13272
13273 @item @code{root-login?} (default: @code{#f})
13274 Whether to allow @code{root} logins.
13275
13276 @item @code{allow-empty-passwords?} (default: @code{#f})
13277 Whether to allow empty passwords.
13278
13279 @item @code{password-authentication?} (default: @code{#t})
13280 Whether to enable password-based authentication.
13281 @end table
13282 @end deftp
13283
13284 @defvr {Scheme Variable} %facebook-host-aliases
13285 This variable contains a string for use in @file{/etc/hosts}
13286 (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
13287 line contains a entry that maps a known server name of the Facebook
13288 on-line service---e.g., @code{www.facebook.com}---to the local
13289 host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
13290
13291 This variable is typically used in the @code{hosts-file} field of an
13292 @code{operating-system} declaration (@pxref{operating-system Reference,
13293 @file{/etc/hosts}}):
13294
13295 @example
13296 (use-modules (gnu) (guix))
13297
13298 (operating-system
13299 (host-name "mymachine")
13300 ;; ...
13301 (hosts-file
13302 ;; Create a /etc/hosts file with aliases for "localhost"
13303 ;; and "mymachine", as well as for Facebook servers.
13304 (plain-file "hosts"
13305 (string-append (local-host-aliases host-name)
13306 %facebook-host-aliases))))
13307 @end example
13308
13309 This mechanism can prevent programs running locally, such as Web
13310 browsers, from accessing Facebook.
13311 @end defvr
13312
13313 The @code{(gnu services avahi)} provides the following definition.
13314
13315 @defvr {Scheme Variable} avahi-service-type
13316 This is the service that runs @command{avahi-daemon}, a system-wide
13317 mDNS/DNS-SD responder that allows for service discovery and
13318 ``zero-configuration'' host name lookups (see @uref{http://avahi.org/}).
13319 Its value must be a @code{zero-configuration} record---see below.
13320
13321 This service extends the name service cache daemon (nscd) so that it can
13322 resolve @code{.local} host names using
13323 @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
13324 Service Switch}, for information on host name resolution.
13325
13326 Additionally, add the @var{avahi} package to the system profile so that
13327 commands such as @command{avahi-browse} are directly usable.
13328 @end defvr
13329
13330 @deftp {Data Type} avahi-configuration
13331 Data type representation the configuration for Avahi.
13332
13333 @table @asis
13334
13335 @item @code{host-name} (default: @code{#f})
13336 If different from @code{#f}, use that as the host name to
13337 publish for this machine; otherwise, use the machine's actual host name.
13338
13339 @item @code{publish?} (default: @code{#t})
13340 When true, allow host names and services to be published (broadcast) over the
13341 network.
13342
13343 @item @code{publish-workstation?} (default: @code{#t})
13344 When true, @command{avahi-daemon} publishes the machine's host name and IP
13345 address via mDNS on the local network. To view the host names published on
13346 your local network, you can run:
13347
13348 @example
13349 avahi-browse _workstation._tcp
13350 @end example
13351
13352 @item @code{wide-area?} (default: @code{#f})
13353 When true, DNS-SD over unicast DNS is enabled.
13354
13355 @item @code{ipv4?} (default: @code{#t})
13356 @itemx @code{ipv6?} (default: @code{#t})
13357 These fields determine whether to use IPv4/IPv6 sockets.
13358
13359 @item @code{domains-to-browse} (default: @code{'()})
13360 This is a list of domains to browse.
13361 @end table
13362 @end deftp
13363
13364 @deffn {Scheme Variable} openvswitch-service-type
13365 This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
13366 service, whose value should be an @code{openvswitch-configuration}
13367 object.
13368 @end deffn
13369
13370 @deftp {Data Type} openvswitch-configuration
13371 Data type representing the configuration of Open vSwitch, a multilayer
13372 virtual switch which is designed to enable massive network automation
13373 through programmatic extension.
13374
13375 @table @asis
13376 @item @code{package} (default: @var{openvswitch})
13377 Package object of the Open vSwitch.
13378
13379 @end table
13380 @end deftp
13381
13382 @node X Window
13383 @subsection X Window
13384
13385 @cindex X11
13386 @cindex X Window System
13387 @cindex login manager
13388 Support for the X Window graphical display system---specifically
13389 Xorg---is provided by the @code{(gnu services xorg)} module. Note that
13390 there is no @code{xorg-service} procedure. Instead, the X server is
13391 started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
13392
13393 @cindex GDM
13394 @cindex GNOME, login manager
13395 GDM of course allows users to log in into window managers and desktop
13396 environments other than GNOME; for those using GNOME, GDM is required for
13397 features such as automatic screen locking.
13398
13399 @cindex window manager
13400 To use X11, you must install at least one @dfn{window manager}---for
13401 example the @code{windowmaker} or @code{openbox} packages---preferably
13402 by adding it to the @code{packages} field of your operating system
13403 definition (@pxref{operating-system Reference, system-wide packages}).
13404
13405 @defvr {Scheme Variable} gdm-service-type
13406 This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
13407 Desktop Manager} (GDM), a program that manages graphical display servers and
13408 handles graphical user logins. Its value must be a @code{gdm-configuration}
13409 (see below.)
13410
13411 @cindex session types (X11)
13412 @cindex X11 session types
13413 GDM looks for @dfn{session types} described by the @file{.desktop} files in
13414 @file{/run/current-system/profile/share/xsessions} and allows users to choose
13415 a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
13416 and @code{i3} provide @file{.desktop} files; adding them to the system-wide
13417 set of packages automatically makes them available at the log-in screen.
13418
13419 In addition, @file{~/.xsession} files are honored. When available,
13420 @file{~/.xsession} must be an executable that starts a window manager
13421 and/or other X clients.
13422 @end defvr
13423
13424 @deftp {Data Type} gdm-configuration
13425 @table @asis
13426 @item @code{auto-login?} (default: @code{#f})
13427 @itemx @code{default-user} (default: @code{#f})
13428 When @code{auto-login?} is false, GDM presents a log-in screen.
13429
13430 When @code{auto-login?} is true, GDM logs in directly as
13431 @code{default-user}.
13432
13433 @item @code{gnome-shell-assets} (default: ...)
13434 List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
13435
13436 @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
13437 Configuration of the Xorg graphical server.
13438
13439 @item @code{xsession} (default: @code{(xinitrc)})
13440 Script to run before starting a X session.
13441
13442 @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
13443 File name of the @code{dbus-daemon} executable.
13444
13445 @item @code{gdm} (default: @code{gdm})
13446 The GDM package to use.
13447 @end table
13448 @end deftp
13449
13450 @defvr {Scheme Variable} slim-service-type
13451 This is the type for the SLiM graphical login manager for X11.
13452
13453 Like GDM, SLiM looks for session types described by @file{.desktop} files and
13454 allows users to choose a session from the log-in screen using @kbd{F1}. It
13455 also honors @file{~/.xsession} files.
13456 @end defvr
13457
13458 @deftp {Data Type} slim-configuration
13459 Data type representing the configuration of @code{slim-service-type}.
13460
13461 @table @asis
13462 @item @code{allow-empty-passwords?} (default: @code{#t})
13463 Whether to allow logins with empty passwords.
13464
13465 @item @code{auto-login?} (default: @code{#f})
13466 @itemx @code{default-user} (default: @code{""})
13467 When @code{auto-login?} is false, SLiM presents a log-in screen.
13468
13469 When @code{auto-login?} is true, SLiM logs in directly as
13470 @code{default-user}.
13471
13472 @item @code{theme} (default: @code{%default-slim-theme})
13473 @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
13474 The graphical theme to use and its name.
13475
13476 @item @code{auto-login-session} (default: @code{#f})
13477 If true, this must be the name of the executable to start as the default
13478 session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
13479
13480 If false, a session described by one of the available @file{.desktop}
13481 files in @code{/run/current-system/profile} and @code{~/.guix-profile}
13482 will be used.
13483
13484 @quotation Note
13485 You must install at least one window manager in the system profile or in
13486 your user profile. Failing to do that, if @code{auto-login-session} is
13487 false, you will be unable to log in.
13488 @end quotation
13489
13490 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
13491 Configuration of the Xorg graphical server.
13492
13493 @item @code{xauth} (default: @code{xauth})
13494 The XAuth package to use.
13495
13496 @item @code{shepherd} (default: @code{shepherd})
13497 The Shepherd package used when invoking @command{halt} and
13498 @command{reboot}.
13499
13500 @item @code{sessreg} (default: @code{sessreg})
13501 The sessreg package used in order to register the session.
13502
13503 @item @code{slim} (default: @code{slim})
13504 The SLiM package to use.
13505 @end table
13506 @end deftp
13507
13508 @defvr {Scheme Variable} %default-theme
13509 @defvrx {Scheme Variable} %default-theme-name
13510 The default SLiM theme and its name.
13511 @end defvr
13512
13513
13514 @deftp {Data Type} sddm-configuration
13515 This is the data type representing the sddm service configuration.
13516
13517 @table @asis
13518 @item @code{display-server} (default: "x11")
13519 Select display server to use for the greeter. Valid values are "x11"
13520 or "wayland".
13521
13522 @item @code{numlock} (default: "on")
13523 Valid values are "on", "off" or "none".
13524
13525 @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
13526 Command to run when halting.
13527
13528 @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
13529 Command to run when rebooting.
13530
13531 @item @code{theme} (default "maldives")
13532 Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
13533
13534 @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
13535 Directory to look for themes.
13536
13537 @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
13538 Directory to look for faces.
13539
13540 @item @code{default-path} (default "/run/current-system/profile/bin")
13541 Default PATH to use.
13542
13543 @item @code{minimum-uid} (default 1000)
13544 Minimum UID to display in SDDM.
13545
13546 @item @code{maximum-uid} (default 2000)
13547 Maximum UID to display in SDDM
13548
13549 @item @code{remember-last-user?} (default #t)
13550 Remember last user.
13551
13552 @item @code{remember-last-session?} (default #t)
13553 Remember last session.
13554
13555 @item @code{hide-users} (default "")
13556 Usernames to hide from SDDM greeter.
13557
13558 @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
13559 Users with shells listed will be hidden from the SDDM greeter.
13560
13561 @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
13562 Script to run before starting a wayland session.
13563
13564 @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
13565 Directory to look for desktop files starting wayland sessions.
13566
13567 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
13568 Configuration of the Xorg graphical server.
13569
13570 @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
13571 Path to xauth.
13572
13573 @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
13574 Path to Xephyr.
13575
13576 @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
13577 Script to run after starting xorg-server.
13578
13579 @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
13580 Script to run before stopping xorg-server.
13581
13582 @item @code{xsession-command} (default: @code{xinitrc})
13583 Script to run before starting a X session.
13584
13585 @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
13586 Directory to look for desktop files starting X sessions.
13587
13588 @item @code{minimum-vt} (default: 7)
13589 Minimum VT to use.
13590
13591 @item @code{auto-login-user} (default "")
13592 User to use for auto-login.
13593
13594 @item @code{auto-login-session} (default "")
13595 Desktop file to use for auto-login.
13596
13597 @item @code{relogin?} (default #f)
13598 Relogin after logout.
13599
13600 @end table
13601 @end deftp
13602
13603 @cindex login manager
13604 @cindex X11 login
13605 @deffn {Scheme Procedure} sddm-service config
13606 Return a service that spawns the SDDM graphical login manager for config of
13607 type @code{<sddm-configuration>}.
13608
13609 @example
13610 (sddm-service (sddm-configuration
13611 (auto-login-user "Alice")
13612 (auto-login-session "xfce.desktop")))
13613 @end example
13614 @end deffn
13615
13616 @cindex Xorg, configuration
13617 @deftp {Data Type} xorg-configuration
13618 This data type represents the configuration of the Xorg graphical display
13619 server. Note that there is not Xorg service; instead, the X server is started
13620 by a ``display manager'' such as GDM, SDDM, and SLiM. Thus, the configuration
13621 of these display managers aggregates an @code{xorg-configuration} record.
13622
13623 @table @asis
13624 @item @code{modules} (default: @code{%default-xorg-modules})
13625 This is a list of @dfn{module packages} loaded by the Xorg
13626 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
13627
13628 @item @code{fonts} (default: @code{%default-xorg-fonts})
13629 This is a list of font directories to add to the server's @dfn{font path}.
13630
13631 @item @code{drivers} (default: @code{'()})
13632 This must be either the empty list, in which case Xorg chooses a graphics
13633 driver automatically, or a list of driver names that will be tried in this
13634 order---e.g., @code{("modesetting" "vesa")}.
13635
13636 @item @code{resolutions} (default: @code{'()})
13637 When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
13638 resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
13639 768) (640 480))}.
13640
13641 @cindex keyboard layout, for Xorg
13642 @cindex keymap, for Xorg
13643 @item @code{keyboard-layout} (default: @code{#f})
13644 If this is @code{#f}, Xorg uses the default keyboard layout---usually US
13645 English (``qwerty'') for a 105-key PC keyboard.
13646
13647 Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
13648 layout in use when Xorg is running. @xref{Keyboard Layout}, for more
13649 information on how to specify the keyboard layout.
13650
13651 @item @code{extra-config} (default: @code{'()})
13652 This is a list of strings or objects appended to the configuration file. It
13653 is used to pass extra text to be added verbatim to the configuration file.
13654
13655 @item @code{server} (default: @code{xorg-server})
13656 This is the package providing the Xorg server.
13657
13658 @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
13659 This is the list of command-line arguments to pass to the X server. The
13660 default is @code{-nolisten tcp}.
13661 @end table
13662 @end deftp
13663
13664 @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
13665 [@var{login-manager-service-type}]
13666 Tell the log-in manager (of type @var{login-manager-service-type}) to use
13667 @var{config}, an <xorg-configuration> record.
13668
13669 Since the Xorg configuration is embedded in the log-in manager's
13670 configuration---e.g., @code{gdm-configuration}---this procedure provides a
13671 shorthand to set the Xorg configuration.
13672 @end deffn
13673
13674 @deffn {Scheme Procedure} xorg-start-command [@var{config}]
13675 Return a @code{startx} script in which the modules, fonts, etc. specified
13676 in @var{config}, are available. The result should be used in place of
13677 @code{startx}.
13678
13679 Usually the X server is started by a login manager.
13680 @end deffn
13681
13682
13683 @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
13684 Add @var{package}, a package for a screen locker or screen saver whose
13685 command is @var{program}, to the set of setuid programs and add a PAM entry
13686 for it. For example:
13687
13688 @lisp
13689 (screen-locker-service xlockmore "xlock")
13690 @end lisp
13691
13692 makes the good ol' XlockMore usable.
13693 @end deffn
13694
13695
13696 @node Printing Services
13697 @subsection Printing Services
13698
13699 @cindex printer support with CUPS
13700 The @code{(gnu services cups)} module provides a Guix service definition
13701 for the CUPS printing service. To add printer support to a Guix
13702 system, add a @code{cups-service} to the operating system definition:
13703
13704 @deffn {Scheme Variable} cups-service-type
13705 The service type for the CUPS print server. Its value should be a valid
13706 CUPS configuration (see below). To use the default settings, simply
13707 write:
13708 @example
13709 (service cups-service-type)
13710 @end example
13711 @end deffn
13712
13713 The CUPS configuration controls the basic things about your CUPS
13714 installation: what interfaces it listens on, what to do if a print job
13715 fails, how much logging to do, and so on. To actually add a printer,
13716 you have to visit the @url{http://localhost:631} URL, or use a tool such
13717 as GNOME's printer configuration services. By default, configuring a
13718 CUPS service will generate a self-signed certificate if needed, for
13719 secure connections to the print server.
13720
13721 Suppose you want to enable the Web interface of CUPS and also add
13722 support for Epson printers @i{via} the @code{escpr} package and for HP
13723 printers @i{via} the @code{hplip-minimal} package. You can do that directly,
13724 like this (you need to use the @code{(gnu packages cups)} module):
13725
13726 @example
13727 (service cups-service-type
13728 (cups-configuration
13729 (web-interface? #t)
13730 (extensions
13731 (list cups-filters escpr hplip-minimal))))
13732 @end example
13733
13734 Note: If you wish to use the Qt5 based GUI which comes with the hplip
13735 package then it is suggested that you install the @code{hplip} package,
13736 either in your OS configuration file or as your user.
13737
13738 The available configuration parameters follow. Each parameter
13739 definition is preceded by its type; for example, @samp{string-list foo}
13740 indicates that the @code{foo} parameter should be specified as a list of
13741 strings. There is also a way to specify the configuration as a string,
13742 if you have an old @code{cupsd.conf} file that you want to port over
13743 from some other system; see the end for more details.
13744
13745 @c The following documentation was initially generated by
13746 @c (generate-documentation) in (gnu services cups). Manually maintained
13747 @c documentation is better, so we shouldn't hesitate to edit below as
13748 @c needed. However if the change you want to make to this documentation
13749 @c can be done in an automated way, it's probably easier to change
13750 @c (generate-documentation) than to make it below and have to deal with
13751 @c the churn as CUPS updates.
13752
13753
13754 Available @code{cups-configuration} fields are:
13755
13756 @deftypevr {@code{cups-configuration} parameter} package cups
13757 The CUPS package.
13758 @end deftypevr
13759
13760 @deftypevr {@code{cups-configuration} parameter} package-list extensions
13761 Drivers and other extensions to the CUPS package.
13762 @end deftypevr
13763
13764 @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
13765 Configuration of where to write logs, what directories to use for print
13766 spools, and related privileged configuration parameters.
13767
13768 Available @code{files-configuration} fields are:
13769
13770 @deftypevr {@code{files-configuration} parameter} log-location access-log
13771 Defines the access log filename. Specifying a blank filename disables
13772 access log generation. The value @code{stderr} causes log entries to be
13773 sent to the standard error file when the scheduler is running in the
13774 foreground, or to the system log daemon when run in the background. The
13775 value @code{syslog} causes log entries to be sent to the system log
13776 daemon. The server name may be included in filenames using the string
13777 @code{%s}, as in @code{/var/log/cups/%s-access_log}.
13778
13779 Defaults to @samp{"/var/log/cups/access_log"}.
13780 @end deftypevr
13781
13782 @deftypevr {@code{files-configuration} parameter} file-name cache-dir
13783 Where CUPS should cache data.
13784
13785 Defaults to @samp{"/var/cache/cups"}.
13786 @end deftypevr
13787
13788 @deftypevr {@code{files-configuration} parameter} string config-file-perm
13789 Specifies the permissions for all configuration files that the scheduler
13790 writes.
13791
13792 Note that the permissions for the printers.conf file are currently
13793 masked to only allow access from the scheduler user (typically root).
13794 This is done because printer device URIs sometimes contain sensitive
13795 authentication information that should not be generally known on the
13796 system. There is no way to disable this security feature.
13797
13798 Defaults to @samp{"0640"}.
13799 @end deftypevr
13800
13801 @deftypevr {@code{files-configuration} parameter} log-location error-log
13802 Defines the error log filename. Specifying a blank filename disables
13803 access log generation. The value @code{stderr} causes log entries to be
13804 sent to the standard error file when the scheduler is running in the
13805 foreground, or to the system log daemon when run in the background. The
13806 value @code{syslog} causes log entries to be sent to the system log
13807 daemon. The server name may be included in filenames using the string
13808 @code{%s}, as in @code{/var/log/cups/%s-error_log}.
13809
13810 Defaults to @samp{"/var/log/cups/error_log"}.
13811 @end deftypevr
13812
13813 @deftypevr {@code{files-configuration} parameter} string fatal-errors
13814 Specifies which errors are fatal, causing the scheduler to exit. The
13815 kind strings are:
13816
13817 @table @code
13818 @item none
13819 No errors are fatal.
13820
13821 @item all
13822 All of the errors below are fatal.
13823
13824 @item browse
13825 Browsing initialization errors are fatal, for example failed connections
13826 to the DNS-SD daemon.
13827
13828 @item config
13829 Configuration file syntax errors are fatal.
13830
13831 @item listen
13832 Listen or Port errors are fatal, except for IPv6 failures on the
13833 loopback or @code{any} addresses.
13834
13835 @item log
13836 Log file creation or write errors are fatal.
13837
13838 @item permissions
13839 Bad startup file permissions are fatal, for example shared TLS
13840 certificate and key files with world-read permissions.
13841 @end table
13842
13843 Defaults to @samp{"all -browse"}.
13844 @end deftypevr
13845
13846 @deftypevr {@code{files-configuration} parameter} boolean file-device?
13847 Specifies whether the file pseudo-device can be used for new printer
13848 queues. The URI @uref{file:///dev/null} is always allowed.
13849
13850 Defaults to @samp{#f}.
13851 @end deftypevr
13852
13853 @deftypevr {@code{files-configuration} parameter} string group
13854 Specifies the group name or ID that will be used when executing external
13855 programs.
13856
13857 Defaults to @samp{"lp"}.
13858 @end deftypevr
13859
13860 @deftypevr {@code{files-configuration} parameter} string log-file-perm
13861 Specifies the permissions for all log files that the scheduler writes.
13862
13863 Defaults to @samp{"0644"}.
13864 @end deftypevr
13865
13866 @deftypevr {@code{files-configuration} parameter} log-location page-log
13867 Defines the page log filename. Specifying a blank filename disables
13868 access log generation. The value @code{stderr} causes log entries to be
13869 sent to the standard error file when the scheduler is running in the
13870 foreground, or to the system log daemon when run in the background. The
13871 value @code{syslog} causes log entries to be sent to the system log
13872 daemon. The server name may be included in filenames using the string
13873 @code{%s}, as in @code{/var/log/cups/%s-page_log}.
13874
13875 Defaults to @samp{"/var/log/cups/page_log"}.
13876 @end deftypevr
13877
13878 @deftypevr {@code{files-configuration} parameter} string remote-root
13879 Specifies the username that is associated with unauthenticated accesses
13880 by clients claiming to be the root user. The default is @code{remroot}.
13881
13882 Defaults to @samp{"remroot"}.
13883 @end deftypevr
13884
13885 @deftypevr {@code{files-configuration} parameter} file-name request-root
13886 Specifies the directory that contains print jobs and other HTTP request
13887 data.
13888
13889 Defaults to @samp{"/var/spool/cups"}.
13890 @end deftypevr
13891
13892 @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
13893 Specifies the level of security sandboxing that is applied to print
13894 filters, backends, and other child processes of the scheduler; either
13895 @code{relaxed} or @code{strict}. This directive is currently only
13896 used/supported on macOS.
13897
13898 Defaults to @samp{strict}.
13899 @end deftypevr
13900
13901 @deftypevr {@code{files-configuration} parameter} file-name server-keychain
13902 Specifies the location of TLS certificates and private keys. CUPS will
13903 look for public and private keys in this directory: a @code{.crt} files
13904 for PEM-encoded certificates and corresponding @code{.key} files for
13905 PEM-encoded private keys.
13906
13907 Defaults to @samp{"/etc/cups/ssl"}.
13908 @end deftypevr
13909
13910 @deftypevr {@code{files-configuration} parameter} file-name server-root
13911 Specifies the directory containing the server configuration files.
13912
13913 Defaults to @samp{"/etc/cups"}.
13914 @end deftypevr
13915
13916 @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
13917 Specifies whether the scheduler calls fsync(2) after writing
13918 configuration or state files.
13919
13920 Defaults to @samp{#f}.
13921 @end deftypevr
13922
13923 @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
13924 Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
13925 @end deftypevr
13926
13927 @deftypevr {@code{files-configuration} parameter} file-name temp-dir
13928 Specifies the directory where temporary files are stored.
13929
13930 Defaults to @samp{"/var/spool/cups/tmp"}.
13931 @end deftypevr
13932
13933 @deftypevr {@code{files-configuration} parameter} string user
13934 Specifies the user name or ID that is used when running external
13935 programs.
13936
13937 Defaults to @samp{"lp"}.
13938 @end deftypevr
13939 @end deftypevr
13940
13941 @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
13942 Specifies the logging level for the AccessLog file. The @code{config}
13943 level logs when printers and classes are added, deleted, or modified and
13944 when configuration files are accessed or updated. The @code{actions}
13945 level logs when print jobs are submitted, held, released, modified, or
13946 canceled, and any of the conditions for @code{config}. The @code{all}
13947 level logs all requests.
13948
13949 Defaults to @samp{actions}.
13950 @end deftypevr
13951
13952 @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
13953 Specifies whether to purge job history data automatically when it is no
13954 longer required for quotas.
13955
13956 Defaults to @samp{#f}.
13957 @end deftypevr
13958
13959 @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
13960 Specifies which protocols to use for local printer sharing.
13961
13962 Defaults to @samp{dnssd}.
13963 @end deftypevr
13964
13965 @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
13966 Specifies whether the CUPS web interface is advertised.
13967
13968 Defaults to @samp{#f}.
13969 @end deftypevr
13970
13971 @deftypevr {@code{cups-configuration} parameter} boolean browsing?
13972 Specifies whether shared printers are advertised.
13973
13974 Defaults to @samp{#f}.
13975 @end deftypevr
13976
13977 @deftypevr {@code{cups-configuration} parameter} string classification
13978 Specifies the security classification of the server. Any valid banner
13979 name can be used, including "classified", "confidential", "secret",
13980 "topsecret", and "unclassified", or the banner can be omitted to disable
13981 secure printing functions.
13982
13983 Defaults to @samp{""}.
13984 @end deftypevr
13985
13986 @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
13987 Specifies whether users may override the classification (cover page) of
13988 individual print jobs using the @code{job-sheets} option.
13989
13990 Defaults to @samp{#f}.
13991 @end deftypevr
13992
13993 @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
13994 Specifies the default type of authentication to use.
13995
13996 Defaults to @samp{Basic}.
13997 @end deftypevr
13998
13999 @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
14000 Specifies whether encryption will be used for authenticated requests.
14001
14002 Defaults to @samp{Required}.
14003 @end deftypevr
14004
14005 @deftypevr {@code{cups-configuration} parameter} string default-language
14006 Specifies the default language to use for text and web content.
14007
14008 Defaults to @samp{"en"}.
14009 @end deftypevr
14010
14011 @deftypevr {@code{cups-configuration} parameter} string default-paper-size
14012 Specifies the default paper size for new print queues. @samp{"Auto"}
14013 uses a locale-specific default, while @samp{"None"} specifies there is
14014 no default paper size. Specific size names are typically
14015 @samp{"Letter"} or @samp{"A4"}.
14016
14017 Defaults to @samp{"Auto"}.
14018 @end deftypevr
14019
14020 @deftypevr {@code{cups-configuration} parameter} string default-policy
14021 Specifies the default access policy to use.
14022
14023 Defaults to @samp{"default"}.
14024 @end deftypevr
14025
14026 @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
14027 Specifies whether local printers are shared by default.
14028
14029 Defaults to @samp{#t}.
14030 @end deftypevr
14031
14032 @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
14033 Specifies the delay for updating of configuration and state files, in
14034 seconds. A value of 0 causes the update to happen as soon as possible,
14035 typically within a few milliseconds.
14036
14037 Defaults to @samp{30}.
14038 @end deftypevr
14039
14040 @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
14041 Specifies what to do when an error occurs. Possible values are
14042 @code{abort-job}, which will discard the failed print job;
14043 @code{retry-job}, which will retry the job at a later time;
14044 @code{retry-this-job}, which retries the failed job immediately; and
14045 @code{stop-printer}, which stops the printer.
14046
14047 Defaults to @samp{stop-printer}.
14048 @end deftypevr
14049
14050 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
14051 Specifies the maximum cost of filters that are run concurrently, which
14052 can be used to minimize disk, memory, and CPU resource problems. A
14053 limit of 0 disables filter limiting. An average print to a
14054 non-PostScript printer needs a filter limit of about 200. A PostScript
14055 printer needs about half that (100). Setting the limit below these
14056 thresholds will effectively limit the scheduler to printing a single job
14057 at any time.
14058
14059 Defaults to @samp{0}.
14060 @end deftypevr
14061
14062 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
14063 Specifies the scheduling priority of filters that are run to print a
14064 job. The nice value ranges from 0, the highest priority, to 19, the
14065 lowest priority.
14066
14067 Defaults to @samp{0}.
14068 @end deftypevr
14069
14070 @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
14071 Specifies whether to do reverse lookups on connecting clients. The
14072 @code{double} setting causes @code{cupsd} to verify that the hostname
14073 resolved from the address matches one of the addresses returned for that
14074 hostname. Double lookups also prevent clients with unregistered
14075 addresses from connecting to your server. Only set this option to
14076 @code{#t} or @code{double} if absolutely required.
14077
14078 Defaults to @samp{#f}.
14079 @end deftypevr
14080
14081 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
14082 Specifies the number of seconds to wait before killing the filters and
14083 backend associated with a canceled or held job.
14084
14085 Defaults to @samp{30}.
14086 @end deftypevr
14087
14088 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
14089 Specifies the interval between retries of jobs in seconds. This is
14090 typically used for fax queues but can also be used with normal print
14091 queues whose error policy is @code{retry-job} or
14092 @code{retry-current-job}.
14093
14094 Defaults to @samp{30}.
14095 @end deftypevr
14096
14097 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
14098 Specifies the number of retries that are done for jobs. This is
14099 typically used for fax queues but can also be used with normal print
14100 queues whose error policy is @code{retry-job} or
14101 @code{retry-current-job}.
14102
14103 Defaults to @samp{5}.
14104 @end deftypevr
14105
14106 @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
14107 Specifies whether to support HTTP keep-alive connections.
14108
14109 Defaults to @samp{#t}.
14110 @end deftypevr
14111
14112 @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
14113 Specifies how long an idle client connection remains open, in seconds.
14114
14115 Defaults to @samp{30}.
14116 @end deftypevr
14117
14118 @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
14119 Specifies the maximum size of print files, IPP requests, and HTML form
14120 data. A limit of 0 disables the limit check.
14121
14122 Defaults to @samp{0}.
14123 @end deftypevr
14124
14125 @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
14126 Listens on the specified interfaces for connections. Valid values are
14127 of the form @var{address}:@var{port}, where @var{address} is either an
14128 IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
14129 indicate all addresses. Values can also be file names of local UNIX
14130 domain sockets. The Listen directive is similar to the Port directive
14131 but allows you to restrict access to specific interfaces or networks.
14132 @end deftypevr
14133
14134 @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
14135 Specifies the number of pending connections that will be allowed. This
14136 normally only affects very busy servers that have reached the MaxClients
14137 limit, but can also be triggered by large numbers of simultaneous
14138 connections. When the limit is reached, the operating system will
14139 refuse additional connections until the scheduler can accept the pending
14140 ones.
14141
14142 Defaults to @samp{128}.
14143 @end deftypevr
14144
14145 @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
14146 Specifies a set of additional access controls.
14147
14148 Available @code{location-access-controls} fields are:
14149
14150 @deftypevr {@code{location-access-controls} parameter} file-name path
14151 Specifies the URI path to which the access control applies.
14152 @end deftypevr
14153
14154 @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
14155 Access controls for all access to this path, in the same format as the
14156 @code{access-controls} of @code{operation-access-control}.
14157
14158 Defaults to @samp{()}.
14159 @end deftypevr
14160
14161 @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
14162 Access controls for method-specific access to this path.
14163
14164 Defaults to @samp{()}.
14165
14166 Available @code{method-access-controls} fields are:
14167
14168 @deftypevr {@code{method-access-controls} parameter} boolean reverse?
14169 If @code{#t}, apply access controls to all methods except the listed
14170 methods. Otherwise apply to only the listed methods.
14171
14172 Defaults to @samp{#f}.
14173 @end deftypevr
14174
14175 @deftypevr {@code{method-access-controls} parameter} method-list methods
14176 Methods to which this access control applies.
14177
14178 Defaults to @samp{()}.
14179 @end deftypevr
14180
14181 @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
14182 Access control directives, as a list of strings. Each string should be
14183 one directive, such as "Order allow,deny".
14184
14185 Defaults to @samp{()}.
14186 @end deftypevr
14187 @end deftypevr
14188 @end deftypevr
14189
14190 @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
14191 Specifies the number of debugging messages that are retained for logging
14192 if an error occurs in a print job. Debug messages are logged regardless
14193 of the LogLevel setting.
14194
14195 Defaults to @samp{100}.
14196 @end deftypevr
14197
14198 @deftypevr {@code{cups-configuration} parameter} log-level log-level
14199 Specifies the level of logging for the ErrorLog file. The value
14200 @code{none} stops all logging while @code{debug2} logs everything.
14201
14202 Defaults to @samp{info}.
14203 @end deftypevr
14204
14205 @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
14206 Specifies the format of the date and time in the log files. The value
14207 @code{standard} logs whole seconds while @code{usecs} logs microseconds.
14208
14209 Defaults to @samp{standard}.
14210 @end deftypevr
14211
14212 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
14213 Specifies the maximum number of simultaneous clients that are allowed by
14214 the scheduler.
14215
14216 Defaults to @samp{100}.
14217 @end deftypevr
14218
14219 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
14220 Specifies the maximum number of simultaneous clients that are allowed
14221 from a single address.
14222
14223 Defaults to @samp{100}.
14224 @end deftypevr
14225
14226 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
14227 Specifies the maximum number of copies that a user can print of each
14228 job.
14229
14230 Defaults to @samp{9999}.
14231 @end deftypevr
14232
14233 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
14234 Specifies the maximum time a job may remain in the @code{indefinite}
14235 hold state before it is canceled. A value of 0 disables cancellation of
14236 held jobs.
14237
14238 Defaults to @samp{0}.
14239 @end deftypevr
14240
14241 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
14242 Specifies the maximum number of simultaneous jobs that are allowed. Set
14243 to 0 to allow an unlimited number of jobs.
14244
14245 Defaults to @samp{500}.
14246 @end deftypevr
14247
14248 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
14249 Specifies the maximum number of simultaneous jobs that are allowed per
14250 printer. A value of 0 allows up to MaxJobs jobs per printer.
14251
14252 Defaults to @samp{0}.
14253 @end deftypevr
14254
14255 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
14256 Specifies the maximum number of simultaneous jobs that are allowed per
14257 user. A value of 0 allows up to MaxJobs jobs per user.
14258
14259 Defaults to @samp{0}.
14260 @end deftypevr
14261
14262 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
14263 Specifies the maximum time a job may take to print before it is
14264 canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
14265
14266 Defaults to @samp{10800}.
14267 @end deftypevr
14268
14269 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
14270 Specifies the maximum size of the log files before they are rotated, in
14271 bytes. The value 0 disables log rotation.
14272
14273 Defaults to @samp{1048576}.
14274 @end deftypevr
14275
14276 @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
14277 Specifies the maximum amount of time to allow between files in a
14278 multiple file print job, in seconds.
14279
14280 Defaults to @samp{300}.
14281 @end deftypevr
14282
14283 @deftypevr {@code{cups-configuration} parameter} string page-log-format
14284 Specifies the format of PageLog lines. Sequences beginning with percent
14285 (@samp{%}) characters are replaced with the corresponding information,
14286 while all other characters are copied literally. The following percent
14287 sequences are recognized:
14288
14289 @table @samp
14290 @item %%
14291 insert a single percent character
14292
14293 @item %@{name@}
14294 insert the value of the specified IPP attribute
14295
14296 @item %C
14297 insert the number of copies for the current page
14298
14299 @item %P
14300 insert the current page number
14301
14302 @item %T
14303 insert the current date and time in common log format
14304
14305 @item %j
14306 insert the job ID
14307
14308 @item %p
14309 insert the printer name
14310
14311 @item %u
14312 insert the username
14313 @end table
14314
14315 A value of the empty string disables page logging. The string @code{%p
14316 %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
14317 %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
14318 standard items.
14319
14320 Defaults to @samp{""}.
14321 @end deftypevr
14322
14323 @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
14324 Passes the specified environment variable(s) to child processes; a list
14325 of strings.
14326
14327 Defaults to @samp{()}.
14328 @end deftypevr
14329
14330 @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
14331 Specifies named access control policies.
14332
14333 Available @code{policy-configuration} fields are:
14334
14335 @deftypevr {@code{policy-configuration} parameter} string name
14336 Name of the policy.
14337 @end deftypevr
14338
14339 @deftypevr {@code{policy-configuration} parameter} string job-private-access
14340 Specifies an access list for a job's private values. @code{@@ACL} maps
14341 to the printer's requesting-user-name-allowed or
14342 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
14343 owner. @code{@@SYSTEM} maps to the groups listed for the
14344 @code{system-group} field of the @code{files-config} configuration,
14345 which is reified into the @code{cups-files.conf(5)} file. Other
14346 possible elements of the access list include specific user names, and
14347 @code{@@@var{group}} to indicate members of a specific group. The
14348 access list may also be simply @code{all} or @code{default}.
14349
14350 Defaults to @samp{"@@OWNER @@SYSTEM"}.
14351 @end deftypevr
14352
14353 @deftypevr {@code{policy-configuration} parameter} string job-private-values
14354 Specifies the list of job values to make private, or @code{all},
14355 @code{default}, or @code{none}.
14356
14357 Defaults to @samp{"job-name job-originating-host-name
14358 job-originating-user-name phone"}.
14359 @end deftypevr
14360
14361 @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
14362 Specifies an access list for a subscription's private values.
14363 @code{@@ACL} maps to the printer's requesting-user-name-allowed or
14364 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
14365 owner. @code{@@SYSTEM} maps to the groups listed for the
14366 @code{system-group} field of the @code{files-config} configuration,
14367 which is reified into the @code{cups-files.conf(5)} file. Other
14368 possible elements of the access list include specific user names, and
14369 @code{@@@var{group}} to indicate members of a specific group. The
14370 access list may also be simply @code{all} or @code{default}.
14371
14372 Defaults to @samp{"@@OWNER @@SYSTEM"}.
14373 @end deftypevr
14374
14375 @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
14376 Specifies the list of job values to make private, or @code{all},
14377 @code{default}, or @code{none}.
14378
14379 Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
14380 notify-subscriber-user-name notify-user-data"}.
14381 @end deftypevr
14382
14383 @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
14384 Access control by IPP operation.
14385
14386 Defaults to @samp{()}.
14387 @end deftypevr
14388 @end deftypevr
14389
14390 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
14391 Specifies whether job files (documents) are preserved after a job is
14392 printed. If a numeric value is specified, job files are preserved for
14393 the indicated number of seconds after printing. Otherwise a boolean
14394 value applies indefinitely.
14395
14396 Defaults to @samp{86400}.
14397 @end deftypevr
14398
14399 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
14400 Specifies whether the job history is preserved after a job is printed.
14401 If a numeric value is specified, the job history is preserved for the
14402 indicated number of seconds after printing. If @code{#t}, the job
14403 history is preserved until the MaxJobs limit is reached.
14404
14405 Defaults to @samp{#t}.
14406 @end deftypevr
14407
14408 @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
14409 Specifies the amount of time to wait for job completion before
14410 restarting the scheduler.
14411
14412 Defaults to @samp{30}.
14413 @end deftypevr
14414
14415 @deftypevr {@code{cups-configuration} parameter} string rip-cache
14416 Specifies the maximum amount of memory to use when converting documents
14417 into bitmaps for a printer.
14418
14419 Defaults to @samp{"128m"}.
14420 @end deftypevr
14421
14422 @deftypevr {@code{cups-configuration} parameter} string server-admin
14423 Specifies the email address of the server administrator.
14424
14425 Defaults to @samp{"root@@localhost.localdomain"}.
14426 @end deftypevr
14427
14428 @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
14429 The ServerAlias directive is used for HTTP Host header validation when
14430 clients connect to the scheduler from external interfaces. Using the
14431 special name @code{*} can expose your system to known browser-based DNS
14432 rebinding attacks, even when accessing sites through a firewall. If the
14433 auto-discovery of alternate names does not work, we recommend listing
14434 each alternate name with a ServerAlias directive instead of using
14435 @code{*}.
14436
14437 Defaults to @samp{*}.
14438 @end deftypevr
14439
14440 @deftypevr {@code{cups-configuration} parameter} string server-name
14441 Specifies the fully-qualified host name of the server.
14442
14443 Defaults to @samp{"localhost"}.
14444 @end deftypevr
14445
14446 @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
14447 Specifies what information is included in the Server header of HTTP
14448 responses. @code{None} disables the Server header. @code{ProductOnly}
14449 reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
14450 reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
14451 @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
14452 the output of the @code{uname} command. @code{Full} reports @code{CUPS
14453 2.0.0 (@var{uname}) IPP/2.0}.
14454
14455 Defaults to @samp{Minimal}.
14456 @end deftypevr
14457
14458 @deftypevr {@code{cups-configuration} parameter} string set-env
14459 Set the specified environment variable to be passed to child processes.
14460
14461 Defaults to @samp{"variable value"}.
14462 @end deftypevr
14463
14464 @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
14465 Listens on the specified interfaces for encrypted connections. Valid
14466 values are of the form @var{address}:@var{port}, where @var{address} is
14467 either an IPv6 address enclosed in brackets, an IPv4 address, or
14468 @code{*} to indicate all addresses.
14469
14470 Defaults to @samp{()}.
14471 @end deftypevr
14472
14473 @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
14474 Sets encryption options. By default, CUPS only supports encryption
14475 using TLS v1.0 or higher using known secure cipher suites. The
14476 @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
14477 required for some older clients that do not implement newer ones. The
14478 @code{AllowSSL3} option enables SSL v3.0, which is required for some
14479 older clients that do not support TLS v1.0.
14480
14481 Defaults to @samp{()}.
14482 @end deftypevr
14483
14484 @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
14485 Specifies whether the scheduler requires clients to strictly adhere to
14486 the IPP specifications.
14487
14488 Defaults to @samp{#f}.
14489 @end deftypevr
14490
14491 @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
14492 Specifies the HTTP request timeout, in seconds.
14493
14494 Defaults to @samp{300}.
14495
14496 @end deftypevr
14497
14498 @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
14499 Specifies whether the web interface is enabled.
14500
14501 Defaults to @samp{#f}.
14502 @end deftypevr
14503
14504 At this point you're probably thinking ``oh dear, Guix manual, I like
14505 you but you can stop already with the configuration options''. Indeed.
14506 However, one more point: it could be that you have an existing
14507 @code{cupsd.conf} that you want to use. In that case, you can pass an
14508 @code{opaque-cups-configuration} as the configuration of a
14509 @code{cups-service-type}.
14510
14511 Available @code{opaque-cups-configuration} fields are:
14512
14513 @deftypevr {@code{opaque-cups-configuration} parameter} package cups
14514 The CUPS package.
14515 @end deftypevr
14516
14517 @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
14518 The contents of the @code{cupsd.conf}, as a string.
14519 @end deftypevr
14520
14521 @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
14522 The contents of the @code{cups-files.conf} file, as a string.
14523 @end deftypevr
14524
14525 For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
14526 strings of the same name, you could instantiate a CUPS service like
14527 this:
14528
14529 @example
14530 (service cups-service-type
14531 (opaque-cups-configuration
14532 (cupsd.conf cupsd.conf)
14533 (cups-files.conf cups-files.conf)))
14534 @end example
14535
14536
14537 @node Desktop Services
14538 @subsection Desktop Services
14539
14540 The @code{(gnu services desktop)} module provides services that are
14541 usually useful in the context of a ``desktop'' setup---that is, on a
14542 machine running a graphical display server, possibly with graphical user
14543 interfaces, etc. It also defines services that provide specific desktop
14544 environments like GNOME, Xfce or MATE.
14545
14546 To simplify things, the module defines a variable containing the set of
14547 services that users typically expect on a machine with a graphical
14548 environment and networking:
14549
14550 @defvr {Scheme Variable} %desktop-services
14551 This is a list of services that builds upon @var{%base-services} and
14552 adds or adjusts services for a typical ``desktop'' setup.
14553
14554 In particular, it adds a graphical login manager (@pxref{X Window,
14555 @code{gdm-service-type}}), screen lockers, a network management tool
14556 (@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
14557 management services, the @code{elogind} login and seat manager, the
14558 Polkit privilege service, the GeoClue location service, the
14559 AccountsService daemon that allows authorized users change system
14560 passwords, an NTP client (@pxref{Networking Services}), the Avahi
14561 daemon, and has the name service switch service configured to be able to
14562 use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
14563 @end defvr
14564
14565 The @var{%desktop-services} variable can be used as the @code{services}
14566 field of an @code{operating-system} declaration (@pxref{operating-system
14567 Reference, @code{services}}).
14568
14569 Additionally, the @code{gnome-desktop-service-type},
14570 @code{xfce-desktop-service}, @code{mate-desktop-service-type} and
14571 @code{enlightenment-desktop-service-type} procedures can add GNOME, Xfce, MATE
14572 and/or Enlightenment to a system. To ``add GNOME'' means that system-level
14573 services like the backlight adjustment helpers and the power management
14574 utilities are added to the system, extending @code{polkit} and @code{dbus}
14575 appropriately, allowing GNOME to operate with elevated privileges on a
14576 limited number of special-purpose system interfaces. Additionally,
14577 adding a service made by @code{gnome-desktop-service-type} adds the GNOME
14578 metapackage to the system profile. Likewise, adding the Xfce service
14579 not only adds the @code{xfce} metapackage to the system profile, but it
14580 also gives the Thunar file manager the ability to open a ``root-mode''
14581 file management window, if the user authenticates using the
14582 administrator's password via the standard polkit graphical interface.
14583 To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
14584 appropriately, allowing MATE to operate with elevated privileges on a
14585 limited number of special-purpose system interfaces. Additionally,
14586 adding a service of type @code{mate-desktop-service-type} adds the MATE
14587 metapackage to the system profile. ``Adding Enlightenment'' means that
14588 @code{dbus} is extended appropriately, and several of Enlightenment's binaries
14589 are set as setuid, allowing Enlightenment's screen locker and other
14590 functionality to work as expetected.
14591
14592 The desktop environments in Guix use the Xorg display server by
14593 default. If you'd like to use the newer display server protocol
14594 called Wayland, you need to use the @code{sddm-service} instead of
14595 GDM as the graphical login manager. You should then
14596 select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
14597 also try starting GNOME on Wayland manually from a TTY with the
14598 command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
14599 gnome-session``. Currently only GNOME has support for Wayland.
14600
14601 @defvr {Scheme Variable} gnome-desktop-service-type
14602 This is the type of the service that adds the @uref{https://www.gnome.org,
14603 GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
14604 object (see below.)
14605
14606 This service adds the @code{gnome} package to the system profile, and extends
14607 polkit with the actions from @code{gnome-settings-daemon}.
14608 @end defvr
14609
14610 @deftp {Data Type} gnome-desktop-configuration
14611 Configuration record for the GNOME desktop environment.
14612
14613 @table @asis
14614 @item @code{gnome} (default @code{gnome})
14615 The GNOME package to use.
14616 @end table
14617 @end deftp
14618
14619 @defvr {Scheme Variable} xfce-desktop-service-type
14620 This is the type of a service to run the @uref{Xfce, https://xfce.org/}
14621 desktop environment. Its value is an @code{xfce-desktop-configuration} object
14622 (see below.)
14623
14624 This service that adds the @code{xfce} package to the system profile, and
14625 extends polkit with the ability for @code{thunar} to manipulate the file
14626 system as root from within a user session, after the user has authenticated
14627 with the administrator's password.
14628 @end defvr
14629
14630 @deftp {Data Type} xfce-desktop-configuration
14631 Configuration record for the Xfce desktop environment.
14632
14633 @table @asis
14634 @item @code{xfce} (default @code{xfce})
14635 The Xfce package to use.
14636 @end table
14637 @end deftp
14638
14639 @deffn {Scheme Variable} mate-desktop-service-type
14640 This is the type of the service that runs the @uref{https://mate-desktop.org/,
14641 MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
14642 object (see below.)
14643
14644 This service adds the @code{mate} package to the system
14645 profile, and extends polkit with the actions from
14646 @code{mate-settings-daemon}.
14647 @end deffn
14648
14649 @deftp {Data Type} mate-desktop-configuration
14650 Configuration record for the MATE desktop environment.
14651
14652 @table @asis
14653 @item @code{mate} (default @code{mate})
14654 The MATE package to use.
14655 @end table
14656 @end deftp
14657
14658 @deffn {Scheme Variable} enlightenment-desktop-service-type
14659 Return a service that adds the @code{enlightenment} package to the system
14660 profile, and extends dbus with actions from @code{efl}.
14661 @end deffn
14662
14663 @deftp {Data Type} enlightenment-desktop-service-configuration
14664 @table @asis
14665 @item @code{enlightenment} (default @code{enlightenment})
14666 The enlightenment package to use.
14667 @end table
14668 @end deftp
14669
14670 Because the GNOME, Xfce and MATE desktop services pull in so many packages,
14671 the default @code{%desktop-services} variable doesn't include any of
14672 them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
14673 @code{%desktop-services} in the @code{services} field of your
14674 @code{operating-system}:
14675
14676 @example
14677 (use-modules (gnu))
14678 (use-service-modules desktop)
14679 (operating-system
14680 ...
14681 ;; cons* adds items to the list given as its last argument.
14682 (services (cons* (service gnome-desktop-service-type)
14683 (service xfce-desktop-service)
14684 %desktop-services))
14685 ...)
14686 @end example
14687
14688 These desktop environments will then be available as options in the
14689 graphical login window.
14690
14691 The actual service definitions included in @code{%desktop-services} and
14692 provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
14693 are described below.
14694
14695 @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
14696 Return a service that runs the ``system bus'', using @var{dbus}, with
14697 support for @var{services}.
14698
14699 @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
14700 facility. Its system bus is used to allow system services to communicate
14701 and to be notified of system-wide events.
14702
14703 @var{services} must be a list of packages that provide an
14704 @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
14705 and policy files. For example, to allow avahi-daemon to use the system bus,
14706 @var{services} must be equal to @code{(list avahi)}.
14707 @end deffn
14708
14709 @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
14710 Return a service that runs the @code{elogind} login and
14711 seat management daemon. @uref{https://github.com/elogind/elogind,
14712 Elogind} exposes a D-Bus interface that can be used to know which users
14713 are logged in, know what kind of sessions they have open, suspend the
14714 system, inhibit system suspend, reboot the system, and other tasks.
14715
14716 Elogind handles most system-level power events for a computer, for
14717 example suspending the system when a lid is closed, or shutting it down
14718 when the power button is pressed.
14719
14720 The @var{config} keyword argument specifies the configuration for
14721 elogind, and should be the result of an @code{(elogind-configuration
14722 (@var{parameter} @var{value})...)} invocation. Available parameters and
14723 their default values are:
14724
14725 @table @code
14726 @item kill-user-processes?
14727 @code{#f}
14728 @item kill-only-users
14729 @code{()}
14730 @item kill-exclude-users
14731 @code{("root")}
14732 @item inhibit-delay-max-seconds
14733 @code{5}
14734 @item handle-power-key
14735 @code{poweroff}
14736 @item handle-suspend-key
14737 @code{suspend}
14738 @item handle-hibernate-key
14739 @code{hibernate}
14740 @item handle-lid-switch
14741 @code{suspend}
14742 @item handle-lid-switch-docked
14743 @code{ignore}
14744 @item power-key-ignore-inhibited?
14745 @code{#f}
14746 @item suspend-key-ignore-inhibited?
14747 @code{#f}
14748 @item hibernate-key-ignore-inhibited?
14749 @code{#f}
14750 @item lid-switch-ignore-inhibited?
14751 @code{#t}
14752 @item holdoff-timeout-seconds
14753 @code{30}
14754 @item idle-action
14755 @code{ignore}
14756 @item idle-action-seconds
14757 @code{(* 30 60)}
14758 @item runtime-directory-size-percent
14759 @code{10}
14760 @item runtime-directory-size
14761 @code{#f}
14762 @item remove-ipc?
14763 @code{#t}
14764 @item suspend-state
14765 @code{("mem" "standby" "freeze")}
14766 @item suspend-mode
14767 @code{()}
14768 @item hibernate-state
14769 @code{("disk")}
14770 @item hibernate-mode
14771 @code{("platform" "shutdown")}
14772 @item hybrid-sleep-state
14773 @code{("disk")}
14774 @item hybrid-sleep-mode
14775 @code{("suspend" "platform" "shutdown")}
14776 @end table
14777 @end deffn
14778
14779 @deffn {Scheme Procedure} accountsservice-service @
14780 [#:accountsservice @var{accountsservice}]
14781 Return a service that runs AccountsService, a system service that can
14782 list available accounts, change their passwords, and so on.
14783 AccountsService integrates with PolicyKit to enable unprivileged users
14784 to acquire the capability to modify their system configuration.
14785 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
14786 accountsservice web site} for more information.
14787
14788 The @var{accountsservice} keyword argument is the @code{accountsservice}
14789 package to expose as a service.
14790 @end deffn
14791
14792 @deffn {Scheme Procedure} polkit-service @
14793 [#:polkit @var{polkit}]
14794 Return a service that runs the
14795 @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
14796 management service}, which allows system administrators to grant access to
14797 privileged operations in a structured way. By querying the Polkit service, a
14798 privileged system component can know when it should grant additional
14799 capabilities to ordinary users. For example, an ordinary user can be granted
14800 the capability to suspend the system if the user is logged in locally.
14801 @end deffn
14802
14803 @defvr {Scheme Variable} upower-service-type
14804 Service that runs @uref{http://upower.freedesktop.org/, @command{upowerd}}, a
14805 system-wide monitor for power consumption and battery levels, with the given
14806 configuration settings.
14807
14808 It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
14809 notably used by GNOME.
14810 @end defvr
14811
14812 @deftp {Data Type} upower-configuration
14813 Data type representation the configuration for UPower.
14814
14815 @table @asis
14816
14817 @item @code{upower} (default: @var{upower})
14818 Package to use for @code{upower}.
14819
14820 @item @code{watts-up-pro?} (default: @code{#f})
14821 Enable the Watts Up Pro device.
14822
14823 @item @code{poll-batteries?} (default: @code{#t})
14824 Enable polling the kernel for battery level changes.
14825
14826 @item @code{ignore-lid?} (default: @code{#f})
14827 Ignore the lid state, this can be useful if it's incorrect on a device.
14828
14829 @item @code{use-percentage-for-policy?} (default: @code{#f})
14830 Whether battery percentage based policy should be used. The default is to use
14831 the time left, change to @code{#t} to use the percentage.
14832
14833 @item @code{percentage-low} (default: @code{10})
14834 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
14835 at which the battery is considered low.
14836
14837 @item @code{percentage-critical} (default: @code{3})
14838 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
14839 at which the battery is considered critical.
14840
14841 @item @code{percentage-action} (default: @code{2})
14842 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
14843 at which action will be taken.
14844
14845 @item @code{time-low} (default: @code{1200})
14846 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
14847 seconds at which the battery is considered low.
14848
14849 @item @code{time-critical} (default: @code{300})
14850 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
14851 seconds at which the battery is considered critical.
14852
14853 @item @code{time-action} (default: @code{120})
14854 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
14855 seconds at which action will be taken.
14856
14857 @item @code{critical-power-action} (default: @code{'hybrid-sleep})
14858 The action taken when @code{percentage-action} or @code{time-action} is
14859 reached (depending on the configuration of @code{use-percentage-for-policy?}).
14860
14861 Possible values are:
14862
14863 @itemize @bullet
14864 @item
14865 @code{'power-off}
14866
14867 @item
14868 @code{'hibernate}
14869
14870 @item
14871 @code{'hybrid-sleep}.
14872 @end itemize
14873
14874 @end table
14875 @end deftp
14876
14877 @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
14878 Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
14879 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
14880 notifications and ways to mount/unmount disks. Programs that talk to UDisks
14881 include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
14882 @end deffn
14883
14884 @deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
14885 Return a service that runs @command{colord}, a system service with a D-Bus
14886 interface to manage the color profiles of input and output devices such as
14887 screens and scanners. It is notably used by the GNOME Color Manager graphical
14888 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
14889 site} for more information.
14890 @end deffn
14891
14892 @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
14893 Return a configuration allowing an application to access GeoClue
14894 location data. @var{name} is the Desktop ID of the application, without
14895 the @code{.desktop} part. If @var{allowed?} is true, the application
14896 will have access to location information by default. The boolean
14897 @var{system?} value indicates whether an application is a system component
14898 or not. Finally @var{users} is a list of UIDs of all users for which
14899 this application is allowed location info access. An empty users list
14900 means that all users are allowed.
14901 @end deffn
14902
14903 @defvr {Scheme Variable} %standard-geoclue-applications
14904 The standard list of well-known GeoClue application configurations,
14905 granting authority to the GNOME date-and-time utility to ask for the
14906 current location in order to set the time zone, and allowing the
14907 IceCat and Epiphany web browsers to request location information.
14908 IceCat and Epiphany both query the user before allowing a web page to
14909 know the user's location.
14910 @end defvr
14911
14912 @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
14913 [#:whitelist '()] @
14914 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
14915 [#:submit-data? #f]
14916 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
14917 [#:submission-nick "geoclue"] @
14918 [#:applications %standard-geoclue-applications]
14919 Return a service that runs the GeoClue location service. This service
14920 provides a D-Bus interface to allow applications to request access to a
14921 user's physical location, and optionally to add information to online
14922 location databases. See
14923 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
14924 web site} for more information.
14925 @end deffn
14926
14927 @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
14928 [@w{#:auto-enable? #f}]
14929 Return a service that runs the @command{bluetoothd} daemon, which
14930 manages all the Bluetooth devices and provides a number of D-Bus
14931 interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
14932 powered automatically at boot, which can be useful when using a
14933 bluetooth keyboard or mouse.
14934
14935 Users need to be in the @code{lp} group to access the D-Bus service.
14936 @end deffn
14937
14938 @node Sound Services
14939 @subsection Sound Services
14940
14941 @cindex sound support
14942 @cindex ALSA
14943 @cindex PulseAudio, sound support
14944
14945 The @code{(gnu services sound)} module provides a service to configure the
14946 Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
14947 preferred ALSA output driver.
14948
14949 @deffn {Scheme Variable} alsa-service-type
14950 This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
14951 Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
14952 configuration file. The value for this type is a @command{alsa-configuration}
14953 record as in this example:
14954
14955 @example
14956 (service alsa-service-type)
14957 @end example
14958
14959 See below for details about @code{alsa-configuration}.
14960 @end deffn
14961
14962 @deftp {Data Type} alsa-configuration
14963 Data type representing the configuration for @code{alsa-service}.
14964
14965 @table @asis
14966 @item @code{alsa-plugins} (default: @var{alsa-plugins})
14967 @code{alsa-plugins} package to use.
14968
14969 @item @code{pulseaudio?} (default: @var{#t})
14970 Whether ALSA applications should transparently be made to use the
14971 @uref{http://www.pulseaudio.org/, PulseAudio} sound server.
14972
14973 Using PulseAudio allows you to run several sound-producing applications
14974 at the same time and to individual control them @i{via}
14975 @command{pavucontrol}, among other things.
14976
14977 @item @code{extra-options} (default: @var{""})
14978 String to append to the @file{/etc/asound.conf} file.
14979
14980 @end table
14981 @end deftp
14982
14983 Individual users who want to override the system configuration of ALSA can do
14984 it with the @file{~/.asoundrc} file:
14985
14986 @example
14987 # In guix, we have to specify the absolute path for plugins.
14988 pcm_type.jack @{
14989 lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
14990 @}
14991
14992 # Routing ALSA to jack:
14993 # <http://jackaudio.org/faq/routing_alsa.html>.
14994 pcm.rawjack @{
14995 type jack
14996 playback_ports @{
14997 0 system:playback_1
14998 1 system:playback_2
14999 @}
15000
15001 capture_ports @{
15002 0 system:capture_1
15003 1 system:capture_2
15004 @}
15005 @}
15006
15007 pcm.!default @{
15008 type plug
15009 slave @{
15010 pcm "rawjack"
15011 @}
15012 @}
15013 @end example
15014
15015 See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
15016 details.
15017
15018
15019 @node Database Services
15020 @subsection Database Services
15021
15022 @cindex database
15023 @cindex SQL
15024 The @code{(gnu services databases)} module provides the following services.
15025
15026 @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
15027 [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
15028 [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
15029 Return a service that runs @var{postgresql}, the PostgreSQL database
15030 server.
15031
15032 The PostgreSQL daemon loads its runtime configuration from @var{config-file},
15033 creates a database cluster with @var{locale} as the default
15034 locale, stored in @var{data-directory}. It then listens on @var{port}.
15035
15036 @cindex postgresql extension-packages
15037 Additional extensions are loaded from packages listed in
15038 @var{extension-packages}. Extensions are available at runtime. For instance,
15039 to create a geographic database using the @code{postgis} extension, a user can
15040 configure the postgresql-service as in this example:
15041
15042 @cindex postgis
15043 @example
15044 (use-package-modules databases geo)
15045
15046 (operating-system
15047 ...
15048 ;; postgresql is required to run `psql' but postgis is not required for
15049 ;; proper operation.
15050 (packages (cons* postgresql %base-packages))
15051 (services
15052 (cons*
15053 (postgresql-service #:extension-packages (list postgis))
15054 %base-services)))
15055 @end example
15056
15057 Then the extension becomes visible and you can initialise an empty geographic
15058 database in this way:
15059
15060 @example
15061 psql -U postgres
15062 > create database postgistest;
15063 > \connect postgistest;
15064 > create extension postgis;
15065 > create extension postgis_topology;
15066 @end example
15067
15068 There is no need to add this field for contrib extensions such as hstore or
15069 dblink as they are already loadable by postgresql. This field is only
15070 required to add extensions provided by other packages.
15071 @end deffn
15072
15073 @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
15074 Return a service that runs @command{mysqld}, the MySQL or MariaDB
15075 database server.
15076
15077 The optional @var{config} argument specifies the configuration for
15078 @command{mysqld}, which should be a @code{<mysql-configuration>} object.
15079 @end deffn
15080
15081 @deftp {Data Type} mysql-configuration
15082 Data type representing the configuration of @var{mysql-service}.
15083
15084 @table @asis
15085 @item @code{mysql} (default: @var{mariadb})
15086 Package object of the MySQL database server, can be either @var{mariadb}
15087 or @var{mysql}.
15088
15089 For MySQL, a temporary root password will be displayed at activation time.
15090 For MariaDB, the root password is empty.
15091
15092 @item @code{port} (default: @code{3306})
15093 TCP port on which the database server listens for incoming connections.
15094 @end table
15095 @end deftp
15096
15097 @defvr {Scheme Variable} memcached-service-type
15098 This is the service type for the @uref{https://memcached.org/,
15099 Memcached} service, which provides a distributed in memory cache. The
15100 value for the service type is a @code{memcached-configuration} object.
15101 @end defvr
15102
15103 @example
15104 (service memcached-service-type)
15105 @end example
15106
15107 @deftp {Data Type} memcached-configuration
15108 Data type representing the configuration of memcached.
15109
15110 @table @asis
15111 @item @code{memcached} (default: @code{memcached})
15112 The Memcached package to use.
15113
15114 @item @code{interfaces} (default: @code{'("0.0.0.0")})
15115 Network interfaces on which to listen.
15116
15117 @item @code{tcp-port} (default: @code{11211})
15118 Port on which to accept connections on,
15119
15120 @item @code{udp-port} (default: @code{11211})
15121 Port on which to accept UDP connections on, a value of 0 will disable
15122 listening on a UDP socket.
15123
15124 @item @code{additional-options} (default: @code{'()})
15125 Additional command line options to pass to @code{memcached}.
15126 @end table
15127 @end deftp
15128
15129 @defvr {Scheme Variable} mongodb-service-type
15130 This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
15131 The value for the service type is a @code{mongodb-configuration} object.
15132 @end defvr
15133
15134 @example
15135 (service mongodb-service-type)
15136 @end example
15137
15138 @deftp {Data Type} mongodb-configuration
15139 Data type representing the configuration of mongodb.
15140
15141 @table @asis
15142 @item @code{mongodb} (default: @code{mongodb})
15143 The MongoDB package to use.
15144
15145 @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
15146 The configuration file for MongoDB.
15147
15148 @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
15149 This value is used to create the directory, so that it exists and is
15150 owned by the mongodb user. It should match the data-directory which
15151 MongoDB is configured to use through the configuration file.
15152 @end table
15153 @end deftp
15154
15155 @defvr {Scheme Variable} redis-service-type
15156 This is the service type for the @uref{https://redis.io/, Redis}
15157 key/value store, whose value is a @code{redis-configuration} object.
15158 @end defvr
15159
15160 @deftp {Data Type} redis-configuration
15161 Data type representing the configuration of redis.
15162
15163 @table @asis
15164 @item @code{redis} (default: @code{redis})
15165 The Redis package to use.
15166
15167 @item @code{bind} (default: @code{"127.0.0.1"})
15168 Network interface on which to listen.
15169
15170 @item @code{port} (default: @code{6379})
15171 Port on which to accept connections on, a value of 0 will disable
15172 listening on a TCP socket.
15173
15174 @item @code{working-directory} (default: @code{"/var/lib/redis"})
15175 Directory in which to store the database and related files.
15176 @end table
15177 @end deftp
15178
15179 @node Mail Services
15180 @subsection Mail Services
15181
15182 @cindex mail
15183 @cindex email
15184 The @code{(gnu services mail)} module provides Guix service definitions
15185 for email services: IMAP, POP3, and LMTP servers, as well as mail
15186 transport agents (MTAs). Lots of acronyms! These services are detailed
15187 in the subsections below.
15188
15189 @subsubheading Dovecot Service
15190
15191 @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
15192 Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
15193 @end deffn
15194
15195 By default, Dovecot does not need much configuration; the default
15196 configuration object created by @code{(dovecot-configuration)} will
15197 suffice if your mail is delivered to @code{~/Maildir}. A self-signed
15198 certificate will be generated for TLS-protected connections, though
15199 Dovecot will also listen on cleartext ports by default. There are a
15200 number of options, though, which mail administrators might need to change,
15201 and as is the case with other services, Guix allows the system
15202 administrator to specify these parameters via a uniform Scheme interface.
15203
15204 For example, to specify that mail is located at @code{maildir~/.mail},
15205 one would instantiate the Dovecot service like this:
15206
15207 @example
15208 (dovecot-service #:config
15209 (dovecot-configuration
15210 (mail-location "maildir:~/.mail")))
15211 @end example
15212
15213 The available configuration parameters follow. Each parameter
15214 definition is preceded by its type; for example, @samp{string-list foo}
15215 indicates that the @code{foo} parameter should be specified as a list of
15216 strings. There is also a way to specify the configuration as a string,
15217 if you have an old @code{dovecot.conf} file that you want to port over
15218 from some other system; see the end for more details.
15219
15220 @c The following documentation was initially generated by
15221 @c (generate-documentation) in (gnu services mail). Manually maintained
15222 @c documentation is better, so we shouldn't hesitate to edit below as
15223 @c needed. However if the change you want to make to this documentation
15224 @c can be done in an automated way, it's probably easier to change
15225 @c (generate-documentation) than to make it below and have to deal with
15226 @c the churn as dovecot updates.
15227
15228 Available @code{dovecot-configuration} fields are:
15229
15230 @deftypevr {@code{dovecot-configuration} parameter} package dovecot
15231 The dovecot package.
15232 @end deftypevr
15233
15234 @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
15235 A list of IPs or hosts where to listen for connections. @samp{*}
15236 listens on all IPv4 interfaces, @samp{::} listens on all IPv6
15237 interfaces. If you want to specify non-default ports or anything more
15238 complex, customize the address and port fields of the
15239 @samp{inet-listener} of the specific services you are interested in.
15240 @end deftypevr
15241
15242 @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
15243 List of protocols we want to serve. Available protocols include
15244 @samp{imap}, @samp{pop3}, and @samp{lmtp}.
15245
15246 Available @code{protocol-configuration} fields are:
15247
15248 @deftypevr {@code{protocol-configuration} parameter} string name
15249 The name of the protocol.
15250 @end deftypevr
15251
15252 @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
15253 UNIX socket path to the master authentication server to find users.
15254 This is used by imap (for shared users) and lda.
15255 It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
15256 @end deftypevr
15257
15258 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
15259 Space separated list of plugins to load.
15260 @end deftypevr
15261
15262 @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
15263 Maximum number of IMAP connections allowed for a user from each IP
15264 address. NOTE: The username is compared case-sensitively.
15265 Defaults to @samp{10}.
15266 @end deftypevr
15267
15268 @end deftypevr
15269
15270 @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
15271 List of services to enable. Available services include @samp{imap},
15272 @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
15273 @samp{lmtp}.
15274
15275 Available @code{service-configuration} fields are:
15276
15277 @deftypevr {@code{service-configuration} parameter} string kind
15278 The service kind. Valid values include @code{director},
15279 @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
15280 @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
15281 @code{tcpwrap}, @code{quota-warning}, or anything else.
15282 @end deftypevr
15283
15284 @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
15285 Listeners for the service. A listener is either a
15286 @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
15287 an @code{inet-listener-configuration}.
15288 Defaults to @samp{()}.
15289
15290 Available @code{unix-listener-configuration} fields are:
15291
15292 @deftypevr {@code{unix-listener-configuration} parameter} string path
15293 Path to the file, relative to @code{base-dir} field. This is also used as
15294 the section name.
15295 @end deftypevr
15296
15297 @deftypevr {@code{unix-listener-configuration} parameter} string mode
15298 The access mode for the socket.
15299 Defaults to @samp{"0600"}.
15300 @end deftypevr
15301
15302 @deftypevr {@code{unix-listener-configuration} parameter} string user
15303 The user to own the socket.
15304 Defaults to @samp{""}.
15305 @end deftypevr
15306
15307 @deftypevr {@code{unix-listener-configuration} parameter} string group
15308 The group to own the socket.
15309 Defaults to @samp{""}.
15310 @end deftypevr
15311
15312
15313 Available @code{fifo-listener-configuration} fields are:
15314
15315 @deftypevr {@code{fifo-listener-configuration} parameter} string path
15316 Path to the file, relative to @code{base-dir} field. This is also used as
15317 the section name.
15318 @end deftypevr
15319
15320 @deftypevr {@code{fifo-listener-configuration} parameter} string mode
15321 The access mode for the socket.
15322 Defaults to @samp{"0600"}.
15323 @end deftypevr
15324
15325 @deftypevr {@code{fifo-listener-configuration} parameter} string user
15326 The user to own the socket.
15327 Defaults to @samp{""}.
15328 @end deftypevr
15329
15330 @deftypevr {@code{fifo-listener-configuration} parameter} string group
15331 The group to own the socket.
15332 Defaults to @samp{""}.
15333 @end deftypevr
15334
15335
15336 Available @code{inet-listener-configuration} fields are:
15337
15338 @deftypevr {@code{inet-listener-configuration} parameter} string protocol
15339 The protocol to listen for.
15340 @end deftypevr
15341
15342 @deftypevr {@code{inet-listener-configuration} parameter} string address
15343 The address on which to listen, or empty for all addresses.
15344 Defaults to @samp{""}.
15345 @end deftypevr
15346
15347 @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
15348 The port on which to listen.
15349 @end deftypevr
15350
15351 @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
15352 Whether to use SSL for this service; @samp{yes}, @samp{no}, or
15353 @samp{required}.
15354 Defaults to @samp{#t}.
15355 @end deftypevr
15356
15357 @end deftypevr
15358
15359 @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
15360 Maximum number of simultaneous client connections per process. Once
15361 this number of connections is received, the next incoming connection
15362 will prompt Dovecot to spawn another process. If set to 0,
15363 @code{default-client-limit} is used instead.
15364
15365 Defaults to @samp{0}.
15366
15367 @end deftypevr
15368
15369 @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
15370 Number of connections to handle before starting a new process.
15371 Typically the only useful values are 0 (unlimited) or 1. 1 is more
15372 secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
15373 Defaults to @samp{1}.
15374
15375 @end deftypevr
15376
15377 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
15378 Maximum number of processes that can exist for this service. If set to
15379 0, @code{default-process-limit} is used instead.
15380
15381 Defaults to @samp{0}.
15382
15383 @end deftypevr
15384
15385 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
15386 Number of processes to always keep waiting for more connections.
15387 Defaults to @samp{0}.
15388 @end deftypevr
15389
15390 @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
15391 If you set @samp{service-count 0}, you probably need to grow
15392 this.
15393 Defaults to @samp{256000000}.
15394 @end deftypevr
15395
15396 @end deftypevr
15397
15398 @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
15399 Dict configuration, as created by the @code{dict-configuration}
15400 constructor.
15401
15402 Available @code{dict-configuration} fields are:
15403
15404 @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
15405 A list of key-value pairs that this dict should hold.
15406 Defaults to @samp{()}.
15407 @end deftypevr
15408
15409 @end deftypevr
15410
15411 @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
15412 A list of passdb configurations, each one created by the
15413 @code{passdb-configuration} constructor.
15414
15415 Available @code{passdb-configuration} fields are:
15416
15417 @deftypevr {@code{passdb-configuration} parameter} string driver
15418 The driver that the passdb should use. Valid values include
15419 @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
15420 @samp{static}.
15421 Defaults to @samp{"pam"}.
15422 @end deftypevr
15423
15424 @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
15425 Space separated list of arguments to the passdb driver.
15426 Defaults to @samp{""}.
15427 @end deftypevr
15428
15429 @end deftypevr
15430
15431 @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
15432 List of userdb configurations, each one created by the
15433 @code{userdb-configuration} constructor.
15434
15435 Available @code{userdb-configuration} fields are:
15436
15437 @deftypevr {@code{userdb-configuration} parameter} string driver
15438 The driver that the userdb should use. Valid values include
15439 @samp{passwd} and @samp{static}.
15440 Defaults to @samp{"passwd"}.
15441 @end deftypevr
15442
15443 @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
15444 Space separated list of arguments to the userdb driver.
15445 Defaults to @samp{""}.
15446 @end deftypevr
15447
15448 @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
15449 Override fields from passwd.
15450 Defaults to @samp{()}.
15451 @end deftypevr
15452
15453 @end deftypevr
15454
15455 @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
15456 Plug-in configuration, created by the @code{plugin-configuration}
15457 constructor.
15458 @end deftypevr
15459
15460 @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
15461 List of namespaces. Each item in the list is created by the
15462 @code{namespace-configuration} constructor.
15463
15464 Available @code{namespace-configuration} fields are:
15465
15466 @deftypevr {@code{namespace-configuration} parameter} string name
15467 Name for this namespace.
15468 @end deftypevr
15469
15470 @deftypevr {@code{namespace-configuration} parameter} string type
15471 Namespace type: @samp{private}, @samp{shared} or @samp{public}.
15472 Defaults to @samp{"private"}.
15473 @end deftypevr
15474
15475 @deftypevr {@code{namespace-configuration} parameter} string separator
15476 Hierarchy separator to use. You should use the same separator for
15477 all namespaces or some clients get confused. @samp{/} is usually a good
15478 one. The default however depends on the underlying mail storage
15479 format.
15480 Defaults to @samp{""}.
15481 @end deftypevr
15482
15483 @deftypevr {@code{namespace-configuration} parameter} string prefix
15484 Prefix required to access this namespace. This needs to be
15485 different for all namespaces. For example @samp{Public/}.
15486 Defaults to @samp{""}.
15487 @end deftypevr
15488
15489 @deftypevr {@code{namespace-configuration} parameter} string location
15490 Physical location of the mailbox. This is in the same format as
15491 mail_location, which is also the default for it.
15492 Defaults to @samp{""}.
15493 @end deftypevr
15494
15495 @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
15496 There can be only one INBOX, and this setting defines which
15497 namespace has it.
15498 Defaults to @samp{#f}.
15499 @end deftypevr
15500
15501 @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
15502 If namespace is hidden, it's not advertised to clients via NAMESPACE
15503 extension. You'll most likely also want to set @samp{list? #f}. This is mostly
15504 useful when converting from another server with different namespaces
15505 which you want to deprecate but still keep working. For example you can
15506 create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
15507 and @samp{mail/}.
15508 Defaults to @samp{#f}.
15509 @end deftypevr
15510
15511 @deftypevr {@code{namespace-configuration} parameter} boolean list?
15512 Show the mailboxes under this namespace with the LIST command. This
15513 makes the namespace visible for clients that do not support the NAMESPACE
15514 extension. The special @code{children} value lists child mailboxes, but
15515 hides the namespace prefix.
15516 Defaults to @samp{#t}.
15517 @end deftypevr
15518
15519 @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
15520 Namespace handles its own subscriptions. If set to @code{#f}, the
15521 parent namespace handles them. The empty prefix should always have this
15522 as @code{#t}).
15523 Defaults to @samp{#t}.
15524 @end deftypevr
15525
15526 @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
15527 List of predefined mailboxes in this namespace.
15528 Defaults to @samp{()}.
15529
15530 Available @code{mailbox-configuration} fields are:
15531
15532 @deftypevr {@code{mailbox-configuration} parameter} string name
15533 Name for this mailbox.
15534 @end deftypevr
15535
15536 @deftypevr {@code{mailbox-configuration} parameter} string auto
15537 @samp{create} will automatically create this mailbox.
15538 @samp{subscribe} will both create and subscribe to the mailbox.
15539 Defaults to @samp{"no"}.
15540 @end deftypevr
15541
15542 @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
15543 List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
15544 Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
15545 @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
15546 Defaults to @samp{()}.
15547 @end deftypevr
15548
15549 @end deftypevr
15550
15551 @end deftypevr
15552
15553 @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
15554 Base directory where to store runtime data.
15555 Defaults to @samp{"/var/run/dovecot/"}.
15556 @end deftypevr
15557
15558 @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
15559 Greeting message for clients.
15560 Defaults to @samp{"Dovecot ready."}.
15561 @end deftypevr
15562
15563 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
15564 List of trusted network ranges. Connections from these IPs are
15565 allowed to override their IP addresses and ports (for logging and for
15566 authentication checks). @samp{disable-plaintext-auth} is also ignored
15567 for these networks. Typically you would specify your IMAP proxy servers
15568 here.
15569 Defaults to @samp{()}.
15570 @end deftypevr
15571
15572 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
15573 List of login access check sockets (e.g.@: tcpwrap).
15574 Defaults to @samp{()}.
15575 @end deftypevr
15576
15577 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
15578 Show more verbose process titles (in ps). Currently shows user name
15579 and IP address. Useful for seeing who is actually using the IMAP
15580 processes (e.g.@: shared mailboxes or if the same uid is used for multiple
15581 accounts).
15582 Defaults to @samp{#f}.
15583 @end deftypevr
15584
15585 @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
15586 Should all processes be killed when Dovecot master process shuts down.
15587 Setting this to @code{#f} means that Dovecot can be upgraded without
15588 forcing existing client connections to close (although that could also
15589 be a problem if the upgrade is e.g.@: due to a security fix).
15590 Defaults to @samp{#t}.
15591 @end deftypevr
15592
15593 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
15594 If non-zero, run mail commands via this many connections to doveadm
15595 server, instead of running them directly in the same process.
15596 Defaults to @samp{0}.
15597 @end deftypevr
15598
15599 @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
15600 UNIX socket or host:port used for connecting to doveadm server.
15601 Defaults to @samp{"doveadm-server"}.
15602 @end deftypevr
15603
15604 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
15605 List of environment variables that are preserved on Dovecot startup
15606 and passed down to all of its child processes. You can also give
15607 key=value pairs to always set specific settings.
15608 @end deftypevr
15609
15610 @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
15611 Disable LOGIN command and all other plaintext authentications unless
15612 SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
15613 matches the local IP (i.e.@: you're connecting from the same computer),
15614 the connection is considered secure and plaintext authentication is
15615 allowed. See also ssl=required setting.
15616 Defaults to @samp{#t}.
15617 @end deftypevr
15618
15619 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
15620 Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
15621 Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
15622 for caching to be used.
15623 Defaults to @samp{0}.
15624 @end deftypevr
15625
15626 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
15627 Time to live for cached data. After TTL expires the cached record
15628 is no longer used, *except* if the main database lookup returns internal
15629 failure. We also try to handle password changes automatically: If
15630 user's previous authentication was successful, but this one wasn't, the
15631 cache isn't used. For now this works only with plaintext
15632 authentication.
15633 Defaults to @samp{"1 hour"}.
15634 @end deftypevr
15635
15636 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
15637 TTL for negative hits (user not found, password mismatch).
15638 0 disables caching them completely.
15639 Defaults to @samp{"1 hour"}.
15640 @end deftypevr
15641
15642 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
15643 List of realms for SASL authentication mechanisms that need them.
15644 You can leave it empty if you don't want to support multiple realms.
15645 Many clients simply use the first one listed here, so keep the default
15646 realm first.
15647 Defaults to @samp{()}.
15648 @end deftypevr
15649
15650 @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
15651 Default realm/domain to use if none was specified. This is used for
15652 both SASL realms and appending @@domain to username in plaintext
15653 logins.
15654 Defaults to @samp{""}.
15655 @end deftypevr
15656
15657 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
15658 List of allowed characters in username. If the user-given username
15659 contains a character not listed in here, the login automatically fails.
15660 This is just an extra check to make sure user can't exploit any
15661 potential quote escaping vulnerabilities with SQL/LDAP databases. If
15662 you want to allow all characters, set this value to empty.
15663 Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
15664 @end deftypevr
15665
15666 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
15667 Username character translations before it's looked up from
15668 databases. The value contains series of from -> to characters. For
15669 example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
15670 translated to @samp{@@}.
15671 Defaults to @samp{""}.
15672 @end deftypevr
15673
15674 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
15675 Username formatting before it's looked up from databases. You can
15676 use the standard variables here, e.g.@: %Lu would lowercase the username,
15677 %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
15678 change the @samp{@@} into @samp{-AT-}. This translation is done after
15679 @samp{auth-username-translation} changes.
15680 Defaults to @samp{"%Lu"}.
15681 @end deftypevr
15682
15683 @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
15684 If you want to allow master users to log in by specifying the master
15685 username within the normal username string (i.e.@: not using SASL
15686 mechanism's support for it), you can specify the separator character
15687 here. The format is then <username><separator><master username>.
15688 UW-IMAP uses @samp{*} as the separator, so that could be a good
15689 choice.
15690 Defaults to @samp{""}.
15691 @end deftypevr
15692
15693 @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
15694 Username to use for users logging in with ANONYMOUS SASL
15695 mechanism.
15696 Defaults to @samp{"anonymous"}.
15697 @end deftypevr
15698
15699 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
15700 Maximum number of dovecot-auth worker processes. They're used to
15701 execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
15702 They're automatically created and destroyed as needed.
15703 Defaults to @samp{30}.
15704 @end deftypevr
15705
15706 @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
15707 Host name to use in GSSAPI principal names. The default is to use
15708 the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
15709 allow all keytab entries.
15710 Defaults to @samp{""}.
15711 @end deftypevr
15712
15713 @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
15714 Kerberos keytab to use for the GSSAPI mechanism. Will use the
15715 system default (usually @file{/etc/krb5.keytab}) if not specified. You may
15716 need to change the auth service to run as root to be able to read this
15717 file.
15718 Defaults to @samp{""}.
15719 @end deftypevr
15720
15721 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
15722 Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
15723 and @samp{ntlm-auth} helper.
15724 <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
15725 Defaults to @samp{#f}.
15726 @end deftypevr
15727
15728 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
15729 Path for Samba's @samp{ntlm-auth} helper binary.
15730 Defaults to @samp{"/usr/bin/ntlm_auth"}.
15731 @end deftypevr
15732
15733 @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
15734 Time to delay before replying to failed authentications.
15735 Defaults to @samp{"2 secs"}.
15736 @end deftypevr
15737
15738 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
15739 Require a valid SSL client certificate or the authentication
15740 fails.
15741 Defaults to @samp{#f}.
15742 @end deftypevr
15743
15744 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
15745 Take the username from client's SSL certificate, using
15746 @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
15747 CommonName.
15748 Defaults to @samp{#f}.
15749 @end deftypevr
15750
15751 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
15752 List of wanted authentication mechanisms. Supported mechanisms are:
15753 @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
15754 @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
15755 @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
15756 @samp{disable-plaintext-auth} setting.
15757 @end deftypevr
15758
15759 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
15760 List of IPs or hostnames to all director servers, including ourself.
15761 Ports can be specified as ip:port. The default port is the same as what
15762 director service's @samp{inet-listener} is using.
15763 Defaults to @samp{()}.
15764 @end deftypevr
15765
15766 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
15767 List of IPs or hostnames to all backend mail servers. Ranges are
15768 allowed too, like 10.0.0.10-10.0.0.30.
15769 Defaults to @samp{()}.
15770 @end deftypevr
15771
15772 @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
15773 How long to redirect users to a specific server after it no longer
15774 has any connections.
15775 Defaults to @samp{"15 min"}.
15776 @end deftypevr
15777
15778 @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
15779 How the username is translated before being hashed. Useful values
15780 include %Ln if user can log in with or without @@domain, %Ld if mailboxes
15781 are shared within domain.
15782 Defaults to @samp{"%Lu"}.
15783 @end deftypevr
15784
15785 @deftypevr {@code{dovecot-configuration} parameter} string log-path
15786 Log file to use for error messages. @samp{syslog} logs to syslog,
15787 @samp{/dev/stderr} logs to stderr.
15788 Defaults to @samp{"syslog"}.
15789 @end deftypevr
15790
15791 @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
15792 Log file to use for informational messages. Defaults to
15793 @samp{log-path}.
15794 Defaults to @samp{""}.
15795 @end deftypevr
15796
15797 @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
15798 Log file to use for debug messages. Defaults to
15799 @samp{info-log-path}.
15800 Defaults to @samp{""}.
15801 @end deftypevr
15802
15803 @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
15804 Syslog facility to use if you're logging to syslog. Usually if you
15805 don't want to use @samp{mail}, you'll use local0..local7. Also other
15806 standard facilities are supported.
15807 Defaults to @samp{"mail"}.
15808 @end deftypevr
15809
15810 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
15811 Log unsuccessful authentication attempts and the reasons why they
15812 failed.
15813 Defaults to @samp{#f}.
15814 @end deftypevr
15815
15816 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
15817 In case of password mismatches, log the attempted password. Valid
15818 values are no, plain and sha1. sha1 can be useful for detecting brute
15819 force password attempts vs. user simply trying the same password over
15820 and over again. You can also truncate the value to n chars by appending
15821 ":n" (e.g.@: sha1:6).
15822 Defaults to @samp{#f}.
15823 @end deftypevr
15824
15825 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
15826 Even more verbose logging for debugging purposes. Shows for example
15827 SQL queries.
15828 Defaults to @samp{#f}.
15829 @end deftypevr
15830
15831 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
15832 In case of password mismatches, log the passwords and used scheme so
15833 the problem can be debugged. Enabling this also enables
15834 @samp{auth-debug}.
15835 Defaults to @samp{#f}.
15836 @end deftypevr
15837
15838 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
15839 Enable mail process debugging. This can help you figure out why
15840 Dovecot isn't finding your mails.
15841 Defaults to @samp{#f}.
15842 @end deftypevr
15843
15844 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
15845 Show protocol level SSL errors.
15846 Defaults to @samp{#f}.
15847 @end deftypevr
15848
15849 @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
15850 Prefix for each line written to log file. % codes are in
15851 strftime(3) format.
15852 Defaults to @samp{"\"%b %d %H:%M:%S \""}.
15853 @end deftypevr
15854
15855 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
15856 List of elements we want to log. The elements which have a
15857 non-empty variable value are joined together to form a comma-separated
15858 string.
15859 @end deftypevr
15860
15861 @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
15862 Login log format. %s contains @samp{login-log-format-elements}
15863 string, %$ contains the data we want to log.
15864 Defaults to @samp{"%$: %s"}.
15865 @end deftypevr
15866
15867 @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
15868 Log prefix for mail processes. See doc/wiki/Variables.txt for list
15869 of possible variables you can use.
15870 Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
15871 @end deftypevr
15872
15873 @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
15874 Format to use for logging mail deliveries. You can use variables:
15875 @table @code
15876 @item %$
15877 Delivery status message (e.g.@: @samp{saved to INBOX})
15878 @item %m
15879 Message-ID
15880 @item %s
15881 Subject
15882 @item %f
15883 From address
15884 @item %p
15885 Physical size
15886 @item %w
15887 Virtual size.
15888 @end table
15889 Defaults to @samp{"msgid=%m: %$"}.
15890 @end deftypevr
15891
15892 @deftypevr {@code{dovecot-configuration} parameter} string mail-location
15893 Location for users' mailboxes. The default is empty, which means
15894 that Dovecot tries to find the mailboxes automatically. This won't work
15895 if the user doesn't yet have any mail, so you should explicitly tell
15896 Dovecot the full location.
15897
15898 If you're using mbox, giving a path to the INBOX
15899 file (e.g.@: /var/mail/%u) isn't enough. You'll also need to tell Dovecot
15900 where the other mailboxes are kept. This is called the "root mail
15901 directory", and it must be the first path given in the
15902 @samp{mail-location} setting.
15903
15904 There are a few special variables you can use, eg.:
15905
15906 @table @samp
15907 @item %u
15908 username
15909 @item %n
15910 user part in user@@domain, same as %u if there's no domain
15911 @item %d
15912 domain part in user@@domain, empty if there's no domain
15913 @item %h
15914 home director
15915 @end table
15916
15917 See doc/wiki/Variables.txt for full list. Some examples:
15918 @table @samp
15919 @item maildir:~/Maildir
15920 @item mbox:~/mail:INBOX=/var/mail/%u
15921 @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
15922 @end table
15923 Defaults to @samp{""}.
15924 @end deftypevr
15925
15926 @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
15927 System user and group used to access mails. If you use multiple,
15928 userdb can override these by returning uid or gid fields. You can use
15929 either numbers or names. <doc/wiki/UserIds.txt>.
15930 Defaults to @samp{""}.
15931 @end deftypevr
15932
15933 @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
15934
15935 Defaults to @samp{""}.
15936 @end deftypevr
15937
15938 @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
15939 Group to enable temporarily for privileged operations. Currently
15940 this is used only with INBOX when either its initial creation or
15941 dotlocking fails. Typically this is set to "mail" to give access to
15942 /var/mail.
15943 Defaults to @samp{""}.
15944 @end deftypevr
15945
15946 @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
15947 Grant access to these supplementary groups for mail processes.
15948 Typically these are used to set up access to shared mailboxes. Note
15949 that it may be dangerous to set these if users can create
15950 symlinks (e.g.@: if "mail" group is set here, ln -s /var/mail ~/mail/var
15951 could allow a user to delete others' mailboxes, or ln -s
15952 /secret/shared/box ~/mail/mybox would allow reading it).
15953 Defaults to @samp{""}.
15954 @end deftypevr
15955
15956 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
15957 Allow full file system access to clients. There's no access checks
15958 other than what the operating system does for the active UID/GID. It
15959 works with both maildir and mboxes, allowing you to prefix mailboxes
15960 names with e.g.@: /path/ or ~user/.
15961 Defaults to @samp{#f}.
15962 @end deftypevr
15963
15964 @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
15965 Don't use mmap() at all. This is required if you store indexes to
15966 shared file systems (NFS or clustered file system).
15967 Defaults to @samp{#f}.
15968 @end deftypevr
15969
15970 @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
15971 Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
15972 supports @samp{O_EXCL} since version 3, so this should be safe to use
15973 nowadays by default.
15974 Defaults to @samp{#t}.
15975 @end deftypevr
15976
15977 @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
15978 When to use fsync() or fdatasync() calls:
15979 @table @code
15980 @item optimized
15981 Whenever necessary to avoid losing important data
15982 @item always
15983 Useful with e.g.@: NFS when write()s are delayed
15984 @item never
15985 Never use it (best performance, but crashes can lose data).
15986 @end table
15987 Defaults to @samp{"optimized"}.
15988 @end deftypevr
15989
15990 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
15991 Mail storage exists in NFS. Set this to yes to make Dovecot flush
15992 NFS caches whenever needed. If you're using only a single mail server
15993 this isn't needed.
15994 Defaults to @samp{#f}.
15995 @end deftypevr
15996
15997 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
15998 Mail index files also exist in NFS. Setting this to yes requires
15999 @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
16000 Defaults to @samp{#f}.
16001 @end deftypevr
16002
16003 @deftypevr {@code{dovecot-configuration} parameter} string lock-method
16004 Locking method for index files. Alternatives are fcntl, flock and
16005 dotlock. Dotlocking uses some tricks which may create more disk I/O
16006 than other locking methods. NFS users: flock doesn't work, remember to
16007 change @samp{mmap-disable}.
16008 Defaults to @samp{"fcntl"}.
16009 @end deftypevr
16010
16011 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
16012 Directory in which LDA/LMTP temporarily stores incoming mails >128
16013 kB.
16014 Defaults to @samp{"/tmp"}.
16015 @end deftypevr
16016
16017 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
16018 Valid UID range for users. This is mostly to make sure that users can't
16019 log in as daemons or other system users. Note that denying root logins is
16020 hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
16021 is set to 0.
16022 Defaults to @samp{500}.
16023 @end deftypevr
16024
16025 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
16026
16027 Defaults to @samp{0}.
16028 @end deftypevr
16029
16030 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
16031 Valid GID range for users. Users having non-valid GID as primary group ID
16032 aren't allowed to log in. If user belongs to supplementary groups with
16033 non-valid GIDs, those groups are not set.
16034 Defaults to @samp{1}.
16035 @end deftypevr
16036
16037 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
16038
16039 Defaults to @samp{0}.
16040 @end deftypevr
16041
16042 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
16043 Maximum allowed length for mail keyword name. It's only forced when
16044 trying to create new keywords.
16045 Defaults to @samp{50}.
16046 @end deftypevr
16047
16048 @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
16049 List of directories under which chrooting is allowed for mail
16050 processes (i.e.@: /var/mail will allow chrooting to /var/mail/foo/bar
16051 too). This setting doesn't affect @samp{login-chroot}
16052 @samp{mail-chroot} or auth chroot settings. If this setting is empty,
16053 "/./" in home dirs are ignored. WARNING: Never add directories here
16054 which local users can modify, that may lead to root exploit. Usually
16055 this should be done only if you don't allow shell access for users.
16056 <doc/wiki/Chrooting.txt>.
16057 Defaults to @samp{()}.
16058 @end deftypevr
16059
16060 @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
16061 Default chroot directory for mail processes. This can be overridden
16062 for specific users in user database by giving /./ in user's home
16063 directory (e.g.@: /home/./user chroots into /home). Note that usually
16064 there is no real need to do chrooting, Dovecot doesn't allow users to
16065 access files outside their mail directory anyway. If your home
16066 directories are prefixed with the chroot directory, append "/."@: to
16067 @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
16068 Defaults to @samp{""}.
16069 @end deftypevr
16070
16071 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
16072 UNIX socket path to master authentication server to find users.
16073 This is used by imap (for shared users) and lda.
16074 Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
16075 @end deftypevr
16076
16077 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
16078 Directory where to look up mail plugins.
16079 Defaults to @samp{"/usr/lib/dovecot"}.
16080 @end deftypevr
16081
16082 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
16083 List of plugins to load for all services. Plugins specific to IMAP,
16084 LDA, etc.@: are added to this list in their own .conf files.
16085 Defaults to @samp{()}.
16086 @end deftypevr
16087
16088 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
16089 The minimum number of mails in a mailbox before updates are done to
16090 cache file. This allows optimizing Dovecot's behavior to do less disk
16091 writes at the cost of more disk reads.
16092 Defaults to @samp{0}.
16093 @end deftypevr
16094
16095 @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
16096 When IDLE command is running, mailbox is checked once in a while to
16097 see if there are any new mails or other changes. This setting defines
16098 the minimum time to wait between those checks. Dovecot can also use
16099 dnotify, inotify and kqueue to find out immediately when changes
16100 occur.
16101 Defaults to @samp{"30 secs"}.
16102 @end deftypevr
16103
16104 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
16105 Save mails with CR+LF instead of plain LF. This makes sending those
16106 mails take less CPU, especially with sendfile() syscall with Linux and
16107 FreeBSD. But it also creates a bit more disk I/O which may just make it
16108 slower. Also note that if other software reads the mboxes/maildirs,
16109 they may handle the extra CRs wrong and cause problems.
16110 Defaults to @samp{#f}.
16111 @end deftypevr
16112
16113 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
16114 By default LIST command returns all entries in maildir beginning
16115 with a dot. Enabling this option makes Dovecot return only entries
16116 which are directories. This is done by stat()ing each entry, so it
16117 causes more disk I/O.
16118 (For systems setting struct @samp{dirent->d_type} this check is free
16119 and it's done always regardless of this setting).
16120 Defaults to @samp{#f}.
16121 @end deftypevr
16122
16123 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
16124 When copying a message, do it with hard links whenever possible.
16125 This makes the performance much better, and it's unlikely to have any
16126 side effects.
16127 Defaults to @samp{#t}.
16128 @end deftypevr
16129
16130 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
16131 Assume Dovecot is the only MUA accessing Maildir: Scan cur/
16132 directory only when its mtime changes unexpectedly or when we can't find
16133 the mail otherwise.
16134 Defaults to @samp{#f}.
16135 @end deftypevr
16136
16137 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
16138 Which locking methods to use for locking mbox. There are four
16139 available:
16140
16141 @table @code
16142 @item dotlock
16143 Create <mailbox>.lock file. This is the oldest and most NFS-safe
16144 solution. If you want to use /var/mail/ like directory, the users will
16145 need write access to that directory.
16146 @item dotlock-try
16147 Same as dotlock, but if it fails because of permissions or because there
16148 isn't enough disk space, just skip it.
16149 @item fcntl
16150 Use this if possible. Works with NFS too if lockd is used.
16151 @item flock
16152 May not exist in all systems. Doesn't work with NFS.
16153 @item lockf
16154 May not exist in all systems. Doesn't work with NFS.
16155 @end table
16156
16157 You can use multiple locking methods; if you do the order they're declared
16158 in is important to avoid deadlocks if other MTAs/MUAs are using multiple
16159 locking methods as well. Some operating systems don't allow using some of
16160 them simultaneously.
16161 @end deftypevr
16162
16163 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
16164
16165 @end deftypevr
16166
16167 @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
16168 Maximum time to wait for lock (all of them) before aborting.
16169 Defaults to @samp{"5 mins"}.
16170 @end deftypevr
16171
16172 @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
16173 If dotlock exists but the mailbox isn't modified in any way,
16174 override the lock file after this much time.
16175 Defaults to @samp{"2 mins"}.
16176 @end deftypevr
16177
16178 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
16179 When mbox changes unexpectedly we have to fully read it to find out
16180 what changed. If the mbox is large this can take a long time. Since
16181 the change is usually just a newly appended mail, it'd be faster to
16182 simply read the new mails. If this setting is enabled, Dovecot does
16183 this but still safely fallbacks to re-reading the whole mbox file
16184 whenever something in mbox isn't how it's expected to be. The only real
16185 downside to this setting is that if some other MUA changes message
16186 flags, Dovecot doesn't notice it immediately. Note that a full sync is
16187 done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
16188 Defaults to @samp{#t}.
16189 @end deftypevr
16190
16191 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
16192 Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
16193 EXAMINE, EXPUNGE or CHECK commands. If this is set,
16194 @samp{mbox-dirty-syncs} is ignored.
16195 Defaults to @samp{#f}.
16196 @end deftypevr
16197
16198 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
16199 Delay writing mbox headers until doing a full write sync (EXPUNGE
16200 and CHECK commands and when closing the mailbox). This is especially
16201 useful for POP3 where clients often delete all mails. The downside is
16202 that our changes aren't immediately visible to other MUAs.
16203 Defaults to @samp{#t}.
16204 @end deftypevr
16205
16206 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
16207 If mbox size is smaller than this (e.g.@: 100k), don't write index
16208 files. If an index file already exists it's still read, just not
16209 updated.
16210 Defaults to @samp{0}.
16211 @end deftypevr
16212
16213 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
16214 Maximum dbox file size until it's rotated.
16215 Defaults to @samp{10000000}.
16216 @end deftypevr
16217
16218 @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
16219 Maximum dbox file age until it's rotated. Typically in days. Day
16220 begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
16221 disabled.
16222 Defaults to @samp{"1d"}.
16223 @end deftypevr
16224
16225 @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
16226 When creating new mdbox files, immediately preallocate their size to
16227 @samp{mdbox-rotate-size}. This setting currently works only in Linux
16228 with some file systems (ext4, xfs).
16229 Defaults to @samp{#f}.
16230 @end deftypevr
16231
16232 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
16233 sdbox and mdbox support saving mail attachments to external files,
16234 which also allows single instance storage for them. Other backends
16235 don't support this for now.
16236
16237 WARNING: This feature hasn't been tested much yet. Use at your own risk.
16238
16239 Directory root where to store mail attachments. Disabled, if empty.
16240 Defaults to @samp{""}.
16241 @end deftypevr
16242
16243 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
16244 Attachments smaller than this aren't saved externally. It's also
16245 possible to write a plugin to disable saving specific attachments
16246 externally.
16247 Defaults to @samp{128000}.
16248 @end deftypevr
16249
16250 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
16251 File system backend to use for saving attachments:
16252 @table @code
16253 @item posix
16254 No SiS done by Dovecot (but this might help FS's own deduplication)
16255 @item sis posix
16256 SiS with immediate byte-by-byte comparison during saving
16257 @item sis-queue posix
16258 SiS with delayed comparison and deduplication.
16259 @end table
16260 Defaults to @samp{"sis posix"}.
16261 @end deftypevr
16262
16263 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
16264 Hash format to use in attachment filenames. You can add any text and
16265 variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
16266 @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
16267 truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
16268 Defaults to @samp{"%@{sha1@}"}.
16269 @end deftypevr
16270
16271 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
16272
16273 Defaults to @samp{100}.
16274 @end deftypevr
16275
16276 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
16277
16278 Defaults to @samp{1000}.
16279 @end deftypevr
16280
16281 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
16282 Default VSZ (virtual memory size) limit for service processes.
16283 This is mainly intended to catch and kill processes that leak memory
16284 before they eat up everything.
16285 Defaults to @samp{256000000}.
16286 @end deftypevr
16287
16288 @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
16289 Login user is internally used by login processes. This is the most
16290 untrusted user in Dovecot system. It shouldn't have access to anything
16291 at all.
16292 Defaults to @samp{"dovenull"}.
16293 @end deftypevr
16294
16295 @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
16296 Internal user is used by unprivileged processes. It should be
16297 separate from login user, so that login processes can't disturb other
16298 processes.
16299 Defaults to @samp{"dovecot"}.
16300 @end deftypevr
16301
16302 @deftypevr {@code{dovecot-configuration} parameter} string ssl?
16303 SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
16304 Defaults to @samp{"required"}.
16305 @end deftypevr
16306
16307 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
16308 PEM encoded X.509 SSL/TLS certificate (public key).
16309 Defaults to @samp{"</etc/dovecot/default.pem"}.
16310 @end deftypevr
16311
16312 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
16313 PEM encoded SSL/TLS private key. The key is opened before
16314 dropping root privileges, so keep the key file unreadable by anyone but
16315 root.
16316 Defaults to @samp{"</etc/dovecot/private/default.pem"}.
16317 @end deftypevr
16318
16319 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
16320 If key file is password protected, give the password here.
16321 Alternatively give it when starting dovecot with -p parameter. Since
16322 this file is often world-readable, you may want to place this setting
16323 instead to a different.
16324 Defaults to @samp{""}.
16325 @end deftypevr
16326
16327 @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
16328 PEM encoded trusted certificate authority. Set this only if you
16329 intend to use @samp{ssl-verify-client-cert? #t}. The file should
16330 contain the CA certificate(s) followed by the matching
16331 CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
16332 Defaults to @samp{""}.
16333 @end deftypevr
16334
16335 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
16336 Require that CRL check succeeds for client certificates.
16337 Defaults to @samp{#t}.
16338 @end deftypevr
16339
16340 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
16341 Request client to send a certificate. If you also want to require
16342 it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
16343 Defaults to @samp{#f}.
16344 @end deftypevr
16345
16346 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
16347 Which field from certificate to use for username. commonName and
16348 x500UniqueIdentifier are the usual choices. You'll also need to set
16349 @samp{auth-ssl-username-from-cert? #t}.
16350 Defaults to @samp{"commonName"}.
16351 @end deftypevr
16352
16353 @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
16354 Minimum SSL protocol version to accept.
16355 Defaults to @samp{"TLSv1"}.
16356 @end deftypevr
16357
16358 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
16359 SSL ciphers to use.
16360 Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
16361 @end deftypevr
16362
16363 @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
16364 SSL crypto device to use, for valid values run "openssl engine".
16365 Defaults to @samp{""}.
16366 @end deftypevr
16367
16368 @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
16369 Address to use when sending rejection mails.
16370 %d expands to recipient domain.
16371 Defaults to @samp{"postmaster@@%d"}.
16372 @end deftypevr
16373
16374 @deftypevr {@code{dovecot-configuration} parameter} string hostname
16375 Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
16376 and in LMTP replies. Default is the system's real hostname@@domain.
16377 Defaults to @samp{""}.
16378 @end deftypevr
16379
16380 @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
16381 If user is over quota, return with temporary failure instead of
16382 bouncing the mail.
16383 Defaults to @samp{#f}.
16384 @end deftypevr
16385
16386 @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
16387 Binary to use for sending mails.
16388 Defaults to @samp{"/usr/sbin/sendmail"}.
16389 @end deftypevr
16390
16391 @deftypevr {@code{dovecot-configuration} parameter} string submission-host
16392 If non-empty, send mails via this SMTP host[:port] instead of
16393 sendmail.
16394 Defaults to @samp{""}.
16395 @end deftypevr
16396
16397 @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
16398 Subject: header to use for rejection mails. You can use the same
16399 variables as for @samp{rejection-reason} below.
16400 Defaults to @samp{"Rejected: %s"}.
16401 @end deftypevr
16402
16403 @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
16404 Human readable error message for rejection mails. You can use
16405 variables:
16406
16407 @table @code
16408 @item %n
16409 CRLF
16410 @item %r
16411 reason
16412 @item %s
16413 original subject
16414 @item %t
16415 recipient
16416 @end table
16417 Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
16418 @end deftypevr
16419
16420 @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
16421 Delimiter character between local-part and detail in email
16422 address.
16423 Defaults to @samp{"+"}.
16424 @end deftypevr
16425
16426 @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
16427 Header where the original recipient address (SMTP's RCPT TO:
16428 address) is taken from if not available elsewhere. With dovecot-lda -a
16429 parameter overrides this. A commonly used header for this is
16430 X-Original-To.
16431 Defaults to @samp{""}.
16432 @end deftypevr
16433
16434 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
16435 Should saving a mail to a nonexistent mailbox automatically create
16436 it?.
16437 Defaults to @samp{#f}.
16438 @end deftypevr
16439
16440 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
16441 Should automatically created mailboxes be also automatically
16442 subscribed?.
16443 Defaults to @samp{#f}.
16444 @end deftypevr
16445
16446 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
16447 Maximum IMAP command line length. Some clients generate very long
16448 command lines with huge mailboxes, so you may need to raise this if you
16449 get "Too long argument" or "IMAP command line too large" errors
16450 often.
16451 Defaults to @samp{64000}.
16452 @end deftypevr
16453
16454 @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
16455 IMAP logout format string:
16456 @table @code
16457 @item %i
16458 total number of bytes read from client
16459 @item %o
16460 total number of bytes sent to client.
16461 @end table
16462 See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
16463 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@}"}.
16464 @end deftypevr
16465
16466 @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
16467 Override the IMAP CAPABILITY response. If the value begins with '+',
16468 add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
16469 Defaults to @samp{""}.
16470 @end deftypevr
16471
16472 @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
16473 How long to wait between "OK Still here" notifications when client
16474 is IDLEing.
16475 Defaults to @samp{"2 mins"}.
16476 @end deftypevr
16477
16478 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
16479 ID field names and values to send to clients. Using * as the value
16480 makes Dovecot use the default value. The following fields have default
16481 values currently: name, version, os, os-version, support-url,
16482 support-email.
16483 Defaults to @samp{""}.
16484 @end deftypevr
16485
16486 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
16487 ID fields sent by client to log. * means everything.
16488 Defaults to @samp{""}.
16489 @end deftypevr
16490
16491 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
16492 Workarounds for various client bugs:
16493
16494 @table @code
16495 @item delay-newmail
16496 Send EXISTS/RECENT new mail notifications only when replying to NOOP and
16497 CHECK commands. Some clients ignore them otherwise, for example OSX
16498 Mail (<v2.1). Outlook Express breaks more badly though, without this it
16499 may show user "Message no longer in server" errors. Note that OE6
16500 still breaks even with this workaround if synchronization is set to
16501 "Headers Only".
16502
16503 @item tb-extra-mailbox-sep
16504 Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
16505 adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
16506 ignore the extra @samp{/} instead of treating it as invalid mailbox name.
16507
16508 @item tb-lsub-flags
16509 Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
16510 This makes Thunderbird realize they aren't selectable and show them
16511 greyed out, instead of only later giving "not selectable" popup error.
16512 @end table
16513 Defaults to @samp{()}.
16514 @end deftypevr
16515
16516 @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
16517 Host allowed in URLAUTH URLs sent by client. "*" allows all.
16518 Defaults to @samp{""}.
16519 @end deftypevr
16520
16521
16522 Whew! Lots of configuration options. The nice thing about it though is
16523 that Guix has a complete interface to Dovecot's configuration
16524 language. This allows not only a nice way to declare configurations,
16525 but also offers reflective capabilities as well: users can write code to
16526 inspect and transform configurations from within Scheme.
16527
16528 However, it could be that you just want to get a @code{dovecot.conf} up
16529 and running. In that case, you can pass an
16530 @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
16531 @code{dovecot-service}. As its name indicates, an opaque configuration
16532 does not have easy reflective capabilities.
16533
16534 Available @code{opaque-dovecot-configuration} fields are:
16535
16536 @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
16537 The dovecot package.
16538 @end deftypevr
16539
16540 @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
16541 The contents of the @code{dovecot.conf}, as a string.
16542 @end deftypevr
16543
16544 For example, if your @code{dovecot.conf} is just the empty string, you
16545 could instantiate a dovecot service like this:
16546
16547 @example
16548 (dovecot-service #:config
16549 (opaque-dovecot-configuration
16550 (string "")))
16551 @end example
16552
16553 @subsubheading OpenSMTPD Service
16554
16555 @deffn {Scheme Variable} opensmtpd-service-type
16556 This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
16557 service, whose value should be an @code{opensmtpd-configuration} object
16558 as in this example:
16559
16560 @example
16561 (service opensmtpd-service-type
16562 (opensmtpd-configuration
16563 (config-file (local-file "./my-smtpd.conf"))))
16564 @end example
16565 @end deffn
16566
16567 @deftp {Data Type} opensmtpd-configuration
16568 Data type representing the configuration of opensmtpd.
16569
16570 @table @asis
16571 @item @code{package} (default: @var{opensmtpd})
16572 Package object of the OpenSMTPD SMTP server.
16573
16574 @item @code{config-file} (default: @var{%default-opensmtpd-file})
16575 File-like object of the OpenSMTPD configuration file to use. By default
16576 it listens on the loopback network interface, and allows for mail from
16577 users and daemons on the local machine, as well as permitting email to
16578 remote servers. Run @command{man smtpd.conf} for more information.
16579
16580 @end table
16581 @end deftp
16582
16583 @subsubheading Exim Service
16584
16585 @cindex mail transfer agent (MTA)
16586 @cindex MTA (mail transfer agent)
16587 @cindex SMTP
16588
16589 @deffn {Scheme Variable} exim-service-type
16590 This is the type of the @uref{https://exim.org, Exim} mail transfer
16591 agent (MTA), whose value should be an @code{exim-configuration} object
16592 as in this example:
16593
16594 @example
16595 (service exim-service-type
16596 (exim-configuration
16597 (config-file (local-file "./my-exim.conf"))))
16598 @end example
16599 @end deffn
16600
16601 In order to use an @code{exim-service-type} service you must also have a
16602 @code{mail-aliases-service-type} service present in your
16603 @code{operating-system} (even if it has no aliases).
16604
16605 @deftp {Data Type} exim-configuration
16606 Data type representing the configuration of exim.
16607
16608 @table @asis
16609 @item @code{package} (default: @var{exim})
16610 Package object of the Exim server.
16611
16612 @item @code{config-file} (default: @code{#f})
16613 File-like object of the Exim configuration file to use. If its value is
16614 @code{#f} then use the default configuration file from the package
16615 provided in @code{package}. The resulting configuration file is loaded
16616 after setting the @code{exim_user} and @code{exim_group} configuration
16617 variables.
16618
16619 @end table
16620 @end deftp
16621
16622 @subsubheading Mail Aliases Service
16623
16624 @cindex email aliases
16625 @cindex aliases, for email addresses
16626
16627 @deffn {Scheme Variable} mail-aliases-service-type
16628 This is the type of the service which provides @code{/etc/aliases},
16629 specifying how to deliver mail to users on this system.
16630
16631 @example
16632 (service mail-aliases-service-type
16633 '(("postmaster" "bob")
16634 ("bob" "bob@@example.com" "bob@@example2.com")))
16635 @end example
16636 @end deffn
16637
16638 The configuration for a @code{mail-aliases-service-type} service is an
16639 association list denoting how to deliver mail that comes to this
16640 system. Each entry is of the form @code{(alias addresses ...)}, with
16641 @code{alias} specifying the local alias and @code{addresses} specifying
16642 where to deliver this user's mail.
16643
16644 The aliases aren't required to exist as users on the local system. In
16645 the above example, there doesn't need to be a @code{postmaster} entry in
16646 the @code{operating-system}'s @code{user-accounts} in order to deliver
16647 the @code{postmaster} mail to @code{bob} (which subsequently would
16648 deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
16649
16650 @subsubheading GNU Mailutils IMAP4 Daemon
16651 @cindex GNU Mailutils IMAP4 Daemon
16652
16653 @deffn {Scheme Variable} imap4d-service-type
16654 This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
16655 mailutils, GNU Mailutils Manual}), whose value should be an
16656 @code{imap4d-configuration} object as in this example:
16657
16658 @example
16659 (service imap4d-service-type
16660 (imap4d-configuration
16661 (config-file (local-file "imap4d.conf"))))
16662 @end example
16663 @end deffn
16664
16665 @deftp {Data Type} imap4d-configuration
16666 Data type representing the configuration of @command{imap4d}.
16667
16668 @table @asis
16669 @item @code{package} (default: @code{mailutils})
16670 The package that provides @command{imap4d}.
16671
16672 @item @code{config-file} (default: @code{%default-imap4d-config-file})
16673 File-like object of the configuration file to use, by default it will listen
16674 on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
16675 Mailutils Manual}, for details.
16676
16677 @end table
16678 @end deftp
16679
16680 @node Messaging Services
16681 @subsection Messaging Services
16682
16683 @cindex messaging
16684 @cindex jabber
16685 @cindex XMPP
16686 The @code{(gnu services messaging)} module provides Guix service
16687 definitions for messaging services: currently only Prosody is supported.
16688
16689 @subsubheading Prosody Service
16690
16691 @deffn {Scheme Variable} prosody-service-type
16692 This is the type for the @uref{https://prosody.im, Prosody XMPP
16693 communication server}. Its value must be a @code{prosody-configuration}
16694 record as in this example:
16695
16696 @example
16697 (service prosody-service-type
16698 (prosody-configuration
16699 (modules-enabled (cons "groups" "mam" %default-modules-enabled))
16700 (int-components
16701 (list
16702 (int-component-configuration
16703 (hostname "conference.example.net")
16704 (plugin "muc")
16705 (mod-muc (mod-muc-configuration)))))
16706 (virtualhosts
16707 (list
16708 (virtualhost-configuration
16709 (domain "example.net"))))))
16710 @end example
16711
16712 See below for details about @code{prosody-configuration}.
16713
16714 @end deffn
16715
16716 By default, Prosody does not need much configuration. Only one
16717 @code{virtualhosts} field is needed: it specifies the domain you wish
16718 Prosody to serve.
16719
16720 You can perform various sanity checks on the generated configuration
16721 with the @code{prosodyctl check} command.
16722
16723 Prosodyctl will also help you to import certificates from the
16724 @code{letsencrypt} directory so that the @code{prosody} user can access
16725 them. See @url{https://prosody.im/doc/letsencrypt}.
16726
16727 @example
16728 prosodyctl --root cert import /etc/letsencrypt/live
16729 @end example
16730
16731 The available configuration parameters follow. Each parameter
16732 definition is preceded by its type; for example, @samp{string-list foo}
16733 indicates that the @code{foo} parameter should be specified as a list of
16734 strings. Types starting with @code{maybe-} denote parameters that won't
16735 show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
16736
16737 There is also a way to specify the configuration as a string, if you
16738 have an old @code{prosody.cfg.lua} file that you want to port over from
16739 some other system; see the end for more details.
16740
16741 The @code{file-object} type designates either a file-like object
16742 (@pxref{G-Expressions, file-like objects}) or a file name.
16743
16744 @c The following documentation was initially generated by
16745 @c (generate-documentation) in (gnu services messaging). Manually maintained
16746 @c documentation is better, so we shouldn't hesitate to edit below as
16747 @c needed. However if the change you want to make to this documentation
16748 @c can be done in an automated way, it's probably easier to change
16749 @c (generate-documentation) than to make it below and have to deal with
16750 @c the churn as Prosody updates.
16751
16752 Available @code{prosody-configuration} fields are:
16753
16754 @deftypevr {@code{prosody-configuration} parameter} package prosody
16755 The Prosody package.
16756 @end deftypevr
16757
16758 @deftypevr {@code{prosody-configuration} parameter} file-name data-path
16759 Location of the Prosody data storage directory. See
16760 @url{https://prosody.im/doc/configure}.
16761 Defaults to @samp{"/var/lib/prosody"}.
16762 @end deftypevr
16763
16764 @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
16765 Additional plugin directories. They are searched in all the specified
16766 paths in order. See @url{https://prosody.im/doc/plugins_directory}.
16767 Defaults to @samp{()}.
16768 @end deftypevr
16769
16770 @deftypevr {@code{prosody-configuration} parameter} file-name certificates
16771 Every virtual host and component needs a certificate so that clients and
16772 servers can securely verify its identity. Prosody will automatically load
16773 certificates/keys from the directory specified here.
16774 Defaults to @samp{"/etc/prosody/certs"}.
16775 @end deftypevr
16776
16777 @deftypevr {@code{prosody-configuration} parameter} string-list admins
16778 This is a list of accounts that are admins for the server. Note that you
16779 must create the accounts separately. See @url{https://prosody.im/doc/admins} and
16780 @url{https://prosody.im/doc/creating_accounts}.
16781 Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
16782 Defaults to @samp{()}.
16783 @end deftypevr
16784
16785 @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
16786 Enable use of libevent for better performance under high load. See
16787 @url{https://prosody.im/doc/libevent}.
16788 Defaults to @samp{#f}.
16789 @end deftypevr
16790
16791 @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
16792 This is the list of modules Prosody will load on startup. It looks for
16793 @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
16794 Documentation on modules can be found at:
16795 @url{https://prosody.im/doc/modules}.
16796 Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
16797 @end deftypevr
16798
16799 @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
16800 @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
16801 should you want to disable them then add them to this list.
16802 Defaults to @samp{()}.
16803 @end deftypevr
16804
16805 @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
16806 Path to a text file where the shared groups are defined. If this path is
16807 empty then @samp{mod_groups} does nothing. See
16808 @url{https://prosody.im/doc/modules/mod_groups}.
16809 Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
16810 @end deftypevr
16811
16812 @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
16813 Disable account creation by default, for security. See
16814 @url{https://prosody.im/doc/creating_accounts}.
16815 Defaults to @samp{#f}.
16816 @end deftypevr
16817
16818 @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
16819 These are the SSL/TLS-related settings. Most of them are disabled so to
16820 use Prosody's defaults. If you do not completely understand these options, do
16821 not add them to your config, it is easy to lower the security of your server
16822 using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
16823
16824 Available @code{ssl-configuration} fields are:
16825
16826 @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
16827 This determines what handshake to use.
16828 @end deftypevr
16829
16830 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
16831 Path to your private key file.
16832 @end deftypevr
16833
16834 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
16835 Path to your certificate file.
16836 @end deftypevr
16837
16838 @deftypevr {@code{ssl-configuration} parameter} file-object capath
16839 Path to directory containing root certificates that you wish Prosody to
16840 trust when verifying the certificates of remote servers.
16841 Defaults to @samp{"/etc/ssl/certs"}.
16842 @end deftypevr
16843
16844 @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
16845 Path to a file containing root certificates that you wish Prosody to trust.
16846 Similar to @code{capath} but with all certificates concatenated together.
16847 @end deftypevr
16848
16849 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
16850 A list of verification options (these mostly map to OpenSSL's
16851 @code{set_verify()} flags).
16852 @end deftypevr
16853
16854 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
16855 A list of general options relating to SSL/TLS. These map to OpenSSL's
16856 @code{set_options()}. For a full list of options available in LuaSec, see the
16857 LuaSec source.
16858 @end deftypevr
16859
16860 @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
16861 How long a chain of certificate authorities to check when looking for a
16862 trusted root certificate.
16863 @end deftypevr
16864
16865 @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
16866 An OpenSSL cipher string. This selects what ciphers Prosody will offer to
16867 clients, and in what order.
16868 @end deftypevr
16869
16870 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
16871 A path to a file containing parameters for Diffie-Hellman key exchange. You
16872 can create such a file with:
16873 @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
16874 @end deftypevr
16875
16876 @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
16877 Curve for Elliptic curve Diffie-Hellman. Prosody's default is
16878 @samp{"secp384r1"}.
16879 @end deftypevr
16880
16881 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
16882 A list of "extra" verification options.
16883 @end deftypevr
16884
16885 @deftypevr {@code{ssl-configuration} parameter} maybe-string password
16886 Password for encrypted private keys.
16887 @end deftypevr
16888
16889 @end deftypevr
16890
16891 @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
16892 Whether to force all client-to-server connections to be encrypted or not.
16893 See @url{https://prosody.im/doc/modules/mod_tls}.
16894 Defaults to @samp{#f}.
16895 @end deftypevr
16896
16897 @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
16898 Set of mechanisms that will never be offered. See
16899 @url{https://prosody.im/doc/modules/mod_saslauth}.
16900 Defaults to @samp{("DIGEST-MD5")}.
16901 @end deftypevr
16902
16903 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
16904 Whether to force all server-to-server connections to be encrypted or not.
16905 See @url{https://prosody.im/doc/modules/mod_tls}.
16906 Defaults to @samp{#f}.
16907 @end deftypevr
16908
16909 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
16910 Whether to require encryption and certificate authentication. This
16911 provides ideal security, but requires servers you communicate with to support
16912 encryption AND present valid, trusted certificates. See
16913 @url{https://prosody.im/doc/s2s#security}.
16914 Defaults to @samp{#f}.
16915 @end deftypevr
16916
16917 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
16918 Many servers don't support encryption or have invalid or self-signed
16919 certificates. You can list domains here that will not be required to
16920 authenticate using certificates. They will be authenticated using DNS. See
16921 @url{https://prosody.im/doc/s2s#security}.
16922 Defaults to @samp{()}.
16923 @end deftypevr
16924
16925 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
16926 Even if you leave @code{s2s-secure-auth?} disabled, you can still require
16927 valid certificates for some domains by specifying a list here. See
16928 @url{https://prosody.im/doc/s2s#security}.
16929 Defaults to @samp{()}.
16930 @end deftypevr
16931
16932 @deftypevr {@code{prosody-configuration} parameter} string authentication
16933 Select the authentication backend to use. The default provider stores
16934 passwords in plaintext and uses Prosody's configured data storage to store the
16935 authentication data. If you do not trust your server please see
16936 @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
16937 about using the hashed backend. See also
16938 @url{https://prosody.im/doc/authentication}
16939 Defaults to @samp{"internal_plain"}.
16940 @end deftypevr
16941
16942 @deftypevr {@code{prosody-configuration} parameter} maybe-string log
16943 Set logging options. Advanced logging configuration is not yet supported
16944 by the Prosody service. See @url{https://prosody.im/doc/logging}.
16945 Defaults to @samp{"*syslog"}.
16946 @end deftypevr
16947
16948 @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
16949 File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
16950 Defaults to @samp{"/var/run/prosody/prosody.pid"}.
16951 @end deftypevr
16952
16953 @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
16954 Maximum allowed size of the HTTP body (in bytes).
16955 @end deftypevr
16956
16957 @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
16958 Some modules expose their own URL in various ways. This URL is built
16959 from the protocol, host and port used. If Prosody sits behind a proxy, the
16960 public URL will be @code{http-external-url} instead. See
16961 @url{https://prosody.im/doc/http#external_url}.
16962 @end deftypevr
16963
16964 @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
16965 A host in Prosody is a domain on which user accounts can be created. For
16966 example if you want your users to have addresses like
16967 @samp{"john.smith@@example.com"} then you need to add a host
16968 @samp{"example.com"}. All options in this list will apply only to this host.
16969
16970 Note: the name "virtual" host is used in configuration to avoid confusion with
16971 the actual physical host that Prosody is installed on. A single Prosody
16972 instance can serve many domains, each one defined as a VirtualHost entry in
16973 Prosody's configuration. Conversely a server that hosts a single domain would
16974 have just one VirtualHost entry.
16975
16976 See @url{https://prosody.im/doc/configure#virtual_host_settings}.
16977
16978 Available @code{virtualhost-configuration} fields are:
16979
16980 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:
16981 @deftypevr {@code{virtualhost-configuration} parameter} string domain
16982 Domain you wish Prosody to serve.
16983 @end deftypevr
16984
16985 @end deftypevr
16986
16987 @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
16988 Components are extra services on a server which are available to clients,
16989 usually on a subdomain of the main server (such as
16990 @samp{"mycomponent.example.com"}). Example components might be chatroom
16991 servers, user directories, or gateways to other protocols.
16992
16993 Internal components are implemented with Prosody-specific plugins. To add an
16994 internal component, you simply fill the hostname field, and the plugin you wish
16995 to use for the component.
16996
16997 See @url{https://prosody.im/doc/components}.
16998 Defaults to @samp{()}.
16999
17000 Available @code{int-component-configuration} fields are:
17001
17002 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:
17003 @deftypevr {@code{int-component-configuration} parameter} string hostname
17004 Hostname of the component.
17005 @end deftypevr
17006
17007 @deftypevr {@code{int-component-configuration} parameter} string plugin
17008 Plugin you wish to use for the component.
17009 @end deftypevr
17010
17011 @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
17012 Multi-user chat (MUC) is Prosody's module for allowing you to create
17013 hosted chatrooms/conferences for XMPP users.
17014
17015 General information on setting up and using multi-user chatrooms can be found
17016 in the "Chatrooms" documentation (@url{https://prosody.im/doc/chatrooms}),
17017 which you should read if you are new to XMPP chatrooms.
17018
17019 See also @url{https://prosody.im/doc/modules/mod_muc}.
17020
17021 Available @code{mod-muc-configuration} fields are:
17022
17023 @deftypevr {@code{mod-muc-configuration} parameter} string name
17024 The name to return in service discovery responses.
17025 Defaults to @samp{"Prosody Chatrooms"}.
17026 @end deftypevr
17027
17028 @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
17029 If @samp{#t}, this will only allow admins to create new chatrooms.
17030 Otherwise anyone can create a room. The value @samp{"local"} restricts room
17031 creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
17032 can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
17033 restricts to service administrators only.
17034 Defaults to @samp{#f}.
17035 @end deftypevr
17036
17037 @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
17038 Maximum number of history messages that will be sent to the member that has
17039 just joined the room.
17040 Defaults to @samp{20}.
17041 @end deftypevr
17042
17043 @end deftypevr
17044
17045 @end deftypevr
17046
17047 @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
17048 External components use XEP-0114, which most standalone components
17049 support. To add an external component, you simply fill the hostname field. See
17050 @url{https://prosody.im/doc/components}.
17051 Defaults to @samp{()}.
17052
17053 Available @code{ext-component-configuration} fields are:
17054
17055 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:
17056 @deftypevr {@code{ext-component-configuration} parameter} string component-secret
17057 Password which the component will use to log in.
17058 @end deftypevr
17059
17060 @deftypevr {@code{ext-component-configuration} parameter} string hostname
17061 Hostname of the component.
17062 @end deftypevr
17063
17064 @end deftypevr
17065
17066 @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
17067 Port(s) Prosody listens on for component connections.
17068 Defaults to @samp{(5347)}.
17069 @end deftypevr
17070
17071 @deftypevr {@code{prosody-configuration} parameter} string component-interface
17072 Interface Prosody listens on for component connections.
17073 Defaults to @samp{"127.0.0.1"}.
17074 @end deftypevr
17075
17076 @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
17077 Raw content that will be added to the configuration file.
17078 @end deftypevr
17079
17080 It could be that you just want to get a @code{prosody.cfg.lua}
17081 up and running. In that case, you can pass an
17082 @code{opaque-prosody-configuration} record as the value of
17083 @code{prosody-service-type}. As its name indicates, an opaque configuration
17084 does not have easy reflective capabilities.
17085 Available @code{opaque-prosody-configuration} fields are:
17086
17087 @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
17088 The prosody package.
17089 @end deftypevr
17090
17091 @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
17092 The contents of the @code{prosody.cfg.lua} to use.
17093 @end deftypevr
17094
17095 For example, if your @code{prosody.cfg.lua} is just the empty
17096 string, you could instantiate a prosody service like this:
17097
17098 @example
17099 (service prosody-service-type
17100 (opaque-prosody-configuration
17101 (prosody.cfg.lua "")))
17102 @end example
17103
17104 @c end of Prosody auto-generated documentation
17105
17106 @subsubheading BitlBee Service
17107
17108 @cindex IRC (Internet Relay Chat)
17109 @cindex IRC gateway
17110 @url{http://bitlbee.org,BitlBee} is a gateway that provides an IRC
17111 interface to a variety of messaging protocols such as XMPP.
17112
17113 @defvr {Scheme Variable} bitlbee-service-type
17114 This is the service type for the @url{http://bitlbee.org,BitlBee} IRC
17115 gateway daemon. Its value is a @code{bitlbee-configuration} (see
17116 below).
17117
17118 To have BitlBee listen on port 6667 on localhost, add this line to your
17119 services:
17120
17121 @example
17122 (service bitlbee-service-type)
17123 @end example
17124 @end defvr
17125
17126 @deftp {Data Type} bitlbee-configuration
17127 This is the configuration for BitlBee, with the following fields:
17128
17129 @table @asis
17130 @item @code{interface} (default: @code{"127.0.0.1"})
17131 @itemx @code{port} (default: @code{6667})
17132 Listen on the network interface corresponding to the IP address
17133 specified in @var{interface}, on @var{port}.
17134
17135 When @var{interface} is @code{127.0.0.1}, only local clients can
17136 connect; when it is @code{0.0.0.0}, connections can come from any
17137 networking interface.
17138
17139 @item @code{package} (default: @code{bitlbee})
17140 The BitlBee package to use.
17141
17142 @item @code{plugins} (default: @code{'()})
17143 List of plugin packages to use---e.g., @code{bitlbee-discord}.
17144
17145 @item @code{extra-settings} (default: @code{""})
17146 Configuration snippet added as-is to the BitlBee configuration file.
17147 @end table
17148 @end deftp
17149
17150 @subsubheading Quassel Service
17151
17152 @cindex IRC (Internet Relay Chat)
17153 @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
17154 meaning that one or more clients can attach to and detach from the
17155 central core.
17156
17157 @defvr {Scheme Variable} quassel-service-type
17158 This is the service type for the @url{https://quassel-irc.org/,Quassel}
17159 IRC backend daemon. Its value is a @code{quassel-configuration}
17160 (see below).
17161 @end defvr
17162
17163 @deftp {Data Type} quassel-configuration
17164 This is the configuration for Quassel, with the following fields:
17165
17166 @table @asis
17167 @item @code{quassel} (default: @code{quassel})
17168 The Quassel package to use.
17169
17170 @item @code{interface} (default: @code{"::,0.0.0.0"})
17171 @item @code{port} (default: @code{4242})
17172 Listen on the network interface(s) corresponding to the IPv4 or IPv6
17173 interfaces specified in the comma delimited @var{interface}, on
17174 @var{port}.
17175
17176 @item @code{loglevel} (default: @code{"Info"})
17177 The level of logging desired. Accepted values are Debug, Info, Warning
17178 and Error.
17179 @end table
17180 @end deftp
17181
17182 @node Telephony Services
17183 @subsection Telephony Services
17184
17185 @cindex Murmur (VoIP server)
17186 @cindex VoIP server
17187 This section describes how to set up and run a Murmur server. Murmur is
17188 the server of the @uref{https://mumble.info, Mumble} voice-over-IP
17189 (VoIP) suite.
17190
17191 @deftp {Data Type} murmur-configuration
17192 The service type for the Murmur server. An example configuration can
17193 look like this:
17194
17195 @example
17196 (service murmur-service-type
17197 (murmur-configuration
17198 (welcome-text
17199 "Welcome to this Mumble server running on Guix!")
17200 (cert-required? #t) ;disallow text password logins
17201 (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
17202 (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
17203 @end example
17204
17205 After reconfiguring your system, you can manually set the murmur @code{SuperUser}
17206 password with the command that is printed during the activation phase.
17207
17208 It is recommended to register a normal Mumble user account
17209 and grant it admin or moderator rights.
17210 You can use the @code{mumble} client to
17211 login as new normal user, register yourself, and log out.
17212 For the next step login with the name @code{SuperUser} use
17213 the @code{SuperUser} password that you set previously,
17214 and grant your newly registered mumble user administrator or moderator
17215 rights and create some channels.
17216
17217 Available @code{murmur-configuration} fields are:
17218
17219 @table @asis
17220 @item @code{package} (default: @code{mumble})
17221 Package that contains @code{bin/murmurd}.
17222
17223 @item @code{user} (default: @code{"murmur"})
17224 User who will run the Murmur server.
17225
17226 @item @code{group} (default: @code{"murmur"})
17227 Group of the user who will run the murmur server.
17228
17229 @item @code{port} (default: @code{64738})
17230 Port on which the server will listen.
17231
17232 @item @code{welcome-text} (default: @code{""})
17233 Welcome text sent to clients when they connect.
17234
17235 @item @code{server-password} (default: @code{""})
17236 Password the clients have to enter in order to connect.
17237
17238 @item @code{max-users} (default: @code{100})
17239 Maximum of users that can be connected to the server at once.
17240
17241 @item @code{max-user-bandwidth} (default: @code{#f})
17242 Maximum voice traffic a user can send per second.
17243
17244 @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
17245 File name of the sqlite database.
17246 The service's user will become the owner of the directory.
17247
17248 @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
17249 File name of the log file.
17250 The service's user will become the owner of the directory.
17251
17252 @item @code{autoban-attempts} (default: @code{10})
17253 Maximum number of logins a user can make in @code{autoban-timeframe}
17254 without getting auto banned for @code{autoban-time}.
17255
17256 @item @code{autoban-timeframe} (default: @code{120})
17257 Timeframe for autoban in seconds.
17258
17259 @item @code{autoban-time} (default: @code{300})
17260 Amount of time in seconds for which a client gets banned
17261 when violating the autoban limits.
17262
17263 @item @code{opus-threshold} (default: @code{100})
17264 Percentage of clients that need to support opus
17265 before switching over to opus audio codec.
17266
17267 @item @code{channel-nesting-limit} (default: @code{10})
17268 How deep channels can be nested at maximum.
17269
17270 @item @code{channelname-regex} (default: @code{#f})
17271 A string in form of a Qt regular expression that channel names must conform to.
17272
17273 @item @code{username-regex} (default: @code{#f})
17274 A string in form of a Qt regular expression that user names must conform to.
17275
17276 @item @code{text-message-length} (default: @code{5000})
17277 Maximum size in bytes that a user can send in one text chat message.
17278
17279 @item @code{image-message-length} (default: @code{(* 128 1024)})
17280 Maximum size in bytes that a user can send in one image message.
17281
17282 @item @code{cert-required?} (default: @code{#f})
17283 If it is set to @code{#t} clients that use weak password authentification
17284 will not be accepted. Users must have completed the certificate wizard to join.
17285
17286 @item @code{remember-channel?} (default: @code{#f})
17287 Should murmur remember the last channel each user was in when they disconnected
17288 and put them into the remembered channel when they rejoin.
17289
17290 @item @code{allow-html?} (default: @code{#f})
17291 Should html be allowed in text messages, user comments, and channel descriptions.
17292
17293 @item @code{allow-ping?} (default: @code{#f})
17294 Setting to true exposes the current user count, the maximum user count, and
17295 the server's maximum bandwidth per client to unauthenticated users. In the
17296 Mumble client, this information is shown in the Connect dialog.
17297
17298 Disabling this setting will prevent public listing of the server.
17299
17300 @item @code{bonjour?} (default: @code{#f})
17301 Should the server advertise itself in the local network through the bonjour protocol.
17302
17303 @item @code{send-version?} (default: @code{#f})
17304 Should the murmur server version be exposed in ping requests.
17305
17306 @item @code{log-days} (default: @code{31})
17307 Murmur also stores logs in the database, which are accessible via RPC.
17308 The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
17309 or -1 to disable logging to the database.
17310
17311 @item @code{obfuscate-ips?} (default: @code{#t})
17312 Should logged ips be obfuscated to protect the privacy of users.
17313
17314 @item @code{ssl-cert} (default: @code{#f})
17315 File name of the SSL/TLS certificate used for encrypted connections.
17316
17317 @example
17318 (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
17319 @end example
17320 @item @code{ssl-key} (default: @code{#f})
17321 Filepath to the ssl private key used for encrypted connections.
17322 @example
17323 (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
17324 @end example
17325
17326 @item @code{ssl-dh-params} (default: @code{#f})
17327 File name of a PEM-encoded file with Diffie-Hellman parameters
17328 for the SSL/TLS encryption. Alternatively you set it to
17329 @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
17330 or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
17331
17332 @item @code{ssl-ciphers} (default: @code{#f})
17333 The @code{ssl-ciphers} option chooses the cipher suites to make available for use
17334 in SSL/TLS.
17335
17336 This option is specified using
17337 @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
17338 OpenSSL cipher list notation}.
17339
17340 It is recommended that you try your cipher string using 'openssl ciphers <string>'
17341 before setting it here, to get a feel for which cipher suites you will get.
17342 After setting this option, it is recommend that you inspect your Murmur log
17343 to ensure that Murmur is using the cipher suites that you expected it to.
17344
17345 Note: Changing this option may impact the backwards compatibility of your
17346 Murmur server, and can remove the ability for older Mumble clients to be able
17347 to connect to it.
17348
17349 @item @code{public-registration} (default: @code{#f})
17350 Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
17351
17352 You can optionally register your server in the public server list that the
17353 @code{mumble} client shows on startup.
17354 You cannot register your server if you have set a @code{server-password},
17355 or set @code{allow-ping} to @code{#f}.
17356
17357 It might take a few hours until it shows up in the public list.
17358
17359 @item @code{file} (default: @code{#f})
17360 Optional alternative override for this configuration.
17361 @end table
17362 @end deftp
17363
17364 @deftp {Data Type} murmur-public-registration-configuration
17365 Configuration for public registration of a murmur service.
17366
17367 @table @asis
17368 @item @code{name}
17369 This is a display name for your server. Not to be confused with the hostname.
17370
17371 @item @code{password}
17372 A password to identify your registration.
17373 Subsequent updates will need the same password. Don't lose your password.
17374
17375 @item @code{url}
17376 This should be a @code{http://} or @code{https://} link to your web
17377 site.
17378
17379 @item @code{hostname} (default: @code{#f})
17380 By default your server will be listed by its IP address.
17381 If it is set your server will be linked by this host name instead.
17382 @end table
17383 @end deftp
17384
17385
17386
17387 @node Monitoring Services
17388 @subsection Monitoring Services
17389
17390 @subsubheading Tailon Service
17391
17392 @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
17393 viewing and searching log files.
17394
17395 The following example will configure the service with default values.
17396 By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
17397
17398 @example
17399 (service tailon-service-type)
17400 @end example
17401
17402 The following example customises more of the Tailon configuration,
17403 adding @command{sed} to the list of allowed commands.
17404
17405 @example
17406 (service tailon-service-type
17407 (tailon-configuration
17408 (config-file
17409 (tailon-configuration-file
17410 (allowed-commands '("tail" "grep" "awk" "sed"))))))
17411 @end example
17412
17413
17414 @deftp {Data Type} tailon-configuration
17415 Data type representing the configuration of Tailon.
17416 This type has the following parameters:
17417
17418 @table @asis
17419 @item @code{config-file} (default: @code{(tailon-configuration-file)})
17420 The configuration file to use for Tailon. This can be set to a
17421 @dfn{tailon-configuration-file} record value, or any gexp
17422 (@pxref{G-Expressions}).
17423
17424 For example, to instead use a local file, the @code{local-file} function
17425 can be used:
17426
17427 @example
17428 (service tailon-service-type
17429 (tailon-configuration
17430 (config-file (local-file "./my-tailon.conf"))))
17431 @end example
17432
17433 @item @code{package} (default: @code{tailon})
17434 The tailon package to use.
17435
17436 @end table
17437 @end deftp
17438
17439 @deftp {Data Type} tailon-configuration-file
17440 Data type representing the configuration options for Tailon.
17441 This type has the following parameters:
17442
17443 @table @asis
17444 @item @code{files} (default: @code{(list "/var/log")})
17445 List of files to display. The list can include strings for a single file
17446 or directory, or a list, where the first item is the name of a
17447 subsection, and the remaining items are the files or directories in that
17448 subsection.
17449
17450 @item @code{bind} (default: @code{"localhost:8080"})
17451 Address and port to which Tailon should bind on.
17452
17453 @item @code{relative-root} (default: @code{#f})
17454 URL path to use for Tailon, set to @code{#f} to not use a path.
17455
17456 @item @code{allow-transfers?} (default: @code{#t})
17457 Allow downloading the log files in the web interface.
17458
17459 @item @code{follow-names?} (default: @code{#t})
17460 Allow tailing of not-yet existent files.
17461
17462 @item @code{tail-lines} (default: @code{200})
17463 Number of lines to read initially from each file.
17464
17465 @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
17466 Commands to allow running. By default, @code{sed} is disabled.
17467
17468 @item @code{debug?} (default: @code{#f})
17469 Set @code{debug?} to @code{#t} to show debug messages.
17470
17471 @item @code{wrap-lines} (default: @code{#t})
17472 Initial line wrapping state in the web interface. Set to @code{#t} to
17473 initially wrap lines (the default), or to @code{#f} to initially not
17474 wrap lines.
17475
17476 @item @code{http-auth} (default: @code{#f})
17477 HTTP authentication type to use. Set to @code{#f} to disable
17478 authentication (the default). Supported values are @code{"digest"} or
17479 @code{"basic"}.
17480
17481 @item @code{users} (default: @code{#f})
17482 If HTTP authentication is enabled (see @code{http-auth}), access will be
17483 restricted to the credentials provided here. To configure users, use a
17484 list of pairs, where the first element of the pair is the username, and
17485 the 2nd element of the pair is the password.
17486
17487 @example
17488 (tailon-configuration-file
17489 (http-auth "basic")
17490 (users '(("user1" . "password1")
17491 ("user2" . "password2"))))
17492 @end example
17493
17494 @end table
17495 @end deftp
17496
17497
17498 @subsubheading Darkstat Service
17499 @cindex darkstat
17500 Darkstat is a packet sniffer that captures network traffic, calculates
17501 statistics about usage, and serves reports over HTTP.
17502
17503 @defvar {Scheme Variable} darkstat-service-type
17504 This is the service type for the
17505 @uref{https://unix4lyfe.org/darkstat/, darkstat}
17506 service, its value must be a @code{darkstat-configuration} record as in
17507 this example:
17508
17509 @example
17510 (service darkstat-service-type
17511 (darkstat-configuration
17512 (interface "eno1")))
17513 @end example
17514 @end defvar
17515
17516 @deftp {Data Type} darkstat-configuration
17517 Data type representing the configuration of @command{darkstat}.
17518
17519 @table @asis
17520 @item @code{package} (default: @code{darkstat})
17521 The darkstat package to use.
17522
17523 @item @code{interface}
17524 Capture traffic on the specified network interface.
17525
17526 @item @code{port} (default: @code{"667"})
17527 Bind the web interface to the specified port.
17528
17529 @item @code{bind-address} (default: @code{"127.0.0.1"})
17530 Bind the web interface to the specified address.
17531
17532 @item @code{base} (default: @code{"/"})
17533 Specify the path of the base URL. This can be useful if
17534 @command{darkstat} is accessed via a reverse proxy.
17535
17536 @end table
17537 @end deftp
17538
17539 @subsubheading Prometheus Node Exporter Service
17540
17541 @cindex prometheus-node-exporter
17542 The Prometheus ``node exporter'' makes hardware and operating system statistics
17543 provided by the Linux kernel available for the Prometheus monitoring system.
17544 This service should be deployed on all physical nodes and virtual machines,
17545 where monitoring these statistics is desirable.
17546
17547 @defvar {Scheme variable} prometheus-node-exporter-service-type
17548 This is the service type for the
17549 @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
17550 service, its value must be a @code{prometheus-node-exporter-configuration}
17551 record as in this example:
17552
17553 @example
17554 (service prometheus-node-exporter-service-type
17555 (prometheus-node-exporter-configuration
17556 (web-listen-address ":9100")))
17557 @end example
17558 @end defvar
17559
17560 @deftp {Data Type} prometheus-node-exporter-configuration
17561 Data type representing the configuration of @command{node_exporter}.
17562
17563 @table @asis
17564 @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
17565 The prometheus-node-exporter package to use.
17566
17567 @item @code{web-listen-address} (default: @code{":9100"})
17568 Bind the web interface to the specified address.
17569
17570 @end table
17571 @end deftp
17572
17573 @subsubheading Zabbix server
17574 @cindex zabbix zabbix-server
17575 Zabbix provides monitoring metrics, among others network utilization, CPU load
17576 and disk space consumption:
17577
17578 @itemize
17579 @item High performance, high capacity (able to monitor hundreds of thousands of devices).
17580 @item Auto-discovery of servers and network devices and interfaces.
17581 @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
17582 @item Distributed monitoring with centralized web administration.
17583 @item Native high performance agents.
17584 @item SLA, and ITIL KPI metrics on reporting.
17585 @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
17586 @item Remote command execution through Zabbix proxies.
17587 @end itemize
17588
17589 @c %start of fragment
17590
17591 Available @code{zabbix-server-configuration} fields are:
17592
17593 @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
17594 The zabbix-server package.
17595
17596 @end deftypevr
17597
17598 @deftypevr {@code{zabbix-server-configuration} parameter} string user
17599 User who will run the Zabbix server.
17600
17601 Defaults to @samp{"zabbix"}.
17602
17603 @end deftypevr
17604
17605 @deftypevr {@code{zabbix-server-configuration} parameter} group group
17606 Group who will run the Zabbix server.
17607
17608 Defaults to @samp{"zabbix"}.
17609
17610 @end deftypevr
17611
17612 @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
17613 Database host name.
17614
17615 Defaults to @samp{"127.0.0.1"}.
17616
17617 @end deftypevr
17618
17619 @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
17620 Database name.
17621
17622 Defaults to @samp{"zabbix"}.
17623
17624 @end deftypevr
17625
17626 @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
17627 Database user.
17628
17629 Defaults to @samp{"zabbix"}.
17630
17631 @end deftypevr
17632
17633 @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
17634 Database password. Please, use @code{include-files} with
17635 @code{DBPassword=SECRET} inside a specified file instead.
17636
17637 Defaults to @samp{""}.
17638
17639 @end deftypevr
17640
17641 @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
17642 Database port.
17643
17644 Defaults to @samp{5432}.
17645
17646 @end deftypevr
17647
17648 @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
17649 Specifies where log messages are written to:
17650
17651 @itemize @bullet
17652 @item
17653 @code{system} - syslog.
17654
17655 @item
17656 @code{file} - file specified with @code{log-file} parameter.
17657
17658 @item
17659 @code{console} - standard output.
17660
17661 @end itemize
17662
17663 Defaults to @samp{""}.
17664
17665 @end deftypevr
17666
17667 @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
17668 Log file name for @code{log-type} @code{file} parameter.
17669
17670 Defaults to @samp{"/var/log/zabbix/server.log"}.
17671
17672 @end deftypevr
17673
17674 @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
17675 Name of PID file.
17676
17677 Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
17678
17679 @end deftypevr
17680
17681 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
17682 The location of certificate authority (CA) files for SSL server
17683 certificate verification.
17684
17685 Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
17686
17687 @end deftypevr
17688
17689 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
17690 Location of SSL client certificates.
17691
17692 Defaults to @samp{"/etc/ssl/certs"}.
17693
17694 @end deftypevr
17695
17696 @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
17697 Extra options will be appended to Zabbix server configuration file.
17698
17699 Defaults to @samp{""}.
17700
17701 @end deftypevr
17702
17703 @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
17704 You may include individual files or all files in a directory in the
17705 configuration file.
17706
17707 Defaults to @samp{()}.
17708
17709 @end deftypevr
17710
17711 @c %end of fragment
17712
17713 @subsubheading Zabbix agent
17714 @cindex zabbix zabbix-agent
17715
17716 Zabbix agent gathers information for Zabbix server.
17717
17718 @c %start of fragment
17719
17720 Available @code{zabbix-agent-configuration} fields are:
17721
17722 @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
17723 The zabbix-agent package.
17724
17725 @end deftypevr
17726
17727 @deftypevr {@code{zabbix-agent-configuration} parameter} string user
17728 User who will run the Zabbix agent.
17729
17730 Defaults to @samp{"zabbix"}.
17731
17732 @end deftypevr
17733
17734 @deftypevr {@code{zabbix-agent-configuration} parameter} group group
17735 Group who will run the Zabbix agent.
17736
17737 Defaults to @samp{"zabbix"}.
17738
17739 @end deftypevr
17740
17741 @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
17742 Unique, case sensitive hostname which is required for active checks and
17743 must match hostname as configured on the server.
17744
17745 Defaults to @samp{"Zabbix server"}.
17746
17747 @end deftypevr
17748
17749 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
17750 Specifies where log messages are written to:
17751
17752 @itemize @bullet
17753 @item
17754 @code{system} - syslog.
17755
17756 @item
17757 @code{file} - file specified with @code{log-file} parameter.
17758
17759 @item
17760 @code{console} - standard output.
17761
17762 @end itemize
17763
17764 Defaults to @samp{""}.
17765
17766 @end deftypevr
17767
17768 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
17769 Log file name for @code{log-type} @code{file} parameter.
17770
17771 Defaults to @samp{"/var/log/zabbix/agent.log"}.
17772
17773 @end deftypevr
17774
17775 @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
17776 Name of PID file.
17777
17778 Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
17779
17780 @end deftypevr
17781
17782 @deftypevr {@code{zabbix-agent-configuration} parameter} list server
17783 List of IP addresses, optionally in CIDR notation, or hostnames of
17784 Zabbix servers and Zabbix proxies. Incoming connections will be
17785 accepted only from the hosts listed here.
17786
17787 Defaults to @samp{("127.0.0.1")}.
17788
17789 @end deftypevr
17790
17791 @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
17792 List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
17793 proxies for active checks. If port is not specified, default port is
17794 used. If this parameter is not specified, active checks are disabled.
17795
17796 Defaults to @samp{("127.0.0.1")}.
17797
17798 @end deftypevr
17799
17800 @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
17801 Extra options will be appended to Zabbix server configuration file.
17802
17803 Defaults to @samp{""}.
17804
17805 @end deftypevr
17806
17807 @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
17808 You may include individual files or all files in a directory in the
17809 configuration file.
17810
17811 Defaults to @samp{()}.
17812
17813 @end deftypevr
17814
17815 @c %end of fragment
17816
17817 @subsubheading Zabbix front-end
17818 @cindex zabbix zabbix-front-end
17819
17820 This service provides a WEB interface to Zabbix server.
17821
17822 @c %start of fragment
17823
17824 Available @code{zabbix-front-end-configuration} fields are:
17825
17826 @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
17827 NGINX configuration.
17828
17829 @end deftypevr
17830
17831 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
17832 Database host name.
17833
17834 Defaults to @samp{"localhost"}.
17835
17836 @end deftypevr
17837
17838 @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
17839 Database port.
17840
17841 Defaults to @samp{5432}.
17842
17843 @end deftypevr
17844
17845 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
17846 Database name.
17847
17848 Defaults to @samp{"zabbix"}.
17849
17850 @end deftypevr
17851
17852 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
17853 Database user.
17854
17855 Defaults to @samp{"zabbix"}.
17856
17857 @end deftypevr
17858
17859 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
17860 Database password. Please, use @code{db-secret-file} instead.
17861
17862 Defaults to @samp{""}.
17863
17864 @end deftypevr
17865
17866 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
17867 Secret file which will be appended to @file{zabbix.conf.php} file. This
17868 file contains credentials for use by Zabbix front-end. You are expected
17869 to create it manually.
17870
17871 Defaults to @samp{""}.
17872
17873 @end deftypevr
17874
17875 @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
17876 Zabbix server hostname.
17877
17878 Defaults to @samp{"localhost"}.
17879
17880 @end deftypevr
17881
17882 @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
17883 Zabbix server port.
17884
17885 Defaults to @samp{10051}.
17886
17887 @end deftypevr
17888
17889
17890 @c %end of fragment
17891
17892 @node Kerberos Services
17893 @subsection Kerberos Services
17894 @cindex Kerberos
17895
17896 The @code{(gnu services kerberos)} module provides services relating to
17897 the authentication protocol @dfn{Kerberos}.
17898
17899 @subsubheading Krb5 Service
17900
17901 Programs using a Kerberos client library normally
17902 expect a configuration file in @file{/etc/krb5.conf}.
17903 This service generates such a file from a definition provided in the
17904 operating system declaration.
17905 It does not cause any daemon to be started.
17906
17907 No ``keytab'' files are provided by this service---you must explicitly create them.
17908 This service is known to work with the MIT client library, @code{mit-krb5}.
17909 Other implementations have not been tested.
17910
17911 @defvr {Scheme Variable} krb5-service-type
17912 A service type for Kerberos 5 clients.
17913 @end defvr
17914
17915 @noindent
17916 Here is an example of its use:
17917 @lisp
17918 (service krb5-service-type
17919 (krb5-configuration
17920 (default-realm "EXAMPLE.COM")
17921 (allow-weak-crypto? #t)
17922 (realms (list
17923 (krb5-realm
17924 (name "EXAMPLE.COM")
17925 (admin-server "groucho.example.com")
17926 (kdc "karl.example.com"))
17927 (krb5-realm
17928 (name "ARGRX.EDU")
17929 (admin-server "kerb-admin.argrx.edu")
17930 (kdc "keys.argrx.edu"))))))
17931 @end lisp
17932
17933 @noindent
17934 This example provides a Kerberos@tie{}5 client configuration which:
17935 @itemize
17936 @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
17937 of which have distinct administration servers and key distribution centers;
17938 @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
17939 specified by clients;
17940 @item Accepts services which only support encryption types known to be weak.
17941 @end itemize
17942
17943 The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
17944 Only the most commonly used ones are described here.
17945 For a full list, and more detailed explanation of each, see the MIT
17946 @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
17947 documentation.
17948
17949
17950 @deftp {Data Type} krb5-realm
17951 @cindex realm, kerberos
17952 @table @asis
17953 @item @code{name}
17954 This field is a string identifying the name of the realm.
17955 A common convention is to use the fully qualified DNS name of your organization,
17956 converted to upper case.
17957
17958 @item @code{admin-server}
17959 This field is a string identifying the host where the administration server is
17960 running.
17961
17962 @item @code{kdc}
17963 This field is a string identifying the key distribution center
17964 for the realm.
17965 @end table
17966 @end deftp
17967
17968 @deftp {Data Type} krb5-configuration
17969
17970 @table @asis
17971 @item @code{allow-weak-crypto?} (default: @code{#f})
17972 If this flag is @code{#t} then services which only offer encryption algorithms
17973 known to be weak will be accepted.
17974
17975 @item @code{default-realm} (default: @code{#f})
17976 This field should be a string identifying the default Kerberos
17977 realm for the client.
17978 You should set this field to the name of your Kerberos realm.
17979 If this value is @code{#f}
17980 then a realm must be specified with every Kerberos principal when invoking programs
17981 such as @command{kinit}.
17982
17983 @item @code{realms}
17984 This should be a non-empty list of @code{krb5-realm} objects, which clients may
17985 access.
17986 Normally, one of them will have a @code{name} field matching the @code{default-realm}
17987 field.
17988 @end table
17989 @end deftp
17990
17991
17992 @subsubheading PAM krb5 Service
17993 @cindex pam-krb5
17994
17995 The @code{pam-krb5} service allows for login authentication and password
17996 management via Kerberos.
17997 You will need this service if you want PAM enabled applications to authenticate
17998 users using Kerberos.
17999
18000 @defvr {Scheme Variable} pam-krb5-service-type
18001 A service type for the Kerberos 5 PAM module.
18002 @end defvr
18003
18004 @deftp {Data Type} pam-krb5-configuration
18005 Data type representing the configuration of the Kerberos 5 PAM module
18006 This type has the following parameters:
18007 @table @asis
18008 @item @code{pam-krb5} (default: @code{pam-krb5})
18009 The pam-krb5 package to use.
18010
18011 @item @code{minimum-uid} (default: @code{1000})
18012 The smallest user ID for which Kerberos authentications should be attempted.
18013 Local accounts with lower values will silently fail to authenticate.
18014 @end table
18015 @end deftp
18016
18017
18018 @node LDAP Services
18019 @subsection LDAP Services
18020 @cindex LDAP
18021 @cindex nslcd, LDAP service
18022
18023 The @code{(gnu services authentication)} module provides the
18024 @code{nslcd-service-type}, which can be used to authenticate against an LDAP
18025 server. In addition to configuring the service itself, you may want to add
18026 @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
18027 Switch} for detailed information.
18028
18029 Here is a simple operating system declaration with a default configuration of
18030 the @code{nslcd-service-type} and a Name Service Switch configuration that
18031 consults the @code{ldap} name service last:
18032
18033 @example
18034 (use-service-modules authentication)
18035 (use-modules (gnu system nss))
18036 ...
18037 (operating-system
18038 ...
18039 (services
18040 (cons*
18041 (service nslcd-service-type)
18042 (service dhcp-client-service-type)
18043 %base-services))
18044 (name-service-switch
18045 (let ((services (list (name-service (name "db"))
18046 (name-service (name "files"))
18047 (name-service (name "ldap")))))
18048 (name-service-switch
18049 (inherit %mdns-host-lookup-nss)
18050 (password services)
18051 (shadow services)
18052 (group services)
18053 (netgroup services)
18054 (gshadow services)))))
18055 @end example
18056
18057 @c %start of generated documentation for nslcd-configuration
18058
18059 Available @code{nslcd-configuration} fields are:
18060
18061 @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
18062 The @code{nss-pam-ldapd} package to use.
18063
18064 @end deftypevr
18065
18066 @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
18067 The number of threads to start that can handle requests and perform LDAP
18068 queries. Each thread opens a separate connection to the LDAP server.
18069 The default is to start 5 threads.
18070
18071 Defaults to @samp{disabled}.
18072
18073 @end deftypevr
18074
18075 @deftypevr {@code{nslcd-configuration} parameter} string uid
18076 This specifies the user id with which the daemon should be run.
18077
18078 Defaults to @samp{"nslcd"}.
18079
18080 @end deftypevr
18081
18082 @deftypevr {@code{nslcd-configuration} parameter} string gid
18083 This specifies the group id with which the daemon should be run.
18084
18085 Defaults to @samp{"nslcd"}.
18086
18087 @end deftypevr
18088
18089 @deftypevr {@code{nslcd-configuration} parameter} log-option log
18090 This option controls the way logging is done via a list containing
18091 SCHEME and LEVEL. The SCHEME argument may either be the symbols "none"
18092 or "syslog", or an absolute file name. The LEVEL argument is optional
18093 and specifies the log level. The log level may be one of the following
18094 symbols: "crit", "error", "warning", "notice", "info" or "debug". All
18095 messages with the specified log level or higher are logged.
18096
18097 Defaults to @samp{("/var/log/nslcd" info)}.
18098
18099 @end deftypevr
18100
18101 @deftypevr {@code{nslcd-configuration} parameter} list uri
18102 The list of LDAP server URIs. Normally, only the first server will be
18103 used with the following servers as fall-back.
18104
18105 Defaults to @samp{("ldap://localhost:389/")}.
18106
18107 @end deftypevr
18108
18109 @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
18110 The version of the LDAP protocol to use. The default is to use the
18111 maximum version supported by the LDAP library.
18112
18113 Defaults to @samp{disabled}.
18114
18115 @end deftypevr
18116
18117 @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
18118 Specifies the distinguished name with which to bind to the directory
18119 server for lookups. The default is to bind anonymously.
18120
18121 Defaults to @samp{disabled}.
18122
18123 @end deftypevr
18124
18125 @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
18126 Specifies the credentials with which to bind. This option is only
18127 applicable when used with binddn.
18128
18129 Defaults to @samp{disabled}.
18130
18131 @end deftypevr
18132
18133 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
18134 Specifies the distinguished name to use when the root user tries to
18135 modify a user's password using the PAM module.
18136
18137 Defaults to @samp{disabled}.
18138
18139 @end deftypevr
18140
18141 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
18142 Specifies the credentials with which to bind if the root user tries to
18143 change a user's password. This option is only applicable when used with
18144 rootpwmoddn
18145
18146 Defaults to @samp{disabled}.
18147
18148 @end deftypevr
18149
18150 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
18151 Specifies the SASL mechanism to be used when performing SASL
18152 authentication.
18153
18154 Defaults to @samp{disabled}.
18155
18156 @end deftypevr
18157
18158 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
18159 Specifies the SASL realm to be used when performing SASL authentication.
18160
18161 Defaults to @samp{disabled}.
18162
18163 @end deftypevr
18164
18165 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
18166 Specifies the authentication identity to be used when performing SASL
18167 authentication.
18168
18169 Defaults to @samp{disabled}.
18170
18171 @end deftypevr
18172
18173 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
18174 Specifies the authorization identity to be used when performing SASL
18175 authentication.
18176
18177 Defaults to @samp{disabled}.
18178
18179 @end deftypevr
18180
18181 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
18182 Determines whether the LDAP server host name should be canonicalised. If
18183 this is enabled the LDAP library will do a reverse host name lookup. By
18184 default, it is left up to the LDAP library whether this check is
18185 performed or not.
18186
18187 Defaults to @samp{disabled}.
18188
18189 @end deftypevr
18190
18191 @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
18192 Set the name for the GSS-API Kerberos credentials cache.
18193
18194 Defaults to @samp{disabled}.
18195
18196 @end deftypevr
18197
18198 @deftypevr {@code{nslcd-configuration} parameter} string base
18199 The directory search base.
18200
18201 Defaults to @samp{"dc=example,dc=com"}.
18202
18203 @end deftypevr
18204
18205 @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
18206 Specifies the search scope (subtree, onelevel, base or children). The
18207 default scope is subtree; base scope is almost never useful for name
18208 service lookups; children scope is not supported on all servers.
18209
18210 Defaults to @samp{(subtree)}.
18211
18212 @end deftypevr
18213
18214 @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
18215 Specifies the policy for dereferencing aliases. The default policy is
18216 to never dereference aliases.
18217
18218 Defaults to @samp{disabled}.
18219
18220 @end deftypevr
18221
18222 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
18223 Specifies whether automatic referral chasing should be enabled. The
18224 default behaviour is to chase referrals.
18225
18226 Defaults to @samp{disabled}.
18227
18228 @end deftypevr
18229
18230 @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
18231 This option allows for custom attributes to be looked up instead of the
18232 default RFC 2307 attributes. It is a list of maps, each consisting of
18233 the name of a map, the RFC 2307 attribute to match and the query
18234 expression for the attribute as it is available in the directory.
18235
18236 Defaults to @samp{()}.
18237
18238 @end deftypevr
18239
18240 @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
18241 A list of filters consisting of the name of a map to which the filter
18242 applies and an LDAP search filter expression.
18243
18244 Defaults to @samp{()}.
18245
18246 @end deftypevr
18247
18248 @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
18249 Specifies the time limit in seconds to use when connecting to the
18250 directory server. The default value is 10 seconds.
18251
18252 Defaults to @samp{disabled}.
18253
18254 @end deftypevr
18255
18256 @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
18257 Specifies the time limit (in seconds) to wait for a response from the
18258 LDAP server. A value of zero, which is the default, is to wait
18259 indefinitely for searches to be completed.
18260
18261 Defaults to @samp{disabled}.
18262
18263 @end deftypevr
18264
18265 @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
18266 Specifies the period if inactivity (in seconds) after which the con‐
18267 nection to the LDAP server will be closed. The default is not to time
18268 out connections.
18269
18270 Defaults to @samp{disabled}.
18271
18272 @end deftypevr
18273
18274 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
18275 Specifies the number of seconds to sleep when connecting to all LDAP
18276 servers fails. By default one second is waited between the first
18277 failure and the first retry.
18278
18279 Defaults to @samp{disabled}.
18280
18281 @end deftypevr
18282
18283 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
18284 Specifies the time after which the LDAP server is considered to be
18285 permanently unavailable. Once this time is reached retries will be done
18286 only once per this time period. The default value is 10 seconds.
18287
18288 Defaults to @samp{disabled}.
18289
18290 @end deftypevr
18291
18292 @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
18293 Specifies whether to use SSL/TLS or not (the default is not to). If
18294 'start-tls is specified then StartTLS is used rather than raw LDAP over
18295 SSL.
18296
18297 Defaults to @samp{disabled}.
18298
18299 @end deftypevr
18300
18301 @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
18302 Specifies what checks to perform on a server-supplied certificate. The
18303 meaning of the values is described in the ldap.conf(5) manual page.
18304
18305 Defaults to @samp{disabled}.
18306
18307 @end deftypevr
18308
18309 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
18310 Specifies the directory containing X.509 certificates for peer authen‐
18311 tication. This parameter is ignored when using GnuTLS.
18312
18313 Defaults to @samp{disabled}.
18314
18315 @end deftypevr
18316
18317 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
18318 Specifies the path to the X.509 certificate for peer authentication.
18319
18320 Defaults to @samp{disabled}.
18321
18322 @end deftypevr
18323
18324 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
18325 Specifies the path to an entropy source. This parameter is ignored when
18326 using GnuTLS.
18327
18328 Defaults to @samp{disabled}.
18329
18330 @end deftypevr
18331
18332 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
18333 Specifies the ciphers to use for TLS as a string.
18334
18335 Defaults to @samp{disabled}.
18336
18337 @end deftypevr
18338
18339 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
18340 Specifies the path to the file containing the local certificate for
18341 client TLS authentication.
18342
18343 Defaults to @samp{disabled}.
18344
18345 @end deftypevr
18346
18347 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
18348 Specifies the path to the file containing the private key for client TLS
18349 authentication.
18350
18351 Defaults to @samp{disabled}.
18352
18353 @end deftypevr
18354
18355 @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
18356 Set this to a number greater than 0 to request paged results from the
18357 LDAP server in accordance with RFC2696. The default (0) is to not
18358 request paged results.
18359
18360 Defaults to @samp{disabled}.
18361
18362 @end deftypevr
18363
18364 @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
18365 This option prevents group membership lookups through LDAP for the
18366 specified users. Alternatively, the value 'all-local may be used. With
18367 that value nslcd builds a full list of non-LDAP users on startup.
18368
18369 Defaults to @samp{disabled}.
18370
18371 @end deftypevr
18372
18373 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
18374 This option ensures that LDAP users with a numeric user id lower than
18375 the specified value are ignored.
18376
18377 Defaults to @samp{disabled}.
18378
18379 @end deftypevr
18380
18381 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
18382 This option specifies an offset that is added to all LDAP numeric user
18383 ids. This can be used to avoid user id collisions with local users.
18384
18385 Defaults to @samp{disabled}.
18386
18387 @end deftypevr
18388
18389 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
18390 This option specifies an offset that is added to all LDAP numeric group
18391 ids. This can be used to avoid user id collisions with local groups.
18392
18393 Defaults to @samp{disabled}.
18394
18395 @end deftypevr
18396
18397 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
18398 If this option is set, the member attribute of a group may point to
18399 another group. Members of nested groups are also returned in the higher
18400 level group and parent groups are returned when finding groups for a
18401 specific user. The default is not to perform extra searches for nested
18402 groups.
18403
18404 Defaults to @samp{disabled}.
18405
18406 @end deftypevr
18407
18408 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
18409 If this option is set, the group member list is not retrieved when
18410 looking up groups. Lookups for finding which groups a user belongs to
18411 will remain functional so the user will likely still get the correct
18412 groups assigned on login.
18413
18414 Defaults to @samp{disabled}.
18415
18416 @end deftypevr
18417
18418 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
18419 If this option is set, functions which cause all user/group entries to
18420 be loaded from the directory will not succeed in doing so. This can
18421 dramatically reduce LDAP server load in situations where there are a
18422 great number of users and/or groups. This option is not recommended for
18423 most configurations.
18424
18425 Defaults to @samp{disabled}.
18426
18427 @end deftypevr
18428
18429 @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
18430 This option can be used to specify how user and group names are verified
18431 within the system. This pattern is used to check all user and group
18432 names that are requested and returned from LDAP.
18433
18434 Defaults to @samp{disabled}.
18435
18436 @end deftypevr
18437
18438 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
18439 This specifies whether or not to perform searches using case-insensitive
18440 matching. Enabling this could open up the system to authorization
18441 bypass vulnerabilities and introduce nscd cache poisoning
18442 vulnerabilities which allow denial of service.
18443
18444 Defaults to @samp{disabled}.
18445
18446 @end deftypevr
18447
18448 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
18449 This option specifies whether password policy controls are requested and
18450 handled from the LDAP server when performing user authentication.
18451
18452 Defaults to @samp{disabled}.
18453
18454 @end deftypevr
18455
18456 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
18457 By default nslcd performs an LDAP search with the user's credentials
18458 after BIND (authentication) to ensure that the BIND operation was
18459 successful. The default search is a simple check to see if the user's
18460 DN exists. A search filter can be specified that will be used instead.
18461 It should return at least one entry.
18462
18463 Defaults to @samp{disabled}.
18464
18465 @end deftypevr
18466
18467 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
18468 This option allows flexible fine tuning of the authorisation check that
18469 should be performed. The search filter specified is executed and if any
18470 entries match, access is granted, otherwise access is denied.
18471
18472 Defaults to @samp{disabled}.
18473
18474 @end deftypevr
18475
18476 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
18477 If this option is set password modification using pam_ldap will be
18478 denied and the specified message will be presented to the user instead.
18479 The message can be used to direct the user to an alternative means of
18480 changing their password.
18481
18482 Defaults to @samp{disabled}.
18483
18484 @end deftypevr
18485
18486 @deftypevr {@code{nslcd-configuration} parameter} list pam-services
18487 List of pam service names for which LDAP authentication should suffice.
18488
18489 Defaults to @samp{()}.
18490
18491 @end deftypevr
18492
18493 @c %end of generated documentation for nslcd-configuration
18494
18495
18496 @node Web Services
18497 @subsection Web Services
18498
18499 @cindex web
18500 @cindex www
18501 @cindex HTTP
18502 The @code{(gnu services web)} module provides the Apache HTTP Server,
18503 the nginx web server, and also a fastcgi wrapper daemon.
18504
18505 @subsubheading Apache HTTP Server
18506
18507 @deffn {Scheme Variable} httpd-service-type
18508 Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
18509 (@dfn{httpd}). The value for this service type is a
18510 @code{httpd-configuration} record.
18511
18512 A simple example configuration is given below.
18513
18514 @example
18515 (service httpd-service-type
18516 (httpd-configuration
18517 (config
18518 (httpd-config-file
18519 (server-name "www.example.com")
18520 (document-root "/srv/http/www.example.com")))))
18521 @end example
18522
18523 Other services can also extend the @code{httpd-service-type} to add to
18524 the configuration.
18525
18526 @example
18527 (simple-service 'my-extra-server httpd-service-type
18528 (list
18529 (httpd-virtualhost
18530 "*:80"
18531 (list (string-append
18532 "ServerName "www.example.com
18533 DocumentRoot \"/srv/http/www.example.com\"")))))
18534 @end example
18535 @end deffn
18536
18537 The details for the @code{httpd-configuration}, @code{httpd-module},
18538 @code{httpd-config-file} and @code{httpd-virtualhost} record types are
18539 given below.
18540
18541 @deffn {Data Type} httpd-configuration
18542 This data type represents the configuration for the httpd service.
18543
18544 @table @asis
18545 @item @code{package} (default: @code{httpd})
18546 The httpd package to use.
18547
18548 @item @code{pid-file} (default: @code{"/var/run/httpd"})
18549 The pid file used by the shepherd-service.
18550
18551 @item @code{config} (default: @code{(httpd-config-file)})
18552 The configuration file to use with the httpd service. The default value
18553 is a @code{httpd-config-file} record, but this can also be a different
18554 G-expression that generates a file, for example a @code{plain-file}. A
18555 file outside of the store can also be specified through a string.
18556
18557 @end table
18558 @end deffn
18559
18560 @deffn {Data Type} httpd-module
18561 This data type represents a module for the httpd service.
18562
18563 @table @asis
18564 @item @code{name}
18565 The name of the module.
18566
18567 @item @code{file}
18568 The file for the module. This can be relative to the httpd package being
18569 used, the absolute location of a file, or a G-expression for a file
18570 within the store, for example @code{(file-append mod-wsgi
18571 "/modules/mod_wsgi.so")}.
18572
18573 @end table
18574 @end deffn
18575
18576 @defvr {Scheme Variable} %default-httpd-modules
18577 A default list of @code{httpd-module} objects.
18578 @end defvr
18579
18580 @deffn {Data Type} httpd-config-file
18581 This data type represents a configuration file for the httpd service.
18582
18583 @table @asis
18584 @item @code{modules} (default: @code{%default-httpd-modules})
18585 The modules to load. Additional modules can be added here, or loaded by
18586 additional configuration.
18587
18588 For example, in order to handle requests for PHP files, you can use Apache’s
18589 @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
18590
18591 @example
18592 (service httpd-service-type
18593 (httpd-configuration
18594 (config
18595 (httpd-config-file
18596 (modules (cons*
18597 (httpd-module
18598 (name "proxy_module")
18599 (file "modules/mod_proxy.so"))
18600 (httpd-module
18601 (name "proxy_fcgi_module")
18602 (file "modules/mod_proxy_fcgi.so"))
18603 %default-httpd-modules))
18604 (extra-config (list "\
18605 <FilesMatch \\.php$>
18606 SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
18607 </FilesMatch>"))))))
18608 (service php-fpm-service-type
18609 (php-fpm-configuration
18610 (socket "/var/run/php-fpm.sock")
18611 (socket-group "httpd")))
18612 @end example
18613
18614 @item @code{server-root} (default: @code{httpd})
18615 The @code{ServerRoot} in the configuration file, defaults to the httpd
18616 package. Directives including @code{Include} and @code{LoadModule} are
18617 taken as relative to the server root.
18618
18619 @item @code{server-name} (default: @code{#f})
18620 The @code{ServerName} in the configuration file, used to specify the
18621 request scheme, hostname and port that the server uses to identify
18622 itself.
18623
18624 This doesn't need to be set in the server config, and can be specifyed
18625 in virtual hosts. The default is @code{#f} to not specify a
18626 @code{ServerName}.
18627
18628 @item @code{document-root} (default: @code{"/srv/http"})
18629 The @code{DocumentRoot} from which files will be served.
18630
18631 @item @code{listen} (default: @code{'("80")})
18632 The list of values for the @code{Listen} directives in the config
18633 file. The value should be a list of strings, when each string can
18634 specify the port number to listen on, and optionally the IP address and
18635 protocol to use.
18636
18637 @item @code{pid-file} (default: @code{"/var/run/httpd"})
18638 The @code{PidFile} to use. This should match the @code{pid-file} set in
18639 the @code{httpd-configuration} so that the Shepherd service is
18640 configured correctly.
18641
18642 @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
18643 The @code{ErrorLog} to which the server will log errors.
18644
18645 @item @code{user} (default: @code{"httpd"})
18646 The @code{User} which the server will answer requests as.
18647
18648 @item @code{group} (default: @code{"httpd"})
18649 The @code{Group} which the server will answer requests as.
18650
18651 @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
18652 A flat list of strings and G-expressions which will be added to the end
18653 of the configuration file.
18654
18655 Any values which the service is extended with will be appended to this
18656 list.
18657
18658 @end table
18659 @end deffn
18660
18661 @deffn {Data Type} httpd-virtualhost
18662 This data type represents a virtualhost configuration block for the httpd service.
18663
18664 These should be added to the extra-config for the httpd-service.
18665
18666 @example
18667 (simple-service 'my-extra-server httpd-service-type
18668 (list
18669 (httpd-virtualhost
18670 "*:80"
18671 (list (string-append
18672 "ServerName "www.example.com
18673 DocumentRoot \"/srv/http/www.example.com\"")))))
18674 @end example
18675
18676 @table @asis
18677 @item @code{addresses-and-ports}
18678 The addresses and ports for the @code{VirtualHost} directive.
18679
18680 @item @code{contents}
18681 The contents of the @code{VirtualHost} directive, this should be a list
18682 of strings and G-expressions.
18683
18684 @end table
18685 @end deffn
18686
18687 @subsubheading NGINX
18688
18689 @deffn {Scheme Variable} nginx-service-type
18690 Service type for the @uref{https://nginx.org/,NGinx} web server. The
18691 value for this service type is a @code{<nginx-configuration>} record.
18692
18693 A simple example configuration is given below.
18694
18695 @example
18696 (service nginx-service-type
18697 (nginx-configuration
18698 (server-blocks
18699 (list (nginx-server-configuration
18700 (server-name '("www.example.com"))
18701 (root "/srv/http/www.example.com"))))))
18702 @end example
18703
18704 In addition to adding server blocks to the service configuration
18705 directly, this service can be extended by other services to add server
18706 blocks, as in this example:
18707
18708 @example
18709 (simple-service 'my-extra-server nginx-service-type
18710 (list (nginx-server-configuration
18711 (root "/srv/http/extra-website")
18712 (try-files (list "$uri" "$uri/index.html")))))
18713 @end example
18714 @end deffn
18715
18716 At startup, @command{nginx} has not yet read its configuration file, so
18717 it uses a default file to log error messages. If it fails to load its
18718 configuration file, that is where error messages are logged. After the
18719 configuration file is loaded, the default error log file changes as per
18720 configuration. In our case, startup error messages can be found in
18721 @file{/var/run/nginx/logs/error.log}, and after configuration in
18722 @file{/var/log/nginx/error.log}. The second location can be changed
18723 with the @var{log-directory} configuration option.
18724
18725 @deffn {Data Type} nginx-configuration
18726 This data type represents the configuration for NGinx. Some
18727 configuration can be done through this and the other provided record
18728 types, or alternatively, a config file can be provided.
18729
18730 @table @asis
18731 @item @code{nginx} (default: @code{nginx})
18732 The nginx package to use.
18733
18734 @item @code{log-directory} (default: @code{"/var/log/nginx"})
18735 The directory to which NGinx will write log files.
18736
18737 @item @code{run-directory} (default: @code{"/var/run/nginx"})
18738 The directory in which NGinx will create a pid file, and write temporary
18739 files.
18740
18741 @item @code{server-blocks} (default: @code{'()})
18742 A list of @dfn{server blocks} to create in the generated configuration
18743 file, the elements should be of type
18744 @code{<nginx-server-configuration>}.
18745
18746 The following example would setup NGinx to serve @code{www.example.com}
18747 from the @code{/srv/http/www.example.com} directory, without using
18748 HTTPS.
18749 @example
18750 (service nginx-service-type
18751 (nginx-configuration
18752 (server-blocks
18753 (list (nginx-server-configuration
18754 (server-name '("www.example.com"))
18755 (root "/srv/http/www.example.com"))))))
18756 @end example
18757
18758 @item @code{upstream-blocks} (default: @code{'()})
18759 A list of @dfn{upstream blocks} to create in the generated configuration
18760 file, the elements should be of type
18761 @code{<nginx-upstream-configuration>}.
18762
18763 Configuring upstreams through the @code{upstream-blocks} can be useful
18764 when combined with @code{locations} in the
18765 @code{<nginx-server-configuration>} records. The following example
18766 creates a server configuration with one location configuration, that
18767 will proxy requests to a upstream configuration, which will handle
18768 requests with two servers.
18769
18770 @example
18771 (service
18772 nginx-service-type
18773 (nginx-configuration
18774 (server-blocks
18775 (list (nginx-server-configuration
18776 (server-name '("www.example.com"))
18777 (root "/srv/http/www.example.com")
18778 (locations
18779 (list
18780 (nginx-location-configuration
18781 (uri "/path1")
18782 (body '("proxy_pass http://server-proxy;"))))))))
18783 (upstream-blocks
18784 (list (nginx-upstream-configuration
18785 (name "server-proxy")
18786 (servers (list "server1.example.com"
18787 "server2.example.com")))))))
18788 @end example
18789
18790 @item @code{file} (default: @code{#f})
18791 If a configuration @var{file} is provided, this will be used, rather than
18792 generating a configuration file from the provided @code{log-directory},
18793 @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
18794 proper operation, these arguments should match what is in @var{file} to ensure
18795 that the directories are created when the service is activated.
18796
18797 This can be useful if you have an existing configuration file, or it's
18798 not possible to do what is required through the other parts of the
18799 nginx-configuration record.
18800
18801 @item @code{server-names-hash-bucket-size} (default: @code{#f})
18802 Bucket size for the server names hash tables, defaults to @code{#f} to
18803 use the size of the processors cache line.
18804
18805 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
18806 Maximum bucket size for the server names hash tables.
18807
18808 @item @code{extra-content} (default: @code{""})
18809 Extra content for the @code{http} block. Should be string or a string
18810 valued G-expression.
18811
18812 @end table
18813 @end deffn
18814
18815 @deftp {Data Type} nginx-server-configuration
18816 Data type representing the configuration of an nginx server block.
18817 This type has the following parameters:
18818
18819 @table @asis
18820 @item @code{listen} (default: @code{'("80" "443 ssl")})
18821 Each @code{listen} directive sets the address and port for IP, or the
18822 path for a UNIX-domain socket on which the server will accept requests.
18823 Both address and port, or only address or only port can be specified.
18824 An address may also be a hostname, for example:
18825
18826 @example
18827 '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
18828 @end example
18829
18830 @item @code{server-name} (default: @code{(list 'default)})
18831 A list of server names this server represents. @code{'default} represents the
18832 default server for connections matching no other server.
18833
18834 @item @code{root} (default: @code{"/srv/http"})
18835 Root of the website nginx will serve.
18836
18837 @item @code{locations} (default: @code{'()})
18838 A list of @dfn{nginx-location-configuration} or
18839 @dfn{nginx-named-location-configuration} records to use within this
18840 server block.
18841
18842 @item @code{index} (default: @code{(list "index.html")})
18843 Index files to look for when clients ask for a directory. If it cannot be found,
18844 Nginx will send the list of files in the directory.
18845
18846 @item @code{try-files} (default: @code{'()})
18847 A list of files whose existence is checked in the specified order.
18848 @code{nginx} will use the first file it finds to process the request.
18849
18850 @item @code{ssl-certificate} (default: @code{#f})
18851 Where to find the certificate for secure connections. Set it to @code{#f} if
18852 you don't have a certificate or you don't want to use HTTPS.
18853
18854 @item @code{ssl-certificate-key} (default: @code{#f})
18855 Where to find the private key for secure connections. Set it to @code{#f} if
18856 you don't have a key or you don't want to use HTTPS.
18857
18858 @item @code{server-tokens?} (default: @code{#f})
18859 Whether the server should add its configuration to response.
18860
18861 @item @code{raw-content} (default: @code{'()})
18862 A list of raw lines added to the server block.
18863
18864 @end table
18865 @end deftp
18866
18867 @deftp {Data Type} nginx-upstream-configuration
18868 Data type representing the configuration of an nginx @code{upstream}
18869 block. This type has the following parameters:
18870
18871 @table @asis
18872 @item @code{name}
18873 Name for this group of servers.
18874
18875 @item @code{servers}
18876 Specify the addresses of the servers in the group. The address can be
18877 specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
18878 (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
18879 prefix @samp{unix:}. For addresses using an IP address or domain name,
18880 the default port is 80, and a different port can be specified
18881 explicitly.
18882
18883 @end table
18884 @end deftp
18885
18886 @deftp {Data Type} nginx-location-configuration
18887 Data type representing the configuration of an nginx @code{location}
18888 block. This type has the following parameters:
18889
18890 @table @asis
18891 @item @code{uri}
18892 URI which this location block matches.
18893
18894 @anchor{nginx-location-configuration body}
18895 @item @code{body}
18896 Body of the location block, specified as a list of strings. This can contain
18897 many
18898 configuration directives. For example, to pass requests to a upstream
18899 server group defined using an @code{nginx-upstream-configuration} block,
18900 the following directive would be specified in the body @samp{(list "proxy_pass
18901 http://upstream-name;")}.
18902
18903 @end table
18904 @end deftp
18905
18906 @deftp {Data Type} nginx-named-location-configuration
18907 Data type representing the configuration of an nginx named location
18908 block. Named location blocks are used for request redirection, and not
18909 used for regular request processing. This type has the following
18910 parameters:
18911
18912 @table @asis
18913 @item @code{name}
18914 Name to identify this location block.
18915
18916 @item @code{body}
18917 @xref{nginx-location-configuration body}, as the body for named location
18918 blocks can be used in a similar way to the
18919 @code{nginx-location-configuration body}. One restriction is that the
18920 body of a named location block cannot contain location blocks.
18921
18922 @end table
18923 @end deftp
18924
18925 @subsubheading Varnish Cache
18926 @cindex Varnish
18927 Varnish is a fast cache server that sits in between web applications
18928 and end users. It proxies requests from clients and caches the
18929 accessed URLs such that multiple requests for the same resource only
18930 creates one request to the back-end.
18931
18932 @defvr {Scheme Variable} varnish-service-type
18933 Service type for the Varnish daemon.
18934 @end defvr
18935
18936 @deftp {Data Type} varnish-configuration
18937 Data type representing the @code{varnish} service configuration.
18938 This type has the following parameters:
18939
18940 @table @asis
18941 @item @code{package} (default: @code{varnish})
18942 The Varnish package to use.
18943
18944 @item @code{name} (default: @code{"default"})
18945 A name for this Varnish instance. Varnish will create a directory in
18946 @file{/var/varnish/} with this name and keep temporary files there. If
18947 the name starts with a forward slash, it is interpreted as an absolute
18948 directory name.
18949
18950 Pass the @code{-n} argument to other Varnish programs to connect to the
18951 named instance, e.g.@: @command{varnishncsa -n default}.
18952
18953 @item @code{backend} (default: @code{"localhost:8080"})
18954 The backend to use. This option has no effect if @code{vcl} is set.
18955
18956 @item @code{vcl} (default: #f)
18957 The @dfn{VCL} (Varnish Configuration Language) program to run. If this
18958 is @code{#f}, Varnish will proxy @code{backend} using the default
18959 configuration. Otherwise this must be a file-like object with valid
18960 VCL syntax.
18961
18962 @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
18963 For example, to mirror @url{http://www.gnu.org,www.gnu.org} with VCL you
18964 can do something along these lines:
18965
18966 @example
18967 (define %gnu-mirror
18968 (plain-file
18969 "gnu.vcl"
18970 "vcl 4.1;
18971 backend gnu @{ .host = "www.gnu.org"; @}"))
18972
18973 (operating-system
18974 ...
18975 (services (cons (service varnish-service-type
18976 (varnish-configuration
18977 (listen '(":80"))
18978 (vcl %gnu-mirror)))
18979 %base-services)))
18980 @end example
18981
18982 The configuration of an already running Varnish instance can be inspected
18983 and changed using the @command{varnishadm} program.
18984
18985 Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
18986 @url{https://book.varnish-software.com/4.0/,Varnish Book} for
18987 comprehensive documentation on Varnish and its configuration language.
18988
18989 @item @code{listen} (default: @code{'("localhost:80")})
18990 List of addresses Varnish will listen on.
18991
18992 @item @code{storage} (default: @code{'("malloc,128m")})
18993 List of storage backends that will be available in VCL.
18994
18995 @item @code{parameters} (default: @code{'()})
18996 List of run-time parameters in the form @code{'(("parameter" . "value"))}.
18997
18998 @item @code{extra-options} (default: @code{'()})
18999 Additional arguments to pass to the @command{varnishd} process.
19000
19001 @end table
19002 @end deftp
19003
19004 @subsubheading FastCGI
19005 @cindex fastcgi
19006 @cindex fcgiwrap
19007 FastCGI is an interface between the front-end and the back-end of a web
19008 service. It is a somewhat legacy facility; new web services should
19009 generally just talk HTTP between the front-end and the back-end.
19010 However there are a number of back-end services such as PHP or the
19011 optimized HTTP Git repository access that use FastCGI, so we have
19012 support for it in Guix.
19013
19014 To use FastCGI, you configure the front-end web server (e.g., nginx) to
19015 dispatch some subset of its requests to the fastcgi backend, which
19016 listens on a local TCP or UNIX socket. There is an intermediary
19017 @code{fcgiwrap} program that sits between the actual backend process and
19018 the web server. The front-end indicates which backend program to run,
19019 passing that information to the @code{fcgiwrap} process.
19020
19021 @defvr {Scheme Variable} fcgiwrap-service-type
19022 A service type for the @code{fcgiwrap} FastCGI proxy.
19023 @end defvr
19024
19025 @deftp {Data Type} fcgiwrap-configuration
19026 Data type representing the configuration of the @code{fcgiwrap} service.
19027 This type has the following parameters:
19028 @table @asis
19029 @item @code{package} (default: @code{fcgiwrap})
19030 The fcgiwrap package to use.
19031
19032 @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
19033 The socket on which the @code{fcgiwrap} process should listen, as a
19034 string. Valid @var{socket} values include
19035 @code{unix:@var{/path/to/unix/socket}},
19036 @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
19037 @code{tcp6:[@var{ipv6_addr}]:port}.
19038
19039 @item @code{user} (default: @code{fcgiwrap})
19040 @itemx @code{group} (default: @code{fcgiwrap})
19041 The user and group names, as strings, under which to run the
19042 @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
19043 the user asks for the specific user or group names @code{fcgiwrap} that
19044 the corresponding user and/or group is present on the system.
19045
19046 It is possible to configure a FastCGI-backed web service to pass HTTP
19047 authentication information from the front-end to the back-end, and to
19048 allow @code{fcgiwrap} to run the back-end process as a corresponding
19049 local user. To enable this capability on the back-end., run
19050 @code{fcgiwrap} as the @code{root} user and group. Note that this
19051 capability also has to be configured on the front-end as well.
19052 @end table
19053 @end deftp
19054
19055 @cindex php-fpm
19056 PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
19057 with some additional features useful for sites of any size.
19058
19059 These features include:
19060 @itemize @bullet
19061 @item Adaptive process spawning
19062 @item Basic statistics (similar to Apache's mod_status)
19063 @item Advanced process management with graceful stop/start
19064 @item Ability to start workers with different uid/gid/chroot/environment
19065 and different php.ini (replaces safe_mode)
19066 @item Stdout & stderr logging
19067 @item Emergency restart in case of accidental opcode cache destruction
19068 @item Accelerated upload support
19069 @item Support for a "slowlog"
19070 @item Enhancements to FastCGI, such as fastcgi_finish_request() -
19071 a special function to finish request & flush all data while continuing to do
19072 something time-consuming (video converting, stats processing, etc.)
19073 @end itemize
19074 ...@: and much more.
19075
19076 @defvr {Scheme Variable} php-fpm-service-type
19077 A Service type for @code{php-fpm}.
19078 @end defvr
19079
19080 @deftp {Data Type} php-fpm-configuration
19081 Data Type for php-fpm service configuration.
19082 @table @asis
19083 @item @code{php} (default: @code{php})
19084 The php package to use.
19085 @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
19086 The address on which to accept FastCGI requests. Valid syntaxes are:
19087 @table @asis
19088 @item @code{"ip.add.re.ss:port"}
19089 Listen on a TCP socket to a specific address on a specific port.
19090 @item @code{"port"}
19091 Listen on a TCP socket to all addresses on a specific port.
19092 @item @code{"/path/to/unix/socket"}
19093 Listen on a unix socket.
19094 @end table
19095
19096 @item @code{user} (default: @code{php-fpm})
19097 User who will own the php worker processes.
19098 @item @code{group} (default: @code{php-fpm})
19099 Group of the worker processes.
19100 @item @code{socket-user} (default: @code{php-fpm})
19101 User who can speak to the php-fpm socket.
19102 @item @code{socket-group} (default: @code{php-fpm})
19103 Group that can speak to the php-fpm socket.
19104 @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
19105 The process id of the php-fpm process is written to this file
19106 once the service has started.
19107 @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
19108 Log for the php-fpm master process.
19109 @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
19110 Detailed settings for the php-fpm process manager.
19111 Must be either:
19112 @table @asis
19113 @item @code{<php-fpm-dynamic-process-manager-configuration>}
19114 @item @code{<php-fpm-static-process-manager-configuration>}
19115 @item @code{<php-fpm-on-demand-process-manager-configuration>}
19116 @end table
19117 @item @code{display-errors} (default @code{#f})
19118 Determines whether php errors and warning should be sent to clients
19119 and displayed in their browsers.
19120 This is useful for local php development, but a security risk for public sites,
19121 as error messages can reveal passwords and personal data.
19122 @item @code{timezone} (default @code{#f})
19123 Specifies @code{php_admin_value[date.timezone]} parameter.
19124 @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
19125 This file will log the @code{stderr} outputs of php worker processes.
19126 Can be set to @code{#f} to disable logging.
19127 @item @code{file} (default @code{#f})
19128 An optional override of the whole configuration.
19129 You can use the @code{mixed-text-file} function or an absolute filepath for it.
19130 @end table
19131 @end deftp
19132
19133 @deftp {Data type} php-fpm-dynamic-process-manager-configuration
19134 Data Type for the @code{dynamic} php-fpm process manager. With the
19135 @code{dynamic} process manager, spare worker processes are kept around
19136 based on it's configured limits.
19137 @table @asis
19138 @item @code{max-children} (default: @code{5})
19139 Maximum of worker processes.
19140 @item @code{start-servers} (default: @code{2})
19141 How many worker processes should be started on start-up.
19142 @item @code{min-spare-servers} (default: @code{1})
19143 How many spare worker processes should be kept around at minimum.
19144 @item @code{max-spare-servers} (default: @code{3})
19145 How many spare worker processes should be kept around at maximum.
19146 @end table
19147 @end deftp
19148
19149 @deftp {Data type} php-fpm-static-process-manager-configuration
19150 Data Type for the @code{static} php-fpm process manager. With the
19151 @code{static} process manager, an unchanging number of worker processes
19152 are created.
19153 @table @asis
19154 @item @code{max-children} (default: @code{5})
19155 Maximum of worker processes.
19156 @end table
19157 @end deftp
19158
19159 @deftp {Data type} php-fpm-on-demand-process-manager-configuration
19160 Data Type for the @code{on-demand} php-fpm process manager. With the
19161 @code{on-demand} process manager, worker processes are only created as
19162 requests arrive.
19163 @table @asis
19164 @item @code{max-children} (default: @code{5})
19165 Maximum of worker processes.
19166 @item @code{process-idle-timeout} (default: @code{10})
19167 The time in seconds after which a process with no requests is killed.
19168 @end table
19169 @end deftp
19170
19171
19172 @deffn {Scheme Procedure} nginx-php-fpm-location @
19173 [#:nginx-package nginx] @
19174 [socket (string-append "/var/run/php" @
19175 (version-major (package-version php)) @
19176 "-fpm.sock")]
19177 A helper function to quickly add php to an @code{nginx-server-configuration}.
19178 @end deffn
19179
19180 A simple services setup for nginx with php can look like this:
19181 @example
19182 (services (cons* (service dhcp-client-service-type)
19183 (service php-fpm-service-type)
19184 (service nginx-service-type
19185 (nginx-server-configuration
19186 (server-name '("example.com"))
19187 (root "/srv/http/")
19188 (locations
19189 (list (nginx-php-location)))
19190 (listen '("80"))
19191 (ssl-certificate #f)
19192 (ssl-certificate-key #f)))
19193 %base-services))
19194 @end example
19195
19196 @cindex cat-avatar-generator
19197 The cat avatar generator is a simple service to demonstrate the use of php-fpm
19198 in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
19199 the hash of a user's email address.
19200
19201 @deffn {Scheme Procedure} cat-avatar-generator-service @
19202 [#:cache-dir "/var/cache/cat-avatar-generator"] @
19203 [#:package cat-avatar-generator] @
19204 [#:configuration (nginx-server-configuration)]
19205 Returns an nginx-server-configuration that inherits @code{configuration}. It
19206 extends the nginx configuration to add a server block that serves @code{package},
19207 a version of cat-avatar-generator. During execution, cat-avatar-generator will
19208 be able to use @code{cache-dir} as its cache directory.
19209 @end deffn
19210
19211 A simple setup for cat-avatar-generator can look like this:
19212 @example
19213 (services (cons* (cat-avatar-generator-service
19214 #:configuration
19215 (nginx-server-configuration
19216 (server-name '("example.com"))))
19217 ...
19218 %base-services))
19219 @end example
19220
19221 @subsubheading Hpcguix-web
19222
19223 @cindex hpcguix-web
19224 The @uref{hpcguix-web, https://github.com/UMCUGenetics/hpcguix-web/}
19225 program is a customizable web interface to browse Guix packages,
19226 initially designed for users of high-performance computing (HPC)
19227 clusters.
19228
19229 @defvr {Scheme Variable} hpcguix-web-service-type
19230 The service type for @code{hpcguix-web}.
19231 @end defvr
19232
19233 @deftp {Data Type} hpcguix-web-configuration
19234 Data type for the hpcguix-web service configuration.
19235
19236 @table @asis
19237 @item @code{specs}
19238 A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
19239 configuration. The main items available in this spec are:
19240
19241 @table @asis
19242 @item @code{title-prefix} (default: @code{"hpcguix | "})
19243 The page title prefix.
19244
19245 @item @code{guix-command} (default: @code{"guix"})
19246 The @command{guix} command.
19247
19248 @item @code{package-filter-proc} (default: @code{(const #t)})
19249 A procedure specifying how to filter packages that are displayed.
19250
19251 @item @code{package-page-extension-proc} (default: @code{(const '())})
19252 Extension package for @code{hpcguix-web}.
19253
19254 @item @code{menu} (default: @code{'()})
19255 Additional entry in page @code{menu}.
19256
19257 @item @code{channels} (default: @code{%default-channels})
19258 List of channels from which the package list is built (@pxref{Channels}).
19259
19260 @item @code{package-list-expiration} (default: @code{(* 12 3600)})
19261 The expiration time, in seconds, after which the package list is rebuilt from
19262 the latest instances of the given channels.
19263 @end table
19264
19265 See the hpcguix-web repository for a
19266 @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
19267 complete example}.
19268
19269 @item @code{package} (default: @code{hpcguix-web})
19270 The hpcguix-web package to use.
19271 @end table
19272 @end deftp
19273
19274 A typical hpcguix-web service declaration looks like this:
19275
19276 @example
19277 (service hpcguix-web-service-type
19278 (hpcguix-web-configuration
19279 (specs
19280 #~(define site-config
19281 (hpcweb-configuration
19282 (title-prefix "Guix-HPC - ")
19283 (menu '(("/about" "ABOUT"))))))))
19284 @end example
19285
19286 @quotation Note
19287 The hpcguix-web service periodically updates the package list it publishes by
19288 pulling channels from Git. To that end, it needs to access X.509 certificates
19289 so that it can authenticate Git servers when communicating over HTTPS, and it
19290 assumes that @file{/etc/ssl/certs} contains those certificates.
19291
19292 Thus, make sure to add @code{nss-certs} or another certificate package to the
19293 @code{packages} field of your configuration. @ref{X.509 Certificates}, for
19294 more information on X.509 certificates.
19295 @end quotation
19296
19297 @node Certificate Services
19298 @subsection Certificate Services
19299
19300 @cindex Web
19301 @cindex HTTP, HTTPS
19302 @cindex Let's Encrypt
19303 @cindex TLS certificates
19304 The @code{(gnu services certbot)} module provides a service to
19305 automatically obtain a valid TLS certificate from the Let's Encrypt
19306 certificate authority. These certificates can then be used to serve
19307 content securely over HTTPS or other TLS-based protocols, with the
19308 knowledge that the client will be able to verify the server's
19309 authenticity.
19310
19311 @url{https://letsencrypt.org/, Let's Encrypt} provides the
19312 @code{certbot} tool to automate the certification process. This tool
19313 first securely generates a key on the server. It then makes a request
19314 to the Let's Encrypt certificate authority (CA) to sign the key. The CA
19315 checks that the request originates from the host in question by using a
19316 challenge-response protocol, requiring the server to provide its
19317 response over HTTP. If that protocol completes successfully, the CA
19318 signs the key, resulting in a certificate. That certificate is valid
19319 for a limited period of time, and therefore to continue to provide TLS
19320 services, the server needs to periodically ask the CA to renew its
19321 signature.
19322
19323 The certbot service automates this process: the initial key
19324 generation, the initial certification request to the Let's Encrypt
19325 service, the web server challenge/response integration, writing the
19326 certificate to disk, the automated periodic renewals, and the deployment
19327 tasks associated with the renewal (e.g.@: reloading services, copying keys
19328 with different permissions).
19329
19330 Certbot is run twice a day, at a random minute within the hour. It
19331 won't do anything until your certificates are due for renewal or
19332 revoked, but running it regularly would give your service a chance of
19333 staying online in case a Let's Encrypt-initiated revocation happened for
19334 some reason.
19335
19336 By using this service, you agree to the ACME Subscriber Agreement, which
19337 can be found there:
19338 @url{https://acme-v01.api.letsencrypt.org/directory}.
19339
19340 @defvr {Scheme Variable} certbot-service-type
19341 A service type for the @code{certbot} Let's Encrypt client. Its value
19342 must be a @code{certbot-configuration} record as in this example:
19343
19344 @example
19345 (define %nginx-deploy-hook
19346 (program-file
19347 "nginx-deploy-hook"
19348 #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
19349 (kill pid SIGHUP))))
19350
19351 (service certbot-service-type
19352 (certbot-configuration
19353 (email "foo@@example.net")
19354 (certificates
19355 (list
19356 (certificate-configuration
19357 (domains '("example.net" "www.example.net"))
19358 (deploy-hook %nginx-deploy-hook))
19359 (certificate-configuration
19360 (domains '("bar.example.net")))))))
19361 @end example
19362
19363 See below for details about @code{certbot-configuration}.
19364 @end defvr
19365
19366 @deftp {Data Type} certbot-configuration
19367 Data type representing the configuration of the @code{certbot} service.
19368 This type has the following parameters:
19369
19370 @table @asis
19371 @item @code{package} (default: @code{certbot})
19372 The certbot package to use.
19373
19374 @item @code{webroot} (default: @code{/var/www})
19375 The directory from which to serve the Let's Encrypt challenge/response
19376 files.
19377
19378 @item @code{certificates} (default: @code{()})
19379 A list of @code{certificates-configuration}s for which to generate
19380 certificates and request signatures. Each certificate has a @code{name}
19381 and several @code{domains}.
19382
19383 @item @code{email}
19384 Mandatory email used for registration, recovery contact, and important
19385 account notifications.
19386
19387 @item @code{rsa-key-size} (default: @code{2048})
19388 Size of the RSA key.
19389
19390 @item @code{default-location} (default: @i{see below})
19391 The default @code{nginx-location-configuration}. Because @code{certbot}
19392 needs to be able to serve challenges and responses, it needs to be able
19393 to run a web server. It does so by extending the @code{nginx} web
19394 service with an @code{nginx-server-configuration} listening on the
19395 @var{domains} on port 80, and which has a
19396 @code{nginx-location-configuration} for the @code{/.well-known/} URI
19397 path subspace used by Let's Encrypt. @xref{Web Services}, for more on
19398 these nginx configuration data types.
19399
19400 Requests to other URL paths will be matched by the
19401 @code{default-location}, which if present is added to all
19402 @code{nginx-server-configuration}s.
19403
19404 By default, the @code{default-location} will issue a redirect from
19405 @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
19406 you to define what to serve on your site via @code{https}.
19407
19408 Pass @code{#f} to not issue a default location.
19409 @end table
19410 @end deftp
19411
19412 @deftp {Data Type} certificate-configuration
19413 Data type representing the configuration of a certificate.
19414 This type has the following parameters:
19415
19416 @table @asis
19417 @item @code{name} (default: @i{see below})
19418 This name is used by Certbot for housekeeping and in file paths; it
19419 doesn't affect the content of the certificate itself. To see
19420 certificate names, run @code{certbot certificates}.
19421
19422 Its default is the first provided domain.
19423
19424 @item @code{domains} (default: @code{()})
19425 The first domain provided will be the subject CN of the certificate, and
19426 all domains will be Subject Alternative Names on the certificate.
19427
19428 @item @code{challenge} (default: @code{#f})
19429 The challenge type that has to be run by certbot. If @code{#f} is specified,
19430 default to the HTTP challenge. If a value is specified, defaults to the
19431 manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
19432 the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}).
19433
19434 @item @code{authentication-hook} (default: @code{#f})
19435 Command to be run in a shell once for each certificate challenge to be
19436 answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
19437 will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
19438 contains the validation string and @code{$CERTBOT_TOKEN} contains the
19439 file name of the resource requested when performing an HTTP-01 challenge.
19440
19441 @item @code{cleanup-hook} (default: @code{#f})
19442 Command to be run in a shell once for each certificate challenge that
19443 have been answered by the @code{auth-hook}. For this command, the shell
19444 variables available in the @code{auth-hook} script are still available, and
19445 additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
19446 of the @code{auth-hook} script.
19447
19448 @item @code{deploy-hook} (default: @code{#f})
19449 Command to be run in a shell once for each successfully issued
19450 certificate. For this command, the shell variable
19451 @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
19452 example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
19453 certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
19454 contain a space-delimited list of renewed certificate domains (for
19455 example, @samp{"example.com www.example.com"}.
19456
19457 @end table
19458 @end deftp
19459
19460 For each @code{certificate-configuration}, the certificate is saved to
19461 @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
19462 saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
19463 @node DNS Services
19464 @subsection DNS Services
19465 @cindex DNS (domain name system)
19466 @cindex domain name system (DNS)
19467
19468 The @code{(gnu services dns)} module provides services related to the
19469 @dfn{domain name system} (DNS). It provides a server service for hosting
19470 an @emph{authoritative} DNS server for multiple zones, slave or master.
19471 This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
19472 caching and forwarding DNS server for the LAN, which uses
19473 @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
19474
19475 @subsubheading Knot Service
19476
19477 An example configuration of an authoritative server for two zones, one master
19478 and one slave, is:
19479
19480 @lisp
19481 (define-zone-entries example.org.zone
19482 ;; Name TTL Class Type Data
19483 ("@@" "" "IN" "A" "127.0.0.1")
19484 ("@@" "" "IN" "NS" "ns")
19485 ("ns" "" "IN" "A" "127.0.0.1"))
19486
19487 (define master-zone
19488 (knot-zone-configuration
19489 (domain "example.org")
19490 (zone (zone-file
19491 (origin "example.org")
19492 (entries example.org.zone)))))
19493
19494 (define slave-zone
19495 (knot-zone-configuration
19496 (domain "plop.org")
19497 (dnssec-policy "default")
19498 (master (list "plop-master"))))
19499
19500 (define plop-master
19501 (knot-remote-configuration
19502 (id "plop-master")
19503 (address (list "208.76.58.171"))))
19504
19505 (operating-system
19506 ;; ...
19507 (services (cons* (service knot-service-type
19508 (knot-configuration
19509 (remotes (list plop-master))
19510 (zones (list master-zone slave-zone))))
19511 ;; ...
19512 %base-services)))
19513 @end lisp
19514
19515 @deffn {Scheme Variable} knot-service-type
19516 This is the type for the Knot DNS server.
19517
19518 Knot DNS is an authoritative DNS server, meaning that it can serve multiple
19519 zones, that is to say domain names you would buy from a registrar. This server
19520 is not a resolver, meaning that it can only resolve names for which it is
19521 authoritative. This server can be configured to serve zones as a master server
19522 or a slave server as a per-zone basis. Slave zones will get their data from
19523 masters, and will serve it as an authoritative server. From the point of view
19524 of a resolver, there is no difference between master and slave.
19525
19526 The following data types are used to configure the Knot DNS server:
19527 @end deffn
19528
19529 @deftp {Data Type} knot-key-configuration
19530 Data type representing a key.
19531 This type has the following parameters:
19532
19533 @table @asis
19534 @item @code{id} (default: @code{""})
19535 An identifier for other configuration fields to refer to this key. IDs must
19536 be unique and must not be empty.
19537
19538 @item @code{algorithm} (default: @code{#f})
19539 The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
19540 @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
19541 and @code{'hmac-sha512}.
19542
19543 @item @code{secret} (default: @code{""})
19544 The secret key itself.
19545
19546 @end table
19547 @end deftp
19548
19549 @deftp {Data Type} knot-acl-configuration
19550 Data type representing an Access Control List (ACL) configuration.
19551 This type has the following parameters:
19552
19553 @table @asis
19554 @item @code{id} (default: @code{""})
19555 An identifier for ether configuration fields to refer to this key. IDs must be
19556 unique and must not be empty.
19557
19558 @item @code{address} (default: @code{'()})
19559 An ordered list of IP addresses, network subnets, or network ranges represented
19560 with strings. The query must match one of them. Empty value means that
19561 address match is not required.
19562
19563 @item @code{key} (default: @code{'()})
19564 An ordered list of references to keys represented with strings. The string
19565 must match a key ID defined in a @code{knot-key-configuration}. No key means
19566 that a key is not require to match that ACL.
19567
19568 @item @code{action} (default: @code{'()})
19569 An ordered list of actions that are permitted or forbidden by this ACL. Possible
19570 values are lists of zero or more elements from @code{'transfer}, @code{'notify}
19571 and @code{'update}.
19572
19573 @item @code{deny?} (default: @code{#f})
19574 When true, the ACL defines restrictions. Listed actions are forbidden. When
19575 false, listed actions are allowed.
19576
19577 @end table
19578 @end deftp
19579
19580 @deftp {Data Type} zone-entry
19581 Data type represnting a record entry in a zone file.
19582 This type has the following parameters:
19583
19584 @table @asis
19585 @item @code{name} (default: @code{"@@"})
19586 The name of the record. @code{"@@"} refers to the origin of the zone. Names
19587 are relative to the origin of the zone. For example, in the @code{example.org}
19588 zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
19589 Names ending with a dot are absolute, which means that @code{"ns.example.org."}
19590 refers to @code{ns.example.org}.
19591
19592 @item @code{ttl} (default: @code{""})
19593 The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
19594
19595 @item @code{class} (default: @code{"IN"})
19596 The class of the record. Knot currently supports only @code{"IN"} and
19597 partially @code{"CH"}.
19598
19599 @item @code{type} (default: @code{"A"})
19600 The type of the record. Common types include A (IPv4 address), AAAA (IPv6
19601 address), NS (Name Server) and MX (Mail eXchange). Many other types are
19602 defined.
19603
19604 @item @code{data} (default: @code{""})
19605 The data contained in the record. For instance an IP address associated with
19606 an A record, or a domain name associated with an NS record. Remember that
19607 domain names are relative to the origin unless they end with a dot.
19608
19609 @end table
19610 @end deftp
19611
19612 @deftp {Data Type} zone-file
19613 Data type representing the content of a zone file.
19614 This type has the following parameters:
19615
19616 @table @asis
19617 @item @code{entries} (default: @code{'()})
19618 The list of entries. The SOA record is taken care of, so you don't need to
19619 put it in the list of entries. This list should probably contain an entry
19620 for your primary authoritative DNS server. Other than using a list of entries
19621 directly, you can use @code{define-zone-entries} to define a object containing
19622 the list of entries more easily, that you can later pass to the @code{entries}
19623 field of the @code{zone-file}.
19624
19625 @item @code{origin} (default: @code{""})
19626 The name of your zone. This parameter cannot be empty.
19627
19628 @item @code{ns} (default: @code{"ns"})
19629 The domain of your primary authoritative DNS server. The name is relative to
19630 the origin, unless it ends with a dot. It is mandatory that this primary
19631 DNS server corresponds to an NS record in the zone and that it is associated
19632 to an IP address in the list of entries.
19633
19634 @item @code{mail} (default: @code{"hostmaster"})
19635 An email address people can contact you at, as the owner of the zone. This
19636 is translated as @code{<mail>@@<origin>}.
19637
19638 @item @code{serial} (default: @code{1})
19639 The serial number of the zone. As this is used to keep track of changes by
19640 both slaves and resolvers, it is mandatory that it @emph{never} decreases.
19641 Always increment it when you make a change in your zone.
19642
19643 @item @code{refresh} (default: @code{(* 2 24 3600)})
19644 The frequency at which slaves will do a zone transfer. This value is a number
19645 of seconds. It can be computed by multiplications or with
19646 @code{(string->duration)}.
19647
19648 @item @code{retry} (default: @code{(* 15 60)})
19649 The period after which a slave will retry to contact its master when it fails
19650 to do so a first time.
19651
19652 @item @code{expiry} (default: @code{(* 14 24 3600)})
19653 Default TTL of records. Existing records are considered correct for at most
19654 this amount of time. After this period, resolvers will invalidate their cache
19655 and check again that it still exists.
19656
19657 @item @code{nx} (default: @code{3600})
19658 Default TTL of inexistant records. This delay is usually short because you want
19659 your new domains to reach everyone quickly.
19660
19661 @end table
19662 @end deftp
19663
19664 @deftp {Data Type} knot-remote-configuration
19665 Data type representing a remote configuration.
19666 This type has the following parameters:
19667
19668 @table @asis
19669 @item @code{id} (default: @code{""})
19670 An identifier for other configuration fields to refer to this remote. IDs must
19671 be unique and must not be empty.
19672
19673 @item @code{address} (default: @code{'()})
19674 An ordered list of destination IP addresses. Addresses are tried in sequence.
19675 An optional port can be given with the @@ separator. For instance:
19676 @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
19677
19678 @item @code{via} (default: @code{'()})
19679 An ordered list of source IP addresses. An empty list will have Knot choose
19680 an appropriate source IP. An optional port can be given with the @@ separator.
19681 The default is to choose at random.
19682
19683 @item @code{key} (default: @code{#f})
19684 A reference to a key, that is a string containing the identifier of a key
19685 defined in a @code{knot-key-configuration} field.
19686
19687 @end table
19688 @end deftp
19689
19690 @deftp {Data Type} knot-keystore-configuration
19691 Data type representing a keystore to hold dnssec keys.
19692 This type has the following parameters:
19693
19694 @table @asis
19695 @item @code{id} (default: @code{""})
19696 The id of the keystore. It must not be empty.
19697
19698 @item @code{backend} (default: @code{'pem})
19699 The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
19700
19701 @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
19702 The configuration string of the backend. An example for the PKCS#11 is:
19703 @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
19704 For the pem backend, the string reprensents a path in the file system.
19705
19706 @end table
19707 @end deftp
19708
19709 @deftp {Data Type} knot-policy-configuration
19710 Data type representing a dnssec policy. Knot DNS is able to automatically
19711 sign your zones. It can either generate and manage your keys automatically or
19712 use keys that you generate.
19713
19714 Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
19715 used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
19716 zone. In order to be trusted, the KSK needs to be present in the parent zone
19717 (usually a top-level domain). If your registrar supports dnssec, you will
19718 have to send them your KSK's hash so they can add a DS record in their zone.
19719 This is not automated and need to be done each time you change your KSK.
19720
19721 The policy also defines the lifetime of keys. Usually, ZSK can be changed
19722 easily and use weaker cryptographic functions (they use lower parameters) in
19723 order to sign records quickly, so they are changed often. The KSK however
19724 requires manual interaction with the registrar, so they are changed less often
19725 and use stronger parameters because they sign only one record.
19726
19727 This type has the following parameters:
19728
19729 @table @asis
19730 @item @code{id} (default: @code{""})
19731 The id of the policy. It must not be empty.
19732
19733 @item @code{keystore} (default: @code{"default"})
19734 A reference to a keystore, that is a string containing the identifier of a
19735 keystore defined in a @code{knot-keystore-configuration} field. The
19736 @code{"default"} identifier means the default keystore (a kasp database that
19737 was setup by this service).
19738
19739 @item @code{manual?} (default: @code{#f})
19740 Whether the key management is manual or automatic.
19741
19742 @item @code{single-type-signing?} (default: @code{#f})
19743 When @code{#t}, use the Single-Type Signing Scheme.
19744
19745 @item @code{algorithm} (default: @code{"ecdsap256sha256"})
19746 An algorithm of signing keys and issued signatures.
19747
19748 @item @code{ksk-size} (default: @code{256})
19749 The length of the KSK. Note that this value is correct for the default
19750 algorithm, but would be unsecure for other algorithms.
19751
19752 @item @code{zsk-size} (default: @code{256})
19753 The length of the ZSK. Note that this value is correct for the default
19754 algorithm, but would be unsecure for other algorithms.
19755
19756 @item @code{dnskey-ttl} (default: @code{'default})
19757 The TTL value for DNSKEY records added into zone apex. The special
19758 @code{'default} value means same as the zone SOA TTL.
19759
19760 @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
19761 The period between ZSK publication and the next rollover initiation.
19762
19763 @item @code{propagation-delay} (default: @code{(* 24 3600)})
19764 An extra delay added for each key rollover step. This value should be high
19765 enough to cover propagation of data from the master server to all slaves.
19766
19767 @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
19768 A validity period of newly issued signatures.
19769
19770 @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
19771 A period how long before a signature expiration the signature will be refreshed.
19772
19773 @item @code{nsec3?} (default: @code{#f})
19774 When @code{#t}, NSEC3 will be used instead of NSEC.
19775
19776 @item @code{nsec3-iterations} (default: @code{5})
19777 The number of additional times the hashing is performed.
19778
19779 @item @code{nsec3-salt-length} (default: @code{8})
19780 The length of a salt field in octets, which is appended to the original owner
19781 name before hashing.
19782
19783 @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
19784 The validity period of newly issued salt field.
19785
19786 @end table
19787 @end deftp
19788
19789 @deftp {Data Type} knot-zone-configuration
19790 Data type representing a zone served by Knot.
19791 This type has the following parameters:
19792
19793 @table @asis
19794 @item @code{domain} (default: @code{""})
19795 The domain served by this configuration. It must not be empty.
19796
19797 @item @code{file} (default: @code{""})
19798 The file where this zone is saved. This parameter is ignored by master zones.
19799 Empty means default location that depends on the domain name.
19800
19801 @item @code{zone} (default: @code{(zone-file)})
19802 The content of the zone file. This parameter is ignored by slave zones. It
19803 must contain a zone-file record.
19804
19805 @item @code{master} (default: @code{'()})
19806 A list of master remotes. When empty, this zone is a master. When set, this
19807 zone is a slave. This is a list of remotes identifiers.
19808
19809 @item @code{ddns-master} (default: @code{#f})
19810 The main master. When empty, it defaults to the first master in the list of
19811 masters.
19812
19813 @item @code{notify} (default: @code{'()})
19814 A list of slave remote identifiers.
19815
19816 @item @code{acl} (default: @code{'()})
19817 A list of acl identifiers.
19818
19819 @item @code{semantic-checks?} (default: @code{#f})
19820 When set, this adds more semantic checks to the zone.
19821
19822 @item @code{disable-any?} (default: @code{#f})
19823 When set, this forbids queries of the ANY type.
19824
19825 @item @code{zonefile-sync} (default: @code{0})
19826 The delay between a modification in memory and on disk. 0 means immediate
19827 synchronization.
19828
19829 @item @code{serial-policy} (default: @code{'increment})
19830 A policy between @code{'increment} and @code{'unixtime}.
19831
19832 @end table
19833 @end deftp
19834
19835 @deftp {Data Type} knot-configuration
19836 Data type representing the Knot configuration.
19837 This type has the following parameters:
19838
19839 @table @asis
19840 @item @code{knot} (default: @code{knot})
19841 The Knot package.
19842
19843 @item @code{run-directory} (default: @code{"/var/run/knot"})
19844 The run directory. This directory will be used for pid file and sockets.
19845
19846 @item @code{includes} (default: @code{'()})
19847 A list of strings or file-like objects denoting other files that must be
19848 included at the top of the configuration file.
19849
19850 @cindex secrets, Knot service
19851 This can be used to manage secrets out-of-band. For example, secret
19852 keys may be stored in an out-of-band file not managed by Guix, and
19853 thus not visible in @file{/gnu/store}---e.g., you could store secret
19854 key configuration in @file{/etc/knot/secrets.conf} and add this file
19855 to the @code{includes} list.
19856
19857 It can also be used to add configuration not supported by this interface.
19858
19859 @item @code{listen-v4} (default: @code{"0.0.0.0"})
19860 An ip address on which to listen.
19861
19862 @item @code{listen-v6} (default: @code{"::"})
19863 An ip address on which to listen.
19864
19865 @item @code{listen-port} (default: @code{53})
19866 A port on which to listen.
19867
19868 @item @code{keys} (default: @code{'()})
19869 The list of knot-key-configuration used by this configuration.
19870
19871 @item @code{acls} (default: @code{'()})
19872 The list of knot-acl-configuration used by this configuration.
19873
19874 @item @code{remotes} (default: @code{'()})
19875 The list of knot-remote-configuration used by this configuration.
19876
19877 @item @code{zones} (default: @code{'()})
19878 The list of knot-zone-configuration used by this configuration.
19879
19880 @end table
19881 @end deftp
19882
19883 @subsubheading Dnsmasq Service
19884
19885 @deffn {Scheme Variable} dnsmasq-service-type
19886 This is the type of the dnsmasq service, whose value should be an
19887 @code{dnsmasq-configuration} object as in this example:
19888
19889 @example
19890 (service dnsmasq-service-type
19891 (dnsmasq-configuration
19892 (no-resolv? #t)
19893 (servers '("192.168.1.1"))))
19894 @end example
19895 @end deffn
19896
19897 @deftp {Data Type} dnsmasq-configuration
19898 Data type representing the configuration of dnsmasq.
19899
19900 @table @asis
19901 @item @code{package} (default: @var{dnsmasq})
19902 Package object of the dnsmasq server.
19903
19904 @item @code{no-hosts?} (default: @code{#f})
19905 When true, don't read the hostnames in /etc/hosts.
19906
19907 @item @code{port} (default: @code{53})
19908 The port to listen on. Setting this to zero completely disables DNS
19909 responses, leaving only DHCP and/or TFTP functions.
19910
19911 @item @code{local-service?} (default: @code{#t})
19912 Accept DNS queries only from hosts whose address is on a local subnet,
19913 ie a subnet for which an interface exists on the server.
19914
19915 @item @code{listen-addresses} (default: @code{'()})
19916 Listen on the given IP addresses.
19917
19918 @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
19919 The file to read the IP address of the upstream nameservers from.
19920
19921 @item @code{no-resolv?} (default: @code{#f})
19922 When true, don't read @var{resolv-file}.
19923
19924 @item @code{servers} (default: @code{'()})
19925 Specify IP address of upstream servers directly.
19926
19927 @item @code{cache-size} (default: @code{150})
19928 Set the size of dnsmasq's cache. Setting the cache size to zero
19929 disables caching.
19930
19931 @item @code{negative-cache?} (default: @code{#t})
19932 When false, disable negative caching.
19933
19934 @end table
19935 @end deftp
19936
19937 @subsubheading ddclient Service
19938
19939 @cindex ddclient
19940 The ddclient service described below runs the ddclient daemon, which takes
19941 care of automatically updating DNS entries for service providers such as
19942 @uref{https://dyn.com/dns/, Dyn}.
19943
19944 The following example show instantiates the service with its default
19945 configuration:
19946
19947 @example
19948 (service ddclient-service-type)
19949 @end example
19950
19951 Note that ddclient needs to access credentials that are stored in a
19952 @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
19953 @code{secret-file} below.) You are expected to create this file manually, in
19954 an ``out-of-band'' fashion (you @emph{could} make this file part of the
19955 service configuration, for instance by using @code{plain-file}, but it will be
19956 world-readable @i{via} @file{/gnu/store}.) See the examples in the
19957 @file{share/ddclient} directory of the @code{ddclient} package.
19958
19959 @c %start of fragment
19960
19961 Available @code{ddclient-configuration} fields are:
19962
19963 @deftypevr {@code{ddclient-configuration} parameter} package ddclient
19964 The ddclient package.
19965
19966 @end deftypevr
19967
19968 @deftypevr {@code{ddclient-configuration} parameter} integer daemon
19969 The period after which ddclient will retry to check IP and domain name.
19970
19971 Defaults to @samp{300}.
19972
19973 @end deftypevr
19974
19975 @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
19976 Use syslog for the output.
19977
19978 Defaults to @samp{#t}.
19979
19980 @end deftypevr
19981
19982 @deftypevr {@code{ddclient-configuration} parameter} string mail
19983 Mail to user.
19984
19985 Defaults to @samp{"root"}.
19986
19987 @end deftypevr
19988
19989 @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
19990 Mail failed update to user.
19991
19992 Defaults to @samp{"root"}.
19993
19994 @end deftypevr
19995
19996 @deftypevr {@code{ddclient-configuration} parameter} string pid
19997 The ddclient PID file.
19998
19999 Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
20000
20001 @end deftypevr
20002
20003 @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
20004 Enable SSL support.
20005
20006 Defaults to @samp{#t}.
20007
20008 @end deftypevr
20009
20010 @deftypevr {@code{ddclient-configuration} parameter} string user
20011 Specifies the user name or ID that is used when running ddclient
20012 program.
20013
20014 Defaults to @samp{"ddclient"}.
20015
20016 @end deftypevr
20017
20018 @deftypevr {@code{ddclient-configuration} parameter} string group
20019 Group of the user who will run the ddclient program.
20020
20021 Defaults to @samp{"ddclient"}.
20022
20023 @end deftypevr
20024
20025 @deftypevr {@code{ddclient-configuration} parameter} string secret-file
20026 Secret file which will be appended to @file{ddclient.conf} file. This
20027 file contains credentials for use by ddclient. You are expected to
20028 create it manually.
20029
20030 Defaults to @samp{"/etc/ddclient/secrets.conf"}.
20031
20032 @end deftypevr
20033
20034 @deftypevr {@code{ddclient-configuration} parameter} list extra-options
20035 Extra options will be appended to @file{ddclient.conf} file.
20036
20037 Defaults to @samp{()}.
20038
20039 @end deftypevr
20040
20041
20042 @c %end of fragment
20043
20044
20045 @node VPN Services
20046 @subsection VPN Services
20047 @cindex VPN (virtual private network)
20048 @cindex virtual private network (VPN)
20049
20050 The @code{(gnu services vpn)} module provides services related to
20051 @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
20052 your machine to connect to a VPN, and a @emph{servire} service for your machine
20053 to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
20054
20055 @deffn {Scheme Procedure} openvpn-client-service @
20056 [#:config (openvpn-client-configuration)]
20057
20058 Return a service that runs @command{openvpn}, a VPN daemon, as a client.
20059 @end deffn
20060
20061 @deffn {Scheme Procedure} openvpn-server-service @
20062 [#:config (openvpn-server-configuration)]
20063
20064 Return a service that runs @command{openvpn}, a VPN daemon, as a server.
20065
20066 Both can be run simultaneously.
20067 @end deffn
20068
20069 @c %automatically generated documentation
20070
20071 Available @code{openvpn-client-configuration} fields are:
20072
20073 @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
20074 The OpenVPN package.
20075
20076 @end deftypevr
20077
20078 @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
20079 The OpenVPN pid file.
20080
20081 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
20082
20083 @end deftypevr
20084
20085 @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
20086 The protocol (UDP or TCP) used to open a channel between clients and
20087 servers.
20088
20089 Defaults to @samp{udp}.
20090
20091 @end deftypevr
20092
20093 @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
20094 The device type used to represent the VPN connection.
20095
20096 Defaults to @samp{tun}.
20097
20098 @end deftypevr
20099
20100 @deftypevr {@code{openvpn-client-configuration} parameter} string ca
20101 The certificate authority to check connections against.
20102
20103 Defaults to @samp{"/etc/openvpn/ca.crt"}.
20104
20105 @end deftypevr
20106
20107 @deftypevr {@code{openvpn-client-configuration} parameter} string cert
20108 The certificate of the machine the daemon is running on. It should be
20109 signed by the authority given in @code{ca}.
20110
20111 Defaults to @samp{"/etc/openvpn/client.crt"}.
20112
20113 @end deftypevr
20114
20115 @deftypevr {@code{openvpn-client-configuration} parameter} string key
20116 The key of the machine the daemon is running on. It must be the key whose
20117 certificate is @code{cert}.
20118
20119 Defaults to @samp{"/etc/openvpn/client.key"}.
20120
20121 @end deftypevr
20122
20123 @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
20124 Whether to use the lzo compression algorithm.
20125
20126 Defaults to @samp{#t}.
20127
20128 @end deftypevr
20129
20130 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
20131 Don't re-read key files across SIGUSR1 or --ping-restart.
20132
20133 Defaults to @samp{#t}.
20134
20135 @end deftypevr
20136
20137 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
20138 Don't close and reopen TUN/TAP device or run up/down scripts across
20139 SIGUSR1 or --ping-restart restarts.
20140
20141 Defaults to @samp{#t}.
20142
20143 @end deftypevr
20144
20145 @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
20146 Verbosity level.
20147
20148 Defaults to @samp{3}.
20149
20150 @end deftypevr
20151
20152 @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
20153 Add an additional layer of HMAC authentication on top of the TLS control
20154 channel to protect against DoS attacks.
20155
20156 Defaults to @samp{#f}.
20157
20158 @end deftypevr
20159
20160 @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
20161 Whether to check the server certificate has server usage extension.
20162
20163 Defaults to @samp{#t}.
20164
20165 @end deftypevr
20166
20167 @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
20168 Bind to a specific local port number.
20169
20170 Defaults to @samp{#f}.
20171
20172 @end deftypevr
20173
20174 @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
20175 Retry resolving server address.
20176
20177 Defaults to @samp{#t}.
20178
20179 @end deftypevr
20180
20181 @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
20182 A list of remote servers to connect to.
20183
20184 Defaults to @samp{()}.
20185
20186 Available @code{openvpn-remote-configuration} fields are:
20187
20188 @deftypevr {@code{openvpn-remote-configuration} parameter} string name
20189 Server name.
20190
20191 Defaults to @samp{"my-server"}.
20192
20193 @end deftypevr
20194
20195 @deftypevr {@code{openvpn-remote-configuration} parameter} number port
20196 Port number the server listens to.
20197
20198 Defaults to @samp{1194}.
20199
20200 @end deftypevr
20201
20202 @end deftypevr
20203 @c %end of automatic openvpn-client documentation
20204
20205 @c %automatically generated documentation
20206
20207 Available @code{openvpn-server-configuration} fields are:
20208
20209 @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
20210 The OpenVPN package.
20211
20212 @end deftypevr
20213
20214 @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
20215 The OpenVPN pid file.
20216
20217 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
20218
20219 @end deftypevr
20220
20221 @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
20222 The protocol (UDP or TCP) used to open a channel between clients and
20223 servers.
20224
20225 Defaults to @samp{udp}.
20226
20227 @end deftypevr
20228
20229 @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
20230 The device type used to represent the VPN connection.
20231
20232 Defaults to @samp{tun}.
20233
20234 @end deftypevr
20235
20236 @deftypevr {@code{openvpn-server-configuration} parameter} string ca
20237 The certificate authority to check connections against.
20238
20239 Defaults to @samp{"/etc/openvpn/ca.crt"}.
20240
20241 @end deftypevr
20242
20243 @deftypevr {@code{openvpn-server-configuration} parameter} string cert
20244 The certificate of the machine the daemon is running on. It should be
20245 signed by the authority given in @code{ca}.
20246
20247 Defaults to @samp{"/etc/openvpn/client.crt"}.
20248
20249 @end deftypevr
20250
20251 @deftypevr {@code{openvpn-server-configuration} parameter} string key
20252 The key of the machine the daemon is running on. It must be the key whose
20253 certificate is @code{cert}.
20254
20255 Defaults to @samp{"/etc/openvpn/client.key"}.
20256
20257 @end deftypevr
20258
20259 @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
20260 Whether to use the lzo compression algorithm.
20261
20262 Defaults to @samp{#t}.
20263
20264 @end deftypevr
20265
20266 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
20267 Don't re-read key files across SIGUSR1 or --ping-restart.
20268
20269 Defaults to @samp{#t}.
20270
20271 @end deftypevr
20272
20273 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
20274 Don't close and reopen TUN/TAP device or run up/down scripts across
20275 SIGUSR1 or --ping-restart restarts.
20276
20277 Defaults to @samp{#t}.
20278
20279 @end deftypevr
20280
20281 @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
20282 Verbosity level.
20283
20284 Defaults to @samp{3}.
20285
20286 @end deftypevr
20287
20288 @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
20289 Add an additional layer of HMAC authentication on top of the TLS control
20290 channel to protect against DoS attacks.
20291
20292 Defaults to @samp{#f}.
20293
20294 @end deftypevr
20295
20296 @deftypevr {@code{openvpn-server-configuration} parameter} number port
20297 Specifies the port number on which the server listens.
20298
20299 Defaults to @samp{1194}.
20300
20301 @end deftypevr
20302
20303 @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
20304 An ip and mask specifying the subnet inside the virtual network.
20305
20306 Defaults to @samp{"10.8.0.0 255.255.255.0"}.
20307
20308 @end deftypevr
20309
20310 @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
20311 A CIDR notation specifying the IPv6 subnet inside the virtual network.
20312
20313 Defaults to @samp{#f}.
20314
20315 @end deftypevr
20316
20317 @deftypevr {@code{openvpn-server-configuration} parameter} string dh
20318 The Diffie-Hellman parameters file.
20319
20320 Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
20321
20322 @end deftypevr
20323
20324 @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
20325 The file that records client IPs.
20326
20327 Defaults to @samp{"/etc/openvpn/ipp.txt"}.
20328
20329 @end deftypevr
20330
20331 @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
20332 When true, the server will act as a gateway for its clients.
20333
20334 Defaults to @samp{#f}.
20335
20336 @end deftypevr
20337
20338 @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
20339 When true, clients are allowed to talk to each other inside the VPN.
20340
20341 Defaults to @samp{#f}.
20342
20343 @end deftypevr
20344
20345 @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
20346 Causes ping-like messages to be sent back and forth over the link so
20347 that each side knows when the other side has gone down. @code{keepalive}
20348 requires a pair. The first element is the period of the ping sending,
20349 and the second element is the timeout before considering the other side
20350 down.
20351
20352 @end deftypevr
20353
20354 @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
20355 The maximum number of clients.
20356
20357 Defaults to @samp{100}.
20358
20359 @end deftypevr
20360
20361 @deftypevr {@code{openvpn-server-configuration} parameter} string status
20362 The status file. This file shows a small report on current connection.
20363 It is truncated and rewritten every minute.
20364
20365 Defaults to @samp{"/var/run/openvpn/status"}.
20366
20367 @end deftypevr
20368
20369 @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
20370 The list of configuration for some clients.
20371
20372 Defaults to @samp{()}.
20373
20374 Available @code{openvpn-ccd-configuration} fields are:
20375
20376 @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
20377 Client name.
20378
20379 Defaults to @samp{"client"}.
20380
20381 @end deftypevr
20382
20383 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
20384 Client own network
20385
20386 Defaults to @samp{#f}.
20387
20388 @end deftypevr
20389
20390 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
20391 Client VPN IP.
20392
20393 Defaults to @samp{#f}.
20394
20395 @end deftypevr
20396
20397 @end deftypevr
20398
20399
20400 @c %end of automatic openvpn-server documentation
20401
20402
20403 @node Network File System
20404 @subsection Network File System
20405 @cindex NFS
20406
20407 The @code{(gnu services nfs)} module provides the following services,
20408 which are most commonly used in relation to mounting or exporting
20409 directory trees as @dfn{network file systems} (NFS).
20410
20411 @subsubheading RPC Bind Service
20412 @cindex rpcbind
20413
20414 The RPC Bind service provides a facility to map program numbers into
20415 universal addresses.
20416 Many NFS related services use this facility. Hence it is automatically
20417 started when a dependent service starts.
20418
20419 @defvr {Scheme Variable} rpcbind-service-type
20420 A service type for the RPC portmapper daemon.
20421 @end defvr
20422
20423
20424 @deftp {Data Type} rpcbind-configuration
20425 Data type representing the configuration of the RPC Bind Service.
20426 This type has the following parameters:
20427 @table @asis
20428 @item @code{rpcbind} (default: @code{rpcbind})
20429 The rpcbind package to use.
20430
20431 @item @code{warm-start?} (default: @code{#t})
20432 If this parameter is @code{#t}, then the daemon will read a
20433 state file on startup thus reloading state information saved by a previous
20434 instance.
20435 @end table
20436 @end deftp
20437
20438
20439 @subsubheading Pipefs Pseudo File System
20440 @cindex pipefs
20441 @cindex rpc_pipefs
20442
20443 The pipefs file system is used to transfer NFS related data
20444 between the kernel and user space programs.
20445
20446 @defvr {Scheme Variable} pipefs-service-type
20447 A service type for the pipefs pseudo file system.
20448 @end defvr
20449
20450 @deftp {Data Type} pipefs-configuration
20451 Data type representing the configuration of the pipefs pseudo file system service.
20452 This type has the following parameters:
20453 @table @asis
20454 @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
20455 The directory to which the file system is to be attached.
20456 @end table
20457 @end deftp
20458
20459
20460 @subsubheading GSS Daemon Service
20461 @cindex GSSD
20462 @cindex GSS
20463 @cindex global security system
20464
20465 The @dfn{global security system} (GSS) daemon provides strong security for RPC
20466 based protocols.
20467 Before exchanging RPC requests an RPC client must establish a security
20468 context. Typically this is done using the Kerberos command @command{kinit}
20469 or automatically at login time using PAM services (@pxref{Kerberos Services}).
20470
20471 @defvr {Scheme Variable} gss-service-type
20472 A service type for the Global Security System (GSS) daemon.
20473 @end defvr
20474
20475 @deftp {Data Type} gss-configuration
20476 Data type representing the configuration of the GSS daemon service.
20477 This type has the following parameters:
20478 @table @asis
20479 @item @code{nfs-utils} (default: @code{nfs-utils})
20480 The package in which the @command{rpc.gssd} command is to be found.
20481
20482 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
20483 The directory where the pipefs file system is mounted.
20484
20485 @end table
20486 @end deftp
20487
20488
20489 @subsubheading IDMAP Daemon Service
20490 @cindex idmapd
20491 @cindex name mapper
20492
20493 The idmap daemon service provides mapping between user IDs and user names.
20494 Typically it is required in order to access file systems mounted via NFSv4.
20495
20496 @defvr {Scheme Variable} idmap-service-type
20497 A service type for the Identity Mapper (IDMAP) daemon.
20498 @end defvr
20499
20500 @deftp {Data Type} idmap-configuration
20501 Data type representing the configuration of the IDMAP daemon service.
20502 This type has the following parameters:
20503 @table @asis
20504 @item @code{nfs-utils} (default: @code{nfs-utils})
20505 The package in which the @command{rpc.idmapd} command is to be found.
20506
20507 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
20508 The directory where the pipefs file system is mounted.
20509
20510 @item @code{domain} (default: @code{#f})
20511 The local NFSv4 domain name.
20512 This must be a string or @code{#f}.
20513 If it is @code{#f} then the daemon will use the host's fully qualified domain name.
20514
20515 @end table
20516 @end deftp
20517
20518 @node Continuous Integration
20519 @subsection Continuous Integration
20520
20521 @cindex continuous integration
20522 @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
20523 continuous integration tool for Guix. It can be used both for development and
20524 for providing substitutes to others (@pxref{Substitutes}).
20525
20526 The @code{(gnu services cuirass)} module provides the following service.
20527
20528 @defvr {Scheme Procedure} cuirass-service-type
20529 The type of the Cuirass service. Its value must be a
20530 @code{cuirass-configuration} object, as described below.
20531 @end defvr
20532
20533 To add build jobs, you have to set the @code{specifications} field of the
20534 configuration. Here is an example of a service that polls the Guix repository
20535 and builds the packages from a manifest. Some of the packages are defined in
20536 the @code{"custom-packages"} input, which is the equivalent of
20537 @code{GUIX_PACKAGE_PATH}.
20538
20539 @example
20540 (define %cuirass-specs
20541 #~(list
20542 '((#:name . "my-manifest")
20543 (#:load-path-inputs . ("guix"))
20544 (#:package-path-inputs . ("custom-packages"))
20545 (#:proc-input . "guix")
20546 (#:proc-file . "build-aux/cuirass/gnu-system.scm")
20547 (#:proc . cuirass-jobs)
20548 (#:proc-args . ((subset . "manifests")
20549 (systems . ("x86_64-linux"))
20550 (manifests . (("config" . "guix/manifest.scm")))))
20551 (#:inputs . (((#:name . "guix")
20552 (#:url . "git://git.savannah.gnu.org/guix.git")
20553 (#:load-path . ".")
20554 (#:branch . "master")
20555 (#:no-compile? . #t))
20556 ((#:name . "config")
20557 (#:url . "git://git.example.org/config.git")
20558 (#:load-path . ".")
20559 (#:branch . "master")
20560 (#:no-compile? . #t))
20561 ((#:name . "custom-packages")
20562 (#:url . "git://git.example.org/custom-packages.git")
20563 (#:load-path . ".")
20564 (#:branch . "master")
20565 (#:no-compile? . #t)))))))
20566
20567 (service cuirass-service-type
20568 (cuirass-configuration
20569 (specifications %cuirass-specs)))
20570 @end example
20571
20572 While information related to build jobs is located directly in the
20573 specifications, global settings for the @command{cuirass} process are
20574 accessible in other @code{cuirass-configuration} fields.
20575
20576 @deftp {Data Type} cuirass-configuration
20577 Data type representing the configuration of Cuirass.
20578
20579 @table @asis
20580 @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
20581 Location of the log file.
20582
20583 @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
20584 Location of the repository cache.
20585
20586 @item @code{user} (default: @code{"cuirass"})
20587 Owner of the @code{cuirass} process.
20588
20589 @item @code{group} (default: @code{"cuirass"})
20590 Owner's group of the @code{cuirass} process.
20591
20592 @item @code{interval} (default: @code{60})
20593 Number of seconds between the poll of the repositories followed by the
20594 Cuirass jobs.
20595
20596 @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
20597 Location of sqlite database which contains the build results and previously
20598 added specifications.
20599
20600 @item @code{ttl} (default: @code{(* 30 24 3600)})
20601 Specifies the time-to-live (TTL) in seconds of garbage collector roots that
20602 are registered for build results. This means that build results are protected
20603 from garbage collection for at least @var{ttl} seconds.
20604
20605 @item @code{port} (default: @code{8081})
20606 Port number used by the HTTP server.
20607
20608 @item --listen=@var{host}
20609 Listen on the network interface for @var{host}. The default is to
20610 accept connections from localhost.
20611
20612 @item @code{specifications} (default: @code{#~'()})
20613 A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
20614 where a specification is an association list
20615 (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
20616 keys are keywords (@code{#:keyword-example}) as shown in the example
20617 above.
20618
20619 @item @code{use-substitutes?} (default: @code{#f})
20620 This allows using substitutes to avoid building every dependencies of a job
20621 from source.
20622
20623 @item @code{one-shot?} (default: @code{#f})
20624 Only evaluate specifications and build derivations once.
20625
20626 @item @code{fallback?} (default: @code{#f})
20627 When substituting a pre-built binary fails, fall back to building
20628 packages locally.
20629
20630 @item @code{cuirass} (default: @code{cuirass})
20631 The Cuirass package to use.
20632 @end table
20633 @end deftp
20634
20635 @node Power Management Services
20636 @subsection Power Management Services
20637
20638 @cindex tlp
20639 @cindex power management with TLP
20640 @subsubheading TLP daemon
20641
20642 The @code{(gnu services pm)} module provides a Guix service definition
20643 for the Linux power management tool TLP.
20644
20645 TLP enables various powersaving modes in userspace and kernel.
20646 Contrary to @code{upower-service}, it is not a passive,
20647 monitoring tool, as it will apply custom settings each time a new power
20648 source is detected. More information can be found at
20649 @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
20650
20651 @deffn {Scheme Variable} tlp-service-type
20652 The service type for the TLP tool. Its value should be a valid
20653 TLP configuration (see below). To use the default settings, simply
20654 write:
20655 @example
20656 (service tlp-service-type)
20657 @end example
20658 @end deffn
20659
20660 By default TLP does not need much configuration but most TLP parameters
20661 can be tweaked using @code{tlp-configuration}.
20662
20663 Each parameter definition is preceded by its type; for example,
20664 @samp{boolean foo} indicates that the @code{foo} parameter
20665 should be specified as a boolean. Types starting with
20666 @code{maybe-} denote parameters that won't show up in TLP config file
20667 when their value is @code{'disabled}.
20668
20669 @c The following documentation was initially generated by
20670 @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
20671 @c documentation is better, so we shouldn't hesitate to edit below as
20672 @c needed. However if the change you want to make to this documentation
20673 @c can be done in an automated way, it's probably easier to change
20674 @c (generate-documentation) than to make it below and have to deal with
20675 @c the churn as TLP updates.
20676
20677 Available @code{tlp-configuration} fields are:
20678
20679 @deftypevr {@code{tlp-configuration} parameter} package tlp
20680 The TLP package.
20681
20682 @end deftypevr
20683
20684 @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
20685 Set to true if you wish to enable TLP.
20686
20687 Defaults to @samp{#t}.
20688
20689 @end deftypevr
20690
20691 @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
20692 Default mode when no power supply can be detected. Alternatives are AC
20693 and BAT.
20694
20695 Defaults to @samp{"AC"}.
20696
20697 @end deftypevr
20698
20699 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
20700 Number of seconds Linux kernel has to wait after the disk goes idle,
20701 before syncing on AC.
20702
20703 Defaults to @samp{0}.
20704
20705 @end deftypevr
20706
20707 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
20708 Same as @code{disk-idle-ac} but on BAT mode.
20709
20710 Defaults to @samp{2}.
20711
20712 @end deftypevr
20713
20714 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
20715 Dirty pages flushing periodicity, expressed in seconds.
20716
20717 Defaults to @samp{15}.
20718
20719 @end deftypevr
20720
20721 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
20722 Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
20723
20724 Defaults to @samp{60}.
20725
20726 @end deftypevr
20727
20728 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
20729 CPU frequency scaling governor on AC mode. With intel_pstate driver,
20730 alternatives are powersave and performance. With acpi-cpufreq driver,
20731 alternatives are ondemand, powersave, performance and conservative.
20732
20733 Defaults to @samp{disabled}.
20734
20735 @end deftypevr
20736
20737 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
20738 Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
20739
20740 Defaults to @samp{disabled}.
20741
20742 @end deftypevr
20743
20744 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
20745 Set the min available frequency for the scaling governor on AC.
20746
20747 Defaults to @samp{disabled}.
20748
20749 @end deftypevr
20750
20751 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
20752 Set the max available frequency for the scaling governor on AC.
20753
20754 Defaults to @samp{disabled}.
20755
20756 @end deftypevr
20757
20758 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
20759 Set the min available frequency for the scaling governor on BAT.
20760
20761 Defaults to @samp{disabled}.
20762
20763 @end deftypevr
20764
20765 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
20766 Set the max available frequency for the scaling governor on BAT.
20767
20768 Defaults to @samp{disabled}.
20769
20770 @end deftypevr
20771
20772 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
20773 Limit the min P-state to control the power dissipation of the CPU, in AC
20774 mode. Values are stated as a percentage of the available performance.
20775
20776 Defaults to @samp{disabled}.
20777
20778 @end deftypevr
20779
20780 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
20781 Limit the max P-state to control the power dissipation of the CPU, in AC
20782 mode. Values are stated as a percentage of the available performance.
20783
20784 Defaults to @samp{disabled}.
20785
20786 @end deftypevr
20787
20788 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
20789 Same as @code{cpu-min-perf-on-ac} on BAT mode.
20790
20791 Defaults to @samp{disabled}.
20792
20793 @end deftypevr
20794
20795 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
20796 Same as @code{cpu-max-perf-on-ac} on BAT mode.
20797
20798 Defaults to @samp{disabled}.
20799
20800 @end deftypevr
20801
20802 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
20803 Enable CPU turbo boost feature on AC mode.
20804
20805 Defaults to @samp{disabled}.
20806
20807 @end deftypevr
20808
20809 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
20810 Same as @code{cpu-boost-on-ac?} on BAT mode.
20811
20812 Defaults to @samp{disabled}.
20813
20814 @end deftypevr
20815
20816 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
20817 Allow Linux kernel to minimize the number of CPU cores/hyper-threads
20818 used under light load conditions.
20819
20820 Defaults to @samp{#f}.
20821
20822 @end deftypevr
20823
20824 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
20825 Same as @code{sched-powersave-on-ac?} but on BAT mode.
20826
20827 Defaults to @samp{#t}.
20828
20829 @end deftypevr
20830
20831 @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
20832 Enable Linux kernel NMI watchdog.
20833
20834 Defaults to @samp{#f}.
20835
20836 @end deftypevr
20837
20838 @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
20839 For Linux kernels with PHC patch applied, change CPU voltages. An
20840 example value would be @samp{"F:V F:V F:V F:V"}.
20841
20842 Defaults to @samp{disabled}.
20843
20844 @end deftypevr
20845
20846 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
20847 Set CPU performance versus energy saving policy on AC. Alternatives are
20848 performance, normal, powersave.
20849
20850 Defaults to @samp{"performance"}.
20851
20852 @end deftypevr
20853
20854 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
20855 Same as @code{energy-perf-policy-ac} but on BAT mode.
20856
20857 Defaults to @samp{"powersave"}.
20858
20859 @end deftypevr
20860
20861 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
20862 Hard disk devices.
20863
20864 @end deftypevr
20865
20866 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
20867 Hard disk advanced power management level.
20868
20869 @end deftypevr
20870
20871 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
20872 Same as @code{disk-apm-bat} but on BAT mode.
20873
20874 @end deftypevr
20875
20876 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
20877 Hard disk spin down timeout. One value has to be specified for each
20878 declared hard disk.
20879
20880 Defaults to @samp{disabled}.
20881
20882 @end deftypevr
20883
20884 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
20885 Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
20886
20887 Defaults to @samp{disabled}.
20888
20889 @end deftypevr
20890
20891 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
20892 Select IO scheduler for disk devices. One value has to be specified for
20893 each declared hard disk. Example alternatives are cfq, deadline and
20894 noop.
20895
20896 Defaults to @samp{disabled}.
20897
20898 @end deftypevr
20899
20900 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
20901 SATA aggressive link power management (ALPM) level. Alternatives are
20902 min_power, medium_power, max_performance.
20903
20904 Defaults to @samp{"max_performance"}.
20905
20906 @end deftypevr
20907
20908 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
20909 Same as @code{sata-linkpwr-ac} but on BAT mode.
20910
20911 Defaults to @samp{"min_power"}.
20912
20913 @end deftypevr
20914
20915 @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
20916 Exclude specified SATA host devices for link power management.
20917
20918 Defaults to @samp{disabled}.
20919
20920 @end deftypevr
20921
20922 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
20923 Enable Runtime Power Management for AHCI controller and disks on AC
20924 mode.
20925
20926 Defaults to @samp{disabled}.
20927
20928 @end deftypevr
20929
20930 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
20931 Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
20932
20933 Defaults to @samp{disabled}.
20934
20935 @end deftypevr
20936
20937 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
20938 Seconds of inactivity before disk is suspended.
20939
20940 Defaults to @samp{15}.
20941
20942 @end deftypevr
20943
20944 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
20945 PCI Express Active State Power Management level. Alternatives are
20946 default, performance, powersave.
20947
20948 Defaults to @samp{"performance"}.
20949
20950 @end deftypevr
20951
20952 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
20953 Same as @code{pcie-aspm-ac} but on BAT mode.
20954
20955 Defaults to @samp{"powersave"}.
20956
20957 @end deftypevr
20958
20959 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
20960 Radeon graphics clock speed level. Alternatives are low, mid, high,
20961 auto, default.
20962
20963 Defaults to @samp{"high"}.
20964
20965 @end deftypevr
20966
20967 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
20968 Same as @code{radeon-power-ac} but on BAT mode.
20969
20970 Defaults to @samp{"low"}.
20971
20972 @end deftypevr
20973
20974 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
20975 Radeon dynamic power management method (DPM). Alternatives are battery,
20976 performance.
20977
20978 Defaults to @samp{"performance"}.
20979
20980 @end deftypevr
20981
20982 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
20983 Same as @code{radeon-dpm-state-ac} but on BAT mode.
20984
20985 Defaults to @samp{"battery"}.
20986
20987 @end deftypevr
20988
20989 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
20990 Radeon DPM performance level. Alternatives are auto, low, high.
20991
20992 Defaults to @samp{"auto"}.
20993
20994 @end deftypevr
20995
20996 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
20997 Same as @code{radeon-dpm-perf-ac} but on BAT mode.
20998
20999 Defaults to @samp{"auto"}.
21000
21001 @end deftypevr
21002
21003 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
21004 Wifi power saving mode.
21005
21006 Defaults to @samp{#f}.
21007
21008 @end deftypevr
21009
21010 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
21011 Same as @code{wifi-power-ac?} but on BAT mode.
21012
21013 Defaults to @samp{#t}.
21014
21015 @end deftypevr
21016
21017 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
21018 Disable wake on LAN.
21019
21020 Defaults to @samp{#t}.
21021
21022 @end deftypevr
21023
21024 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
21025 Timeout duration in seconds before activating audio power saving on
21026 Intel HDA and AC97 devices. A value of 0 disables power saving.
21027
21028 Defaults to @samp{0}.
21029
21030 @end deftypevr
21031
21032 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
21033 Same as @code{sound-powersave-ac} but on BAT mode.
21034
21035 Defaults to @samp{1}.
21036
21037 @end deftypevr
21038
21039 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
21040 Disable controller in powersaving mode on Intel HDA devices.
21041
21042 Defaults to @samp{#t}.
21043
21044 @end deftypevr
21045
21046 @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
21047 Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
21048 powered on again by releasing (and reinserting) the eject lever or by
21049 pressing the disc eject button on newer models.
21050
21051 Defaults to @samp{#f}.
21052
21053 @end deftypevr
21054
21055 @deftypevr {@code{tlp-configuration} parameter} string bay-device
21056 Name of the optical drive device to power off.
21057
21058 Defaults to @samp{"sr0"}.
21059
21060 @end deftypevr
21061
21062 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
21063 Runtime Power Management for PCI(e) bus devices. Alternatives are on
21064 and auto.
21065
21066 Defaults to @samp{"on"}.
21067
21068 @end deftypevr
21069
21070 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
21071 Same as @code{runtime-pm-ac} but on BAT mode.
21072
21073 Defaults to @samp{"auto"}.
21074
21075 @end deftypevr
21076
21077 @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
21078 Runtime Power Management for all PCI(e) bus devices, except blacklisted
21079 ones.
21080
21081 Defaults to @samp{#t}.
21082
21083 @end deftypevr
21084
21085 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
21086 Exclude specified PCI(e) device addresses from Runtime Power Management.
21087
21088 Defaults to @samp{disabled}.
21089
21090 @end deftypevr
21091
21092 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
21093 Exclude PCI(e) devices assigned to the specified drivers from Runtime
21094 Power Management.
21095
21096 @end deftypevr
21097
21098 @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
21099 Enable USB autosuspend feature.
21100
21101 Defaults to @samp{#t}.
21102
21103 @end deftypevr
21104
21105 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
21106 Exclude specified devices from USB autosuspend.
21107
21108 Defaults to @samp{disabled}.
21109
21110 @end deftypevr
21111
21112 @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
21113 Exclude WWAN devices from USB autosuspend.
21114
21115 Defaults to @samp{#t}.
21116
21117 @end deftypevr
21118
21119 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
21120 Include specified devices into USB autosuspend, even if they are already
21121 excluded by the driver or via @code{usb-blacklist-wwan?}.
21122
21123 Defaults to @samp{disabled}.
21124
21125 @end deftypevr
21126
21127 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
21128 Enable USB autosuspend before shutdown.
21129
21130 Defaults to @samp{disabled}.
21131
21132 @end deftypevr
21133
21134 @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
21135 Restore radio device state (bluetooth, wifi, wwan) from previous
21136 shutdown on system startup.
21137
21138 Defaults to @samp{#f}.
21139
21140 @end deftypevr
21141
21142 @cindex thermald
21143 @cindex CPU frequency scaling with thermald
21144 @subsubheading Thermald daemon
21145
21146 The @code{(gnu services pm)} module provides an interface to
21147 thermald, a CPU frequency scaling service which helps prevent overheating.
21148
21149 @defvr {Scheme Variable} thermald-service-type
21150 This is the service type for
21151 @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
21152 Thermal Daemon, which is responsible for controlling the thermal state
21153 of processors and preventing overheating.
21154 @end defvr
21155
21156 @deftp {Data Type} thermald-configuration
21157 Data type representing the configuration of @code{thermald-service-type}.
21158
21159 @table @asis
21160 @item @code{ignore-cpuid-check?} (default: @code{#f})
21161 Ignore cpuid check for supported CPU models.
21162
21163 @item @code{thermald} (default: @var{thermald})
21164 Package object of thermald.
21165
21166 @end table
21167 @end deftp
21168
21169 @node Audio Services
21170 @subsection Audio Services
21171
21172 The @code{(gnu services audio)} module provides a service to start MPD
21173 (the Music Player Daemon).
21174
21175 @cindex mpd
21176 @subsubheading Music Player Daemon
21177
21178 The Music Player Daemon (MPD) is a service that can play music while
21179 being controlled from the local machine or over the network by a variety
21180 of clients.
21181
21182 The following example shows how one might run @code{mpd} as user
21183 @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
21184
21185 @example
21186 (service mpd-service-type
21187 (mpd-configuration
21188 (user "bob")
21189 (port "6666")))
21190 @end example
21191
21192 @defvr {Scheme Variable} mpd-service-type
21193 The service type for @command{mpd}
21194 @end defvr
21195
21196 @deftp {Data Type} mpd-configuration
21197 Data type representing the configuration of @command{mpd}.
21198
21199 @table @asis
21200 @item @code{user} (default: @code{"mpd"})
21201 The user to run mpd as.
21202
21203 @item @code{music-dir} (default: @code{"~/Music"})
21204 The directory to scan for music files.
21205
21206 @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
21207 The directory to store playlists.
21208
21209 @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
21210 The location of the music database.
21211
21212 @item @code{state-file} (default: @code{"~/.mpd/state"})
21213 The location of the file that stores current MPD's state.
21214
21215 @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
21216 The location of the sticker database.
21217
21218 @item @code{port} (default: @code{"6600"})
21219 The port to run mpd on.
21220
21221 @item @code{address} (default: @code{"any"})
21222 The address that mpd will bind to. To use a Unix domain socket,
21223 an absolute path can be specified here.
21224
21225 @end table
21226 @end deftp
21227
21228 @node Virtualization Services
21229 @subsection Virtualization services
21230
21231 The @code{(gnu services virtualization)} module provides services for
21232 the libvirt and virtlog daemons, as well as other virtualization-related
21233 services.
21234
21235 @subsubheading Libvirt daemon
21236 @code{libvirtd} is the server side daemon component of the libvirt
21237 virtualization management system. This daemon runs on host servers
21238 and performs required management tasks for virtualized guests.
21239
21240 @deffn {Scheme Variable} libvirt-service-type
21241 This is the type of the @uref{https://libvirt.org, libvirt daemon}.
21242 Its value must be a @code{libvirt-configuration}.
21243
21244 @example
21245 (service libvirt-service-type
21246 (libvirt-configuration
21247 (unix-sock-group "libvirt")
21248 (tls-port "16555")))
21249 @end example
21250 @end deffn
21251
21252 @c Auto-generated with (generate-libvirt-documentation)
21253 Available @code{libvirt-configuration} fields are:
21254
21255 @deftypevr {@code{libvirt-configuration} parameter} package libvirt
21256 Libvirt package.
21257
21258 @end deftypevr
21259
21260 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
21261 Flag listening for secure TLS connections on the public TCP/IP port.
21262 must set @code{listen} for this to have any effect.
21263
21264 It is necessary to setup a CA and issue server certificates before using
21265 this capability.
21266
21267 Defaults to @samp{#t}.
21268
21269 @end deftypevr
21270
21271 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
21272 Listen for unencrypted TCP connections on the public TCP/IP port. must
21273 set @code{listen} for this to have any effect.
21274
21275 Using the TCP socket requires SASL authentication by default. Only SASL
21276 mechanisms which support data encryption are allowed. This is
21277 DIGEST_MD5 and GSSAPI (Kerberos5)
21278
21279 Defaults to @samp{#f}.
21280
21281 @end deftypevr
21282
21283 @deftypevr {@code{libvirt-configuration} parameter} string tls-port
21284 Port for accepting secure TLS connections This can be a port number, or
21285 service name
21286
21287 Defaults to @samp{"16514"}.
21288
21289 @end deftypevr
21290
21291 @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
21292 Port for accepting insecure TCP connections This can be a port number,
21293 or service name
21294
21295 Defaults to @samp{"16509"}.
21296
21297 @end deftypevr
21298
21299 @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
21300 IP address or hostname used for client connections.
21301
21302 Defaults to @samp{"0.0.0.0"}.
21303
21304 @end deftypevr
21305
21306 @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
21307 Flag toggling mDNS advertisement of the libvirt service.
21308
21309 Alternatively can disable for all services on a host by stopping the
21310 Avahi daemon.
21311
21312 Defaults to @samp{#f}.
21313
21314 @end deftypevr
21315
21316 @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
21317 Default mDNS advertisement name. This must be unique on the immediate
21318 broadcast network.
21319
21320 Defaults to @samp{"Virtualization Host <hostname>"}.
21321
21322 @end deftypevr
21323
21324 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
21325 UNIX domain socket group ownership. This can be used to allow a
21326 'trusted' set of users access to management capabilities without
21327 becoming root.
21328
21329 Defaults to @samp{"root"}.
21330
21331 @end deftypevr
21332
21333 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
21334 UNIX socket permissions for the R/O socket. This is used for monitoring
21335 VM status only.
21336
21337 Defaults to @samp{"0777"}.
21338
21339 @end deftypevr
21340
21341 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
21342 UNIX socket permissions for the R/W socket. Default allows only root.
21343 If PolicyKit is enabled on the socket, the default will change to allow
21344 everyone (eg, 0777)
21345
21346 Defaults to @samp{"0770"}.
21347
21348 @end deftypevr
21349
21350 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
21351 UNIX socket permissions for the admin socket. Default allows only owner
21352 (root), do not change it unless you are sure to whom you are exposing
21353 the access to.
21354
21355 Defaults to @samp{"0777"}.
21356
21357 @end deftypevr
21358
21359 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
21360 The directory in which sockets will be found/created.
21361
21362 Defaults to @samp{"/var/run/libvirt"}.
21363
21364 @end deftypevr
21365
21366 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
21367 Authentication scheme for UNIX read-only sockets. By default socket
21368 permissions allow anyone to connect
21369
21370 Defaults to @samp{"polkit"}.
21371
21372 @end deftypevr
21373
21374 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
21375 Authentication scheme for UNIX read-write sockets. By default socket
21376 permissions only allow root. If PolicyKit support was compiled into
21377 libvirt, the default will be to use 'polkit' auth.
21378
21379 Defaults to @samp{"polkit"}.
21380
21381 @end deftypevr
21382
21383 @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
21384 Authentication scheme for TCP sockets. If you don't enable SASL, then
21385 all TCP traffic is cleartext. Don't do this outside of a dev/test
21386 scenario.
21387
21388 Defaults to @samp{"sasl"}.
21389
21390 @end deftypevr
21391
21392 @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
21393 Authentication scheme for TLS sockets. TLS sockets already have
21394 encryption provided by the TLS layer, and limited authentication is done
21395 by certificates.
21396
21397 It is possible to make use of any SASL authentication mechanism as well,
21398 by using 'sasl' for this option
21399
21400 Defaults to @samp{"none"}.
21401
21402 @end deftypevr
21403
21404 @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
21405 API access control scheme.
21406
21407 By default an authenticated user is allowed access to all APIs. Access
21408 drivers can place restrictions on this.
21409
21410 Defaults to @samp{()}.
21411
21412 @end deftypevr
21413
21414 @deftypevr {@code{libvirt-configuration} parameter} string key-file
21415 Server key file path. If set to an empty string, then no private key is
21416 loaded.
21417
21418 Defaults to @samp{""}.
21419
21420 @end deftypevr
21421
21422 @deftypevr {@code{libvirt-configuration} parameter} string cert-file
21423 Server key file path. If set to an empty string, then no certificate is
21424 loaded.
21425
21426 Defaults to @samp{""}.
21427
21428 @end deftypevr
21429
21430 @deftypevr {@code{libvirt-configuration} parameter} string ca-file
21431 Server key file path. If set to an empty string, then no CA certificate
21432 is loaded.
21433
21434 Defaults to @samp{""}.
21435
21436 @end deftypevr
21437
21438 @deftypevr {@code{libvirt-configuration} parameter} string crl-file
21439 Certificate revocation list path. If set to an empty string, then no
21440 CRL is loaded.
21441
21442 Defaults to @samp{""}.
21443
21444 @end deftypevr
21445
21446 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
21447 Disable verification of our own server certificates.
21448
21449 When libvirtd starts it performs some sanity checks against its own
21450 certificates.
21451
21452 Defaults to @samp{#f}.
21453
21454 @end deftypevr
21455
21456 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
21457 Disable verification of client certificates.
21458
21459 Client certificate verification is the primary authentication mechanism.
21460 Any client which does not present a certificate signed by the CA will be
21461 rejected.
21462
21463 Defaults to @samp{#f}.
21464
21465 @end deftypevr
21466
21467 @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
21468 Whitelist of allowed x509 Distinguished Name.
21469
21470 Defaults to @samp{()}.
21471
21472 @end deftypevr
21473
21474 @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
21475 Whitelist of allowed SASL usernames. The format for username depends on
21476 the SASL authentication mechanism.
21477
21478 Defaults to @samp{()}.
21479
21480 @end deftypevr
21481
21482 @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
21483 Override the compile time default TLS priority string. The default is
21484 usually "NORMAL" unless overridden at build time. Only set this is it
21485 is desired for libvirt to deviate from the global default settings.
21486
21487 Defaults to @samp{"NORMAL"}.
21488
21489 @end deftypevr
21490
21491 @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
21492 Maximum number of concurrent client connections to allow over all
21493 sockets combined.
21494
21495 Defaults to @samp{5000}.
21496
21497 @end deftypevr
21498
21499 @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
21500 Maximum length of queue of connections waiting to be accepted by the
21501 daemon. Note, that some protocols supporting retransmission may obey
21502 this so that a later reattempt at connection succeeds.
21503
21504 Defaults to @samp{1000}.
21505
21506 @end deftypevr
21507
21508 @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
21509 Maximum length of queue of accepted but not yet authenticated clients.
21510 Set this to zero to turn this feature off
21511
21512 Defaults to @samp{20}.
21513
21514 @end deftypevr
21515
21516 @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
21517 Number of workers to start up initially.
21518
21519 Defaults to @samp{5}.
21520
21521 @end deftypevr
21522
21523 @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
21524 Maximum number of worker threads.
21525
21526 If the number of active clients exceeds @code{min-workers}, then more
21527 threads are spawned, up to max_workers limit. Typically you'd want
21528 max_workers to equal maximum number of clients allowed.
21529
21530 Defaults to @samp{20}.
21531
21532 @end deftypevr
21533
21534 @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
21535 Number of priority workers. If all workers from above pool are stuck,
21536 some calls marked as high priority (notably domainDestroy) can be
21537 executed in this pool.
21538
21539 Defaults to @samp{5}.
21540
21541 @end deftypevr
21542
21543 @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
21544 Total global limit on concurrent RPC calls.
21545
21546 Defaults to @samp{20}.
21547
21548 @end deftypevr
21549
21550 @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
21551 Limit on concurrent requests from a single client connection. To avoid
21552 one client monopolizing the server this should be a small fraction of
21553 the global max_requests and max_workers parameter.
21554
21555 Defaults to @samp{5}.
21556
21557 @end deftypevr
21558
21559 @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
21560 Same as @code{min-workers} but for the admin interface.
21561
21562 Defaults to @samp{1}.
21563
21564 @end deftypevr
21565
21566 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
21567 Same as @code{max-workers} but for the admin interface.
21568
21569 Defaults to @samp{5}.
21570
21571 @end deftypevr
21572
21573 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
21574 Same as @code{max-clients} but for the admin interface.
21575
21576 Defaults to @samp{5}.
21577
21578 @end deftypevr
21579
21580 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
21581 Same as @code{max-queued-clients} but for the admin interface.
21582
21583 Defaults to @samp{5}.
21584
21585 @end deftypevr
21586
21587 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
21588 Same as @code{max-client-requests} but for the admin interface.
21589
21590 Defaults to @samp{5}.
21591
21592 @end deftypevr
21593
21594 @deftypevr {@code{libvirt-configuration} parameter} integer log-level
21595 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
21596
21597 Defaults to @samp{3}.
21598
21599 @end deftypevr
21600
21601 @deftypevr {@code{libvirt-configuration} parameter} string log-filters
21602 Logging filters.
21603
21604 A filter allows to select a different logging level for a given category
21605 of logs The format for a filter is one of:
21606
21607 @itemize @bullet
21608 @item
21609 x:name
21610
21611 @item
21612 x:+name
21613
21614 @end itemize
21615
21616 where @code{name} is a string which is matched against the category
21617 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
21618 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
21619 be a substring of the full category name, in order to match multiple
21620 similar categories), the optional "+" prefix tells libvirt to log stack
21621 trace for each message matching name, and @code{x} is the minimal level
21622 where matching messages should be logged:
21623
21624 @itemize @bullet
21625 @item
21626 1: DEBUG
21627
21628 @item
21629 2: INFO
21630
21631 @item
21632 3: WARNING
21633
21634 @item
21635 4: ERROR
21636
21637 @end itemize
21638
21639 Multiple filters can be defined in a single filters statement, they just
21640 need to be separated by spaces.
21641
21642 Defaults to @samp{"3:remote 4:event"}.
21643
21644 @end deftypevr
21645
21646 @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
21647 Logging outputs.
21648
21649 An output is one of the places to save logging information The format
21650 for an output can be:
21651
21652 @table @code
21653 @item x:stderr
21654 output goes to stderr
21655
21656 @item x:syslog:name
21657 use syslog for the output and use the given name as the ident
21658
21659 @item x:file:file_path
21660 output to a file, with the given filepath
21661
21662 @item x:journald
21663 output to journald logging system
21664
21665 @end table
21666
21667 In all case the x prefix is the minimal level, acting as a filter
21668
21669 @itemize @bullet
21670 @item
21671 1: DEBUG
21672
21673 @item
21674 2: INFO
21675
21676 @item
21677 3: WARNING
21678
21679 @item
21680 4: ERROR
21681
21682 @end itemize
21683
21684 Multiple outputs can be defined, they just need to be separated by
21685 spaces.
21686
21687 Defaults to @samp{"3:stderr"}.
21688
21689 @end deftypevr
21690
21691 @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
21692 Allows usage of the auditing subsystem to be altered
21693
21694 @itemize @bullet
21695 @item
21696 0: disable all auditing
21697
21698 @item
21699 1: enable auditing, only if enabled on host
21700
21701 @item
21702 2: enable auditing, and exit if disabled on host.
21703
21704 @end itemize
21705
21706 Defaults to @samp{1}.
21707
21708 @end deftypevr
21709
21710 @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
21711 Send audit messages via libvirt logging infrastructure.
21712
21713 Defaults to @samp{#f}.
21714
21715 @end deftypevr
21716
21717 @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
21718 Host UUID. UUID must not have all digits be the same.
21719
21720 Defaults to @samp{""}.
21721
21722 @end deftypevr
21723
21724 @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
21725 Source to read host UUID.
21726
21727 @itemize @bullet
21728 @item
21729 @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
21730
21731 @item
21732 @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
21733
21734 @end itemize
21735
21736 If @code{dmidecode} does not provide a valid UUID a temporary UUID will
21737 be generated.
21738
21739 Defaults to @samp{"smbios"}.
21740
21741 @end deftypevr
21742
21743 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
21744 A keepalive message is sent to a client after @code{keepalive_interval}
21745 seconds of inactivity to check if the client is still responding. If
21746 set to -1, libvirtd will never send keepalive requests; however clients
21747 can still send them and the daemon will send responses.
21748
21749 Defaults to @samp{5}.
21750
21751 @end deftypevr
21752
21753 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
21754 Maximum number of keepalive messages that are allowed to be sent to the
21755 client without getting any response before the connection is considered
21756 broken.
21757
21758 In other words, the connection is automatically closed approximately
21759 after @code{keepalive_interval * (keepalive_count + 1)} seconds since
21760 the last message received from the client. When @code{keepalive-count}
21761 is set to 0, connections will be automatically closed after
21762 @code{keepalive-interval} seconds of inactivity without sending any
21763 keepalive messages.
21764
21765 Defaults to @samp{5}.
21766
21767 @end deftypevr
21768
21769 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
21770 Same as above but for admin interface.
21771
21772 Defaults to @samp{5}.
21773
21774 @end deftypevr
21775
21776 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
21777 Same as above but for admin interface.
21778
21779 Defaults to @samp{5}.
21780
21781 @end deftypevr
21782
21783 @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
21784 Timeout for Open vSwitch calls.
21785
21786 The @code{ovs-vsctl} utility is used for the configuration and its
21787 timeout option is set by default to 5 seconds to avoid potential
21788 infinite waits blocking libvirt.
21789
21790 Defaults to @samp{5}.
21791
21792 @end deftypevr
21793
21794 @c %end of autogenerated docs
21795
21796 @subsubheading Virtlog daemon
21797 The virtlogd service is a server side daemon component of libvirt that is
21798 used to manage logs from virtual machine consoles.
21799
21800 This daemon is not used directly by libvirt client applications, rather it
21801 is called on their behalf by @code{libvirtd}. By maintaining the logs in a
21802 standalone daemon, the main @code{libvirtd} daemon can be restarted without
21803 risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
21804 itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
21805
21806 @deffn {Scheme Variable} virtlog-service-type
21807 This is the type of the virtlog daemon.
21808 Its value must be a @code{virtlog-configuration}.
21809
21810 @example
21811 (service virtlog-service-type
21812 (virtlog-configuration
21813 (max-clients 1000)))
21814 @end example
21815 @end deffn
21816
21817 @deftypevr {@code{virtlog-configuration} parameter} integer log-level
21818 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
21819
21820 Defaults to @samp{3}.
21821
21822 @end deftypevr
21823
21824 @deftypevr {@code{virtlog-configuration} parameter} string log-filters
21825 Logging filters.
21826
21827 A filter allows to select a different logging level for a given category
21828 of logs The format for a filter is one of:
21829
21830 @itemize @bullet
21831 @item
21832 x:name
21833
21834 @item
21835 x:+name
21836
21837 @end itemize
21838
21839 where @code{name} is a string which is matched against the category
21840 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
21841 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
21842 be a substring of the full category name, in order to match multiple
21843 similar categories), the optional "+" prefix tells libvirt to log stack
21844 trace for each message matching name, and @code{x} is the minimal level
21845 where matching messages should be logged:
21846
21847 @itemize @bullet
21848 @item
21849 1: DEBUG
21850
21851 @item
21852 2: INFO
21853
21854 @item
21855 3: WARNING
21856
21857 @item
21858 4: ERROR
21859
21860 @end itemize
21861
21862 Multiple filters can be defined in a single filters statement, they just
21863 need to be separated by spaces.
21864
21865 Defaults to @samp{"3:remote 4:event"}.
21866
21867 @end deftypevr
21868
21869 @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
21870 Logging outputs.
21871
21872 An output is one of the places to save logging information The format
21873 for an output can be:
21874
21875 @table @code
21876 @item x:stderr
21877 output goes to stderr
21878
21879 @item x:syslog:name
21880 use syslog for the output and use the given name as the ident
21881
21882 @item x:file:file_path
21883 output to a file, with the given filepath
21884
21885 @item x:journald
21886 output to journald logging system
21887
21888 @end table
21889
21890 In all case the x prefix is the minimal level, acting as a filter
21891
21892 @itemize @bullet
21893 @item
21894 1: DEBUG
21895
21896 @item
21897 2: INFO
21898
21899 @item
21900 3: WARNING
21901
21902 @item
21903 4: ERROR
21904
21905 @end itemize
21906
21907 Multiple outputs can be defined, they just need to be separated by
21908 spaces.
21909
21910 Defaults to @samp{"3:stderr"}.
21911
21912 @end deftypevr
21913
21914 @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
21915 Maximum number of concurrent client connections to allow over all
21916 sockets combined.
21917
21918 Defaults to @samp{1024}.
21919
21920 @end deftypevr
21921
21922 @deftypevr {@code{virtlog-configuration} parameter} integer max-size
21923 Maximum file size before rolling over.
21924
21925 Defaults to @samp{2MB}
21926
21927 @end deftypevr
21928
21929 @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
21930 Maximum number of backup files to keep.
21931
21932 Defaults to @samp{3}
21933
21934 @end deftypevr
21935
21936 @subsubheading Transparent Emulation with QEMU
21937
21938 @cindex emulation
21939 @cindex @code{binfmt_misc}
21940 @code{qemu-binfmt-service-type} provides support for transparent
21941 emulation of program binaries built for different architectures---e.g.,
21942 it allows you to transparently execute an ARMv7 program on an x86_64
21943 machine. It achieves this by combining the @uref{https://www.qemu.org,
21944 QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
21945
21946 @defvr {Scheme Variable} qemu-binfmt-service-type
21947 This is the type of the QEMU/binfmt service for transparent emulation.
21948 Its value must be a @code{qemu-binfmt-configuration} object, which
21949 specifies the QEMU package to use as well as the architecture we want to
21950 emulated:
21951
21952 @example
21953 (service qemu-binfmt-service-type
21954 (qemu-binfmt-configuration
21955 (platforms (lookup-qemu-platforms "arm" "aarch64" "mips64el"))))
21956 @end example
21957
21958 In this example, we enable transparent emulation for the ARM and aarch64
21959 platforms. Running @code{herd stop qemu-binfmt} turns it off, and
21960 running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
21961 herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
21962 @end defvr
21963
21964 @deftp {Data Type} qemu-binfmt-configuration
21965 This is the configuration for the @code{qemu-binfmt} service.
21966
21967 @table @asis
21968 @item @code{platforms} (default: @code{'()})
21969 The list of emulated QEMU platforms. Each item must be a @dfn{platform
21970 object} as returned by @code{lookup-qemu-platforms} (see below).
21971
21972 @item @code{guix-support?} (default: @code{#f})
21973 When it is true, QEMU and all its dependencies are added to the build
21974 environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
21975 @code{--chroot-directory} option}). This allows the @code{binfmt_misc}
21976 handlers to be used within the build environment, which in turn means
21977 that you can transparently build programs for another architecture.
21978
21979 For example, let's suppose you're on an x86_64 machine and you have this
21980 service:
21981
21982 @example
21983 (service qemu-binfmt-service-type
21984 (qemu-binfmt-configuration
21985 (platforms (lookup-qemu-platforms "arm"))
21986 (guix-support? #t)))
21987 @end example
21988
21989 You can run:
21990
21991 @example
21992 guix build -s armhf-linux inkscape
21993 @end example
21994
21995 @noindent
21996 and it will build Inkscape for ARMv7 @emph{as if it were a native
21997 build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
21998 if you'd like to test a package build for an architecture you don't have
21999 access to!
22000
22001 @item @code{qemu} (default: @code{qemu})
22002 The QEMU package to use.
22003 @end table
22004 @end deftp
22005
22006 @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
22007 Return the list of QEMU platform objects corresponding to
22008 @var{platforms}@dots{}. @var{platforms} must be a list of strings
22009 corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
22010 @code{"mips64el"}, and so on.
22011 @end deffn
22012
22013 @deffn {Scheme Procedure} qemu-platform? @var{obj}
22014 Return true if @var{obj} is a platform object.
22015 @end deffn
22016
22017 @deffn {Scheme Procedure} qemu-platform-name @var{platform}
22018 Return the name of @var{platform}---a string such as @code{"arm"}.
22019 @end deffn
22020
22021 @node Version Control Services
22022 @subsection Version Control Services
22023
22024 The @code{(gnu services version-control)} module provides a service to
22025 allow remote access to local Git repositories. There are three options:
22026 the @code{git-daemon-service}, which provides access to repositories via
22027 the @code{git://} unsecured TCP-based protocol, extending the
22028 @code{nginx} web server to proxy some requests to
22029 @code{git-http-backend}, or providing a web interface with
22030 @code{cgit-service-type}.
22031
22032 @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
22033
22034 Return a service that runs @command{git daemon}, a simple TCP server to
22035 expose repositories over the Git protocol for anonymous access.
22036
22037 The optional @var{config} argument should be a
22038 @code{<git-daemon-configuration>} object, by default it allows read-only
22039 access to exported@footnote{By creating the magic file
22040 "git-daemon-export-ok" in the repository directory.} repositories under
22041 @file{/srv/git}.
22042
22043 @end deffn
22044
22045 @deftp {Data Type} git-daemon-configuration
22046 Data type representing the configuration for @code{git-daemon-service}.
22047
22048 @table @asis
22049 @item @code{package} (default: @var{git})
22050 Package object of the Git distributed version control system.
22051
22052 @item @code{export-all?} (default: @var{#f})
22053 Whether to allow access for all Git repositories, even if they do not
22054 have the @file{git-daemon-export-ok} file.
22055
22056 @item @code{base-path} (default: @file{/srv/git})
22057 Whether to remap all the path requests as relative to the given path.
22058 If you run git daemon with @var{(base-path "/srv/git")} on example.com,
22059 then if you later try to pull @code{git://example.com/hello.git}, git
22060 daemon will interpret the path as @code{/srv/git/hello.git}.
22061
22062 @item @code{user-path} (default: @var{#f})
22063 Whether to allow @code{~user} notation to be used in requests. When
22064 specified with empty string, requests to @code{git://host/~alice/foo} is
22065 taken as a request to access @code{foo} repository in the home directory
22066 of user @code{alice}. If @var{(user-path "path")} is specified, the
22067 same request is taken as a request to access @code{path/foo} repository
22068 in the home directory of user @code{alice}.
22069
22070 @item @code{listen} (default: @var{'()})
22071 Whether to listen on specific IP addresses or hostnames, defaults to
22072 all.
22073
22074 @item @code{port} (default: @var{#f})
22075 Whether to listen on an alternative port, which defaults to 9418.
22076
22077 @item @code{whitelist} (default: @var{'()})
22078 If not empty, only allow access to this list of directories.
22079
22080 @item @code{extra-options} (default: @var{'()})
22081 Extra options will be passed to @code{git daemon}, please run
22082 @command{man git-daemon} for more information.
22083
22084 @end table
22085 @end deftp
22086
22087 The @code{git://} protocol lacks authentication. When you pull from a
22088 repository fetched via @code{git://}, you don't know that the data you
22089 receive was modified is really coming from the specified host, and you
22090 have your connection is subject to eavesdropping. It's better to use an
22091 authenticated and encrypted transport, such as @code{https}. Although Git allows you
22092 to serve repositories using unsophisticated file-based web servers,
22093 there is a faster protocol implemented by the @code{git-http-backend}
22094 program. This program is the back-end of a proper Git web service. It
22095 is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
22096 on running the necessary @code{fcgiwrap} daemon.
22097
22098 Guix has a separate configuration data type for serving Git repositories
22099 over HTTP.
22100
22101 @deftp {Data Type} git-http-configuration
22102 Data type representing the configuration for @code{git-http-service}.
22103
22104 @table @asis
22105 @item @code{package} (default: @var{git})
22106 Package object of the Git distributed version control system.
22107
22108 @item @code{git-root} (default: @file{/srv/git})
22109 Directory containing the Git repositories to expose to the world.
22110
22111 @item @code{export-all?} (default: @var{#f})
22112 Whether to expose access for all Git repositories in @var{git-root},
22113 even if they do not have the @file{git-daemon-export-ok} file.
22114
22115 @item @code{uri-path} (default: @file{/git/})
22116 Path prefix for Git access. With the default @code{/git/} prefix, this
22117 will map @code{http://@var{server}/git/@var{repo}.git} to
22118 @code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
22119 with this prefix are not passed on to this Git instance.
22120
22121 @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
22122 The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
22123 Services}.
22124 @end table
22125 @end deftp
22126
22127 There is no @code{git-http-service-type}, currently; instead you can
22128 create an @code{nginx-location-configuration} from a
22129 @code{git-http-configuration} and then add that location to a web
22130 server.
22131
22132 @deffn {Scheme Procedure} git-http-nginx-location-configuration @
22133 [config=(git-http-configuration)]
22134 Compute an @code{nginx-location-configuration} that corresponds to the
22135 given Git http configuration. An example nginx service definition to
22136 serve the default @file{/srv/git} over HTTPS might be:
22137
22138 @example
22139 (service nginx-service-type
22140 (nginx-configuration
22141 (server-blocks
22142 (list
22143 (nginx-server-configuration
22144 (listen '("443 ssl"))
22145 (server-name "git.my-host.org")
22146 (ssl-certificate
22147 "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
22148 (ssl-certificate-key
22149 "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
22150 (locations
22151 (list
22152 (git-http-nginx-location-configuration
22153 (git-http-configuration (uri-path "/"))))))))))
22154 @end example
22155
22156 This example assumes that you are using Let's Encrypt to get your TLS
22157 certificate. @xref{Certificate Services}. The default @code{certbot}
22158 service will redirect all HTTP traffic on @code{git.my-host.org} to
22159 HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
22160 system services. @xref{Web Services}.
22161 @end deffn
22162
22163 @subsubheading Cgit Service
22164
22165 @cindex Cgit service
22166 @cindex Git, web interface
22167 @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
22168 repositories written in C.
22169
22170 The following example will configure the service with default values.
22171 By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
22172
22173 @example
22174 (service cgit-service-type)
22175 @end example
22176
22177 The @code{file-object} type designates either a file-like object
22178 (@pxref{G-Expressions, file-like objects}) or a string.
22179
22180 @c %start of fragment
22181
22182 Available @code{cgit-configuration} fields are:
22183
22184 @deftypevr {@code{cgit-configuration} parameter} package package
22185 The CGIT package.
22186
22187 @end deftypevr
22188
22189 @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
22190 NGINX configuration.
22191
22192 @end deftypevr
22193
22194 @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
22195 Specifies a command which will be invoked to format the content of about
22196 pages (both top-level and for each repository).
22197
22198 Defaults to @samp{""}.
22199
22200 @end deftypevr
22201
22202 @deftypevr {@code{cgit-configuration} parameter} string agefile
22203 Specifies a path, relative to each repository path, which can be used to
22204 specify the date and time of the youngest commit in the repository.
22205
22206 Defaults to @samp{""}.
22207
22208 @end deftypevr
22209
22210 @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
22211 Specifies a command that will be invoked for authenticating repository
22212 access.
22213
22214 Defaults to @samp{""}.
22215
22216 @end deftypevr
22217
22218 @deftypevr {@code{cgit-configuration} parameter} string branch-sort
22219 Flag which, when set to @samp{age}, enables date ordering in the branch
22220 ref list, and when set @samp{name} enables ordering by branch name.
22221
22222 Defaults to @samp{"name"}.
22223
22224 @end deftypevr
22225
22226 @deftypevr {@code{cgit-configuration} parameter} string cache-root
22227 Path used to store the cgit cache entries.
22228
22229 Defaults to @samp{"/var/cache/cgit"}.
22230
22231 @end deftypevr
22232
22233 @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
22234 Number which specifies the time-to-live, in minutes, for the cached
22235 version of repository pages accessed with a fixed SHA1.
22236
22237 Defaults to @samp{-1}.
22238
22239 @end deftypevr
22240
22241 @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
22242 Number which specifies the time-to-live, in minutes, for the cached
22243 version of repository pages accessed without a fixed SHA1.
22244
22245 Defaults to @samp{5}.
22246
22247 @end deftypevr
22248
22249 @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
22250 Number which specifies the time-to-live, in minutes, for the cached
22251 version of the repository summary page.
22252
22253 Defaults to @samp{5}.
22254
22255 @end deftypevr
22256
22257 @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
22258 Number which specifies the time-to-live, in minutes, for the cached
22259 version of the repository index page.
22260
22261 Defaults to @samp{5}.
22262
22263 @end deftypevr
22264
22265 @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
22266 Number which specifies the time-to-live, in minutes, for the result of
22267 scanning a path for Git repositories.
22268
22269 Defaults to @samp{15}.
22270
22271 @end deftypevr
22272
22273 @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
22274 Number which specifies the time-to-live, in minutes, for the cached
22275 version of the repository about page.
22276
22277 Defaults to @samp{15}.
22278
22279 @end deftypevr
22280
22281 @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
22282 Number which specifies the time-to-live, in minutes, for the cached
22283 version of snapshots.
22284
22285 Defaults to @samp{5}.
22286
22287 @end deftypevr
22288
22289 @deftypevr {@code{cgit-configuration} parameter} integer cache-size
22290 The maximum number of entries in the cgit cache. When set to @samp{0},
22291 caching is disabled.
22292
22293 Defaults to @samp{0}.
22294
22295 @end deftypevr
22296
22297 @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
22298 Sort items in the repo list case sensitively.
22299
22300 Defaults to @samp{#t}.
22301
22302 @end deftypevr
22303
22304 @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
22305 List of common prefixes which, when combined with a repository URL,
22306 generates valid clone URLs for the repository.
22307
22308 Defaults to @samp{()}.
22309
22310 @end deftypevr
22311
22312 @deftypevr {@code{cgit-configuration} parameter} list clone-url
22313 List of @code{clone-url} templates.
22314
22315 Defaults to @samp{()}.
22316
22317 @end deftypevr
22318
22319 @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
22320 Command which will be invoked to format commit messages.
22321
22322 Defaults to @samp{""}.
22323
22324 @end deftypevr
22325
22326 @deftypevr {@code{cgit-configuration} parameter} string commit-sort
22327 Flag which, when set to @samp{date}, enables strict date ordering in the
22328 commit log, and when set to @samp{topo} enables strict topological
22329 ordering.
22330
22331 Defaults to @samp{"git log"}.
22332
22333 @end deftypevr
22334
22335 @deftypevr {@code{cgit-configuration} parameter} file-object css
22336 URL which specifies the css document to include in all cgit pages.
22337
22338 Defaults to @samp{"/share/cgit/cgit.css"}.
22339
22340 @end deftypevr
22341
22342 @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
22343 Specifies a command which will be invoked to format names and email
22344 address of committers, authors, and taggers, as represented in various
22345 places throughout the cgit interface.
22346
22347 Defaults to @samp{""}.
22348
22349 @end deftypevr
22350
22351 @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
22352 Flag which, when set to @samp{#t}, will make cgit generate a HTML
22353 fragment suitable for embedding in other HTML pages.
22354
22355 Defaults to @samp{#f}.
22356
22357 @end deftypevr
22358
22359 @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
22360 Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
22361 commit history graph to the left of the commit messages in the
22362 repository log page.
22363
22364 Defaults to @samp{#f}.
22365
22366 @end deftypevr
22367
22368 @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
22369 Flag which, when set to @samp{#t}, allows all filter settings to be
22370 overridden in repository-specific cgitrc files.
22371
22372 Defaults to @samp{#f}.
22373
22374 @end deftypevr
22375
22376 @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
22377 Flag which, when set to @samp{#t}, allows users to follow a file in the
22378 log view.
22379
22380 Defaults to @samp{#f}.
22381
22382 @end deftypevr
22383
22384 @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
22385 If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
22386 clones.
22387
22388 Defaults to @samp{#t}.
22389
22390 @end deftypevr
22391
22392 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
22393 Flag which, when set to @samp{#t}, will make cgit generate extra links
22394 "summary", "commit", "tree" for each repo in the repository index.
22395
22396 Defaults to @samp{#f}.
22397
22398 @end deftypevr
22399
22400 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
22401 Flag which, when set to @samp{#t}, will make cgit display the owner of
22402 each repo in the repository index.
22403
22404 Defaults to @samp{#t}.
22405
22406 @end deftypevr
22407
22408 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
22409 Flag which, when set to @samp{#t}, will make cgit print the number of
22410 modified files for each commit on the repository log page.
22411
22412 Defaults to @samp{#f}.
22413
22414 @end deftypevr
22415
22416 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
22417 Flag which, when set to @samp{#t}, will make cgit print the number of
22418 added and removed lines for each commit on the repository log page.
22419
22420 Defaults to @samp{#f}.
22421
22422 @end deftypevr
22423
22424 @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
22425 Flag which, when set to @code{#t}, will make cgit display remote
22426 branches in the summary and refs views.
22427
22428 Defaults to @samp{#f}.
22429
22430 @end deftypevr
22431
22432 @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
22433 Flag which, when set to @code{1}, will make cgit use the subject of the
22434 parent commit as link text when generating links to parent commits in
22435 commit view.
22436
22437 Defaults to @samp{#f}.
22438
22439 @end deftypevr
22440
22441 @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
22442 Flag which, when set to @samp{#t}, will make cgit use the subject of the
22443 parent commit as link text when generating links to parent commits in
22444 commit view.
22445
22446 Defaults to @samp{#f}.
22447
22448 @end deftypevr
22449
22450 @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
22451 Flag which, when set to @samp{#t}, will make cgit generate linenumber
22452 links for plaintext blobs printed in the tree view.
22453
22454 Defaults to @samp{#t}.
22455
22456 @end deftypevr
22457
22458 @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
22459 Flag which, when set to @samp{#f}, will allow cgit to use Git config to
22460 set any repo specific settings.
22461
22462 Defaults to @samp{#f}.
22463
22464 @end deftypevr
22465
22466 @deftypevr {@code{cgit-configuration} parameter} file-object favicon
22467 URL used as link to a shortcut icon for cgit.
22468
22469 Defaults to @samp{"/favicon.ico"}.
22470
22471 @end deftypevr
22472
22473 @deftypevr {@code{cgit-configuration} parameter} string footer
22474 The content of the file specified with this option will be included
22475 verbatim at the bottom of all pages (i.e.@: it replaces the standard
22476 "generated by..."@: message).
22477
22478 Defaults to @samp{""}.
22479
22480 @end deftypevr
22481
22482 @deftypevr {@code{cgit-configuration} parameter} string head-include
22483 The content of the file specified with this option will be included
22484 verbatim in the HTML HEAD section on all pages.
22485
22486 Defaults to @samp{""}.
22487
22488 @end deftypevr
22489
22490 @deftypevr {@code{cgit-configuration} parameter} string header
22491 The content of the file specified with this option will be included
22492 verbatim at the top of all pages.
22493
22494 Defaults to @samp{""}.
22495
22496 @end deftypevr
22497
22498 @deftypevr {@code{cgit-configuration} parameter} file-object include
22499 Name of a configfile to include before the rest of the current config-
22500 file is parsed.
22501
22502 Defaults to @samp{""}.
22503
22504 @end deftypevr
22505
22506 @deftypevr {@code{cgit-configuration} parameter} string index-header
22507 The content of the file specified with this option will be included
22508 verbatim above the repository index.
22509
22510 Defaults to @samp{""}.
22511
22512 @end deftypevr
22513
22514 @deftypevr {@code{cgit-configuration} parameter} string index-info
22515 The content of the file specified with this option will be included
22516 verbatim below the heading on the repository index page.
22517
22518 Defaults to @samp{""}.
22519
22520 @end deftypevr
22521
22522 @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
22523 Flag which, if set to @samp{#t}, makes cgit print commit and tag times
22524 in the servers timezone.
22525
22526 Defaults to @samp{#f}.
22527
22528 @end deftypevr
22529
22530 @deftypevr {@code{cgit-configuration} parameter} file-object logo
22531 URL which specifies the source of an image which will be used as a logo
22532 on all cgit pages.
22533
22534 Defaults to @samp{"/share/cgit/cgit.png"}.
22535
22536 @end deftypevr
22537
22538 @deftypevr {@code{cgit-configuration} parameter} string logo-link
22539 URL loaded when clicking on the cgit logo image.
22540
22541 Defaults to @samp{""}.
22542
22543 @end deftypevr
22544
22545 @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
22546 Command which will be invoked to format the Owner column of the main
22547 page.
22548
22549 Defaults to @samp{""}.
22550
22551 @end deftypevr
22552
22553 @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
22554 Number of items to display in atom feeds view.
22555
22556 Defaults to @samp{10}.
22557
22558 @end deftypevr
22559
22560 @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
22561 Number of entries to list per page in "log" view.
22562
22563 Defaults to @samp{50}.
22564
22565 @end deftypevr
22566
22567 @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
22568 Number of commit message characters to display in "log" view.
22569
22570 Defaults to @samp{80}.
22571
22572 @end deftypevr
22573
22574 @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
22575 Specifies the number of entries to list per page on the repository index
22576 page.
22577
22578 Defaults to @samp{50}.
22579
22580 @end deftypevr
22581
22582 @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
22583 Specifies the maximum number of repo description characters to display
22584 on the repository index page.
22585
22586 Defaults to @samp{80}.
22587
22588 @end deftypevr
22589
22590 @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
22591 Specifies the maximum size of a blob to display HTML for in KBytes.
22592
22593 Defaults to @samp{0}.
22594
22595 @end deftypevr
22596
22597 @deftypevr {@code{cgit-configuration} parameter} string max-stats
22598 Maximum statistics period. Valid values are @samp{week},@samp{month},
22599 @samp{quarter} and @samp{year}.
22600
22601 Defaults to @samp{""}.
22602
22603 @end deftypevr
22604
22605 @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
22606 Mimetype for the specified filename extension.
22607
22608 Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
22609 "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
22610 "image/png") (svg "image/svg+xml"))}.
22611
22612 @end deftypevr
22613
22614 @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
22615 Specifies the file to use for automatic mimetype lookup.
22616
22617 Defaults to @samp{""}.
22618
22619 @end deftypevr
22620
22621 @deftypevr {@code{cgit-configuration} parameter} string module-link
22622 Text which will be used as the formatstring for a hyperlink when a
22623 submodule is printed in a directory listing.
22624
22625 Defaults to @samp{""}.
22626
22627 @end deftypevr
22628
22629 @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
22630 If set to the value @samp{#t} caching will be disabled.
22631
22632 Defaults to @samp{#f}.
22633
22634 @end deftypevr
22635
22636 @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
22637 If set to @samp{#t} showing full author email addresses will be
22638 disabled.
22639
22640 Defaults to @samp{#f}.
22641
22642 @end deftypevr
22643
22644 @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
22645 Flag which, when set to @samp{#t}, will make cgit omit the standard
22646 header on all pages.
22647
22648 Defaults to @samp{#f}.
22649
22650 @end deftypevr
22651
22652 @deftypevr {@code{cgit-configuration} parameter} project-list project-list
22653 A list of subdirectories inside of @code{repository-directory}, relative
22654 to it, that should loaded as Git repositories. An empty list means that
22655 all subdirectories will be loaded.
22656
22657 Defaults to @samp{()}.
22658
22659 @end deftypevr
22660
22661 @deftypevr {@code{cgit-configuration} parameter} file-object readme
22662 Text which will be used as default value for @code{cgit-repo-readme}.
22663
22664 Defaults to @samp{""}.
22665
22666 @end deftypevr
22667
22668 @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
22669 If set to @code{#t} and @code{repository-directory} is enabled, if any
22670 repositories are found with a suffix of @code{.git}, this suffix will be
22671 removed for the URL and name.
22672
22673 Defaults to @samp{#f}.
22674
22675 @end deftypevr
22676
22677 @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
22678 Maximum number of files to consider when detecting renames.
22679
22680 Defaults to @samp{-1}.
22681
22682 @end deftypevr
22683
22684 @deftypevr {@code{cgit-configuration} parameter} string repository-sort
22685 The way in which repositories in each section are sorted.
22686
22687 Defaults to @samp{""}.
22688
22689 @end deftypevr
22690
22691 @deftypevr {@code{cgit-configuration} parameter} robots-list robots
22692 Text used as content for the @code{robots} meta-tag.
22693
22694 Defaults to @samp{("noindex" "nofollow")}.
22695
22696 @end deftypevr
22697
22698 @deftypevr {@code{cgit-configuration} parameter} string root-desc
22699 Text printed below the heading on the repository index page.
22700
22701 Defaults to @samp{"a fast webinterface for the git dscm"}.
22702
22703 @end deftypevr
22704
22705 @deftypevr {@code{cgit-configuration} parameter} string root-readme
22706 The content of the file specified with this option will be included
22707 verbatim below thef "about" link on the repository index page.
22708
22709 Defaults to @samp{""}.
22710
22711 @end deftypevr
22712
22713 @deftypevr {@code{cgit-configuration} parameter} string root-title
22714 Text printed as heading on the repository index page.
22715
22716 Defaults to @samp{""}.
22717
22718 @end deftypevr
22719
22720 @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
22721 If set to @samp{#t} and repository-directory is enabled,
22722 repository-directory will recurse into directories whose name starts
22723 with a period. Otherwise, repository-directory will stay away from such
22724 directories, considered as "hidden". Note that this does not apply to
22725 the ".git" directory in non-bare repos.
22726
22727 Defaults to @samp{#f}.
22728
22729 @end deftypevr
22730
22731 @deftypevr {@code{cgit-configuration} parameter} list snapshots
22732 Text which specifies the default set of snapshot formats that cgit
22733 generates links for.
22734
22735 Defaults to @samp{()}.
22736
22737 @end deftypevr
22738
22739 @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
22740 Name of the directory to scan for repositories (represents
22741 @code{scan-path}).
22742
22743 Defaults to @samp{"/srv/git"}.
22744
22745 @end deftypevr
22746
22747 @deftypevr {@code{cgit-configuration} parameter} string section
22748 The name of the current repository section - all repositories defined
22749 after this option will inherit the current section name.
22750
22751 Defaults to @samp{""}.
22752
22753 @end deftypevr
22754
22755 @deftypevr {@code{cgit-configuration} parameter} string section-sort
22756 Flag which, when set to @samp{1}, will sort the sections on the
22757 repository listing by name.
22758
22759 Defaults to @samp{""}.
22760
22761 @end deftypevr
22762
22763 @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
22764 A number which, if defined prior to repository-directory, specifies how
22765 many path elements from each repo path to use as a default section name.
22766
22767 Defaults to @samp{0}.
22768
22769 @end deftypevr
22770
22771 @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
22772 If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
22773 default.
22774
22775 Defaults to @samp{#f}.
22776
22777 @end deftypevr
22778
22779 @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
22780 Specifies a command which will be invoked to format plaintext blobs in
22781 the tree view.
22782
22783 Defaults to @samp{""}.
22784
22785 @end deftypevr
22786
22787 @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
22788 Specifies the number of branches to display in the repository "summary"
22789 view.
22790
22791 Defaults to @samp{10}.
22792
22793 @end deftypevr
22794
22795 @deftypevr {@code{cgit-configuration} parameter} integer summary-log
22796 Specifies the number of log entries to display in the repository
22797 "summary" view.
22798
22799 Defaults to @samp{10}.
22800
22801 @end deftypevr
22802
22803 @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
22804 Specifies the number of tags to display in the repository "summary"
22805 view.
22806
22807 Defaults to @samp{10}.
22808
22809 @end deftypevr
22810
22811 @deftypevr {@code{cgit-configuration} parameter} string strict-export
22812 Filename which, if specified, needs to be present within the repository
22813 for cgit to allow access to that repository.
22814
22815 Defaults to @samp{""}.
22816
22817 @end deftypevr
22818
22819 @deftypevr {@code{cgit-configuration} parameter} string virtual-root
22820 URL which, if specified, will be used as root for all cgit links.
22821
22822 Defaults to @samp{"/"}.
22823
22824 @end deftypevr
22825
22826 @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
22827 A list of @dfn{cgit-repo} records to use with config.
22828
22829 Defaults to @samp{()}.
22830
22831 Available @code{repository-cgit-configuration} fields are:
22832
22833 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
22834 A mask of snapshot formats for this repo that cgit generates links for,
22835 restricted by the global @code{snapshots} setting.
22836
22837 Defaults to @samp{()}.
22838
22839 @end deftypevr
22840
22841 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
22842 Override the default @code{source-filter}.
22843
22844 Defaults to @samp{""}.
22845
22846 @end deftypevr
22847
22848 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
22849 The relative URL used to access the repository.
22850
22851 Defaults to @samp{""}.
22852
22853 @end deftypevr
22854
22855 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
22856 Override the default @code{about-filter}.
22857
22858 Defaults to @samp{""}.
22859
22860 @end deftypevr
22861
22862 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
22863 Flag which, when set to @samp{age}, enables date ordering in the branch
22864 ref list, and when set to @samp{name} enables ordering by branch name.
22865
22866 Defaults to @samp{""}.
22867
22868 @end deftypevr
22869
22870 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
22871 A list of URLs which can be used to clone repo.
22872
22873 Defaults to @samp{()}.
22874
22875 @end deftypevr
22876
22877 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
22878 Override the default @code{commit-filter}.
22879
22880 Defaults to @samp{""}.
22881
22882 @end deftypevr
22883
22884 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
22885 Flag which, when set to @samp{date}, enables strict date ordering in the
22886 commit log, and when set to @samp{topo} enables strict topological
22887 ordering.
22888
22889 Defaults to @samp{""}.
22890
22891 @end deftypevr
22892
22893 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
22894 The name of the default branch for this repository. If no such branch
22895 exists in the repository, the first branch name (when sorted) is used as
22896 default instead. By default branch pointed to by HEAD, or "master" if
22897 there is no suitable HEAD.
22898
22899 Defaults to @samp{""}.
22900
22901 @end deftypevr
22902
22903 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
22904 The value to show as repository description.
22905
22906 Defaults to @samp{""}.
22907
22908 @end deftypevr
22909
22910 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
22911 The value to show as repository homepage.
22912
22913 Defaults to @samp{""}.
22914
22915 @end deftypevr
22916
22917 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
22918 Override the default @code{email-filter}.
22919
22920 Defaults to @samp{""}.
22921
22922 @end deftypevr
22923
22924 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
22925 A flag which can be used to disable the global setting
22926 @code{enable-commit-graph?}.
22927
22928 Defaults to @samp{disabled}.
22929
22930 @end deftypevr
22931
22932 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
22933 A flag which can be used to disable the global setting
22934 @code{enable-log-filecount?}.
22935
22936 Defaults to @samp{disabled}.
22937
22938 @end deftypevr
22939
22940 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
22941 A flag which can be used to disable the global setting
22942 @code{enable-log-linecount?}.
22943
22944 Defaults to @samp{disabled}.
22945
22946 @end deftypevr
22947
22948 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
22949 Flag which, when set to @code{#t}, will make cgit display remote
22950 branches in the summary and refs views.
22951
22952 Defaults to @samp{disabled}.
22953
22954 @end deftypevr
22955
22956 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
22957 A flag which can be used to override the global setting
22958 @code{enable-subject-links?}.
22959
22960 Defaults to @samp{disabled}.
22961
22962 @end deftypevr
22963
22964 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
22965 A flag which can be used to override the global setting
22966 @code{enable-html-serving?}.
22967
22968 Defaults to @samp{disabled}.
22969
22970 @end deftypevr
22971
22972 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
22973 Flag which, when set to @code{#t}, hides the repository from the
22974 repository index.
22975
22976 Defaults to @samp{#f}.
22977
22978 @end deftypevr
22979
22980 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
22981 Flag which, when set to @samp{#t}, ignores the repository.
22982
22983 Defaults to @samp{#f}.
22984
22985 @end deftypevr
22986
22987 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
22988 URL which specifies the source of an image which will be used as a logo
22989 on this repo’s pages.
22990
22991 Defaults to @samp{""}.
22992
22993 @end deftypevr
22994
22995 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
22996 URL loaded when clicking on the cgit logo image.
22997
22998 Defaults to @samp{""}.
22999
23000 @end deftypevr
23001
23002 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
23003 Override the default @code{owner-filter}.
23004
23005 Defaults to @samp{""}.
23006
23007 @end deftypevr
23008
23009 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
23010 Text which will be used as the formatstring for a hyperlink when a
23011 submodule is printed in a directory listing. The arguments for the
23012 formatstring are the path and SHA1 of the submodule commit.
23013
23014 Defaults to @samp{""}.
23015
23016 @end deftypevr
23017
23018 @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
23019 Text which will be used as the formatstring for a hyperlink when a
23020 submodule with the specified subdirectory path is printed in a directory
23021 listing.
23022
23023 Defaults to @samp{()}.
23024
23025 @end deftypevr
23026
23027 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
23028 Override the default maximum statistics period.
23029
23030 Defaults to @samp{""}.
23031
23032 @end deftypevr
23033
23034 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
23035 The value to show as repository name.
23036
23037 Defaults to @samp{""}.
23038
23039 @end deftypevr
23040
23041 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
23042 A value used to identify the owner of the repository.
23043
23044 Defaults to @samp{""}.
23045
23046 @end deftypevr
23047
23048 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
23049 An absolute path to the repository directory.
23050
23051 Defaults to @samp{""}.
23052
23053 @end deftypevr
23054
23055 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
23056 A path (relative to repo) which specifies a file to include verbatim as
23057 the "About" page for this repo.
23058
23059 Defaults to @samp{""}.
23060
23061 @end deftypevr
23062
23063 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
23064 The name of the current repository section - all repositories defined
23065 after this option will inherit the current section name.
23066
23067 Defaults to @samp{""}.
23068
23069 @end deftypevr
23070
23071 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
23072 Extra options will be appended to cgitrc file.
23073
23074 Defaults to @samp{()}.
23075
23076 @end deftypevr
23077
23078 @end deftypevr
23079
23080 @deftypevr {@code{cgit-configuration} parameter} list extra-options
23081 Extra options will be appended to cgitrc file.
23082
23083 Defaults to @samp{()}.
23084
23085 @end deftypevr
23086
23087
23088 @c %end of fragment
23089
23090 However, it could be that you just want to get a @code{cgitrc} up and
23091 running. In that case, you can pass an @code{opaque-cgit-configuration}
23092 as a record to @code{cgit-service-type}. As its name indicates, an
23093 opaque configuration does not have easy reflective capabilities.
23094
23095 Available @code{opaque-cgit-configuration} fields are:
23096
23097 @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
23098 The cgit package.
23099 @end deftypevr
23100
23101 @deftypevr {@code{opaque-cgit-configuration} parameter} string string
23102 The contents of the @code{cgitrc}, as a string.
23103 @end deftypevr
23104
23105 For example, if your @code{cgitrc} is just the empty string, you
23106 could instantiate a cgit service like this:
23107
23108 @example
23109 (service cgit-service-type
23110 (opaque-cgit-configuration
23111 (cgitrc "")))
23112 @end example
23113
23114 @subsubheading Gitolite Service
23115
23116 @cindex Gitolite service
23117 @cindex Git, hosting
23118 @uref{http://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
23119 repositories on a central server.
23120
23121 Gitolite can handle multiple repositories and users, and supports flexible
23122 configuration of the permissions for the users on the repositories.
23123
23124 The following example will configure Gitolite using the default @code{git}
23125 user, and the provided SSH public key.
23126
23127 @example
23128 (service gitolite-service-type
23129 (gitolite-configuration
23130 (admin-pubkey (plain-file
23131 "yourname.pub"
23132 "ssh-rsa AAAA... guix@@example.com"))))
23133 @end example
23134
23135 Gitolite is configured through a special admin repository which you can clone,
23136 for example, if you setup Gitolite on @code{example.com}, you would run the
23137 following command to clone the admin repository.
23138
23139 @example
23140 git clone git@@example.com:gitolite-admin
23141 @end example
23142
23143 When the Gitolite service is activated, the provided @code{admin-pubkey} will
23144 be inserted in to the @file{keydir} directory in the gitolite-admin
23145 repository. If this results in a change in the repository, it will be
23146 committed using the message ``gitolite setup by GNU Guix''.
23147
23148 @deftp {Data Type} gitolite-configuration
23149 Data type representing the configuration for @code{gitolite-service-type}.
23150
23151 @table @asis
23152 @item @code{package} (default: @var{gitolite})
23153 Gitolite package to use.
23154
23155 @item @code{user} (default: @var{git})
23156 User to use for Gitolite. This will be user that you use when accessing
23157 Gitolite over SSH.
23158
23159 @item @code{group} (default: @var{git})
23160 Group to use for Gitolite.
23161
23162 @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
23163 Directory in which to store the Gitolite configuration and repositories.
23164
23165 @item @code{rc-file} (default: @var{(gitolite-rc-file)})
23166 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
23167 representing the configuration for Gitolite.
23168
23169 @item @code{admin-pubkey} (default: @var{#f})
23170 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
23171 setup Gitolite. This will be inserted in to the @file{keydir} directory
23172 within the gitolite-admin repository.
23173
23174 To specify the SSH key as a string, use the @code{plain-file} function.
23175
23176 @example
23177 (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
23178 @end example
23179
23180 @end table
23181 @end deftp
23182
23183 @deftp {Data Type} gitolite-rc-file
23184 Data type representing the Gitolite RC file.
23185
23186 @table @asis
23187 @item @code{umask} (default: @code{#o0077})
23188 This controls the permissions Gitolite sets on the repositories and their
23189 contents.
23190
23191 A value like @code{#o0027} will give read access to the group used by Gitolite
23192 (by default: @code{git}). This is necessary when using Gitolite with software
23193 like cgit or gitweb.
23194
23195 @item @code{git-config-keys} (default: @code{""})
23196 Gitolite allows you to set git config values using the "config" keyword. This
23197 setting allows control over the config keys to accept.
23198
23199 @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
23200 Set the role names allowed to be used by users running the perms command.
23201
23202 @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
23203 This setting controls the commands and features to enable within Gitolite.
23204
23205 @end table
23206 @end deftp
23207
23208
23209 @node Game Services
23210 @subsection Game Services
23211
23212 @subsubheading The Battle for Wesnoth Service
23213 @cindex wesnothd
23214 @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
23215 based tactical strategy game, with several single player campaigns, and
23216 multiplayer games (both networked and local).
23217
23218 @defvar {Scheme Variable} wesnothd-service-type
23219 Service type for the wesnothd service. Its value must be a
23220 @code{wesnothd-configuration} object. To run wesnothd in the default
23221 configuration, instantiate it as:
23222
23223 @example
23224 (service wesnothd-service-type)
23225 @end example
23226 @end defvar
23227
23228 @deftp {Data Type} wesnothd-configuration
23229 Data type representing the configuration of @command{wesnothd}.
23230
23231 @table @asis
23232 @item @code{package} (default: @code{wesnoth-server})
23233 The wesnoth server package to use.
23234
23235 @item @code{port} (default: @code{15000})
23236 The port to bind the server to.
23237 @end table
23238 @end deftp
23239
23240 @node Miscellaneous Services
23241 @subsection Miscellaneous Services
23242
23243 @cindex fingerprint
23244 @subsubheading Fingerprint Service
23245
23246 The @code{(gnu services authentication)} module provides a DBus service to
23247 read and identify fingerprints via a fingerprint sensor.
23248
23249 @defvr {Scheme Variable} fprintd-service-type
23250 The service type for @command{fprintd}, which provides the fingerprint
23251 reading capability.
23252
23253 @example
23254 (service fprintd-service-type)
23255 @end example
23256 @end defvr
23257
23258 @cindex sysctl
23259 @subsubheading System Control Service
23260
23261 The @code{(gnu services sysctl)} provides a service to configure kernel
23262 parameters at boot.
23263
23264 @defvr {Scheme Variable} sysctl-service-type
23265 The service type for @command{sysctl}, which modifies kernel parameters
23266 under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
23267 instantiated as:
23268
23269 @example
23270 (service sysctl-service-type
23271 (sysctl-configuration
23272 (settings '(("net.ipv4.ip_forward" . "1")))))
23273 @end example
23274 @end defvr
23275
23276 @deftp {Data Type} sysctl-configuration
23277 The data type representing the configuration of @command{sysctl}.
23278
23279 @table @asis
23280 @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
23281 The @command{sysctl} executable to use.
23282
23283 @item @code{settings} (default: @code{'()})
23284 An association list specifies kernel parameters and their values.
23285 @end table
23286 @end deftp
23287
23288 @cindex pcscd
23289 @subsubheading PC/SC Smart Card Daemon Service
23290
23291 The @code{(gnu services security-token)} module provides the following service
23292 to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
23293 daemon program for pcsc-lite and the MuscleCard framework. It is a resource
23294 manager that coordinates communications with smart card readers, smart cards
23295 and cryptographic tokens that are connected to the system.
23296
23297 @defvr {Scheme Variable} pcscd-service-type
23298 Service type for the @command{pcscd} service. Its value must be a
23299 @code{pcscd-configuration} object. To run pcscd in the default
23300 configuration, instantiate it as:
23301
23302 @example
23303 (service pcscd-service-type)
23304 @end example
23305 @end defvr
23306
23307 @deftp {Data Type} pcscd-configuration
23308 The data type representing the configuration of @command{pcscd}.
23309
23310 @table @asis
23311 @item @code{pcsc-lite} (default: @code{pcsc-lite})
23312 The pcsc-lite package that provides pcscd.
23313 @item @code{usb-drivers} (default: @code{(list ccid)})
23314 List of packages that provide USB drivers to pcscd. Drivers are expected to be
23315 under @file{pcsc/drivers} in the store directory of the package.
23316 @end table
23317 @end deftp
23318
23319 @cindex lirc
23320 @subsubheading Lirc Service
23321
23322 The @code{(gnu services lirc)} module provides the following service.
23323
23324 @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
23325 [#:device #f] [#:driver #f] [#:config-file #f] @
23326 [#:extra-options '()]
23327 Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
23328 decodes infrared signals from remote controls.
23329
23330 Optionally, @var{device}, @var{driver} and @var{config-file}
23331 (configuration file name) may be specified. See @command{lircd} manual
23332 for details.
23333
23334 Finally, @var{extra-options} is a list of additional command-line options
23335 passed to @command{lircd}.
23336 @end deffn
23337
23338 @cindex spice
23339 @subsubheading Spice Service
23340
23341 The @code{(gnu services spice)} module provides the following service.
23342
23343 @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
23344 Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
23345 that enables sharing the clipboard with a vm and setting the guest display
23346 resolution when the graphical console window resizes.
23347 @end deffn
23348
23349 @cindex inputattach
23350 @subsubheading inputattach Service
23351
23352 @cindex tablet input, for Xorg
23353 @cindex touchscreen input, for Xorg
23354 The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
23355 use input devices such as Wacom tablets, touchscreens, or joysticks with the
23356 Xorg display server.
23357
23358 @deffn {Scheme Variable} inputattach-service-type
23359 Type of a service that runs @command{inputattach} on a device and
23360 dispatches events from it.
23361 @end deffn
23362
23363 @deftp {Data Type} inputattach-configuration
23364 @table @asis
23365 @item @code{device-type} (default: @code{"wacom"})
23366 The type of device to connect to. Run @command{inputattach --help}, from the
23367 @code{inputattach} package, to see the list of supported device types.
23368
23369 @item @code{device} (default: @code{"/dev/ttyS0"})
23370 The device file to connect to the device.
23371
23372 @item @code{log-file} (default: @code{#f})
23373 If true, this must be the name of a file to log messages to.
23374 @end table
23375 @end deftp
23376
23377 @subsection Dictionary Services
23378 @cindex dictionary
23379 The @code{(gnu services dict)} module provides the following service:
23380
23381 @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
23382 Return a service that runs the @command{dicod} daemon, an implementation
23383 of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
23384
23385 The optional @var{config} argument specifies the configuration for
23386 @command{dicod}, which should be a @code{<dicod-configuration>} object, by
23387 default it serves the GNU Collaborative International Dictonary of English.
23388
23389 You can add @command{open localhost} to your @file{~/.dico} file to make
23390 @code{localhost} the default server for @command{dico} client
23391 (@pxref{Initialization File,,, dico, GNU Dico Manual}).
23392 @end deffn
23393
23394 @deftp {Data Type} dicod-configuration
23395 Data type representing the configuration of dicod.
23396
23397 @table @asis
23398 @item @code{dico} (default: @var{dico})
23399 Package object of the GNU Dico dictionary server.
23400
23401 @item @code{interfaces} (default: @var{'("localhost")})
23402 This is the list of IP addresses and ports and possibly socket file
23403 names to listen to (@pxref{Server Settings, @code{listen} directive,,
23404 dico, GNU Dico Manual}).
23405
23406 @item @code{handlers} (default: @var{'()})
23407 List of @code{<dicod-handler>} objects denoting handlers (module instances).
23408
23409 @item @code{databases} (default: @var{(list %dicod-database:gcide)})
23410 List of @code{<dicod-database>} objects denoting dictionaries to be served.
23411 @end table
23412 @end deftp
23413
23414 @deftp {Data Type} dicod-handler
23415 Data type representing a dictionary handler (module instance).
23416
23417 @table @asis
23418 @item @code{name}
23419 Name of the handler (module instance).
23420
23421 @item @code{module} (default: @var{#f})
23422 Name of the dicod module of the handler (instance). If it is @code{#f},
23423 the module has the same name as the handler.
23424 (@pxref{Modules,,, dico, GNU Dico Manual}).
23425
23426 @item @code{options}
23427 List of strings or gexps representing the arguments for the module handler
23428 @end table
23429 @end deftp
23430
23431 @deftp {Data Type} dicod-database
23432 Data type representing a dictionary database.
23433
23434 @table @asis
23435 @item @code{name}
23436 Name of the database, will be used in DICT commands.
23437
23438 @item @code{handler}
23439 Name of the dicod handler (module instance) used by this database
23440 (@pxref{Handlers,,, dico, GNU Dico Manual}).
23441
23442 @item @code{complex?} (default: @var{#f})
23443 Whether the database configuration complex. The complex configuration
23444 will need a corresponding @code{<dicod-handler>} object, otherwise not.
23445
23446 @item @code{options}
23447 List of strings or gexps representing the arguments for the database
23448 (@pxref{Databases,,, dico, GNU Dico Manual}).
23449 @end table
23450 @end deftp
23451
23452 @defvr {Scheme Variable} %dicod-database:gcide
23453 A @code{<dicod-database>} object serving the GNU Collaborative International
23454 Dictionary of English using the @code{gcide} package.
23455 @end defvr
23456
23457 The following is an example @code{dicod-service} configuration.
23458
23459 @example
23460 (dicod-service #:config
23461 (dicod-configuration
23462 (handlers (list (dicod-handler
23463 (name "wordnet")
23464 (module "dictorg")
23465 (options
23466 (list #~(string-append "dbdir=" #$wordnet))))))
23467 (databases (list (dicod-database
23468 (name "wordnet")
23469 (complex? #t)
23470 (handler "wordnet")
23471 (options '("database=wn")))
23472 %dicod-database:gcide))))
23473 @end example
23474
23475 @cindex Docker
23476 @subsubheading Docker Service
23477
23478 The @code{(gnu services docker)} module provides the following service.
23479
23480 @defvr {Scheme Variable} docker-service-type
23481
23482 This is the type of the service that runs @url{http://www.docker.com,Docker},
23483 a daemon that can execute application bundles (sometimes referred to as
23484 ``containers'') in isolated environments.
23485
23486 @end defvr
23487
23488 @deftp {Data Type} docker-configuration
23489 This is the data type representing the configuration of Docker and Containerd.
23490
23491 @table @asis
23492
23493 @item @code{package} (default: @code{docker})
23494 The Docker package to use.
23495
23496 @item @code{containerd} (default: @var{containerd})
23497 The Containerd package to use.
23498
23499 @end table
23500 @end deftp
23501
23502 @node Setuid Programs
23503 @section Setuid Programs
23504
23505 @cindex setuid programs
23506 Some programs need to run with ``root'' privileges, even when they are
23507 launched by unprivileged users. A notorious example is the
23508 @command{passwd} program, which users can run to change their
23509 password, and which needs to access the @file{/etc/passwd} and
23510 @file{/etc/shadow} files---something normally restricted to root, for
23511 obvious security reasons. To address that, these executables are
23512 @dfn{setuid-root}, meaning that they always run with root privileges
23513 (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
23514 for more info about the setuid mechanism.)
23515
23516 The store itself @emph{cannot} contain setuid programs: that would be a
23517 security issue since any user on the system can write derivations that
23518 populate the store (@pxref{The Store}). Thus, a different mechanism is
23519 used: instead of changing the setuid bit directly on files that are in
23520 the store, we let the system administrator @emph{declare} which programs
23521 should be setuid root.
23522
23523 The @code{setuid-programs} field of an @code{operating-system}
23524 declaration contains a list of G-expressions denoting the names of
23525 programs to be setuid-root (@pxref{Using the Configuration System}).
23526 For instance, the @command{passwd} program, which is part of the Shadow
23527 package, can be designated by this G-expression (@pxref{G-Expressions}):
23528
23529 @example
23530 #~(string-append #$shadow "/bin/passwd")
23531 @end example
23532
23533 A default set of setuid programs is defined by the
23534 @code{%setuid-programs} variable of the @code{(gnu system)} module.
23535
23536 @defvr {Scheme Variable} %setuid-programs
23537 A list of G-expressions denoting common programs that are setuid-root.
23538
23539 The list includes commands such as @command{passwd}, @command{ping},
23540 @command{su}, and @command{sudo}.
23541 @end defvr
23542
23543 Under the hood, the actual setuid programs are created in the
23544 @file{/run/setuid-programs} directory at system activation time. The
23545 files in this directory refer to the ``real'' binaries, which are in the
23546 store.
23547
23548 @node X.509 Certificates
23549 @section X.509 Certificates
23550
23551 @cindex HTTPS, certificates
23552 @cindex X.509 certificates
23553 @cindex TLS
23554 Web servers available over HTTPS (that is, HTTP over the transport-layer
23555 security mechanism, TLS) send client programs an @dfn{X.509 certificate}
23556 that the client can then use to @emph{authenticate} the server. To do
23557 that, clients verify that the server's certificate is signed by a
23558 so-called @dfn{certificate authority} (CA). But to verify the CA's
23559 signature, clients must have first acquired the CA's certificate.
23560
23561 Web browsers such as GNU@tie{}IceCat include their own set of CA
23562 certificates, such that they are able to verify CA signatures
23563 out-of-the-box.
23564
23565 However, most other programs that can talk HTTPS---@command{wget},
23566 @command{git}, @command{w3m}, etc.---need to be told where CA
23567 certificates can be found.
23568
23569 @cindex @code{nss-certs}
23570 In Guix, this is done by adding a package that provides certificates
23571 to the @code{packages} field of the @code{operating-system} declaration
23572 (@pxref{operating-system Reference}). Guix includes one such package,
23573 @code{nss-certs}, which is a set of CA certificates provided as part of
23574 Mozilla's Network Security Services.
23575
23576 Note that it is @emph{not} part of @var{%base-packages}, so you need to
23577 explicitly add it. The @file{/etc/ssl/certs} directory, which is where
23578 most applications and libraries look for certificates by default, points
23579 to the certificates installed globally.
23580
23581 Unprivileged users, including users of Guix on a foreign distro,
23582 can also install their own certificate package in
23583 their profile. A number of environment variables need to be defined so
23584 that applications and libraries know where to find them. Namely, the
23585 OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
23586 variables. Some applications add their own environment variables; for
23587 instance, the Git version control system honors the certificate bundle
23588 pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
23589 would typically run something like:
23590
23591 @example
23592 $ guix package -i nss-certs
23593 $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
23594 $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
23595 $ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
23596 @end example
23597
23598 As another example, R requires the @code{CURL_CA_BUNDLE} environment
23599 variable to point to a certificate bundle, so you would have to run
23600 something like this:
23601
23602 @example
23603 $ guix package -i nss-certs
23604 $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
23605 @end example
23606
23607 For other applications you may want to look up the required environment
23608 variable in the relevant documentation.
23609
23610
23611 @node Name Service Switch
23612 @section Name Service Switch
23613
23614 @cindex name service switch
23615 @cindex NSS
23616 The @code{(gnu system nss)} module provides bindings to the
23617 configuration file of the libc @dfn{name service switch} or @dfn{NSS}
23618 (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
23619 Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
23620 extended with new ``name'' lookup methods for system databases, which
23621 includes host names, service names, user accounts, and more (@pxref{Name
23622 Service Switch, System Databases and Name Service Switch,, libc, The GNU
23623 C Library Reference Manual}).
23624
23625 The NSS configuration specifies, for each system database, which lookup
23626 method is to be used, and how the various methods are chained
23627 together---for instance, under which circumstances NSS should try the
23628 next method in the list. The NSS configuration is given in the
23629 @code{name-service-switch} field of @code{operating-system} declarations
23630 (@pxref{operating-system Reference, @code{name-service-switch}}).
23631
23632 @cindex nss-mdns
23633 @cindex .local, host name lookup
23634 As an example, the declaration below configures the NSS to use the
23635 @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
23636 back-end}, which supports host name lookups over multicast DNS (mDNS)
23637 for host names ending in @code{.local}:
23638
23639 @example
23640 (name-service-switch
23641 (hosts (list %files ;first, check /etc/hosts
23642
23643 ;; If the above did not succeed, try
23644 ;; with 'mdns_minimal'.
23645 (name-service
23646 (name "mdns_minimal")
23647
23648 ;; 'mdns_minimal' is authoritative for
23649 ;; '.local'. When it returns "not found",
23650 ;; no need to try the next methods.
23651 (reaction (lookup-specification
23652 (not-found => return))))
23653
23654 ;; Then fall back to DNS.
23655 (name-service
23656 (name "dns"))
23657
23658 ;; Finally, try with the "full" 'mdns'.
23659 (name-service
23660 (name "mdns")))))
23661 @end example
23662
23663 Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
23664 contains this configuration, so you will not have to type it if all you
23665 want is to have @code{.local} host lookup working.
23666
23667 Note that, in this case, in addition to setting the
23668 @code{name-service-switch} of the @code{operating-system} declaration,
23669 you also need to use @code{avahi-service-type} (@pxref{Networking Services,
23670 @code{avahi-service-type}}), or @var{%desktop-services}, which includes it
23671 (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
23672 to the name service cache daemon (@pxref{Base Services,
23673 @code{nscd-service}}).
23674
23675 For convenience, the following variables provide typical NSS
23676 configurations.
23677
23678 @defvr {Scheme Variable} %default-nss
23679 This is the default name service switch configuration, a
23680 @code{name-service-switch} object.
23681 @end defvr
23682
23683 @defvr {Scheme Variable} %mdns-host-lookup-nss
23684 This is the name service switch configuration with support for host name
23685 lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
23686 @end defvr
23687
23688 The reference for name service switch configuration is given below. It
23689 is a direct mapping of the configuration file format of the C library , so
23690 please refer to the C library manual for more information (@pxref{NSS
23691 Configuration File,,, libc, The GNU C Library Reference Manual}).
23692 Compared to the configuration file format of libc NSS, it has the advantage
23693 not only of adding this warm parenthetic feel that we like, but also
23694 static checks: you will know about syntax errors and typos as soon as you
23695 run @command{guix system}.
23696
23697 @deftp {Data Type} name-service-switch
23698
23699 This is the data type representation the configuration of libc's name
23700 service switch (NSS). Each field below represents one of the supported
23701 system databases.
23702
23703 @table @code
23704 @item aliases
23705 @itemx ethers
23706 @itemx group
23707 @itemx gshadow
23708 @itemx hosts
23709 @itemx initgroups
23710 @itemx netgroup
23711 @itemx networks
23712 @itemx password
23713 @itemx public-key
23714 @itemx rpc
23715 @itemx services
23716 @itemx shadow
23717 The system databases handled by the NSS. Each of these fields must be a
23718 list of @code{<name-service>} objects (see below).
23719 @end table
23720 @end deftp
23721
23722 @deftp {Data Type} name-service
23723
23724 This is the data type representing an actual name service and the
23725 associated lookup action.
23726
23727 @table @code
23728 @item name
23729 A string denoting the name service (@pxref{Services in the NSS
23730 configuration,,, libc, The GNU C Library Reference Manual}).
23731
23732 Note that name services listed here must be visible to nscd. This is
23733 achieved by passing the @code{#:name-services} argument to
23734 @code{nscd-service} the list of packages providing the needed name
23735 services (@pxref{Base Services, @code{nscd-service}}).
23736
23737 @item reaction
23738 An action specified using the @code{lookup-specification} macro
23739 (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
23740 Reference Manual}). For example:
23741
23742 @example
23743 (lookup-specification (unavailable => continue)
23744 (success => return))
23745 @end example
23746 @end table
23747 @end deftp
23748
23749 @node Initial RAM Disk
23750 @section Initial RAM Disk
23751
23752 @cindex initrd
23753 @cindex initial RAM disk
23754 For bootstrapping purposes, the Linux-Libre kernel is passed an
23755 @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
23756 root file system as well as an initialization script. The latter is
23757 responsible for mounting the real root file system, and for loading any
23758 kernel modules that may be needed to achieve that.
23759
23760 The @code{initrd-modules} field of an @code{operating-system}
23761 declaration allows you to specify Linux-libre kernel modules that must
23762 be available in the initrd. In particular, this is where you would list
23763 modules needed to actually drive the hard disk where your root partition
23764 is---although the default value of @code{initrd-modules} should cover
23765 most use cases. For example, assuming you need the @code{megaraid_sas}
23766 module in addition to the default modules to be able to access your root
23767 file system, you would write:
23768
23769 @example
23770 (operating-system
23771 ;; @dots{}
23772 (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
23773 @end example
23774
23775 @defvr {Scheme Variable} %base-initrd-modules
23776 This is the list of kernel modules included in the initrd by default.
23777 @end defvr
23778
23779 Furthermore, if you need lower-level customization, the @code{initrd}
23780 field of an @code{operating-system} declaration allows
23781 you to specify which initrd you would like to use. The @code{(gnu
23782 system linux-initrd)} module provides three ways to build an initrd: the
23783 high-level @code{base-initrd} procedure and the low-level
23784 @code{raw-initrd} and @code{expression->initrd} procedures.
23785
23786 The @code{base-initrd} procedure is intended to cover most common uses.
23787 For example, if you want to add a bunch of kernel modules to be loaded
23788 at boot time, you can define the @code{initrd} field of the operating
23789 system declaration like this:
23790
23791 @example
23792 (initrd (lambda (file-systems . rest)
23793 ;; Create a standard initrd but set up networking
23794 ;; with the parameters QEMU expects by default.
23795 (apply base-initrd file-systems
23796 #:qemu-networking? #t
23797 rest)))
23798 @end example
23799
23800 The @code{base-initrd} procedure also handles common use cases that
23801 involves using the system as a QEMU guest, or as a ``live'' system with
23802 volatile root file system.
23803
23804 The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
23805 Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
23806 such as trying to guess which kernel modules and packages should be included
23807 to the initrd. An example use of @code{raw-initrd} is when a user has
23808 a custom Linux kernel configuration and default kernel modules included by
23809 @code{base-initrd} are not available.
23810
23811 The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
23812 honors several options passed on the Linux kernel command line
23813 (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
23814 @code{-append} option of QEMU), notably:
23815
23816 @table @code
23817 @item --load=@var{boot}
23818 Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
23819 program, once it has mounted the root file system.
23820
23821 Guix uses this option to yield control to a boot program that runs the
23822 service activation programs and then spawns the GNU@tie{}Shepherd, the
23823 initialization system.
23824
23825 @item --root=@var{root}
23826 Mount @var{root} as the root file system. @var{root} can be a
23827 device name like @code{/dev/sda1}, a file system label, or a file system
23828 UUID.
23829
23830 @item --system=@var{system}
23831 Have @file{/run/booted-system} and @file{/run/current-system} point to
23832 @var{system}.
23833
23834 @item modprobe.blacklist=@var{modules}@dots{}
23835 @cindex module, black-listing
23836 @cindex black list, of kernel modules
23837 Instruct the initial RAM disk as well as the @command{modprobe} command
23838 (from the kmod package) to refuse to load @var{modules}. @var{modules}
23839 must be a comma-separated list of module names---e.g.,
23840 @code{usbkbd,9pnet}.
23841
23842 @item --repl
23843 Start a read-eval-print loop (REPL) from the initial RAM disk before it
23844 tries to load kernel modules and to mount the root file system. Our
23845 marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
23846 love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
23847 Manual}, for more information on Guile's REPL.
23848
23849 @end table
23850
23851 Now that you know all the features that initial RAM disks produced by
23852 @code{base-initrd} and @code{raw-initrd} provide,
23853 here is how to use it and customize it further.
23854
23855 @cindex initrd
23856 @cindex initial RAM disk
23857 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
23858 [#:linux-modules '()] [#:mapped-devices '()] @
23859 [#:keyboard-layout #f] @
23860 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
23861 Return a derivation that builds a raw initrd. @var{file-systems} is
23862 a list of file systems to be mounted by the initrd, possibly in addition to
23863 the root file system specified on the kernel command line via @code{--root}.
23864 @var{linux-modules} is a list of kernel modules to be loaded at boot time.
23865 @var{mapped-devices} is a list of device mappings to realize before
23866 @var{file-systems} are mounted (@pxref{Mapped Devices}).
23867 @var{helper-packages} is a list of packages to be copied in the initrd. It may
23868 include @code{e2fsck/static} or other packages needed by the initrd to check
23869 the root file system.
23870
23871 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
23872 the desired console keyboard layout. This is done before @var{mapped-devices}
23873 are set up and before @var{file-systems} are mounted such that, should the
23874 user need to enter a passphrase or use the REPL, this happens using the
23875 intended keyboard layout.
23876
23877 When @var{qemu-networking?} is true, set up networking with the standard QEMU
23878 parameters. When @var{virtio?} is true, load additional modules so that the
23879 initrd can be used as a QEMU guest with para-virtualized I/O drivers.
23880
23881 When @var{volatile-root?} is true, the root file system is writable but any changes
23882 to it are lost.
23883 @end deffn
23884
23885 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
23886 [#:mapped-devices '()] [#:keyboard-layout #f] @
23887 [#:qemu-networking? #f] [#:volatile-root? #f] @
23888 [#:linux-modules '()]
23889 Return as a file-like object a generic initrd, with kernel
23890 modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
23891 mounted by the initrd, possibly in addition to the root file system specified
23892 on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device
23893 mappings to realize before @var{file-systems} are mounted.
23894
23895 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
23896 the desired console keyboard layout. This is done before @var{mapped-devices}
23897 are set up and before @var{file-systems} are mounted such that, should the
23898 user need to enter a passphrase or use the REPL, this happens using the
23899 intended keyboard layout.
23900
23901 @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
23902
23903 The initrd is automatically populated with all the kernel modules necessary
23904 for @var{file-systems} and for the given options. Additional kernel
23905 modules can be listed in @var{linux-modules}. They will be added to the initrd, and
23906 loaded at boot time in the order in which they appear.
23907 @end deffn
23908
23909 Needless to say, the initrds we produce and use embed a
23910 statically-linked Guile, and the initialization program is a Guile
23911 program. That gives a lot of flexibility. The
23912 @code{expression->initrd} procedure builds such an initrd, given the
23913 program to run in that initrd.
23914
23915 @deffn {Scheme Procedure} expression->initrd @var{exp} @
23916 [#:guile %guile-static-stripped] [#:name "guile-initrd"]
23917 Return as a file-like object a Linux initrd (a gzipped cpio archive)
23918 containing @var{guile} and that evaluates @var{exp}, a G-expression,
23919 upon booting. All the derivations referenced by @var{exp} are
23920 automatically copied to the initrd.
23921 @end deffn
23922
23923 @node Bootloader Configuration
23924 @section Bootloader Configuration
23925
23926 @cindex bootloader
23927 @cindex boot loader
23928
23929 The operating system supports multiple bootloaders. The bootloader is
23930 configured using @code{bootloader-configuration} declaration. All the
23931 fields of this structure are bootloader agnostic except for one field,
23932 @code{bootloader} that indicates the bootloader to be configured and
23933 installed.
23934
23935 Some of the bootloaders do not honor every field of
23936 @code{bootloader-configuration}. For instance, the extlinux
23937 bootloader does not support themes and thus ignores the @code{theme}
23938 field.
23939
23940 @deftp {Data Type} bootloader-configuration
23941 The type of a bootloader configuration declaration.
23942
23943 @table @asis
23944
23945 @item @code{bootloader}
23946 @cindex EFI, bootloader
23947 @cindex UEFI, bootloader
23948 @cindex BIOS, bootloader
23949 The bootloader to use, as a @code{bootloader} object. For now
23950 @code{grub-bootloader}, @code{grub-efi-bootloader},
23951 @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
23952
23953 @vindex grub-efi-bootloader
23954 @code{grub-efi-bootloader} allows to boot on modern systems using the
23955 @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
23956 use if the installation image contains a @file{/sys/firmware/efi} directory
23957 when you boot it on your system.
23958
23959 @vindex grub-bootloader
23960 @code{grub-bootloader} allows you to boot in particular Intel-based machines
23961 in ``legacy'' BIOS mode.
23962
23963 @cindex ARM, bootloaders
23964 @cindex AArch64, bootloaders
23965 Available bootloaders are described in @code{(gnu bootloader @dots{})}
23966 modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
23967 of bootloaders for a wide range of ARM and AArch64 systems, using the
23968 @uref{http://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
23969
23970 @item @code{target}
23971 This is a string denoting the target onto which to install the
23972 bootloader.
23973
23974 The interpretation depends on the bootloader in question. For
23975 @code{grub-bootloader}, for example, it should be a device name understood by
23976 the bootloader @command{installer} command, such as @code{/dev/sda} or
23977 @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
23978 @code{grub-efi-bootloader}, it should be the mount point of the EFI file
23979 system, usually @file{/boot/efi}.
23980
23981 @item @code{menu-entries} (default: @code{()})
23982 A possibly empty list of @code{menu-entry} objects (see below), denoting
23983 entries to appear in the bootloader menu, in addition to the current
23984 system entry and the entry pointing to previous system generations.
23985
23986 @item @code{default-entry} (default: @code{0})
23987 The index of the default boot menu entry. Index 0 is for the entry of the
23988 current system.
23989
23990 @item @code{timeout} (default: @code{5})
23991 The number of seconds to wait for keyboard input before booting. Set to
23992 0 to boot immediately, and to -1 to wait indefinitely.
23993
23994 @cindex keyboard layout, for the bootloader
23995 @item @code{keyboard-layout} (default: @code{#f})
23996 If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
23997 layout, usually US@tie{}English (``qwerty'').
23998
23999 Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
24000 Layout}).
24001
24002 @quotation Note
24003 This option is currently ignored by bootloaders other than @code{grub} and
24004 @code{grub-efi}.
24005 @end quotation
24006
24007 @item @code{theme} (default: @var{#f})
24008 The bootloader theme object describing the theme to use. If no theme
24009 is provided, some bootloaders might use a default theme, that's true
24010 for GRUB.
24011
24012 @item @code{terminal-outputs} (default: @code{'gfxterm})
24013 The output terminals used for the bootloader boot menu, as a list of
24014 symbols. GRUB accepts the values: @code{console}, @code{serial},
24015 @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
24016 @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
24017 corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
24018 configuration,,, grub,GNU GRUB manual}).
24019
24020 @item @code{terminal-inputs} (default: @code{'()})
24021 The input terminals used for the bootloader boot menu, as a list of
24022 symbols. For GRUB, the default is the native platform terminal as
24023 determined at run-time. GRUB accepts the values: @code{console},
24024 @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
24025 @code{usb_keyboard}. This field corresponds to the GRUB variable
24026 @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
24027 manual}).
24028
24029 @item @code{serial-unit} (default: @code{#f})
24030 The serial unit used by the bootloader, as an integer from 0 to 3.
24031 For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
24032 corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
24033
24034 @item @code{serial-speed} (default: @code{#f})
24035 The speed of the serial interface, as an integer. For GRUB, the
24036 default value is chosen at run-time; currently GRUB chooses
24037 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
24038 @end table
24039
24040 @end deftp
24041
24042 @cindex dual boot
24043 @cindex boot menu
24044 Should you want to list additional boot menu entries @i{via} the
24045 @code{menu-entries} field above, you will need to create them with the
24046 @code{menu-entry} form. For example, imagine you want to be able to
24047 boot another distro (hard to imagine!), you can define a menu entry
24048 along these lines:
24049
24050 @example
24051 (menu-entry
24052 (label "The Other Distro")
24053 (linux "/boot/old/vmlinux-2.6.32")
24054 (linux-arguments '("root=/dev/sda2"))
24055 (initrd "/boot/old/initrd"))
24056 @end example
24057
24058 Details below.
24059
24060 @deftp {Data Type} menu-entry
24061 The type of an entry in the bootloader menu.
24062
24063 @table @asis
24064
24065 @item @code{label}
24066 The label to show in the menu---e.g., @code{"GNU"}.
24067
24068 @item @code{linux}
24069 The Linux kernel image to boot, for example:
24070
24071 @example
24072 (file-append linux-libre "/bzImage")
24073 @end example
24074
24075 For GRUB, it is also possible to specify a device explicitly in the
24076 file path using GRUB's device naming convention (@pxref{Naming
24077 convention,,, grub, GNU GRUB manual}), for example:
24078
24079 @example
24080 "(hd0,msdos1)/boot/vmlinuz"
24081 @end example
24082
24083 If the device is specified explicitly as above, then the @code{device}
24084 field is ignored entirely.
24085
24086 @item @code{linux-arguments} (default: @code{()})
24087 The list of extra Linux kernel command-line arguments---e.g.,
24088 @code{("console=ttyS0")}.
24089
24090 @item @code{initrd}
24091 A G-Expression or string denoting the file name of the initial RAM disk
24092 to use (@pxref{G-Expressions}).
24093 @item @code{device} (default: @code{#f})
24094 The device where the kernel and initrd are to be found---i.e., for GRUB,
24095 @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
24096
24097 This may be a file system label (a string), a file system UUID (a
24098 bytevector, @pxref{File Systems}), or @code{#f}, in which case
24099 the bootloader will search the device containing the file specified by
24100 the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
24101 must @emph{not} be an OS device name such as @file{/dev/sda1}.
24102
24103 @end table
24104 @end deftp
24105
24106 @c FIXME: Write documentation once it's stable.
24107 For now only GRUB has theme support. GRUB themes are created using
24108 the @code{grub-theme} form, which is not documented yet.
24109
24110 @defvr {Scheme Variable} %default-theme
24111 This is the default GRUB theme used by the operating system if no
24112 @code{theme} field is specified in @code{bootloader-configuration}
24113 record.
24114
24115 It comes with a fancy background image displaying the GNU and Guix
24116 logos.
24117 @end defvr
24118
24119
24120 @node Invoking guix system
24121 @section Invoking @code{guix system}
24122
24123 Once you have written an operating system declaration as seen in the
24124 previous section, it can be @dfn{instantiated} using the @command{guix
24125 system} command. The synopsis is:
24126
24127 @example
24128 guix system @var{options}@dots{} @var{action} @var{file}
24129 @end example
24130
24131 @var{file} must be the name of a file containing an
24132 @code{operating-system} declaration. @var{action} specifies how the
24133 operating system is instantiated. Currently the following values are
24134 supported:
24135
24136 @table @code
24137 @item search
24138 Display available service type definitions that match the given regular
24139 expressions, sorted by relevance:
24140
24141 @example
24142 $ guix system search console font
24143 name: console-fonts
24144 location: gnu/services/base.scm:729:2
24145 extends: shepherd-root
24146 description: Install the given fonts on the specified ttys (fonts are
24147 + per virtual console on GNU/Linux). The value of this service is a list
24148 + of tty/font pairs like:
24149 +
24150 + '(("tty1" . "LatGrkCyr-8x16"))
24151 relevance: 20
24152
24153 name: mingetty
24154 location: gnu/services/base.scm:1048:2
24155 extends: shepherd-root
24156 description: Provide console login using the `mingetty' program.
24157 relevance: 2
24158
24159 name: login
24160 location: gnu/services/base.scm:775:2
24161 extends: pam
24162 description: Provide a console log-in service as specified by its
24163 + configuration value, a `login-configuration' object.
24164 relevance: 2
24165
24166 @dots{}
24167 @end example
24168
24169 As for @command{guix package --search}, the result is written in
24170 @code{recutils} format, which makes it easy to filter the output
24171 (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
24172
24173 @item reconfigure
24174 Build the operating system described in @var{file}, activate it, and
24175 switch to it@footnote{This action (and the related actions
24176 @code{switch-generation} and @code{roll-back}) are usable only on
24177 systems already running Guix System.}.
24178
24179 This effects all the configuration specified in @var{file}: user
24180 accounts, system services, global package list, setuid programs, etc.
24181 The command starts system services specified in @var{file} that are not
24182 currently running; if a service is currently running this command will
24183 arrange for it to be upgraded the next time it is stopped (e.g.@: by
24184 @code{herd stop X} or @code{herd restart X}).
24185
24186 This command creates a new generation whose number is one greater than
24187 the current generation (as reported by @command{guix system
24188 list-generations}). If that generation already exists, it will be
24189 overwritten. This behavior mirrors that of @command{guix package}
24190 (@pxref{Invoking guix package}).
24191
24192 It also adds a bootloader menu entry for the new OS configuration,
24193 ---unless @option{--no-bootloader} is passed. For GRUB, it moves
24194 entries for older configurations to a submenu, allowing you to choose
24195 an older system generation at boot time should you need it.
24196
24197 @quotation Note
24198 @c The paragraph below refers to the problem discussed at
24199 @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
24200 It is highly recommended to run @command{guix pull} once before you run
24201 @command{guix system reconfigure} for the first time (@pxref{Invoking
24202 guix pull}). Failing to do that you would see an older version of Guix
24203 once @command{reconfigure} has completed.
24204 @end quotation
24205
24206 @item switch-generation
24207 @cindex generations
24208 Switch to an existing system generation. This action atomically
24209 switches the system profile to the specified system generation. It
24210 also rearranges the system's existing bootloader menu entries. It
24211 makes the menu entry for the specified system generation the default,
24212 and it moves the entries for the other generatiors to a submenu, if
24213 supported by the bootloader being used. The next time the system
24214 boots, it will use the specified system generation.
24215
24216 The bootloader itself is not being reinstalled when using this
24217 command. Thus, the installed bootloader is used with an updated
24218 configuration file.
24219
24220 The target generation can be specified explicitly by its generation
24221 number. For example, the following invocation would switch to system
24222 generation 7:
24223
24224 @example
24225 guix system switch-generation 7
24226 @end example
24227
24228 The target generation can also be specified relative to the current
24229 generation with the form @code{+N} or @code{-N}, where @code{+3} means
24230 ``3 generations ahead of the current generation,'' and @code{-1} means
24231 ``1 generation prior to the current generation.'' When specifying a
24232 negative value such as @code{-1}, you must precede it with @code{--} to
24233 prevent it from being parsed as an option. For example:
24234
24235 @example
24236 guix system switch-generation -- -1
24237 @end example
24238
24239 Currently, the effect of invoking this action is @emph{only} to switch
24240 the system profile to an existing generation and rearrange the
24241 bootloader menu entries. To actually start using the target system
24242 generation, you must reboot after running this action. In the future,
24243 it will be updated to do the same things as @command{reconfigure},
24244 like activating and deactivating services.
24245
24246 This action will fail if the specified generation does not exist.
24247
24248 @item roll-back
24249 @cindex rolling back
24250 Switch to the preceding system generation. The next time the system
24251 boots, it will use the preceding system generation. This is the inverse
24252 of @command{reconfigure}, and it is exactly the same as invoking
24253 @command{switch-generation} with an argument of @code{-1}.
24254
24255 Currently, as with @command{switch-generation}, you must reboot after
24256 running this action to actually start using the preceding system
24257 generation.
24258
24259 @item delete-generations
24260 @cindex deleting system generations
24261 @cindex saving space
24262 Delete system generations, making them candidates for garbage collection
24263 (@pxref{Invoking guix gc}, for information on how to run the ``garbage
24264 collector'').
24265
24266 This works in the same way as @command{guix package --delete-generations}
24267 (@pxref{Invoking guix package, @code{--delete-generations}}). With no
24268 arguments, all system generations but the current one are deleted:
24269
24270 @example
24271 guix system delete-generations
24272 @end example
24273
24274 You can also select the generations you want to delete. The example below
24275 deletes all the system generations that are more than two month old:
24276
24277 @example
24278 guix system delete-generations 2m
24279 @end example
24280
24281 Running this command automatically reinstalls the bootloader with an updated
24282 list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
24283 longer lists the generations that have been deleted.
24284
24285 @item build
24286 Build the derivation of the operating system, which includes all the
24287 configuration files and programs needed to boot and run the system.
24288 This action does not actually install anything.
24289
24290 @item init
24291 Populate the given directory with all the files necessary to run the
24292 operating system specified in @var{file}. This is useful for first-time
24293 installations of Guix System. For instance:
24294
24295 @example
24296 guix system init my-os-config.scm /mnt
24297 @end example
24298
24299 copies to @file{/mnt} all the store items required by the configuration
24300 specified in @file{my-os-config.scm}. This includes configuration
24301 files, packages, and so on. It also creates other essential files
24302 needed for the system to operate correctly---e.g., the @file{/etc},
24303 @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
24304
24305 This command also installs bootloader on the target specified in
24306 @file{my-os-config}, unless the @option{--no-bootloader} option was
24307 passed.
24308
24309 @item vm
24310 @cindex virtual machine
24311 @cindex VM
24312 @anchor{guix system vm}
24313 Build a virtual machine that contains the operating system declared in
24314 @var{file}, and return a script to run that virtual machine (VM).
24315
24316 @quotation Note
24317 The @code{vm} action and others below
24318 can use KVM support in the Linux-libre kernel. Specifically, if the
24319 machine has hardware virtualization support, the corresponding
24320 KVM kernel module should be loaded, and the @file{/dev/kvm} device node
24321 must exist and be readable and writable by the user and by the
24322 build users of the daemon (@pxref{Build Environment Setup}).
24323 @end quotation
24324
24325 Arguments given to the script are passed to QEMU as in the example
24326 below, which enables networking and requests 1@tie{}GiB of RAM for the
24327 emulated machine:
24328
24329 @example
24330 $ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
24331 @end example
24332
24333 The VM shares its store with the host system.
24334
24335 Additional file systems can be shared between the host and the VM using
24336 the @code{--share} and @code{--expose} command-line options: the former
24337 specifies a directory to be shared with write access, while the latter
24338 provides read-only access to the shared directory.
24339
24340 The example below creates a VM in which the user's home directory is
24341 accessible read-only, and where the @file{/exchange} directory is a
24342 read-write mapping of @file{$HOME/tmp} on the host:
24343
24344 @example
24345 guix system vm my-config.scm \
24346 --expose=$HOME --share=$HOME/tmp=/exchange
24347 @end example
24348
24349 On GNU/Linux, the default is to boot directly to the kernel; this has
24350 the advantage of requiring only a very tiny root disk image since the
24351 store of the host can then be mounted.
24352
24353 The @code{--full-boot} option forces a complete boot sequence, starting
24354 with the bootloader. This requires more disk space since a root image
24355 containing at least the kernel, initrd, and bootloader data files must
24356 be created. The @code{--image-size} option can be used to specify the
24357 size of the image.
24358
24359 @cindex System images, creation in various formats
24360 @cindex Creating system images in various formats
24361 @item vm-image
24362 @itemx disk-image
24363 @itemx docker-image
24364 Return a virtual machine, disk image, or Docker image of the operating
24365 system declared in @var{file} that stands alone. By default,
24366 @command{guix system} estimates the size of the image needed to store
24367 the system, but you can use the @option{--image-size} option to specify
24368 a value. Docker images are built to contain exactly what they need, so
24369 the @option{--image-size} option is ignored in the case of
24370 @code{docker-image}.
24371
24372 You can specify the root file system type by using the
24373 @option{--file-system-type} option. It defaults to @code{ext4}.
24374
24375 When using @code{vm-image}, the returned image is in qcow2 format, which
24376 the QEMU emulator can efficiently use. @xref{Running Guix in a VM},
24377 for more information on how to run the image in a virtual machine.
24378
24379 When using @code{disk-image}, a raw disk image is produced; it can be
24380 copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
24381 the device corresponding to a USB stick, one can copy the image to it
24382 using the following command:
24383
24384 @example
24385 # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
24386 @end example
24387
24388 When using @code{docker-image}, a Docker image is produced. Guix builds
24389 the image from scratch, not from a pre-existing Docker base image. As a
24390 result, it contains @emph{exactly} what you define in the operating
24391 system configuration file. You can then load the image and launch a
24392 Docker container using commands like the following:
24393
24394 @example
24395 image_id="$(docker load < guix-system-docker-image.tar.gz)"
24396 docker run -e GUIX_NEW_SYSTEM=/var/guix/profiles/system \\
24397 --entrypoint /var/guix/profiles/system/profile/bin/guile \\
24398 $image_id /var/guix/profiles/system/boot
24399 @end example
24400
24401 This command starts a new Docker container from the specified image. It
24402 will boot the Guix system in the usual manner, which means it will
24403 start any services you have defined in the operating system
24404 configuration. Depending on what you run in the Docker container, it
24405 may be necessary to give the container additional permissions. For
24406 example, if you intend to build software using Guix inside of the Docker
24407 container, you may need to pass the @option{--privileged} option to
24408 @code{docker run}.
24409
24410 @item container
24411 Return a script to run the operating system declared in @var{file}
24412 within a container. Containers are a set of lightweight isolation
24413 mechanisms provided by the kernel Linux-libre. Containers are
24414 substantially less resource-demanding than full virtual machines since
24415 the kernel, shared objects, and other resources can be shared with the
24416 host system; this also means they provide thinner isolation.
24417
24418 Currently, the script must be run as root in order to support more than
24419 a single user and group. The container shares its store with the host
24420 system.
24421
24422 As with the @code{vm} action (@pxref{guix system vm}), additional file
24423 systems to be shared between the host and container can be specified
24424 using the @option{--share} and @option{--expose} options:
24425
24426 @example
24427 guix system container my-config.scm \
24428 --expose=$HOME --share=$HOME/tmp=/exchange
24429 @end example
24430
24431 @quotation Note
24432 This option requires Linux-libre 3.19 or newer.
24433 @end quotation
24434
24435 @end table
24436
24437 @var{options} can contain any of the common build options (@pxref{Common
24438 Build Options}). In addition, @var{options} can contain one of the
24439 following:
24440
24441 @table @option
24442 @item --expression=@var{expr}
24443 @itemx -e @var{expr}
24444 Consider the operating-system @var{expr} evaluates to.
24445 This is an alternative to specifying a file which evaluates to an
24446 operating system.
24447 This is used to generate the Guix system installer @pxref{Building the
24448 Installation Image}).
24449
24450 @item --system=@var{system}
24451 @itemx -s @var{system}
24452 Attempt to build for @var{system} instead of the host system type.
24453 This works as per @command{guix build} (@pxref{Invoking guix build}).
24454
24455 @item --derivation
24456 @itemx -d
24457 Return the derivation file name of the given operating system without
24458 building anything.
24459
24460 @item --file-system-type=@var{type}
24461 @itemx -t @var{type}
24462 For the @code{disk-image} action, create a file system of the given
24463 @var{type} on the image.
24464
24465 When this option is omitted, @command{guix system} uses @code{ext4}.
24466
24467 @cindex ISO-9660 format
24468 @cindex CD image format
24469 @cindex DVD image format
24470 @code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
24471 for burning on CDs and DVDs.
24472
24473 @item --image-size=@var{size}
24474 For the @code{vm-image} and @code{disk-image} actions, create an image
24475 of the given @var{size}. @var{size} may be a number of bytes, or it may
24476 include a unit as a suffix (@pxref{Block size, size specifications,,
24477 coreutils, GNU Coreutils}).
24478
24479 When this option is omitted, @command{guix system} computes an estimate
24480 of the image size as a function of the size of the system declared in
24481 @var{file}.
24482
24483 @item --root=@var{file}
24484 @itemx -r @var{file}
24485 Make @var{file} a symlink to the result, and register it as a garbage
24486 collector root.
24487
24488 @item --skip-checks
24489 Skip pre-installation safety checks.
24490
24491 By default, @command{guix system init} and @command{guix system
24492 reconfigure} perform safety checks: they make sure the file systems that
24493 appear in the @code{operating-system} declaration actually exist
24494 (@pxref{File Systems}), and that any Linux kernel modules that may be
24495 needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
24496 RAM Disk}). Passing this option skips these tests altogether.
24497
24498 @cindex on-error
24499 @cindex on-error strategy
24500 @cindex error strategy
24501 @item --on-error=@var{strategy}
24502 Apply @var{strategy} when an error occurs when reading @var{file}.
24503 @var{strategy} may be one of the following:
24504
24505 @table @code
24506 @item nothing-special
24507 Report the error concisely and exit. This is the default strategy.
24508
24509 @item backtrace
24510 Likewise, but also display a backtrace.
24511
24512 @item debug
24513 Report the error and enter Guile's debugger. From there, you can run
24514 commands such as @code{,bt} to get a backtrace, @code{,locals} to
24515 display local variable values, and more generally inspect the state of the
24516 program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
24517 a list of available debugging commands.
24518 @end table
24519 @end table
24520
24521 Once you have built, configured, re-configured, and re-re-configured
24522 your Guix installation, you may find it useful to list the operating
24523 system generations available on disk---and that you can choose from the
24524 bootloader boot menu:
24525
24526 @table @code
24527
24528 @item list-generations
24529 List a summary of each generation of the operating system available on
24530 disk, in a human-readable way. This is similar to the
24531 @option{--list-generations} option of @command{guix package}
24532 (@pxref{Invoking guix package}).
24533
24534 Optionally, one can specify a pattern, with the same syntax that is used
24535 in @command{guix package --list-generations}, to restrict the list of
24536 generations displayed. For instance, the following command displays
24537 generations that are up to 10 days old:
24538
24539 @example
24540 $ guix system list-generations 10d
24541 @end example
24542
24543 @end table
24544
24545 The @command{guix system} command has even more to offer! The following
24546 sub-commands allow you to visualize how your system services relate to
24547 each other:
24548
24549 @anchor{system-extension-graph}
24550 @table @code
24551
24552 @item extension-graph
24553 Emit in Dot/Graphviz format to standard output the @dfn{service
24554 extension graph} of the operating system defined in @var{file}
24555 (@pxref{Service Composition}, for more information on service
24556 extensions.)
24557
24558 The command:
24559
24560 @example
24561 $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
24562 @end example
24563
24564 produces a PDF file showing the extension relations among services.
24565
24566 @anchor{system-shepherd-graph}
24567 @item shepherd-graph
24568 Emit in Dot/Graphviz format to standard output the @dfn{dependency
24569 graph} of shepherd services of the operating system defined in
24570 @var{file}. @xref{Shepherd Services}, for more information and for an
24571 example graph.
24572
24573 @end table
24574
24575 @node Running Guix in a VM
24576 @section Running Guix in a Virtual Machine
24577
24578 @cindex virtual machine
24579 To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
24580 distributed at
24581 @indicateurl{https://alpha.gnu.org/gnu/guix/guix-system-vm-image-@value{VERSION}.@var{system}.xz}
24582 This image is a compressed image in QCOW format. You will first need to
24583 decompress with @command{xz -d}, and then you can pass it to an emulator such
24584 as QEMU (see below for details).
24585
24586 This image boots the Xfce graphical environment and it contains some
24587 commonly-used tools. You can install more software in the image by running
24588 @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
24589 also reconfigure the system based on its initial configuration file available
24590 as @file{/etc/config.scm} (@pxref{Using the Configuration System}).
24591
24592 Instead of using this pre-built image, one can also build their own virtual
24593 machine image using @command{guix system vm-image} (@pxref{Invoking guix
24594 system}). The returned image is in qcow2 format, which the
24595 @uref{http://qemu.org/, QEMU emulator} can efficiently use.
24596
24597 @cindex QEMU
24598 If you built your own image, you must copy it out of the store
24599 (@pxref{The Store}) and give yourself permission to write to the copy
24600 before you can use it. When invoking QEMU, you must choose a system
24601 emulator that is suitable for your hardware platform. Here is a minimal
24602 QEMU invocation that will boot the result of @command{guix system
24603 vm-image} on x86_64 hardware:
24604
24605 @example
24606 $ qemu-system-x86_64 \
24607 -net user -net nic,model=virtio \
24608 -enable-kvm -m 512 /tmp/qemu-image
24609 @end example
24610
24611 Here is what each of these options means:
24612
24613 @table @code
24614 @item qemu-system-x86_64
24615 This specifies the hardware platform to emulate. This should match the
24616 host.
24617
24618 @item -net user
24619 Enable the unprivileged user-mode network stack. The guest OS can
24620 access the host but not vice versa. This is the simplest way to get the
24621 guest OS online.
24622
24623 @item -net nic,model=virtio
24624 You must create a network interface of a given model. If you do not
24625 create a NIC, the boot will fail. Assuming your hardware platform is
24626 x86_64, you can get a list of available NIC models by running
24627 @command{qemu-system-x86_64 -net nic,model=help}.
24628
24629 @item -enable-kvm
24630 If your system has hardware virtualization extensions, enabling the
24631 virtual machine support (KVM) of the Linux kernel will make things run
24632 faster.
24633
24634 @item -m 512
24635 RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
24636 which may be insufficient for some operations.
24637
24638 @item /tmp/qemu-image
24639 The file name of the qcow2 image.
24640 @end table
24641
24642 The default @command{run-vm.sh} script that is returned by an invocation of
24643 @command{guix system vm} does not add a @command{-net user} flag by default.
24644 To get network access from within the vm add the @code{(dhcp-client-service)}
24645 to your system definition and start the VM using
24646 @command{`guix system vm config.scm` -net user}. An important caveat of using
24647 @command{-net user} for networking is that @command{ping} will not work, because
24648 it uses the ICMP protocol. You'll have to use a different command to check for
24649 network connectivity, for example @command{guix download}.
24650
24651 @subsection Connecting Through SSH
24652
24653 @cindex SSH
24654 @cindex SSH server
24655 To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
24656 or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
24657 boot unsupervised. It requires you to type some characters to initialize the
24658 randomness generator. In addition you need to forward the SSH port, 22 by
24659 default, to the host. You can do this with
24660
24661 @example
24662 `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
24663 @end example
24664
24665 To connect to the VM you can run
24666
24667 @example
24668 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
24669 @end example
24670
24671 The @command{-p} tells @command{ssh} the port you want to connect to.
24672 @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
24673 every time you modify your @command{config.scm} file and the
24674 @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
24675 connection to an unknown host every time you connect.
24676
24677 @subsection Using @command{virt-viewer} with Spice
24678
24679 As an alternative to the default @command{qemu} graphical client you can
24680 use the @command{remote-viewer} from the @command{virt-viewer} package. To
24681 connect pass the @command{-spice port=5930,disable-ticketing} flag to
24682 @command{qemu}. See previous section for further information on how to do this.
24683
24684 Spice also allows you to do some nice stuff like share your clipboard with your
24685 VM. To enable that you'll also have to pass the following flags to @command{qemu}:
24686
24687 @example
24688 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
24689 -chardev spicevmc,name=vdagent,id=vdagent
24690 -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
24691 name=com.redhat.spice.0
24692 @end example
24693
24694 You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
24695
24696 @node Defining Services
24697 @section Defining Services
24698
24699 The previous sections show the available services and how one can combine
24700 them in an @code{operating-system} declaration. But how do we define
24701 them in the first place? And what is a service anyway?
24702
24703 @menu
24704 * Service Composition:: The model for composing services.
24705 * Service Types and Services:: Types and services.
24706 * Service Reference:: API reference.
24707 * Shepherd Services:: A particular type of service.
24708 @end menu
24709
24710 @node Service Composition
24711 @subsection Service Composition
24712
24713 @cindex services
24714 @cindex daemons
24715 Here we define a @dfn{service} as, broadly, something that extends the
24716 functionality of the operating system. Often a service is a process---a
24717 @dfn{daemon}---started when the system boots: a secure shell server, a
24718 Web server, the Guix build daemon, etc. Sometimes a service is a daemon
24719 whose execution can be triggered by another daemon---e.g., an FTP server
24720 started by @command{inetd} or a D-Bus service activated by
24721 @command{dbus-daemon}. Occasionally, a service does not map to a
24722 daemon. For instance, the ``account'' service collects user accounts
24723 and makes sure they exist when the system runs; the ``udev'' service
24724 collects device management rules and makes them available to the eudev
24725 daemon; the @file{/etc} service populates the @file{/etc} directory
24726 of the system.
24727
24728 @cindex service extensions
24729 Guix system services are connected by @dfn{extensions}. For instance, the
24730 secure shell service @emph{extends} the Shepherd---the
24731 initialization system, running as PID@tie{}1---by giving it the command
24732 lines to start and stop the secure shell daemon (@pxref{Networking
24733 Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
24734 service by passing it its @file{.service} specification, and extends the
24735 udev service by passing it device management rules (@pxref{Desktop
24736 Services, @code{upower-service}}); the Guix daemon service extends the
24737 Shepherd by passing it the command lines to start and stop the daemon,
24738 and extends the account service by passing it a list of required build
24739 user accounts (@pxref{Base Services}).
24740
24741 All in all, services and their ``extends'' relations form a directed
24742 acyclic graph (DAG). If we represent services as boxes and extensions
24743 as arrows, a typical system might provide something like this:
24744
24745 @image{images/service-graph,,5in,Typical service extension graph.}
24746
24747 @cindex system service
24748 At the bottom, we see the @dfn{system service}, which produces the
24749 directory containing everything to run and boot the system, as returned
24750 by the @command{guix system build} command. @xref{Service Reference},
24751 to learn about the other service types shown here.
24752 @xref{system-extension-graph, the @command{guix system extension-graph}
24753 command}, for information on how to generate this representation for a
24754 particular operating system definition.
24755
24756 @cindex service types
24757 Technically, developers can define @dfn{service types} to express these
24758 relations. There can be any number of services of a given type on the
24759 system---for instance, a system running two instances of the GNU secure
24760 shell server (lsh) has two instances of @code{lsh-service-type}, with
24761 different parameters.
24762
24763 The following section describes the programming interface for service
24764 types and services.
24765
24766 @node Service Types and Services
24767 @subsection Service Types and Services
24768
24769 A @dfn{service type} is a node in the DAG described above. Let us start
24770 with a simple example, the service type for the Guix build daemon
24771 (@pxref{Invoking guix-daemon}):
24772
24773 @example
24774 (define guix-service-type
24775 (service-type
24776 (name 'guix)
24777 (extensions
24778 (list (service-extension shepherd-root-service-type guix-shepherd-service)
24779 (service-extension account-service-type guix-accounts)
24780 (service-extension activation-service-type guix-activation)))
24781 (default-value (guix-configuration))))
24782 @end example
24783
24784 @noindent
24785 It defines three things:
24786
24787 @enumerate
24788 @item
24789 A name, whose sole purpose is to make inspection and debugging easier.
24790
24791 @item
24792 A list of @dfn{service extensions}, where each extension designates the
24793 target service type and a procedure that, given the parameters of the
24794 service, returns a list of objects to extend the service of that type.
24795
24796 Every service type has at least one service extension. The only
24797 exception is the @dfn{boot service type}, which is the ultimate service.
24798
24799 @item
24800 Optionally, a default value for instances of this type.
24801 @end enumerate
24802
24803 In this example, @code{guix-service-type} extends three services:
24804
24805 @table @code
24806 @item shepherd-root-service-type
24807 The @code{guix-shepherd-service} procedure defines how the Shepherd
24808 service is extended. Namely, it returns a @code{<shepherd-service>}
24809 object that defines how @command{guix-daemon} is started and stopped
24810 (@pxref{Shepherd Services}).
24811
24812 @item account-service-type
24813 This extension for this service is computed by @code{guix-accounts},
24814 which returns a list of @code{user-group} and @code{user-account}
24815 objects representing the build user accounts (@pxref{Invoking
24816 guix-daemon}).
24817
24818 @item activation-service-type
24819 Here @code{guix-activation} is a procedure that returns a gexp, which is
24820 a code snippet to run at ``activation time''---e.g., when the service is
24821 booted.
24822 @end table
24823
24824 A service of this type is instantiated like this:
24825
24826 @example
24827 (service guix-service-type
24828 (guix-configuration
24829 (build-accounts 5)
24830 (use-substitutes? #f)))
24831 @end example
24832
24833 The second argument to the @code{service} form is a value representing
24834 the parameters of this specific service instance.
24835 @xref{guix-configuration-type, @code{guix-configuration}}, for
24836 information about the @code{guix-configuration} data type. When the
24837 value is omitted, the default value specified by
24838 @code{guix-service-type} is used:
24839
24840 @example
24841 (service guix-service-type)
24842 @end example
24843
24844 @code{guix-service-type} is quite simple because it extends other
24845 services but is not extensible itself.
24846
24847 @c @subsubsubsection Extensible Service Types
24848
24849 The service type for an @emph{extensible} service looks like this:
24850
24851 @example
24852 (define udev-service-type
24853 (service-type (name 'udev)
24854 (extensions
24855 (list (service-extension shepherd-root-service-type
24856 udev-shepherd-service)))
24857
24858 (compose concatenate) ;concatenate the list of rules
24859 (extend (lambda (config rules)
24860 (match config
24861 (($ <udev-configuration> udev initial-rules)
24862 (udev-configuration
24863 (udev udev) ;the udev package to use
24864 (rules (append initial-rules rules)))))))))
24865 @end example
24866
24867 This is the service type for the
24868 @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
24869 management daemon}. Compared to the previous example, in addition to an
24870 extension of @code{shepherd-root-service-type}, we see two new fields:
24871
24872 @table @code
24873 @item compose
24874 This is the procedure to @dfn{compose} the list of extensions to
24875 services of this type.
24876
24877 Services can extend the udev service by passing it lists of rules; we
24878 compose those extensions simply by concatenating them.
24879
24880 @item extend
24881 This procedure defines how the value of the service is @dfn{extended} with
24882 the composition of the extensions.
24883
24884 Udev extensions are composed into a list of rules, but the udev service
24885 value is itself a @code{<udev-configuration>} record. So here, we
24886 extend that record by appending the list of rules it contains to the
24887 list of contributed rules.
24888
24889 @item description
24890 This is a string giving an overview of the service type. The string can
24891 contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
24892 @command{guix system search} command searches these strings and displays
24893 them (@pxref{Invoking guix system}).
24894 @end table
24895
24896 There can be only one instance of an extensible service type such as
24897 @code{udev-service-type}. If there were more, the
24898 @code{service-extension} specifications would be ambiguous.
24899
24900 Still here? The next section provides a reference of the programming
24901 interface for services.
24902
24903 @node Service Reference
24904 @subsection Service Reference
24905
24906 We have seen an overview of service types (@pxref{Service Types and
24907 Services}). This section provides a reference on how to manipulate
24908 services and service types. This interface is provided by the
24909 @code{(gnu services)} module.
24910
24911 @deffn {Scheme Procedure} service @var{type} [@var{value}]
24912 Return a new service of @var{type}, a @code{<service-type>} object (see
24913 below.) @var{value} can be any object; it represents the parameters of
24914 this particular service instance.
24915
24916 When @var{value} is omitted, the default value specified by @var{type}
24917 is used; if @var{type} does not specify a default value, an error is
24918 raised.
24919
24920 For instance, this:
24921
24922 @example
24923 (service openssh-service-type)
24924 @end example
24925
24926 @noindent
24927 is equivalent to this:
24928
24929 @example
24930 (service openssh-service-type
24931 (openssh-configuration))
24932 @end example
24933
24934 In both cases the result is an instance of @code{openssh-service-type}
24935 with the default configuration.
24936 @end deffn
24937
24938 @deffn {Scheme Procedure} service? @var{obj}
24939 Return true if @var{obj} is a service.
24940 @end deffn
24941
24942 @deffn {Scheme Procedure} service-kind @var{service}
24943 Return the type of @var{service}---i.e., a @code{<service-type>} object.
24944 @end deffn
24945
24946 @deffn {Scheme Procedure} service-value @var{service}
24947 Return the value associated with @var{service}. It represents its
24948 parameters.
24949 @end deffn
24950
24951 Here is an example of how a service is created and manipulated:
24952
24953 @example
24954 (define s
24955 (service nginx-service-type
24956 (nginx-configuration
24957 (nginx nginx)
24958 (log-directory log-directory)
24959 (run-directory run-directory)
24960 (file config-file))))
24961
24962 (service? s)
24963 @result{} #t
24964
24965 (eq? (service-kind s) nginx-service-type)
24966 @result{} #t
24967 @end example
24968
24969 The @code{modify-services} form provides a handy way to change the
24970 parameters of some of the services of a list such as
24971 @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
24972 evaluates to a list of services. Of course, you could always use
24973 standard list combinators such as @code{map} and @code{fold} to do that
24974 (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
24975 @code{modify-services} simply provides a more concise form for this
24976 common pattern.
24977
24978 @deffn {Scheme Syntax} modify-services @var{services} @
24979 (@var{type} @var{variable} => @var{body}) @dots{}
24980
24981 Modify the services listed in @var{services} according to the given
24982 clauses. Each clause has the form:
24983
24984 @example
24985 (@var{type} @var{variable} => @var{body})
24986 @end example
24987
24988 where @var{type} is a service type---e.g.,
24989 @code{guix-service-type}---and @var{variable} is an identifier that is
24990 bound within the @var{body} to the service parameters---e.g., a
24991 @code{guix-configuration} instance---of the original service of that
24992 @var{type}.
24993
24994 The @var{body} should evaluate to the new service parameters, which will
24995 be used to configure the new service. This new service will replace the
24996 original in the resulting list. Because a service's service parameters
24997 are created using @code{define-record-type*}, you can write a succinct
24998 @var{body} that evaluates to the new service parameters by using the
24999 @code{inherit} feature that @code{define-record-type*} provides.
25000
25001 @xref{Using the Configuration System}, for example usage.
25002
25003 @end deffn
25004
25005 Next comes the programming interface for service types. This is
25006 something you want to know when writing new service definitions, but not
25007 necessarily when simply looking for ways to customize your
25008 @code{operating-system} declaration.
25009
25010 @deftp {Data Type} service-type
25011 @cindex service type
25012 This is the representation of a @dfn{service type} (@pxref{Service Types
25013 and Services}).
25014
25015 @table @asis
25016 @item @code{name}
25017 This is a symbol, used only to simplify inspection and debugging.
25018
25019 @item @code{extensions}
25020 A non-empty list of @code{<service-extension>} objects (see below).
25021
25022 @item @code{compose} (default: @code{#f})
25023 If this is @code{#f}, then the service type denotes services that cannot
25024 be extended---i.e., services that do not receive ``values'' from other
25025 services.
25026
25027 Otherwise, it must be a one-argument procedure. The procedure is called
25028 by @code{fold-services} and is passed a list of values collected from
25029 extensions. It may return any single value.
25030
25031 @item @code{extend} (default: @code{#f})
25032 If this is @code{#f}, services of this type cannot be extended.
25033
25034 Otherwise, it must be a two-argument procedure: @code{fold-services}
25035 calls it, passing it the initial value of the service as the first
25036 argument and the result of applying @code{compose} to the extension
25037 values as the second argument. It must return a value that is a valid
25038 parameter value for the service instance.
25039 @end table
25040
25041 @xref{Service Types and Services}, for examples.
25042 @end deftp
25043
25044 @deffn {Scheme Procedure} service-extension @var{target-type} @
25045 @var{compute}
25046 Return a new extension for services of type @var{target-type}.
25047 @var{compute} must be a one-argument procedure: @code{fold-services}
25048 calls it, passing it the value associated with the service that provides
25049 the extension; it must return a valid value for the target service.
25050 @end deffn
25051
25052 @deffn {Scheme Procedure} service-extension? @var{obj}
25053 Return true if @var{obj} is a service extension.
25054 @end deffn
25055
25056 Occasionally, you might want to simply extend an existing service. This
25057 involves creating a new service type and specifying the extension of
25058 interest, which can be verbose; the @code{simple-service} procedure
25059 provides a shorthand for this.
25060
25061 @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
25062 Return a service that extends @var{target} with @var{value}. This works
25063 by creating a singleton service type @var{name}, of which the returned
25064 service is an instance.
25065
25066 For example, this extends mcron (@pxref{Scheduled Job Execution}) with
25067 an additional job:
25068
25069 @example
25070 (simple-service 'my-mcron-job mcron-service-type
25071 #~(job '(next-hour (3)) "guix gc -F 2G"))
25072 @end example
25073 @end deffn
25074
25075 At the core of the service abstraction lies the @code{fold-services}
25076 procedure, which is responsible for ``compiling'' a list of services
25077 down to a single directory that contains everything needed to boot and
25078 run the system---the directory shown by the @command{guix system build}
25079 command (@pxref{Invoking guix system}). In essence, it propagates
25080 service extensions down the service graph, updating each node parameters
25081 on the way, until it reaches the root node.
25082
25083 @deffn {Scheme Procedure} fold-services @var{services} @
25084 [#:target-type @var{system-service-type}]
25085 Fold @var{services} by propagating their extensions down to the root of
25086 type @var{target-type}; return the root service adjusted accordingly.
25087 @end deffn
25088
25089 Lastly, the @code{(gnu services)} module also defines several essential
25090 service types, some of which are listed below.
25091
25092 @defvr {Scheme Variable} system-service-type
25093 This is the root of the service graph. It produces the system directory
25094 as returned by the @command{guix system build} command.
25095 @end defvr
25096
25097 @defvr {Scheme Variable} boot-service-type
25098 The type of the ``boot service'', which produces the @dfn{boot script}.
25099 The boot script is what the initial RAM disk runs when booting.
25100 @end defvr
25101
25102 @defvr {Scheme Variable} etc-service-type
25103 The type of the @file{/etc} service. This service is used to create
25104 files under @file{/etc} and can be extended by
25105 passing it name/file tuples such as:
25106
25107 @example
25108 (list `("issue" ,(plain-file "issue" "Welcome!\n")))
25109 @end example
25110
25111 In this example, the effect would be to add an @file{/etc/issue} file
25112 pointing to the given file.
25113 @end defvr
25114
25115 @defvr {Scheme Variable} setuid-program-service-type
25116 Type for the ``setuid-program service''. This service collects lists of
25117 executable file names, passed as gexps, and adds them to the set of
25118 setuid-root programs on the system (@pxref{Setuid Programs}).
25119 @end defvr
25120
25121 @defvr {Scheme Variable} profile-service-type
25122 Type of the service that populates the @dfn{system profile}---i.e., the
25123 programs under @file{/run/current-system/profile}. Other services can
25124 extend it by passing it lists of packages to add to the system profile.
25125 @end defvr
25126
25127
25128 @node Shepherd Services
25129 @subsection Shepherd Services
25130
25131 @cindex shepherd services
25132 @cindex PID 1
25133 @cindex init system
25134 The @code{(gnu services shepherd)} module provides a way to define
25135 services managed by the GNU@tie{}Shepherd, which is the
25136 initialization system---the first process that is started when the
25137 system boots, also known as PID@tie{}1
25138 (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
25139
25140 Services in the Shepherd can depend on each other. For instance, the
25141 SSH daemon may need to be started after the syslog daemon has been
25142 started, which in turn can only happen once all the file systems have
25143 been mounted. The simple operating system defined earlier (@pxref{Using
25144 the Configuration System}) results in a service graph like this:
25145
25146 @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
25147
25148 You can actually generate such a graph for any operating system
25149 definition using the @command{guix system shepherd-graph} command
25150 (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
25151
25152 The @code{%shepherd-root-service} is a service object representing
25153 PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
25154 by passing it lists of @code{<shepherd-service>} objects.
25155
25156 @deftp {Data Type} shepherd-service
25157 The data type representing a service managed by the Shepherd.
25158
25159 @table @asis
25160 @item @code{provision}
25161 This is a list of symbols denoting what the service provides.
25162
25163 These are the names that may be passed to @command{herd start},
25164 @command{herd status}, and similar commands (@pxref{Invoking herd,,,
25165 shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
25166 @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
25167
25168 @item @code{requirements} (default: @code{'()})
25169 List of symbols denoting the Shepherd services this one depends on.
25170
25171 @cindex one-shot services, for the Shepherd
25172 @item @code{one-shot?} (default: @code{#f})
25173 Whether this service is @dfn{one-shot}. One-shot services stop immediately
25174 after their @code{start} action has completed. @xref{Slots of services,,,
25175 shepherd, The GNU Shepherd Manual}, for more info.
25176
25177 @item @code{respawn?} (default: @code{#t})
25178 Whether to restart the service when it stops, for instance when the
25179 underlying process dies.
25180
25181 @item @code{start}
25182 @itemx @code{stop} (default: @code{#~(const #f)})
25183 The @code{start} and @code{stop} fields refer to the Shepherd's
25184 facilities to start and stop processes (@pxref{Service De- and
25185 Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
25186 G-expressions that get expanded in the Shepherd configuration file
25187 (@pxref{G-Expressions}).
25188
25189 @item @code{actions} (default: @code{'()})
25190 @cindex actions, of Shepherd services
25191 This is a list of @code{shepherd-action} objects (see below) defining
25192 @dfn{actions} supported by the service, in addition to the standard
25193 @code{start} and @code{stop} actions. Actions listed here become available as
25194 @command{herd} sub-commands:
25195
25196 @example
25197 herd @var{action} @var{service} [@var{arguments}@dots{}]
25198 @end example
25199
25200 @item @code{documentation}
25201 A documentation string, as shown when running:
25202
25203 @example
25204 herd doc @var{service-name}
25205 @end example
25206
25207 where @var{service-name} is one of the symbols in @code{provision}
25208 (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
25209
25210 @item @code{modules} (default: @code{%default-modules})
25211 This is the list of modules that must be in scope when @code{start} and
25212 @code{stop} are evaluated.
25213
25214 @end table
25215 @end deftp
25216
25217 @deftp {Data Type} shepherd-action
25218 This is the data type that defines additional actions implemented by a
25219 Shepherd service (see above).
25220
25221 @table @code
25222 @item name
25223 Symbol naming the action.
25224
25225 @item documentation
25226 This is a documentation string for the action. It can be viewed by running:
25227
25228 @example
25229 herd doc @var{service} action @var{action}
25230 @end example
25231
25232 @item procedure
25233 This should be a gexp that evaluates to a procedure of at least one argument,
25234 which is the ``running value'' of the service (@pxref{Slots of services,,,
25235 shepherd, The GNU Shepherd Manual}).
25236 @end table
25237
25238 The following example defines an action called @code{say-hello} that kindly
25239 greets the user:
25240
25241 @example
25242 (shepherd-action
25243 (name 'say-hello)
25244 (documentation "Say hi!")
25245 (procedure #~(lambda (running . args)
25246 (format #t "Hello, friend! arguments: ~s\n"
25247 args)
25248 #t)))
25249 @end example
25250
25251 Assuming this action is added to the @code{example} service, then you can do:
25252
25253 @example
25254 # herd say-hello example
25255 Hello, friend! arguments: ()
25256 # herd say-hello example a b c
25257 Hello, friend! arguments: ("a" "b" "c")
25258 @end example
25259
25260 This, as you can see, is a fairly sophisticated way to say hello.
25261 @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
25262 info on actions.
25263 @end deftp
25264
25265 @defvr {Scheme Variable} shepherd-root-service-type
25266 The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
25267
25268 This is the service type that extensions target when they want to create
25269 shepherd services (@pxref{Service Types and Services}, for an example).
25270 Each extension must pass a list of @code{<shepherd-service>}.
25271 @end defvr
25272
25273 @defvr {Scheme Variable} %shepherd-root-service
25274 This service represents PID@tie{}1.
25275 @end defvr
25276
25277
25278 @node Documentation
25279 @chapter Documentation
25280
25281 @cindex documentation, searching for
25282 @cindex searching for documentation
25283 @cindex Info, documentation format
25284 @cindex man pages
25285 @cindex manual pages
25286 In most cases packages installed with Guix come with documentation.
25287 There are two main documentation formats: ``Info'', a browseable
25288 hypertext format used for GNU software, and ``manual pages'' (or ``man
25289 pages''), the linear documentation format traditionally found on Unix.
25290 Info manuals are accessed with the @command{info} command or with Emacs,
25291 and man pages are accessed using @command{man}.
25292
25293 You can look for documentation of software installed on your system by
25294 keyword. For example, the following command searches for information
25295 about ``TLS'' in Info manuals:
25296
25297 @example
25298 $ info -k TLS
25299 "(emacs)Network Security" -- STARTTLS
25300 "(emacs)Network Security" -- TLS
25301 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
25302 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
25303 @dots{}
25304 @end example
25305
25306 @noindent
25307 The command below searches for the same keyword in man pages:
25308
25309 @example
25310 $ man -k TLS
25311 SSL (7) - OpenSSL SSL/TLS library
25312 certtool (1) - GnuTLS certificate tool
25313 @dots {}
25314 @end example
25315
25316 These searches are purely local to your computer so you have the
25317 guarantee that documentation you find corresponds to what you have
25318 actually installed, you can access it off-line, and your privacy is
25319 respected.
25320
25321 Once you have these results, you can view the relevant documentation by
25322 running, say:
25323
25324 @example
25325 $ info "(gnutls)Core TLS API"
25326 @end example
25327
25328 @noindent
25329 or:
25330
25331 @example
25332 $ man certtool
25333 @end example
25334
25335 Info manuals contain sections and indices as well as hyperlinks like
25336 those found in Web pages. The @command{info} reader (@pxref{Top, Info
25337 reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
25338 (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
25339 bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
25340 Introduction}, for an introduction to Info navigation.
25341
25342 @node Installing Debugging Files
25343 @chapter Installing Debugging Files
25344
25345 @cindex debugging files
25346 Program binaries, as produced by the GCC compilers for instance, are
25347 typically written in the ELF format, with a section containing
25348 @dfn{debugging information}. Debugging information is what allows the
25349 debugger, GDB, to map binary code to source code; it is required to
25350 debug a compiled program in good conditions.
25351
25352 The problem with debugging information is that is takes up a fair amount
25353 of disk space. For example, debugging information for the GNU C Library
25354 weighs in at more than 60 MiB. Thus, as a user, keeping all the
25355 debugging info of all the installed programs is usually not an option.
25356 Yet, space savings should not come at the cost of an impediment to
25357 debugging---especially in the GNU system, which should make it easier
25358 for users to exert their computing freedom (@pxref{GNU Distribution}).
25359
25360 Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
25361 mechanism that allows users to get the best of both worlds: debugging
25362 information can be stripped from the binaries and stored in separate
25363 files. GDB is then able to load debugging information from those files,
25364 when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
25365 with GDB}).
25366
25367 The GNU distribution takes advantage of this by storing debugging
25368 information in the @code{lib/debug} sub-directory of a separate package
25369 output unimaginatively called @code{debug} (@pxref{Packages with
25370 Multiple Outputs}). Users can choose to install the @code{debug} output
25371 of a package when they need it. For instance, the following command
25372 installs the debugging information for the GNU C Library and for GNU
25373 Guile:
25374
25375 @example
25376 guix package -i glibc:debug guile:debug
25377 @end example
25378
25379 GDB must then be told to look for debug files in the user's profile, by
25380 setting the @code{debug-file-directory} variable (consider setting it
25381 from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
25382 GDB}):
25383
25384 @example
25385 (gdb) set debug-file-directory ~/.guix-profile/lib/debug
25386 @end example
25387
25388 From there on, GDB will pick up debugging information from the
25389 @code{.debug} files under @file{~/.guix-profile/lib/debug}.
25390
25391 In addition, you will most likely want GDB to be able to show the source
25392 code being debugged. To do that, you will have to unpack the source
25393 code of the package of interest (obtained with @code{guix build
25394 --source}, @pxref{Invoking guix build}), and to point GDB to that source
25395 directory using the @code{directory} command (@pxref{Source Path,
25396 @code{directory},, gdb, Debugging with GDB}).
25397
25398 @c XXX: keep me up-to-date
25399 The @code{debug} output mechanism in Guix is implemented by the
25400 @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
25401 opt-in---debugging information is available only for the packages
25402 with definitions explicitly declaring a @code{debug} output. This may be
25403 changed to opt-out in the future if our build farm servers can handle
25404 the load. To check whether a package has a @code{debug} output, use
25405 @command{guix package --list-available} (@pxref{Invoking guix package}).
25406
25407
25408 @node Security Updates
25409 @chapter Security Updates
25410
25411 @cindex security updates
25412 @cindex security vulnerabilities
25413 Occasionally, important security vulnerabilities are discovered in software
25414 packages and must be patched. Guix developers try hard to keep track of
25415 known vulnerabilities and to apply fixes as soon as possible in the
25416 @code{master} branch of Guix (we do not yet provide a ``stable'' branch
25417 containing only security updates.) The @command{guix lint} tool helps
25418 developers find out about vulnerable versions of software packages in the
25419 distribution:
25420
25421 @smallexample
25422 $ guix lint -c cve
25423 gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
25424 gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
25425 gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
25426 @dots{}
25427 @end smallexample
25428
25429 @xref{Invoking guix lint}, for more information.
25430
25431 @quotation Note
25432 As of version @value{VERSION}, the feature described below is considered
25433 ``beta''.
25434 @end quotation
25435
25436 Guix follows a functional
25437 package management discipline (@pxref{Introduction}), which implies
25438 that, when a package is changed, @emph{every package that depends on it}
25439 must be rebuilt. This can significantly slow down the deployment of
25440 fixes in core packages such as libc or Bash, since basically the whole
25441 distribution would need to be rebuilt. Using pre-built binaries helps
25442 (@pxref{Substitutes}), but deployment may still take more time than
25443 desired.
25444
25445 @cindex grafts
25446 To address this, Guix implements @dfn{grafts}, a mechanism that allows
25447 for fast deployment of critical updates without the costs associated
25448 with a whole-distribution rebuild. The idea is to rebuild only the
25449 package that needs to be patched, and then to ``graft'' it onto packages
25450 explicitly installed by the user and that were previously referring to
25451 the original package. The cost of grafting is typically very low, and
25452 order of magnitudes lower than a full rebuild of the dependency chain.
25453
25454 @cindex replacements of packages, for grafts
25455 For instance, suppose a security update needs to be applied to Bash.
25456 Guix developers will provide a package definition for the ``fixed''
25457 Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
25458 Packages}). Then, the original package definition is augmented with a
25459 @code{replacement} field pointing to the package containing the bug fix:
25460
25461 @example
25462 (define bash
25463 (package
25464 (name "bash")
25465 ;; @dots{}
25466 (replacement bash-fixed)))
25467 @end example
25468
25469 From there on, any package depending directly or indirectly on Bash---as
25470 reported by @command{guix gc --requisites} (@pxref{Invoking guix
25471 gc})---that is installed is automatically ``rewritten'' to refer to
25472 @code{bash-fixed} instead of @code{bash}. This grafting process takes
25473 time proportional to the size of the package, usually less than a
25474 minute for an ``average'' package on a recent machine. Grafting is
25475 recursive: when an indirect dependency requires grafting, then grafting
25476 ``propagates'' up to the package that the user is installing.
25477
25478 Currently, the length of the name and version of the graft and that of
25479 the package it replaces (@code{bash-fixed} and @code{bash} in the example
25480 above) must be equal. This restriction mostly comes from the fact that
25481 grafting works by patching files, including binary files, directly.
25482 Other restrictions may apply: for instance, when adding a graft to a
25483 package providing a shared library, the original shared library and its
25484 replacement must have the same @code{SONAME} and be binary-compatible.
25485
25486 The @option{--no-grafts} command-line option allows you to forcefully
25487 avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
25488 Thus, the command:
25489
25490 @example
25491 guix build bash --no-grafts
25492 @end example
25493
25494 @noindent
25495 returns the store file name of the original Bash, whereas:
25496
25497 @example
25498 guix build bash
25499 @end example
25500
25501 @noindent
25502 returns the store file name of the ``fixed'', replacement Bash. This
25503 allows you to distinguish between the two variants of Bash.
25504
25505 To verify which Bash your whole profile refers to, you can run
25506 (@pxref{Invoking guix gc}):
25507
25508 @example
25509 guix gc -R `readlink -f ~/.guix-profile` | grep bash
25510 @end example
25511
25512 @noindent
25513 @dots{} and compare the store file names that you get with those above.
25514 Likewise for a complete Guix system generation:
25515
25516 @example
25517 guix gc -R `guix system build my-config.scm` | grep bash
25518 @end example
25519
25520 Lastly, to check which Bash running processes are using, you can use the
25521 @command{lsof} command:
25522
25523 @example
25524 lsof | grep /gnu/store/.*bash
25525 @end example
25526
25527
25528 @node Bootstrapping
25529 @chapter Bootstrapping
25530
25531 @c Adapted from the ELS 2013 paper.
25532
25533 @cindex bootstrapping
25534
25535 Bootstrapping in our context refers to how the distribution gets built
25536 ``from nothing''. Remember that the build environment of a derivation
25537 contains nothing but its declared inputs (@pxref{Introduction}). So
25538 there's an obvious chicken-and-egg problem: how does the first package
25539 get built? How does the first compiler get compiled? Note that this is
25540 a question of interest only to the curious hacker, not to the regular
25541 user, so you can shamelessly skip this section if you consider yourself
25542 a ``regular user''.
25543
25544 @cindex bootstrap binaries
25545 The GNU system is primarily made of C code, with libc at its core. The
25546 GNU build system itself assumes the availability of a Bourne shell and
25547 command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
25548 `grep'. Furthermore, build programs---programs that run
25549 @code{./configure}, @code{make}, etc.---are written in Guile Scheme
25550 (@pxref{Derivations}). Consequently, to be able to build anything at
25551 all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
25552 Binutils, libc, and the other packages mentioned above---the
25553 @dfn{bootstrap binaries}.
25554
25555 These bootstrap binaries are ``taken for granted'', though we can also
25556 re-create them if needed (more on that later).
25557
25558 @unnumberedsec Preparing to Use the Bootstrap Binaries
25559
25560 @c As of Emacs 24.3, Info-mode displays the image, but since it's a
25561 @c large image, it's hard to scroll. Oh well.
25562 @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
25563
25564 The figure above shows the very beginning of the dependency graph of the
25565 distribution, corresponding to the package definitions of the @code{(gnu
25566 packages bootstrap)} module. A similar figure can be generated with
25567 @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
25568
25569 @example
25570 guix graph -t derivation \
25571 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
25572 | dot -Tps > t.ps
25573 @end example
25574
25575 At this level of detail, things are
25576 slightly complex. First, Guile itself consists of an ELF executable,
25577 along with many source and compiled Scheme files that are dynamically
25578 loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
25579 tarball shown in this graph. This tarball is part of Guix's ``source''
25580 distribution, and gets inserted into the store with @code{add-to-store}
25581 (@pxref{The Store}).
25582
25583 But how do we write a derivation that unpacks this tarball and adds it
25584 to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
25585 derivation---the first one that gets built---uses @code{bash} as its
25586 builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
25587 @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
25588 @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
25589 the Guix source distribution, whose sole purpose is to allow the Guile
25590 tarball to be unpacked.
25591
25592 Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
25593 Guile that can be used to run subsequent build programs. Its first task
25594 is to download tarballs containing the other pre-built binaries---this
25595 is what the @code{.tar.xz.drv} derivations do. Guix modules such as
25596 @code{ftp-client.scm} are used for this purpose. The
25597 @code{module-import.drv} derivations import those modules in a directory
25598 in the store, using the original layout. The
25599 @code{module-import-compiled.drv} derivations compile those modules, and
25600 write them in an output directory with the right layout. This
25601 corresponds to the @code{#:modules} argument of
25602 @code{build-expression->derivation} (@pxref{Derivations}).
25603
25604 Finally, the various tarballs are unpacked by the
25605 derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
25606 etc., at which point we have a working C tool chain.
25607
25608
25609 @unnumberedsec Building the Build Tools
25610
25611 Bootstrapping is complete when we have a full tool chain that does not
25612 depend on the pre-built bootstrap tools discussed above. This
25613 no-dependency requirement is verified by checking whether the files of
25614 the final tool chain contain references to the @file{/gnu/store}
25615 directories of the bootstrap inputs. The process that leads to this
25616 ``final'' tool chain is described by the package definitions found in
25617 the @code{(gnu packages commencement)} module.
25618
25619 The @command{guix graph} command allows us to ``zoom out'' compared to
25620 the graph above, by looking at the level of package objects instead of
25621 individual derivations---remember that a package may translate to
25622 several derivations, typically one derivation to download its source,
25623 one to build the Guile modules it needs, and one to actually build the
25624 package from source. The command:
25625
25626 @example
25627 guix graph -t bag \
25628 -e '(@@@@ (gnu packages commencement)
25629 glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
25630 @end example
25631
25632 @noindent
25633 produces the dependency graph leading to the ``final'' C
25634 library@footnote{You may notice the @code{glibc-intermediate} label,
25635 suggesting that it is not @emph{quite} final, but as a good
25636 approximation, we will consider it final.}, depicted below.
25637
25638 @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
25639
25640 @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
25641 The first tool that gets built with the bootstrap binaries is
25642 GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
25643 for all the following packages. From there Findutils and Diffutils get
25644 built.
25645
25646 Then come the first-stage Binutils and GCC, built as pseudo cross
25647 tools---i.e., with @code{--target} equal to @code{--host}. They are
25648 used to build libc. Thanks to this cross-build trick, this libc is
25649 guaranteed not to hold any reference to the initial tool chain.
25650
25651 From there the final Binutils and GCC (not shown above) are built.
25652 GCC uses @code{ld}
25653 from the final Binutils, and links programs against the just-built libc.
25654 This tool chain is used to build the other packages used by Guix and by
25655 the GNU Build System: Guile, Bash, Coreutils, etc.
25656
25657 And voilà! At this point we have the complete set of build tools that
25658 the GNU Build System expects. These are in the @code{%final-inputs}
25659 variable of the @code{(gnu packages commencement)} module, and are
25660 implicitly used by any package that uses @code{gnu-build-system}
25661 (@pxref{Build Systems, @code{gnu-build-system}}).
25662
25663
25664 @unnumberedsec Building the Bootstrap Binaries
25665
25666 @cindex bootstrap binaries
25667 Because the final tool chain does not depend on the bootstrap binaries,
25668 those rarely need to be updated. Nevertheless, it is useful to have an
25669 automated way to produce them, should an update occur, and this is what
25670 the @code{(gnu packages make-bootstrap)} module provides.
25671
25672 The following command builds the tarballs containing the bootstrap
25673 binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
25674 of Coreutils and other basic command-line tools):
25675
25676 @example
25677 guix build bootstrap-tarballs
25678 @end example
25679
25680 The generated tarballs are those that should be referred to in the
25681 @code{(gnu packages bootstrap)} module mentioned at the beginning of
25682 this section.
25683
25684 Still here? Then perhaps by now you've started to wonder: when do we
25685 reach a fixed point? That is an interesting question! The answer is
25686 unknown, but if you would like to investigate further (and have
25687 significant computational and storage resources to do so), then let us
25688 know.
25689
25690 @unnumberedsec Reducing the Set of Bootstrap Binaries
25691
25692 Our bootstrap binaries currently include GCC, Guile, etc. That's a lot
25693 of binary code! Why is that a problem? It's a problem because these
25694 big chunks of binary code are practically non-auditable, which makes it
25695 hard to establish what source code produced them. Every unauditable
25696 binary also leaves us vulnerable to compiler backdoors as described by
25697 Ken Thompson in the 1984 paper @emph{Reflections on Trusting Trust}.
25698
25699 This is mitigated by the fact that our bootstrap binaries were generated
25700 from an earlier Guix revision. Nevertheless it lacks the level of
25701 transparency that we get in the rest of the package dependency graph,
25702 where Guix always gives us a source-to-binary mapping. Thus, our goal
25703 is to reduce the set of bootstrap binaries to the bare minimum.
25704
25705 The @uref{http://bootstrappable.org, Bootstrappable.org web site} lists
25706 on-going projects to do that. One of these is about replacing the
25707 bootstrap GCC with a sequence of assemblers, interpreters, and compilers
25708 of increasing complexity, which could be built from source starting from
25709 a simple and auditable assembler. Your help is welcome!
25710
25711
25712 @node Porting
25713 @chapter Porting to a New Platform
25714
25715 As discussed above, the GNU distribution is self-contained, and
25716 self-containment is achieved by relying on pre-built ``bootstrap
25717 binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
25718 operating system kernel, CPU architecture, and application binary
25719 interface (ABI). Thus, to port the distribution to a platform that is
25720 not yet supported, one must build those bootstrap binaries, and update
25721 the @code{(gnu packages bootstrap)} module to use them on that platform.
25722
25723 Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
25724 When everything goes well, and assuming the GNU tool chain supports the
25725 target platform, this can be as simple as running a command like this
25726 one:
25727
25728 @example
25729 guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
25730 @end example
25731
25732 For this to work, the @code{glibc-dynamic-linker} procedure in
25733 @code{(gnu packages bootstrap)} must be augmented to return the right
25734 file name for libc's dynamic linker on that platform; likewise,
25735 @code{system->linux-architecture} in @code{(gnu packages linux)} must be
25736 taught about the new platform.
25737
25738 Once these are built, the @code{(gnu packages bootstrap)} module needs
25739 to be updated to refer to these binaries on the target platform. That
25740 is, the hashes and URLs of the bootstrap tarballs for the new platform
25741 must be added alongside those of the currently supported platforms. The
25742 bootstrap Guile tarball is treated specially: it is expected to be
25743 available locally, and @file{gnu/local.mk} has rules to download it for
25744 the supported architectures; a rule for the new platform must be added
25745 as well.
25746
25747 In practice, there may be some complications. First, it may be that the
25748 extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
25749 above) is not recognized by all the GNU tools. Typically, glibc
25750 recognizes some of these, whereas GCC uses an extra @code{--with-abi}
25751 configure flag (see @code{gcc.scm} for examples of how to handle this).
25752 Second, some of the required packages could fail to build for that
25753 platform. Lastly, the generated binaries could be broken for some
25754 reason.
25755
25756 @c *********************************************************************
25757 @include contributing.texi
25758
25759 @c *********************************************************************
25760 @node Acknowledgments
25761 @chapter Acknowledgments
25762
25763 Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
25764 which was designed and
25765 implemented by Eelco Dolstra, with contributions from other people (see
25766 the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
25767 management, and promoted unprecedented features, such as transactional
25768 package upgrades and rollbacks, per-user profiles, and referentially
25769 transparent build processes. Without this work, Guix would not exist.
25770
25771 The Nix-based software distributions, Nixpkgs and NixOS, have also been
25772 an inspiration for Guix.
25773
25774 GNU@tie{}Guix itself is a collective work with contributions from a
25775 number of people. See the @file{AUTHORS} file in Guix for more
25776 information on these fine people. The @file{THANKS} file lists people
25777 who have helped by reporting bugs, taking care of the infrastructure,
25778 providing artwork and themes, making suggestions, and more---thank you!
25779
25780
25781 @c *********************************************************************
25782 @node GNU Free Documentation License
25783 @appendix GNU Free Documentation License
25784 @cindex license, GNU Free Documentation License
25785 @include fdl-1.3.texi
25786
25787 @c *********************************************************************
25788 @node Concept Index
25789 @unnumbered Concept Index
25790 @printindex cp
25791
25792 @node Programming Index
25793 @unnumbered Programming Index
25794 @syncodeindex tp fn
25795 @syncodeindex vr fn
25796 @printindex fn
25797
25798 @bye
25799
25800 @c Local Variables:
25801 @c ispell-local-dictionary: "american";
25802 @c End: