doc: Suggest 1G of RAM for the VM image.
[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 Base URL for downloads.
17 @set BASE-URL https://ftp.gnu.org/gnu/guix
18
19 @c The official substitute server used by default.
20 @set SUBSTITUTE-SERVER ci.guix.info
21
22 @copying
23 Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès@*
24 Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
25 Copyright @copyright{} 2013 Nikita Karetnikov@*
26 Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
27 Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
28 Copyright @copyright{} 2014 Pierre-Antoine Rault@*
29 Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
30 Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
31 Copyright @copyright{} 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus@*
32 Copyright @copyright{} 2016 Ben Woodcroft@*
33 Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
34 Copyright @copyright{} 2016, 2017, 2018, 2019 Efraim Flashner@*
35 Copyright @copyright{} 2016 John Darrington@*
36 Copyright @copyright{} 2016, 2017 ng0@*
37 Copyright @copyright{} 2016, 2017, 2018, 2019 Jan Nieuwenhuizen@*
38 Copyright @copyright{} 2016 Julien Lepiller@*
39 Copyright @copyright{} 2016 Alex ter Weele@*
40 Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@*
41 Copyright @copyright{} 2017, 2018 Clément Lassieur@*
42 Copyright @copyright{} 2017, 2018 Mathieu Othacehe@*
43 Copyright @copyright{} 2017 Federico Beffa@*
44 Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
45 Copyright @copyright{} 2017 Thomas Danckaert@*
46 Copyright @copyright{} 2017 humanitiesNerd@*
47 Copyright @copyright{} 2017 Christopher Allan Webber@*
48 Copyright @copyright{} 2017, 2018 Marius Bakke@*
49 Copyright @copyright{} 2017 Hartmut Goebel@*
50 Copyright @copyright{} 2017 Maxim Cournoyer@*
51 Copyright @copyright{} 2017, 2018 Tobias Geerinckx-Rice@*
52 Copyright @copyright{} 2017 George Clemmer@*
53 Copyright @copyright{} 2017 Andy Wingo@*
54 Copyright @copyright{} 2017, 2018, 2019 Arun Isaac@*
55 Copyright @copyright{} 2017 nee@*
56 Copyright @copyright{} 2018 Rutger Helling@*
57 Copyright @copyright{} 2018 Oleg Pykhalov@*
58 Copyright @copyright{} 2018 Mike Gerwitz@*
59 Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
60 Copyright @copyright{} 2018 Gábor Boskovits@*
61 Copyright @copyright{} 2018 Florian Pelz@*
62 Copyright @copyright{} 2018 Laura Lazzati@*
63 Copyright @copyright{} 2018 Alex Vong@*
64
65 Permission is granted to copy, distribute and/or modify this document
66 under the terms of the GNU Free Documentation License, Version 1.3 or
67 any later version published by the Free Software Foundation; with no
68 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
69 copy of the license is included in the section entitled ``GNU Free
70 Documentation License''.
71 @end copying
72
73 @dircategory System administration
74 @direntry
75 * Guix: (guix). Manage installed software and system configuration.
76 * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
77 * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
78 * guix pull: (guix)Invoking guix pull. Update the list of available packages.
79 * guix system: (guix)Invoking guix system. Manage the operating system configuration.
80 @end direntry
81
82 @dircategory Software development
83 @direntry
84 * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
85 * guix build: (guix)Invoking guix build. Building packages.
86 * guix pack: (guix)Invoking guix pack. Creating binary bundles.
87 @end direntry
88
89 @titlepage
90 @title GNU Guix Reference Manual
91 @subtitle Using the GNU Guix Functional Package Manager
92 @author The GNU Guix Developers
93
94 @page
95 @vskip 0pt plus 1filll
96 Edition @value{EDITION} @*
97 @value{UPDATED} @*
98
99 @insertcopying
100 @end titlepage
101
102 @contents
103
104 @c *********************************************************************
105 @node Top
106 @top GNU Guix
107
108 This document describes GNU Guix version @value{VERSION}, a functional
109 package management tool written for the GNU system.
110
111 @c TRANSLATORS: You can replace the following paragraph with information on
112 @c how to join your own translation team and how to report issues with the
113 @c translation.
114 This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
115 GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
116 Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}), and
117 Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}). If you
118 would like to translate it in your native language, consider joining the
119 @uref{https://translationproject.org/domain/guix-manual.html, Translation
120 Project}.
121
122 @menu
123 * Introduction:: What is Guix about?
124 * Installation:: Installing Guix.
125 * System Installation:: Installing the whole operating system.
126 * Package Management:: Package installation, upgrade, etc.
127 * Development:: Guix-aided software development.
128 * Programming Interface:: Using Guix in Scheme.
129 * Utilities:: Package management commands.
130 * System Configuration:: Configuring the operating system.
131 * Documentation:: Browsing software user manuals.
132 * Installing Debugging Files:: Feeding the debugger.
133 * Security Updates:: Deploying security fixes quickly.
134 * Bootstrapping:: GNU/Linux built from scratch.
135 * Porting:: Targeting another platform or kernel.
136 * Contributing:: Your help needed!
137
138 * Acknowledgments:: Thanks!
139 * GNU Free Documentation License:: The license of this manual.
140 * Concept Index:: Concepts.
141 * Programming Index:: Data types, functions, and variables.
142
143 @detailmenu
144 --- The Detailed Node Listing ---
145
146 Introduction
147
148 * Managing Software the Guix Way:: What's special.
149 * GNU Distribution:: The packages and tools.
150
151 Installation
152
153 * Binary Installation:: Getting Guix running in no time!
154 * Requirements:: Software needed to build and run Guix.
155 * Running the Test Suite:: Testing Guix.
156 * Setting Up the Daemon:: Preparing the build daemon's environment.
157 * Invoking guix-daemon:: Running the build daemon.
158 * Application Setup:: Application-specific setup.
159
160 Setting Up the Daemon
161
162 * Build Environment Setup:: Preparing the isolated build environment.
163 * Daemon Offload Setup:: Offloading builds to remote machines.
164 * SELinux Support:: Using an SELinux policy for the daemon.
165
166 System Installation
167
168 * Limitations:: What you can expect.
169 * Hardware Considerations:: Supported hardware.
170 * USB Stick and DVD Installation:: Preparing the installation medium.
171 * Preparing for Installation:: Networking, partitioning, etc.
172 * Guided Graphical Installation:: Easy graphical installation.
173 * Manual Installation:: Manual installation for wizards.
174 * After System Installation:: When installation succeeded.
175 * Installing Guix in a VM:: Guix System playground.
176 * Building the Installation Image:: How this comes to be.
177
178 Manual Installation
179
180 * Keyboard Layout and Networking and Partitioning:: Initial setup.
181 * Proceeding with the Installation:: Installing.
182
183 Package Management
184
185 * Features:: How Guix will make your life brighter.
186 * Invoking guix package:: Package installation, removal, etc.
187 * Substitutes:: Downloading pre-built binaries.
188 * Packages with Multiple Outputs:: Single source package, multiple outputs.
189 * Invoking guix gc:: Running the garbage collector.
190 * Invoking guix pull:: Fetching the latest Guix and distribution.
191 * Channels:: Customizing the package collection.
192 * Inferiors:: Interacting with another revision of Guix.
193 * Invoking guix describe:: Display information about your Guix revision.
194 * Invoking guix archive:: Exporting and importing store files.
195
196 Substitutes
197
198 * Official Substitute Server:: One particular source of substitutes.
199 * Substitute Server Authorization:: How to enable or disable substitutes.
200 * Substitute Authentication:: How Guix verifies substitutes.
201 * Proxy Settings:: How to get substitutes via proxy.
202 * Substitution Failure:: What happens when substitution fails.
203 * On Trusting Binaries:: How can you trust that binary blob?
204
205 Development
206
207 * Invoking guix environment:: Setting up development environments.
208 * Invoking guix pack:: Creating software bundles.
209
210 Programming Interface
211
212 * Package Modules:: Packages from the programmer's viewpoint.
213 * Defining Packages:: Defining new packages.
214 * Build Systems:: Specifying how packages are built.
215 * The Store:: Manipulating the package store.
216 * Derivations:: Low-level interface to package derivations.
217 * The Store Monad:: Purely functional interface to the store.
218 * G-Expressions:: Manipulating build expressions.
219 * Invoking guix repl:: Fiddling with Guix interactively.
220
221 Defining Packages
222
223 * package Reference:: The package data type.
224 * origin Reference:: The origin data type.
225
226 Utilities
227
228 * Invoking guix build:: Building packages from the command line.
229 * Invoking guix edit:: Editing package definitions.
230 * Invoking guix download:: Downloading a file and printing its hash.
231 * Invoking guix hash:: Computing the cryptographic hash of a file.
232 * Invoking guix import:: Importing package definitions.
233 * Invoking guix refresh:: Updating package definitions.
234 * Invoking guix lint:: Finding errors in package definitions.
235 * Invoking guix size:: Profiling disk usage.
236 * Invoking guix graph:: Visualizing the graph of packages.
237 * Invoking guix publish:: Sharing substitutes.
238 * Invoking guix challenge:: Challenging substitute servers.
239 * Invoking guix copy:: Copying to and from a remote store.
240 * Invoking guix container:: Process isolation.
241 * Invoking guix weather:: Assessing substitute availability.
242 * Invoking guix processes:: Listing client processes.
243
244 Invoking @command{guix build}
245
246 * Common Build Options:: Build options for most commands.
247 * Package Transformation Options:: Creating variants of packages.
248 * Additional Build Options:: Options specific to 'guix build'.
249 * Debugging Build Failures:: Real life packaging experience.
250
251 System Configuration
252
253 * Using the Configuration System:: Customizing your GNU system.
254 * operating-system Reference:: Detail of operating-system declarations.
255 * File Systems:: Configuring file system mounts.
256 * Mapped Devices:: Block device extra processing.
257 * User Accounts:: Specifying user accounts.
258 * Keyboard Layout:: How the system interprets key strokes.
259 * Locales:: Language and cultural convention settings.
260 * Services:: Specifying system services.
261 * Setuid Programs:: Programs running with root privileges.
262 * X.509 Certificates:: Authenticating HTTPS servers.
263 * Name Service Switch:: Configuring libc's name service switch.
264 * Initial RAM Disk:: Linux-Libre bootstrapping.
265 * Bootloader Configuration:: Configuring the boot loader.
266 * Invoking guix system:: Instantiating a system configuration.
267 * Running Guix in a VM:: How to run Guix System in a virtual machine.
268 * Defining Services:: Adding new service definitions.
269
270 Services
271
272 * Base Services:: Essential system services.
273 * Scheduled Job Execution:: The mcron service.
274 * Log Rotation:: The rottlog service.
275 * Networking Services:: Network setup, SSH daemon, etc.
276 * X Window:: Graphical display.
277 * Printing Services:: Local and remote printer support.
278 * Desktop Services:: D-Bus and desktop services.
279 * Sound Services:: ALSA and Pulseaudio services.
280 * Database Services:: SQL databases, key-value stores, etc.
281 * Mail Services:: IMAP, POP3, SMTP, and all that.
282 * Messaging Services:: Messaging services.
283 * Telephony Services:: Telephony services.
284 * Monitoring Services:: Monitoring services.
285 * Kerberos Services:: Kerberos services.
286 * Web Services:: Web servers.
287 * Certificate Services:: TLS certificates via Let's Encrypt.
288 * DNS Services:: DNS daemons.
289 * VPN Services:: VPN daemons.
290 * Network File System:: NFS related services.
291 * Continuous Integration:: The Cuirass service.
292 * Power Management Services:: Extending battery life.
293 * Audio Services:: The MPD.
294 * Virtualization Services:: Virtualization services.
295 * Version Control Services:: Providing remote access to Git repositories.
296 * Game Services:: Game servers.
297 * Miscellaneous Services:: Other services.
298
299 Defining Services
300
301 * Service Composition:: The model for composing services.
302 * Service Types and Services:: Types and services.
303 * Service Reference:: API reference.
304 * Shepherd Services:: A particular type of service.
305
306 @end detailmenu
307 @end menu
308
309 @c *********************************************************************
310 @node Introduction
311 @chapter Introduction
312
313 @cindex purpose
314 GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
315 using the international phonetic alphabet (IPA).} is a package
316 management tool for and distribution of the GNU system.
317 Guix makes it easy for unprivileged
318 users to install, upgrade, or remove software packages, to roll back to a
319 previous package set, to build packages from source, and generally
320 assists with the creation and maintenance of software environments.
321
322 @cindex Guix System
323 @cindex GuixSD, now Guix System
324 @cindex Guix System Distribution, now Guix System
325 You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
326 complements the available tools without interference (@pxref{Installation}),
327 or you can use it as a standalone operating system distribution,
328 @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
329 System Distribution'' or ``GuixSD''. We now consider it makes more sense to
330 group everything under the ``Guix'' banner since, after all, Guix System is
331 readily available through the @command{guix system} command, even if you're
332 using a different distro underneath!}. @xref{GNU Distribution}.
333
334 @menu
335 * Managing Software the Guix Way:: What's special.
336 * GNU Distribution:: The packages and tools.
337 @end menu
338
339 @node Managing Software the Guix Way
340 @section Managing Software the Guix Way
341
342 @cindex user interfaces
343 Guix provides a command-line package management interface
344 (@pxref{Package Management}), tools to help with software development
345 (@pxref{Development}), command-line utilities for more advanced usage,
346 (@pxref{Utilities}), as well as Scheme programming interfaces
347 (@pxref{Programming Interface}).
348 @cindex build daemon
349 Its @dfn{build daemon} is responsible for building packages on behalf of
350 users (@pxref{Setting Up the Daemon}) and for downloading pre-built
351 binaries from authorized sources (@pxref{Substitutes}).
352
353 @cindex extensibility of the distribution
354 @cindex customization, of packages
355 Guix includes package definitions for many GNU and non-GNU packages, all
356 of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
357 user's computing freedom}. It is @emph{extensible}: users can write
358 their own package definitions (@pxref{Defining Packages}) and make them
359 available as independent package modules (@pxref{Package Modules}). It
360 is also @emph{customizable}: users can @emph{derive} specialized package
361 definitions from existing ones, including from the command line
362 (@pxref{Package Transformation Options}).
363
364 @cindex functional package management
365 @cindex isolation
366 Under the hood, Guix implements the @dfn{functional package management}
367 discipline pioneered by Nix (@pxref{Acknowledgments}).
368 In Guix, the package build and installation process is seen
369 as a @emph{function}, in the mathematical sense. That function takes inputs,
370 such as build scripts, a compiler, and libraries, and
371 returns an installed package. As a pure function, its result depends
372 solely on its inputs---for instance, it cannot refer to software or
373 scripts that were not explicitly passed as inputs. A build function
374 always produces the same result when passed a given set of inputs. It
375 cannot alter the environment of the running system in
376 any way; for instance, it cannot create, modify, or delete files outside
377 of its build and installation directories. This is achieved by running
378 build processes in isolated environments (or @dfn{containers}), where only their
379 explicit inputs are visible.
380
381 @cindex store
382 The result of package build functions is @dfn{cached} in the file
383 system, in a special directory called @dfn{the store} (@pxref{The
384 Store}). Each package is installed in a directory of its own in the
385 store---by default under @file{/gnu/store}. The directory name contains
386 a hash of all the inputs used to build that package; thus, changing an
387 input yields a different directory name.
388
389 This approach is the foundation for the salient features of Guix: support
390 for transactional package upgrade and rollback, per-user installation, and
391 garbage collection of packages (@pxref{Features}).
392
393
394 @node GNU Distribution
395 @section GNU Distribution
396
397 @cindex Guix System
398 Guix comes with a distribution of the GNU system consisting entirely of
399 free software@footnote{The term ``free'' here refers to the
400 @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
401 users of that software}.}. The
402 distribution can be installed on its own (@pxref{System Installation}),
403 but it is also possible to install Guix as a package manager on top of
404 an installed GNU/Linux system (@pxref{Installation}). When we need to
405 distinguish between the two, we refer to the standalone distribution as
406 Guix@tie{}System.
407
408 The distribution provides core GNU packages such as GNU libc, GCC, and
409 Binutils, as well as many GNU and non-GNU applications. The complete
410 list of available packages can be browsed
411 @url{http://www.gnu.org/software/guix/packages,on-line} or by
412 running @command{guix package} (@pxref{Invoking guix package}):
413
414 @example
415 guix package --list-available
416 @end example
417
418 Our goal is to provide a practical 100% free software distribution of
419 Linux-based and other variants of GNU, with a focus on the promotion and
420 tight integration of GNU components, and an emphasis on programs and
421 tools that help users exert that freedom.
422
423 Packages are currently available on the following platforms:
424
425 @table @code
426
427 @item x86_64-linux
428 Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
429
430 @item i686-linux
431 Intel 32-bit architecture (IA32), Linux-Libre kernel;
432
433 @item armhf-linux
434 ARMv7-A architecture with hard float, Thumb-2 and NEON,
435 using the EABI hard-float application binary interface (ABI),
436 and Linux-Libre kernel.
437
438 @item aarch64-linux
439 little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
440 currently in an experimental stage, with limited support.
441 @xref{Contributing}, for how to help!
442
443 @item mips64el-linux
444 little-endian 64-bit MIPS processors, specifically the Loongson series,
445 n32 ABI, and Linux-Libre kernel.
446
447 @end table
448
449 With Guix@tie{}System, you @emph{declare} all aspects of the operating system
450 configuration and Guix takes care of instantiating the configuration in a
451 transactional, reproducible, and stateless fashion (@pxref{System
452 Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
453 initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
454 Manual}), the well-known GNU utilities and tool chain, as well as the
455 graphical environment or system services of your choice.
456
457 Guix System is available on all the above platforms except
458 @code{mips64el-linux}.
459
460 @noindent
461 For information on porting to other architectures or kernels,
462 @pxref{Porting}.
463
464 Building this distribution is a cooperative effort, and you are invited
465 to join! @xref{Contributing}, for information about how you can help.
466
467
468 @c *********************************************************************
469 @node Installation
470 @chapter Installation
471
472 @cindex installing Guix
473
474 @quotation Note
475 We recommend the use of this
476 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
477 shell installer script} to install Guix on top of a running GNU/Linux system,
478 thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
479 with the installation of the package manager, which can be done on top of a
480 running GNU/Linux system. If, instead, you want to install the complete GNU
481 operating system, @pxref{System Installation}.} The script automates the
482 download, installation, and initial configuration of Guix. It should be run
483 as the root user.
484 @end quotation
485
486 @cindex foreign distro
487 @cindex directories related to foreign distro
488 When installed on a foreign distro, GNU@tie{}Guix complements the available
489 tools without interference. Its data lives exclusively in two directories,
490 usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
491 such as @file{/etc}, are left untouched.
492
493 Once installed, Guix can be updated by running @command{guix pull}
494 (@pxref{Invoking guix pull}).
495
496 If you prefer to perform the installation steps manually or want to tweak
497 them, you may find the following subsections useful. They describe the
498 software requirements of Guix, as well as how to install it manually and get
499 ready to use it.
500
501 @menu
502 * Binary Installation:: Getting Guix running in no time!
503 * Requirements:: Software needed to build and run Guix.
504 * Running the Test Suite:: Testing Guix.
505 * Setting Up the Daemon:: Preparing the build daemon's environment.
506 * Invoking guix-daemon:: Running the build daemon.
507 * Application Setup:: Application-specific setup.
508 @end menu
509
510 @node Binary Installation
511 @section Binary Installation
512
513 @cindex installing Guix from binaries
514 @cindex installer script
515 This section describes how to install Guix on an arbitrary system from a
516 self-contained tarball providing binaries for Guix and for all its
517 dependencies. This is often quicker than installing from source, which
518 is described in the next sections. The only requirement is to have
519 GNU@tie{}tar and Xz.
520
521 Installing goes along these lines:
522
523 @enumerate
524 @item
525 @cindex downloading Guix binary
526 Download the binary tarball from
527 @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.@var{system}.tar.xz},
528 where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
529 already running the kernel Linux, and so on.
530
531 @c The following is somewhat duplicated in ``System Installation''.
532 Make sure to download the associated @file{.sig} file and to verify the
533 authenticity of the tarball against it, along these lines:
534
535 @example
536 $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
537 $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
538 @end example
539
540 If that command fails because you do not have the required public key,
541 then run this command to import it:
542
543 @example
544 $ gpg --keyserver @value{KEY-SERVER} \
545 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
546 @end example
547
548 @noindent
549 and rerun the @code{gpg --verify} command.
550 @c end authentication part
551
552 @item
553 Now, you need to become the @code{root} user. Depending on your distribution,
554 you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
555
556 @example
557 # cd /tmp
558 # tar --warning=no-timestamp -xf \
559 guix-binary-@value{VERSION}.@var{system}.tar.xz
560 # mv var/guix /var/ && mv gnu /
561 @end example
562
563 This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
564 The latter contains a ready-to-use profile for @code{root} (see next
565 step.)
566
567 Do @emph{not} unpack the tarball on a working Guix system since that
568 would overwrite its own essential files.
569
570 The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
571 not emit warnings about ``implausibly old time stamps'' (such
572 warnings were triggered by GNU@tie{}tar 1.26 and older; recent
573 versions are fine.)
574 They stem from the fact that all the
575 files in the archive have their modification time set to zero (which
576 means January 1st, 1970.) This is done on purpose to make sure the
577 archive content is independent of its creation time, thus making it
578 reproducible.
579
580 @item
581 Make the profile available under @file{~root/.config/guix/current}, which is
582 where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
583
584 @example
585 # mkdir -p ~root/.config/guix
586 # ln -sf /var/guix/profiles/per-user/root/current-guix \
587 ~root/.config/guix/current
588 @end example
589
590 Source @file{etc/profile} to augment @code{PATH} and other relevant
591 environment variables:
592
593 @example
594 # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
595 source $GUIX_PROFILE/etc/profile
596 @end example
597
598 @item
599 Create the group and user accounts for build users as explained below
600 (@pxref{Build Environment Setup}).
601
602 @item
603 Run the daemon, and set it to automatically start on boot.
604
605 If your host distro uses the systemd init system, this can be achieved
606 with these commands:
607
608 @c Versions of systemd that supported symlinked service files are not
609 @c yet widely deployed, so we should suggest that users copy the service
610 @c files into place.
611 @c
612 @c See this thread for more information:
613 @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
614
615 @example
616 # cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
617 /etc/systemd/system/
618 # systemctl start guix-daemon && systemctl enable guix-daemon
619 @end example
620
621 If your host distro uses the Upstart init system:
622
623 @example
624 # initctl reload-configuration
625 # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
626 /etc/init/
627 # start guix-daemon
628 @end example
629
630 Otherwise, you can still start the daemon manually with:
631
632 @example
633 # ~root/.config/guix/current/bin/guix-daemon \
634 --build-users-group=guixbuild
635 @end example
636
637 @item
638 Make the @command{guix} command available to other users on the machine,
639 for instance with:
640
641 @example
642 # mkdir -p /usr/local/bin
643 # cd /usr/local/bin
644 # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
645 @end example
646
647 It is also a good idea to make the Info version of this manual available
648 there:
649
650 @example
651 # mkdir -p /usr/local/share/info
652 # cd /usr/local/share/info
653 # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
654 do ln -s $i ; done
655 @end example
656
657 That way, assuming @file{/usr/local/share/info} is in the search path,
658 running @command{info guix} will open this manual (@pxref{Other Info
659 Directories,,, texinfo, GNU Texinfo}, for more details on changing the
660 Info search path.)
661
662 @item
663 @cindex substitutes, authorization thereof
664 To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
665 (@pxref{Substitutes}), authorize them:
666
667 @example
668 # guix archive --authorize < \
669 ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
670 @end example
671
672 @item
673 Each user may need to perform a few additional steps to make their Guix
674 environment ready for use, @pxref{Application Setup}.
675 @end enumerate
676
677 Voilà, the installation is complete!
678
679 You can confirm that Guix is working by installing a sample package into
680 the root profile:
681
682 @example
683 # guix package -i hello
684 @end example
685
686 The @code{guix} package must remain available in @code{root}'s profile,
687 or it would become subject to garbage collection---in which case you
688 would find yourself badly handicapped by the lack of the @command{guix}
689 command. In other words, do not remove @code{guix} by running
690 @code{guix package -r guix}.
691
692 The binary installation tarball can be (re)produced and verified simply
693 by running the following command in the Guix source tree:
694
695 @example
696 make guix-binary.@var{system}.tar.xz
697 @end example
698
699 @noindent
700 ...@: which, in turn, runs:
701
702 @example
703 guix pack -s @var{system} --localstatedir \
704 --profile-name=current-guix guix
705 @end example
706
707 @xref{Invoking guix pack}, for more info on this handy tool.
708
709 @node Requirements
710 @section Requirements
711
712 This section lists requirements when building Guix from source. The
713 build procedure for Guix is the same as for other GNU software, and is
714 not covered here. Please see the files @file{README} and @file{INSTALL}
715 in the Guix source tree for additional details.
716
717 @cindex official website
718 GNU Guix is available for download from its website at
719 @url{https://www.gnu.org/software/guix/}.
720
721 GNU Guix depends on the following packages:
722
723 @itemize
724 @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.2.x;
725 @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
726 0.1.0 or later;
727 @item
728 @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
729 (@pxref{Guile Preparations, how to install the GnuTLS bindings for
730 Guile,, gnutls-guile, GnuTLS-Guile});
731 @item
732 @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
733 or later;
734 @item
735 @c FIXME: Specify a version number once a release has been made.
736 @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
737 2017 or later;
738 @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON};
739 @item @url{http://zlib.net, zlib};
740 @item @url{http://www.gnu.org/software/make/, GNU Make}.
741 @end itemize
742
743 The following dependencies are optional:
744
745 @itemize
746 @item
747 @c Note: We need at least 0.10.2 for 'channel-send-eof'.
748 Support for build offloading (@pxref{Daemon Offload Setup}) and
749 @command{guix copy} (@pxref{Invoking guix copy}) depends on
750 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
751 version 0.10.2 or later.
752
753 @item
754 When @url{http://www.bzip.org, libbz2} is available,
755 @command{guix-daemon} can use it to compress build logs.
756 @end itemize
757
758 Unless @code{--disable-daemon} was passed to @command{configure}, the
759 following packages are also needed:
760
761 @itemize
762 @item @url{http://gnupg.org/, GNU libgcrypt};
763 @item @url{http://sqlite.org, SQLite 3};
764 @item @url{http://gcc.gnu.org, GCC's g++}, with support for the
765 C++11 standard.
766 @end itemize
767
768 @cindex state directory
769 When configuring Guix on a system that already has a Guix installation,
770 be sure to specify the same state directory as the existing installation
771 using the @code{--localstatedir} option of the @command{configure}
772 script (@pxref{Directory Variables, @code{localstatedir},, standards,
773 GNU Coding Standards}). The @command{configure} script protects against
774 unintended misconfiguration of @var{localstatedir} so you do not
775 inadvertently corrupt your store (@pxref{The Store}).
776
777 @cindex Nix, compatibility
778 When a working installation of @url{http://nixos.org/nix/, the Nix package
779 manager} is available, you
780 can instead configure Guix with @code{--disable-daemon}. In that case,
781 Nix replaces the three dependencies above.
782
783 Guix is compatible with Nix, so it is possible to share the same store
784 between both. To do so, you must pass @command{configure} not only the
785 same @code{--with-store-dir} value, but also the same
786 @code{--localstatedir} value. The latter is essential because it
787 specifies where the database that stores metadata about the store is
788 located, among other things. The default values for Nix are
789 @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
790 Note that @code{--disable-daemon} is not required if
791 your goal is to share the store with Nix.
792
793 @node Running the Test Suite
794 @section Running the Test Suite
795
796 @cindex test suite
797 After a successful @command{configure} and @code{make} run, it is a good
798 idea to run the test suite. It can help catch issues with the setup or
799 environment, or bugs in Guix itself---and really, reporting test
800 failures is a good way to help improve the software. To run the test
801 suite, type:
802
803 @example
804 make check
805 @end example
806
807 Test cases can run in parallel: you can use the @code{-j} option of
808 GNU@tie{}make to speed things up. The first run may take a few minutes
809 on a recent machine; subsequent runs will be faster because the store
810 that is created for test purposes will already have various things in
811 cache.
812
813 It is also possible to run a subset of the tests by defining the
814 @code{TESTS} makefile variable as in this example:
815
816 @example
817 make check TESTS="tests/store.scm tests/cpio.scm"
818 @end example
819
820 By default, tests results are displayed at a file level. In order to
821 see the details of every individual test cases, it is possible to define
822 the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
823
824 @example
825 make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
826 @end example
827
828 Upon failure, please email @email{bug-guix@@gnu.org} and attach the
829 @file{test-suite.log} file. Please specify the Guix version being used
830 as well as version numbers of the dependencies (@pxref{Requirements}) in
831 your message.
832
833 Guix also comes with a whole-system test suite that tests complete
834 Guix System instances. It can only run on systems where
835 Guix is already installed, using:
836
837 @example
838 make check-system
839 @end example
840
841 @noindent
842 or, again, by defining @code{TESTS} to select a subset of tests to run:
843
844 @example
845 make check-system TESTS="basic mcron"
846 @end example
847
848 These system tests are defined in the @code{(gnu tests @dots{})}
849 modules. They work by running the operating systems under test with
850 lightweight instrumentation in a virtual machine (VM). They can be
851 computationally intensive or rather cheap, depending on whether
852 substitutes are available for their dependencies (@pxref{Substitutes}).
853 Some of them require a lot of storage space to hold VM images.
854
855 Again in case of test failures, please send @email{bug-guix@@gnu.org}
856 all the details.
857
858 @node Setting Up the Daemon
859 @section Setting Up the Daemon
860
861 @cindex daemon
862 Operations such as building a package or running the garbage collector
863 are all performed by a specialized process, the @dfn{build daemon}, on
864 behalf of clients. Only the daemon may access the store and its
865 associated database. Thus, any operation that manipulates the store
866 goes through the daemon. For instance, command-line tools such as
867 @command{guix package} and @command{guix build} communicate with the
868 daemon (@i{via} remote procedure calls) to instruct it what to do.
869
870 The following sections explain how to prepare the build daemon's
871 environment. See also @ref{Substitutes}, for information on how to allow
872 the daemon to download pre-built binaries.
873
874 @menu
875 * Build Environment Setup:: Preparing the isolated build environment.
876 * Daemon Offload Setup:: Offloading builds to remote machines.
877 * SELinux Support:: Using an SELinux policy for the daemon.
878 @end menu
879
880 @node Build Environment Setup
881 @subsection Build Environment Setup
882
883 @cindex build environment
884 In a standard multi-user setup, Guix and its daemon---the
885 @command{guix-daemon} program---are installed by the system
886 administrator; @file{/gnu/store} is owned by @code{root} and
887 @command{guix-daemon} runs as @code{root}. Unprivileged users may use
888 Guix tools to build packages or otherwise access the store, and the
889 daemon will do it on their behalf, ensuring that the store is kept in a
890 consistent state, and allowing built packages to be shared among users.
891
892 @cindex build users
893 When @command{guix-daemon} runs as @code{root}, you may not want package
894 build processes themselves to run as @code{root} too, for obvious
895 security reasons. To avoid that, a special pool of @dfn{build users}
896 should be created for use by build processes started by the daemon.
897 These build users need not have a shell and a home directory: they will
898 just be used when the daemon drops @code{root} privileges in build
899 processes. Having several such users allows the daemon to launch
900 distinct build processes under separate UIDs, which guarantees that they
901 do not interfere with each other---an essential feature since builds are
902 regarded as pure functions (@pxref{Introduction}).
903
904 On a GNU/Linux system, a build user pool may be created like this (using
905 Bash syntax and the @code{shadow} commands):
906
907 @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
908 @c for why `-G' is needed.
909 @example
910 # groupadd --system guixbuild
911 # for i in `seq -w 1 10`;
912 do
913 useradd -g guixbuild -G guixbuild \
914 -d /var/empty -s `which nologin` \
915 -c "Guix build user $i" --system \
916 guixbuilder$i;
917 done
918 @end example
919
920 @noindent
921 The number of build users determines how many build jobs may run in
922 parallel, as specified by the @option{--max-jobs} option
923 (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
924 @command{guix system vm} and related commands, you may need to add the
925 build users to the @code{kvm} group so they can access @file{/dev/kvm},
926 using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
927 (@pxref{Invoking guix system}).
928
929 The @code{guix-daemon} program may then be run as @code{root} with the
930 following command@footnote{If your machine uses the systemd init system,
931 dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
932 file in @file{/etc/systemd/system} will ensure that
933 @command{guix-daemon} is automatically started. Similarly, if your
934 machine uses the Upstart init system, drop the
935 @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
936 file in @file{/etc/init}.}:
937
938 @example
939 # guix-daemon --build-users-group=guixbuild
940 @end example
941
942 @cindex chroot
943 @noindent
944 This way, the daemon starts build processes in a chroot, under one of
945 the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
946 environment contains nothing but:
947
948 @c Keep this list in sync with libstore/build.cc! -----------------------
949 @itemize
950 @item
951 a minimal @code{/dev} directory, created mostly independently from the
952 host @code{/dev}@footnote{``Mostly'', because while the set of files
953 that appear in the chroot's @code{/dev} is fixed, most of these files
954 can only be created if the host has them.};
955
956 @item
957 the @code{/proc} directory; it only shows the processes of the container
958 since a separate PID name space is used;
959
960 @item
961 @file{/etc/passwd} with an entry for the current user and an entry for
962 user @file{nobody};
963
964 @item
965 @file{/etc/group} with an entry for the user's group;
966
967 @item
968 @file{/etc/hosts} with an entry that maps @code{localhost} to
969 @code{127.0.0.1};
970
971 @item
972 a writable @file{/tmp} directory.
973 @end itemize
974
975 You can influence the directory where the daemon stores build trees
976 @i{via} the @code{TMPDIR} environment variable. However, the build tree
977 within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
978 where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
979 This way, the value of @code{TMPDIR} does not leak inside build
980 environments, which avoids discrepancies in cases where build processes
981 capture the name of their build tree.
982
983 @vindex http_proxy
984 The daemon also honors the @code{http_proxy} environment variable for
985 HTTP downloads it performs, be it for fixed-output derivations
986 (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
987
988 If you are installing Guix as an unprivileged user, it is still possible
989 to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
990 However, build processes will not be isolated from one another, and not
991 from the rest of the system. Thus, build processes may interfere with
992 each other, and may access programs, libraries, and other files
993 available on the system---making it much harder to view them as
994 @emph{pure} functions.
995
996
997 @node Daemon Offload Setup
998 @subsection Using the Offload Facility
999
1000 @cindex offloading
1001 @cindex build hook
1002 When desired, the build daemon can @dfn{offload} derivation builds to
1003 other machines running Guix, using the @code{offload} @dfn{build
1004 hook}@footnote{This feature is available only when
1005 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
1006 present.}. When that
1007 feature is enabled, a list of user-specified build machines is read from
1008 @file{/etc/guix/machines.scm}; every time a build is requested, for
1009 instance via @code{guix build}, the daemon attempts to offload it to one
1010 of the machines that satisfy the constraints of the derivation, in
1011 particular its system type---e.g., @file{x86_64-linux}. Missing
1012 prerequisites for the build are copied over SSH to the target machine,
1013 which then proceeds with the build; upon success the output(s) of the
1014 build are copied back to the initial machine.
1015
1016 The @file{/etc/guix/machines.scm} file typically looks like this:
1017
1018 @example
1019 (list (build-machine
1020 (name "eightysix.example.org")
1021 (system "x86_64-linux")
1022 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
1023 (user "bob")
1024 (speed 2.)) ;incredibly fast!
1025
1026 (build-machine
1027 (name "meeps.example.org")
1028 (system "mips64el-linux")
1029 (host-key "ssh-rsa AAAAB3Nza@dots{}")
1030 (user "alice")
1031 (private-key
1032 (string-append (getenv "HOME")
1033 "/.ssh/identity-for-guix"))))
1034 @end example
1035
1036 @noindent
1037 In the example above we specify a list of two build machines, one for
1038 the @code{x86_64} architecture and one for the @code{mips64el}
1039 architecture.
1040
1041 In fact, this file is---not surprisingly!---a Scheme file that is
1042 evaluated when the @code{offload} hook is started. Its return value
1043 must be a list of @code{build-machine} objects. While this example
1044 shows a fixed list of build machines, one could imagine, say, using
1045 DNS-SD to return a list of potential build machines discovered in the
1046 local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
1047 Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
1048 detailed below.
1049
1050 @deftp {Data Type} build-machine
1051 This data type represents build machines to which the daemon may offload
1052 builds. The important fields are:
1053
1054 @table @code
1055
1056 @item name
1057 The host name of the remote machine.
1058
1059 @item system
1060 The system type of the remote machine---e.g., @code{"x86_64-linux"}.
1061
1062 @item user
1063 The user account to use when connecting to the remote machine over SSH.
1064 Note that the SSH key pair must @emph{not} be passphrase-protected, to
1065 allow non-interactive logins.
1066
1067 @item host-key
1068 This must be the machine's SSH @dfn{public host key} in OpenSSH format.
1069 This is used to authenticate the machine when we connect to it. It is a
1070 long string that looks like this:
1071
1072 @example
1073 ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
1074 @end example
1075
1076 If the machine is running the OpenSSH daemon, @command{sshd}, the host
1077 key can be found in a file such as
1078 @file{/etc/ssh/ssh_host_ed25519_key.pub}.
1079
1080 If the machine is running the SSH daemon of GNU@tie{}lsh,
1081 @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
1082 similar file. It can be converted to the OpenSSH format using
1083 @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
1084
1085 @example
1086 $ lsh-export-key --openssh < /etc/lsh/host-key.pub
1087 ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
1088 @end example
1089
1090 @end table
1091
1092 A number of optional fields may be specified:
1093
1094 @table @asis
1095
1096 @item @code{port} (default: @code{22})
1097 Port number of SSH server on the machine.
1098
1099 @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
1100 The SSH private key file to use when connecting to the machine, in
1101 OpenSSH format. This key must not be protected with a passphrase.
1102
1103 Note that the default value is the private key @emph{of the root
1104 account}. Make sure it exists if you use the default.
1105
1106 @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
1107 @itemx @code{compression-level} (default: @code{3})
1108 The SSH-level compression methods and compression level requested.
1109
1110 Note that offloading relies on SSH compression to reduce bandwidth usage
1111 when transferring files to and from build machines.
1112
1113 @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
1114 File name of the Unix-domain socket @command{guix-daemon} is listening
1115 to on that machine.
1116
1117 @item @code{parallel-builds} (default: @code{1})
1118 The number of builds that may run in parallel on the machine.
1119
1120 @item @code{speed} (default: @code{1.0})
1121 A ``relative speed factor''. The offload scheduler will tend to prefer
1122 machines with a higher speed factor.
1123
1124 @item @code{features} (default: @code{'()})
1125 A list of strings denoting specific features supported by the machine.
1126 An example is @code{"kvm"} for machines that have the KVM Linux modules
1127 and corresponding hardware support. Derivations can request features by
1128 name, and they will be scheduled on matching build machines.
1129
1130 @end table
1131 @end deftp
1132
1133 The @command{guix} command must be in the search path on the build
1134 machines. You can check whether this is the case by running:
1135
1136 @example
1137 ssh build-machine guix repl --version
1138 @end example
1139
1140 There is one last thing to do once @file{machines.scm} is in place. As
1141 explained above, when offloading, files are transferred back and forth
1142 between the machine stores. For this to work, you first need to
1143 generate a key pair on each machine to allow the daemon to export signed
1144 archives of files from the store (@pxref{Invoking guix archive}):
1145
1146 @example
1147 # guix archive --generate-key
1148 @end example
1149
1150 @noindent
1151 Each build machine must authorize the key of the master machine so that
1152 it accepts store items it receives from the master:
1153
1154 @example
1155 # guix archive --authorize < master-public-key.txt
1156 @end example
1157
1158 @noindent
1159 Likewise, the master machine must authorize the key of each build machine.
1160
1161 All the fuss with keys is here to express pairwise mutual trust
1162 relations between the master and the build machines. Concretely, when
1163 the master receives files from a build machine (and @i{vice versa}), its
1164 build daemon can make sure they are genuine, have not been tampered
1165 with, and that they are signed by an authorized key.
1166
1167 @cindex offload test
1168 To test whether your setup is operational, run this command on the
1169 master node:
1170
1171 @example
1172 # guix offload test
1173 @end example
1174
1175 This will attempt to connect to each of the build machines specified in
1176 @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
1177 available on each machine, attempt to export to the machine and import
1178 from it, and report any error in the process.
1179
1180 If you want to test a different machine file, just specify it on the
1181 command line:
1182
1183 @example
1184 # guix offload test machines-qualif.scm
1185 @end example
1186
1187 Last, you can test the subset of the machines whose name matches a
1188 regular expression like this:
1189
1190 @example
1191 # guix offload test machines.scm '\.gnu\.org$'
1192 @end example
1193
1194 @cindex offload status
1195 To display the current load of all build hosts, run this command on the
1196 main node:
1197
1198 @example
1199 # guix offload status
1200 @end example
1201
1202
1203 @node SELinux Support
1204 @subsection SELinux Support
1205
1206 @cindex SELinux, daemon policy
1207 @cindex mandatory access control, SELinux
1208 @cindex security, guix-daemon
1209 Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
1210 can be installed on a system where SELinux is enabled, in order to label
1211 Guix files and to specify the expected behavior of the daemon. Since
1212 Guix System does not provide an SELinux base policy, the daemon policy cannot
1213 be used on Guix System.
1214
1215 @subsubsection Installing the SELinux policy
1216 @cindex SELinux, policy installation
1217 To install the policy run this command as root:
1218
1219 @example
1220 semodule -i etc/guix-daemon.cil
1221 @end example
1222
1223 Then relabel the file system with @code{restorecon} or by a different
1224 mechanism provided by your system.
1225
1226 Once the policy is installed, the file system has been relabeled, and
1227 the daemon has been restarted, it should be running in the
1228 @code{guix_daemon_t} context. You can confirm this with the following
1229 command:
1230
1231 @example
1232 ps -Zax | grep guix-daemon
1233 @end example
1234
1235 Monitor the SELinux log files as you run a command like @code{guix build
1236 hello} to convince yourself that SELinux permits all necessary
1237 operations.
1238
1239 @subsubsection Limitations
1240 @cindex SELinux, limitations
1241
1242 This policy is not perfect. Here is a list of limitations or quirks
1243 that should be considered when deploying the provided SELinux policy for
1244 the Guix daemon.
1245
1246 @enumerate
1247 @item
1248 @code{guix_daemon_socket_t} isn’t actually used. None of the socket
1249 operations involve contexts that have anything to do with
1250 @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
1251 but it would be preferrable to define socket rules for only this label.
1252
1253 @item
1254 @code{guix gc} cannot access arbitrary links to profiles. By design,
1255 the file label of the destination of a symlink is independent of the
1256 file label of the link itself. Although all profiles under
1257 $localstatedir are labelled, the links to these profiles inherit the
1258 label of the directory they are in. For links in the user’s home
1259 directory this will be @code{user_home_t}. But for links from the root
1260 user’s home directory, or @file{/tmp}, or the HTTP server’s working
1261 directory, etc, this won’t work. @code{guix gc} would be prevented from
1262 reading and following these links.
1263
1264 @item
1265 The daemon’s feature to listen for TCP connections might no longer work.
1266 This might require extra rules, because SELinux treats network sockets
1267 differently from files.
1268
1269 @item
1270 Currently all files with a name matching the regular expression
1271 @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
1272 label @code{guix_daemon_exec_t}; this means that @emph{any} file with
1273 that name in any profile would be permitted to run in the
1274 @code{guix_daemon_t} domain. This is not ideal. An attacker could
1275 build a package that provides this executable and convince a user to
1276 install and run it, which lifts it into the @code{guix_daemon_t} domain.
1277 At that point SELinux could not prevent it from accessing files that are
1278 allowed for processes in that domain.
1279
1280 We could generate a much more restrictive policy at installation time,
1281 so that only the @emph{exact} file name of the currently installed
1282 @code{guix-daemon} executable would be labelled with
1283 @code{guix_daemon_exec_t}, instead of using a broad regular expression.
1284 The downside is that root would have to install or upgrade the policy at
1285 installation time whenever the Guix package that provides the
1286 effectively running @code{guix-daemon} executable is upgraded.
1287 @end enumerate
1288
1289 @node Invoking guix-daemon
1290 @section Invoking @command{guix-daemon}
1291
1292 The @command{guix-daemon} program implements all the functionality to
1293 access the store. This includes launching build processes, running the
1294 garbage collector, querying the availability of a build result, etc. It
1295 is normally run as @code{root} like this:
1296
1297 @example
1298 # guix-daemon --build-users-group=guixbuild
1299 @end example
1300
1301 @noindent
1302 For details on how to set it up, @pxref{Setting Up the Daemon}.
1303
1304 @cindex chroot
1305 @cindex container, build environment
1306 @cindex build environment
1307 @cindex reproducible builds
1308 By default, @command{guix-daemon} launches build processes under
1309 different UIDs, taken from the build group specified with
1310 @code{--build-users-group}. In addition, each build process is run in a
1311 chroot environment that only contains the subset of the store that the
1312 build process depends on, as specified by its derivation
1313 (@pxref{Programming Interface, derivation}), plus a set of specific
1314 system directories. By default, the latter contains @file{/dev} and
1315 @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1316 @dfn{container}: in addition to having its own file system tree, it has
1317 a separate mount name space, its own PID name space, network name space,
1318 etc. This helps achieve reproducible builds (@pxref{Features}).
1319
1320 When the daemon performs a build on behalf of the user, it creates a
1321 build directory under @file{/tmp} or under the directory specified by
1322 its @code{TMPDIR} environment variable. This directory is shared with
1323 the container for the duration of the build, though within the container,
1324 the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
1325
1326 The build directory is automatically deleted upon completion, unless the
1327 build failed and the client specified @option{--keep-failed}
1328 (@pxref{Invoking guix build, @option{--keep-failed}}).
1329
1330 The daemon listens for connections and spawns one sub-process for each session
1331 started by a client (one of the @command{guix} sub-commands.) The
1332 @command{guix processes} command allows you to get an overview of the activity
1333 on your system by viewing each of the active sessions and clients.
1334 @xref{Invoking guix processes}, for more information.
1335
1336 The following command-line options are supported:
1337
1338 @table @code
1339 @item --build-users-group=@var{group}
1340 Take users from @var{group} to run build processes (@pxref{Setting Up
1341 the Daemon, build users}).
1342
1343 @item --no-substitutes
1344 @cindex substitutes
1345 Do not use substitutes for build products. That is, always build things
1346 locally instead of allowing downloads of pre-built binaries
1347 (@pxref{Substitutes}).
1348
1349 When the daemon runs with @code{--no-substitutes}, clients can still
1350 explicitly enable substitution @i{via} the @code{set-build-options}
1351 remote procedure call (@pxref{The Store}).
1352
1353 @item --substitute-urls=@var{urls}
1354 @anchor{daemon-substitute-urls}
1355 Consider @var{urls} the default whitespace-separated list of substitute
1356 source URLs. When this option is omitted,
1357 @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
1358
1359 This means that substitutes may be downloaded from @var{urls}, as long
1360 as they are signed by a trusted signature (@pxref{Substitutes}).
1361
1362 @cindex build hook
1363 @item --no-build-hook
1364 Do not use the @dfn{build hook}.
1365
1366 The build hook is a helper program that the daemon can start and to
1367 which it submits build requests. This mechanism is used to offload
1368 builds to other machines (@pxref{Daemon Offload Setup}).
1369
1370 @item --cache-failures
1371 Cache build failures. By default, only successful builds are cached.
1372
1373 When this option is used, @command{guix gc --list-failures} can be used
1374 to query the set of store items marked as failed; @command{guix gc
1375 --clear-failures} removes store items from the set of cached failures.
1376 @xref{Invoking guix gc}.
1377
1378 @item --cores=@var{n}
1379 @itemx -c @var{n}
1380 Use @var{n} CPU cores to build each derivation; @code{0} means as many
1381 as available.
1382
1383 The default value is @code{0}, but it may be overridden by clients, such
1384 as the @code{--cores} option of @command{guix build} (@pxref{Invoking
1385 guix build}).
1386
1387 The effect is to define the @code{NIX_BUILD_CORES} environment variable
1388 in the build process, which can then use it to exploit internal
1389 parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1390
1391 @item --max-jobs=@var{n}
1392 @itemx -M @var{n}
1393 Allow at most @var{n} build jobs in parallel. The default value is
1394 @code{1}. Setting it to @code{0} means that no builds will be performed
1395 locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1396 Setup}), or simply fail.
1397
1398 @item --max-silent-time=@var{seconds}
1399 When the build or substitution process remains silent for more than
1400 @var{seconds}, terminate it and report a build failure.
1401
1402 The default value is @code{0}, which disables the timeout.
1403
1404 The value specified here can be overridden by clients (@pxref{Common
1405 Build Options, @code{--max-silent-time}}).
1406
1407 @item --timeout=@var{seconds}
1408 Likewise, when the build or substitution process lasts for more than
1409 @var{seconds}, terminate it and report a build failure.
1410
1411 The default value is @code{0}, which disables the timeout.
1412
1413 The value specified here can be overridden by clients (@pxref{Common
1414 Build Options, @code{--timeout}}).
1415
1416 @item --rounds=@var{N}
1417 Build each derivation @var{n} times in a row, and raise an error if
1418 consecutive build results are not bit-for-bit identical. Note that this
1419 setting can be overridden by clients such as @command{guix build}
1420 (@pxref{Invoking guix build}).
1421
1422 When used in conjunction with @option{--keep-failed}, the differing
1423 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1424 This makes it easy to look for differences between the two results.
1425
1426 @item --debug
1427 Produce debugging output.
1428
1429 This is useful to debug daemon start-up issues, but then it may be
1430 overridden by clients, for example the @code{--verbosity} option of
1431 @command{guix build} (@pxref{Invoking guix build}).
1432
1433 @item --chroot-directory=@var{dir}
1434 Add @var{dir} to the build chroot.
1435
1436 Doing this may change the result of build processes---for instance if
1437 they use optional dependencies found in @var{dir} when it is available,
1438 and not otherwise. For that reason, it is not recommended to do so.
1439 Instead, make sure that each derivation declares all the inputs that it
1440 needs.
1441
1442 @item --disable-chroot
1443 Disable chroot builds.
1444
1445 Using this option is not recommended since, again, it would allow build
1446 processes to gain access to undeclared dependencies. It is necessary,
1447 though, when @command{guix-daemon} is running under an unprivileged user
1448 account.
1449
1450 @item --log-compression=@var{type}
1451 Compress build logs according to @var{type}, one of @code{gzip},
1452 @code{bzip2}, or @code{none}.
1453
1454 Unless @code{--lose-logs} is used, all the build logs are kept in the
1455 @var{localstatedir}. To save space, the daemon automatically compresses
1456 them with bzip2 by default.
1457
1458 @item --disable-deduplication
1459 @cindex deduplication
1460 Disable automatic file ``deduplication'' in the store.
1461
1462 By default, files added to the store are automatically ``deduplicated'':
1463 if a newly added file is identical to another one found in the store,
1464 the daemon makes the new file a hard link to the other file. This can
1465 noticeably reduce disk usage, at the expense of slightly increased
1466 input/output load at the end of a build process. This option disables
1467 this optimization.
1468
1469 @item --gc-keep-outputs[=yes|no]
1470 Tell whether the garbage collector (GC) must keep outputs of live
1471 derivations.
1472
1473 @cindex GC roots
1474 @cindex garbage collector roots
1475 When set to ``yes'', the GC will keep the outputs of any live derivation
1476 available in the store---the @code{.drv} files. The default is ``no'',
1477 meaning that derivation outputs are kept only if they are reachable from a GC
1478 root. @xref{Invoking guix gc}, for more on GC roots.
1479
1480 @item --gc-keep-derivations[=yes|no]
1481 Tell whether the garbage collector (GC) must keep derivations
1482 corresponding to live outputs.
1483
1484 When set to ``yes'', as is the case by default, the GC keeps
1485 derivations---i.e., @code{.drv} files---as long as at least one of their
1486 outputs is live. This allows users to keep track of the origins of
1487 items in their store. Setting it to ``no'' saves a bit of disk space.
1488
1489 In this way, setting @code{--gc-keep-derivations} to ``yes'' causes liveness
1490 to flow from outputs to derivations, and setting @code{--gc-keep-outputs} to
1491 ``yes'' causes liveness to flow from derivations to outputs. When both are
1492 set to ``yes'', the effect is to keep all the build prerequisites (the
1493 sources, compiler, libraries, and other build-time tools) of live objects in
1494 the store, regardless of whether these prerequisites are reachable from a GC
1495 root. This is convenient for developers since it saves rebuilds or downloads.
1496
1497 @item --impersonate-linux-2.6
1498 On Linux-based systems, impersonate Linux 2.6. This means that the
1499 kernel's @code{uname} system call will report 2.6 as the release number.
1500
1501 This might be helpful to build programs that (usually wrongfully) depend
1502 on the kernel version number.
1503
1504 @item --lose-logs
1505 Do not keep build logs. By default they are kept under
1506 @code{@var{localstatedir}/guix/log}.
1507
1508 @item --system=@var{system}
1509 Assume @var{system} as the current system type. By default it is the
1510 architecture/kernel pair found at configure time, such as
1511 @code{x86_64-linux}.
1512
1513 @item --listen=@var{endpoint}
1514 Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
1515 as the file name of a Unix-domain socket if it starts with
1516 @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
1517 host name or host name and port to listen to. Here are a few examples:
1518
1519 @table @code
1520 @item --listen=/gnu/var/daemon
1521 Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
1522 creating it if needed.
1523
1524 @item --listen=localhost
1525 @cindex daemon, remote access
1526 @cindex remote access to the daemon
1527 @cindex daemon, cluster setup
1528 @cindex clusters, daemon setup
1529 Listen for TCP connections on the network interface corresponding to
1530 @code{localhost}, on port 44146.
1531
1532 @item --listen=128.0.0.42:1234
1533 Listen for TCP connections on the network interface corresponding to
1534 @code{128.0.0.42}, on port 1234.
1535 @end table
1536
1537 This option can be repeated multiple times, in which case
1538 @command{guix-daemon} accepts connections on all the specified
1539 endpoints. Users can tell client commands what endpoint to connect to
1540 by setting the @code{GUIX_DAEMON_SOCKET} environment variable
1541 (@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
1542
1543 @quotation Note
1544 The daemon protocol is @emph{unauthenticated and unencrypted}. Using
1545 @code{--listen=@var{host}} is suitable on local networks, such as
1546 clusters, where only trusted nodes may connect to the build daemon. In
1547 other cases where remote access to the daemon is needed, we recommend
1548 using Unix-domain sockets along with SSH.
1549 @end quotation
1550
1551 When @code{--listen} is omitted, @command{guix-daemon} listens for
1552 connections on the Unix-domain socket located at
1553 @file{@var{localstatedir}/guix/daemon-socket/socket}.
1554 @end table
1555
1556
1557 @node Application Setup
1558 @section Application Setup
1559
1560 @cindex foreign distro
1561 When using Guix on top of GNU/Linux distribution other than Guix System---a
1562 so-called @dfn{foreign distro}---a few additional steps are needed to
1563 get everything in place. Here are some of them.
1564
1565 @subsection Locales
1566
1567 @anchor{locales-and-locpath}
1568 @cindex locales, when not on Guix System
1569 @vindex LOCPATH
1570 @vindex GUIX_LOCPATH
1571 Packages installed @i{via} Guix will not use the locale data of the
1572 host system. Instead, you must first install one of the locale packages
1573 available with Guix and then define the @code{GUIX_LOCPATH} environment
1574 variable:
1575
1576 @example
1577 $ guix package -i glibc-locales
1578 $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
1579 @end example
1580
1581 Note that the @code{glibc-locales} package contains data for all the
1582 locales supported by the GNU@tie{}libc and weighs in at around
1583 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
1584 limited to a few UTF-8 locales.
1585
1586 The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
1587 (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
1588 Manual}). There are two important differences though:
1589
1590 @enumerate
1591 @item
1592 @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
1593 provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
1594 to make sure the programs of the foreign distro will not end up loading
1595 incompatible locale data.
1596
1597 @item
1598 libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
1599 @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1600 should your Guix profile contain a mixture of programs linked against
1601 different libc version, each libc version will only try to load locale
1602 data in the right format.
1603 @end enumerate
1604
1605 This is important because the locale data format used by different libc
1606 versions may be incompatible.
1607
1608 @subsection Name Service Switch
1609
1610 @cindex name service switch, glibc
1611 @cindex NSS (name service switch), glibc
1612 @cindex nscd (name service caching daemon)
1613 @cindex name service caching daemon (nscd)
1614 When using Guix on a foreign distro, we @emph{strongly recommend} that
1615 the system run the GNU C library's @dfn{name service cache daemon},
1616 @command{nscd}, which should be listening on the
1617 @file{/var/run/nscd/socket} socket. Failing to do that, applications
1618 installed with Guix may fail to look up host names or user accounts, or
1619 may even crash. The next paragraphs explain why.
1620
1621 @cindex @file{nsswitch.conf}
1622 The GNU C library implements a @dfn{name service switch} (NSS), which is
1623 an extensible mechanism for ``name lookups'' in general: host name
1624 resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1625 The GNU C Library Reference Manual}).
1626
1627 @cindex Network information service (NIS)
1628 @cindex NIS (Network information service)
1629 Being extensible, the NSS supports @dfn{plugins}, which provide new name
1630 lookup implementations: for example, the @code{nss-mdns} plugin allow
1631 resolution of @code{.local} host names, the @code{nis} plugin allows
1632 user account lookup using the Network information service (NIS), and so
1633 on. These extra ``lookup services'' are configured system-wide in
1634 @file{/etc/nsswitch.conf}, and all the programs running on the system
1635 honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1636 Reference Manual}).
1637
1638 When they perform a name lookup---for instance by calling the
1639 @code{getaddrinfo} function in C---applications first try to connect to
1640 the nscd; on success, nscd performs name lookups on their behalf. If
1641 the nscd is not running, then they perform the name lookup by
1642 themselves, by loading the name lookup services into their own address
1643 space and running it. These name lookup services---the
1644 @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1645 the host system's C library, rather than from the C library the
1646 application is linked against (the C library coming from Guix).
1647
1648 And this is where the problem is: if your application is linked against
1649 Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1650 another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1651 likely crash or have its name lookups fail unexpectedly.
1652
1653 Running @command{nscd} on the system, among other advantages, eliminates
1654 this binary incompatibility problem because those @code{libnss_*.so}
1655 files are loaded in the @command{nscd} process, not in applications
1656 themselves.
1657
1658 @subsection X11 Fonts
1659
1660 @cindex fonts
1661 The majority of graphical applications use Fontconfig to locate and
1662 load fonts and perform X11-client-side rendering. The @code{fontconfig}
1663 package in Guix looks for fonts in @file{$HOME/.guix-profile}
1664 by default. Thus, to allow graphical applications installed with Guix
1665 to display fonts, you have to install fonts with Guix as well.
1666 Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
1667 @code{font-gnu-freefont-ttf}.
1668
1669 To display text written in Chinese languages, Japanese, or Korean in
1670 graphical applications, consider installing
1671 @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1672 has multiple outputs, one per language family (@pxref{Packages with
1673 Multiple Outputs}). For instance, the following command installs fonts
1674 for Chinese languages:
1675
1676 @example
1677 guix package -i font-adobe-source-han-sans:cn
1678 @end example
1679
1680 @cindex @code{xterm}
1681 Older programs such as @command{xterm} do not use Fontconfig and instead
1682 rely on server-side font rendering. Such programs require to specify a
1683 full name of a font using XLFD (X Logical Font Description), like this:
1684
1685 @example
1686 -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1687 @end example
1688
1689 To be able to use such full names for the TrueType fonts installed in
1690 your Guix profile, you need to extend the font path of the X server:
1691
1692 @c Note: 'xset' does not accept symlinks so the trick below arranges to
1693 @c get at the real directory. See <https://bugs.gnu.org/30655>.
1694 @example
1695 xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
1696 @end example
1697
1698 @cindex @code{xlsfonts}
1699 After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1700 to make sure your TrueType fonts are listed there.
1701
1702 @cindex @code{fc-cache}
1703 @cindex font cache
1704 After installing fonts you may have to refresh the font cache to use
1705 them in applications. The same applies when applications installed via
1706 Guix do not seem to find fonts. To force rebuilding of the font cache
1707 run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
1708 @code{fontconfig} package.
1709
1710 @subsection X.509 Certificates
1711
1712 @cindex @code{nss-certs}
1713 The @code{nss-certs} package provides X.509 certificates, which allow
1714 programs to authenticate Web servers accessed over HTTPS.
1715
1716 When using Guix on a foreign distro, you can install this package and
1717 define the relevant environment variables so that packages know where to
1718 look for certificates. @xref{X.509 Certificates}, for detailed
1719 information.
1720
1721 @subsection Emacs Packages
1722
1723 @cindex @code{emacs}
1724 When you install Emacs packages with Guix, the elisp files may be placed
1725 either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
1726 sub-directories of
1727 @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
1728 directory exists because potentially there may exist thousands of Emacs
1729 packages and storing all their files in a single directory may not be
1730 reliable (because of name conflicts). So we think using a separate
1731 directory for each package is a good idea. It is very similar to how
1732 the Emacs package system organizes the file structure (@pxref{Package
1733 Files,,, emacs, The GNU Emacs Manual}).
1734
1735 By default, Emacs (installed with Guix) ``knows'' where these packages
1736 are placed, so you do not need to perform any configuration. If, for
1737 some reason, you want to avoid auto-loading Emacs packages installed
1738 with Guix, you can do so by running Emacs with @code{--no-site-file}
1739 option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1740
1741 @subsection The GCC toolchain
1742
1743 @cindex GCC
1744 @cindex ld-wrapper
1745
1746 Guix offers individual compiler packages such as @code{gcc} but if you
1747 are in need of a complete toolchain for compiling and linking source
1748 code what you really want is the @code{gcc-toolchain} package. This
1749 package provides a complete GCC toolchain for C/C++ development,
1750 including GCC itself, the GNU C Library (headers and binaries, plus
1751 debugging symbols in the @code{debug} output), Binutils, and a linker
1752 wrapper.
1753
1754 The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
1755 passed to the linker, add corresponding @code{-rpath} arguments, and
1756 invoke the actual linker with this new set of arguments. You can instruct the
1757 wrapper to refuse to link against libraries not in the store by setting the
1758 @code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
1759
1760 @c TODO What else?
1761
1762 @c *********************************************************************
1763 @node System Installation
1764 @chapter System Installation
1765
1766 @cindex installing Guix System
1767 @cindex Guix System, installation
1768 This section explains how to install Guix System
1769 on a machine. Guix, as a package manager, can
1770 also be installed on top of a running GNU/Linux system,
1771 @pxref{Installation}.
1772
1773 @ifinfo
1774 @quotation Note
1775 @c This paragraph is for people reading this from tty2 of the
1776 @c installation image.
1777 You are reading this documentation with an Info reader. For details on
1778 how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
1779 link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
1780 Info}. Hit @kbd{l} afterwards to come back here.
1781
1782 Alternately, run @command{info info} in another tty to keep the manual
1783 available.
1784 @end quotation
1785 @end ifinfo
1786
1787 @menu
1788 * Limitations:: What you can expect.
1789 * Hardware Considerations:: Supported hardware.
1790 * USB Stick and DVD Installation:: Preparing the installation medium.
1791 * Preparing for Installation:: Networking, partitioning, etc.
1792 * Guided Graphical Installation:: Easy graphical installation.
1793 * Manual Installation:: Manual installation for wizards.
1794 * After System Installation:: When installation succeeded.
1795 * Installing Guix in a VM:: Guix System playground.
1796 * Building the Installation Image:: How this comes to be.
1797 @end menu
1798
1799 @node Limitations
1800 @section Limitations
1801
1802 We consider Guix System to be ready for a wide range of ``desktop'' and server
1803 use cases. The reliability guarantees it provides---transactional upgrades
1804 and rollbacks, reproducibility---make it a solid foundation.
1805
1806 Nevertheless, before you proceed with the installation, be aware of the
1807 following noteworthy limitations applicable to version @value{VERSION}:
1808
1809 @itemize
1810 @item
1811 Support for the Logical Volume Manager (LVM) is missing.
1812
1813 @item
1814 More and more system services are provided (@pxref{Services}), but some
1815 may be missing.
1816
1817 @item
1818 GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
1819 as well as a number of X11 window managers. However, KDE is currently
1820 missing.
1821 @end itemize
1822
1823 More than a disclaimer, this is an invitation to report issues (and success
1824 stories!), and to join us in improving it. @xref{Contributing}, for more
1825 info.
1826
1827
1828 @node Hardware Considerations
1829 @section Hardware Considerations
1830
1831 @cindex hardware support on Guix System
1832 GNU@tie{}Guix focuses on respecting the user's computing freedom. It
1833 builds around the kernel Linux-libre, which means that only hardware for
1834 which free software drivers and firmware exist is supported. Nowadays,
1835 a wide range of off-the-shelf hardware is supported on
1836 GNU/Linux-libre---from keyboards to graphics cards to scanners and
1837 Ethernet controllers. Unfortunately, there are still areas where
1838 hardware vendors deny users control over their own computing, and such
1839 hardware is not supported on Guix System.
1840
1841 @cindex WiFi, hardware support
1842 One of the main areas where free drivers or firmware are lacking is WiFi
1843 devices. WiFi devices known to work include those using Atheros chips
1844 (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
1845 driver, and those using Broadcom/AirForce chips (BCM43xx with
1846 Wireless-Core Revision 5), which corresponds to the @code{b43-open}
1847 Linux-libre driver. Free firmware exists for both and is available
1848 out-of-the-box on Guix System, as part of @code{%base-firmware}
1849 (@pxref{operating-system Reference, @code{firmware}}).
1850
1851 @cindex RYF, Respects Your Freedom
1852 The @uref{https://www.fsf.org/, Free Software Foundation} runs
1853 @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
1854 certification program for hardware products that respect your freedom
1855 and your privacy and ensure that you have control over your device. We
1856 encourage you to check the list of RYF-certified devices.
1857
1858 Another useful resource is the @uref{https://www.h-node.org/, H-Node}
1859 web site. It contains a catalog of hardware devices with information
1860 about their support in GNU/Linux.
1861
1862
1863 @node USB Stick and DVD Installation
1864 @section USB Stick and DVD Installation
1865
1866 An ISO-9660 installation image that can be written to a USB stick or
1867 burnt to a DVD can be downloaded from
1868 @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.@var{system}.iso.xz},
1869 where @var{system} is one of:
1870
1871 @table @code
1872 @item x86_64-linux
1873 for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
1874
1875 @item i686-linux
1876 for a 32-bit GNU/Linux system on Intel-compatible CPUs.
1877 @end table
1878
1879 @c start duplication of authentication part from ``Binary Installation''
1880 Make sure to download the associated @file{.sig} file and to verify the
1881 authenticity of the image against it, along these lines:
1882
1883 @example
1884 $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.@var{system}.iso.xz.sig
1885 $ gpg --verify guix-system-install-@value{VERSION}.@var{system}.iso.xz.sig
1886 @end example
1887
1888 If that command fails because you do not have the required public key,
1889 then run this command to import it:
1890
1891 @example
1892 $ gpg --keyserver @value{KEY-SERVER} \
1893 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
1894 @end example
1895
1896 @noindent
1897 and rerun the @code{gpg --verify} command.
1898 @c end duplication
1899
1900 This image contains the tools necessary for an installation.
1901 It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
1902
1903 @unnumberedsubsec Copying to a USB Stick
1904
1905 To copy the image to a USB stick, follow these steps:
1906
1907 @enumerate
1908 @item
1909 Decompress the image using the @command{xz} command:
1910
1911 @example
1912 xz -d guix-system-install-@value{VERSION}.@var{system}.iso.xz
1913 @end example
1914
1915 @item
1916 Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
1917 its device name. Assuming that the USB stick is known as @file{/dev/sdX},
1918 copy the image with:
1919
1920 @example
1921 dd if=guix-system-install-@value{VERSION}.@var{system}.iso of=/dev/sdX
1922 sync
1923 @end example
1924
1925 Access to @file{/dev/sdX} usually requires root privileges.
1926 @end enumerate
1927
1928 @unnumberedsubsec Burning on a DVD
1929
1930 To copy the image to a DVD, follow these steps:
1931
1932 @enumerate
1933 @item
1934 Decompress the image using the @command{xz} command:
1935
1936 @example
1937 xz -d guix-system-install-@value{VERSION}.@var{system}.iso.xz
1938 @end example
1939
1940 @item
1941 Insert a blank DVD into your machine, and determine
1942 its device name. Assuming that the DVD drive is known as @file{/dev/srX},
1943 copy the image with:
1944
1945 @example
1946 growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.@var{system}.iso
1947 @end example
1948
1949 Access to @file{/dev/srX} usually requires root privileges.
1950 @end enumerate
1951
1952 @unnumberedsubsec Booting
1953
1954 Once this is done, you should be able to reboot the system and boot from
1955 the USB stick or DVD. The latter usually requires you to get in the
1956 BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
1957
1958 @xref{Installing Guix in a VM}, if, instead, you would like to install
1959 Guix System in a virtual machine (VM).
1960
1961
1962 @node Preparing for Installation
1963 @section Preparing for Installation
1964
1965 Once you have booted, you can use the guided graphical installer, which makes
1966 it easy to get started (@pxref{Guided Graphical Installation}). Alternately,
1967 if you are already familiar with GNU/Linux and if you want more control than
1968 what the graphical installer provides, you can choose the ``manual''
1969 installation process (@pxref{Manual Installation}).
1970
1971 The graphical installer is available on TTY1. You can obtain root shells on
1972 TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
1973 this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
1974 is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
1975 Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
1976 which allows you to select text with the left mouse button and to paste it
1977 with the middle button.
1978
1979 @quotation Note
1980 Installation requires access to the Internet so that any missing
1981 dependencies of your system configuration can be downloaded. See the
1982 ``Networking'' section below.
1983 @end quotation
1984
1985 @node Guided Graphical Installation
1986 @section Guided Graphical Installation
1987
1988 The graphical installer is a text-based user interface. It will guide you,
1989 with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
1990
1991 The first dialog boxes allow you to set up the system as you use it during the
1992 installation: you can choose the language, keyboard layout, and set up
1993 networking, which will be used during the installation. The image below shows
1994 the networking dialog.
1995
1996 @image{images/installer-network,5in,, networking setup with the graphical installer}
1997
1998 Later steps allow you to partition your hard disk, as shown in the image
1999 below, to choose whether or not to use encrypted file systems, to enter the
2000 host name and root password, and to create an additional account, among other
2001 things.
2002
2003 @image{images/installer-partitions,5in,, partitioning with the graphical installer}
2004
2005 Note that, at any time, the installer allows you to exit the current
2006 installation step and resume at a previous step, as show in the image below.
2007
2008 @image{images/installer-resume,5in,, resuming the installation process}
2009
2010 Once you're done, the installer produces an operating system configuration and
2011 displays it (@pxref{Using the Configuration System}). At that point you can
2012 hit ``OK'' and installation will proceed. On success, you can reboot into the
2013 new system and enjoy. @xref{After System Installation}, for what's next!
2014
2015
2016 @node Manual Installation
2017 @section Manual Installation
2018
2019 This section describes how you would ``manually'' install GNU@tie{}Guix System
2020 on your machine. This option requires familiarity with GNU/Linux, with the
2021 shell, and with common administration tools. If you think this is not for
2022 you, consider using the guided graphical installer (@pxref{Guided Graphical
2023 Installation}).
2024
2025 The installation system provides root shells on TTYs 3 to 6; press
2026 @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
2027 many common tools needed to install the system. But it is also a full-blown
2028 Guix System, which means that you can install additional packages, should you
2029 need it, using @command{guix package} (@pxref{Invoking guix package}).
2030
2031 @menu
2032 * Keyboard Layout and Networking and Partitioning:: Initial setup.
2033 * Proceeding with the Installation:: Installing.
2034 @end menu
2035
2036 @node Keyboard Layout and Networking and Partitioning
2037 @subsection Keyboard Layout, Networking, and Partitioning
2038
2039 Before you can install the system, you may want to adjust the keyboard layout,
2040 set up networking, and partition your target hard disk. This section will
2041 guide you through this.
2042
2043 @subsubsection Keyboard Layout
2044
2045 @cindex keyboard layout
2046 The installation image uses the US qwerty keyboard layout. If you want
2047 to change it, you can use the @command{loadkeys} command. For example,
2048 the following command selects the Dvorak keyboard layout:
2049
2050 @example
2051 loadkeys dvorak
2052 @end example
2053
2054 See the files under @file{/run/current-system/profile/share/keymaps} for
2055 a list of available keyboard layouts. Run @command{man loadkeys} for
2056 more information.
2057
2058 @subsubsection Networking
2059
2060 Run the following command to see what your network interfaces are called:
2061
2062 @example
2063 ifconfig -a
2064 @end example
2065
2066 @noindent
2067 @dots{} or, using the GNU/Linux-specific @command{ip} command:
2068
2069 @example
2070 ip a
2071 @end example
2072
2073 @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
2074 Wired interfaces have a name starting with @samp{e}; for example, the
2075 interface corresponding to the first on-board Ethernet controller is
2076 called @samp{eno1}. Wireless interfaces have a name starting with
2077 @samp{w}, like @samp{w1p2s0}.
2078
2079 @table @asis
2080 @item Wired connection
2081 To configure a wired network run the following command, substituting
2082 @var{interface} with the name of the wired interface you want to use.
2083
2084 @example
2085 ifconfig @var{interface} up
2086 @end example
2087
2088 @item Wireless connection
2089 @cindex wireless
2090 @cindex WiFi
2091 To configure wireless networking, you can create a configuration file
2092 for the @command{wpa_supplicant} configuration tool (its location is not
2093 important) using one of the available text editors such as
2094 @command{nano}:
2095
2096 @example
2097 nano wpa_supplicant.conf
2098 @end example
2099
2100 As an example, the following stanza can go to this file and will work
2101 for many wireless networks, provided you give the actual SSID and
2102 passphrase for the network you are connecting to:
2103
2104 @example
2105 network=@{
2106 ssid="@var{my-ssid}"
2107 key_mgmt=WPA-PSK
2108 psk="the network's secret passphrase"
2109 @}
2110 @end example
2111
2112 Start the wireless service and run it in the background with the
2113 following command (substitute @var{interface} with the name of the
2114 network interface you want to use):
2115
2116 @example
2117 wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
2118 @end example
2119
2120 Run @command{man wpa_supplicant} for more information.
2121 @end table
2122
2123 @cindex DHCP
2124 At this point, you need to acquire an IP address. On a network where IP
2125 addresses are automatically assigned @i{via} DHCP, you can run:
2126
2127 @example
2128 dhclient -v @var{interface}
2129 @end example
2130
2131 Try to ping a server to see if networking is up and running:
2132
2133 @example
2134 ping -c 3 gnu.org
2135 @end example
2136
2137 Setting up network access is almost always a requirement because the
2138 image does not contain all the software and tools that may be needed.
2139
2140 @cindex installing over SSH
2141 If you want to, you can continue the installation remotely by starting
2142 an SSH server:
2143
2144 @example
2145 herd start ssh-daemon
2146 @end example
2147
2148 Make sure to either set a password with @command{passwd}, or configure
2149 OpenSSH public key authentication before logging in.
2150
2151 @subsubsection Disk Partitioning
2152
2153 Unless this has already been done, the next step is to partition, and
2154 then format the target partition(s).
2155
2156 The installation image includes several partitioning tools, including
2157 Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
2158 @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
2159 the partition layout you want:
2160
2161 @example
2162 cfdisk
2163 @end example
2164
2165 If your disk uses the GUID Partition Table (GPT) format and you plan to
2166 install BIOS-based GRUB (which is the default), make sure a BIOS Boot
2167 Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
2168 manual}).
2169
2170 @cindex EFI, installation
2171 @cindex UEFI, installation
2172 @cindex ESP, EFI system partition
2173 If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
2174 (ESP) is required. This partition can be mounted at @file{/boot/efi} for
2175 instance and must have the @code{esp} flag set. E.g., for @command{parted}:
2176
2177 @example
2178 parted /dev/sda set 1 esp on
2179 @end example
2180
2181 @quotation Note
2182 @vindex grub-bootloader
2183 @vindex grub-efi-bootloader
2184 Unsure whether to use EFI- or BIOS-based GRUB? If the directory
2185 @file{/sys/firmware/efi} exists in the installation image, then you should
2186 probably perform an EFI installation, using @code{grub-efi-bootloader}.
2187 Otherwise you should use the BIOS-based GRUB, known as
2188 @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
2189 bootloaders.
2190 @end quotation
2191
2192 Once you are done partitioning the target hard disk drive, you have to
2193 create a file system on the relevant partition(s)@footnote{Currently
2194 Guix System only supports ext4 and btrfs file systems. In particular, code
2195 that reads file system UUIDs and labels only works for these file system
2196 types.}. For the ESP, if you have one and assuming it is
2197 @file{/dev/sda1}, run:
2198
2199 @example
2200 mkfs.fat -F32 /dev/sda1
2201 @end example
2202
2203 Preferably, assign file systems a label so that you can easily and
2204 reliably refer to them in @code{file-system} declarations (@pxref{File
2205 Systems}). This is typically done using the @code{-L} option of
2206 @command{mkfs.ext4} and related commands. So, assuming the target root
2207 partition lives at @file{/dev/sda2}, a file system with the label
2208 @code{my-root} can be created with:
2209
2210 @example
2211 mkfs.ext4 -L my-root /dev/sda2
2212 @end example
2213
2214 @cindex encrypted disk
2215 If you are instead planning to encrypt the root partition, you can use
2216 the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
2217 @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
2218 @code{man cryptsetup}} for more information.) Assuming you want to
2219 store the root partition on @file{/dev/sda2}, the command sequence would
2220 be along these lines:
2221
2222 @example
2223 cryptsetup luksFormat /dev/sda2
2224 cryptsetup open --type luks /dev/sda2 my-partition
2225 mkfs.ext4 -L my-root /dev/mapper/my-partition
2226 @end example
2227
2228 Once that is done, mount the target file system under @file{/mnt}
2229 with a command like (again, assuming @code{my-root} is the label of the
2230 root file system):
2231
2232 @example
2233 mount LABEL=my-root /mnt
2234 @end example
2235
2236 Also mount any other file systems you would like to use on the target
2237 system relative to this path. If you have opted for @file{/boot/efi} as an
2238 EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
2239 found by @code{guix system init} afterwards.
2240
2241 Finally, if you plan to use one or more swap partitions (@pxref{Memory
2242 Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
2243 sure to initialize them with @command{mkswap}. Assuming you have one
2244 swap partition on @file{/dev/sda3}, you would run:
2245
2246 @example
2247 mkswap /dev/sda3
2248 swapon /dev/sda3
2249 @end example
2250
2251 Alternatively, you may use a swap file. For example, assuming that in
2252 the new system you want to use the file @file{/swapfile} as a swap file,
2253 you would run@footnote{This example will work for many types of file
2254 systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
2255 btrfs), the required steps may be different. For details, see the
2256 manual pages for @command{mkswap} and @command{swapon}.}:
2257
2258 @example
2259 # This is 10 GiB of swap space. Adjust "count" to change the size.
2260 dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
2261 # For security, make the file readable and writable only by root.
2262 chmod 600 /mnt/swapfile
2263 mkswap /mnt/swapfile
2264 swapon /mnt/swapfile
2265 @end example
2266
2267 Note that if you have encrypted the root partition and created a swap
2268 file in its file system as described above, then the encryption also
2269 protects the swap file, just like any other file in that file system.
2270
2271 @node Proceeding with the Installation
2272 @subsection Proceeding with the Installation
2273
2274 With the target partitions ready and the target root mounted on
2275 @file{/mnt}, we're ready to go. First, run:
2276
2277 @example
2278 herd start cow-store /mnt
2279 @end example
2280
2281 This makes @file{/gnu/store} copy-on-write, such that packages added to it
2282 during the installation phase are written to the target disk on @file{/mnt}
2283 rather than kept in memory. This is necessary because the first phase of
2284 the @command{guix system init} command (see below) entails downloads or
2285 builds to @file{/gnu/store} which, initially, is an in-memory file system.
2286
2287 Next, you have to edit a file and
2288 provide the declaration of the operating system to be installed. To
2289 that end, the installation system comes with three text editors. We
2290 recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
2291 supports syntax highlighting and parentheses matching; other editors
2292 include GNU Zile (an Emacs clone), and
2293 nvi (a clone of the original BSD @command{vi} editor).
2294 We strongly recommend storing that file on the target root file system, say,
2295 as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
2296 configuration file once you have rebooted into the newly-installed system.
2297
2298 @xref{Using the Configuration System}, for an overview of the
2299 configuration file. The example configurations discussed in that
2300 section are available under @file{/etc/configuration} in the
2301 installation image. Thus, to get started with a system configuration
2302 providing a graphical display server (a ``desktop'' system), you can run
2303 something along these lines:
2304
2305 @example
2306 # mkdir /mnt/etc
2307 # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
2308 # nano /mnt/etc/config.scm
2309 @end example
2310
2311 You should pay attention to what your configuration file contains, and
2312 in particular:
2313
2314 @itemize
2315 @item
2316 Make sure the @code{bootloader-configuration} form refers to the target
2317 you want to install GRUB on. It should mention @code{grub-bootloader} if
2318 you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
2319 for newer UEFI systems. For legacy systems, the @code{target} field
2320 names a device, like @code{/dev/sda}; for UEFI systems it names a path
2321 to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
2322 currently mounted and a @code{file-system} entry is specified in your
2323 configuration.
2324
2325 @item
2326 Be sure that your file system labels match the value of their respective
2327 @code{device} fields in your @code{file-system} configuration, assuming
2328 your @code{file-system} configuration uses the @code{file-system-label}
2329 procedure in its @code{device} field.
2330
2331 @item
2332 If there are encrypted or RAID partitions, make sure to add a
2333 @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
2334 @end itemize
2335
2336 Once you are done preparing the configuration file, the new system must
2337 be initialized (remember that the target root file system is mounted
2338 under @file{/mnt}):
2339
2340 @example
2341 guix system init /mnt/etc/config.scm /mnt
2342 @end example
2343
2344 @noindent
2345 This copies all the necessary files and installs GRUB on
2346 @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
2347 more information, @pxref{Invoking guix system}. This command may trigger
2348 downloads or builds of missing packages, which can take some time.
2349
2350 Once that command has completed---and hopefully succeeded!---you can run
2351 @command{reboot} and boot into the new system. The @code{root} password
2352 in the new system is initially empty; other users' passwords need to be
2353 initialized by running the @command{passwd} command as @code{root},
2354 unless your configuration specifies otherwise
2355 (@pxref{user-account-password, user account passwords}).
2356 @xref{After System Installation}, for what's next!
2357
2358
2359 @node After System Installation
2360 @section After System Installation
2361
2362 Success, you've now booted into Guix System! From then on, you can update the
2363 system whenever you want by running, say:
2364
2365 @example
2366 guix pull
2367 sudo guix system reconfigure /etc/config.scm
2368 @end example
2369
2370 @noindent
2371 This builds a new system generation with the latest packages and services
2372 (@pxref{Invoking guix system}). We recommend doing that regularly so that
2373 your system includes the latest security updates (@pxref{Security Updates}).
2374
2375 @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
2376 @quotation Note
2377 @cindex sudo vs. @command{guix pull}
2378 Note that @command{sudo guix} runs your user's @command{guix} command and
2379 @emph{not} root's, because @command{sudo} leaves @code{PATH} unchanged. To
2380 explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
2381 @end quotation
2382
2383 Join us on @code{#guix} on the Freenode IRC network or on
2384 @email{guix-devel@@gnu.org} to share your experience!
2385
2386
2387 @node Installing Guix in a VM
2388 @section Installing Guix in a Virtual Machine
2389
2390 @cindex virtual machine, Guix System installation
2391 @cindex virtual private server (VPS)
2392 @cindex VPS (virtual private server)
2393 If you'd like to install Guix System in a virtual machine (VM) or on a
2394 virtual private server (VPS) rather than on your beloved machine, this
2395 section is for you.
2396
2397 To boot a @uref{http://qemu.org/,QEMU} VM for installing Guix System in a
2398 disk image, follow these steps:
2399
2400 @enumerate
2401 @item
2402 First, retrieve and decompress the Guix system installation image as
2403 described previously (@pxref{USB Stick and DVD Installation}).
2404
2405 @item
2406 Create a disk image that will hold the installed system. To make a
2407 qcow2-formatted disk image, use the @command{qemu-img} command:
2408
2409 @example
2410 qemu-img create -f qcow2 guixsd.img 50G
2411 @end example
2412
2413 The resulting file will be much smaller than 50 GB (typically less than
2414 1 MB), but it will grow as the virtualized storage device is filled up.
2415
2416 @item
2417 Boot the USB installation image in an VM:
2418
2419 @example
2420 qemu-system-x86_64 -m 1024 -smp 1 \
2421 -net user -net nic,model=virtio -boot menu=on \
2422 -drive file=guix-system-install-@value{VERSION}.@var{system}.iso \
2423 -drive file=guixsd.img
2424 @end example
2425
2426 The ordering of the drives matters.
2427
2428 In the VM console, quickly press the @kbd{F12} key to enter the boot
2429 menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
2430 selection.
2431
2432 @item
2433 You're now root in the VM, proceed with the installation process.
2434 @xref{Preparing for Installation}, and follow the instructions.
2435 @end enumerate
2436
2437 Once installation is complete, you can boot the system that's on your
2438 @file{guixsd.img} image. @xref{Running Guix in a VM}, for how to do
2439 that.
2440
2441 @node Building the Installation Image
2442 @section Building the Installation Image
2443
2444 @cindex installation image
2445 The installation image described above was built using the @command{guix
2446 system} command, specifically:
2447
2448 @example
2449 guix system disk-image --file-system-type=iso9660 \
2450 gnu/system/install.scm
2451 @end example
2452
2453 Have a look at @file{gnu/system/install.scm} in the source tree,
2454 and see also @ref{Invoking guix system} for more information
2455 about the installation image.
2456
2457 @section Building the Installation Image for ARM Boards
2458
2459 Many ARM boards require a specific variant of the
2460 @uref{http://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
2461
2462 If you build a disk image and the bootloader is not available otherwise
2463 (on another boot drive etc), it's advisable to build an image that
2464 includes the bootloader, specifically:
2465
2466 @example
2467 guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
2468 @end example
2469
2470 @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
2471 board, a list of possible boards will be printed.
2472
2473 @c *********************************************************************
2474 @node Package Management
2475 @chapter Package Management
2476
2477 @cindex packages
2478 The purpose of GNU Guix is to allow users to easily install, upgrade, and
2479 remove software packages, without having to know about their build
2480 procedures or dependencies. Guix also goes beyond this obvious set of
2481 features.
2482
2483 This chapter describes the main features of Guix, as well as the
2484 package management tools it provides. Along with the command-line
2485 interface described below (@pxref{Invoking guix package, @code{guix
2486 package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
2487 emacs-guix, The Emacs-Guix Reference Manual}), after installing
2488 @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
2489 with it):
2490
2491 @example
2492 guix package -i emacs-guix
2493 @end example
2494
2495 @menu
2496 * Features:: How Guix will make your life brighter.
2497 * Invoking guix package:: Package installation, removal, etc.
2498 * Substitutes:: Downloading pre-built binaries.
2499 * Packages with Multiple Outputs:: Single source package, multiple outputs.
2500 * Invoking guix gc:: Running the garbage collector.
2501 * Invoking guix pull:: Fetching the latest Guix and distribution.
2502 * Channels:: Customizing the package collection.
2503 * Inferiors:: Interacting with another revision of Guix.
2504 * Invoking guix describe:: Display information about your Guix revision.
2505 * Invoking guix archive:: Exporting and importing store files.
2506 @end menu
2507
2508 @node Features
2509 @section Features
2510
2511 When using Guix, each package ends up in the @dfn{package store}, in its
2512 own directory---something that resembles
2513 @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
2514
2515 Instead of referring to these directories, users have their own
2516 @dfn{profile}, which points to the packages that they actually want to
2517 use. These profiles are stored within each user's home directory, at
2518 @code{$HOME/.guix-profile}.
2519
2520 For example, @code{alice} installs GCC 4.7.2. As a result,
2521 @file{/home/alice/.guix-profile/bin/gcc} points to
2522 @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
2523 @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
2524 simply continues to point to
2525 @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
2526 coexist on the same system without any interference.
2527
2528 The @command{guix package} command is the central tool to manage
2529 packages (@pxref{Invoking guix package}). It operates on the per-user
2530 profiles, and can be used @emph{with normal user privileges}.
2531
2532 @cindex transactions
2533 The command provides the obvious install, remove, and upgrade
2534 operations. Each invocation is actually a @emph{transaction}: either
2535 the specified operation succeeds, or nothing happens. Thus, if the
2536 @command{guix package} process is terminated during the transaction,
2537 or if a power outage occurs during the transaction, then the user's
2538 profile remains in its previous state, and remains usable.
2539
2540 In addition, any package transaction may be @emph{rolled back}. So, if,
2541 for example, an upgrade installs a new version of a package that turns
2542 out to have a serious bug, users may roll back to the previous instance
2543 of their profile, which was known to work well. Similarly, the global
2544 system configuration on Guix is subject to
2545 transactional upgrades and roll-back
2546 (@pxref{Using the Configuration System}).
2547
2548 All packages in the package store may be @emph{garbage-collected}.
2549 Guix can determine which packages are still referenced by user
2550 profiles, and remove those that are provably no longer referenced
2551 (@pxref{Invoking guix gc}). Users may also explicitly remove old
2552 generations of their profile so that the packages they refer to can be
2553 collected.
2554
2555 @cindex reproducibility
2556 @cindex reproducible builds
2557 Guix takes a @dfn{purely functional} approach to package
2558 management, as described in the introduction (@pxref{Introduction}).
2559 Each @file{/gnu/store} package directory name contains a hash of all the
2560 inputs that were used to build that package---compiler, libraries, build
2561 scripts, etc. This direct correspondence allows users to make sure a
2562 given package installation matches the current state of their
2563 distribution. It also helps maximize @dfn{build reproducibility}:
2564 thanks to the isolated build environments that are used, a given build
2565 is likely to yield bit-identical files when performed on different
2566 machines (@pxref{Invoking guix-daemon, container}).
2567
2568 @cindex substitutes
2569 This foundation allows Guix to support @dfn{transparent binary/source
2570 deployment}. When a pre-built binary for a @file{/gnu/store} item is
2571 available from an external source---a @dfn{substitute}, Guix just
2572 downloads it and unpacks it;
2573 otherwise, it builds the package from source, locally
2574 (@pxref{Substitutes}). Because build results are usually bit-for-bit
2575 reproducible, users do not have to trust servers that provide
2576 substitutes: they can force a local build and @emph{challenge} providers
2577 (@pxref{Invoking guix challenge}).
2578
2579 Control over the build environment is a feature that is also useful for
2580 developers. The @command{guix environment} command allows developers of
2581 a package to quickly set up the right development environment for their
2582 package, without having to manually install the dependencies of the
2583 package into their profile (@pxref{Invoking guix environment}).
2584
2585 @cindex replication, of software environments
2586 @cindex provenance tracking, of software artifacts
2587 All of Guix and its package definitions is version-controlled, and
2588 @command{guix pull} allows you to ``travel in time'' on the history of Guix
2589 itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
2590 Guix instance on a different machine or at a later point in time, which in
2591 turn allows you to @emph{replicate complete software environments}, while
2592 retaining precise @dfn{provenance tracking} of the software.
2593
2594 @node Invoking guix package
2595 @section Invoking @command{guix package}
2596
2597 @cindex installing packages
2598 @cindex removing packages
2599 @cindex package installation
2600 @cindex package removal
2601 The @command{guix package} command is the tool that allows users to
2602 install, upgrade, and remove packages, as well as rolling back to
2603 previous configurations. It operates only on the user's own profile,
2604 and works with normal user privileges (@pxref{Features}). Its syntax
2605 is:
2606
2607 @example
2608 guix package @var{options}
2609 @end example
2610 @cindex transactions
2611 Primarily, @var{options} specifies the operations to be performed during
2612 the transaction. Upon completion, a new profile is created, but
2613 previous @dfn{generations} of the profile remain available, should the user
2614 want to roll back.
2615
2616 For example, to remove @code{lua} and install @code{guile} and
2617 @code{guile-cairo} in a single transaction:
2618
2619 @example
2620 guix package -r lua -i guile guile-cairo
2621 @end example
2622
2623 @command{guix package} also supports a @dfn{declarative approach}
2624 whereby the user specifies the exact set of packages to be available and
2625 passes it @i{via} the @option{--manifest} option
2626 (@pxref{profile-manifest, @option{--manifest}}).
2627
2628 @cindex profile
2629 For each user, a symlink to the user's default profile is automatically
2630 created in @file{$HOME/.guix-profile}. This symlink always points to the
2631 current generation of the user's default profile. Thus, users can add
2632 @file{$HOME/.guix-profile/bin} to their @code{PATH} environment
2633 variable, and so on.
2634 @cindex search paths
2635 If you are not using the Guix System Distribution, consider adding the
2636 following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
2637 Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
2638 shells get all the right environment variable definitions:
2639
2640 @example
2641 GUIX_PROFILE="$HOME/.guix-profile" ; \
2642 source "$HOME/.guix-profile/etc/profile"
2643 @end example
2644
2645 In a multi-user setup, user profiles are stored in a place registered as
2646 a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
2647 to (@pxref{Invoking guix gc}). That directory is normally
2648 @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
2649 @var{localstatedir} is the value passed to @code{configure} as
2650 @code{--localstatedir}, and @var{user} is the user name. The
2651 @file{per-user} directory is created when @command{guix-daemon} is
2652 started, and the @var{user} sub-directory is created by @command{guix
2653 package}.
2654
2655 The @var{options} can be among the following:
2656
2657 @table @code
2658
2659 @item --install=@var{package} @dots{}
2660 @itemx -i @var{package} @dots{}
2661 Install the specified @var{package}s.
2662
2663 Each @var{package} may specify either a simple package name, such as
2664 @code{guile}, or a package name followed by an at-sign and version number,
2665 such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
2666 case, the newest version prefixed by @code{1.8} is selected.)
2667
2668 If no version number is specified, the
2669 newest available version will be selected. In addition, @var{package}
2670 may contain a colon, followed by the name of one of the outputs of the
2671 package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
2672 (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
2673 name (and optionally version) are searched for among the GNU
2674 distribution modules (@pxref{Package Modules}).
2675
2676 @cindex propagated inputs
2677 Sometimes packages have @dfn{propagated inputs}: these are dependencies
2678 that automatically get installed along with the required package
2679 (@pxref{package-propagated-inputs, @code{propagated-inputs} in
2680 @code{package} objects}, for information about propagated inputs in
2681 package definitions).
2682
2683 @anchor{package-cmd-propagated-inputs}
2684 An example is the GNU MPC library: its C header files refer to those of
2685 the GNU MPFR library, which in turn refer to those of the GMP library.
2686 Thus, when installing MPC, the MPFR and GMP libraries also get installed
2687 in the profile; removing MPC also removes MPFR and GMP---unless they had
2688 also been explicitly installed by the user.
2689
2690 Besides, packages sometimes rely on the definition of environment
2691 variables for their search paths (see explanation of
2692 @code{--search-paths} below). Any missing or possibly incorrect
2693 environment variable definitions are reported here.
2694
2695 @item --install-from-expression=@var{exp}
2696 @itemx -e @var{exp}
2697 Install the package @var{exp} evaluates to.
2698
2699 @var{exp} must be a Scheme expression that evaluates to a
2700 @code{<package>} object. This option is notably useful to disambiguate
2701 between same-named variants of a package, with expressions such as
2702 @code{(@@ (gnu packages base) guile-final)}.
2703
2704 Note that this option installs the first output of the specified
2705 package, which may be insufficient when needing a specific output of a
2706 multiple-output package.
2707
2708 @item --install-from-file=@var{file}
2709 @itemx -f @var{file}
2710 Install the package that the code within @var{file} evaluates to.
2711
2712 As an example, @var{file} might contain a definition like this
2713 (@pxref{Defining Packages}):
2714
2715 @example
2716 @verbatiminclude package-hello.scm
2717 @end example
2718
2719 Developers may find it useful to include such a @file{guix.scm} file
2720 in the root of their project source tree that can be used to test
2721 development snapshots and create reproducible development environments
2722 (@pxref{Invoking guix environment}).
2723
2724 @item --remove=@var{package} @dots{}
2725 @itemx -r @var{package} @dots{}
2726 Remove the specified @var{package}s.
2727
2728 As for @code{--install}, each @var{package} may specify a version number
2729 and/or output name in addition to the package name. For instance,
2730 @code{-r glibc:debug} would remove the @code{debug} output of
2731 @code{glibc}.
2732
2733 @item --upgrade[=@var{regexp} @dots{}]
2734 @itemx -u [@var{regexp} @dots{}]
2735 @cindex upgrading packages
2736 Upgrade all the installed packages. If one or more @var{regexp}s are
2737 specified, upgrade only installed packages whose name matches a
2738 @var{regexp}. Also see the @code{--do-not-upgrade} option below.
2739
2740 Note that this upgrades package to the latest version of packages found
2741 in the distribution currently installed. To update your distribution,
2742 you should regularly run @command{guix pull} (@pxref{Invoking guix
2743 pull}).
2744
2745 @item --do-not-upgrade[=@var{regexp} @dots{}]
2746 When used together with the @code{--upgrade} option, do @emph{not}
2747 upgrade any packages whose name matches a @var{regexp}. For example, to
2748 upgrade all packages in the current profile except those containing the
2749 substring ``emacs'':
2750
2751 @example
2752 $ guix package --upgrade . --do-not-upgrade emacs
2753 @end example
2754
2755 @item @anchor{profile-manifest}--manifest=@var{file}
2756 @itemx -m @var{file}
2757 @cindex profile declaration
2758 @cindex profile manifest
2759 Create a new generation of the profile from the manifest object
2760 returned by the Scheme code in @var{file}.
2761
2762 This allows you to @emph{declare} the profile's contents rather than
2763 constructing it through a sequence of @code{--install} and similar
2764 commands. The advantage is that @var{file} can be put under version
2765 control, copied to different machines to reproduce the same profile, and
2766 so on.
2767
2768 @c FIXME: Add reference to (guix profile) documentation when available.
2769 @var{file} must return a @dfn{manifest} object, which is roughly a list
2770 of packages:
2771
2772 @findex packages->manifest
2773 @example
2774 (use-package-modules guile emacs)
2775
2776 (packages->manifest
2777 (list emacs
2778 guile-2.0
2779 ;; Use a specific package output.
2780 (list guile-2.0 "debug")))
2781 @end example
2782
2783 @findex specifications->manifest
2784 In this example we have to know which modules define the @code{emacs}
2785 and @code{guile-2.0} variables to provide the right
2786 @code{use-package-modules} line, which can be cumbersome. We can
2787 instead provide regular package specifications and let
2788 @code{specifications->manifest} look up the corresponding package
2789 objects, like this:
2790
2791 @example
2792 (specifications->manifest
2793 '("emacs" "guile@@2.2" "guile@@2.2:debug"))
2794 @end example
2795
2796 @item --roll-back
2797 @cindex rolling back
2798 @cindex undoing transactions
2799 @cindex transactions, undoing
2800 Roll back to the previous @dfn{generation} of the profile---i.e., undo
2801 the last transaction.
2802
2803 When combined with options such as @code{--install}, roll back occurs
2804 before any other actions.
2805
2806 When rolling back from the first generation that actually contains
2807 installed packages, the profile is made to point to the @dfn{zeroth
2808 generation}, which contains no files apart from its own metadata.
2809
2810 After having rolled back, installing, removing, or upgrading packages
2811 overwrites previous future generations. Thus, the history of the
2812 generations in a profile is always linear.
2813
2814 @item --switch-generation=@var{pattern}
2815 @itemx -S @var{pattern}
2816 @cindex generations
2817 Switch to a particular generation defined by @var{pattern}.
2818
2819 @var{pattern} may be either a generation number or a number prefixed
2820 with ``+'' or ``-''. The latter means: move forward/backward by a
2821 specified number of generations. For example, if you want to return to
2822 the latest generation after @code{--roll-back}, use
2823 @code{--switch-generation=+1}.
2824
2825 The difference between @code{--roll-back} and
2826 @code{--switch-generation=-1} is that @code{--switch-generation} will
2827 not make a zeroth generation, so if a specified generation does not
2828 exist, the current generation will not be changed.
2829
2830 @item --search-paths[=@var{kind}]
2831 @cindex search paths
2832 Report environment variable definitions, in Bash syntax, that may be
2833 needed in order to use the set of installed packages. These environment
2834 variables are used to specify @dfn{search paths} for files used by some
2835 of the installed packages.
2836
2837 For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
2838 environment variables to be defined so it can look for headers and
2839 libraries in the user's profile (@pxref{Environment Variables,,, gcc,
2840 Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
2841 library are installed in the profile, then @code{--search-paths} will
2842 suggest setting these variables to @code{@var{profile}/include} and
2843 @code{@var{profile}/lib}, respectively.
2844
2845 The typical use case is to define these environment variables in the
2846 shell:
2847
2848 @example
2849 $ eval `guix package --search-paths`
2850 @end example
2851
2852 @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
2853 meaning that the returned environment variable definitions will either
2854 be exact settings, or prefixes or suffixes of the current value of these
2855 variables. When omitted, @var{kind} defaults to @code{exact}.
2856
2857 This option can also be used to compute the @emph{combined} search paths
2858 of several profiles. Consider this example:
2859
2860 @example
2861 $ guix package -p foo -i guile
2862 $ guix package -p bar -i guile-json
2863 $ guix package -p foo -p bar --search-paths
2864 @end example
2865
2866 The last command above reports about the @code{GUILE_LOAD_PATH}
2867 variable, even though, taken individually, neither @file{foo} nor
2868 @file{bar} would lead to that recommendation.
2869
2870
2871 @item --profile=@var{profile}
2872 @itemx -p @var{profile}
2873 Use @var{profile} instead of the user's default profile.
2874
2875 @cindex collisions, in a profile
2876 @cindex colliding packages in profiles
2877 @cindex profile collisions
2878 @item --allow-collisions
2879 Allow colliding packages in the new profile. Use at your own risk!
2880
2881 By default, @command{guix package} reports as an error @dfn{collisions}
2882 in the profile. Collisions happen when two or more different versions
2883 or variants of a given package end up in the profile.
2884
2885 @item --bootstrap
2886 Use the bootstrap Guile to build the profile. This option is only
2887 useful to distribution developers.
2888
2889 @end table
2890
2891 In addition to these actions, @command{guix package} supports the
2892 following options to query the current state of a profile, or the
2893 availability of packages:
2894
2895 @table @option
2896
2897 @item --search=@var{regexp}
2898 @itemx -s @var{regexp}
2899 @cindex searching for packages
2900 List the available packages whose name, synopsis, or description matches
2901 @var{regexp} (in a case-insensitive fashion), sorted by relevance.
2902 Print all the metadata of matching packages in
2903 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
2904 GNU recutils manual}).
2905
2906 This allows specific fields to be extracted using the @command{recsel}
2907 command, for instance:
2908
2909 @example
2910 $ guix package -s malloc | recsel -p name,version,relevance
2911 name: jemalloc
2912 version: 4.5.0
2913 relevance: 6
2914
2915 name: glibc
2916 version: 2.25
2917 relevance: 1
2918
2919 name: libgc
2920 version: 7.6.0
2921 relevance: 1
2922 @end example
2923
2924 Similarly, to show the name of all the packages available under the
2925 terms of the GNU@tie{}LGPL version 3:
2926
2927 @example
2928 $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
2929 name: elfutils
2930
2931 name: gmp
2932 @dots{}
2933 @end example
2934
2935 It is also possible to refine search results using several @code{-s}
2936 flags. For example, the following command returns a list of board
2937 games:
2938
2939 @example
2940 $ guix package -s '\<board\>' -s game | recsel -p name
2941 name: gnubg
2942 @dots{}
2943 @end example
2944
2945 If we were to omit @code{-s game}, we would also get software packages
2946 that deal with printed circuit boards; removing the angle brackets
2947 around @code{board} would further add packages that have to do with
2948 keyboards.
2949
2950 And now for a more elaborate example. The following command searches
2951 for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
2952 libraries, and prints the name and synopsis of the matching packages:
2953
2954 @example
2955 $ guix package -s crypto -s library | \
2956 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
2957 @end example
2958
2959 @noindent
2960 @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
2961 information on @dfn{selection expressions} for @code{recsel -e}.
2962
2963 @item --show=@var{package}
2964 Show details about @var{package}, taken from the list of available packages, in
2965 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
2966 recutils manual}).
2967
2968 @example
2969 $ guix package --show=python | recsel -p name,version
2970 name: python
2971 version: 2.7.6
2972
2973 name: python
2974 version: 3.3.5
2975 @end example
2976
2977 You may also specify the full name of a package to only get details about a
2978 specific version of it:
2979 @example
2980 $ guix package --show=python@@3.4 | recsel -p name,version
2981 name: python
2982 version: 3.4.3
2983 @end example
2984
2985
2986
2987 @item --list-installed[=@var{regexp}]
2988 @itemx -I [@var{regexp}]
2989 List the currently installed packages in the specified profile, with the
2990 most recently installed packages shown last. When @var{regexp} is
2991 specified, list only installed packages whose name matches @var{regexp}.
2992
2993 For each installed package, print the following items, separated by
2994 tabs: the package name, its version string, the part of the package that
2995 is installed (for instance, @code{out} for the default output,
2996 @code{include} for its headers, etc.), and the path of this package in
2997 the store.
2998
2999 @item --list-available[=@var{regexp}]
3000 @itemx -A [@var{regexp}]
3001 List packages currently available in the distribution for this system
3002 (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
3003 installed packages whose name matches @var{regexp}.
3004
3005 For each package, print the following items separated by tabs: its name,
3006 its version string, the parts of the package (@pxref{Packages with
3007 Multiple Outputs}), and the source location of its definition.
3008
3009 @item --list-generations[=@var{pattern}]
3010 @itemx -l [@var{pattern}]
3011 @cindex generations
3012 Return a list of generations along with their creation dates; for each
3013 generation, show the installed packages, with the most recently
3014 installed packages shown last. Note that the zeroth generation is never
3015 shown.
3016
3017 For each installed package, print the following items, separated by
3018 tabs: the name of a package, its version string, the part of the package
3019 that is installed (@pxref{Packages with Multiple Outputs}), and the
3020 location of this package in the store.
3021
3022 When @var{pattern} is used, the command returns only matching
3023 generations. Valid patterns include:
3024
3025 @itemize
3026 @item @emph{Integers and comma-separated integers}. Both patterns denote
3027 generation numbers. For instance, @code{--list-generations=1} returns
3028 the first one.
3029
3030 And @code{--list-generations=1,8,2} outputs three generations in the
3031 specified order. Neither spaces nor trailing commas are allowed.
3032
3033 @item @emph{Ranges}. @code{--list-generations=2..9} prints the
3034 specified generations and everything in between. Note that the start of
3035 a range must be smaller than its end.
3036
3037 It is also possible to omit the endpoint. For example,
3038 @code{--list-generations=2..}, returns all generations starting from the
3039 second one.
3040
3041 @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
3042 or months by passing an integer along with the first letter of the
3043 duration. For example, @code{--list-generations=20d} lists generations
3044 that are up to 20 days old.
3045 @end itemize
3046
3047 @item --delete-generations[=@var{pattern}]
3048 @itemx -d [@var{pattern}]
3049 When @var{pattern} is omitted, delete all generations except the current
3050 one.
3051
3052 This command accepts the same patterns as @option{--list-generations}.
3053 When @var{pattern} is specified, delete the matching generations. When
3054 @var{pattern} specifies a duration, generations @emph{older} than the
3055 specified duration match. For instance, @code{--delete-generations=1m}
3056 deletes generations that are more than one month old.
3057
3058 If the current generation matches, it is @emph{not} deleted. Also, the
3059 zeroth generation is never deleted.
3060
3061 Note that deleting generations prevents rolling back to them.
3062 Consequently, this command must be used with care.
3063
3064 @end table
3065
3066 Finally, since @command{guix package} may actually start build
3067 processes, it supports all the common build options (@pxref{Common Build
3068 Options}). It also supports package transformation options, such as
3069 @option{--with-source} (@pxref{Package Transformation Options}).
3070 However, note that package transformations are lost when upgrading; to
3071 preserve transformations across upgrades, you should define your own
3072 package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
3073 (@pxref{Defining Packages}).
3074
3075 @node Substitutes
3076 @section Substitutes
3077
3078 @cindex substitutes
3079 @cindex pre-built binaries
3080 Guix supports transparent source/binary deployment, which means that it
3081 can either build things locally, or download pre-built items from a
3082 server, or both. We call these pre-built items @dfn{substitutes}---they
3083 are substitutes for local build results. In many cases, downloading a
3084 substitute is much faster than building things locally.
3085
3086 Substitutes can be anything resulting from a derivation build
3087 (@pxref{Derivations}). Of course, in the common case, they are
3088 pre-built package binaries, but source tarballs, for instance, which
3089 also result from derivation builds, can be available as substitutes.
3090
3091 @menu
3092 * Official Substitute Server:: One particular source of substitutes.
3093 * Substitute Server Authorization:: How to enable or disable substitutes.
3094 * Substitute Authentication:: How Guix verifies substitutes.
3095 * Proxy Settings:: How to get substitutes via proxy.
3096 * Substitution Failure:: What happens when substitution fails.
3097 * On Trusting Binaries:: How can you trust that binary blob?
3098 @end menu
3099
3100 @node Official Substitute Server
3101 @subsection Official Substitute Server
3102
3103 @cindex hydra
3104 @cindex build farm
3105 The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
3106 that builds packages from Guix continuously for some
3107 architectures, and makes them available as substitutes. This is the
3108 default source of substitutes; it can be overridden by passing the
3109 @option{--substitute-urls} option either to @command{guix-daemon}
3110 (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
3111 or to client tools such as @command{guix package}
3112 (@pxref{client-substitute-urls,, client @option{--substitute-urls}
3113 option}).
3114
3115 Substitute URLs can be either HTTP or HTTPS.
3116 HTTPS is recommended because communications are encrypted; conversely,
3117 using HTTP makes all communications visible to an eavesdropper, who
3118 could use the information gathered to determine, for instance, whether
3119 your system has unpatched security vulnerabilities.
3120
3121 Substitutes from the official build farm are enabled by default when
3122 using the Guix System Distribution (@pxref{GNU Distribution}). However,
3123 they are disabled by default when using Guix on a foreign distribution,
3124 unless you have explicitly enabled them via one of the recommended
3125 installation steps (@pxref{Installation}). The following paragraphs
3126 describe how to enable or disable substitutes for the official build
3127 farm; the same procedure can also be used to enable substitutes for any
3128 other substitute server.
3129
3130 @node Substitute Server Authorization
3131 @subsection Substitute Server Authorization
3132
3133 @cindex security
3134 @cindex substitutes, authorization thereof
3135 @cindex access control list (ACL), for substitutes
3136 @cindex ACL (access control list), for substitutes
3137 To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
3138 mirror thereof, you
3139 must add its public key to the access control list (ACL) of archive
3140 imports, using the @command{guix archive} command (@pxref{Invoking guix
3141 archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
3142 be compromised and to serve genuine substitutes.
3143
3144 The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
3145 @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
3146 the installation prefix of Guix. If you installed Guix from source,
3147 make sure you checked the GPG signature of
3148 @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
3149 Then, you can run something like this:
3150
3151 @example
3152 # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
3153 @end example
3154
3155 @quotation Note
3156 Similarly, the @file{hydra.gnu.org.pub} file contains the public key
3157 of an independent build farm also run by the project, reachable at
3158 @indicateurl{https://mirror.hydra.gnu.org}.
3159 @end quotation
3160
3161 Once this is in place, the output of a command like @code{guix build}
3162 should change from something like:
3163
3164 @example
3165 $ guix build emacs --dry-run
3166 The following derivations would be built:
3167 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
3168 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
3169 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
3170 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
3171 @dots{}
3172 @end example
3173
3174 @noindent
3175 to something like:
3176
3177 @example
3178 $ guix build emacs --dry-run
3179 112.3 MB would be downloaded:
3180 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
3181 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
3182 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
3183 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
3184 @dots{}
3185 @end example
3186
3187 @noindent
3188 This indicates that substitutes from @code{@value{SUBSTITUTE-SERVER}} are usable and
3189 will be downloaded, when possible, for future builds.
3190
3191 @cindex substitutes, how to disable
3192 The substitute mechanism can be disabled globally by running
3193 @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
3194 guix-daemon}). It can also be disabled temporarily by passing the
3195 @code{--no-substitutes} option to @command{guix package}, @command{guix
3196 build}, and other command-line tools.
3197
3198 @node Substitute Authentication
3199 @subsection Substitute Authentication
3200
3201 @cindex digital signatures
3202 Guix detects and raises an error when attempting to use a substitute
3203 that has been tampered with. Likewise, it ignores substitutes that are
3204 not signed, or that are not signed by one of the keys listed in the ACL.
3205
3206 There is one exception though: if an unauthorized server provides
3207 substitutes that are @emph{bit-for-bit identical} to those provided by
3208 an authorized server, then the unauthorized server becomes eligible for
3209 downloads. For example, assume we have chosen two substitute servers
3210 with this option:
3211
3212 @example
3213 --substitute-urls="https://a.example.org https://b.example.org"
3214 @end example
3215
3216 @noindent
3217 @cindex reproducible builds
3218 If the ACL contains only the key for @code{b.example.org}, and if
3219 @code{a.example.org} happens to serve the @emph{exact same} substitutes,
3220 then Guix will download substitutes from @code{a.example.org} because it
3221 comes first in the list and can be considered a mirror of
3222 @code{b.example.org}. In practice, independent build machines usually
3223 produce the same binaries, thanks to bit-reproducible builds (see
3224 below).
3225
3226 When using HTTPS, the server's X.509 certificate is @emph{not} validated
3227 (in other words, the server is not authenticated), contrary to what
3228 HTTPS clients such as Web browsers usually do. This is because Guix
3229 authenticates substitute information itself, as explained above, which
3230 is what we care about (whereas X.509 certificates are about
3231 authenticating bindings between domain names and public keys.)
3232
3233 @node Proxy Settings
3234 @subsection Proxy Settings
3235
3236 @vindex http_proxy
3237 Substitutes are downloaded over HTTP or HTTPS.
3238 The @code{http_proxy} environment
3239 variable can be set in the environment of @command{guix-daemon} and is
3240 honored for downloads of substitutes. Note that the value of
3241 @code{http_proxy} in the environment where @command{guix build},
3242 @command{guix package}, and other client commands are run has
3243 @emph{absolutely no effect}.
3244
3245 @node Substitution Failure
3246 @subsection Substitution Failure
3247
3248 Even when a substitute for a derivation is available, sometimes the
3249 substitution attempt will fail. This can happen for a variety of
3250 reasons: the substitute server might be offline, the substitute may
3251 recently have been deleted, the connection might have been interrupted,
3252 etc.
3253
3254 When substitutes are enabled and a substitute for a derivation is
3255 available, but the substitution attempt fails, Guix will attempt to
3256 build the derivation locally depending on whether or not
3257 @code{--fallback} was given (@pxref{fallback-option,, common build
3258 option @code{--fallback}}). Specifically, if @code{--fallback} was
3259 omitted, then no local build will be performed, and the derivation is
3260 considered to have failed. However, if @code{--fallback} was given,
3261 then Guix will attempt to build the derivation locally, and the success
3262 or failure of the derivation depends on the success or failure of the
3263 local build. Note that when substitutes are disabled or no substitute
3264 is available for the derivation in question, a local build will
3265 @emph{always} be performed, regardless of whether or not
3266 @code{--fallback} was given.
3267
3268 To get an idea of how many substitutes are available right now, you can
3269 try running the @command{guix weather} command (@pxref{Invoking guix
3270 weather}). This command provides statistics on the substitutes provided
3271 by a server.
3272
3273 @node On Trusting Binaries
3274 @subsection On Trusting Binaries
3275
3276 @cindex trust, of pre-built binaries
3277 Today, each individual's control over their own computing is at the
3278 mercy of institutions, corporations, and groups with enough power and
3279 determination to subvert the computing infrastructure and exploit its
3280 weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
3281 convenient, we encourage users to also build on their own, or even run
3282 their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
3283 interesting target. One way to help is by publishing the software you
3284 build using @command{guix publish} so that others have one more choice
3285 of server to download substitutes from (@pxref{Invoking guix publish}).
3286
3287 Guix has the foundations to maximize build reproducibility
3288 (@pxref{Features}). In most cases, independent builds of a given
3289 package or derivation should yield bit-identical results. Thus, through
3290 a diverse set of independent package builds, we can strengthen the
3291 integrity of our systems. The @command{guix challenge} command aims to
3292 help users assess substitute servers, and to assist developers in
3293 finding out about non-deterministic package builds (@pxref{Invoking guix
3294 challenge}). Similarly, the @option{--check} option of @command{guix
3295 build} allows users to check whether previously-installed substitutes
3296 are genuine by rebuilding them locally (@pxref{build-check,
3297 @command{guix build --check}}).
3298
3299 In the future, we want Guix to have support to publish and retrieve
3300 binaries to/from other users, in a peer-to-peer fashion. If you would
3301 like to discuss this project, join us on @email{guix-devel@@gnu.org}.
3302
3303 @node Packages with Multiple Outputs
3304 @section Packages with Multiple Outputs
3305
3306 @cindex multiple-output packages
3307 @cindex package outputs
3308 @cindex outputs
3309
3310 Often, packages defined in Guix have a single @dfn{output}---i.e., the
3311 source package leads to exactly one directory in the store. When running
3312 @command{guix package -i glibc}, one installs the default output of the
3313 GNU libc package; the default output is called @code{out}, but its name
3314 can be omitted as shown in this command. In this particular case, the
3315 default output of @code{glibc} contains all the C header files, shared
3316 libraries, static libraries, Info documentation, and other supporting
3317 files.
3318
3319 Sometimes it is more appropriate to separate the various types of files
3320 produced from a single source package into separate outputs. For
3321 instance, the GLib C library (used by GTK+ and related packages)
3322 installs more than 20 MiB of reference documentation as HTML pages.
3323 To save space for users who do not need it, the documentation goes to a
3324 separate output, called @code{doc}. To install the main GLib output,
3325 which contains everything but the documentation, one would run:
3326
3327 @example
3328 guix package -i glib
3329 @end example
3330
3331 @cindex documentation
3332 The command to install its documentation is:
3333
3334 @example
3335 guix package -i glib:doc
3336 @end example
3337
3338 Some packages install programs with different ``dependency footprints''.
3339 For instance, the WordNet package installs both command-line tools and
3340 graphical user interfaces (GUIs). The former depend solely on the C
3341 library, whereas the latter depend on Tcl/Tk and the underlying X
3342 libraries. In this case, we leave the command-line tools in the default
3343 output, whereas the GUIs are in a separate output. This allows users
3344 who do not need the GUIs to save space. The @command{guix size} command
3345 can help find out about such situations (@pxref{Invoking guix size}).
3346 @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
3347
3348 There are several such multiple-output packages in the GNU distribution.
3349 Other conventional output names include @code{lib} for libraries and
3350 possibly header files, @code{bin} for stand-alone programs, and
3351 @code{debug} for debugging information (@pxref{Installing Debugging
3352 Files}). The outputs of a packages are listed in the third column of
3353 the output of @command{guix package --list-available} (@pxref{Invoking
3354 guix package}).
3355
3356
3357 @node Invoking guix gc
3358 @section Invoking @command{guix gc}
3359
3360 @cindex garbage collector
3361 @cindex disk space
3362 Packages that are installed, but not used, may be @dfn{garbage-collected}.
3363 The @command{guix gc} command allows users to explicitly run the garbage
3364 collector to reclaim space from the @file{/gnu/store} directory. It is
3365 the @emph{only} way to remove files from @file{/gnu/store}---removing
3366 files or directories manually may break it beyond repair!
3367
3368 @cindex GC roots
3369 @cindex garbage collector roots
3370 The garbage collector has a set of known @dfn{roots}: any file under
3371 @file{/gnu/store} reachable from a root is considered @dfn{live} and
3372 cannot be deleted; any other file is considered @dfn{dead} and may be
3373 deleted. The set of garbage collector roots (``GC roots'' for short)
3374 includes default user profiles; by default, the symlinks under
3375 @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
3376 added with @command{guix build --root}, for example (@pxref{Invoking
3377 guix build}). The @command{guix gc --list-roots} command lists them.
3378
3379 Prior to running @code{guix gc --collect-garbage} to make space, it is
3380 often useful to remove old generations from user profiles; that way, old
3381 package builds referenced by those generations can be reclaimed. This
3382 is achieved by running @code{guix package --delete-generations}
3383 (@pxref{Invoking guix package}).
3384
3385 Our recommendation is to run a garbage collection periodically, or when
3386 you are short on disk space. For instance, to guarantee that at least
3387 5@tie{}GB are available on your disk, simply run:
3388
3389 @example
3390 guix gc -F 5G
3391 @end example
3392
3393 It is perfectly safe to run as a non-interactive periodic job
3394 (@pxref{Scheduled Job Execution}, for how to set up such a job).
3395 Running @command{guix gc} with no arguments will collect as
3396 much garbage as it can, but that is often inconvenient: you may find
3397 yourself having to rebuild or re-download software that is ``dead'' from
3398 the GC viewpoint but that is necessary to build other pieces of
3399 software---e.g., the compiler tool chain.
3400
3401 The @command{guix gc} command has three modes of operation: it can be
3402 used to garbage-collect any dead files (the default), to delete specific
3403 files (the @code{--delete} option), to print garbage-collector
3404 information, or for more advanced queries. The garbage collection
3405 options are as follows:
3406
3407 @table @code
3408 @item --collect-garbage[=@var{min}]
3409 @itemx -C [@var{min}]
3410 Collect garbage---i.e., unreachable @file{/gnu/store} files and
3411 sub-directories. This is the default operation when no option is
3412 specified.
3413
3414 When @var{min} is given, stop once @var{min} bytes have been collected.
3415 @var{min} may be a number of bytes, or it may include a unit as a
3416 suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
3417 (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
3418
3419 When @var{min} is omitted, collect all the garbage.
3420
3421 @item --free-space=@var{free}
3422 @itemx -F @var{free}
3423 Collect garbage until @var{free} space is available under
3424 @file{/gnu/store}, if possible; @var{free} denotes storage space, such
3425 as @code{500MiB}, as described above.
3426
3427 When @var{free} or more is already available in @file{/gnu/store}, do
3428 nothing and exit immediately.
3429
3430 @item --delete-generations[=@var{duration}]
3431 @itemx -d [@var{duration}]
3432 Before starting the garbage collection process, delete all the generations
3433 older than @var{duration}, for all the user profiles; when run as root, this
3434 applies to all the profiles @emph{of all the users}.
3435
3436 For example, this command deletes all the generations of all your profiles
3437 that are older than 2 months (except generations that are current), and then
3438 proceeds to free space until at least 10 GiB are available:
3439
3440 @example
3441 guix gc -d 2m -F 10G
3442 @end example
3443
3444 @item --delete
3445 @itemx -D
3446 Attempt to delete all the store files and directories specified as
3447 arguments. This fails if some of the files are not in the store, or if
3448 they are still live.
3449
3450 @item --list-failures
3451 List store items corresponding to cached build failures.
3452
3453 This prints nothing unless the daemon was started with
3454 @option{--cache-failures} (@pxref{Invoking guix-daemon,
3455 @option{--cache-failures}}).
3456
3457 @item --list-roots
3458 List the GC roots owned by the user; when run as root, list @emph{all} the GC
3459 roots.
3460
3461 @item --clear-failures
3462 Remove the specified store items from the failed-build cache.
3463
3464 Again, this option only makes sense when the daemon is started with
3465 @option{--cache-failures}. Otherwise, it does nothing.
3466
3467 @item --list-dead
3468 Show the list of dead files and directories still present in the
3469 store---i.e., files and directories no longer reachable from any root.
3470
3471 @item --list-live
3472 Show the list of live store files and directories.
3473
3474 @end table
3475
3476 In addition, the references among existing store files can be queried:
3477
3478 @table @code
3479
3480 @item --references
3481 @itemx --referrers
3482 @cindex package dependencies
3483 List the references (respectively, the referrers) of store files given
3484 as arguments.
3485
3486 @item --requisites
3487 @itemx -R
3488 @cindex closure
3489 List the requisites of the store files passed as arguments. Requisites
3490 include the store files themselves, their references, and the references
3491 of these, recursively. In other words, the returned list is the
3492 @dfn{transitive closure} of the store files.
3493
3494 @xref{Invoking guix size}, for a tool to profile the size of the closure
3495 of an element. @xref{Invoking guix graph}, for a tool to visualize
3496 the graph of references.
3497
3498 @item --derivers
3499 @cindex derivation
3500 Return the derivation(s) leading to the given store items
3501 (@pxref{Derivations}).
3502
3503 For example, this command:
3504
3505 @example
3506 guix gc --derivers `guix package -I ^emacs$ | cut -f4`
3507 @end example
3508
3509 @noindent
3510 returns the @file{.drv} file(s) leading to the @code{emacs} package
3511 installed in your profile.
3512
3513 Note that there may be zero matching @file{.drv} files, for instance
3514 because these files have been garbage-collected. There can also be more
3515 than one matching @file{.drv} due to fixed-output derivations.
3516 @end table
3517
3518 Lastly, the following options allow you to check the integrity of the
3519 store and to control disk usage.
3520
3521 @table @option
3522
3523 @item --verify[=@var{options}]
3524 @cindex integrity, of the store
3525 @cindex integrity checking
3526 Verify the integrity of the store.
3527
3528 By default, make sure that all the store items marked as valid in the
3529 database of the daemon actually exist in @file{/gnu/store}.
3530
3531 When provided, @var{options} must be a comma-separated list containing one
3532 or more of @code{contents} and @code{repair}.
3533
3534 When passing @option{--verify=contents}, the daemon computes the
3535 content hash of each store item and compares it against its hash in the
3536 database. Hash mismatches are reported as data corruptions. Because it
3537 traverses @emph{all the files in the store}, this command can take a
3538 long time, especially on systems with a slow disk drive.
3539
3540 @cindex repairing the store
3541 @cindex corruption, recovering from
3542 Using @option{--verify=repair} or @option{--verify=contents,repair}
3543 causes the daemon to try to repair corrupt store items by fetching
3544 substitutes for them (@pxref{Substitutes}). Because repairing is not
3545 atomic, and thus potentially dangerous, it is available only to the
3546 system administrator. A lightweight alternative, when you know exactly
3547 which items in the store are corrupt, is @command{guix build --repair}
3548 (@pxref{Invoking guix build}).
3549
3550 @item --optimize
3551 @cindex deduplication
3552 Optimize the store by hard-linking identical files---this is
3553 @dfn{deduplication}.
3554
3555 The daemon performs deduplication after each successful build or archive
3556 import, unless it was started with @code{--disable-deduplication}
3557 (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
3558 this option is primarily useful when the daemon was running with
3559 @code{--disable-deduplication}.
3560
3561 @end table
3562
3563 @node Invoking guix pull
3564 @section Invoking @command{guix pull}
3565
3566 @cindex upgrading Guix
3567 @cindex updating Guix
3568 @cindex @command{guix pull}
3569 @cindex pull
3570 Packages are installed or upgraded to the latest version available in
3571 the distribution currently available on your local machine. To update
3572 that distribution, along with the Guix tools, you must run @command{guix
3573 pull}: the command downloads the latest Guix source code and package
3574 descriptions, and deploys it. Source code is downloaded from a
3575 @uref{https://git-scm.com, Git} repository, by default the official
3576 GNU@tie{}Guix repository, though this can be customized.
3577
3578 On completion, @command{guix package} will use packages and package
3579 versions from this just-retrieved copy of Guix. Not only that, but all
3580 the Guix commands and Scheme modules will also be taken from that latest
3581 version. New @command{guix} sub-commands added by the update also
3582 become available.
3583
3584 Any user can update their Guix copy using @command{guix pull}, and the
3585 effect is limited to the user who run @command{guix pull}. For
3586 instance, when user @code{root} runs @command{guix pull}, this has no
3587 effect on the version of Guix that user @code{alice} sees, and vice
3588 versa.
3589
3590 The result of running @command{guix pull} is a @dfn{profile} available
3591 under @file{~/.config/guix/current} containing the latest Guix. Thus,
3592 make sure to add it to the beginning of your search path so that you use
3593 the latest version, and similarly for the Info manual
3594 (@pxref{Documentation}):
3595
3596 @example
3597 export PATH="$HOME/.config/guix/current/bin:$PATH"
3598 export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
3599 @end example
3600
3601 The @code{--list-generations} or @code{-l} option lists past generations
3602 produced by @command{guix pull}, along with details about their provenance:
3603
3604 @example
3605 $ guix pull -l
3606 Generation 1 Jun 10 2018 00:18:18
3607 guix 65956ad
3608 repository URL: https://git.savannah.gnu.org/git/guix.git
3609 branch: origin/master
3610 commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
3611
3612 Generation 2 Jun 11 2018 11:02:49
3613 guix e0cc7f6
3614 repository URL: https://git.savannah.gnu.org/git/guix.git
3615 branch: origin/master
3616 commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
3617 2 new packages: keepalived, libnfnetlink
3618 6 packages upgraded: emacs-nix-mode@@2.0.4,
3619 guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
3620 heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
3621
3622 Generation 3 Jun 13 2018 23:31:07 (current)
3623 guix 844cc1c
3624 repository URL: https://git.savannah.gnu.org/git/guix.git
3625 branch: origin/master
3626 commit: 844cc1c8f394f03b404c5bb3aee086922373490c
3627 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
3628 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
3629 @end example
3630
3631 @xref{Invoking guix describe, @command{guix describe}}, for other ways to
3632 describe the current status of Guix.
3633
3634 This @code{~/.config/guix/current} profile works like any other profile
3635 created by @command{guix package} (@pxref{Invoking guix package}). That
3636 is, you can list generations, roll back to the previous
3637 generation---i.e., the previous Guix---and so on:
3638
3639 @example
3640 $ guix package -p ~/.config/guix/current --roll-back
3641 switched from generation 3 to 2
3642 $ guix package -p ~/.config/guix/current --delete-generations=1
3643 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
3644 @end example
3645
3646 The @command{guix pull} command is usually invoked with no arguments,
3647 but it supports the following options:
3648
3649 @table @code
3650 @item --url=@var{url}
3651 @itemx --commit=@var{commit}
3652 @itemx --branch=@var{branch}
3653 Download code for the @code{guix} channel from the specified @var{url}, at the
3654 given @var{commit} (a valid Git commit ID represented as a hexadecimal
3655 string), or @var{branch}.
3656
3657 @cindex @file{channels.scm}, configuration file
3658 @cindex configuration file for channels
3659 These options are provided for convenience, but you can also specify your
3660 configuration in the @file{~/.config/guix/channels.scm} file or using the
3661 @option{--channels} option (see below).
3662
3663 @item --channels=@var{file}
3664 @itemx -C @var{file}
3665 Read the list of channels from @var{file} instead of
3666 @file{~/.config/guix/channels.scm}. @var{file} must contain Scheme code that
3667 evaluates to a list of channel objects. @xref{Channels}, for more
3668 information.
3669
3670 @item --news
3671 @itemx -N
3672 Display the list of packages added or upgraded since the previous generation.
3673
3674 This is the same information as displayed upon @command{guix pull} completion,
3675 but without ellipses; it is also similar to the output of @command{guix pull
3676 -l} for the last generation (see below).
3677
3678 @item --list-generations[=@var{pattern}]
3679 @itemx -l [@var{pattern}]
3680 List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
3681 is provided, the subset of generations that match @var{pattern}.
3682 The syntax of @var{pattern} is the same as with @code{guix package
3683 --list-generations} (@pxref{Invoking guix package}).
3684
3685 @xref{Invoking guix describe}, for a way to display information about the
3686 current generation only.
3687
3688 @item --profile=@var{profile}
3689 @itemx -p @var{profile}
3690 Use @var{profile} instead of @file{~/.config/guix/current}.
3691
3692 @item --dry-run
3693 @itemx -n
3694 Show which channel commit(s) would be used and what would be built or
3695 substituted but do not actually do it.
3696
3697 @item --system=@var{system}
3698 @itemx -s @var{system}
3699 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
3700 the system type of the build host.
3701
3702 @item --verbose
3703 Produce verbose output, writing build logs to the standard error output.
3704
3705 @item --bootstrap
3706 Use the bootstrap Guile to build the latest Guix. This option is only
3707 useful to Guix developers.
3708 @end table
3709
3710 The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
3711 repository and branch to pull from, as well as @emph{additional} repositories
3712 containing package modules that should be deployed. @xref{Channels}, for more
3713 information.
3714
3715 In addition, @command{guix pull} supports all the common build options
3716 (@pxref{Common Build Options}).
3717
3718 @node Channels
3719 @section Channels
3720
3721 @cindex channels
3722 @cindex @file{channels.scm}, configuration file
3723 @cindex configuration file for channels
3724 @cindex @command{guix pull}, configuration file
3725 @cindex configuration of @command{guix pull}
3726 Guix and its package collection are updated by running @command{guix pull}
3727 (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
3728 deploys Guix itself from the official GNU@tie{}Guix repository. This can be
3729 customized by defining @dfn{channels} in the
3730 @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
3731 of a Git repository to be deployed, and @command{guix pull} can be instructed
3732 to pull from one or more channels. In other words, channels can be used to
3733 @emph{customize} and to @emph{extend} Guix, as we will see below.
3734
3735 @subsection Using a Custom Guix Channel
3736
3737 The channel called @code{guix} specifies where Guix itself---its command-line
3738 tools as well as its package collection---should be downloaded. For instance,
3739 suppose you want to update from your own copy of the Guix repository at
3740 @code{example.org}, and specifically the @code{super-hacks} branch, you can
3741 write in @code{~/.config/guix/channels.scm} this specification:
3742
3743 @lisp
3744 ;; Tell 'guix pull' to use my own repo.
3745 (list (channel
3746 (name 'guix)
3747 (url "https://example.org/my-guix.git")
3748 (branch "super-hacks")))
3749 @end lisp
3750
3751 @noindent
3752 From there on, @command{guix pull} will fetch code from the @code{super-hacks}
3753 branch of the repository at @code{example.org}.
3754
3755 @subsection Specifying Additional Channels
3756
3757 @cindex extending the package collection (channels)
3758 @cindex personal packages (channels)
3759 @cindex channels, for personal packages
3760 You can also specify @emph{additional channels} to pull from. Let's say you
3761 have a bunch of custom package variants or personal packages that you think
3762 would make little sense to contribute to the Guix project, but would like to
3763 have these packages transparently available to you at the command line. You
3764 would first write modules containing those package definitions (@pxref{Package
3765 Modules}), maintain them in a Git repository, and then you and anyone else can
3766 use it as an additional channel to get packages from. Neat, no?
3767
3768 @c What follows stems from discussions at
3769 @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
3770 @c earlier discussions on guix-devel@gnu.org.
3771 @quotation Warning
3772 Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
3773 publish your personal channel to the world, we would like to share a few words
3774 of caution:
3775
3776 @itemize
3777 @item
3778 Before publishing a channel, please consider contributing your package
3779 definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
3780 to free software of all sorts, and packages in Guix proper are readily
3781 available to all Guix users and benefit from the project's quality assurance
3782 process.
3783
3784 @item
3785 When you maintain package definitions outside Guix, we, Guix developers,
3786 consider that @emph{the compatibility burden is on you}. Remember that
3787 package modules and package definitions are just Scheme code that uses various
3788 programming interfaces (APIs). We want to remain free to change these APIs to
3789 keep improving Guix, possibly in ways that break your channel. We never
3790 change APIs gratuitously, but we will @emph{not} commit to freezing APIs
3791 either.
3792
3793 @item
3794 Corollary: if you're using an external channel and that channel breaks, please
3795 @emph{report the issue to the channel authors}, not to the Guix project.
3796 @end itemize
3797
3798 You've been warned! Having said this, we believe external channels are a
3799 practical way to exert your freedom to augment Guix' package collection and to
3800 share your improvements, which are basic tenets of
3801 @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
3802 email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
3803 @end quotation
3804
3805 To use a channel, write @code{~/.config/guix/channels.scm} to instruct
3806 @command{guix pull} to pull from it @emph{in addition} to the default Guix
3807 channel(s):
3808
3809 @vindex %default-channels
3810 @lisp
3811 ;; Add my personal packages to those Guix provides.
3812 (cons (channel
3813 (name 'my-personal-packages)
3814 (url "https://example.org/personal-packages.git"))
3815 %default-channels)
3816 @end lisp
3817
3818 @noindent
3819 Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
3820 add a channel the list of channels that the variable @code{%default-channels}
3821 is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
3822 Manual}). With this file in place, @command{guix pull} builds not only Guix
3823 but also the package modules from your own repository. The result in
3824 @file{~/.config/guix/current} is the union of Guix with your own package
3825 modules:
3826
3827 @example
3828 $ guix pull --list-generations
3829 @dots{}
3830 Generation 19 Aug 27 2018 16:20:48
3831 guix d894ab8
3832 repository URL: https://git.savannah.gnu.org/git/guix.git
3833 branch: master
3834 commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
3835 my-personal-packages dd3df5e
3836 repository URL: https://example.org/personal-packages.git
3837 branch: master
3838 commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
3839 11 new packages: my-gimp, my-emacs-with-cool-features, @dots{}
3840 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
3841 @end example
3842
3843 @noindent
3844 The output of @command{guix pull} above shows that Generation@tie{}19 includes
3845 both Guix and packages from the @code{my-personal-packages} channel. Among
3846 the new and upgraded packages that are listed, some like @code{my-gimp} and
3847 @code{my-emacs-with-cool-features} might come from
3848 @code{my-personal-packages}, while others come from the Guix default channel.
3849
3850 To create a channel, create a Git repository containing your own package
3851 modules and make it available. The repository can contain anything, but a
3852 useful channel will contain Guile modules that export packages. Once you
3853 start using a channel, Guix will behave as if the root directory of that
3854 channel's Git repository has been added to the Guile load path (@pxref{Load
3855 Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
3856 contains a file at @file{my-packages/my-tools.scm} that defines a Guile
3857 module, then the module will be available under the name @code{(my-packages
3858 my-tools)}, and you will be able to use it like any other module
3859 (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
3860
3861 @cindex dependencies, channels
3862 @cindex meta-data, channels
3863 @subsection Declaring Channel Dependencies
3864
3865 Channel authors may decide to augment a package collection provided by other
3866 channels. They can declare their channel to be dependent on other channels in
3867 a meta-data file @file{.guix-channel}, which is to be placed in the root of
3868 the channel repository.
3869
3870 The meta-data file should contain a simple S-expression like this:
3871
3872 @lisp
3873 (channel
3874 (version 0)
3875 (dependencies
3876 (channel
3877 (name some-collection)
3878 (url "https://example.org/first-collection.git"))
3879 (channel
3880 (name some-other-collection)
3881 (url "https://example.org/second-collection.git")
3882 (branch "testing"))))
3883 @end lisp
3884
3885 In the above example this channel is declared to depend on two other channels,
3886 which will both be fetched automatically. The modules provided by the channel
3887 will be compiled in an environment where the modules of all these declared
3888 channels are available.
3889
3890 For the sake of reliability and maintainability, you should avoid dependencies
3891 on channels that you don't control, and you should aim to keep the number of
3892 dependencies to a minimum.
3893
3894 @subsection Replicating Guix
3895
3896 @cindex pinning, channels
3897 @cindex replicating Guix
3898 @cindex reproducibility, of Guix
3899 The @command{guix pull --list-generations} output above shows precisely which
3900 commits were used to build this instance of Guix. We can thus replicate it,
3901 say, on another machine, by providing a channel specification in
3902 @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
3903
3904 @lisp
3905 ;; Deploy specific commits of my channels of interest.
3906 (list (channel
3907 (name 'guix)
3908 (url "https://git.savannah.gnu.org/git/guix.git")
3909 (commit "d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300"))
3910 (channel
3911 (name 'my-personal-packages)
3912 (url "https://example.org/personal-packages.git")
3913 (branch "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
3914 @end lisp
3915
3916 The @command{guix describe --format=channels} command can even generate this
3917 list of channels directly (@pxref{Invoking guix describe}).
3918
3919 At this point the two machines run the @emph{exact same Guix}, with access to
3920 the @emph{exact same packages}. The output of @command{guix build gimp} on
3921 one machine will be exactly the same, bit for bit, as the output of the same
3922 command on the other machine. It also means both machines have access to all
3923 the source code of Guix and, transitively, to all the source code of every
3924 package it defines.
3925
3926 This gives you super powers, allowing you to track the provenance of binary
3927 artifacts with very fine grain, and to reproduce software environments at
3928 will---some sort of ``meta reproducibility'' capabilities, if you will.
3929 @xref{Inferiors}, for another way to take advantage of these super powers.
3930
3931 @node Inferiors
3932 @section Inferiors
3933
3934 @c TODO: Remove this once we're more confident about API stability.
3935 @quotation Note
3936 The functionality described here is a ``technology preview'' as of version
3937 @value{VERSION}. As such, the interface is subject to change.
3938 @end quotation
3939
3940 @cindex inferiors
3941 @cindex composition of Guix revisions
3942 Sometimes you might need to mix packages from the revision of Guix you're
3943 currently running with packages available in a different revision of Guix.
3944 Guix @dfn{inferiors} allow you to achieve that by composing different Guix
3945 revisions in arbitrary ways.
3946
3947 @cindex inferior packages
3948 Technically, an ``inferior'' is essentially a separate Guix process connected
3949 to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
3950 @code{(guix inferior)} module allows you to create inferiors and to
3951 communicate with them. It also provides a high-level interface to browse and
3952 manipulate the packages that an inferior provides---@dfn{inferior packages}.
3953
3954 When combined with channels (@pxref{Channels}), inferiors provide a simple way
3955 to interact with a separate revision of Guix. For example, let's assume you
3956 want to install in your profile the current @code{guile} package, along with
3957 the @code{guile-json} as it existed in an older revision of Guix---perhaps
3958 because the newer @code{guile-json} has an incompatible API and you want to
3959 run your code against the old API@. To do that, you could write a manifest for
3960 use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
3961 manifest, you would create an inferior for that old Guix revision you care
3962 about, and you would look up the @code{guile-json} package in the inferior:
3963
3964 @lisp
3965 (use-modules (guix inferior) (guix channels)
3966 (srfi srfi-1)) ;for 'first'
3967
3968 (define channels
3969 ;; This is the old revision from which we want to
3970 ;; extract guile-json.
3971 (list (channel
3972 (name 'guix)
3973 (url "https://git.savannah.gnu.org/git/guix.git")
3974 (commit
3975 "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
3976
3977 (define inferior
3978 ;; An inferior representing the above revision.
3979 (inferior-for-channels channels))
3980
3981 ;; Now create a manifest with the current "guile" package
3982 ;; and the old "guile-json" package.
3983 (packages->manifest
3984 (list (first (lookup-inferior-packages inferior "guile-json"))
3985 (specification->package "guile")))
3986 @end lisp
3987
3988 On its first run, @command{guix package --manifest} might have to build the
3989 channel you specified before it can create the inferior; subsequent runs will
3990 be much faster because the Guix revision will be cached.
3991
3992 The @code{(guix inferior)} module provides the following procedures to open an
3993 inferior:
3994
3995 @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
3996 [#:cache-directory] [#:ttl]
3997 Return an inferior for @var{channels}, a list of channels. Use the cache at
3998 @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
3999 This procedure opens a new connection to the build daemon.
4000
4001 As a side effect, this procedure may build or substitute binaries for
4002 @var{channels}, which can take time.
4003 @end deffn
4004
4005 @deffn {Scheme Procedure} open-inferior @var{directory} @
4006 [#:command "bin/guix"]
4007 Open the inferior Guix in @var{directory}, running
4008 @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
4009 the inferior could not be launched.
4010 @end deffn
4011
4012 @cindex inferior packages
4013 The procedures listed below allow you to obtain and manipulate inferior
4014 packages.
4015
4016 @deffn {Scheme Procedure} inferior-packages @var{inferior}
4017 Return the list of packages known to @var{inferior}.
4018 @end deffn
4019
4020 @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
4021 [@var{version}]
4022 Return the sorted list of inferior packages matching @var{name} in
4023 @var{inferior}, with highest version numbers first. If @var{version} is true,
4024 return only packages with a version number prefixed by @var{version}.
4025 @end deffn
4026
4027 @deffn {Scheme Procedure} inferior-package? @var{obj}
4028 Return true if @var{obj} is an inferior package.
4029 @end deffn
4030
4031 @deffn {Scheme Procedure} inferior-package-name @var{package}
4032 @deffnx {Scheme Procedure} inferior-package-version @var{package}
4033 @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
4034 @deffnx {Scheme Procedure} inferior-package-description @var{package}
4035 @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
4036 @deffnx {Scheme Procedure} inferior-package-location @var{package}
4037 @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
4038 @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
4039 @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
4040 @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
4041 @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
4042 @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
4043 @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
4044 These procedures are the counterpart of package record accessors
4045 (@pxref{package Reference}). Most of them work by querying the inferior
4046 @var{package} comes from, so the inferior must still be live when you call
4047 these procedures.
4048 @end deffn
4049
4050 Inferior packages can be used transparently like any other package or
4051 file-like object in G-expressions (@pxref{G-Expressions}). They are also
4052 transparently handled by the @code{packages->manifest} procedure, which is
4053 commonly use in manifests (@pxref{Invoking guix package, the
4054 @option{--manifest} option of @command{guix package}}). Thus you can insert
4055 an inferior package pretty much anywhere you would insert a regular package:
4056 in manifests, in the @code{packages} field of your @code{operating-system}
4057 declaration, and so on.
4058
4059 @node Invoking guix describe
4060 @section Invoking @command{guix describe}
4061
4062 @cindex reproducibility
4063 @cindex replicating Guix
4064 Often you may want to answer questions like: ``Which revision of Guix am I
4065 using?'' or ``Which channels am I using?'' This is useful information in many
4066 situations: if you want to @emph{replicate} an environment on a different
4067 machine or user account, if you want to report a bug or to determine what
4068 change in the channels you are using caused it, or if you want to record your
4069 system state for reproducibility purposes. The @command{guix describe}
4070 command answers these questions.
4071
4072 When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
4073 displays the channel(s) that it was built from, including their repository URL
4074 and commit IDs (@pxref{Channels}):
4075
4076 @example
4077 $ guix describe
4078 Generation 10 Sep 03 2018 17:32:44 (current)
4079 guix e0fa68c
4080 repository URL: https://git.savannah.gnu.org/git/guix.git
4081 branch: master
4082 commit: e0fa68c7718fffd33d81af415279d6ddb518f727
4083 @end example
4084
4085 If you're familiar with the Git version control system, this is similar in
4086 spirit to @command{git describe}; the output is also similar to that of
4087 @command{guix pull --list-generations}, but limited to the current generation
4088 (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
4089 the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
4090 information is all it takes to describe the revision of Guix you're using, and
4091 also to replicate it.
4092
4093 To make it easier to replicate Guix, @command{guix describe} can also be asked
4094 to return a list of channels instead of the human-readable description above:
4095
4096 @example
4097 $ guix describe -f channels
4098 (list (channel
4099 (name 'guix)
4100 (url "https://git.savannah.gnu.org/git/guix.git")
4101 (commit
4102 "e0fa68c7718fffd33d81af415279d6ddb518f727")))
4103 @end example
4104
4105 @noindent
4106 You can save this to a file and feed it to @command{guix pull -C} on some
4107 other machine or at a later point in time, which will instantiate @emph{this
4108 exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
4109 From there on, since you're able to deploy the same revision of Guix, you can
4110 just as well @emph{replicate a complete software environment}. We humbly
4111 think that this is @emph{awesome}, and we hope you'll like it too!
4112
4113 The details of the options supported by @command{guix describe} are as
4114 follows:
4115
4116 @table @code
4117 @item --format=@var{format}
4118 @itemx -f @var{format}
4119 Produce output in the specified @var{format}, one of:
4120
4121 @table @code
4122 @item human
4123 produce human-readable output;
4124 @item channels
4125 produce a list of channel specifications that can be passed to @command{guix
4126 pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
4127 guix pull});
4128 @item json
4129 @cindex JSON
4130 produce a list of channel specifications in JSON format;
4131 @item recutils
4132 produce a list of channel specifications in Recutils format.
4133 @end table
4134
4135 @item --profile=@var{profile}
4136 @itemx -p @var{profile}
4137 Display information about @var{profile}.
4138 @end table
4139
4140 @node Invoking guix archive
4141 @section Invoking @command{guix archive}
4142
4143 @cindex @command{guix archive}
4144 @cindex archive
4145 The @command{guix archive} command allows users to @dfn{export} files
4146 from the store into a single archive, and to later @dfn{import} them on
4147 a machine that runs Guix.
4148 In particular, it allows store files to be transferred from one machine
4149 to the store on another machine.
4150
4151 @quotation Note
4152 If you're looking for a way to produce archives in a format suitable for
4153 tools other than Guix, @pxref{Invoking guix pack}.
4154 @end quotation
4155
4156 @cindex exporting store items
4157 To export store files as an archive to standard output, run:
4158
4159 @example
4160 guix archive --export @var{options} @var{specifications}...
4161 @end example
4162
4163 @var{specifications} may be either store file names or package
4164 specifications, as for @command{guix package} (@pxref{Invoking guix
4165 package}). For instance, the following command creates an archive
4166 containing the @code{gui} output of the @code{git} package and the main
4167 output of @code{emacs}:
4168
4169 @example
4170 guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
4171 @end example
4172
4173 If the specified packages are not built yet, @command{guix archive}
4174 automatically builds them. The build process may be controlled with the
4175 common build options (@pxref{Common Build Options}).
4176
4177 To transfer the @code{emacs} package to a machine connected over SSH,
4178 one would run:
4179
4180 @example
4181 guix archive --export -r emacs | ssh the-machine guix archive --import
4182 @end example
4183
4184 @noindent
4185 Similarly, a complete user profile may be transferred from one machine
4186 to another like this:
4187
4188 @example
4189 guix archive --export -r $(readlink -f ~/.guix-profile) | \
4190 ssh the-machine guix-archive --import
4191 @end example
4192
4193 @noindent
4194 However, note that, in both examples, all of @code{emacs} and the
4195 profile as well as all of their dependencies are transferred (due to
4196 @code{-r}), regardless of what is already available in the store on the
4197 target machine. The @code{--missing} option can help figure out which
4198 items are missing from the target store. The @command{guix copy}
4199 command simplifies and optimizes this whole process, so this is probably
4200 what you should use in this case (@pxref{Invoking guix copy}).
4201
4202 @cindex nar, archive format
4203 @cindex normalized archive (nar)
4204 Archives are stored in the ``normalized archive'' or ``nar'' format, which is
4205 comparable in spirit to `tar', but with differences
4206 that make it more appropriate for our purposes. First, rather than
4207 recording all Unix metadata for each file, the nar format only mentions
4208 the file type (regular, directory, or symbolic link); Unix permissions
4209 and owner/group are dismissed. Second, the order in which directory
4210 entries are stored always follows the order of file names according to
4211 the C locale collation order. This makes archive production fully
4212 deterministic.
4213
4214 When exporting, the daemon digitally signs the contents of the archive,
4215 and that digital signature is appended. When importing, the daemon
4216 verifies the signature and rejects the import in case of an invalid
4217 signature or if the signing key is not authorized.
4218 @c FIXME: Add xref to daemon doc about signatures.
4219
4220 The main options are:
4221
4222 @table @code
4223 @item --export
4224 Export the specified store files or packages (see below.) Write the
4225 resulting archive to the standard output.
4226
4227 Dependencies are @emph{not} included in the output, unless
4228 @code{--recursive} is passed.
4229
4230 @item -r
4231 @itemx --recursive
4232 When combined with @code{--export}, this instructs @command{guix
4233 archive} to include dependencies of the given items in the archive.
4234 Thus, the resulting archive is self-contained: it contains the closure
4235 of the exported store items.
4236
4237 @item --import
4238 Read an archive from the standard input, and import the files listed
4239 therein into the store. Abort if the archive has an invalid digital
4240 signature, or if it is signed by a public key not among the authorized
4241 keys (see @code{--authorize} below.)
4242
4243 @item --missing
4244 Read a list of store file names from the standard input, one per line,
4245 and write on the standard output the subset of these files missing from
4246 the store.
4247
4248 @item --generate-key[=@var{parameters}]
4249 @cindex signing, archives
4250 Generate a new key pair for the daemon. This is a prerequisite before
4251 archives can be exported with @code{--export}. Note that this operation
4252 usually takes time, because it needs to gather enough entropy to
4253 generate the key pair.
4254
4255 The generated key pair is typically stored under @file{/etc/guix}, in
4256 @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
4257 key, which must be kept secret.) When @var{parameters} is omitted,
4258 an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
4259 versions before 1.6.0, it is a 4096-bit RSA key.
4260 Alternatively, @var{parameters} can specify
4261 @code{genkey} parameters suitable for Libgcrypt (@pxref{General
4262 public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
4263 Libgcrypt Reference Manual}).
4264
4265 @item --authorize
4266 @cindex authorizing, archives
4267 Authorize imports signed by the public key passed on standard input.
4268 The public key must be in ``s-expression advanced format''---i.e., the
4269 same format as the @file{signing-key.pub} file.
4270
4271 The list of authorized keys is kept in the human-editable file
4272 @file{/etc/guix/acl}. The file contains
4273 @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
4274 s-expressions''} and is structured as an access-control list in the
4275 @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
4276 (SPKI)}.
4277
4278 @item --extract=@var{directory}
4279 @itemx -x @var{directory}
4280 Read a single-item archive as served by substitute servers
4281 (@pxref{Substitutes}) and extract it to @var{directory}. This is a
4282 low-level operation needed in only very narrow use cases; see below.
4283
4284 For example, the following command extracts the substitute for Emacs
4285 served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
4286
4287 @example
4288 $ wget -O - \
4289 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-emacs-24.5 \
4290 | bunzip2 | guix archive -x /tmp/emacs
4291 @end example
4292
4293 Single-item archives are different from multiple-item archives produced
4294 by @command{guix archive --export}; they contain a single store item,
4295 and they do @emph{not} embed a signature. Thus this operation does
4296 @emph{no} signature verification and its output should be considered
4297 unsafe.
4298
4299 The primary purpose of this operation is to facilitate inspection of
4300 archive contents coming from possibly untrusted substitute servers.
4301
4302 @end table
4303
4304
4305 @c *********************************************************************
4306 @node Development
4307 @chapter Development
4308
4309 @cindex software development
4310 If you are a software developer, Guix provides tools that you should find
4311 helpful---independently of the language you're developing in. This is what
4312 this chapter is about.
4313
4314 The @command{guix environment} command provides a convenient way to set up
4315 @dfn{development environments} containing all the dependencies and tools
4316 necessary to work on the software package of your choice. The @command{guix
4317 pack} command allows you to create @dfn{application bundles} that can be
4318 easily distributed to users who do not run Guix.
4319
4320 @menu
4321 * Invoking guix environment:: Setting up development environments.
4322 * Invoking guix pack:: Creating software bundles.
4323 @end menu
4324
4325 @node Invoking guix environment
4326 @section Invoking @command{guix environment}
4327
4328 @cindex reproducible build environments
4329 @cindex development environments
4330 @cindex @command{guix environment}
4331 @cindex environment, package build environment
4332 The purpose of @command{guix environment} is to assist hackers in
4333 creating reproducible development environments without polluting their
4334 package profile. The @command{guix environment} tool takes one or more
4335 packages, builds all of their inputs, and creates a shell
4336 environment to use them.
4337
4338 The general syntax is:
4339
4340 @example
4341 guix environment @var{options} @var{package}@dots{}
4342 @end example
4343
4344 The following example spawns a new shell set up for the development of
4345 GNU@tie{}Guile:
4346
4347 @example
4348 guix environment guile
4349 @end example
4350
4351 If the needed dependencies are not built yet, @command{guix environment}
4352 automatically builds them. The environment of the new shell is an augmented
4353 version of the environment that @command{guix environment} was run in.
4354 It contains the necessary search paths for building the given package
4355 added to the existing environment variables. To create a ``pure''
4356 environment, in which the original environment variables have been unset,
4357 use the @code{--pure} option@footnote{Users sometimes wrongfully augment
4358 environment variables such as @code{PATH} in their @file{~/.bashrc}
4359 file. As a consequence, when @code{guix environment} launches it, Bash
4360 may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
4361 environment variables. It is an error to define such environment
4362 variables in @file{.bashrc}; instead, they should be defined in
4363 @file{.bash_profile}, which is sourced only by log-in shells.
4364 @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
4365 details on Bash start-up files.}.
4366
4367 @vindex GUIX_ENVIRONMENT
4368 @command{guix environment} defines the @code{GUIX_ENVIRONMENT}
4369 variable in the shell it spawns; its value is the file name of the
4370 profile of this environment. This allows users to, say, define a
4371 specific prompt for development environments in their @file{.bashrc}
4372 (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
4373
4374 @example
4375 if [ -n "$GUIX_ENVIRONMENT" ]
4376 then
4377 export PS1="\u@@\h \w [dev]\$ "
4378 fi
4379 @end example
4380
4381 @noindent
4382 ...@: or to browse the profile:
4383
4384 @example
4385 $ ls "$GUIX_ENVIRONMENT/bin"
4386 @end example
4387
4388 Additionally, more than one package may be specified, in which case the
4389 union of the inputs for the given packages are used. For example, the
4390 command below spawns a shell where all of the dependencies of both Guile
4391 and Emacs are available:
4392
4393 @example
4394 guix environment guile emacs
4395 @end example
4396
4397 Sometimes an interactive shell session is not desired. An arbitrary
4398 command may be invoked by placing the @code{--} token to separate the
4399 command from the rest of the arguments:
4400
4401 @example
4402 guix environment guile -- make -j4
4403 @end example
4404
4405 In other situations, it is more convenient to specify the list of
4406 packages needed in the environment. For example, the following command
4407 runs @command{python} from an environment containing Python@tie{}2.7 and
4408 NumPy:
4409
4410 @example
4411 guix environment --ad-hoc python2-numpy python-2.7 -- python
4412 @end example
4413
4414 Furthermore, one might want the dependencies of a package and also some
4415 additional packages that are not build-time or runtime dependencies, but
4416 are useful when developing nonetheless. Because of this, the
4417 @code{--ad-hoc} flag is positional. Packages appearing before
4418 @code{--ad-hoc} are interpreted as packages whose dependencies will be
4419 added to the environment. Packages appearing after are interpreted as
4420 packages that will be added to the environment directly. For example,
4421 the following command creates a Guix development environment that
4422 additionally includes Git and strace:
4423
4424 @example
4425 guix environment guix --ad-hoc git strace
4426 @end example
4427
4428 Sometimes it is desirable to isolate the environment as much as
4429 possible, for maximal purity and reproducibility. In particular, when
4430 using Guix on a host distro that is not Guix System, it is desirable to
4431 prevent access to @file{/usr/bin} and other system-wide resources from
4432 the development environment. For example, the following command spawns
4433 a Guile REPL in a ``container'' where only the store and the current
4434 working directory are mounted:
4435
4436 @example
4437 guix environment --ad-hoc --container guile -- guile
4438 @end example
4439
4440 @quotation Note
4441 The @code{--container} option requires Linux-libre 3.19 or newer.
4442 @end quotation
4443
4444 The available options are summarized below.
4445
4446 @table @code
4447 @item --root=@var{file}
4448 @itemx -r @var{file}
4449 @cindex persistent environment
4450 @cindex garbage collector root, for environments
4451 Make @var{file} a symlink to the profile for this environment, and
4452 register it as a garbage collector root.
4453
4454 This is useful if you want to protect your environment from garbage
4455 collection, to make it ``persistent''.
4456
4457 When this option is omitted, the environment is protected from garbage
4458 collection only for the duration of the @command{guix environment}
4459 session. This means that next time you recreate the same environment,
4460 you could have to rebuild or re-download packages. @xref{Invoking guix
4461 gc}, for more on GC roots.
4462
4463 @item --expression=@var{expr}
4464 @itemx -e @var{expr}
4465 Create an environment for the package or list of packages that
4466 @var{expr} evaluates to.
4467
4468 For example, running:
4469
4470 @example
4471 guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
4472 @end example
4473
4474 starts a shell with the environment for this specific variant of the
4475 PETSc package.
4476
4477 Running:
4478
4479 @example
4480 guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
4481 @end example
4482
4483 starts a shell with all the base system packages available.
4484
4485 The above commands only use the default output of the given packages.
4486 To select other outputs, two element tuples can be specified:
4487
4488 @example
4489 guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
4490 @end example
4491
4492 @item --load=@var{file}
4493 @itemx -l @var{file}
4494 Create an environment for the package or list of packages that the code
4495 within @var{file} evaluates to.
4496
4497 As an example, @var{file} might contain a definition like this
4498 (@pxref{Defining Packages}):
4499
4500 @example
4501 @verbatiminclude environment-gdb.scm
4502 @end example
4503
4504 @item --manifest=@var{file}
4505 @itemx -m @var{file}
4506 Create an environment for the packages contained in the manifest object
4507 returned by the Scheme code in @var{file}.
4508
4509 This is similar to the same-named option in @command{guix package}
4510 (@pxref{profile-manifest, @option{--manifest}}) and uses the same
4511 manifest files.
4512
4513 @item --ad-hoc
4514 Include all specified packages in the resulting environment, as if an
4515 @i{ad hoc} package were defined with them as inputs. This option is
4516 useful for quickly creating an environment without having to write a
4517 package expression to contain the desired inputs.
4518
4519 For instance, the command:
4520
4521 @example
4522 guix environment --ad-hoc guile guile-sdl -- guile
4523 @end example
4524
4525 runs @command{guile} in an environment where Guile and Guile-SDL are
4526 available.
4527
4528 Note that this example implicitly asks for the default output of
4529 @code{guile} and @code{guile-sdl}, but it is possible to ask for a
4530 specific output---e.g., @code{glib:bin} asks for the @code{bin} output
4531 of @code{glib} (@pxref{Packages with Multiple Outputs}).
4532
4533 This option may be composed with the default behavior of @command{guix
4534 environment}. Packages appearing before @code{--ad-hoc} are interpreted
4535 as packages whose dependencies will be added to the environment, the
4536 default behavior. Packages appearing after are interpreted as packages
4537 that will be added to the environment directly.
4538
4539 @item --pure
4540 Unset existing environment variables when building the new environment, except
4541 those specified with @option{--preserve} (see below.) This has the effect of
4542 creating an environment in which search paths only contain package inputs.
4543
4544 @item --preserve=@var{regexp}
4545 @itemx -E @var{regexp}
4546 When used alongside @option{--pure}, preserve the environment variables
4547 matching @var{regexp}---in other words, put them on a ``white list'' of
4548 environment variables that must be preserved. This option can be repeated
4549 several times.
4550
4551 @example
4552 guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
4553 -- mpirun @dots{}
4554 @end example
4555
4556 This example runs @command{mpirun} in a context where the only environment
4557 variables defined are @code{PATH}, environment variables whose name starts
4558 with @code{SLURM}, as well as the usual ``precious'' variables (@code{HOME},
4559 @code{USER}, etc.)
4560
4561 @item --search-paths
4562 Display the environment variable definitions that make up the
4563 environment.
4564
4565 @item --system=@var{system}
4566 @itemx -s @var{system}
4567 Attempt to build for @var{system}---e.g., @code{i686-linux}.
4568
4569 @item --container
4570 @itemx -C
4571 @cindex container
4572 Run @var{command} within an isolated container. The current working
4573 directory outside the container is mapped inside the container.
4574 Additionally, unless overridden with @code{--user}, a dummy home
4575 directory is created that matches the current user's home directory, and
4576 @file{/etc/passwd} is configured accordingly.
4577
4578 The spawned process runs as the current user outside the container. Inside
4579 the container, it has the same UID and GID as the current user, unless
4580 @option{--user} is passed (see below.)
4581
4582 @item --network
4583 @itemx -N
4584 For containers, share the network namespace with the host system.
4585 Containers created without this flag only have access to the loopback
4586 device.
4587
4588 @item --link-profile
4589 @itemx -P
4590 For containers, link the environment profile to
4591 @file{~/.guix-profile} within the container. This is equivalent to
4592 running the command @command{ln -s $GUIX_ENVIRONMENT ~/.guix-profile}
4593 within the container. Linking will fail and abort the environment if
4594 the directory already exists, which will certainly be the case if
4595 @command{guix environment} was invoked in the user's home directory.
4596
4597 Certain packages are configured to look in
4598 @code{~/.guix-profile} for configuration files and data;@footnote{For
4599 example, the @code{fontconfig} package inspects
4600 @file{~/.guix-profile/share/fonts} for additional fonts.}
4601 @code{--link-profile} allows these programs to behave as expected within
4602 the environment.
4603
4604 @item --user=@var{user}
4605 @itemx -u @var{user}
4606 For containers, use the username @var{user} in place of the current
4607 user. The generated @file{/etc/passwd} entry within the container will
4608 contain the name @var{user}, the home directory will be
4609 @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
4610 the UID and GID inside the container are 1000. @var{user}
4611 need not exist on the system.
4612
4613 Additionally, any shared or exposed path (see @code{--share} and
4614 @code{--expose} respectively) whose target is within the current user's
4615 home directory will be remapped relative to @file{/home/USER}; this
4616 includes the automatic mapping of the current working directory.
4617
4618 @example
4619 # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
4620 cd $HOME/wd
4621 guix environment --container --user=foo \
4622 --expose=$HOME/test \
4623 --expose=/tmp/target=$HOME/target
4624 @end example
4625
4626 While this will limit the leaking of user identity through home paths
4627 and each of the user fields, this is only one useful component of a
4628 broader privacy/anonymity solution---not one in and of itself.
4629
4630 @item --expose=@var{source}[=@var{target}]
4631 For containers, expose the file system @var{source} from the host system
4632 as the read-only file system @var{target} within the container. If
4633 @var{target} is not specified, @var{source} is used as the target mount
4634 point in the container.
4635
4636 The example below spawns a Guile REPL in a container in which the user's
4637 home directory is accessible read-only via the @file{/exchange}
4638 directory:
4639
4640 @example
4641 guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
4642 @end example
4643
4644 @item --share=@var{source}[=@var{target}]
4645 For containers, share the file system @var{source} from the host system
4646 as the writable file system @var{target} within the container. If
4647 @var{target} is not specified, @var{source} is used as the target mount
4648 point in the container.
4649
4650 The example below spawns a Guile REPL in a container in which the user's
4651 home directory is accessible for both reading and writing via the
4652 @file{/exchange} directory:
4653
4654 @example
4655 guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
4656 @end example
4657 @end table
4658
4659 @command{guix environment}
4660 also supports all of the common build options that @command{guix
4661 build} supports (@pxref{Common Build Options}) as well as package
4662 transformation options (@pxref{Package Transformation Options}).
4663
4664 @node Invoking guix pack
4665 @section Invoking @command{guix pack}
4666
4667 Occasionally you want to pass software to people who are not (yet!)
4668 lucky enough to be using Guix. You'd tell them to run @command{guix
4669 package -i @var{something}}, but that's not possible in this case. This
4670 is where @command{guix pack} comes in.
4671
4672 @quotation Note
4673 If you are looking for ways to exchange binaries among machines that
4674 already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
4675 publish}, and @ref{Invoking guix archive}.
4676 @end quotation
4677
4678 @cindex pack
4679 @cindex bundle
4680 @cindex application bundle
4681 @cindex software bundle
4682 The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
4683 @dfn{software bundle}: it creates a tarball or some other archive
4684 containing the binaries of the software you're interested in, and all
4685 its dependencies. The resulting archive can be used on any machine that
4686 does not have Guix, and people can run the exact same binaries as those
4687 you have with Guix. The pack itself is created in a bit-reproducible
4688 fashion, so anyone can verify that it really contains the build results
4689 that you pretend to be shipping.
4690
4691 For example, to create a bundle containing Guile, Emacs, Geiser, and all
4692 their dependencies, you can run:
4693
4694 @example
4695 $ guix pack guile emacs geiser
4696 @dots{}
4697 /gnu/store/@dots{}-pack.tar.gz
4698 @end example
4699
4700 The result here is a tarball containing a @file{/gnu/store} directory
4701 with all the relevant packages. The resulting tarball contains a
4702 @dfn{profile} with the three packages of interest; the profile is the
4703 same as would be created by @command{guix package -i}. It is this
4704 mechanism that is used to create Guix's own standalone binary tarball
4705 (@pxref{Binary Installation}).
4706
4707 Users of this pack would have to run
4708 @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
4709 find inconvenient. To work around it, you can create, say, a
4710 @file{/opt/gnu/bin} symlink to the profile:
4711
4712 @example
4713 guix pack -S /opt/gnu/bin=bin guile emacs geiser
4714 @end example
4715
4716 @noindent
4717 That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
4718
4719 @cindex relocatable binaries, with @command{guix pack}
4720 What if the recipient of your pack does not have root privileges on
4721 their machine, and thus cannot unpack it in the root file system? In
4722 that case, you will want to use the @code{--relocatable} option (see
4723 below). This option produces @dfn{relocatable binaries}, meaning they
4724 they can be placed anywhere in the file system hierarchy: in the example
4725 above, users can unpack your tarball in their home directory and
4726 directly run @file{./opt/gnu/bin/guile}.
4727
4728 @cindex Docker, build an image with guix pack
4729 Alternatively, you can produce a pack in the Docker image format using
4730 the following command:
4731
4732 @example
4733 guix pack -f docker guile emacs geiser
4734 @end example
4735
4736 @noindent
4737 The result is a tarball that can be passed to the @command{docker load}
4738 command. See the
4739 @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
4740 documentation} for more information.
4741
4742 @cindex Singularity, build an image with guix pack
4743 @cindex SquashFS, build an image with guix pack
4744 Yet another option is to produce a SquashFS image with the following
4745 command:
4746
4747 @example
4748 guix pack -f squashfs guile emacs geiser
4749 @end example
4750
4751 @noindent
4752 The result is a SquashFS file system image that can either be mounted or
4753 directly be used as a file system container image with the
4754 @uref{http://singularity.lbl.gov, Singularity container execution
4755 environment}, using commands like @command{singularity shell} or
4756 @command{singularity exec}.
4757
4758 Several command-line options allow you to customize your pack:
4759
4760 @table @code
4761 @item --format=@var{format}
4762 @itemx -f @var{format}
4763 Produce a pack in the given @var{format}.
4764
4765 The available formats are:
4766
4767 @table @code
4768 @item tarball
4769 This is the default format. It produces a tarball containing all the
4770 specified binaries and symlinks.
4771
4772 @item docker
4773 This produces a tarball that follows the
4774 @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
4775 Docker Image Specification}.
4776
4777 @item squashfs
4778 This produces a SquashFS image containing all the specified binaries and
4779 symlinks, as well as empty mount points for virtual file systems like
4780 procfs.
4781 @end table
4782
4783 @cindex relocatable binaries
4784 @item --relocatable
4785 @itemx -R
4786 Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
4787 anywhere in the file system hierarchy and run from there.
4788
4789 When this option is passed once, the resulting binaries require support for
4790 @dfn{user namespaces} in the kernel Linux; when passed
4791 @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
4792 PRoot support, can be thought of as the abbreviation of ``Really
4793 Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to PRoot
4794 if user namespaces are unavailable, and essentially work anywhere---see below
4795 for the implications.
4796
4797 For example, if you create a pack containing Bash with:
4798
4799 @example
4800 guix pack -RR -S /mybin=bin bash
4801 @end example
4802
4803 @noindent
4804 ...@: you can copy that pack to a machine that lacks Guix, and from your
4805 home directory as a normal user, run:
4806
4807 @example
4808 tar xf pack.tar.gz
4809 ./mybin/sh
4810 @end example
4811
4812 @noindent
4813 In that shell, if you type @code{ls /gnu/store}, you'll notice that
4814 @file{/gnu/store} shows up and contains all the dependencies of
4815 @code{bash}, even though the machine actually lacks @file{/gnu/store}
4816 altogether! That is probably the simplest way to deploy Guix-built
4817 software on a non-Guix machine.
4818
4819 @quotation Note
4820 By default, relocatable binaries rely on the @dfn{user namespace} feature of
4821 the kernel Linux, which allows unprivileged users to mount or change root.
4822 Old versions of Linux did not support it, and some GNU/Linux distributions
4823 turn it off.
4824
4825 To produce relocatable binaries that work even in the absence of user
4826 namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
4827 case, binaries will try user namespace support and fall back to PRoot if user
4828 namespaces are not supported.
4829
4830 The @uref{https://proot-me.github.io/, PRoot} program provides the necessary
4831 support for file system virtualization. It achieves that by using the
4832 @code{ptrace} system call on the running program. This approach has the
4833 advantage to work without requiring special kernel support, but it incurs
4834 run-time overhead every time a system call is made.
4835 @end quotation
4836
4837 @item --expression=@var{expr}
4838 @itemx -e @var{expr}
4839 Consider the package @var{expr} evaluates to.
4840
4841 This has the same purpose as the same-named option in @command{guix
4842 build} (@pxref{Additional Build Options, @code{--expression} in
4843 @command{guix build}}).
4844
4845 @item --manifest=@var{file}
4846 @itemx -m @var{file}
4847 Use the packages contained in the manifest object returned by the Scheme
4848 code in @var{file}.
4849
4850 This has a similar purpose as the same-named option in @command{guix
4851 package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
4852 same manifest files. It allows you to define a collection of packages
4853 once and use it both for creating profiles and for creating archives
4854 for use on machines that do not have Guix installed. Note that you can
4855 specify @emph{either} a manifest file @emph{or} a list of packages,
4856 but not both.
4857
4858 @item --system=@var{system}
4859 @itemx -s @var{system}
4860 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
4861 the system type of the build host.
4862
4863 @item --target=@var{triplet}
4864 @cindex cross-compilation
4865 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
4866 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
4867 configuration triplets,, autoconf, Autoconf}).
4868
4869 @item --compression=@var{tool}
4870 @itemx -C @var{tool}
4871 Compress the resulting tarball using @var{tool}---one of @code{gzip},
4872 @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
4873
4874 @item --symlink=@var{spec}
4875 @itemx -S @var{spec}
4876 Add the symlinks specified by @var{spec} to the pack. This option can
4877 appear several times.
4878
4879 @var{spec} has the form @code{@var{source}=@var{target}}, where
4880 @var{source} is the symlink that will be created and @var{target} is the
4881 symlink target.
4882
4883 For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
4884 symlink pointing to the @file{bin} sub-directory of the profile.
4885
4886 @item --save-provenance
4887 Save provenance information for the packages passed on the command line.
4888 Provenance information includes the URL and commit of the channels in use
4889 (@pxref{Channels}).
4890
4891 Provenance information is saved in the
4892 @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
4893 usual package metadata---the name and version of each package, their
4894 propagated inputs, and so on. It is useful information to the recipient of
4895 the pack, who then knows how the pack was (supposedly) obtained.
4896
4897 This option is not enabled by default because, like timestamps, provenance
4898 information contributes nothing to the build process. In other words, there
4899 is an infinity of channel URLs and commit IDs that can lead to the same pack.
4900 Recording such ``silent'' metadata in the output thus potentially breaks the
4901 source-to-binary bitwise reproducibility property.
4902
4903 @item --localstatedir
4904 @itemx --profile-name=@var{name}
4905 Include the ``local state directory'', @file{/var/guix}, in the resulting
4906 pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
4907 profile---by default @var{name} is @code{guix-profile}, which corresponds to
4908 @file{~root/.guix-profile}.
4909
4910 @file{/var/guix} contains the store database (@pxref{The Store}) as well
4911 as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
4912 the pack means that the store is ``complete'' and manageable by Guix;
4913 not providing it pack means that the store is ``dead'': items cannot be
4914 added to it or removed from it after extraction of the pack.
4915
4916 One use case for this is the Guix self-contained binary tarball
4917 (@pxref{Binary Installation}).
4918
4919 @item --bootstrap
4920 Use the bootstrap binaries to build the pack. This option is only
4921 useful to Guix developers.
4922 @end table
4923
4924 In addition, @command{guix pack} supports all the common build options
4925 (@pxref{Common Build Options}) and all the package transformation
4926 options (@pxref{Package Transformation Options}).
4927
4928
4929 @c *********************************************************************
4930 @node Programming Interface
4931 @chapter Programming Interface
4932
4933 GNU Guix provides several Scheme programming interfaces (APIs) to
4934 define, build, and query packages. The first interface allows users to
4935 write high-level package definitions. These definitions refer to
4936 familiar packaging concepts, such as the name and version of a package,
4937 its build system, and its dependencies. These definitions can then be
4938 turned into concrete build actions.
4939
4940 Build actions are performed by the Guix daemon, on behalf of users. In a
4941 standard setup, the daemon has write access to the store---the
4942 @file{/gnu/store} directory---whereas users do not. The recommended
4943 setup also has the daemon perform builds in chroots, under a specific
4944 build users, to minimize interference with the rest of the system.
4945
4946 @cindex derivation
4947 Lower-level APIs are available to interact with the daemon and the
4948 store. To instruct the daemon to perform a build action, users actually
4949 provide it with a @dfn{derivation}. A derivation is a low-level
4950 representation of the build actions to be taken, and the environment in
4951 which they should occur---derivations are to package definitions what
4952 assembly is to C programs. The term ``derivation'' comes from the fact
4953 that build results @emph{derive} from them.
4954
4955 This chapter describes all these APIs in turn, starting from high-level
4956 package definitions.
4957
4958 @menu
4959 * Package Modules:: Packages from the programmer's viewpoint.
4960 * Defining Packages:: Defining new packages.
4961 * Build Systems:: Specifying how packages are built.
4962 * The Store:: Manipulating the package store.
4963 * Derivations:: Low-level interface to package derivations.
4964 * The Store Monad:: Purely functional interface to the store.
4965 * G-Expressions:: Manipulating build expressions.
4966 * Invoking guix repl:: Fiddling with Guix interactively.
4967 @end menu
4968
4969 @node Package Modules
4970 @section Package Modules
4971
4972 From a programming viewpoint, the package definitions of the
4973 GNU distribution are provided by Guile modules in the @code{(gnu packages
4974 @dots{})} name space@footnote{Note that packages under the @code{(gnu
4975 packages @dots{})} module name space are not necessarily ``GNU
4976 packages''. This module naming scheme follows the usual Guile module
4977 naming convention: @code{gnu} means that these modules are distributed
4978 as part of the GNU system, and @code{packages} identifies modules that
4979 define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
4980 Reference Manual}). For instance, the @code{(gnu packages emacs)}
4981 module exports a variable named @code{emacs}, which is bound to a
4982 @code{<package>} object (@pxref{Defining Packages}).
4983
4984 The @code{(gnu packages @dots{})} module name space is
4985 automatically scanned for packages by the command-line tools. For
4986 instance, when running @code{guix package -i emacs}, all the @code{(gnu
4987 packages @dots{})} modules are scanned until one that exports a package
4988 object whose name is @code{emacs} is found. This package search
4989 facility is implemented in the @code{(gnu packages)} module.
4990
4991 @cindex customization, of packages
4992 @cindex package module search path
4993 Users can store package definitions in modules with different
4994 names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
4995 name and module name must match. For instance, the @code{(my-packages
4996 emacs)} module must be stored in a @file{my-packages/emacs.scm} file
4997 relative to the load path specified with @option{--load-path} or
4998 @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
4999 guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
5000 these package definitions visible to the user interfaces:
5001
5002 @enumerate
5003 @item
5004 By adding the directory containing your package modules to the search path
5005 with the @code{-L} flag of @command{guix package} and other commands
5006 (@pxref{Common Build Options}), or by setting the @code{GUIX_PACKAGE_PATH}
5007 environment variable described below.
5008
5009 @item
5010 By defining a @dfn{channel} and configuring @command{guix pull} so that it
5011 pulls from it. A channel is essentially a Git repository containing package
5012 modules. @xref{Channels}, for more information on how to define and use
5013 channels.
5014 @end enumerate
5015
5016 @code{GUIX_PACKAGE_PATH} works similarly to other search path variables:
5017
5018 @defvr {Environment Variable} GUIX_PACKAGE_PATH
5019 This is a colon-separated list of directories to search for additional
5020 package modules. Directories listed in this variable take precedence
5021 over the own modules of the distribution.
5022 @end defvr
5023
5024 The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
5025 each package is built based solely on other packages in the
5026 distribution. The root of this dependency graph is a small set of
5027 @dfn{bootstrap binaries}, provided by the @code{(gnu packages
5028 bootstrap)} module. For more information on bootstrapping,
5029 @pxref{Bootstrapping}.
5030
5031 @node Defining Packages
5032 @section Defining Packages
5033
5034 The high-level interface to package definitions is implemented in the
5035 @code{(guix packages)} and @code{(guix build-system)} modules. As an
5036 example, the package definition, or @dfn{recipe}, for the GNU Hello
5037 package looks like this:
5038
5039 @example
5040 (define-module (gnu packages hello)
5041 #:use-module (guix packages)
5042 #:use-module (guix download)
5043 #:use-module (guix build-system gnu)
5044 #:use-module (guix licenses)
5045 #:use-module (gnu packages gawk))
5046
5047 (define-public hello
5048 (package
5049 (name "hello")
5050 (version "2.10")
5051 (source (origin
5052 (method url-fetch)
5053 (uri (string-append "mirror://gnu/hello/hello-" version
5054 ".tar.gz"))
5055 (sha256
5056 (base32
5057 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
5058 (build-system gnu-build-system)
5059 (arguments '(#:configure-flags '("--enable-silent-rules")))
5060 (inputs `(("gawk" ,gawk)))
5061 (synopsis "Hello, GNU world: An example GNU package")
5062 (description "Guess what GNU Hello prints!")
5063 (home-page "http://www.gnu.org/software/hello/")
5064 (license gpl3+)))
5065 @end example
5066
5067 @noindent
5068 Without being a Scheme expert, the reader may have guessed the meaning
5069 of the various fields here. This expression binds the variable
5070 @code{hello} to a @code{<package>} object, which is essentially a record
5071 (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
5072 This package object can be inspected using procedures found in the
5073 @code{(guix packages)} module; for instance, @code{(package-name hello)}
5074 returns---surprise!---@code{"hello"}.
5075
5076 With luck, you may be able to import part or all of the definition of
5077 the package you are interested in from another repository, using the
5078 @code{guix import} command (@pxref{Invoking guix import}).
5079
5080 In the example above, @var{hello} is defined in a module of its own,
5081 @code{(gnu packages hello)}. Technically, this is not strictly
5082 necessary, but it is convenient to do so: all the packages defined in
5083 modules under @code{(gnu packages @dots{})} are automatically known to
5084 the command-line tools (@pxref{Package Modules}).
5085
5086 There are a few points worth noting in the above package definition:
5087
5088 @itemize
5089 @item
5090 The @code{source} field of the package is an @code{<origin>} object
5091 (@pxref{origin Reference}, for the complete reference).
5092 Here, the @code{url-fetch} method from @code{(guix download)} is used,
5093 meaning that the source is a file to be downloaded over FTP or HTTP.
5094
5095 The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
5096 the GNU mirrors defined in @code{(guix download)}.
5097
5098 The @code{sha256} field specifies the expected SHA256 hash of the file
5099 being downloaded. It is mandatory, and allows Guix to check the
5100 integrity of the file. The @code{(base32 @dots{})} form introduces the
5101 base32 representation of the hash. You can obtain this information with
5102 @code{guix download} (@pxref{Invoking guix download}) and @code{guix
5103 hash} (@pxref{Invoking guix hash}).
5104
5105 @cindex patches
5106 When needed, the @code{origin} form can also have a @code{patches} field
5107 listing patches to be applied, and a @code{snippet} field giving a
5108 Scheme expression to modify the source code.
5109
5110 @item
5111 @cindex GNU Build System
5112 The @code{build-system} field specifies the procedure to build the
5113 package (@pxref{Build Systems}). Here, @var{gnu-build-system}
5114 represents the familiar GNU Build System, where packages may be
5115 configured, built, and installed with the usual @code{./configure &&
5116 make && make check && make install} command sequence.
5117
5118 @item
5119 The @code{arguments} field specifies options for the build system
5120 (@pxref{Build Systems}). Here it is interpreted by
5121 @var{gnu-build-system} as a request run @file{configure} with the
5122 @code{--enable-silent-rules} flag.
5123
5124 @cindex quote
5125 @cindex quoting
5126 @findex '
5127 @findex quote
5128 What about these quote (@code{'}) characters? They are Scheme syntax to
5129 introduce a literal list; @code{'} is synonymous with @code{quote}.
5130 @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
5131 for details. Here the value of the @code{arguments} field is a list of
5132 arguments passed to the build system down the road, as with @code{apply}
5133 (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
5134 Manual}).
5135
5136 The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
5137 (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
5138 @code{#:configure-flags} is a keyword used to pass a keyword argument
5139 to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
5140 Reference Manual}).
5141
5142 @item
5143 The @code{inputs} field specifies inputs to the build process---i.e.,
5144 build-time or run-time dependencies of the package. Here, we define an
5145 input called @code{"gawk"} whose value is that of the @var{gawk}
5146 variable; @var{gawk} is itself bound to a @code{<package>} object.
5147
5148 @cindex backquote (quasiquote)
5149 @findex `
5150 @findex quasiquote
5151 @cindex comma (unquote)
5152 @findex ,
5153 @findex unquote
5154 @findex ,@@
5155 @findex unquote-splicing
5156 Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
5157 us to introduce a literal list in the @code{inputs} field, while
5158 @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
5159 value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
5160 Reference Manual}).
5161
5162 Note that GCC, Coreutils, Bash, and other essential tools do not need to
5163 be specified as inputs here. Instead, @var{gnu-build-system} takes care
5164 of ensuring that they are present (@pxref{Build Systems}).
5165
5166 However, any other dependencies need to be specified in the
5167 @code{inputs} field. Any dependency not specified here will simply be
5168 unavailable to the build process, possibly leading to a build failure.
5169 @end itemize
5170
5171 @xref{package Reference}, for a full description of possible fields.
5172
5173 Once a package definition is in place, the
5174 package may actually be built using the @code{guix build} command-line
5175 tool (@pxref{Invoking guix build}), troubleshooting any build failures
5176 you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
5177 package definition using the @command{guix edit} command
5178 (@pxref{Invoking guix edit}).
5179 @xref{Packaging Guidelines}, for
5180 more information on how to test package definitions, and
5181 @ref{Invoking guix lint}, for information on how to check a definition
5182 for style conformance.
5183 @vindex GUIX_PACKAGE_PATH
5184 Lastly, @pxref{Channels}, for information
5185 on how to extend the distribution by adding your own package definitions
5186 in a ``channel''.
5187
5188 Finally, updating the package definition to a new upstream version
5189 can be partly automated by the @command{guix refresh} command
5190 (@pxref{Invoking guix refresh}).
5191
5192 Behind the scenes, a derivation corresponding to the @code{<package>}
5193 object is first computed by the @code{package-derivation} procedure.
5194 That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
5195 The build actions it prescribes may then be realized by using the
5196 @code{build-derivations} procedure (@pxref{The Store}).
5197
5198 @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
5199 Return the @code{<derivation>} object of @var{package} for @var{system}
5200 (@pxref{Derivations}).
5201
5202 @var{package} must be a valid @code{<package>} object, and @var{system}
5203 must be a string denoting the target system type---e.g.,
5204 @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
5205 must be a connection to the daemon, which operates on the store
5206 (@pxref{The Store}).
5207 @end deffn
5208
5209 @noindent
5210 @cindex cross-compilation
5211 Similarly, it is possible to compute a derivation that cross-builds a
5212 package for some other system:
5213
5214 @deffn {Scheme Procedure} package-cross-derivation @var{store} @
5215 @var{package} @var{target} [@var{system}]
5216 Return the @code{<derivation>} object of @var{package} cross-built from
5217 @var{system} to @var{target}.
5218
5219 @var{target} must be a valid GNU triplet denoting the target hardware
5220 and operating system, such as @code{"mips64el-linux-gnu"}
5221 (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
5222 Configure and Build System}).
5223 @end deffn
5224
5225 @cindex package transformations
5226 @cindex input rewriting
5227 @cindex dependency tree rewriting
5228 Packages can be manipulated in arbitrary ways. An example of a useful
5229 transformation is @dfn{input rewriting}, whereby the dependency tree of
5230 a package is rewritten by replacing specific inputs by others:
5231
5232 @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
5233 [@var{rewrite-name}]
5234 Return a procedure that, when passed a package, replaces its direct and
5235 indirect dependencies (but not its implicit inputs) according to
5236 @var{replacements}. @var{replacements} is a list of package pairs; the
5237 first element of each pair is the package to replace, and the second one
5238 is the replacement.
5239
5240 Optionally, @var{rewrite-name} is a one-argument procedure that takes
5241 the name of a package and returns its new name after rewrite.
5242 @end deffn
5243
5244 @noindent
5245 Consider this example:
5246
5247 @example
5248 (define libressl-instead-of-openssl
5249 ;; This is a procedure to replace OPENSSL by LIBRESSL,
5250 ;; recursively.
5251 (package-input-rewriting `((,openssl . ,libressl))))
5252
5253 (define git-with-libressl
5254 (libressl-instead-of-openssl git))
5255 @end example
5256
5257 @noindent
5258 Here we first define a rewriting procedure that replaces @var{openssl}
5259 with @var{libressl}. Then we use it to define a @dfn{variant} of the
5260 @var{git} package that uses @var{libressl} instead of @var{openssl}.
5261 This is exactly what the @option{--with-input} command-line option does
5262 (@pxref{Package Transformation Options, @option{--with-input}}).
5263
5264 The following variant of @code{package-input-rewriting} can match packages to
5265 be replaced by name rather than by identity.
5266
5267 @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements}
5268 Return a procedure that, given a package, applies the given @var{replacements} to
5269 all the package graph (excluding implicit inputs). @var{replacements} is a list of
5270 spec/procedures pair; each spec is a package specification such as @code{"gcc"} or
5271 @code{"guile@@2"}, and each procedure takes a matching package and returns a
5272 replacement for that package.
5273 @end deffn
5274
5275 The example above could be rewritten this way:
5276
5277 @example
5278 (define libressl-instead-of-openssl
5279 ;; Replace all the packages called "openssl" with LibreSSL.
5280 (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
5281 @end example
5282
5283 The key difference here is that, this time, packages are matched by spec and
5284 not by identity. In other words, any package in the graph that is called
5285 @code{openssl} will be replaced.
5286
5287 A more generic procedure to rewrite a package dependency graph is
5288 @code{package-mapping}: it supports arbitrary changes to nodes in the
5289 graph.
5290
5291 @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
5292 Return a procedure that, given a package, applies @var{proc} to all the packages
5293 depended on and returns the resulting package. The procedure stops recursion
5294 when @var{cut?} returns true for a given package.
5295 @end deffn
5296
5297 @menu
5298 * package Reference:: The package data type.
5299 * origin Reference:: The origin data type.
5300 @end menu
5301
5302
5303 @node package Reference
5304 @subsection @code{package} Reference
5305
5306 This section summarizes all the options available in @code{package}
5307 declarations (@pxref{Defining Packages}).
5308
5309 @deftp {Data Type} package
5310 This is the data type representing a package recipe.
5311
5312 @table @asis
5313 @item @code{name}
5314 The name of the package, as a string.
5315
5316 @item @code{version}
5317 The version of the package, as a string.
5318
5319 @item @code{source}
5320 An object telling how the source code for the package should be
5321 acquired. Most of the time, this is an @code{origin} object, which
5322 denotes a file fetched from the Internet (@pxref{origin Reference}). It
5323 can also be any other ``file-like'' object such as a @code{local-file},
5324 which denotes a file from the local file system (@pxref{G-Expressions,
5325 @code{local-file}}).
5326
5327 @item @code{build-system}
5328 The build system that should be used to build the package (@pxref{Build
5329 Systems}).
5330
5331 @item @code{arguments} (default: @code{'()})
5332 The arguments that should be passed to the build system. This is a
5333 list, typically containing sequential keyword-value pairs.
5334
5335 @item @code{inputs} (default: @code{'()})
5336 @itemx @code{native-inputs} (default: @code{'()})
5337 @itemx @code{propagated-inputs} (default: @code{'()})
5338 @cindex inputs, of packages
5339 These fields list dependencies of the package. Each one is a list of
5340 tuples, where each tuple has a label for the input (a string) as its
5341 first element, a package, origin, or derivation as its second element,
5342 and optionally the name of the output thereof that should be used, which
5343 defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
5344 more on package outputs). For example, the list below specifies three
5345 inputs:
5346
5347 @example
5348 `(("libffi" ,libffi)
5349 ("libunistring" ,libunistring)
5350 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
5351 @end example
5352
5353 @cindex cross compilation, package dependencies
5354 The distinction between @code{native-inputs} and @code{inputs} is
5355 necessary when considering cross-compilation. When cross-compiling,
5356 dependencies listed in @code{inputs} are built for the @emph{target}
5357 architecture; conversely, dependencies listed in @code{native-inputs}
5358 are built for the architecture of the @emph{build} machine.
5359
5360 @code{native-inputs} is typically used to list tools needed at
5361 build time, but not at run time, such as Autoconf, Automake, pkg-config,
5362 Gettext, or Bison. @command{guix lint} can report likely mistakes in
5363 this area (@pxref{Invoking guix lint}).
5364
5365 @anchor{package-propagated-inputs}
5366 Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
5367 specified packages will be automatically installed alongside the package
5368 they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
5369 package}}, for information on how @command{guix package} deals with
5370 propagated inputs.)
5371
5372 For example this is necessary when a C/C++ library needs headers of
5373 another library to compile, or when a pkg-config file refers to another
5374 one @i{via} its @code{Requires} field.
5375
5376 Another example where @code{propagated-inputs} is useful is for languages
5377 that lack a facility to record the run-time search path akin to the
5378 @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
5379 more. To ensure that libraries written in those languages can find
5380 library code they depend on at run time, run-time dependencies must be
5381 listed in @code{propagated-inputs} rather than @code{inputs}.
5382
5383 @item @code{outputs} (default: @code{'("out")})
5384 The list of output names of the package. @xref{Packages with Multiple
5385 Outputs}, for typical uses of additional outputs.
5386
5387 @item @code{native-search-paths} (default: @code{'()})
5388 @itemx @code{search-paths} (default: @code{'()})
5389 A list of @code{search-path-specification} objects describing
5390 search-path environment variables honored by the package.
5391
5392 @item @code{replacement} (default: @code{#f})
5393 This must be either @code{#f} or a package object that will be used as a
5394 @dfn{replacement} for this package. @xref{Security Updates, grafts},
5395 for details.
5396
5397 @item @code{synopsis}
5398 A one-line description of the package.
5399
5400 @item @code{description}
5401 A more elaborate description of the package.
5402
5403 @item @code{license}
5404 @cindex license, of packages
5405 The license of the package; a value from @code{(guix licenses)},
5406 or a list of such values.
5407
5408 @item @code{home-page}
5409 The URL to the home-page of the package, as a string.
5410
5411 @item @code{supported-systems} (default: @var{%supported-systems})
5412 The list of systems supported by the package, as strings of the form
5413 @code{architecture-kernel}, for example @code{"x86_64-linux"}.
5414
5415 @item @code{maintainers} (default: @code{'()})
5416 The list of maintainers of the package, as @code{maintainer} objects.
5417
5418 @item @code{location} (default: source location of the @code{package} form)
5419 The source location of the package. It is useful to override this when
5420 inheriting from another package, in which case this field is not
5421 automatically corrected.
5422 @end table
5423 @end deftp
5424
5425 @deffn {Scheme Syntax} this-package
5426 When used in the @emph{lexical scope} of a package field definition, this
5427 identifier resolves to the package being defined.
5428
5429 The example below shows how to add a package as a native input of itself when
5430 cross-compiling:
5431
5432 @example
5433 (package
5434 (name "guile")
5435 ;; ...
5436
5437 ;; When cross-compiled, Guile, for example, depends on
5438 ;; a native version of itself. Add it here.
5439 (native-inputs (if (%current-target-system)
5440 `(("self" ,this-package))
5441 '())))
5442 @end example
5443
5444 It is an error to refer to @code{this-package} outside a package definition.
5445 @end deffn
5446
5447 @node origin Reference
5448 @subsection @code{origin} Reference
5449
5450 This section summarizes all the options available in @code{origin}
5451 declarations (@pxref{Defining Packages}).
5452
5453 @deftp {Data Type} origin
5454 This is the data type representing a source code origin.
5455
5456 @table @asis
5457 @item @code{uri}
5458 An object containing the URI of the source. The object type depends on
5459 the @code{method} (see below). For example, when using the
5460 @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
5461 values are: a URL represented as a string, or a list thereof.
5462
5463 @item @code{method}
5464 A procedure that handles the URI.
5465
5466 Examples include:
5467
5468 @table @asis
5469 @item @var{url-fetch} from @code{(guix download)}
5470 download a file from the HTTP, HTTPS, or FTP URL specified in the
5471 @code{uri} field;
5472
5473 @vindex git-fetch
5474 @item @var{git-fetch} from @code{(guix git-download)}
5475 clone the Git version control repository, and check out the revision
5476 specified in the @code{uri} field as a @code{git-reference} object; a
5477 @code{git-reference} looks like this:
5478
5479 @example
5480 (git-reference
5481 (url "git://git.debian.org/git/pkg-shadow/shadow")
5482 (commit "v4.1.5.1"))
5483 @end example
5484 @end table
5485
5486 @item @code{sha256}
5487 A bytevector containing the SHA-256 hash of the source. Typically the
5488 @code{base32} form is used here to generate the bytevector from a
5489 base-32 string.
5490
5491 You can obtain this information using @code{guix download}
5492 (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
5493 guix hash}).
5494
5495 @item @code{file-name} (default: @code{#f})
5496 The file name under which the source code should be saved. When this is
5497 @code{#f}, a sensible default value will be used in most cases. In case
5498 the source is fetched from a URL, the file name from the URL will be
5499 used. For version control checkouts, it is recommended to provide the
5500 file name explicitly because the default is not very descriptive.
5501
5502 @item @code{patches} (default: @code{'()})
5503 A list of file names, origins, or file-like objects (@pxref{G-Expressions,
5504 file-like objects}) pointing to patches to be applied to the source.
5505
5506 This list of patches must be unconditional. In particular, it cannot
5507 depend on the value of @code{%current-system} or
5508 @code{%current-target-system}.
5509
5510 @item @code{snippet} (default: @code{#f})
5511 A G-expression (@pxref{G-Expressions}) or S-expression that will be run
5512 in the source directory. This is a convenient way to modify the source,
5513 sometimes more convenient than a patch.
5514
5515 @item @code{patch-flags} (default: @code{'("-p1")})
5516 A list of command-line flags that should be passed to the @code{patch}
5517 command.
5518
5519 @item @code{patch-inputs} (default: @code{#f})
5520 Input packages or derivations to the patching process. When this is
5521 @code{#f}, the usual set of inputs necessary for patching are provided,
5522 such as GNU@tie{}Patch.
5523
5524 @item @code{modules} (default: @code{'()})
5525 A list of Guile modules that should be loaded during the patching
5526 process and while running the code in the @code{snippet} field.
5527
5528 @item @code{patch-guile} (default: @code{#f})
5529 The Guile package that should be used in the patching process. When
5530 this is @code{#f}, a sensible default is used.
5531 @end table
5532 @end deftp
5533
5534
5535 @node Build Systems
5536 @section Build Systems
5537
5538 @cindex build system
5539 Each package definition specifies a @dfn{build system} and arguments for
5540 that build system (@pxref{Defining Packages}). This @code{build-system}
5541 field represents the build procedure of the package, as well as implicit
5542 dependencies of that build procedure.
5543
5544 Build systems are @code{<build-system>} objects. The interface to
5545 create and manipulate them is provided by the @code{(guix build-system)}
5546 module, and actual build systems are exported by specific modules.
5547
5548 @cindex bag (low-level package representation)
5549 Under the hood, build systems first compile package objects to
5550 @dfn{bags}. A @dfn{bag} is like a package, but with less
5551 ornamentation---in other words, a bag is a lower-level representation of
5552 a package, which includes all the inputs of that package, including some
5553 that were implicitly added by the build system. This intermediate
5554 representation is then compiled to a derivation (@pxref{Derivations}).
5555
5556 Build systems accept an optional list of @dfn{arguments}. In package
5557 definitions, these are passed @i{via} the @code{arguments} field
5558 (@pxref{Defining Packages}). They are typically keyword arguments
5559 (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
5560 Guile Reference Manual}). The value of these arguments is usually
5561 evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
5562 by the daemon (@pxref{Derivations}).
5563
5564 The main build system is @var{gnu-build-system}, which implements the
5565 standard build procedure for GNU and many other packages. It
5566 is provided by the @code{(guix build-system gnu)} module.
5567
5568 @defvr {Scheme Variable} gnu-build-system
5569 @var{gnu-build-system} represents the GNU Build System, and variants
5570 thereof (@pxref{Configuration, configuration and makefile conventions,,
5571 standards, GNU Coding Standards}).
5572
5573 @cindex build phases
5574 In a nutshell, packages using it are configured, built, and installed with
5575 the usual @code{./configure && make && make check && make install}
5576 command sequence. In practice, a few additional steps are often needed.
5577 All these steps are split up in separate @dfn{phases},
5578 notably@footnote{Please see the @code{(guix build gnu-build-system)}
5579 modules for more details about the build phases.}:
5580
5581 @table @code
5582 @item unpack
5583 Unpack the source tarball, and change the current directory to the
5584 extracted source tree. If the source is actually a directory, copy it
5585 to the build tree, and enter that directory.
5586
5587 @item patch-source-shebangs
5588 Patch shebangs encountered in source files so they refer to the right
5589 store file names. For instance, this changes @code{#!/bin/sh} to
5590 @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
5591
5592 @item configure
5593 Run the @file{configure} script with a number of default options, such
5594 as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
5595 by the @code{#:configure-flags} argument.
5596
5597 @item build
5598 Run @code{make} with the list of flags specified with
5599 @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
5600 (the default), build with @code{make -j}.
5601
5602 @item check
5603 Run @code{make check}, or some other target specified with
5604 @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
5605 @code{#:parallel-tests?} argument is true (the default), run @code{make
5606 check -j}.
5607
5608 @item install
5609 Run @code{make install} with the flags listed in @code{#:make-flags}.
5610
5611 @item patch-shebangs
5612 Patch shebangs on the installed executable files.
5613
5614 @item strip
5615 Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
5616 is false), copying them to the @code{debug} output when available
5617 (@pxref{Installing Debugging Files}).
5618 @end table
5619
5620 @vindex %standard-phases
5621 The build-side module @code{(guix build gnu-build-system)} defines
5622 @var{%standard-phases} as the default list of build phases.
5623 @var{%standard-phases} is a list of symbol/procedure pairs, where the
5624 procedure implements the actual phase.
5625
5626 The list of phases used for a particular package can be changed with the
5627 @code{#:phases} parameter. For instance, passing:
5628
5629 @example
5630 #:phases (modify-phases %standard-phases (delete 'configure))
5631 @end example
5632
5633 means that all the phases described above will be used, except the
5634 @code{configure} phase.
5635
5636 In addition, this build system ensures that the ``standard'' environment
5637 for GNU packages is available. This includes tools such as GCC, libc,
5638 Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
5639 build-system gnu)} module for a complete list). We call these the
5640 @dfn{implicit inputs} of a package, because package definitions do not
5641 have to mention them.
5642 @end defvr
5643
5644 Other @code{<build-system>} objects are defined to support other
5645 conventions and tools used by free software packages. They inherit most
5646 of @var{gnu-build-system}, and differ mainly in the set of inputs
5647 implicitly added to the build process, and in the list of phases
5648 executed. Some of these build systems are listed below.
5649
5650 @defvr {Scheme Variable} ant-build-system
5651 This variable is exported by @code{(guix build-system ant)}. It
5652 implements the build procedure for Java packages that can be built with
5653 @url{http://ant.apache.org/, Ant build tool}.
5654
5655 It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
5656 provided by the @code{icedtea} package to the set of inputs. Different
5657 packages can be specified with the @code{#:ant} and @code{#:jdk}
5658 parameters, respectively.
5659
5660 When the original package does not provide a suitable Ant build file,
5661 the parameter @code{#:jar-name} can be used to generate a minimal Ant
5662 build file @file{build.xml} with tasks to build the specified jar
5663 archive. In this case the parameter @code{#:source-dir} can be used to
5664 specify the source sub-directory, defaulting to ``src''.
5665
5666 The @code{#:main-class} parameter can be used with the minimal ant
5667 buildfile to specify the main class of the resulting jar. This makes the
5668 jar file executable. The @code{#:test-include} parameter can be used to
5669 specify the list of junit tests to run. It defaults to
5670 @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
5671 disable some tests. It defaults to @code{(list "**/Abstract*.java")},
5672 because abstract classes cannot be run as tests.
5673
5674 The parameter @code{#:build-target} can be used to specify the Ant task
5675 that should be run during the @code{build} phase. By default the
5676 ``jar'' task will be run.
5677
5678 @end defvr
5679
5680 @defvr {Scheme Variable} android-ndk-build-system
5681 @cindex Android distribution
5682 @cindex Android NDK build system
5683 This variable is exported by @code{(guix build-system android-ndk)}. It
5684 implements a build procedure for Android NDK (native development kit)
5685 packages using a Guix-specific build process.
5686
5687 The build system assumes that packages install their public interface
5688 (header) files to the subdirectory "include" of the "out" output and
5689 their libraries to the subdirectory "lib" of the "out" output.
5690
5691 It's also assumed that the union of all the dependencies of a package
5692 has no conflicting files.
5693
5694 For the time being, cross-compilation is not supported - so right now
5695 the libraries and header files are assumed to be host tools.
5696
5697 @end defvr
5698
5699 @defvr {Scheme Variable} asdf-build-system/source
5700 @defvrx {Scheme Variable} asdf-build-system/sbcl
5701 @defvrx {Scheme Variable} asdf-build-system/ecl
5702
5703 These variables, exported by @code{(guix build-system asdf)}, implement
5704 build procedures for Common Lisp packages using
5705 @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
5706 definition facility for Common Lisp programs and libraries.
5707
5708 The @code{asdf-build-system/source} system installs the packages in
5709 source form, and can be loaded using any common lisp implementation, via
5710 ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
5711 systems in the format which a particular implementation understands.
5712 These build systems can also be used to produce executable programs, or
5713 lisp images which contain a set of packages pre-loaded.
5714
5715 The build system uses naming conventions. For binary packages, the
5716 package name should be prefixed with the lisp implementation, such as
5717 @code{sbcl-} for @code{asdf-build-system/sbcl}.
5718
5719 Additionally, the corresponding source package should be labeled using
5720 the same convention as python packages (see @ref{Python Modules}), using
5721 the @code{cl-} prefix.
5722
5723 For binary packages, each system should be defined as a Guix package.
5724 If one package @code{origin} contains several systems, package variants
5725 can be created in order to build all the systems. Source packages,
5726 which use @code{asdf-build-system/source}, may contain several systems.
5727
5728 In order to create executable programs and images, the build-side
5729 procedures @code{build-program} and @code{build-image} can be used.
5730 They should be called in a build phase after the @code{create-symlinks}
5731 phase, so that the system which was just built can be used within the
5732 resulting image. @code{build-program} requires a list of Common Lisp
5733 expressions to be passed as the @code{#:entry-program} argument.
5734
5735 If the system is not defined within its own @code{.asd} file of the same
5736 name, then the @code{#:asd-file} parameter should be used to specify
5737 which file the system is defined in. Furthermore, if the package
5738 defines a system for its tests in a separate file, it will be loaded
5739 before the tests are run if it is specified by the
5740 @code{#:test-asd-file} parameter. If it is not set, the files
5741 @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
5742 and @code{test.asd} will be tried if they exist.
5743
5744 If for some reason the package must be named in a different way than the
5745 naming conventions suggest, the @code{#:asd-system-name} parameter can
5746 be used to specify the name of the system.
5747
5748 @end defvr
5749
5750 @defvr {Scheme Variable} cargo-build-system
5751 @cindex Rust programming language
5752 @cindex Cargo (Rust build system)
5753 This variable is exported by @code{(guix build-system cargo)}. It
5754 supports builds of packages using Cargo, the build tool of the
5755 @uref{https://www.rust-lang.org, Rust programming language}.
5756
5757 In its @code{configure} phase, this build system replaces dependencies
5758 specified in the @file{Carto.toml} file with inputs to the Guix package.
5759 The @code{install} phase installs the binaries, and it also installs the
5760 source code and @file{Cargo.toml} file.
5761 @end defvr
5762
5763 @cindex Clojure (programming language)
5764 @cindex simple Clojure build system
5765 @defvr {Scheme Variable} clojure-build-system
5766 This variable is exported by @code{(guix build-system clojure)}. It implements
5767 a simple build procedure for @uref{https://clojure.org/, Clojure} packages
5768 using plain old @code{compile} in Clojure. Cross-compilation is not supported
5769 yet.
5770
5771 It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
5772 Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
5773 @code{#:zip} parameters, respectively.
5774
5775 A list of source directories, test directories and jar names can be specified
5776 with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
5777 parameters, respectively. Compile directory and main class can be specified
5778 with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
5779 Other parameters are documented below.
5780
5781 This build system is an extension of @var{ant-build-system}, but with the
5782 following phases changed:
5783
5784 @table @code
5785
5786 @item build
5787 This phase calls @code{compile} in Clojure to compile source files and runs
5788 @command{jar} to create jars from both source files and compiled files
5789 according to the include list and exclude list specified in
5790 @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
5791 has priority over the include list. These lists consist of symbols
5792 representing Clojure libraries or the special keyword @code{#:all} representing
5793 all Clojure libraries found under the source directories. The parameter
5794 @code{#:omit-source?} decides if source should be included into the jars.
5795
5796 @item check
5797 This phase runs tests according to the include list and exclude list specified
5798 in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
5799 meanings are analogous to that of @code{#:aot-include} and
5800 @code{#:aot-exclude}, except that the special keyword @code{#:all} now
5801 stands for all Clojure libraries found under the test directories. The
5802 parameter @code{#:tests?} decides if tests should be run.
5803
5804 @item install
5805 This phase installs all jars built previously.
5806 @end table
5807
5808 Apart from the above, this build system also contains an additional phase:
5809
5810 @table @code
5811
5812 @item install-doc
5813 This phase installs all top-level files with base name matching
5814 @var{%doc-regex}. A different regex can be specified with the
5815 @code{#:doc-regex} parameter. All files (recursively) inside the documentation
5816 directories specified in @code{#:doc-dirs} are installed as well.
5817 @end table
5818 @end defvr
5819
5820 @defvr {Scheme Variable} cmake-build-system
5821 This variable is exported by @code{(guix build-system cmake)}. It
5822 implements the build procedure for packages using the
5823 @url{http://www.cmake.org, CMake build tool}.
5824
5825 It automatically adds the @code{cmake} package to the set of inputs.
5826 Which package is used can be specified with the @code{#:cmake}
5827 parameter.
5828
5829 The @code{#:configure-flags} parameter is taken as a list of flags
5830 passed to the @command{cmake} command. The @code{#:build-type}
5831 parameter specifies in abstract terms the flags passed to the compiler;
5832 it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
5833 debugging information''), which roughly means that code is compiled with
5834 @code{-O2 -g}, as is the case for Autoconf-based packages by default.
5835 @end defvr
5836
5837 @defvr {Scheme Variable} dune-build-system
5838 This variable is exported by @code{(guix build-system dune)}. It
5839 supports builds of packages using @uref{https://dune.build/, Dune}, a build
5840 tool for the OCaml programming language. It is implemented as an extension
5841 of the @code{ocaml-build-system} which is described below. As such, the
5842 @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
5843 system.
5844
5845 It automatically adds the @code{dune} package to the set of inputs.
5846 Which package is used can be specified with the @code{#:dune}
5847 parameter.
5848
5849 There is no @code{configure} phase because dune packages typically don't
5850 need to be configured. The @code{#:build-flags} parameter is taken as a
5851 list of flags passed to the @code{dune} command during the build.
5852
5853 The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
5854 command instead of the more recent @code{dune} command while building
5855 a package. Its default value is @code{#f}.
5856
5857 The @code{#:package} parameter can be passed to specify a package name, which
5858 is useful when a package contains multiple packages and you want to build
5859 only one of them. This is equivalent to passing the @code{-p} argument to
5860 @code{dune}.
5861 @end defvr
5862
5863 @defvr {Scheme Variable} go-build-system
5864 This variable is exported by @code{(guix build-system go)}. It
5865 implements a build procedure for Go packages using the standard
5866 @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
5867 Go build mechanisms}.
5868
5869 The user is expected to provide a value for the key @code{#:import-path}
5870 and, in some cases, @code{#:unpack-path}. The
5871 @url{https://golang.org/doc/code.html#ImportPaths, import path}
5872 corresponds to the file system path expected by the package's build
5873 scripts and any referring packages, and provides a unique way to
5874 refer to a Go package. It is typically based on a combination of the
5875 package source code's remote URI and file system hierarchy structure. In
5876 some cases, you will need to unpack the package's source code to a
5877 different directory structure than the one indicated by the import path,
5878 and @code{#:unpack-path} should be used in such cases.
5879
5880 Packages that provide Go libraries should install their source code into
5881 the built output. The key @code{#:install-source?}, which defaults to
5882 @code{#t}, controls whether or not the source code is installed. It can
5883 be set to @code{#f} for packages that only provide executable files.
5884 @end defvr
5885
5886 @defvr {Scheme Variable} glib-or-gtk-build-system
5887 This variable is exported by @code{(guix build-system glib-or-gtk)}. It
5888 is intended for use with packages making use of GLib or GTK+.
5889
5890 This build system adds the following two phases to the ones defined by
5891 @var{gnu-build-system}:
5892
5893 @table @code
5894 @item glib-or-gtk-wrap
5895 The phase @code{glib-or-gtk-wrap} ensures that programs in
5896 @file{bin/} are able to find GLib ``schemas'' and
5897 @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
5898 modules}. This is achieved by wrapping the programs in launch scripts
5899 that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
5900 environment variables.
5901
5902 It is possible to exclude specific package outputs from that wrapping
5903 process by listing their names in the
5904 @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
5905 when an output is known not to contain any GLib or GTK+ binaries, and
5906 where wrapping would gratuitously add a dependency of that output on
5907 GLib and GTK+.
5908
5909 @item glib-or-gtk-compile-schemas
5910 The phase @code{glib-or-gtk-compile-schemas} makes sure that all
5911 @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
5912 GSettings schemas} of GLib are compiled. Compilation is performed by the
5913 @command{glib-compile-schemas} program. It is provided by the package
5914 @code{glib:bin} which is automatically imported by the build system.
5915 The @code{glib} package providing @command{glib-compile-schemas} can be
5916 specified with the @code{#:glib} parameter.
5917 @end table
5918
5919 Both phases are executed after the @code{install} phase.
5920 @end defvr
5921
5922 @defvr {Scheme Variable} guile-build-system
5923 This build system is for Guile packages that consist exclusively of Scheme
5924 code and that are so lean that they don't even have a makefile, let alone a
5925 @file{configure} script. It compiles Scheme code using @command{guild
5926 compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
5927 installs the @file{.scm} and @file{.go} files in the right place. It also
5928 installs documentation.
5929
5930 This build system supports cross-compilation by using the @code{--target}
5931 option of @command{guild compile}.
5932
5933 Packages built with @code{guile-build-system} must provide a Guile package in
5934 their @code{native-inputs} field.
5935 @end defvr
5936
5937 @defvr {Scheme Variable} minify-build-system
5938 This variable is exported by @code{(guix build-system minify)}. It
5939 implements a minification procedure for simple JavaScript packages.
5940
5941 It adds @code{uglify-js} to the set of inputs and uses it to compress
5942 all JavaScript files in the @file{src} directory. A different minifier
5943 package can be specified with the @code{#:uglify-js} parameter, but it
5944 is expected that the package writes the minified code to the standard
5945 output.
5946
5947 When the input JavaScript files are not all located in the @file{src}
5948 directory, the parameter @code{#:javascript-files} can be used to
5949 specify a list of file names to feed to the minifier.
5950 @end defvr
5951
5952 @defvr {Scheme Variable} ocaml-build-system
5953 This variable is exported by @code{(guix build-system ocaml)}. It implements
5954 a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
5955 of choosing the correct set of commands to run for each package. OCaml
5956 packages can expect many different commands to be run. This build system will
5957 try some of them.
5958
5959 When the package has a @file{setup.ml} file present at the top-level, it will
5960 run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
5961 @code{ocaml setup.ml -install}. The build system will assume that this file
5962 was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
5963 care of setting the prefix and enabling tests if they are not disabled. You
5964 can pass configure and build flags with the @code{#:configure-flags} and
5965 @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
5966 set of flags used to enable tests. The @code{#:use-make?} key can be used to
5967 bypass this system in the build and install phases.
5968
5969 When the package has a @file{configure} file, it is assumed that it is a
5970 hand-made configure script that requires a different argument format than
5971 in the @code{gnu-build-system}. You can add more flags with the
5972 @code{#:configure-flags} key.
5973
5974 When the package has a @file{Makefile} file (or @code{#:use-make?} is
5975 @code{#t}), it will be used and more flags can be passed to the build and
5976 install phases with the @code{#:make-flags} key.
5977
5978 Finally, some packages do not have these files and use a somewhat standard
5979 location for its build system. In that case, the build system will run
5980 @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
5981 providing the path to the required findlib module. Additional flags can
5982 be passed via the @code{#:build-flags} key. Install is taken care of by
5983 @command{opam-installer}. In this case, the @code{opam} package must
5984 be added to the @code{native-inputs} field of the package definition.
5985
5986 Note that most OCaml packages assume they will be installed in the same
5987 directory as OCaml, which is not what we want in guix. In particular, they
5988 will install @file{.so} files in their module's directory, which is usually
5989 fine because it is in the OCaml compiler directory. In guix though, these
5990 libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
5991 variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
5992 @file{.so} libraries should be installed.
5993 @end defvr
5994
5995 @defvr {Scheme Variable} python-build-system
5996 This variable is exported by @code{(guix build-system python)}. It
5997 implements the more or less standard build procedure used by Python
5998 packages, which consists in running @code{python setup.py build} and
5999 then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
6000
6001 For packages that install stand-alone Python programs under @code{bin/},
6002 it takes care of wrapping these programs so that their @code{PYTHONPATH}
6003 environment variable points to all the Python libraries they depend on.
6004
6005 Which Python package is used to perform the build can be specified with
6006 the @code{#:python} parameter. This is a useful way to force a package
6007 to be built for a specific version of the Python interpreter, which
6008 might be necessary if the package is only compatible with a single
6009 interpreter version.
6010
6011 By default guix calls @code{setup.py} under control of
6012 @code{setuptools}, much like @command{pip} does. Some packages are not
6013 compatible with setuptools (and pip), thus you can disable this by
6014 setting the @code{#:use-setuptools} parameter to @code{#f}.
6015 @end defvr
6016
6017 @defvr {Scheme Variable} perl-build-system
6018 This variable is exported by @code{(guix build-system perl)}. It
6019 implements the standard build procedure for Perl packages, which either
6020 consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
6021 followed by @code{Build} and @code{Build install}; or in running
6022 @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
6023 @code{make} and @code{make install}, depending on which of
6024 @code{Build.PL} or @code{Makefile.PL} is present in the package
6025 distribution. Preference is given to the former if both @code{Build.PL}
6026 and @code{Makefile.PL} exist in the package distribution. This
6027 preference can be reversed by specifying @code{#t} for the
6028 @code{#:make-maker?} parameter.
6029
6030 The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
6031 passes flags specified by the @code{#:make-maker-flags} or
6032 @code{#:module-build-flags} parameter, respectively.
6033
6034 Which Perl package is used can be specified with @code{#:perl}.
6035 @end defvr
6036
6037 @defvr {Scheme Variable} r-build-system
6038 This variable is exported by @code{(guix build-system r)}. It
6039 implements the build procedure used by @uref{http://r-project.org, R}
6040 packages, which essentially is little more than running @code{R CMD
6041 INSTALL --library=/gnu/store/@dots{}} in an environment where
6042 @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
6043 are run after installation using the R function
6044 @code{tools::testInstalledPackage}.
6045 @end defvr
6046
6047 @defvr {Scheme Variable} rakudo-build-system
6048 This variable is exported by @code{(guix build-system rakudo)} It
6049 implements the build procedure used by @uref{https://rakudo.org/,
6050 Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
6051 package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
6052 installs the binaries, library files and the resources, as well as wrap
6053 the files under the @code{bin/} directory. Tests can be skipped by
6054 passing @code{#f} to the @code{tests?} parameter.
6055
6056 Which rakudo package is used can be specified with @code{rakudo}.
6057 Which perl6-tap-harness package used for the tests can be specified with
6058 @code{#:prove6} or removed by passing @code{#f} to the
6059 @code{with-prove6?} parameter.
6060 Which perl6-zef package used for tests and installing can be specified
6061 with @code{#:zef} or removed by passing @code{#f} to the
6062 @code{with-zef?} parameter.
6063 @end defvr
6064
6065 @defvr {Scheme Variable} texlive-build-system
6066 This variable is exported by @code{(guix build-system texlive)}. It is
6067 used to build TeX packages in batch mode with a specified engine. The
6068 build system sets the @code{TEXINPUTS} variable to find all TeX source
6069 files in the inputs.
6070
6071 By default it runs @code{luatex} on all files ending on @code{ins}. A
6072 different engine and format can be specified with the
6073 @code{#:tex-format} argument. Different build targets can be specified
6074 with the @code{#:build-targets} argument, which expects a list of file
6075 names. The build system adds only @code{texlive-bin} and
6076 @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
6077 inputs. Both can be overridden with the arguments @code{#:texlive-bin}
6078 and @code{#:texlive-latex-base}, respectively.
6079
6080 The @code{#:tex-directory} parameter tells the build system where to
6081 install the built files under the texmf tree.
6082 @end defvr
6083
6084 @defvr {Scheme Variable} ruby-build-system
6085 This variable is exported by @code{(guix build-system ruby)}. It
6086 implements the RubyGems build procedure used by Ruby packages, which
6087 involves running @code{gem build} followed by @code{gem install}.
6088
6089 The @code{source} field of a package that uses this build system
6090 typically references a gem archive, since this is the format that Ruby
6091 developers use when releasing their software. The build system unpacks
6092 the gem archive, potentially patches the source, runs the test suite,
6093 repackages the gem, and installs it. Additionally, directories and
6094 tarballs may be referenced to allow building unreleased gems from Git or
6095 a traditional source release tarball.
6096
6097 Which Ruby package is used can be specified with the @code{#:ruby}
6098 parameter. A list of additional flags to be passed to the @command{gem}
6099 command can be specified with the @code{#:gem-flags} parameter.
6100 @end defvr
6101
6102 @defvr {Scheme Variable} waf-build-system
6103 This variable is exported by @code{(guix build-system waf)}. It
6104 implements a build procedure around the @code{waf} script. The common
6105 phases---@code{configure}, @code{build}, and @code{install}---are
6106 implemented by passing their names as arguments to the @code{waf}
6107 script.
6108
6109 The @code{waf} script is executed by the Python interpreter. Which
6110 Python package is used to run the script can be specified with the
6111 @code{#:python} parameter.
6112 @end defvr
6113
6114 @defvr {Scheme Variable} scons-build-system
6115 This variable is exported by @code{(guix build-system scons)}. It
6116 implements the build procedure used by the SCons software construction
6117 tool. This build system runs @code{scons} to build the package,
6118 @code{scons test} to run tests, and then @code{scons install} to install
6119 the package.
6120
6121 Additional flags to be passed to @code{scons} can be specified with the
6122 @code{#:scons-flags} parameter. The version of Python used to run SCons
6123 can be specified by selecting the appropriate SCons package with the
6124 @code{#:scons} parameter.
6125 @end defvr
6126
6127 @defvr {Scheme Variable} haskell-build-system
6128 This variable is exported by @code{(guix build-system haskell)}. It
6129 implements the Cabal build procedure used by Haskell packages, which
6130 involves running @code{runhaskell Setup.hs configure
6131 --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
6132 Instead of installing the package by running @code{runhaskell Setup.hs
6133 install}, to avoid trying to register libraries in the read-only
6134 compiler store directory, the build system uses @code{runhaskell
6135 Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
6136 addition, the build system generates the package documentation by
6137 running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
6138 is passed. Optional Haddock parameters can be passed with the help of
6139 the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
6140 not found, the build system looks for @code{Setup.lhs} instead.
6141
6142 Which Haskell compiler is used can be specified with the @code{#:haskell}
6143 parameter which defaults to @code{ghc}.
6144 @end defvr
6145
6146 @defvr {Scheme Variable} dub-build-system
6147 This variable is exported by @code{(guix build-system dub)}. It
6148 implements the Dub build procedure used by D packages, which
6149 involves running @code{dub build} and @code{dub run}.
6150 Installation is done by copying the files manually.
6151
6152 Which D compiler is used can be specified with the @code{#:ldc}
6153 parameter which defaults to @code{ldc}.
6154 @end defvr
6155
6156 @defvr {Scheme Variable} emacs-build-system
6157 This variable is exported by @code{(guix build-system emacs)}. It
6158 implements an installation procedure similar to the packaging system
6159 of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
6160
6161 It first creates the @code{@var{package}-autoloads.el} file, then it
6162 byte compiles all Emacs Lisp files. Differently from the Emacs
6163 packaging system, the Info documentation files are moved to the standard
6164 documentation directory and the @file{dir} file is deleted. Each
6165 package is installed in its own directory under
6166 @file{share/emacs/site-lisp/guix.d}.
6167 @end defvr
6168
6169 @defvr {Scheme Variable} font-build-system
6170 This variable is exported by @code{(guix build-system font)}. It
6171 implements an installation procedure for font packages where upstream
6172 provides pre-compiled TrueType, OpenType, etc.@: font files that merely
6173 need to be copied into place. It copies font files to standard
6174 locations in the output directory.
6175 @end defvr
6176
6177 @defvr {Scheme Variable} meson-build-system
6178 This variable is exported by @code{(guix build-system meson)}. It
6179 implements the build procedure for packages that use
6180 @url{http://mesonbuild.com, Meson} as their build system.
6181
6182 It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
6183 of inputs, and they can be changed with the parameters @code{#:meson}
6184 and @code{#:ninja} if needed. The default Meson is
6185 @code{meson-for-build}, which is special because it doesn't clear the
6186 @code{RUNPATH} of binaries and libraries when they are installed.
6187
6188 This build system is an extension of @var{gnu-build-system}, but with the
6189 following phases changed to some specific for Meson:
6190
6191 @table @code
6192
6193 @item configure
6194 The phase runs @code{meson} with the flags specified in
6195 @code{#:configure-flags}. The flag @code{--build-type} is always set to
6196 @code{plain} unless something else is specified in @code{#:build-type}.
6197
6198 @item build
6199 The phase runs @code{ninja} to build the package in parallel by default, but
6200 this can be changed with @code{#:parallel-build?}.
6201
6202 @item check
6203 The phase runs @code{ninja} with the target specified in @code{#:test-target},
6204 which is @code{"test"} by default.
6205
6206 @item install
6207 The phase runs @code{ninja install} and can not be changed.
6208 @end table
6209
6210 Apart from that, the build system also adds the following phases:
6211
6212 @table @code
6213
6214 @item fix-runpath
6215 This phase ensures that all binaries can find the libraries they need.
6216 It searches for required libraries in subdirectories of the package being
6217 built, and adds those to @code{RUNPATH} where needed. It also removes
6218 references to libraries left over from the build phase by
6219 @code{meson-for-build}, such as test dependencies, that aren't actually
6220 required for the program to run.
6221
6222 @item glib-or-gtk-wrap
6223 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
6224 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
6225
6226 @item glib-or-gtk-compile-schemas
6227 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
6228 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
6229 @end table
6230 @end defvr
6231
6232 @defvr {Scheme Variable} linux-module-build-system
6233 @var{linux-module-build-system} allows building Linux kernel modules.
6234
6235 @cindex build phases
6236 This build system is an extension of @var{gnu-build-system}, but with the
6237 following phases changed:
6238
6239 @table @code
6240
6241 @item configure
6242 This phase configures the environment so that the Linux kernel's Makefile
6243 can be used to build the external kernel module.
6244
6245 @item build
6246 This phase uses the Linux kernel's Makefile in order to build the external
6247 kernel module.
6248
6249 @item install
6250 This phase uses the Linux kernel's Makefile in order to install the external
6251 kernel module.
6252 @end table
6253
6254 It is possible and useful to specify the Linux kernel to use for building
6255 the module (in the "arguments" form of a package using the
6256 linux-module-build-system, use the key #:linux to specify it).
6257 @end defvr
6258
6259 Lastly, for packages that do not need anything as sophisticated, a
6260 ``trivial'' build system is provided. It is trivial in the sense that
6261 it provides basically no support: it does not pull any implicit inputs,
6262 and does not have a notion of build phases.
6263
6264 @defvr {Scheme Variable} trivial-build-system
6265 This variable is exported by @code{(guix build-system trivial)}.
6266
6267 This build system requires a @code{#:builder} argument. This argument
6268 must be a Scheme expression that builds the package output(s)---as
6269 with @code{build-expression->derivation} (@pxref{Derivations,
6270 @code{build-expression->derivation}}).
6271 @end defvr
6272
6273 @node The Store
6274 @section The Store
6275
6276 @cindex store
6277 @cindex store items
6278 @cindex store paths
6279
6280 Conceptually, the @dfn{store} is the place where derivations that have
6281 been built successfully are stored---by default, @file{/gnu/store}.
6282 Sub-directories in the store are referred to as @dfn{store items} or
6283 sometimes @dfn{store paths}. The store has an associated database that
6284 contains information such as the store paths referred to by each store
6285 path, and the list of @emph{valid} store items---results of successful
6286 builds. This database resides in @file{@var{localstatedir}/guix/db},
6287 where @var{localstatedir} is the state directory specified @i{via}
6288 @option{--localstatedir} at configure time, usually @file{/var}.
6289
6290 The store is @emph{always} accessed by the daemon on behalf of its clients
6291 (@pxref{Invoking guix-daemon}). To manipulate the store, clients
6292 connect to the daemon over a Unix-domain socket, send requests to it,
6293 and read the result---these are remote procedure calls, or RPCs.
6294
6295 @quotation Note
6296 Users must @emph{never} modify files under @file{/gnu/store} directly.
6297 This would lead to inconsistencies and break the immutability
6298 assumptions of Guix's functional model (@pxref{Introduction}).
6299
6300 @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
6301 how to check the integrity of the store and attempt recovery from
6302 accidental modifications.
6303 @end quotation
6304
6305 The @code{(guix store)} module provides procedures to connect to the
6306 daemon, and to perform RPCs. These are described below. By default,
6307 @code{open-connection}, and thus all the @command{guix} commands,
6308 connect to the local daemon or to the URI specified by the
6309 @code{GUIX_DAEMON_SOCKET} environment variable.
6310
6311 @defvr {Environment Variable} GUIX_DAEMON_SOCKET
6312 When set, the value of this variable should be a file name or a URI
6313 designating the daemon endpoint. When it is a file name, it denotes a
6314 Unix-domain socket to connect to. In addition to file names, the
6315 supported URI schemes are:
6316
6317 @table @code
6318 @item file
6319 @itemx unix
6320 These are for Unix-domain sockets.
6321 @code{file:///var/guix/daemon-socket/socket} is equivalent to
6322 @file{/var/guix/daemon-socket/socket}.
6323
6324 @item guix
6325 @cindex daemon, remote access
6326 @cindex remote access to the daemon
6327 @cindex daemon, cluster setup
6328 @cindex clusters, daemon setup
6329 These URIs denote connections over TCP/IP, without encryption nor
6330 authentication of the remote host. The URI must specify the host name
6331 and optionally a port number (by default port 44146 is used):
6332
6333 @example
6334 guix://master.guix.example.org:1234
6335 @end example
6336
6337 This setup is suitable on local networks, such as clusters, where only
6338 trusted nodes may connect to the build daemon at
6339 @code{master.guix.example.org}.
6340
6341 The @code{--listen} option of @command{guix-daemon} can be used to
6342 instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
6343 @code{--listen}}).
6344
6345 @item ssh
6346 @cindex SSH access to build daemons
6347 These URIs allow you to connect to a remote daemon over
6348 SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
6349 A typical URL might look like this:
6350
6351 @example
6352 ssh://charlie@@guix.example.org:22
6353 @end example
6354
6355 As for @command{guix copy}, the usual OpenSSH client configuration files
6356 are honored (@pxref{Invoking guix copy}).
6357 @end table
6358
6359 Additional URI schemes may be supported in the future.
6360
6361 @c XXX: Remove this note when the protocol incurs fewer round trips
6362 @c and when (guix derivations) no longer relies on file system access.
6363 @quotation Note
6364 The ability to connect to remote build daemons is considered
6365 experimental as of @value{VERSION}. Please get in touch with us to
6366 share any problems or suggestions you may have (@pxref{Contributing}).
6367 @end quotation
6368 @end defvr
6369
6370 @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
6371 Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
6372 @var{reserve-space?} is true, instruct it to reserve a little bit of
6373 extra space on the file system so that the garbage collector can still
6374 operate should the disk become full. Return a server object.
6375
6376 @var{file} defaults to @var{%default-socket-path}, which is the normal
6377 location given the options that were passed to @command{configure}.
6378 @end deffn
6379
6380 @deffn {Scheme Procedure} close-connection @var{server}
6381 Close the connection to @var{server}.
6382 @end deffn
6383
6384 @defvr {Scheme Variable} current-build-output-port
6385 This variable is bound to a SRFI-39 parameter, which refers to the port
6386 where build and error logs sent by the daemon should be written.
6387 @end defvr
6388
6389 Procedures that make RPCs all take a server object as their first
6390 argument.
6391
6392 @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
6393 @cindex invalid store items
6394 Return @code{#t} when @var{path} designates a valid store item and
6395 @code{#f} otherwise (an invalid item may exist on disk but still be
6396 invalid, for instance because it is the result of an aborted or failed
6397 build.)
6398
6399 A @code{&store-protocol-error} condition is raised if @var{path} is not
6400 prefixed by the store directory (@file{/gnu/store}).
6401 @end deffn
6402
6403 @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
6404 Add @var{text} under file @var{name} in the store, and return its store
6405 path. @var{references} is the list of store paths referred to by the
6406 resulting store path.
6407 @end deffn
6408
6409 @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
6410 Build @var{derivations} (a list of @code{<derivation>} objects or
6411 derivation paths), and return when the worker is done building them.
6412 Return @code{#t} on success.
6413 @end deffn
6414
6415 Note that the @code{(guix monads)} module provides a monad as well as
6416 monadic versions of the above procedures, with the goal of making it
6417 more convenient to work with code that accesses the store (@pxref{The
6418 Store Monad}).
6419
6420 @c FIXME
6421 @i{This section is currently incomplete.}
6422
6423 @node Derivations
6424 @section Derivations
6425
6426 @cindex derivations
6427 Low-level build actions and the environment in which they are performed
6428 are represented by @dfn{derivations}. A derivation contains the
6429 following pieces of information:
6430
6431 @itemize
6432 @item
6433 The outputs of the derivation---derivations produce at least one file or
6434 directory in the store, but may produce more.
6435
6436 @item
6437 @cindex build-time dependencies
6438 @cindex dependencies, build-time
6439 The inputs of the derivations---i.e., its build-time dependencies---which may
6440 be other derivations or plain files in the store (patches, build scripts,
6441 etc.)
6442
6443 @item
6444 The system type targeted by the derivation---e.g., @code{x86_64-linux}.
6445
6446 @item
6447 The file name of a build script in the store, along with the arguments
6448 to be passed.
6449
6450 @item
6451 A list of environment variables to be defined.
6452
6453 @end itemize
6454
6455 @cindex derivation path
6456 Derivations allow clients of the daemon to communicate build actions to
6457 the store. They exist in two forms: as an in-memory representation,
6458 both on the client- and daemon-side, and as files in the store whose
6459 name end in @code{.drv}---these files are referred to as @dfn{derivation
6460 paths}. Derivations paths can be passed to the @code{build-derivations}
6461 procedure to perform the build actions they prescribe (@pxref{The
6462 Store}).
6463
6464 @cindex fixed-output derivations
6465 Operations such as file downloads and version-control checkouts for
6466 which the expected content hash is known in advance are modeled as
6467 @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
6468 of a fixed-output derivation are independent of its inputs---e.g., a
6469 source code download produces the same result regardless of the download
6470 method and tools being used.
6471
6472 @cindex references
6473 @cindex run-time dependencies
6474 @cindex dependencies, run-time
6475 The outputs of derivations---i.e., the build results---have a set of
6476 @dfn{references}, as reported by the @code{references} RPC or the
6477 @command{guix gc --references} command (@pxref{Invoking guix gc}). References
6478 are the set of run-time dependencies of the build results. References are a
6479 subset of the inputs of the derivation; this subset is automatically computed
6480 by the build daemon by scanning all the files in the outputs.
6481
6482 The @code{(guix derivations)} module provides a representation of
6483 derivations as Scheme objects, along with procedures to create and
6484 otherwise manipulate derivations. The lowest-level primitive to create
6485 a derivation is the @code{derivation} procedure:
6486
6487 @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
6488 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
6489 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
6490 [#:system (%current-system)] [#:references-graphs #f] @
6491 [#:allowed-references #f] [#:disallowed-references #f] @
6492 [#:leaked-env-vars #f] [#:local-build? #f] @
6493 [#:substitutable? #t] [#:properties '()]
6494 Build a derivation with the given arguments, and return the resulting
6495 @code{<derivation>} object.
6496
6497 When @var{hash} and @var{hash-algo} are given, a
6498 @dfn{fixed-output derivation} is created---i.e., one whose result is
6499 known in advance, such as a file download. If, in addition,
6500 @var{recursive?} is true, then that fixed output may be an executable
6501 file or a directory and @var{hash} must be the hash of an archive
6502 containing this output.
6503
6504 When @var{references-graphs} is true, it must be a list of file
6505 name/store path pairs. In that case, the reference graph of each store
6506 path is exported in the build environment in the corresponding file, in
6507 a simple text format.
6508
6509 When @var{allowed-references} is true, it must be a list of store items
6510 or outputs that the derivation's output may refer to. Likewise,
6511 @var{disallowed-references}, if true, must be a list of things the
6512 outputs may @emph{not} refer to.
6513
6514 When @var{leaked-env-vars} is true, it must be a list of strings
6515 denoting environment variables that are allowed to ``leak'' from the
6516 daemon's environment to the build environment. This is only applicable
6517 to fixed-output derivations---i.e., when @var{hash} is true. The main
6518 use is to allow variables such as @code{http_proxy} to be passed to
6519 derivations that download files.
6520
6521 When @var{local-build?} is true, declare that the derivation is not a
6522 good candidate for offloading and should rather be built locally
6523 (@pxref{Daemon Offload Setup}). This is the case for small derivations
6524 where the costs of data transfers would outweigh the benefits.
6525
6526 When @var{substitutable?} is false, declare that substitutes of the
6527 derivation's output should not be used (@pxref{Substitutes}). This is
6528 useful, for instance, when building packages that capture details of the
6529 host CPU instruction set.
6530
6531 @var{properties} must be an association list describing ``properties'' of the
6532 derivation. It is kept as-is, uninterpreted, in the derivation.
6533 @end deffn
6534
6535 @noindent
6536 Here's an example with a shell script as its builder, assuming
6537 @var{store} is an open connection to the daemon, and @var{bash} points
6538 to a Bash executable in the store:
6539
6540 @lisp
6541 (use-modules (guix utils)
6542 (guix store)
6543 (guix derivations))
6544
6545 (let ((builder ; add the Bash script to the store
6546 (add-text-to-store store "my-builder.sh"
6547 "echo hello world > $out\n" '())))
6548 (derivation store "foo"
6549 bash `("-e" ,builder)
6550 #:inputs `((,bash) (,builder))
6551 #:env-vars '(("HOME" . "/homeless"))))
6552 @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
6553 @end lisp
6554
6555 As can be guessed, this primitive is cumbersome to use directly. A
6556 better approach is to write build scripts in Scheme, of course! The
6557 best course of action for that is to write the build code as a
6558 ``G-expression'', and to pass it to @code{gexp->derivation}. For more
6559 information, @pxref{G-Expressions}.
6560
6561 Once upon a time, @code{gexp->derivation} did not exist and constructing
6562 derivations with build code written in Scheme was achieved with
6563 @code{build-expression->derivation}, documented below. This procedure
6564 is now deprecated in favor of the much nicer @code{gexp->derivation}.
6565
6566 @deffn {Scheme Procedure} build-expression->derivation @var{store} @
6567 @var{name} @var{exp} @
6568 [#:system (%current-system)] [#:inputs '()] @
6569 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
6570 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
6571 [#:references-graphs #f] [#:allowed-references #f] @
6572 [#:disallowed-references #f] @
6573 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
6574 Return a derivation that executes Scheme expression @var{exp} as a
6575 builder for derivation @var{name}. @var{inputs} must be a list of
6576 @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
6577 @code{"out"} is assumed. @var{modules} is a list of names of Guile
6578 modules from the current search path to be copied in the store,
6579 compiled, and made available in the load path during the execution of
6580 @var{exp}---e.g., @code{((guix build utils) (guix build
6581 gnu-build-system))}.
6582
6583 @var{exp} is evaluated in an environment where @code{%outputs} is bound
6584 to a list of output/path pairs, and where @code{%build-inputs} is bound
6585 to a list of string/output-path pairs made from @var{inputs}.
6586 Optionally, @var{env-vars} is a list of string pairs specifying the name
6587 and value of environment variables visible to the builder. The builder
6588 terminates by passing the result of @var{exp} to @code{exit}; thus, when
6589 @var{exp} returns @code{#f}, the build is considered to have failed.
6590
6591 @var{exp} is built using @var{guile-for-build} (a derivation). When
6592 @var{guile-for-build} is omitted or is @code{#f}, the value of the
6593 @code{%guile-for-build} fluid is used instead.
6594
6595 See the @code{derivation} procedure for the meaning of
6596 @var{references-graphs}, @var{allowed-references},
6597 @var{disallowed-references}, @var{local-build?}, and
6598 @var{substitutable?}.
6599 @end deffn
6600
6601 @noindent
6602 Here's an example of a single-output derivation that creates a directory
6603 containing one file:
6604
6605 @lisp
6606 (let ((builder '(let ((out (assoc-ref %outputs "out")))
6607 (mkdir out) ; create /gnu/store/@dots{}-goo
6608 (call-with-output-file (string-append out "/test")
6609 (lambda (p)
6610 (display '(hello guix) p))))))
6611 (build-expression->derivation store "goo" builder))
6612
6613 @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
6614 @end lisp
6615
6616
6617 @node The Store Monad
6618 @section The Store Monad
6619
6620 @cindex monad
6621
6622 The procedures that operate on the store described in the previous
6623 sections all take an open connection to the build daemon as their first
6624 argument. Although the underlying model is functional, they either have
6625 side effects or depend on the current state of the store.
6626
6627 The former is inconvenient: the connection to the build daemon has to be
6628 carried around in all those functions, making it impossible to compose
6629 functions that do not take that parameter with functions that do. The
6630 latter can be problematic: since store operations have side effects
6631 and/or depend on external state, they have to be properly sequenced.
6632
6633 @cindex monadic values
6634 @cindex monadic functions
6635 This is where the @code{(guix monads)} module comes in. This module
6636 provides a framework for working with @dfn{monads}, and a particularly
6637 useful monad for our uses, the @dfn{store monad}. Monads are a
6638 construct that allows two things: associating ``context'' with values
6639 (in our case, the context is the store), and building sequences of
6640 computations (here computations include accesses to the store). Values
6641 in a monad---values that carry this additional context---are called
6642 @dfn{monadic values}; procedures that return such values are called
6643 @dfn{monadic procedures}.
6644
6645 Consider this ``normal'' procedure:
6646
6647 @example
6648 (define (sh-symlink store)
6649 ;; Return a derivation that symlinks the 'bash' executable.
6650 (let* ((drv (package-derivation store bash))
6651 (out (derivation->output-path drv))
6652 (sh (string-append out "/bin/bash")))
6653 (build-expression->derivation store "sh"
6654 `(symlink ,sh %output))))
6655 @end example
6656
6657 Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
6658 as a monadic function:
6659
6660 @example
6661 (define (sh-symlink)
6662 ;; Same, but return a monadic value.
6663 (mlet %store-monad ((drv (package->derivation bash)))
6664 (gexp->derivation "sh"
6665 #~(symlink (string-append #$drv "/bin/bash")
6666 #$output))))
6667 @end example
6668
6669 There are several things to note in the second version: the @code{store}
6670 parameter is now implicit and is ``threaded'' in the calls to the
6671 @code{package->derivation} and @code{gexp->derivation} monadic
6672 procedures, and the monadic value returned by @code{package->derivation}
6673 is @dfn{bound} using @code{mlet} instead of plain @code{let}.
6674
6675 As it turns out, the call to @code{package->derivation} can even be
6676 omitted since it will take place implicitly, as we will see later
6677 (@pxref{G-Expressions}):
6678
6679 @example
6680 (define (sh-symlink)
6681 (gexp->derivation "sh"
6682 #~(symlink (string-append #$bash "/bin/bash")
6683 #$output)))
6684 @end example
6685
6686 @c See
6687 @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
6688 @c for the funny quote.
6689 Calling the monadic @code{sh-symlink} has no effect. As someone once
6690 said, ``you exit a monad like you exit a building on fire: by running''.
6691 So, to exit the monad and get the desired effect, one must use
6692 @code{run-with-store}:
6693
6694 @example
6695 (run-with-store (open-connection) (sh-symlink))
6696 @result{} /gnu/store/...-sh-symlink
6697 @end example
6698
6699 Note that the @code{(guix monad-repl)} module extends the Guile REPL with
6700 new ``meta-commands'' to make it easier to deal with monadic procedures:
6701 @code{run-in-store}, and @code{enter-store-monad}. The former is used
6702 to ``run'' a single monadic value through the store:
6703
6704 @example
6705 scheme@@(guile-user)> ,run-in-store (package->derivation hello)
6706 $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
6707 @end example
6708
6709 The latter enters a recursive REPL, where all the return values are
6710 automatically run through the store:
6711
6712 @example
6713 scheme@@(guile-user)> ,enter-store-monad
6714 store-monad@@(guile-user) [1]> (package->derivation hello)
6715 $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
6716 store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
6717 $3 = "/gnu/store/@dots{}-foo"
6718 store-monad@@(guile-user) [1]> ,q
6719 scheme@@(guile-user)>
6720 @end example
6721
6722 @noindent
6723 Note that non-monadic values cannot be returned in the
6724 @code{store-monad} REPL.
6725
6726 The main syntactic forms to deal with monads in general are provided by
6727 the @code{(guix monads)} module and are described below.
6728
6729 @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
6730 Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
6731 in @var{monad}.
6732 @end deffn
6733
6734 @deffn {Scheme Syntax} return @var{val}
6735 Return a monadic value that encapsulates @var{val}.
6736 @end deffn
6737
6738 @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
6739 @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
6740 procedures @var{mproc}@dots{}@footnote{This operation is commonly
6741 referred to as ``bind'', but that name denotes an unrelated procedure in
6742 Guile. Thus we use this somewhat cryptic symbol inherited from the
6743 Haskell language.}. There can be one @var{mproc} or several of them, as
6744 in this example:
6745
6746 @example
6747 (run-with-state
6748 (with-monad %state-monad
6749 (>>= (return 1)
6750 (lambda (x) (return (+ 1 x)))
6751 (lambda (x) (return (* 2 x)))))
6752 'some-state)
6753
6754 @result{} 4
6755 @result{} some-state
6756 @end example
6757 @end deffn
6758
6759 @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
6760 @var{body} ...
6761 @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
6762 @var{body} ...
6763 Bind the variables @var{var} to the monadic values @var{mval} in
6764 @var{body}, which is a sequence of expressions. As with the bind
6765 operator, this can be thought of as ``unpacking'' the raw, non-monadic
6766 value ``contained'' in @var{mval} and making @var{var} refer to that
6767 raw, non-monadic value within the scope of the @var{body}. The form
6768 (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
6769 @var{val}, as per @code{let}. The binding operations occur in sequence
6770 from left to right. The last expression of @var{body} must be a monadic
6771 expression, and its result will become the result of the @code{mlet} or
6772 @code{mlet*} when run in the @var{monad}.
6773
6774 @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
6775 (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
6776 @end deffn
6777
6778 @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
6779 Bind @var{mexp} and the following monadic expressions in sequence,
6780 returning the result of the last expression. Every expression in the
6781 sequence must be a monadic expression.
6782
6783 This is akin to @code{mlet}, except that the return values of the
6784 monadic expressions are ignored. In that sense, it is analogous to
6785 @code{begin}, but applied to monadic expressions.
6786 @end deffn
6787
6788 @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
6789 When @var{condition} is true, evaluate the sequence of monadic
6790 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
6791 @var{condition} is false, return @code{*unspecified*} in the current
6792 monad. Every expression in the sequence must be a monadic expression.
6793 @end deffn
6794
6795 @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
6796 When @var{condition} is false, evaluate the sequence of monadic
6797 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
6798 @var{condition} is true, return @code{*unspecified*} in the current
6799 monad. Every expression in the sequence must be a monadic expression.
6800 @end deffn
6801
6802 @cindex state monad
6803 The @code{(guix monads)} module provides the @dfn{state monad}, which
6804 allows an additional value---the state---to be @emph{threaded} through
6805 monadic procedure calls.
6806
6807 @defvr {Scheme Variable} %state-monad
6808 The state monad. Procedures in the state monad can access and change
6809 the state that is threaded.
6810
6811 Consider the example below. The @code{square} procedure returns a value
6812 in the state monad. It returns the square of its argument, but also
6813 increments the current state value:
6814
6815 @example
6816 (define (square x)
6817 (mlet %state-monad ((count (current-state)))
6818 (mbegin %state-monad
6819 (set-current-state (+ 1 count))
6820 (return (* x x)))))
6821
6822 (run-with-state (sequence %state-monad (map square (iota 3))) 0)
6823 @result{} (0 1 4)
6824 @result{} 3
6825 @end example
6826
6827 When ``run'' through @var{%state-monad}, we obtain that additional state
6828 value, which is the number of @code{square} calls.
6829 @end defvr
6830
6831 @deffn {Monadic Procedure} current-state
6832 Return the current state as a monadic value.
6833 @end deffn
6834
6835 @deffn {Monadic Procedure} set-current-state @var{value}
6836 Set the current state to @var{value} and return the previous state as a
6837 monadic value.
6838 @end deffn
6839
6840 @deffn {Monadic Procedure} state-push @var{value}
6841 Push @var{value} to the current state, which is assumed to be a list,
6842 and return the previous state as a monadic value.
6843 @end deffn
6844
6845 @deffn {Monadic Procedure} state-pop
6846 Pop a value from the current state and return it as a monadic value.
6847 The state is assumed to be a list.
6848 @end deffn
6849
6850 @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
6851 Run monadic value @var{mval} starting with @var{state} as the initial
6852 state. Return two values: the resulting value, and the resulting state.
6853 @end deffn
6854
6855 The main interface to the store monad, provided by the @code{(guix
6856 store)} module, is as follows.
6857
6858 @defvr {Scheme Variable} %store-monad
6859 The store monad---an alias for @var{%state-monad}.
6860
6861 Values in the store monad encapsulate accesses to the store. When its
6862 effect is needed, a value of the store monad must be ``evaluated'' by
6863 passing it to the @code{run-with-store} procedure (see below.)
6864 @end defvr
6865
6866 @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
6867 Run @var{mval}, a monadic value in the store monad, in @var{store}, an
6868 open store connection.
6869 @end deffn
6870
6871 @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
6872 Return as a monadic value the absolute file name in the store of the file
6873 containing @var{text}, a string. @var{references} is a list of store items that the
6874 resulting text file refers to; it defaults to the empty list.
6875 @end deffn
6876
6877 @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
6878 Return as a monadic value the absolute file name in the store of the file
6879 containing @var{data}, a bytevector. @var{references} is a list of store
6880 items that the resulting binary file refers to; it defaults to the empty list.
6881 @end deffn
6882
6883 @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
6884 [#:recursive? #t] [#:select? (const #t)]
6885 Return the name of @var{file} once interned in the store. Use
6886 @var{name} as its store name, or the basename of @var{file} if
6887 @var{name} is omitted.
6888
6889 When @var{recursive?} is true, the contents of @var{file} are added
6890 recursively; if @var{file} designates a flat file and @var{recursive?}
6891 is true, its contents are added, and its permission bits are kept.
6892
6893 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
6894 @var{stat})} for each directory entry, where @var{file} is the entry's
6895 absolute file name and @var{stat} is the result of @code{lstat}; exclude
6896 entries for which @var{select?} does not return true.
6897
6898 The example below adds a file to the store, under two different names:
6899
6900 @example
6901 (run-with-store (open-connection)
6902 (mlet %store-monad ((a (interned-file "README"))
6903 (b (interned-file "README" "LEGU-MIN")))
6904 (return (list a b))))
6905
6906 @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
6907 @end example
6908
6909 @end deffn
6910
6911 The @code{(guix packages)} module exports the following package-related
6912 monadic procedures:
6913
6914 @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
6915 [#:system (%current-system)] [#:target #f] @
6916 [#:output "out"]
6917 Return as a monadic
6918 value in the absolute file name of @var{file} within the @var{output}
6919 directory of @var{package}. When @var{file} is omitted, return the name
6920 of the @var{output} directory of @var{package}. When @var{target} is
6921 true, use it as a cross-compilation target triplet.
6922 @end deffn
6923
6924 @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
6925 @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
6926 @var{target} [@var{system}]
6927 Monadic version of @code{package-derivation} and
6928 @code{package-cross-derivation} (@pxref{Defining Packages}).
6929 @end deffn
6930
6931
6932 @node G-Expressions
6933 @section G-Expressions
6934
6935 @cindex G-expression
6936 @cindex build code quoting
6937 So we have ``derivations'', which represent a sequence of build actions
6938 to be performed to produce an item in the store (@pxref{Derivations}).
6939 These build actions are performed when asking the daemon to actually
6940 build the derivations; they are run by the daemon in a container
6941 (@pxref{Invoking guix-daemon}).
6942
6943 @cindex strata of code
6944 It should come as no surprise that we like to write these build actions
6945 in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
6946 code@footnote{The term @dfn{stratum} in this context was coined by
6947 Manuel Serrano et al.@: in the context of their work on Hop. Oleg
6948 Kiselyov, who has written insightful
6949 @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
6950 on this topic}, refers to this kind of code generation as
6951 @dfn{staging}.}: the ``host code''---code that defines packages, talks
6952 to the daemon, etc.---and the ``build code''---code that actually
6953 performs build actions, such as making directories, invoking
6954 @command{make}, etc.
6955
6956 To describe a derivation and its build actions, one typically needs to
6957 embed build code inside host code. It boils down to manipulating build
6958 code as data, and the homoiconicity of Scheme---code has a direct
6959 representation as data---comes in handy for that. But we need more than
6960 the normal @code{quasiquote} mechanism in Scheme to construct build
6961 expressions.
6962
6963 The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
6964 S-expressions adapted to build expressions. G-expressions, or
6965 @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
6966 @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
6967 @code{#$}, and @code{#$@@}), which are comparable to
6968 @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
6969 respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
6970 GNU Guile Reference Manual}). However, there are major differences:
6971
6972 @itemize
6973 @item
6974 Gexps are meant to be written to a file and run or manipulated by other
6975 processes.
6976
6977 @item
6978 When a high-level object such as a package or derivation is unquoted
6979 inside a gexp, the result is as if its output file name had been
6980 introduced.
6981
6982 @item
6983 Gexps carry information about the packages or derivations they refer to,
6984 and these dependencies are automatically added as inputs to the build
6985 processes that use them.
6986 @end itemize
6987
6988 @cindex lowering, of high-level objects in gexps
6989 This mechanism is not limited to package and derivation
6990 objects: @dfn{compilers} able to ``lower'' other high-level objects to
6991 derivations or files in the store can be defined,
6992 such that these objects can also be inserted
6993 into gexps. For example, a useful type of high-level objects that can be
6994 inserted in a gexp is ``file-like objects'', which make it easy to
6995 add files to the store and to refer to them in
6996 derivations and such (see @code{local-file} and @code{plain-file}
6997 below.)
6998
6999 To illustrate the idea, here is an example of a gexp:
7000
7001 @example
7002 (define build-exp
7003 #~(begin
7004 (mkdir #$output)
7005 (chdir #$output)
7006 (symlink (string-append #$coreutils "/bin/ls")
7007 "list-files")))
7008 @end example
7009
7010 This gexp can be passed to @code{gexp->derivation}; we obtain a
7011 derivation that builds a directory containing exactly one symlink to
7012 @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
7013
7014 @example
7015 (gexp->derivation "the-thing" build-exp)
7016 @end example
7017
7018 As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
7019 substituted to the reference to the @var{coreutils} package in the
7020 actual build code, and @var{coreutils} is automatically made an input to
7021 the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
7022 output)}) is replaced by a string containing the directory name of the
7023 output of the derivation.
7024
7025 @cindex cross compilation
7026 In a cross-compilation context, it is useful to distinguish between
7027 references to the @emph{native} build of a package---that can run on the
7028 host---versus references to cross builds of a package. To that end, the
7029 @code{#+} plays the same role as @code{#$}, but is a reference to a
7030 native package build:
7031
7032 @example
7033 (gexp->derivation "vi"
7034 #~(begin
7035 (mkdir #$output)
7036 (system* (string-append #+coreutils "/bin/ln")
7037 "-s"
7038 (string-append #$emacs "/bin/emacs")
7039 (string-append #$output "/bin/vi")))
7040 #:target "mips64el-linux-gnu")
7041 @end example
7042
7043 @noindent
7044 In the example above, the native build of @var{coreutils} is used, so
7045 that @command{ln} can actually run on the host; but then the
7046 cross-compiled build of @var{emacs} is referenced.
7047
7048 @cindex imported modules, for gexps
7049 @findex with-imported-modules
7050 Another gexp feature is @dfn{imported modules}: sometimes you want to be
7051 able to use certain Guile modules from the ``host environment'' in the
7052 gexp, so those modules should be imported in the ``build environment''.
7053 The @code{with-imported-modules} form allows you to express that:
7054
7055 @example
7056 (let ((build (with-imported-modules '((guix build utils))
7057 #~(begin
7058 (use-modules (guix build utils))
7059 (mkdir-p (string-append #$output "/bin"))))))
7060 (gexp->derivation "empty-dir"
7061 #~(begin
7062 #$build
7063 (display "success!\n")
7064 #t)))
7065 @end example
7066
7067 @noindent
7068 In this example, the @code{(guix build utils)} module is automatically
7069 pulled into the isolated build environment of our gexp, such that
7070 @code{(use-modules (guix build utils))} works as expected.
7071
7072 @cindex module closure
7073 @findex source-module-closure
7074 Usually you want the @emph{closure} of the module to be imported---i.e.,
7075 the module itself and all the modules it depends on---rather than just
7076 the module; failing to do that, attempts to use the module will fail
7077 because of missing dependent modules. The @code{source-module-closure}
7078 procedure computes the closure of a module by looking at its source file
7079 headers, which comes in handy in this case:
7080
7081 @example
7082 (use-modules (guix modules)) ;for 'source-module-closure'
7083
7084 (with-imported-modules (source-module-closure
7085 '((guix build utils)
7086 (gnu build vm)))
7087 (gexp->derivation "something-with-vms"
7088 #~(begin
7089 (use-modules (guix build utils)
7090 (gnu build vm))
7091 @dots{})))
7092 @end example
7093
7094 @cindex extensions, for gexps
7095 @findex with-extensions
7096 In the same vein, sometimes you want to import not just pure-Scheme
7097 modules, but also ``extensions'' such as Guile bindings to C libraries
7098 or other ``full-blown'' packages. Say you need the @code{guile-json}
7099 package available on the build side, here's how you would do it:
7100
7101 @example
7102 (use-modules (gnu packages guile)) ;for 'guile-json'
7103
7104 (with-extensions (list guile-json)
7105 (gexp->derivation "something-with-json"
7106 #~(begin
7107 (use-modules (json))
7108 @dots{})))
7109 @end example
7110
7111 The syntactic form to construct gexps is summarized below.
7112
7113 @deffn {Scheme Syntax} #~@var{exp}
7114 @deffnx {Scheme Syntax} (gexp @var{exp})
7115 Return a G-expression containing @var{exp}. @var{exp} may contain one
7116 or more of the following forms:
7117
7118 @table @code
7119 @item #$@var{obj}
7120 @itemx (ungexp @var{obj})
7121 Introduce a reference to @var{obj}. @var{obj} may have one of the
7122 supported types, for example a package or a
7123 derivation, in which case the @code{ungexp} form is replaced by its
7124 output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
7125
7126 If @var{obj} is a list, it is traversed and references to supported
7127 objects are substituted similarly.
7128
7129 If @var{obj} is another gexp, its contents are inserted and its
7130 dependencies are added to those of the containing gexp.
7131
7132 If @var{obj} is another kind of object, it is inserted as is.
7133
7134 @item #$@var{obj}:@var{output}
7135 @itemx (ungexp @var{obj} @var{output})
7136 This is like the form above, but referring explicitly to the
7137 @var{output} of @var{obj}---this is useful when @var{obj} produces
7138 multiple outputs (@pxref{Packages with Multiple Outputs}).
7139
7140 @item #+@var{obj}
7141 @itemx #+@var{obj}:output
7142 @itemx (ungexp-native @var{obj})
7143 @itemx (ungexp-native @var{obj} @var{output})
7144 Same as @code{ungexp}, but produces a reference to the @emph{native}
7145 build of @var{obj} when used in a cross compilation context.
7146
7147 @item #$output[:@var{output}]
7148 @itemx (ungexp output [@var{output}])
7149 Insert a reference to derivation output @var{output}, or to the main
7150 output when @var{output} is omitted.
7151
7152 This only makes sense for gexps passed to @code{gexp->derivation}.
7153
7154 @item #$@@@var{lst}
7155 @itemx (ungexp-splicing @var{lst})
7156 Like the above, but splices the contents of @var{lst} inside the
7157 containing list.
7158
7159 @item #+@@@var{lst}
7160 @itemx (ungexp-native-splicing @var{lst})
7161 Like the above, but refers to native builds of the objects listed in
7162 @var{lst}.
7163
7164 @end table
7165
7166 G-expressions created by @code{gexp} or @code{#~} are run-time objects
7167 of the @code{gexp?} type (see below.)
7168 @end deffn
7169
7170 @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
7171 Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
7172 in their execution environment.
7173
7174 Each item in @var{modules} can be the name of a module, such as
7175 @code{(guix build utils)}, or it can be a module name, followed by an
7176 arrow, followed by a file-like object:
7177
7178 @example
7179 `((guix build utils)
7180 (guix gcrypt)
7181 ((guix config) => ,(scheme-file "config.scm"
7182 #~(define-module @dots{}))))
7183 @end example
7184
7185 @noindent
7186 In the example above, the first two modules are taken from the search
7187 path, and the last one is created from the given file-like object.
7188
7189 This form has @emph{lexical} scope: it has an effect on the gexps
7190 directly defined in @var{body}@dots{}, but not on those defined, say, in
7191 procedures called from @var{body}@dots{}.
7192 @end deffn
7193
7194 @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
7195 Mark the gexps defined in @var{body}@dots{} as requiring
7196 @var{extensions} in their build and execution environment.
7197 @var{extensions} is typically a list of package objects such as those
7198 defined in the @code{(gnu packages guile)} module.
7199
7200 Concretely, the packages listed in @var{extensions} are added to the
7201 load path while compiling imported modules in @var{body}@dots{}; they
7202 are also added to the load path of the gexp returned by
7203 @var{body}@dots{}.
7204 @end deffn
7205
7206 @deffn {Scheme Procedure} gexp? @var{obj}
7207 Return @code{#t} if @var{obj} is a G-expression.
7208 @end deffn
7209
7210 G-expressions are meant to be written to disk, either as code building
7211 some derivation, or as plain files in the store. The monadic procedures
7212 below allow you to do that (@pxref{The Store Monad}, for more
7213 information about monads.)
7214
7215 @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
7216 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
7217 [#:hash #f] [#:hash-algo #f] @
7218 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
7219 [#:module-path @var{%load-path}] @
7220 [#:effective-version "2.2"] @
7221 [#:references-graphs #f] [#:allowed-references #f] @
7222 [#:disallowed-references #f] @
7223 [#:leaked-env-vars #f] @
7224 [#:script-name (string-append @var{name} "-builder")] @
7225 [#:deprecation-warnings #f] @
7226 [#:local-build? #f] [#:substitutable? #t] @
7227 [#:properties '()] [#:guile-for-build #f]
7228 Return a derivation @var{name} that runs @var{exp} (a gexp) with
7229 @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
7230 stored in a file called @var{script-name}. When @var{target} is true,
7231 it is used as the cross-compilation target triplet for packages referred
7232 to by @var{exp}.
7233
7234 @var{modules} is deprecated in favor of @code{with-imported-modules}.
7235 Its meaning is to
7236 make @var{modules} available in the evaluation context of @var{exp};
7237 @var{modules} is a list of names of Guile modules searched in
7238 @var{module-path} to be copied in the store, compiled, and made available in
7239 the load path during the execution of @var{exp}---e.g., @code{((guix
7240 build utils) (guix build gnu-build-system))}.
7241
7242 @var{effective-version} determines the string to use when adding extensions of
7243 @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
7244
7245 @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
7246 applicable.
7247
7248 When @var{references-graphs} is true, it must be a list of tuples of one of the
7249 following forms:
7250
7251 @example
7252 (@var{file-name} @var{package})
7253 (@var{file-name} @var{package} @var{output})
7254 (@var{file-name} @var{derivation})
7255 (@var{file-name} @var{derivation} @var{output})
7256 (@var{file-name} @var{store-item})
7257 @end example
7258
7259 The right-hand-side of each element of @var{references-graphs} is automatically made
7260 an input of the build process of @var{exp}. In the build environment, each
7261 @var{file-name} contains the reference graph of the corresponding item, in a simple
7262 text format.
7263
7264 @var{allowed-references} must be either @code{#f} or a list of output names and packages.
7265 In the latter case, the list denotes store items that the result is allowed to
7266 refer to. Any reference to another store item will lead to a build error.
7267 Similarly for @var{disallowed-references}, which can list items that must not be
7268 referenced by the outputs.
7269
7270 @var{deprecation-warnings} determines whether to show deprecation warnings while
7271 compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
7272
7273 The other arguments are as for @code{derivation} (@pxref{Derivations}).
7274 @end deffn
7275
7276 @cindex file-like objects
7277 The @code{local-file}, @code{plain-file}, @code{computed-file},
7278 @code{program-file}, and @code{scheme-file} procedures below return
7279 @dfn{file-like objects}. That is, when unquoted in a G-expression,
7280 these objects lead to a file in the store. Consider this G-expression:
7281
7282 @example
7283 #~(system* #$(file-append glibc "/sbin/nscd") "-f"
7284 #$(local-file "/tmp/my-nscd.conf"))
7285 @end example
7286
7287 The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
7288 to the store. Once expanded, for instance @i{via}
7289 @code{gexp->derivation}, the G-expression refers to that copy under
7290 @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
7291 does not have any effect on what the G-expression does.
7292 @code{plain-file} can be used similarly; it differs in that the file
7293 content is directly passed as a string.
7294
7295 @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
7296 [#:recursive? #f] [#:select? (const #t)]
7297 Return an object representing local file @var{file} to add to the store; this
7298 object can be used in a gexp. If @var{file} is a relative file name, it is looked
7299 up relative to the source file where this form appears. @var{file} will be added to
7300 the store under @var{name}--by default the base name of @var{file}.
7301
7302 When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
7303 designates a flat file and @var{recursive?} is true, its contents are added, and its
7304 permission bits are kept.
7305
7306 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
7307 @var{stat})} for each directory entry, where @var{file} is the entry's
7308 absolute file name and @var{stat} is the result of @code{lstat}; exclude
7309 entries for which @var{select?} does not return true.
7310
7311 This is the declarative counterpart of the @code{interned-file} monadic
7312 procedure (@pxref{The Store Monad, @code{interned-file}}).
7313 @end deffn
7314
7315 @deffn {Scheme Procedure} plain-file @var{name} @var{content}
7316 Return an object representing a text file called @var{name} with the given
7317 @var{content} (a string or a bytevector) to be added to the store.
7318
7319 This is the declarative counterpart of @code{text-file}.
7320 @end deffn
7321
7322 @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
7323 [#:options '(#:local-build? #t)]
7324 Return an object representing the store item @var{name}, a file or
7325 directory computed by @var{gexp}. @var{options}
7326 is a list of additional arguments to pass to @code{gexp->derivation}.
7327
7328 This is the declarative counterpart of @code{gexp->derivation}.
7329 @end deffn
7330
7331 @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
7332 [#:guile (default-guile)] [#:module-path %load-path]
7333 Return an executable script @var{name} that runs @var{exp} using
7334 @var{guile}, with @var{exp}'s imported modules in its search path.
7335 Look up @var{exp}'s modules in @var{module-path}.
7336
7337 The example below builds a script that simply invokes the @command{ls}
7338 command:
7339
7340 @example
7341 (use-modules (guix gexp) (gnu packages base))
7342
7343 (gexp->script "list-files"
7344 #~(execl #$(file-append coreutils "/bin/ls")
7345 "ls"))
7346 @end example
7347
7348 When ``running'' it through the store (@pxref{The Store Monad,
7349 @code{run-with-store}}), we obtain a derivation that produces an
7350 executable file @file{/gnu/store/@dots{}-list-files} along these lines:
7351
7352 @example
7353 #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
7354 !#
7355 (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
7356 @end example
7357 @end deffn
7358
7359 @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
7360 [#:guile #f] [#:module-path %load-path]
7361 Return an object representing the executable store item @var{name} that
7362 runs @var{gexp}. @var{guile} is the Guile package used to execute that
7363 script. Imported modules of @var{gexp} are looked up in @var{module-path}.
7364
7365 This is the declarative counterpart of @code{gexp->script}.
7366 @end deffn
7367
7368 @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
7369 [#:set-load-path? #t] [#:module-path %load-path] @
7370 [#:splice? #f] @
7371 [#:guile (default-guile)]
7372 Return a derivation that builds a file @var{name} containing @var{exp}.
7373 When @var{splice?} is true, @var{exp} is considered to be a list of
7374 expressions that will be spliced in the resulting file.
7375
7376 When @var{set-load-path?} is true, emit code in the resulting file to
7377 set @code{%load-path} and @code{%load-compiled-path} to honor
7378 @var{exp}'s imported modules. Look up @var{exp}'s modules in
7379 @var{module-path}.
7380
7381 The resulting file holds references to all the dependencies of @var{exp}
7382 or a subset thereof.
7383 @end deffn
7384
7385 @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f]
7386 Return an object representing the Scheme file @var{name} that contains
7387 @var{exp}.
7388
7389 This is the declarative counterpart of @code{gexp->file}.
7390 @end deffn
7391
7392 @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
7393 Return as a monadic value a derivation that builds a text file
7394 containing all of @var{text}. @var{text} may list, in addition to
7395 strings, objects of any type that can be used in a gexp: packages,
7396 derivations, local file objects, etc. The resulting store file holds
7397 references to all these.
7398
7399 This variant should be preferred over @code{text-file} anytime the file
7400 to create will reference items from the store. This is typically the
7401 case when building a configuration file that embeds store file names,
7402 like this:
7403
7404 @example
7405 (define (profile.sh)
7406 ;; Return the name of a shell script in the store that
7407 ;; initializes the 'PATH' environment variable.
7408 (text-file* "profile.sh"
7409 "export PATH=" coreutils "/bin:"
7410 grep "/bin:" sed "/bin\n"))
7411 @end example
7412
7413 In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
7414 will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
7415 preventing them from being garbage-collected during its lifetime.
7416 @end deffn
7417
7418 @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
7419 Return an object representing store file @var{name} containing
7420 @var{text}. @var{text} is a sequence of strings and file-like objects,
7421 as in:
7422
7423 @example
7424 (mixed-text-file "profile"
7425 "export PATH=" coreutils "/bin:" grep "/bin")
7426 @end example
7427
7428 This is the declarative counterpart of @code{text-file*}.
7429 @end deffn
7430
7431 @deffn {Scheme Procedure} file-union @var{name} @var{files}
7432 Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
7433 Each item in @var{files} must be a two-element list where the first element is the
7434 file name to use in the new directory, and the second element is a gexp
7435 denoting the target file. Here's an example:
7436
7437 @example
7438 (file-union "etc"
7439 `(("hosts" ,(plain-file "hosts"
7440 "127.0.0.1 localhost"))
7441 ("bashrc" ,(plain-file "bashrc"
7442 "alias ls='ls --color=auto'"))))
7443 @end example
7444
7445 This yields an @code{etc} directory containing these two files.
7446 @end deffn
7447
7448 @deffn {Scheme Procedure} directory-union @var{name} @var{things}
7449 Return a directory that is the union of @var{things}, where @var{things} is a list of
7450 file-like objects denoting directories. For example:
7451
7452 @example
7453 (directory-union "guile+emacs" (list guile emacs))
7454 @end example
7455
7456 yields a directory that is the union of the @code{guile} and @code{emacs} packages.
7457 @end deffn
7458
7459 @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
7460 Return a file-like object that expands to the concatenation of @var{obj}
7461 and @var{suffix}, where @var{obj} is a lowerable object and each
7462 @var{suffix} is a string.
7463
7464 As an example, consider this gexp:
7465
7466 @example
7467 (gexp->script "run-uname"
7468 #~(system* #$(file-append coreutils
7469 "/bin/uname")))
7470 @end example
7471
7472 The same effect could be achieved with:
7473
7474 @example
7475 (gexp->script "run-uname"
7476 #~(system* (string-append #$coreutils
7477 "/bin/uname")))
7478 @end example
7479
7480 There is one difference though: in the @code{file-append} case, the
7481 resulting script contains the absolute file name as a string, whereas in
7482 the second case, the resulting script contains a @code{(string-append
7483 @dots{})} expression to construct the file name @emph{at run time}.
7484 @end deffn
7485
7486
7487 Of course, in addition to gexps embedded in ``host'' code, there are
7488 also modules containing build tools. To make it clear that they are
7489 meant to be used in the build stratum, these modules are kept in the
7490 @code{(guix build @dots{})} name space.
7491
7492 @cindex lowering, of high-level objects in gexps
7493 Internally, high-level objects are @dfn{lowered}, using their compiler,
7494 to either derivations or store items. For instance, lowering a package
7495 yields a derivation, and lowering a @code{plain-file} yields a store
7496 item. This is achieved using the @code{lower-object} monadic procedure.
7497
7498 @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
7499 [#:target #f]
7500 Return as a value in @var{%store-monad} the derivation or store item
7501 corresponding to @var{obj} for @var{system}, cross-compiling for
7502 @var{target} if @var{target} is true. @var{obj} must be an object that
7503 has an associated gexp compiler, such as a @code{<package>}.
7504 @end deffn
7505
7506 @node Invoking guix repl
7507 @section Invoking @command{guix repl}
7508
7509 @cindex REPL, read-eval-print loop
7510 The @command{guix repl} command spawns a Guile @dfn{read-eval-print loop}
7511 (REPL) for interactive programming (@pxref{Using Guile Interactively,,, guile,
7512 GNU Guile Reference Manual}). Compared to just launching the @command{guile}
7513 command, @command{guix repl} guarantees that all the Guix modules and all its
7514 dependencies are available in the search path. You can use it this way:
7515
7516 @example
7517 $ guix repl
7518 scheme@@(guile-user)> ,use (gnu packages base)
7519 scheme@@(guile-user)> coreutils
7520 $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
7521 @end example
7522
7523 @cindex inferiors
7524 In addition, @command{guix repl} implements a simple machine-readable REPL
7525 protocol for use by @code{(guix inferior)}, a facility to interact with
7526 @dfn{inferiors}, separate processes running a potentially different revision
7527 of Guix.
7528
7529 The available options are as follows:
7530
7531 @table @code
7532 @item --type=@var{type}
7533 @itemx -t @var{type}
7534 Start a REPL of the given @var{TYPE}, which can be one of the following:
7535
7536 @table @code
7537 @item guile
7538 This is default, and it spawns a standard full-featured Guile REPL.
7539 @item machine
7540 Spawn a REPL that uses the machine-readable protocol. This is the protocol
7541 that the @code{(guix inferior)} module speaks.
7542 @end table
7543
7544 @item --listen=@var{endpoint}
7545 By default, @command{guix repl} reads from standard input and writes to
7546 standard output. When this option is passed, it will instead listen for
7547 connections on @var{endpoint}. Here are examples of valid options:
7548
7549 @table @code
7550 @item --listen=tcp:37146
7551 Accept connections on localhost on port 37146.
7552
7553 @item --listen=unix:/tmp/socket
7554 Accept connections on the Unix-domain socket @file{/tmp/socket}.
7555 @end table
7556 @end table
7557
7558 @c *********************************************************************
7559 @node Utilities
7560 @chapter Utilities
7561
7562 This section describes Guix command-line utilities. Some of them are
7563 primarily targeted at developers and users who write new package
7564 definitions, while others are more generally useful. They complement
7565 the Scheme programming interface of Guix in a convenient way.
7566
7567 @menu
7568 * Invoking guix build:: Building packages from the command line.
7569 * Invoking guix edit:: Editing package definitions.
7570 * Invoking guix download:: Downloading a file and printing its hash.
7571 * Invoking guix hash:: Computing the cryptographic hash of a file.
7572 * Invoking guix import:: Importing package definitions.
7573 * Invoking guix refresh:: Updating package definitions.
7574 * Invoking guix lint:: Finding errors in package definitions.
7575 * Invoking guix size:: Profiling disk usage.
7576 * Invoking guix graph:: Visualizing the graph of packages.
7577 * Invoking guix publish:: Sharing substitutes.
7578 * Invoking guix challenge:: Challenging substitute servers.
7579 * Invoking guix copy:: Copying to and from a remote store.
7580 * Invoking guix container:: Process isolation.
7581 * Invoking guix weather:: Assessing substitute availability.
7582 * Invoking guix processes:: Listing client processes.
7583 @end menu
7584
7585 @node Invoking guix build
7586 @section Invoking @command{guix build}
7587
7588 @cindex package building
7589 @cindex @command{guix build}
7590 The @command{guix build} command builds packages or derivations and
7591 their dependencies, and prints the resulting store paths. Note that it
7592 does not modify the user's profile---this is the job of the
7593 @command{guix package} command (@pxref{Invoking guix package}). Thus,
7594 it is mainly useful for distribution developers.
7595
7596 The general syntax is:
7597
7598 @example
7599 guix build @var{options} @var{package-or-derivation}@dots{}
7600 @end example
7601
7602 As an example, the following command builds the latest versions of Emacs
7603 and of Guile, displays their build logs, and finally displays the
7604 resulting directories:
7605
7606 @example
7607 guix build emacs guile
7608 @end example
7609
7610 Similarly, the following command builds all the available packages:
7611
7612 @example
7613 guix build --quiet --keep-going \
7614 `guix package -A | cut -f1,2 --output-delimiter=@@`
7615 @end example
7616
7617 @var{package-or-derivation} may be either the name of a package found in
7618 the software distribution such as @code{coreutils} or
7619 @code{coreutils@@8.20}, or a derivation such as
7620 @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
7621 package with the corresponding name (and optionally version) is searched
7622 for among the GNU distribution modules (@pxref{Package Modules}).
7623
7624 Alternatively, the @code{--expression} option may be used to specify a
7625 Scheme expression that evaluates to a package; this is useful when
7626 disambiguating among several same-named packages or package variants is
7627 needed.
7628
7629 There may be zero or more @var{options}. The available options are
7630 described in the subsections below.
7631
7632 @menu
7633 * Common Build Options:: Build options for most commands.
7634 * Package Transformation Options:: Creating variants of packages.
7635 * Additional Build Options:: Options specific to 'guix build'.
7636 * Debugging Build Failures:: Real life packaging experience.
7637 @end menu
7638
7639 @node Common Build Options
7640 @subsection Common Build Options
7641
7642 A number of options that control the build process are common to
7643 @command{guix build} and other commands that can spawn builds, such as
7644 @command{guix package} or @command{guix archive}. These are the
7645 following:
7646
7647 @table @code
7648
7649 @item --load-path=@var{directory}
7650 @itemx -L @var{directory}
7651 Add @var{directory} to the front of the package module search path
7652 (@pxref{Package Modules}).
7653
7654 This allows users to define their own packages and make them visible to
7655 the command-line tools.
7656
7657 @item --keep-failed
7658 @itemx -K
7659 Keep the build tree of failed builds. Thus, if a build fails, its build
7660 tree is kept under @file{/tmp}, in a directory whose name is shown at
7661 the end of the build log. This is useful when debugging build issues.
7662 @xref{Debugging Build Failures}, for tips and tricks on how to debug
7663 build issues.
7664
7665 This option has no effect when connecting to a remote daemon with a
7666 @code{guix://} URI (@pxref{The Store, the @code{GUIX_DAEMON_SOCKET}
7667 variable}).
7668
7669 @item --keep-going
7670 @itemx -k
7671 Keep going when some of the derivations fail to build; return only once
7672 all the builds have either completed or failed.
7673
7674 The default behavior is to stop as soon as one of the specified
7675 derivations has failed.
7676
7677 @item --dry-run
7678 @itemx -n
7679 Do not build the derivations.
7680
7681 @anchor{fallback-option}
7682 @item --fallback
7683 When substituting a pre-built binary fails, fall back to building
7684 packages locally (@pxref{Substitution Failure}).
7685
7686 @item --substitute-urls=@var{urls}
7687 @anchor{client-substitute-urls}
7688 Consider @var{urls} the whitespace-separated list of substitute source
7689 URLs, overriding the default list of URLs of @command{guix-daemon}
7690 (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
7691
7692 This means that substitutes may be downloaded from @var{urls}, provided
7693 they are signed by a key authorized by the system administrator
7694 (@pxref{Substitutes}).
7695
7696 When @var{urls} is the empty string, substitutes are effectively
7697 disabled.
7698
7699 @item --no-substitutes
7700 Do not use substitutes for build products. That is, always build things
7701 locally instead of allowing downloads of pre-built binaries
7702 (@pxref{Substitutes}).
7703
7704 @item --no-grafts
7705 Do not ``graft'' packages. In practice, this means that package updates
7706 available as grafts are not applied. @xref{Security Updates}, for more
7707 information on grafts.
7708
7709 @item --rounds=@var{n}
7710 Build each derivation @var{n} times in a row, and raise an error if
7711 consecutive build results are not bit-for-bit identical.
7712
7713 This is a useful way to detect non-deterministic builds processes.
7714 Non-deterministic build processes are a problem because they make it
7715 practically impossible for users to @emph{verify} whether third-party
7716 binaries are genuine. @xref{Invoking guix challenge}, for more.
7717
7718 Note that, currently, the differing build results are not kept around,
7719 so you will have to manually investigate in case of an error---e.g., by
7720 stashing one of the build results with @code{guix archive --export}
7721 (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
7722 the two results.
7723
7724 @item --no-build-hook
7725 Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
7726 (@pxref{Daemon Offload Setup}). That is, always build things locally
7727 instead of offloading builds to remote machines.
7728
7729 @item --max-silent-time=@var{seconds}
7730 When the build or substitution process remains silent for more than
7731 @var{seconds}, terminate it and report a build failure.
7732
7733 By default, the daemon's setting is honored (@pxref{Invoking
7734 guix-daemon, @code{--max-silent-time}}).
7735
7736 @item --timeout=@var{seconds}
7737 Likewise, when the build or substitution process lasts for more than
7738 @var{seconds}, terminate it and report a build failure.
7739
7740 By default, the daemon's setting is honored (@pxref{Invoking
7741 guix-daemon, @code{--timeout}}).
7742
7743 @c Note: This option is actually not part of %standard-build-options but
7744 @c most programs honor it.
7745 @cindex verbosity, of the command-line tools
7746 @cindex build logs, verbosity
7747 @item -v @var{level}
7748 @itemx --verbosity=@var{level}
7749 Use the given verbosity @var{level}, an integer. Choosing 0 means that no
7750 output is produced, 1 is for quiet output, and 2 shows all the build log
7751 output on standard error.
7752
7753 @item --cores=@var{n}
7754 @itemx -c @var{n}
7755 Allow the use of up to @var{n} CPU cores for the build. The special
7756 value @code{0} means to use as many CPU cores as available.
7757
7758 @item --max-jobs=@var{n}
7759 @itemx -M @var{n}
7760 Allow at most @var{n} build jobs in parallel. @xref{Invoking
7761 guix-daemon, @code{--max-jobs}}, for details about this option and the
7762 equivalent @command{guix-daemon} option.
7763
7764 @item --debug=@var{level}
7765 Produce debugging output coming from the build daemon. @var{level} must be an
7766 integer between 0 and 5; higher means more verbose output. Setting a level of
7767 4 or more may be helpful when debugging setup issues with the build daemon.
7768
7769 @end table
7770
7771 Behind the scenes, @command{guix build} is essentially an interface to
7772 the @code{package-derivation} procedure of the @code{(guix packages)}
7773 module, and to the @code{build-derivations} procedure of the @code{(guix
7774 derivations)} module.
7775
7776 In addition to options explicitly passed on the command line,
7777 @command{guix build} and other @command{guix} commands that support
7778 building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
7779
7780 @defvr {Environment Variable} GUIX_BUILD_OPTIONS
7781 Users can define this variable to a list of command line options that
7782 will automatically be used by @command{guix build} and other
7783 @command{guix} commands that can perform builds, as in the example
7784 below:
7785
7786 @example
7787 $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
7788 @end example
7789
7790 These options are parsed independently, and the result is appended to
7791 the parsed command-line options.
7792 @end defvr
7793
7794
7795 @node Package Transformation Options
7796 @subsection Package Transformation Options
7797
7798 @cindex package variants
7799 Another set of command-line options supported by @command{guix build}
7800 and also @command{guix package} are @dfn{package transformation
7801 options}. These are options that make it possible to define @dfn{package
7802 variants}---for instance, packages built from different source code.
7803 This is a convenient way to create customized packages on the fly
7804 without having to type in the definitions of package variants
7805 (@pxref{Defining Packages}).
7806
7807 @table @code
7808
7809 @item --with-source=@var{source}
7810 @itemx --with-source=@var{package}=@var{source}
7811 @itemx --with-source=@var{package}@@@var{version}=@var{source}
7812 Use @var{source} as the source of @var{package}, and @var{version} as
7813 its version number.
7814 @var{source} must be a file name or a URL, as for @command{guix
7815 download} (@pxref{Invoking guix download}).
7816
7817 When @var{package} is omitted,
7818 it is taken to be the package name specified on the
7819 command line that matches the base of @var{source}---e.g.,
7820 if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
7821 package is @code{guile}.
7822
7823 Likewise, when @var{version} is omitted, the version string is inferred from
7824 @var{source}; in the previous example, it is @code{2.0.10}.
7825
7826 This option allows users to try out versions of packages other than the
7827 one provided by the distribution. The example below downloads
7828 @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
7829 the @code{ed} package:
7830
7831 @example
7832 guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
7833 @end example
7834
7835 As a developer, @code{--with-source} makes it easy to test release
7836 candidates:
7837
7838 @example
7839 guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
7840 @end example
7841
7842 @dots{} or to build from a checkout in a pristine environment:
7843
7844 @example
7845 $ git clone git://git.sv.gnu.org/guix.git
7846 $ guix build guix --with-source=guix@@1.0=./guix
7847 @end example
7848
7849 @item --with-input=@var{package}=@var{replacement}
7850 Replace dependency on @var{package} by a dependency on
7851 @var{replacement}. @var{package} must be a package name, and
7852 @var{replacement} must be a package specification such as @code{guile}
7853 or @code{guile@@1.8}.
7854
7855 For instance, the following command builds Guix, but replaces its
7856 dependency on the current stable version of Guile with a dependency on
7857 the legacy version of Guile, @code{guile@@2.0}:
7858
7859 @example
7860 guix build --with-input=guile=guile@@2.0 guix
7861 @end example
7862
7863 This is a recursive, deep replacement. So in this example, both
7864 @code{guix} and its dependency @code{guile-json} (which also depends on
7865 @code{guile}) get rebuilt against @code{guile@@2.0}.
7866
7867 This is implemented using the @code{package-input-rewriting} Scheme
7868 procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
7869
7870 @item --with-graft=@var{package}=@var{replacement}
7871 This is similar to @code{--with-input} but with an important difference:
7872 instead of rebuilding the whole dependency chain, @var{replacement} is
7873 built and then @dfn{grafted} onto the binaries that were initially
7874 referring to @var{package}. @xref{Security Updates}, for more
7875 information on grafts.
7876
7877 For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
7878 and all its dependencies, replacing references to the version of GnuTLS
7879 they currently refer to:
7880
7881 @example
7882 guix build --with-graft=gnutls=gnutls@@3.5.4 wget
7883 @end example
7884
7885 This has the advantage of being much faster than rebuilding everything.
7886 But there is a caveat: it works if and only if @var{package} and
7887 @var{replacement} are strictly compatible---for example, if they provide
7888 a library, the application binary interface (ABI) of those libraries
7889 must be compatible. If @var{replacement} is somehow incompatible with
7890 @var{package}, then the resulting package may be unusable. Use with
7891 care!
7892
7893 @item --with-git-url=@var{package}=@var{url}
7894 @cindex Git, using the latest commit
7895 @cindex latest commit, building
7896 Build @var{package} from the latest commit of the @code{master} branch of the
7897 Git repository at @var{url}. Git sub-modules of the repository are fetched,
7898 recursively.
7899
7900 For example, the following command builds the NumPy Python library against the
7901 latest commit of the master branch of Python itself:
7902
7903 @example
7904 guix build python-numpy \
7905 --with-git-url=python=https://github.com/python/cpython
7906 @end example
7907
7908 This option can also be combined with @code{--with-branch} or
7909 @code{--with-commit} (see below).
7910
7911 @cindex continuous integration
7912 Obviously, since it uses the latest commit of the given branch, the result of
7913 such a command varies over time. Nevertheless it is a convenient way to
7914 rebuild entire software stacks against the latest commit of one or more
7915 packages. This is particularly useful in the context of continuous
7916 integration (CI).
7917
7918 Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
7919 consecutive accesses to the same repository. You may want to clean it up once
7920 in a while to save disk space.
7921
7922 @item --with-branch=@var{package}=@var{branch}
7923 Build @var{package} from the latest commit of @var{branch}. If the
7924 @code{source} field of @var{package} is an origin with the @code{git-fetch}
7925 method (@pxref{origin Reference}) or a @code{git-checkout} object, the
7926 repository URL is taken from that @code{source}. Otherwise you have to use
7927 @code{--with-git-url} to specify the URL of the Git repository.
7928
7929 For instance, the following command builds @code{guile-sqlite3} from the
7930 latest commit of its @code{master} branch, and then builds @code{guix} (which
7931 depends on it) and @code{cuirass} (which depends on @code{guix}) against this
7932 specific @code{guile-sqlite3} build:
7933
7934 @example
7935 guix build --with-branch=guile-sqlite3=master cuirass
7936 @end example
7937
7938 @item --with-commit=@var{package}=@var{commit}
7939 This is similar to @code{--with-branch}, except that it builds from
7940 @var{commit} rather than the tip of a branch. @var{commit} must be a valid
7941 Git commit SHA1 identifier.
7942 @end table
7943
7944 @node Additional Build Options
7945 @subsection Additional Build Options
7946
7947 The command-line options presented below are specific to @command{guix
7948 build}.
7949
7950 @table @code
7951
7952 @item --quiet
7953 @itemx -q
7954 Build quietly, without displaying the build log; this is equivalent to
7955 @code{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
7956 (or similar) and can always be retrieved using the @option{--log-file} option.
7957
7958 @item --file=@var{file}
7959 @itemx -f @var{file}
7960 Build the package, derivation, or other file-like object that the code within
7961 @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
7962
7963 As an example, @var{file} might contain a package definition like this
7964 (@pxref{Defining Packages}):
7965
7966 @example
7967 @verbatiminclude package-hello.scm
7968 @end example
7969
7970 @item --expression=@var{expr}
7971 @itemx -e @var{expr}
7972 Build the package or derivation @var{expr} evaluates to.
7973
7974 For example, @var{expr} may be @code{(@@ (gnu packages guile)
7975 guile-1.8)}, which unambiguously designates this specific variant of
7976 version 1.8 of Guile.
7977
7978 Alternatively, @var{expr} may be a G-expression, in which case it is used
7979 as a build program passed to @code{gexp->derivation}
7980 (@pxref{G-Expressions}).
7981
7982 Lastly, @var{expr} may refer to a zero-argument monadic procedure
7983 (@pxref{The Store Monad}). The procedure must return a derivation as a
7984 monadic value, which is then passed through @code{run-with-store}.
7985
7986 @item --source
7987 @itemx -S
7988 Build the source derivations of the packages, rather than the packages
7989 themselves.
7990
7991 For instance, @code{guix build -S gcc} returns something like
7992 @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
7993 source tarball.
7994
7995 The returned source tarball is the result of applying any patches and
7996 code snippets specified in the package @code{origin} (@pxref{Defining
7997 Packages}).
7998
7999 @item --sources
8000 Fetch and return the source of @var{package-or-derivation} and all their
8001 dependencies, recursively. This is a handy way to obtain a local copy
8002 of all the source code needed to build @var{packages}, allowing you to
8003 eventually build them even without network access. It is an extension
8004 of the @code{--source} option and can accept one of the following
8005 optional argument values:
8006
8007 @table @code
8008 @item package
8009 This value causes the @code{--sources} option to behave in the same way
8010 as the @code{--source} option.
8011
8012 @item all
8013 Build the source derivations of all packages, including any source that
8014 might be listed as @code{inputs}. This is the default value.
8015
8016 @example
8017 $ guix build --sources tzdata
8018 The following derivations will be built:
8019 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
8020 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
8021 @end example
8022
8023 @item transitive
8024 Build the source derivations of all packages, as well of all transitive
8025 inputs to the packages. This can be used e.g.@: to
8026 prefetch package source for later offline building.
8027
8028 @example
8029 $ guix build --sources=transitive tzdata
8030 The following derivations will be built:
8031 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
8032 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
8033 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
8034 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
8035 /gnu/store/@dots{}-make-4.1.tar.xz.drv
8036 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
8037 @dots{}
8038 @end example
8039
8040 @end table
8041
8042 @item --system=@var{system}
8043 @itemx -s @var{system}
8044 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
8045 the system type of the build host. The @command{guix build} command allows
8046 you to repeat this option several times, in which case it builds for all the
8047 specified systems; other commands ignore extraneous @option{-s} options.
8048
8049 @quotation Note
8050 The @code{--system} flag is for @emph{native} compilation and must not
8051 be confused with cross-compilation. See @code{--target} below for
8052 information on cross-compilation.
8053 @end quotation
8054
8055 An example use of this is on Linux-based systems, which can emulate
8056 different personalities. For instance, passing
8057 @code{--system=i686-linux} on an @code{x86_64-linux} system or
8058 @code{--system=armhf-linux} on an @code{aarch64-linux} system allows you
8059 to build packages in a complete 32-bit environment.
8060
8061 @quotation Note
8062 Building for an @code{armhf-linux} system is unconditionally enabled on
8063 @code{aarch64-linux} machines, although certain aarch64 chipsets do not
8064 allow for this functionality, notably the ThunderX.
8065 @end quotation
8066
8067 Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
8068 is enabled (@pxref{Virtualization Services,
8069 @code{qemu-binfmt-service-type}}), you can build for any system for
8070 which a QEMU @code{binfmt_misc} handler is installed.
8071
8072 Builds for a system other than that of the machine you are using can
8073 also be offloaded to a remote machine of the right architecture.
8074 @xref{Daemon Offload Setup}, for more information on offloading.
8075
8076 @item --target=@var{triplet}
8077 @cindex cross-compilation
8078 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
8079 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
8080 configuration triplets,, autoconf, Autoconf}).
8081
8082 @anchor{build-check}
8083 @item --check
8084 @cindex determinism, checking
8085 @cindex reproducibility, checking
8086 Rebuild @var{package-or-derivation}, which are already available in the
8087 store, and raise an error if the build results are not bit-for-bit
8088 identical.
8089
8090 This mechanism allows you to check whether previously installed
8091 substitutes are genuine (@pxref{Substitutes}), or whether the build result
8092 of a package is deterministic. @xref{Invoking guix challenge}, for more
8093 background information and tools.
8094
8095 When used in conjunction with @option{--keep-failed}, the differing
8096 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
8097 This makes it easy to look for differences between the two results.
8098
8099 @item --repair
8100 @cindex repairing store items
8101 @cindex corruption, recovering from
8102 Attempt to repair the specified store items, if they are corrupt, by
8103 re-downloading or rebuilding them.
8104
8105 This operation is not atomic and thus restricted to @code{root}.
8106
8107 @item --derivations
8108 @itemx -d
8109 Return the derivation paths, not the output paths, of the given
8110 packages.
8111
8112 @item --root=@var{file}
8113 @itemx -r @var{file}
8114 @cindex GC roots, adding
8115 @cindex garbage collector roots, adding
8116 Make @var{file} a symlink to the result, and register it as a garbage
8117 collector root.
8118
8119 Consequently, the results of this @command{guix build} invocation are
8120 protected from garbage collection until @var{file} is removed. When
8121 that option is omitted, build results are eligible for garbage
8122 collection as soon as the build completes. @xref{Invoking guix gc}, for
8123 more on GC roots.
8124
8125 @item --log-file
8126 @cindex build logs, access
8127 Return the build log file names or URLs for the given
8128 @var{package-or-derivation}, or raise an error if build logs are
8129 missing.
8130
8131 This works regardless of how packages or derivations are specified. For
8132 instance, the following invocations are equivalent:
8133
8134 @example
8135 guix build --log-file `guix build -d guile`
8136 guix build --log-file `guix build guile`
8137 guix build --log-file guile
8138 guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
8139 @end example
8140
8141 If a log is unavailable locally, and unless @code{--no-substitutes} is
8142 passed, the command looks for a corresponding log on one of the
8143 substitute servers (as specified with @code{--substitute-urls}.)
8144
8145 So for instance, imagine you want to see the build log of GDB on MIPS,
8146 but you are actually on an @code{x86_64} machine:
8147
8148 @example
8149 $ guix build --log-file gdb -s mips64el-linux
8150 https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
8151 @end example
8152
8153 You can freely access a huge library of build logs!
8154 @end table
8155
8156 @node Debugging Build Failures
8157 @subsection Debugging Build Failures
8158
8159 @cindex build failures, debugging
8160 When defining a new package (@pxref{Defining Packages}), you will
8161 probably find yourself spending some time debugging and tweaking the
8162 build until it succeeds. To do that, you need to operate the build
8163 commands yourself in an environment as close as possible to the one the
8164 build daemon uses.
8165
8166 To that end, the first thing to do is to use the @option{--keep-failed}
8167 or @option{-K} option of @command{guix build}, which will keep the
8168 failed build tree in @file{/tmp} or whatever directory you specified as
8169 @code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
8170
8171 From there on, you can @command{cd} to the failed build tree and source
8172 the @file{environment-variables} file, which contains all the
8173 environment variable definitions that were in place when the build
8174 failed. So let's say you're debugging a build failure in package
8175 @code{foo}; a typical session would look like this:
8176
8177 @example
8178 $ guix build foo -K
8179 @dots{} @i{build fails}
8180 $ cd /tmp/guix-build-foo.drv-0
8181 $ source ./environment-variables
8182 $ cd foo-1.2
8183 @end example
8184
8185 Now, you can invoke commands as if you were the daemon (almost) and
8186 troubleshoot your build process.
8187
8188 Sometimes it happens that, for example, a package's tests pass when you
8189 run them manually but they fail when the daemon runs them. This can
8190 happen because the daemon runs builds in containers where, unlike in our
8191 environment above, network access is missing, @file{/bin/sh} does not
8192 exist, etc. (@pxref{Build Environment Setup}).
8193
8194 In such cases, you may need to run inspect the build process from within
8195 a container similar to the one the build daemon creates:
8196
8197 @example
8198 $ guix build -K foo
8199 @dots{}
8200 $ cd /tmp/guix-build-foo.drv-0
8201 $ guix environment --no-grafts -C foo --ad-hoc strace gdb
8202 [env]# source ./environment-variables
8203 [env]# cd foo-1.2
8204 @end example
8205
8206 Here, @command{guix environment -C} creates a container and spawns a new
8207 shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
8208 strace gdb} part adds the @command{strace} and @command{gdb} commands to
8209 the container, which would may find handy while debugging. The
8210 @option{--no-grafts} option makes sure we get the exact same
8211 environment, with ungrafted packages (@pxref{Security Updates}, for more
8212 info on grafts).
8213
8214 To get closer to a container like that used by the build daemon, we can
8215 remove @file{/bin/sh}:
8216
8217 @example
8218 [env]# rm /bin/sh
8219 @end example
8220
8221 (Don't worry, this is harmless: this is all happening in the throw-away
8222 container created by @command{guix environment}.)
8223
8224 The @command{strace} command is probably not in the search path, but we
8225 can run:
8226
8227 @example
8228 [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
8229 @end example
8230
8231 In this way, not only you will have reproduced the environment variables
8232 the daemon uses, you will also be running the build process in a container
8233 similar to the one the daemon uses.
8234
8235
8236 @node Invoking guix edit
8237 @section Invoking @command{guix edit}
8238
8239 @cindex @command{guix edit}
8240 @cindex package definition, editing
8241 So many packages, so many source files! The @command{guix edit} command
8242 facilitates the life of users and packagers by pointing their editor at
8243 the source file containing the definition of the specified packages.
8244 For instance:
8245
8246 @example
8247 guix edit gcc@@4.9 vim
8248 @end example
8249
8250 @noindent
8251 launches the program specified in the @code{VISUAL} or in the
8252 @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
8253 and that of Vim.
8254
8255 If you are using a Guix Git checkout (@pxref{Building from Git}), or
8256 have created your own packages on @code{GUIX_PACKAGE_PATH}
8257 (@pxref{Package Modules}), you will be able to edit the package
8258 recipes. In other cases, you will be able to examine the read-only recipes
8259 for packages currently in the store.
8260
8261
8262 @node Invoking guix download
8263 @section Invoking @command{guix download}
8264
8265 @cindex @command{guix download}
8266 @cindex downloading package sources
8267 When writing a package definition, developers typically need to download
8268 a source tarball, compute its SHA256 hash, and write that
8269 hash in the package definition (@pxref{Defining Packages}). The
8270 @command{guix download} tool helps with this task: it downloads a file
8271 from the given URI, adds it to the store, and prints both its file name
8272 in the store and its SHA256 hash.
8273
8274 The fact that the downloaded file is added to the store saves bandwidth:
8275 when the developer eventually tries to build the newly defined package
8276 with @command{guix build}, the source tarball will not have to be
8277 downloaded again because it is already in the store. It is also a
8278 convenient way to temporarily stash files, which may be deleted
8279 eventually (@pxref{Invoking guix gc}).
8280
8281 The @command{guix download} command supports the same URIs as used in
8282 package definitions. In particular, it supports @code{mirror://} URIs.
8283 @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
8284 Guile bindings for GnuTLS are available in the user's environment; when
8285 they are not available, an error is raised. @xref{Guile Preparations,
8286 how to install the GnuTLS bindings for Guile,, gnutls-guile,
8287 GnuTLS-Guile}, for more information.
8288
8289 @command{guix download} verifies HTTPS server certificates by loading
8290 the certificates of X.509 authorities from the directory pointed to by
8291 the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
8292 Certificates}), unless @option{--no-check-certificate} is used.
8293
8294 The following options are available:
8295
8296 @table @code
8297 @item --format=@var{fmt}
8298 @itemx -f @var{fmt}
8299 Write the hash in the format specified by @var{fmt}. For more
8300 information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
8301
8302 @item --no-check-certificate
8303 Do not validate the X.509 certificates of HTTPS servers.
8304
8305 When using this option, you have @emph{absolutely no guarantee} that you
8306 are communicating with the authentic server responsible for the given
8307 URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
8308
8309 @item --output=@var{file}
8310 @itemx -o @var{file}
8311 Save the downloaded file to @var{file} instead of adding it to the
8312 store.
8313 @end table
8314
8315 @node Invoking guix hash
8316 @section Invoking @command{guix hash}
8317
8318 @cindex @command{guix hash}
8319 The @command{guix hash} command computes the SHA256 hash of a file.
8320 It is primarily a convenience tool for anyone contributing to the
8321 distribution: it computes the cryptographic hash of a file, which can be
8322 used in the definition of a package (@pxref{Defining Packages}).
8323
8324 The general syntax is:
8325
8326 @example
8327 guix hash @var{option} @var{file}
8328 @end example
8329
8330 When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
8331 hash of data read from standard input. @command{guix hash} has the
8332 following options:
8333
8334 @table @code
8335
8336 @item --format=@var{fmt}
8337 @itemx -f @var{fmt}
8338 Write the hash in the format specified by @var{fmt}.
8339
8340 Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
8341 (@code{hex} and @code{hexadecimal} can be used as well).
8342
8343 If the @option{--format} option is not specified, @command{guix hash}
8344 will output the hash in @code{nix-base32}. This representation is used
8345 in the definitions of packages.
8346
8347 @item --recursive
8348 @itemx -r
8349 Compute the hash on @var{file} recursively.
8350
8351 In this case, the hash is computed on an archive containing @var{file},
8352 including its children if it is a directory. Some of the metadata of
8353 @var{file} is part of the archive; for instance, when @var{file} is a
8354 regular file, the hash is different depending on whether @var{file} is
8355 executable or not. Metadata such as time stamps has no impact on the
8356 hash (@pxref{Invoking guix archive}).
8357 @c FIXME: Replace xref above with xref to an ``Archive'' section when
8358 @c it exists.
8359
8360 @item --exclude-vcs
8361 @itemx -x
8362 When combined with @option{--recursive}, exclude version control system
8363 directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
8364
8365 @vindex git-fetch
8366 As an example, here is how you would compute the hash of a Git checkout,
8367 which is useful when using the @code{git-fetch} method (@pxref{origin
8368 Reference}):
8369
8370 @example
8371 $ git clone http://example.org/foo.git
8372 $ cd foo
8373 $ guix hash -rx .
8374 @end example
8375 @end table
8376
8377 @node Invoking guix import
8378 @section Invoking @command{guix import}
8379
8380 @cindex importing packages
8381 @cindex package import
8382 @cindex package conversion
8383 @cindex Invoking @command{guix import}
8384 The @command{guix import} command is useful for people who would like to
8385 add a package to the distribution with as little work as
8386 possible---a legitimate demand. The command knows of a few
8387 repositories from which it can ``import'' package metadata. The result
8388 is a package definition, or a template thereof, in the format we know
8389 (@pxref{Defining Packages}).
8390
8391 The general syntax is:
8392
8393 @example
8394 guix import @var{importer} @var{options}@dots{}
8395 @end example
8396
8397 @var{importer} specifies the source from which to import package
8398 metadata, and @var{options} specifies a package identifier and other
8399 options specific to @var{importer}. Currently, the available
8400 ``importers'' are:
8401
8402 @table @code
8403 @item gnu
8404 Import metadata for the given GNU package. This provides a template
8405 for the latest version of that GNU package, including the hash of its
8406 source tarball, and its canonical synopsis and description.
8407
8408 Additional information such as the package dependencies and its
8409 license needs to be figured out manually.
8410
8411 For example, the following command returns a package definition for
8412 GNU@tie{}Hello:
8413
8414 @example
8415 guix import gnu hello
8416 @end example
8417
8418 Specific command-line options are:
8419
8420 @table @code
8421 @item --key-download=@var{policy}
8422 As for @code{guix refresh}, specify the policy to handle missing OpenPGP
8423 keys when verifying the package signature. @xref{Invoking guix
8424 refresh, @code{--key-download}}.
8425 @end table
8426
8427 @item pypi
8428 @cindex pypi
8429 Import metadata from the @uref{https://pypi.python.org/, Python Package
8430 Index}. Information is taken from the JSON-formatted description
8431 available at @code{pypi.python.org} and usually includes all the relevant
8432 information, including package dependencies. For maximum efficiency, it
8433 is recommended to install the @command{unzip} utility, so that the
8434 importer can unzip Python wheels and gather data from them.
8435
8436 The command below imports metadata for the @code{itsdangerous} Python
8437 package:
8438
8439 @example
8440 guix import pypi itsdangerous
8441 @end example
8442
8443 @table @code
8444 @item --recursive
8445 @itemx -r
8446 Traverse the dependency graph of the given upstream package recursively
8447 and generate package expressions for all those packages that are not yet
8448 in Guix.
8449 @end table
8450
8451 @item gem
8452 @cindex gem
8453 Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
8454 is taken from the JSON-formatted description available at
8455 @code{rubygems.org} and includes most relevant information, including
8456 runtime dependencies. There are some caveats, however. The metadata
8457 doesn't distinguish between synopses and descriptions, so the same string
8458 is used for both fields. Additionally, the details of non-Ruby
8459 dependencies required to build native extensions is unavailable and left
8460 as an exercise to the packager.
8461
8462 The command below imports metadata for the @code{rails} Ruby package:
8463
8464 @example
8465 guix import gem rails
8466 @end example
8467
8468 @table @code
8469 @item --recursive
8470 @itemx -r
8471 Traverse the dependency graph of the given upstream package recursively
8472 and generate package expressions for all those packages that are not yet
8473 in Guix.
8474 @end table
8475
8476 @item cpan
8477 @cindex CPAN
8478 Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
8479 Information is taken from the JSON-formatted metadata provided through
8480 @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
8481 relevant information, such as module dependencies. License information
8482 should be checked closely. If Perl is available in the store, then the
8483 @code{corelist} utility will be used to filter core modules out of the
8484 list of dependencies.
8485
8486 The command command below imports metadata for the @code{Acme::Boolean}
8487 Perl module:
8488
8489 @example
8490 guix import cpan Acme::Boolean
8491 @end example
8492
8493 @item cran
8494 @cindex CRAN
8495 @cindex Bioconductor
8496 Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
8497 central repository for the @uref{http://r-project.org, GNU@tie{}R
8498 statistical and graphical environment}.
8499
8500 Information is extracted from the @code{DESCRIPTION} file of the package.
8501
8502 The command command below imports metadata for the @code{Cairo}
8503 R package:
8504
8505 @example
8506 guix import cran Cairo
8507 @end example
8508
8509 When @code{--recursive} is added, the importer will traverse the
8510 dependency graph of the given upstream package recursively and generate
8511 package expressions for all those packages that are not yet in Guix.
8512
8513 When @code{--archive=bioconductor} is added, metadata is imported from
8514 @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
8515 packages for for the analysis and comprehension of high-throughput
8516 genomic data in bioinformatics.
8517
8518 Information is extracted from the @code{DESCRIPTION} file of a package
8519 published on the web interface of the Bioconductor SVN repository.
8520
8521 The command below imports metadata for the @code{GenomicRanges}
8522 R package:
8523
8524 @example
8525 guix import cran --archive=bioconductor GenomicRanges
8526 @end example
8527
8528 @item texlive
8529 @cindex TeX Live
8530 @cindex CTAN
8531 Import metadata from @uref{http://www.ctan.org/, CTAN}, the
8532 comprehensive TeX archive network for TeX packages that are part of the
8533 @uref{https://www.tug.org/texlive/, TeX Live distribution}.
8534
8535 Information about the package is obtained through the XML API provided
8536 by CTAN, while the source code is downloaded from the SVN repository of
8537 the Tex Live project. This is done because the CTAN does not keep
8538 versioned archives.
8539
8540 The command command below imports metadata for the @code{fontspec}
8541 TeX package:
8542
8543 @example
8544 guix import texlive fontspec
8545 @end example
8546
8547 When @code{--archive=DIRECTORY} is added, the source code is downloaded
8548 not from the @file{latex} sub-directory of the @file{texmf-dist/source}
8549 tree in the TeX Live SVN repository, but from the specified sibling
8550 directory under the same root.
8551
8552 The command below imports metadata for the @code{ifxetex} package from
8553 CTAN while fetching the sources from the directory
8554 @file{texmf/source/generic}:
8555
8556 @example
8557 guix import texlive --archive=generic ifxetex
8558 @end example
8559
8560 @item json
8561 @cindex JSON, import
8562 Import package metadata from a local JSON file. Consider the following
8563 example package definition in JSON format:
8564
8565 @example
8566 @{
8567 "name": "hello",
8568 "version": "2.10",
8569 "source": "mirror://gnu/hello/hello-2.10.tar.gz",
8570 "build-system": "gnu",
8571 "home-page": "https://www.gnu.org/software/hello/",
8572 "synopsis": "Hello, GNU world: An example GNU package",
8573 "description": "GNU Hello prints a greeting.",
8574 "license": "GPL-3.0+",
8575 "native-inputs": ["gcc@@6"]
8576 @}
8577 @end example
8578
8579 The field names are the same as for the @code{<package>} record
8580 (@xref{Defining Packages}). References to other packages are provided
8581 as JSON lists of quoted package specification strings such as
8582 @code{guile} or @code{guile@@2.0}.
8583
8584 The importer also supports a more explicit source definition using the
8585 common fields for @code{<origin>} records:
8586
8587 @example
8588 @{
8589 @dots{}
8590 "source": @{
8591 "method": "url-fetch",
8592 "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
8593 "sha256": @{
8594 "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
8595 @}
8596 @}
8597 @dots{}
8598 @}
8599 @end example
8600
8601 The command below reads metadata from the JSON file @code{hello.json}
8602 and outputs a package expression:
8603
8604 @example
8605 guix import json hello.json
8606 @end example
8607
8608 @item nix
8609 Import metadata from a local copy of the source of the
8610 @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
8611 relies on the @command{nix-instantiate} command of
8612 @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
8613 typically written in a mixture of Nix-language and Bash code. This
8614 command only imports the high-level package structure that is written in
8615 the Nix language. It normally includes all the basic fields of a
8616 package definition.
8617
8618 When importing a GNU package, the synopsis and descriptions are replaced
8619 by their canonical upstream variant.
8620
8621 Usually, you will first need to do:
8622
8623 @example
8624 export NIX_REMOTE=daemon
8625 @end example
8626
8627 @noindent
8628 so that @command{nix-instantiate} does not try to open the Nix database.
8629
8630 As an example, the command below imports the package definition of
8631 LibreOffice (more precisely, it imports the definition of the package
8632 bound to the @code{libreoffice} top-level attribute):
8633
8634 @example
8635 guix import nix ~/path/to/nixpkgs libreoffice
8636 @end example
8637
8638 @item hackage
8639 @cindex hackage
8640 Import metadata from the Haskell community's central package archive
8641 @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
8642 Cabal files and includes all the relevant information, including package
8643 dependencies.
8644
8645 Specific command-line options are:
8646
8647 @table @code
8648 @item --stdin
8649 @itemx -s
8650 Read a Cabal file from standard input.
8651 @item --no-test-dependencies
8652 @itemx -t
8653 Do not include dependencies required only by the test suites.
8654 @item --cabal-environment=@var{alist}
8655 @itemx -e @var{alist}
8656 @var{alist} is a Scheme alist defining the environment in which the
8657 Cabal conditionals are evaluated. The accepted keys are: @code{os},
8658 @code{arch}, @code{impl} and a string representing the name of a flag.
8659 The value associated with a flag has to be either the symbol
8660 @code{true} or @code{false}. The value associated with other keys
8661 has to conform to the Cabal file format definition. The default value
8662 associated with the keys @code{os}, @code{arch} and @code{impl} is
8663 @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
8664 @item --recursive
8665 @itemx -r
8666 Traverse the dependency graph of the given upstream package recursively
8667 and generate package expressions for all those packages that are not yet
8668 in Guix.
8669 @end table
8670
8671 The command below imports metadata for the latest version of the
8672 @code{HTTP} Haskell package without including test dependencies and
8673 specifying the value of the flag @samp{network-uri} as @code{false}:
8674
8675 @example
8676 guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
8677 @end example
8678
8679 A specific package version may optionally be specified by following the
8680 package name by an at-sign and a version number as in the following example:
8681
8682 @example
8683 guix import hackage mtl@@2.1.3.1
8684 @end example
8685
8686 @item stackage
8687 @cindex stackage
8688 The @code{stackage} importer is a wrapper around the @code{hackage} one.
8689 It takes a package name, looks up the package version included in a
8690 long-term support (LTS) @uref{https://www.stackage.org, Stackage}
8691 release and uses the @code{hackage} importer to retrieve its metadata.
8692 Note that it is up to you to select an LTS release compatible with the
8693 GHC compiler used by Guix.
8694
8695 Specific command-line options are:
8696
8697 @table @code
8698 @item --no-test-dependencies
8699 @itemx -t
8700 Do not include dependencies required only by the test suites.
8701 @item --lts-version=@var{version}
8702 @itemx -l @var{version}
8703 @var{version} is the desired LTS release version. If omitted the latest
8704 release is used.
8705 @item --recursive
8706 @itemx -r
8707 Traverse the dependency graph of the given upstream package recursively
8708 and generate package expressions for all those packages that are not yet
8709 in Guix.
8710 @end table
8711
8712 The command below imports metadata for the @code{HTTP} Haskell package
8713 included in the LTS Stackage release version 7.18:
8714
8715 @example
8716 guix import stackage --lts-version=7.18 HTTP
8717 @end example
8718
8719 @item elpa
8720 @cindex elpa
8721 Import metadata from an Emacs Lisp Package Archive (ELPA) package
8722 repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
8723
8724 Specific command-line options are:
8725
8726 @table @code
8727 @item --archive=@var{repo}
8728 @itemx -a @var{repo}
8729 @var{repo} identifies the archive repository from which to retrieve the
8730 information. Currently the supported repositories and their identifiers
8731 are:
8732 @itemize -
8733 @item
8734 @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
8735 identifier. This is the default.
8736
8737 Packages from @code{elpa.gnu.org} are signed with one of the keys
8738 contained in the GnuPG keyring at
8739 @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
8740 @code{emacs} package (@pxref{Package Installation, ELPA package
8741 signatures,, emacs, The GNU Emacs Manual}).
8742
8743 @item
8744 @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
8745 @code{melpa-stable} identifier.
8746
8747 @item
8748 @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
8749 identifier.
8750 @end itemize
8751
8752 @item --recursive
8753 @itemx -r
8754 Traverse the dependency graph of the given upstream package recursively
8755 and generate package expressions for all those packages that are not yet
8756 in Guix.
8757 @end table
8758
8759 @item crate
8760 @cindex crate
8761 Import metadata from the crates.io Rust package repository
8762 @uref{https://crates.io, crates.io}.
8763
8764 @item opam
8765 @cindex OPAM
8766 @cindex OCaml
8767 Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
8768 repository used by the OCaml community.
8769 @end table
8770
8771 The structure of the @command{guix import} code is modular. It would be
8772 useful to have more importers for other package formats, and your help
8773 is welcome here (@pxref{Contributing}).
8774
8775 @node Invoking guix refresh
8776 @section Invoking @command{guix refresh}
8777
8778 @cindex @command {guix refresh}
8779 The primary audience of the @command{guix refresh} command is developers
8780 of the GNU software distribution. By default, it reports any packages
8781 provided by the distribution that are outdated compared to the latest
8782 upstream version, like this:
8783
8784 @example
8785 $ guix refresh
8786 gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
8787 gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
8788 @end example
8789
8790 Alternately, one can specify packages to consider, in which case a
8791 warning is emitted for packages that lack an updater:
8792
8793 @example
8794 $ guix refresh coreutils guile guile-ssh
8795 gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
8796 gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
8797 @end example
8798
8799 @command{guix refresh} browses the upstream repository of each package and determines
8800 the highest version number of the releases therein. The command
8801 knows how to update specific types of packages: GNU packages, ELPA
8802 packages, etc.---see the documentation for @option{--type} below. There
8803 are many packages, though, for which it lacks a method to determine
8804 whether a new upstream release is available. However, the mechanism is
8805 extensible, so feel free to get in touch with us to add a new method!
8806
8807 @table @code
8808
8809 @item --recursive
8810 Consider the packages specified, and all the packages upon which they depend.
8811
8812 @example
8813 $ guix refresh --recursive coreutils
8814 gnu/packages/acl.scm:35:2: warning: no updater for acl
8815 gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
8816 gnu/packages/xml.scm:68:2: warning: no updater for expat
8817 gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest version of gmp
8818 @dots{}
8819 @end example
8820
8821 @end table
8822
8823 Sometimes the upstream name differs from the package name used in Guix,
8824 and @command{guix refresh} needs a little help. Most updaters honor the
8825 @code{upstream-name} property in package definitions, which can be used
8826 to that effect:
8827
8828 @example
8829 (define-public network-manager
8830 (package
8831 (name "network-manager")
8832 ;; @dots{}
8833 (properties '((upstream-name . "NetworkManager")))))
8834 @end example
8835
8836 When passed @code{--update}, it modifies distribution source files to
8837 update the version numbers and source tarball hashes of those package
8838 recipes (@pxref{Defining Packages}). This is achieved by downloading
8839 each package's latest source tarball and its associated OpenPGP
8840 signature, authenticating the downloaded tarball against its signature
8841 using @command{gpg}, and finally computing its hash. When the public
8842 key used to sign the tarball is missing from the user's keyring, an
8843 attempt is made to automatically retrieve it from a public key server;
8844 when this is successful, the key is added to the user's keyring; otherwise,
8845 @command{guix refresh} reports an error.
8846
8847 The following options are supported:
8848
8849 @table @code
8850
8851 @item --expression=@var{expr}
8852 @itemx -e @var{expr}
8853 Consider the package @var{expr} evaluates to.
8854
8855 This is useful to precisely refer to a package, as in this example:
8856
8857 @example
8858 guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
8859 @end example
8860
8861 This command lists the dependents of the ``final'' libc (essentially all
8862 the packages.)
8863
8864 @item --update
8865 @itemx -u
8866 Update distribution source files (package recipes) in place. This is
8867 usually run from a checkout of the Guix source tree (@pxref{Running
8868 Guix Before It Is Installed}):
8869
8870 @example
8871 $ ./pre-inst-env guix refresh -s non-core -u
8872 @end example
8873
8874 @xref{Defining Packages}, for more information on package definitions.
8875
8876 @item --select=[@var{subset}]
8877 @itemx -s @var{subset}
8878 Select all the packages in @var{subset}, one of @code{core} or
8879 @code{non-core}.
8880
8881 The @code{core} subset refers to all the packages at the core of the
8882 distribution---i.e., packages that are used to build ``everything
8883 else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
8884 changing one of these packages in the distribution entails a rebuild of
8885 all the others. Thus, such updates are an inconvenience to users in
8886 terms of build time or bandwidth used to achieve the upgrade.
8887
8888 The @code{non-core} subset refers to the remaining packages. It is
8889 typically useful in cases where an update of the core packages would be
8890 inconvenient.
8891
8892 @item --manifest=@var{file}
8893 @itemx -m @var{file}
8894 Select all the packages from the manifest in @var{file}. This is useful to
8895 check if any packages of the user manifest can be updated.
8896
8897 @item --type=@var{updater}
8898 @itemx -t @var{updater}
8899 Select only packages handled by @var{updater} (may be a comma-separated
8900 list of updaters). Currently, @var{updater} may be one of:
8901
8902 @table @code
8903 @item gnu
8904 the updater for GNU packages;
8905 @item gnome
8906 the updater for GNOME packages;
8907 @item kde
8908 the updater for KDE packages;
8909 @item xorg
8910 the updater for X.org packages;
8911 @item kernel.org
8912 the updater for packages hosted on kernel.org;
8913 @item elpa
8914 the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
8915 @item cran
8916 the updater for @uref{https://cran.r-project.org/, CRAN} packages;
8917 @item bioconductor
8918 the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
8919 @item cpan
8920 the updater for @uref{http://www.cpan.org/, CPAN} packages;
8921 @item pypi
8922 the updater for @uref{https://pypi.python.org, PyPI} packages.
8923 @item gem
8924 the updater for @uref{https://rubygems.org, RubyGems} packages.
8925 @item github
8926 the updater for @uref{https://github.com, GitHub} packages.
8927 @item hackage
8928 the updater for @uref{https://hackage.haskell.org, Hackage} packages.
8929 @item stackage
8930 the updater for @uref{https://www.stackage.org, Stackage} packages.
8931 @item crate
8932 the updater for @uref{https://crates.io, Crates} packages.
8933 @item launchpad
8934 the updater for @uref{https://launchpad.net, Launchpad} packages.
8935 @end table
8936
8937 For instance, the following command only checks for updates of Emacs
8938 packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
8939
8940 @example
8941 $ guix refresh --type=elpa,cran
8942 gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
8943 gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
8944 @end example
8945
8946 @end table
8947
8948 In addition, @command{guix refresh} can be passed one or more package
8949 names, as in this example:
8950
8951 @example
8952 $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
8953 @end example
8954
8955 @noindent
8956 The command above specifically updates the @code{emacs} and
8957 @code{idutils} packages. The @code{--select} option would have no
8958 effect in this case.
8959
8960 When considering whether to upgrade a package, it is sometimes
8961 convenient to know which packages would be affected by the upgrade and
8962 should be checked for compatibility. For this the following option may
8963 be used when passing @command{guix refresh} one or more package names:
8964
8965 @table @code
8966
8967 @item --list-updaters
8968 @itemx -L
8969 List available updaters and exit (see @option{--type} above.)
8970
8971 For each updater, display the fraction of packages it covers; at the
8972 end, display the fraction of packages covered by all these updaters.
8973
8974 @item --list-dependent
8975 @itemx -l
8976 List top-level dependent packages that would need to be rebuilt as a
8977 result of upgrading one or more packages.
8978
8979 @xref{Invoking guix graph, the @code{reverse-package} type of
8980 @command{guix graph}}, for information on how to visualize the list of
8981 dependents of a package.
8982
8983 @end table
8984
8985 Be aware that the @code{--list-dependent} option only
8986 @emph{approximates} the rebuilds that would be required as a result of
8987 an upgrade. More rebuilds might be required under some circumstances.
8988
8989 @example
8990 $ guix refresh --list-dependent flex
8991 Building the following 120 packages would ensure 213 dependent packages are rebuilt:
8992 hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
8993 @end example
8994
8995 The command above lists a set of packages that could be built to check
8996 for compatibility with an upgraded @code{flex} package.
8997
8998 @table @code
8999
9000 @item --list-transitive
9001 List all the packages which one or more packages depend upon.
9002
9003 @example
9004 $ guix refresh --list-transitive flex
9005 flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
9006 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{}
9007 @end example
9008
9009 @end table
9010
9011 The command above lists a set of packages which, when changed, would cause
9012 @code{flex} to be rebuilt.
9013
9014 The following options can be used to customize GnuPG operation:
9015
9016 @table @code
9017
9018 @item --gpg=@var{command}
9019 Use @var{command} as the GnuPG 2.x command. @var{command} is searched
9020 for in @code{$PATH}.
9021
9022 @item --keyring=@var{file}
9023 Use @var{file} as the keyring for upstream keys. @var{file} must be in the
9024 @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
9025 and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
9026 (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
9027 information on a tool to manipulate keybox files).
9028
9029 When this option is omitted, @command{guix refresh} uses
9030 @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
9031 signing keys. OpenPGP signatures are checked against keys from this keyring;
9032 missing keys are downloaded to this keyring as well (see
9033 @option{--key-download} below.)
9034
9035 You can export keys from your default GPG keyring into a keybox file using
9036 commands like this one:
9037
9038 @example
9039 gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
9040 @end example
9041
9042 Likewise, you can fetch keys to a specific keybox file like this:
9043
9044 @example
9045 gpg --no-default-keyring --keyring mykeyring.kbx \
9046 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
9047 @end example
9048
9049 @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
9050 Privacy Guard}, for more information on GPG's @option{--keyring} option.
9051
9052 @item --key-download=@var{policy}
9053 Handle missing OpenPGP keys according to @var{policy}, which may be one
9054 of:
9055
9056 @table @code
9057 @item always
9058 Always download missing OpenPGP keys from the key server, and add them
9059 to the user's GnuPG keyring.
9060
9061 @item never
9062 Never try to download missing OpenPGP keys. Instead just bail out.
9063
9064 @item interactive
9065 When a package signed with an unknown OpenPGP key is encountered, ask
9066 the user whether to download it or not. This is the default behavior.
9067 @end table
9068
9069 @item --key-server=@var{host}
9070 Use @var{host} as the OpenPGP key server when importing a public key.
9071
9072 @end table
9073
9074 The @code{github} updater uses the
9075 @uref{https://developer.github.com/v3/, GitHub API} to query for new
9076 releases. When used repeatedly e.g.@: when refreshing all packages,
9077 GitHub will eventually refuse to answer any further API requests. By
9078 default 60 API requests per hour are allowed, and a full refresh on all
9079 GitHub packages in Guix requires more than this. Authentication with
9080 GitHub through the use of an API token alleviates these limits. To use
9081 an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
9082 token procured from @uref{https://github.com/settings/tokens} or
9083 otherwise.
9084
9085
9086 @node Invoking guix lint
9087 @section Invoking @command{guix lint}
9088
9089 @cindex @command{guix lint}
9090 @cindex package, checking for errors
9091 The @command{guix lint} command is meant to help package developers avoid
9092 common errors and use a consistent style. It runs a number of checks on
9093 a given set of packages in order to find common mistakes in their
9094 definitions. Available @dfn{checkers} include (see
9095 @code{--list-checkers} for a complete list):
9096
9097 @table @code
9098 @item synopsis
9099 @itemx description
9100 Validate certain typographical and stylistic rules about package
9101 descriptions and synopses.
9102
9103 @item inputs-should-be-native
9104 Identify inputs that should most likely be native inputs.
9105
9106 @item source
9107 @itemx home-page
9108 @itemx mirror-url
9109 @itemx github-url
9110 @itemx source-file-name
9111 Probe @code{home-page} and @code{source} URLs and report those that are
9112 invalid. Suggest a @code{mirror://} URL when applicable. If the
9113 @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
9114 URL. Check that the source file name is meaningful, e.g.@: is not just a
9115 version number or ``git-checkout'', without a declared @code{file-name}
9116 (@pxref{origin Reference}).
9117
9118 @item source-unstable-tarball
9119 Parse the @code{source} URL to determine if a tarball from GitHub is
9120 autogenerated or if it is a release tarball. Unfortunately GitHub's
9121 autogenerated tarballs are sometimes regenerated.
9122
9123 @item cve
9124 @cindex security vulnerabilities
9125 @cindex CVE, Common Vulnerabilities and Exposures
9126 Report known vulnerabilities found in the Common Vulnerabilities and
9127 Exposures (CVE) databases of the current and past year
9128 @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
9129 NIST}.
9130
9131 To view information about a particular vulnerability, visit pages such as:
9132
9133 @itemize
9134 @item
9135 @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
9136 @item
9137 @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
9138 @end itemize
9139
9140 @noindent
9141 where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
9142 @code{CVE-2015-7554}.
9143
9144 Package developers can specify in package recipes the
9145 @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
9146 name and version of the package when they differ from the name or version
9147 that Guix uses, as in this example:
9148
9149 @example
9150 (package
9151 (name "grub")
9152 ;; @dots{}
9153 ;; CPE calls this package "grub2".
9154 (properties '((cpe-name . "grub2")
9155 (cpe-version . "2.3")))
9156 @end example
9157
9158 @c See <http://www.openwall.com/lists/oss-security/2017/03/15/3>.
9159 Some entries in the CVE database do not specify which version of a
9160 package they apply to, and would thus ``stick around'' forever. Package
9161 developers who found CVE alerts and verified they can be ignored can
9162 declare them as in this example:
9163
9164 @example
9165 (package
9166 (name "t1lib")
9167 ;; @dots{}
9168 ;; These CVEs no longer apply and can be safely ignored.
9169 (properties `((lint-hidden-cve . ("CVE-2011-0433"
9170 "CVE-2011-1553"
9171 "CVE-2011-1554"
9172 "CVE-2011-5244")))))
9173 @end example
9174
9175 @item formatting
9176 Warn about obvious source code formatting issues: trailing white space,
9177 use of tabulations, etc.
9178 @end table
9179
9180 The general syntax is:
9181
9182 @example
9183 guix lint @var{options} @var{package}@dots{}
9184 @end example
9185
9186 If no package is given on the command line, then all packages are checked.
9187 The @var{options} may be zero or more of the following:
9188
9189 @table @code
9190 @item --list-checkers
9191 @itemx -l
9192 List and describe all the available checkers that will be run on packages
9193 and exit.
9194
9195 @item --checkers
9196 @itemx -c
9197 Only enable the checkers specified in a comma-separated list using the
9198 names returned by @code{--list-checkers}.
9199
9200 @end table
9201
9202 @node Invoking guix size
9203 @section Invoking @command{guix size}
9204
9205 @cindex size
9206 @cindex package size
9207 @cindex closure
9208 @cindex @command{guix size}
9209 The @command{guix size} command helps package developers profile the
9210 disk usage of packages. It is easy to overlook the impact of an
9211 additional dependency added to a package, or the impact of using a
9212 single output for a package that could easily be split (@pxref{Packages
9213 with Multiple Outputs}). Such are the typical issues that
9214 @command{guix size} can highlight.
9215
9216 The command can be passed one or more package specifications
9217 such as @code{gcc@@4.8}
9218 or @code{guile:debug}, or a file name in the store. Consider this
9219 example:
9220
9221 @example
9222 $ guix size coreutils
9223 store item total self
9224 /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
9225 /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
9226 /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
9227 /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
9228 /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
9229 /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
9230 /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
9231 /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
9232 total: 78.9 MiB
9233 @end example
9234
9235 @cindex closure
9236 The store items listed here constitute the @dfn{transitive closure} of
9237 Coreutils---i.e., Coreutils and all its dependencies, recursively---as
9238 would be returned by:
9239
9240 @example
9241 $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
9242 @end example
9243
9244 Here the output shows three columns next to store items. The first column,
9245 labeled ``total'', shows the size in mebibytes (MiB) of the closure of
9246 the store item---that is, its own size plus the size of all its
9247 dependencies. The next column, labeled ``self'', shows the size of the
9248 item itself. The last column shows the ratio of the size of the item
9249 itself to the space occupied by all the items listed here.
9250
9251 In this example, we see that the closure of Coreutils weighs in at
9252 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
9253 libraries. (That libc and GCC's libraries represent a large fraction of
9254 the closure is not a problem @i{per se} because they are always available
9255 on the system anyway.)
9256
9257 When the package(s) passed to @command{guix size} are available in the
9258 store@footnote{More precisely, @command{guix size} looks for the
9259 @emph{ungrafted} variant of the given package(s), as returned by
9260 @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
9261 for information on grafts.}, @command{guix size} queries the daemon to determine its
9262 dependencies, and measures its size in the store, similar to @command{du
9263 -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
9264 Coreutils}).
9265
9266 When the given packages are @emph{not} in the store, @command{guix size}
9267 reports information based on the available substitutes
9268 (@pxref{Substitutes}). This makes it possible it to profile disk usage of
9269 store items that are not even on disk, only available remotely.
9270
9271 You can also specify several package names:
9272
9273 @example
9274 $ guix size coreutils grep sed bash
9275 store item total self
9276 /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
9277 /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
9278 /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
9279 /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
9280 @dots{}
9281 total: 102.3 MiB
9282 @end example
9283
9284 @noindent
9285 In this example we see that the combination of the four packages takes
9286 102.3@tie{}MiB in total, which is much less than the sum of each closure
9287 since they have a lot of dependencies in common.
9288
9289 The available options are:
9290
9291 @table @option
9292
9293 @item --substitute-urls=@var{urls}
9294 Use substitute information from @var{urls}.
9295 @xref{client-substitute-urls, the same option for @code{guix build}}.
9296
9297 @item --sort=@var{key}
9298 Sort lines according to @var{key}, one of the following options:
9299
9300 @table @code
9301 @item self
9302 the size of each item (the default);
9303 @item closure
9304 the total size of the item's closure.
9305 @end table
9306
9307 @item --map-file=@var{file}
9308 Write a graphical map of disk usage in PNG format to @var{file}.
9309
9310 For the example above, the map looks like this:
9311
9312 @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
9313 produced by @command{guix size}}
9314
9315 This option requires that
9316 @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
9317 installed and visible in Guile's module search path. When that is not
9318 the case, @command{guix size} fails as it tries to load it.
9319
9320 @item --system=@var{system}
9321 @itemx -s @var{system}
9322 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
9323
9324 @end table
9325
9326 @node Invoking guix graph
9327 @section Invoking @command{guix graph}
9328
9329 @cindex DAG
9330 @cindex @command{guix graph}
9331 @cindex package dependencies
9332 Packages and their dependencies form a @dfn{graph}, specifically a
9333 directed acyclic graph (DAG). It can quickly become difficult to have a
9334 mental model of the package DAG, so the @command{guix graph} command
9335 provides a visual representation of the DAG. By default,
9336 @command{guix graph} emits a DAG representation in the input format of
9337 @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
9338 directly to the @command{dot} command of Graphviz. It can also emit an
9339 HTML page with embedded JavaScript code to display a ``chord diagram''
9340 in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
9341 emit Cypher queries to construct a graph in a graph database supporting
9342 the @uref{http://www.opencypher.org/, openCypher} query language.
9343 The general syntax is:
9344
9345 @example
9346 guix graph @var{options} @var{package}@dots{}
9347 @end example
9348
9349 For example, the following command generates a PDF file representing the
9350 package DAG for the GNU@tie{}Core Utilities, showing its build-time
9351 dependencies:
9352
9353 @example
9354 guix graph coreutils | dot -Tpdf > dag.pdf
9355 @end example
9356
9357 The output looks like this:
9358
9359 @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
9360
9361 Nice little graph, no?
9362
9363 But there is more than one graph! The one above is concise: it is the
9364 graph of package objects, omitting implicit inputs such as GCC, libc,
9365 grep, etc. It is often useful to have such a concise graph, but
9366 sometimes one may want to see more details. @command{guix graph} supports
9367 several types of graphs, allowing you to choose the level of detail:
9368
9369 @table @code
9370 @item package
9371 This is the default type used in the example above. It shows the DAG of
9372 package objects, excluding implicit dependencies. It is concise, but
9373 filters out many details.
9374
9375 @item reverse-package
9376 This shows the @emph{reverse} DAG of packages. For example:
9377
9378 @example
9379 guix graph --type=reverse-package ocaml
9380 @end example
9381
9382 ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
9383 you are also interested in cases where OCaml is an implicit dependency, see
9384 @code{reverse-bag} below.)
9385
9386 Note that for core packages this can yield huge graphs. If all you want
9387 is to know the number of packages that depend on a given package, use
9388 @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
9389 @option{--list-dependent}}).
9390
9391 @item bag-emerged
9392 This is the package DAG, @emph{including} implicit inputs.
9393
9394 For instance, the following command:
9395
9396 @example
9397 guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
9398 @end example
9399
9400 ...@: yields this bigger graph:
9401
9402 @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
9403
9404 At the bottom of the graph, we see all the implicit inputs of
9405 @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
9406
9407 Now, note that the dependencies of these implicit inputs---that is, the
9408 @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
9409 here, for conciseness.
9410
9411 @item bag
9412 Similar to @code{bag-emerged}, but this time including all the bootstrap
9413 dependencies.
9414
9415 @item bag-with-origins
9416 Similar to @code{bag}, but also showing origins and their dependencies.
9417
9418 @item reverse-bag
9419 This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
9420 it also takes implicit dependencies into account. For example:
9421
9422 @example
9423 guix graph -t reverse-bag dune
9424 @end example
9425
9426 @noindent
9427 ...@: yields the graph of all packages that depend on Dune, directly or
9428 indirectly. Since Dune is an @emph{implicit} dependency of many packages
9429 @i{via} @code{dune-build-system}, this shows a large number of packages,
9430 whereas @code{reverse-package} would show very few if any.
9431
9432 @item derivation
9433 This is the most detailed representation: It shows the DAG of
9434 derivations (@pxref{Derivations}) and plain store items. Compared to
9435 the above representation, many additional nodes are visible, including
9436 build scripts, patches, Guile modules, etc.
9437
9438 For this type of graph, it is also possible to pass a @file{.drv} file
9439 name instead of a package name, as in:
9440
9441 @example
9442 guix graph -t derivation `guix system build -d my-config.scm`
9443 @end example
9444
9445 @item module
9446 This is the graph of @dfn{package modules} (@pxref{Package Modules}).
9447 For example, the following command shows the graph for the package
9448 module that defines the @code{guile} package:
9449
9450 @example
9451 guix graph -t module guile | dot -Tpdf > module-graph.pdf
9452 @end example
9453 @end table
9454
9455 All the types above correspond to @emph{build-time dependencies}. The
9456 following graph type represents the @emph{run-time dependencies}:
9457
9458 @table @code
9459 @item references
9460 This is the graph of @dfn{references} of a package output, as returned
9461 by @command{guix gc --references} (@pxref{Invoking guix gc}).
9462
9463 If the given package output is not available in the store, @command{guix
9464 graph} attempts to obtain dependency information from substitutes.
9465
9466 Here you can also pass a store file name instead of a package name. For
9467 example, the command below produces the reference graph of your profile
9468 (which can be big!):
9469
9470 @example
9471 guix graph -t references `readlink -f ~/.guix-profile`
9472 @end example
9473
9474 @item referrers
9475 This is the graph of the @dfn{referrers} of a store item, as returned by
9476 @command{guix gc --referrers} (@pxref{Invoking guix gc}).
9477
9478 This relies exclusively on local information from your store. For
9479 instance, let us suppose that the current Inkscape is available in 10
9480 profiles on your machine; @command{guix graph -t referrers inkscape}
9481 will show a graph rooted at Inkscape and with those 10 profiles linked
9482 to it.
9483
9484 It can help determine what is preventing a store item from being garbage
9485 collected.
9486
9487 @end table
9488
9489 The available options are the following:
9490
9491 @table @option
9492 @item --type=@var{type}
9493 @itemx -t @var{type}
9494 Produce a graph output of @var{type}, where @var{type} must be one of
9495 the values listed above.
9496
9497 @item --list-types
9498 List the supported graph types.
9499
9500 @item --backend=@var{backend}
9501 @itemx -b @var{backend}
9502 Produce a graph using the selected @var{backend}.
9503
9504 @item --list-backends
9505 List the supported graph backends.
9506
9507 Currently, the available backends are Graphviz and d3.js.
9508
9509 @item --expression=@var{expr}
9510 @itemx -e @var{expr}
9511 Consider the package @var{expr} evaluates to.
9512
9513 This is useful to precisely refer to a package, as in this example:
9514
9515 @example
9516 guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
9517 @end example
9518
9519 @item --system=@var{system}
9520 @itemx -s @var{system}
9521 Display the graph for @var{system}---e.g., @code{i686-linux}.
9522
9523 The package dependency graph is largely architecture-independent, but there
9524 are some architecture-dependent bits that this option allows you to visualize.
9525 @end table
9526
9527
9528
9529 @node Invoking guix publish
9530 @section Invoking @command{guix publish}
9531
9532 @cindex @command{guix publish}
9533 The purpose of @command{guix publish} is to enable users to easily share
9534 their store with others, who can then use it as a substitute server
9535 (@pxref{Substitutes}).
9536
9537 When @command{guix publish} runs, it spawns an HTTP server which allows
9538 anyone with network access to obtain substitutes from it. This means
9539 that any machine running Guix can also act as if it were a build farm,
9540 since the HTTP interface is compatible with Hydra, the software behind
9541 the @code{@value{SUBSTITUTE-SERVER}} build farm.
9542
9543 For security, each substitute is signed, allowing recipients to check
9544 their authenticity and integrity (@pxref{Substitutes}). Because
9545 @command{guix publish} uses the signing key of the system, which is only
9546 readable by the system administrator, it must be started as root; the
9547 @code{--user} option makes it drop root privileges early on.
9548
9549 The signing key pair must be generated before @command{guix publish} is
9550 launched, using @command{guix archive --generate-key} (@pxref{Invoking
9551 guix archive}).
9552
9553 The general syntax is:
9554
9555 @example
9556 guix publish @var{options}@dots{}
9557 @end example
9558
9559 Running @command{guix publish} without any additional arguments will
9560 spawn an HTTP server on port 8080:
9561
9562 @example
9563 guix publish
9564 @end example
9565
9566 Once a publishing server has been authorized (@pxref{Invoking guix
9567 archive}), the daemon may download substitutes from it:
9568
9569 @example
9570 guix-daemon --substitute-urls=http://example.org:8080
9571 @end example
9572
9573 By default, @command{guix publish} compresses archives on the fly as it
9574 serves them. This ``on-the-fly'' mode is convenient in that it requires
9575 no setup and is immediately available. However, when serving lots of
9576 clients, we recommend using the @option{--cache} option, which enables
9577 caching of the archives before they are sent to clients---see below for
9578 details. The @command{guix weather} command provides a handy way to
9579 check what a server provides (@pxref{Invoking guix weather}).
9580
9581 As a bonus, @command{guix publish} also serves as a content-addressed
9582 mirror for source files referenced in @code{origin} records
9583 (@pxref{origin Reference}). For instance, assuming @command{guix
9584 publish} is running on @code{example.org}, the following URL returns the
9585 raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
9586 (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
9587
9588 @example
9589 http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
9590 @end example
9591
9592 Obviously, these URLs only work for files that are in the store; in
9593 other cases, they return 404 (``Not Found'').
9594
9595 @cindex build logs, publication
9596 Build logs are available from @code{/log} URLs like:
9597
9598 @example
9599 http://example.org/log/gwspk@dots{}-guile-2.2.3
9600 @end example
9601
9602 @noindent
9603 When @command{guix-daemon} is configured to save compressed build logs,
9604 as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
9605 URLs return the compressed log as-is, with an appropriate
9606 @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
9607 running @command{guix-daemon} with @code{--log-compression=gzip} since
9608 Web browsers can automatically decompress it, which is not the case with
9609 bzip2 compression.
9610
9611 The following options are available:
9612
9613 @table @code
9614 @item --port=@var{port}
9615 @itemx -p @var{port}
9616 Listen for HTTP requests on @var{port}.
9617
9618 @item --listen=@var{host}
9619 Listen on the network interface for @var{host}. The default is to
9620 accept connections from any interface.
9621
9622 @item --user=@var{user}
9623 @itemx -u @var{user}
9624 Change privileges to @var{user} as soon as possible---i.e., once the
9625 server socket is open and the signing key has been read.
9626
9627 @item --compression[=@var{level}]
9628 @itemx -C [@var{level}]
9629 Compress data using the given @var{level}. When @var{level} is zero,
9630 disable compression. The range 1 to 9 corresponds to different gzip
9631 compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
9632 The default is 3.
9633
9634 Unless @option{--cache} is used, compression occurs on the fly and
9635 the compressed streams are not
9636 cached. Thus, to reduce load on the machine that runs @command{guix
9637 publish}, it may be a good idea to choose a low compression level, to
9638 run @command{guix publish} behind a caching proxy, or to use
9639 @option{--cache}. Using @option{--cache} has the advantage that it
9640 allows @command{guix publish} to add @code{Content-Length} HTTP header
9641 to its responses.
9642
9643 @item --cache=@var{directory}
9644 @itemx -c @var{directory}
9645 Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
9646 and only serve archives that are in cache.
9647
9648 When this option is omitted, archives and meta-data are created
9649 on-the-fly. This can reduce the available bandwidth, especially when
9650 compression is enabled, since this may become CPU-bound. Another
9651 drawback of the default mode is that the length of archives is not known
9652 in advance, so @command{guix publish} does not add a
9653 @code{Content-Length} HTTP header to its responses, which in turn
9654 prevents clients from knowing the amount of data being downloaded.
9655
9656 Conversely, when @option{--cache} is used, the first request for a store
9657 item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
9658 background process to @dfn{bake} the archive---computing its
9659 @code{.narinfo} and compressing the archive, if needed. Once the
9660 archive is cached in @var{directory}, subsequent requests succeed and
9661 are served directly from the cache, which guarantees that clients get
9662 the best possible bandwidth.
9663
9664 The ``baking'' process is performed by worker threads. By default, one
9665 thread per CPU core is created, but this can be customized. See
9666 @option{--workers} below.
9667
9668 When @option{--ttl} is used, cached entries are automatically deleted
9669 when they have expired.
9670
9671 @item --workers=@var{N}
9672 When @option{--cache} is used, request the allocation of @var{N} worker
9673 threads to ``bake'' archives.
9674
9675 @item --ttl=@var{ttl}
9676 Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
9677 (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
9678 days, @code{1m} means 1 month, and so on.
9679
9680 This allows the user's Guix to keep substitute information in cache for
9681 @var{ttl}. However, note that @code{guix publish} does not itself
9682 guarantee that the store items it provides will indeed remain available
9683 for as long as @var{ttl}.
9684
9685 Additionally, when @option{--cache} is used, cached entries that have
9686 not been accessed for @var{ttl} and that no longer have a corresponding
9687 item in the store, may be deleted.
9688
9689 @item --nar-path=@var{path}
9690 Use @var{path} as the prefix for the URLs of ``nar'' files
9691 (@pxref{Invoking guix archive, normalized archives}).
9692
9693 By default, nars are served at a URL such as
9694 @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
9695 change the @code{/nar} part to @var{path}.
9696
9697 @item --public-key=@var{file}
9698 @itemx --private-key=@var{file}
9699 Use the specific @var{file}s as the public/private key pair used to sign
9700 the store items being published.
9701
9702 The files must correspond to the same key pair (the private key is used
9703 for signing and the public key is merely advertised in the signature
9704 metadata). They must contain keys in the canonical s-expression format
9705 as produced by @command{guix archive --generate-key} (@pxref{Invoking
9706 guix archive}). By default, @file{/etc/guix/signing-key.pub} and
9707 @file{/etc/guix/signing-key.sec} are used.
9708
9709 @item --repl[=@var{port}]
9710 @itemx -r [@var{port}]
9711 Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
9712 Reference Manual}) on @var{port} (37146 by default). This is used
9713 primarily for debugging a running @command{guix publish} server.
9714 @end table
9715
9716 Enabling @command{guix publish} on Guix System is a one-liner: just
9717 instantiate a @code{guix-publish-service-type} service in the @code{services} field
9718 of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
9719 @code{guix-publish-service-type}}).
9720
9721 If you are instead running Guix on a ``foreign distro'', follow these
9722 instructions:”
9723
9724 @itemize
9725 @item
9726 If your host distro uses the systemd init system:
9727
9728 @example
9729 # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
9730 /etc/systemd/system/
9731 # systemctl start guix-publish && systemctl enable guix-publish
9732 @end example
9733
9734 @item
9735 If your host distro uses the Upstart init system:
9736
9737 @example
9738 # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
9739 # start guix-publish
9740 @end example
9741
9742 @item
9743 Otherwise, proceed similarly with your distro's init system.
9744 @end itemize
9745
9746 @node Invoking guix challenge
9747 @section Invoking @command{guix challenge}
9748
9749 @cindex reproducible builds
9750 @cindex verifiable builds
9751 @cindex @command{guix challenge}
9752 @cindex challenge
9753 Do the binaries provided by this server really correspond to the source
9754 code it claims to build? Is a package build process deterministic?
9755 These are the questions the @command{guix challenge} command attempts to
9756 answer.
9757
9758 The former is obviously an important question: Before using a substitute
9759 server (@pxref{Substitutes}), one had better @emph{verify} that it
9760 provides the right binaries, and thus @emph{challenge} it. The latter
9761 is what enables the former: If package builds are deterministic, then
9762 independent builds of the package should yield the exact same result,
9763 bit for bit; if a server provides a binary different from the one
9764 obtained locally, it may be either corrupt or malicious.
9765
9766 We know that the hash that shows up in @file{/gnu/store} file names is
9767 the hash of all the inputs of the process that built the file or
9768 directory---compilers, libraries, build scripts,
9769 etc. (@pxref{Introduction}). Assuming deterministic build processes,
9770 one store file name should map to exactly one build output.
9771 @command{guix challenge} checks whether there is, indeed, a single
9772 mapping by comparing the build outputs of several independent builds of
9773 any given store item.
9774
9775 The command output looks like this:
9776
9777 @smallexample
9778 $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
9779 updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
9780 updating list of substitutes from 'https://guix.example.org'... 100.0%
9781 /gnu/store/@dots{}-openssl-1.0.2d contents differ:
9782 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
9783 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
9784 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
9785 /gnu/store/@dots{}-git-2.5.0 contents differ:
9786 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
9787 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
9788 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
9789 /gnu/store/@dots{}-pius-2.1.1 contents differ:
9790 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
9791 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
9792 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
9793
9794 @dots{}
9795
9796 6,406 store items were analyzed:
9797 - 4,749 (74.1%) were identical
9798 - 525 (8.2%) differed
9799 - 1,132 (17.7%) were inconclusive
9800 @end smallexample
9801
9802 @noindent
9803 In this example, @command{guix challenge} first scans the store to
9804 determine the set of locally-built derivations---as opposed to store
9805 items that were downloaded from a substitute server---and then queries
9806 all the substitute servers. It then reports those store items for which
9807 the servers obtained a result different from the local build.
9808
9809 @cindex non-determinism, in package builds
9810 As an example, @code{guix.example.org} always gets a different answer.
9811 Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
9812 case of Git. This might indicate that the build process of Git is
9813 non-deterministic, meaning that its output varies as a function of
9814 various things that Guix does not fully control, in spite of building
9815 packages in isolated environments (@pxref{Features}). Most common
9816 sources of non-determinism include the addition of timestamps in build
9817 results, the inclusion of random numbers, and directory listings sorted
9818 by inode number. See @uref{https://reproducible-builds.org/docs/}, for
9819 more information.
9820
9821 To find out what is wrong with this Git binary, we can do something along
9822 these lines (@pxref{Invoking guix archive}):
9823
9824 @example
9825 $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0 \
9826 | guix archive -x /tmp/git
9827 $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
9828 @end example
9829
9830 This command shows the difference between the files resulting from the
9831 local build, and the files resulting from the build on
9832 @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
9833 diffutils, Comparing and Merging Files}). The @command{diff} command
9834 works great for text files. When binary files differ, a better option
9835 is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
9836 visualize differences for all kinds of files.
9837
9838 Once you have done that work, you can tell whether the differences are due
9839 to a non-deterministic build process or to a malicious server. We try
9840 hard to remove sources of non-determinism in packages to make it easier
9841 to verify substitutes, but of course, this is a process that
9842 involves not just Guix, but a large part of the free software community.
9843 In the meantime, @command{guix challenge} is one tool to help address
9844 the problem.
9845
9846 If you are writing packages for Guix, you are encouraged to check
9847 whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
9848 same build result as you did with:
9849
9850 @example
9851 $ guix challenge @var{package}
9852 @end example
9853
9854 @noindent
9855 where @var{package} is a package specification such as
9856 @code{guile@@2.0} or @code{glibc:debug}.
9857
9858 The general syntax is:
9859
9860 @example
9861 guix challenge @var{options} [@var{packages}@dots{}]
9862 @end example
9863
9864 When a difference is found between the hash of a locally-built item and
9865 that of a server-provided substitute, or among substitutes provided by
9866 different servers, the command displays it as in the example above and
9867 its exit code is 2 (other non-zero exit codes denote other kinds of
9868 errors.)
9869
9870 The one option that matters is:
9871
9872 @table @code
9873
9874 @item --substitute-urls=@var{urls}
9875 Consider @var{urls} the whitespace-separated list of substitute source
9876 URLs to compare to.
9877
9878 @item --verbose
9879 @itemx -v
9880 Show details about matches (identical contents) in addition to
9881 information about mismatches.
9882
9883 @end table
9884
9885 @node Invoking guix copy
9886 @section Invoking @command{guix copy}
9887
9888 @cindex copy, of store items, over SSH
9889 @cindex SSH, copy of store items
9890 @cindex sharing store items across machines
9891 @cindex transferring store items across machines
9892 The @command{guix copy} command copies items from the store of one
9893 machine to that of another machine over a secure shell (SSH)
9894 connection@footnote{This command is available only when Guile-SSH was
9895 found. @xref{Requirements}, for details.}. For example, the following
9896 command copies the @code{coreutils} package, the user's profile, and all
9897 their dependencies over to @var{host}, logged in as @var{user}:
9898
9899 @example
9900 guix copy --to=@var{user}@@@var{host} \
9901 coreutils `readlink -f ~/.guix-profile`
9902 @end example
9903
9904 If some of the items to be copied are already present on @var{host},
9905 they are not actually sent.
9906
9907 The command below retrieves @code{libreoffice} and @code{gimp} from
9908 @var{host}, assuming they are available there:
9909
9910 @example
9911 guix copy --from=@var{host} libreoffice gimp
9912 @end example
9913
9914 The SSH connection is established using the Guile-SSH client, which is
9915 compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
9916 @file{~/.ssh/config}, and uses the SSH agent for authentication.
9917
9918 The key used to sign items that are sent must be accepted by the remote
9919 machine. Likewise, the key used by the remote machine to sign items you
9920 are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
9921 own daemon. @xref{Invoking guix archive}, for more information about
9922 store item authentication.
9923
9924 The general syntax is:
9925
9926 @example
9927 guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
9928 @end example
9929
9930 You must always specify one of the following options:
9931
9932 @table @code
9933 @item --to=@var{spec}
9934 @itemx --from=@var{spec}
9935 Specify the host to send to or receive from. @var{spec} must be an SSH
9936 spec such as @code{example.org}, @code{charlie@@example.org}, or
9937 @code{charlie@@example.org:2222}.
9938 @end table
9939
9940 The @var{items} can be either package names, such as @code{gimp}, or
9941 store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
9942
9943 When specifying the name of a package to send, it is first built if
9944 needed, unless @option{--dry-run} was specified. Common build options
9945 are supported (@pxref{Common Build Options}).
9946
9947
9948 @node Invoking guix container
9949 @section Invoking @command{guix container}
9950 @cindex container
9951 @cindex @command{guix container}
9952 @quotation Note
9953 As of version @value{VERSION}, this tool is experimental. The interface
9954 is subject to radical change in the future.
9955 @end quotation
9956
9957 The purpose of @command{guix container} is to manipulate processes
9958 running within an isolated environment, commonly known as a
9959 ``container'', typically created by the @command{guix environment}
9960 (@pxref{Invoking guix environment}) and @command{guix system container}
9961 (@pxref{Invoking guix system}) commands.
9962
9963 The general syntax is:
9964
9965 @example
9966 guix container @var{action} @var{options}@dots{}
9967 @end example
9968
9969 @var{action} specifies the operation to perform with a container, and
9970 @var{options} specifies the context-specific arguments for the action.
9971
9972 The following actions are available:
9973
9974 @table @code
9975 @item exec
9976 Execute a command within the context of a running container.
9977
9978 The syntax is:
9979
9980 @example
9981 guix container exec @var{pid} @var{program} @var{arguments}@dots{}
9982 @end example
9983
9984 @var{pid} specifies the process ID of the running container.
9985 @var{program} specifies an executable file name within the root file
9986 system of the container. @var{arguments} are the additional options that
9987 will be passed to @var{program}.
9988
9989 The following command launches an interactive login shell inside a
9990 Guix system container, started by @command{guix system container}, and whose
9991 process ID is 9001:
9992
9993 @example
9994 guix container exec 9001 /run/current-system/profile/bin/bash --login
9995 @end example
9996
9997 Note that the @var{pid} cannot be the parent process of a container. It
9998 must be PID 1 of the container or one of its child processes.
9999
10000 @end table
10001
10002 @node Invoking guix weather
10003 @section Invoking @command{guix weather}
10004
10005 Occasionally you're grumpy because substitutes are lacking and you end
10006 up building packages by yourself (@pxref{Substitutes}). The
10007 @command{guix weather} command reports on substitute availability on the
10008 specified servers so you can have an idea of whether you'll be grumpy
10009 today. It can sometimes be useful info as a user, but it is primarily
10010 useful to people running @command{guix publish} (@pxref{Invoking guix
10011 publish}).
10012
10013 @cindex statistics, for substitutes
10014 @cindex availability of substitutes
10015 @cindex substitute availability
10016 @cindex weather, substitute availability
10017 Here's a sample run:
10018
10019 @example
10020 $ guix weather --substitute-urls=https://guix.example.org
10021 computing 5,872 package derivations for x86_64-linux...
10022 looking for 6,128 store items on https://guix.example.org..
10023 updating list of substitutes from 'https://guix.example.org'... 100.0%
10024 https://guix.example.org
10025 43.4% substitutes available (2,658 out of 6,128)
10026 7,032.5 MiB of nars (compressed)
10027 19,824.2 MiB on disk (uncompressed)
10028 0.030 seconds per request (182.9 seconds in total)
10029 33.5 requests per second
10030
10031 9.8% (342 out of 3,470) of the missing items are queued
10032 867 queued builds
10033 x86_64-linux: 518 (59.7%)
10034 i686-linux: 221 (25.5%)
10035 aarch64-linux: 128 (14.8%)
10036 build rate: 23.41 builds per hour
10037 x86_64-linux: 11.16 builds per hour
10038 i686-linux: 6.03 builds per hour
10039 aarch64-linux: 6.41 builds per hour
10040 @end example
10041
10042 @cindex continuous integration, statistics
10043 As you can see, it reports the fraction of all the packages for which
10044 substitutes are available on the server---regardless of whether
10045 substitutes are enabled, and regardless of whether this server's signing
10046 key is authorized. It also reports the size of the compressed archives
10047 (``nars'') provided by the server, the size the corresponding store
10048 items occupy in the store (assuming deduplication is turned off), and
10049 the server's throughput. The second part gives continuous integration
10050 (CI) statistics, if the server supports it. In addition, using the
10051 @option{--coverage} option, @command{guix weather} can list ``important''
10052 package substitutes missing on the server (see below).
10053
10054 To achieve that, @command{guix weather} queries over HTTP(S) meta-data
10055 (@dfn{narinfos}) for all the relevant store items. Like @command{guix
10056 challenge}, it ignores signatures on those substitutes, which is
10057 innocuous since the command only gathers statistics and cannot install
10058 those substitutes.
10059
10060 Among other things, it is possible to query specific system types and
10061 specific package sets. The available options are listed below.
10062
10063 @table @code
10064 @item --substitute-urls=@var{urls}
10065 @var{urls} is the space-separated list of substitute server URLs to
10066 query. When this option is omitted, the default set of substitute
10067 servers is queried.
10068
10069 @item --system=@var{system}
10070 @itemx -s @var{system}
10071 Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
10072 option can be repeated, in which case @command{guix weather} will query
10073 substitutes for several system types.
10074
10075 @item --manifest=@var{file}
10076 Instead of querying substitutes for all the packages, only ask for those
10077 specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
10078 with the @code{-m} option of @command{guix package} (@pxref{Invoking
10079 guix package}).
10080
10081 @item --coverage[=@var{count}]
10082 @itemx -c [@var{count}]
10083 Report on substitute coverage for packages: list packages with at least
10084 @var{count} dependents (zero by default) for which substitutes are
10085 unavailable. Dependent packages themselves are not listed: if @var{b} depends
10086 on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
10087 @var{b} usually lacks substitutes as well. The result looks like this:
10088
10089 @example
10090 $ guix weather --substitute-urls=https://ci.guix.info -c 10
10091 computing 8,983 package derivations for x86_64-linux...
10092 looking for 9,343 store items on https://ci.guix.info...
10093 updating substitutes from 'https://ci.guix.info'... 100.0%
10094 https://ci.guix.info
10095 64.7% substitutes available (6,047 out of 9,343)
10096 @dots{}
10097 2502 packages are missing from 'https://ci.guix.info' for 'x86_64-linux', among which:
10098 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
10099 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
10100 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
10101 @dots{}
10102 @end example
10103
10104 What this example shows is that @code{kcoreaddons} and presumably the 58
10105 packages that depend on it have no substitutes at @code{ci.guix.info};
10106 likewise for @code{qgpgme} and the 46 packages that depend on it.
10107
10108 If you are a Guix developer, or if you are taking care of this build farm,
10109 you'll probably want to have a closer look at these packages: they may simply
10110 fail to build.
10111 @end table
10112
10113 @node Invoking guix processes
10114 @section Invoking @command{guix processes}
10115
10116 The @command{guix processes} command can be useful to developers and system
10117 administrators, especially on multi-user machines and on build farms: it lists
10118 the current sessions (connections to the daemon), as well as information about
10119 the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
10120 started with @option{--listen} specifying a TCP endpoint, are @emph{not}
10121 listed.}. Here's an example of the information it returns:
10122
10123 @example
10124 $ sudo guix processes
10125 SessionPID: 19002
10126 ClientPID: 19090
10127 ClientCommand: guix environment --ad-hoc python
10128
10129 SessionPID: 19402
10130 ClientPID: 19367
10131 ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
10132
10133 SessionPID: 19444
10134 ClientPID: 19419
10135 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
10136 LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
10137 LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
10138 LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
10139 ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
10140 ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
10141 ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
10142 @end example
10143
10144 In this example we see that @command{guix-daemon} has three clients:
10145 @command{guix environment}, @command{guix publish}, and the Cuirass continuous
10146 integration tool; their process identifier (PID) is given by the
10147 @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
10148 @command{guix-daemon} sub-process of this particular session.
10149
10150 The @code{LockHeld} fields show which store items are currently locked by this
10151 session, which corresponds to store items being built or substituted (the
10152 @code{LockHeld} field is not displayed when @command{guix processes} is not
10153 running as root.) Last, by looking at the @code{ChildProcess} field, we
10154 understand that these three builds are being offloaded (@pxref{Daemon Offload
10155 Setup}).
10156
10157 The output is in Recutils format so we can use the handy @command{recsel}
10158 command to select sessions of interest (@pxref{Selection Expressions,,,
10159 recutils, GNU recutils manual}). As an example, the command shows the command
10160 line and PID of the client that triggered the build of a Perl package:
10161
10162 @example
10163 $ sudo guix processes | \
10164 recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
10165 ClientPID: 19419
10166 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
10167 @end example
10168
10169
10170 @node System Configuration
10171 @chapter System Configuration
10172
10173 @cindex system configuration
10174 The Guix System Distribution supports a consistent whole-system configuration
10175 mechanism. By that we mean that all aspects of the global system
10176 configuration---such as the available system services, timezone and
10177 locale settings, user accounts---are declared in a single place. Such
10178 a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
10179
10180 One of the advantages of putting all the system configuration under the
10181 control of Guix is that it supports transactional system upgrades, and
10182 makes it possible to roll back to a previous system instantiation,
10183 should something go wrong with the new one (@pxref{Features}). Another
10184 advantage is that it makes it easy to replicate the exact same configuration
10185 across different machines, or at different points in time, without
10186 having to resort to additional administration tools layered on top of
10187 the own tools of the system.
10188 @c Yes, we're talking of Puppet, Chef, & co. here. ↑
10189
10190 This section describes this mechanism. First we focus on the system
10191 administrator's viewpoint---explaining how the system is configured and
10192 instantiated. Then we show how this mechanism can be extended, for
10193 instance to support new system services.
10194
10195 @menu
10196 * Using the Configuration System:: Customizing your GNU system.
10197 * operating-system Reference:: Detail of operating-system declarations.
10198 * File Systems:: Configuring file system mounts.
10199 * Mapped Devices:: Block device extra processing.
10200 * User Accounts:: Specifying user accounts.
10201 * Keyboard Layout:: How the system interprets key strokes.
10202 * Locales:: Language and cultural convention settings.
10203 * Services:: Specifying system services.
10204 * Setuid Programs:: Programs running with root privileges.
10205 * X.509 Certificates:: Authenticating HTTPS servers.
10206 * Name Service Switch:: Configuring libc's name service switch.
10207 * Initial RAM Disk:: Linux-Libre bootstrapping.
10208 * Bootloader Configuration:: Configuring the boot loader.
10209 * Invoking guix system:: Instantiating a system configuration.
10210 * Running Guix in a VM:: How to run Guix System in a virtual machine.
10211 * Defining Services:: Adding new service definitions.
10212 @end menu
10213
10214 @node Using the Configuration System
10215 @section Using the Configuration System
10216
10217 The operating system is configured by providing an
10218 @code{operating-system} declaration in a file that can then be passed to
10219 the @command{guix system} command (@pxref{Invoking guix system}). A
10220 simple setup, with the default system services, the default Linux-Libre
10221 kernel, initial RAM disk, and boot loader looks like this:
10222
10223 @findex operating-system
10224 @lisp
10225 @include os-config-bare-bones.texi
10226 @end lisp
10227
10228 This example should be self-describing. Some of the fields defined
10229 above, such as @code{host-name} and @code{bootloader}, are mandatory.
10230 Others, such as @code{packages} and @code{services}, can be omitted, in
10231 which case they get a default value.
10232
10233 Below we discuss the effect of some of the most important fields
10234 (@pxref{operating-system Reference}, for details about all the available
10235 fields), and how to @dfn{instantiate} the operating system using
10236 @command{guix system}.
10237
10238 @unnumberedsubsec Bootloader
10239
10240 @cindex legacy boot, on Intel machines
10241 @cindex BIOS boot, on Intel machines
10242 @cindex UEFI boot
10243 @cindex EFI boot
10244 The @code{bootloader} field describes the method that will be used to boot
10245 your system. Machines based on Intel processors can boot in ``legacy'' BIOS
10246 mode, as in the example above. However, more recent machines rely instead on
10247 the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
10248 the @code{bootloader} field should contain something along these lines:
10249
10250 @example
10251 (bootloader-configuration
10252 (bootloader grub-efi-bootloader)
10253 (target "/boot/efi"))
10254 @end example
10255
10256 @xref{Bootloader Configuration}, for more information on the available
10257 configuration options.
10258
10259 @unnumberedsubsec Globally-Visible Packages
10260
10261 @vindex %base-packages
10262 The @code{packages} field lists packages that will be globally visible
10263 on the system, for all user accounts---i.e., in every user's @code{PATH}
10264 environment variable---in addition to the per-user profiles
10265 (@pxref{Invoking guix package}). The @var{%base-packages} variable
10266 provides all the tools one would expect for basic user and administrator
10267 tasks---including the GNU Core Utilities, the GNU Networking Utilities,
10268 the GNU Zile lightweight text editor, @command{find}, @command{grep},
10269 etc. The example above adds GNU@tie{}Screen to those,
10270 taken from the @code{(gnu packages screen)}
10271 module (@pxref{Package Modules}). The
10272 @code{(list package output)} syntax can be used to add a specific output
10273 of a package:
10274
10275 @lisp
10276 (use-modules (gnu packages))
10277 (use-modules (gnu packages dns))
10278
10279 (operating-system
10280 ;; ...
10281 (packages (cons (list bind "utils")
10282 %base-packages)))
10283 @end lisp
10284
10285 @findex specification->package
10286 Referring to packages by variable name, like @code{bind} above, has
10287 the advantage of being unambiguous; it also allows typos and such to be
10288 diagnosed right away as ``unbound variables''. The downside is that one
10289 needs to know which module defines which package, and to augment the
10290 @code{use-package-modules} line accordingly. To avoid that, one can use
10291 the @code{specification->package} procedure of the @code{(gnu packages)}
10292 module, which returns the best package for a given name or name and
10293 version:
10294
10295 @lisp
10296 (use-modules (gnu packages))
10297
10298 (operating-system
10299 ;; ...
10300 (packages (append (map specification->package
10301 '("tcpdump" "htop" "gnupg@@2.0"))
10302 %base-packages)))
10303 @end lisp
10304
10305 @unnumberedsubsec System Services
10306
10307 @cindex services
10308 @vindex %base-services
10309 The @code{services} field lists @dfn{system services} to be made
10310 available when the system starts (@pxref{Services}).
10311 The @code{operating-system} declaration above specifies that, in
10312 addition to the basic services, we want the OpenSSH secure shell
10313 daemon listening on port 2222 (@pxref{Networking Services,
10314 @code{openssh-service-type}}). Under the hood,
10315 @code{openssh-service-type} arranges so that @command{sshd} is started with the
10316 right command-line options, possibly with supporting configuration files
10317 generated as needed (@pxref{Defining Services}).
10318
10319 @cindex customization, of services
10320 @findex modify-services
10321 Occasionally, instead of using the base services as is, you will want to
10322 customize them. To do this, use @code{modify-services} (@pxref{Service
10323 Reference, @code{modify-services}}) to modify the list.
10324
10325 For example, suppose you want to modify @code{guix-daemon} and Mingetty
10326 (the console log-in) in the @var{%base-services} list (@pxref{Base
10327 Services, @code{%base-services}}). To do that, you can write the
10328 following in your operating system declaration:
10329
10330 @lisp
10331 (define %my-services
10332 ;; My very own list of services.
10333 (modify-services %base-services
10334 (guix-service-type config =>
10335 (guix-configuration
10336 (inherit config)
10337 (use-substitutes? #f)
10338 (extra-options '("--gc-keep-derivations"))))
10339 (mingetty-service-type config =>
10340 (mingetty-configuration
10341 (inherit config)))))
10342
10343 (operating-system
10344 ;; @dots{}
10345 (services %my-services))
10346 @end lisp
10347
10348 This changes the configuration---i.e., the service parameters---of the
10349 @code{guix-service-type} instance, and that of all the
10350 @code{mingetty-service-type} instances in the @var{%base-services} list.
10351 Observe how this is accomplished: first, we arrange for the original
10352 configuration to be bound to the identifier @code{config} in the
10353 @var{body}, and then we write the @var{body} so that it evaluates to the
10354 desired configuration. In particular, notice how we use @code{inherit}
10355 to create a new configuration which has the same values as the old
10356 configuration, but with a few modifications.
10357
10358 @cindex encrypted disk
10359 The configuration for a typical ``desktop'' usage, with an encrypted
10360 root partition, the X11 display
10361 server, GNOME and Xfce (users can choose which of these desktop
10362 environments to use at the log-in screen by pressing @kbd{F1}), network
10363 management, power management, and more, would look like this:
10364
10365 @lisp
10366 @include os-config-desktop.texi
10367 @end lisp
10368
10369 A graphical system with a choice of lightweight window managers
10370 instead of full-blown desktop environments would look like this:
10371
10372 @lisp
10373 @include os-config-lightweight-desktop.texi
10374 @end lisp
10375
10376 This example refers to the @file{/boot/efi} file system by its UUID,
10377 @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
10378 as returned by the @command{blkid} command.
10379
10380 @xref{Desktop Services}, for the exact list of services provided by
10381 @var{%desktop-services}. @xref{X.509 Certificates}, for background
10382 information about the @code{nss-certs} package that is used here.
10383
10384 Again, @var{%desktop-services} is just a list of service objects. If
10385 you want to remove services from there, you can do so using the
10386 procedures for list filtering (@pxref{SRFI-1 Filtering and
10387 Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
10388 following expression returns a list that contains all the services in
10389 @var{%desktop-services} minus the Avahi service:
10390
10391 @example
10392 (remove (lambda (service)
10393 (eq? (service-kind service) avahi-service-type))
10394 %desktop-services)
10395 @end example
10396
10397 @unnumberedsubsec Instantiating the System
10398
10399 Assuming the @code{operating-system} declaration
10400 is stored in the @file{my-system-config.scm}
10401 file, the @command{guix system reconfigure my-system-config.scm} command
10402 instantiates that configuration, and makes it the default GRUB boot
10403 entry (@pxref{Invoking guix system}).
10404
10405 The normal way to change the system configuration is by updating this
10406 file and re-running @command{guix system reconfigure}. One should never
10407 have to touch files in @file{/etc} or to run commands that modify the
10408 system state such as @command{useradd} or @command{grub-install}. In
10409 fact, you must avoid that since that would not only void your warranty
10410 but also prevent you from rolling back to previous versions of your
10411 system, should you ever need to.
10412
10413 @cindex roll-back, of the operating system
10414 Speaking of roll-back, each time you run @command{guix system
10415 reconfigure}, a new @dfn{generation} of the system is created---without
10416 modifying or deleting previous generations. Old system generations get
10417 an entry in the bootloader boot menu, allowing you to boot them in case
10418 something went wrong with the latest generation. Reassuring, no? The
10419 @command{guix system list-generations} command lists the system
10420 generations available on disk. It is also possible to roll back the
10421 system via the commands @command{guix system roll-back} and
10422 @command{guix system switch-generation}.
10423
10424 Although the @command{guix system reconfigure} command will not modify
10425 previous generations, you must take care when the current generation is not
10426 the latest (e.g., after invoking @command{guix system roll-back}), since
10427 the operation might overwrite a later generation (@pxref{Invoking guix
10428 system}).
10429
10430 @unnumberedsubsec The Programming Interface
10431
10432 At the Scheme level, the bulk of an @code{operating-system} declaration
10433 is instantiated with the following monadic procedure (@pxref{The Store
10434 Monad}):
10435
10436 @deffn {Monadic Procedure} operating-system-derivation os
10437 Return a derivation that builds @var{os}, an @code{operating-system}
10438 object (@pxref{Derivations}).
10439
10440 The output of the derivation is a single directory that refers to all
10441 the packages, configuration files, and other supporting files needed to
10442 instantiate @var{os}.
10443 @end deffn
10444
10445 This procedure is provided by the @code{(gnu system)} module. Along
10446 with @code{(gnu services)} (@pxref{Services}), this module contains the
10447 guts of Guix System. Make sure to visit it!
10448
10449
10450 @node operating-system Reference
10451 @section @code{operating-system} Reference
10452
10453 This section summarizes all the options available in
10454 @code{operating-system} declarations (@pxref{Using the Configuration
10455 System}).
10456
10457 @deftp {Data Type} operating-system
10458 This is the data type representing an operating system configuration.
10459 By that, we mean all the global system configuration, not per-user
10460 configuration (@pxref{Using the Configuration System}).
10461
10462 @table @asis
10463 @item @code{kernel} (default: @var{linux-libre})
10464 The package object of the operating system kernel to use@footnote{Currently
10465 only the Linux-libre kernel is supported. In the future, it will be
10466 possible to use the GNU@tie{}Hurd.}.
10467
10468 @item @code{kernel-arguments} (default: @code{'("quiet")})
10469 List of strings or gexps representing additional arguments to pass on
10470 the command-line of the kernel---e.g., @code{("console=ttyS0")}.
10471
10472 @item @code{bootloader}
10473 The system bootloader configuration object. @xref{Bootloader Configuration}.
10474
10475 @item @code{label}
10476 This is the label (a string) as it appears in the bootloader's menu entry.
10477 The default label includes the kernel name and version.
10478
10479 @item @code{keyboard-layout} (default: @code{#f})
10480 This field specifies the keyboard layout to use in the console. It can be
10481 either @code{#f}, in which case the default keyboard layout is used (usually
10482 US English), or a @code{<keyboard-layout>} record.
10483
10484 This keyboard layout is in effect as soon as the kernel has booted. For
10485 instance, it is the keyboard layout in effect when you type a passphrase if
10486 your root file system is on a @code{luks-device-mapping} mapped device
10487 (@pxref{Mapped Devices}).
10488
10489 @quotation Note
10490 This does @emph{not} specify the keyboard layout used by the bootloader, nor
10491 that used by the graphical display server. @xref{Bootloader Configuration},
10492 for information on how to specify the bootloader's keyboard layout. @xref{X
10493 Window}, for information on how to specify the keyboard layout used by the X
10494 Window System.
10495 @end quotation
10496
10497 @item @code{initrd-modules} (default: @code{%base-initrd-modules})
10498 @cindex initrd
10499 @cindex initial RAM disk
10500 The list of Linux kernel modules that need to be available in the
10501 initial RAM disk. @xref{Initial RAM Disk}.
10502
10503 @item @code{initrd} (default: @code{base-initrd})
10504 A procedure that returns an initial RAM disk for the Linux
10505 kernel. This field is provided to support low-level customization and
10506 should rarely be needed for casual use. @xref{Initial RAM Disk}.
10507
10508 @item @code{firmware} (default: @var{%base-firmware})
10509 @cindex firmware
10510 List of firmware packages loadable by the operating system kernel.
10511
10512 The default includes firmware needed for Atheros- and Broadcom-based
10513 WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
10514 respectively). @xref{Hardware Considerations}, for more info on
10515 supported hardware.
10516
10517 @item @code{host-name}
10518 The host name.
10519
10520 @item @code{hosts-file}
10521 @cindex hosts file
10522 A file-like object (@pxref{G-Expressions, file-like objects}) for use as
10523 @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
10524 Reference Manual}). The default is a file with entries for
10525 @code{localhost} and @var{host-name}.
10526
10527 @item @code{mapped-devices} (default: @code{'()})
10528 A list of mapped devices. @xref{Mapped Devices}.
10529
10530 @item @code{file-systems}
10531 A list of file systems. @xref{File Systems}.
10532
10533 @item @code{swap-devices} (default: @code{'()})
10534 @cindex swap devices
10535 A list of strings identifying devices or files to be used for ``swap
10536 space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
10537 Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
10538 It is possible to specify a swap file in a file system on a mapped
10539 device, provided that the necessary device mapping and file system are
10540 also specified. @xref{Mapped Devices} and @ref{File Systems}.
10541
10542 @item @code{users} (default: @code{%base-user-accounts})
10543 @itemx @code{groups} (default: @var{%base-groups})
10544 List of user accounts and groups. @xref{User Accounts}.
10545
10546 If the @code{users} list lacks a user account with UID@tie{}0, a
10547 ``root'' account with UID@tie{}0 is automatically added.
10548
10549 @item @code{skeletons} (default: @code{(default-skeletons)})
10550 A list target file name/file-like object tuples (@pxref{G-Expressions,
10551 file-like objects}). These are the skeleton files that will be added to
10552 the home directory of newly-created user accounts.
10553
10554 For instance, a valid value may look like this:
10555
10556 @example
10557 `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
10558 (".guile" ,(plain-file "guile"
10559 "(use-modules (ice-9 readline))
10560 (activate-readline)")))
10561 @end example
10562
10563 @item @code{issue} (default: @var{%default-issue})
10564 A string denoting the contents of the @file{/etc/issue} file, which is
10565 displayed when users log in on a text console.
10566
10567 @item @code{packages} (default: @var{%base-packages})
10568 The set of packages installed in the global profile, which is accessible
10569 at @file{/run/current-system/profile}.
10570
10571 The default set includes core utilities and it is good practice to
10572 install non-core utilities in user profiles (@pxref{Invoking guix
10573 package}).
10574
10575 @item @code{timezone}
10576 A timezone identifying string---e.g., @code{"Europe/Paris"}.
10577
10578 You can run the @command{tzselect} command to find out which timezone
10579 string corresponds to your region. Choosing an invalid timezone name
10580 causes @command{guix system} to fail.
10581
10582 @item @code{locale} (default: @code{"en_US.utf8"})
10583 The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
10584 Library Reference Manual}). @xref{Locales}, for more information.
10585
10586 @item @code{locale-definitions} (default: @var{%default-locale-definitions})
10587 The list of locale definitions to be compiled and that may be used at
10588 run time. @xref{Locales}.
10589
10590 @item @code{locale-libcs} (default: @code{(list @var{glibc})})
10591 The list of GNU@tie{}libc packages whose locale data and tools are used
10592 to build the locale definitions. @xref{Locales}, for compatibility
10593 considerations that justify this option.
10594
10595 @item @code{name-service-switch} (default: @var{%default-nss})
10596 Configuration of the libc name service switch (NSS)---a
10597 @code{<name-service-switch>} object. @xref{Name Service Switch}, for
10598 details.
10599
10600 @item @code{services} (default: @var{%base-services})
10601 A list of service objects denoting system services. @xref{Services}.
10602
10603 @cindex essential services
10604 @item @code{essential-services} (default: ...)
10605 The list of ``essential services''---i.e., things like instances of
10606 @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
10607 Reference}), which are derived from the operating system definition itself.
10608 As a user you should @emph{never} need to touch this field.
10609
10610 @item @code{pam-services} (default: @code{(base-pam-services)})
10611 @cindex PAM
10612 @cindex pluggable authentication modules
10613 Linux @dfn{pluggable authentication module} (PAM) services.
10614 @c FIXME: Add xref to PAM services section.
10615
10616 @item @code{setuid-programs} (default: @var{%setuid-programs})
10617 List of string-valued G-expressions denoting setuid programs.
10618 @xref{Setuid Programs}.
10619
10620 @item @code{sudoers-file} (default: @var{%sudoers-specification})
10621 @cindex sudoers file
10622 The contents of the @file{/etc/sudoers} file as a file-like object
10623 (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
10624
10625 This file specifies which users can use the @command{sudo} command, what
10626 they are allowed to do, and what privileges they may gain. The default
10627 is that only @code{root} and members of the @code{wheel} group may use
10628 @code{sudo}.
10629
10630 @end table
10631
10632 @deffn {Scheme Syntax} this-operating-system
10633 When used in the @emph{lexical scope} of an operating system field definition,
10634 this identifier resolves to the operating system being defined.
10635
10636 The example below shows how to refer to the operating system being defined in
10637 the definition of the @code{label} field:
10638
10639 @example
10640 (use-modules (gnu) (guix))
10641
10642 (operating-system
10643 ;; ...
10644 (label (package-full-name
10645 (operating-system-kernel this-operating-system))))
10646 @end example
10647
10648 It is an error to refer to @code{this-operating-system} outside an operating
10649 system definition.
10650 @end deffn
10651
10652 @end deftp
10653
10654 @node File Systems
10655 @section File Systems
10656
10657 The list of file systems to be mounted is specified in the
10658 @code{file-systems} field of the operating system declaration
10659 (@pxref{Using the Configuration System}). Each file system is declared
10660 using the @code{file-system} form, like this:
10661
10662 @example
10663 (file-system
10664 (mount-point "/home")
10665 (device "/dev/sda3")
10666 (type "ext4"))
10667 @end example
10668
10669 As usual, some of the fields are mandatory---those shown in the example
10670 above---while others can be omitted. These are described below.
10671
10672 @deftp {Data Type} file-system
10673 Objects of this type represent file systems to be mounted. They
10674 contain the following members:
10675
10676 @table @asis
10677 @item @code{type}
10678 This is a string specifying the type of the file system---e.g.,
10679 @code{"ext4"}.
10680
10681 @item @code{mount-point}
10682 This designates the place where the file system is to be mounted.
10683
10684 @item @code{device}
10685 This names the ``source'' of the file system. It can be one of three
10686 things: a file system label, a file system UUID, or the name of a
10687 @file{/dev} node. Labels and UUIDs offer a way to refer to file
10688 systems without having to hard-code their actual device
10689 name@footnote{Note that, while it is tempting to use
10690 @file{/dev/disk/by-uuid} and similar device names to achieve the same
10691 result, this is not recommended: These special device nodes are created
10692 by the udev daemon and may be unavailable at the time the device is
10693 mounted.}.
10694
10695 @findex file-system-label
10696 File system labels are created using the @code{file-system-label}
10697 procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
10698 plain strings. Here's an example of a file system referred to by its
10699 label, as shown by the @command{e2label} command:
10700
10701 @example
10702 (file-system
10703 (mount-point "/home")
10704 (type "ext4")
10705 (device (file-system-label "my-home")))
10706 @end example
10707
10708 @findex uuid
10709 UUIDs are converted from their string representation (as shown by the
10710 @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
10711 @code{uuid} form expects 16-byte UUIDs as defined in
10712 @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
10713 form of UUID used by the ext2 family of file systems and others, but it
10714 is different from ``UUIDs'' found in FAT file systems, for instance.},
10715 like this:
10716
10717 @example
10718 (file-system
10719 (mount-point "/home")
10720 (type "ext4")
10721 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
10722 @end example
10723
10724 When the source of a file system is a mapped device (@pxref{Mapped
10725 Devices}), its @code{device} field @emph{must} refer to the mapped
10726 device name---e.g., @file{"/dev/mapper/root-partition"}.
10727 This is required so that
10728 the system knows that mounting the file system depends on having the
10729 corresponding device mapping established.
10730
10731 @item @code{flags} (default: @code{'()})
10732 This is a list of symbols denoting mount flags. Recognized flags
10733 include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
10734 access to special files), @code{no-suid} (ignore setuid and setgid
10735 bits), and @code{no-exec} (disallow program execution.)
10736
10737 @item @code{options} (default: @code{#f})
10738 This is either @code{#f}, or a string denoting mount options.
10739
10740 @item @code{mount?} (default: @code{#t})
10741 This value indicates whether to automatically mount the file system when
10742 the system is brought up. When set to @code{#f}, the file system gets
10743 an entry in @file{/etc/fstab} (read by the @command{mount} command) but
10744 is not automatically mounted.
10745
10746 @item @code{needed-for-boot?} (default: @code{#f})
10747 This Boolean value indicates whether the file system is needed when
10748 booting. If that is true, then the file system is mounted when the
10749 initial RAM disk (initrd) is loaded. This is always the case, for
10750 instance, for the root file system.
10751
10752 @item @code{check?} (default: @code{#t})
10753 This Boolean indicates whether the file system needs to be checked for
10754 errors before being mounted.
10755
10756 @item @code{create-mount-point?} (default: @code{#f})
10757 When true, the mount point is created if it does not exist yet.
10758
10759 @item @code{dependencies} (default: @code{'()})
10760 This is a list of @code{<file-system>} or @code{<mapped-device>} objects
10761 representing file systems that must be mounted or mapped devices that
10762 must be opened before (and unmounted or closed after) this one.
10763
10764 As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
10765 a dependency of @file{/sys/fs/cgroup/cpu} and
10766 @file{/sys/fs/cgroup/memory}.
10767
10768 Another example is a file system that depends on a mapped device, for
10769 example for an encrypted partition (@pxref{Mapped Devices}).
10770 @end table
10771 @end deftp
10772
10773 The @code{(gnu system file-systems)} exports the following useful
10774 variables.
10775
10776 @defvr {Scheme Variable} %base-file-systems
10777 These are essential file systems that are required on normal systems,
10778 such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
10779 below.) Operating system declarations should always contain at least
10780 these.
10781 @end defvr
10782
10783 @defvr {Scheme Variable} %pseudo-terminal-file-system
10784 This is the file system to be mounted as @file{/dev/pts}. It supports
10785 @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
10786 functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
10787 Manual}). Pseudo-terminals are used by terminal emulators such as
10788 @command{xterm}.
10789 @end defvr
10790
10791 @defvr {Scheme Variable} %shared-memory-file-system
10792 This file system is mounted as @file{/dev/shm} and is used to support
10793 memory sharing across processes (@pxref{Memory-mapped I/O,
10794 @code{shm_open},, libc, The GNU C Library Reference Manual}).
10795 @end defvr
10796
10797 @defvr {Scheme Variable} %immutable-store
10798 This file system performs a read-only ``bind mount'' of
10799 @file{/gnu/store}, making it read-only for all the users including
10800 @code{root}. This prevents against accidental modification by software
10801 running as @code{root} or by system administrators.
10802
10803 The daemon itself is still able to write to the store: it remounts it
10804 read-write in its own ``name space.''
10805 @end defvr
10806
10807 @defvr {Scheme Variable} %binary-format-file-system
10808 The @code{binfmt_misc} file system, which allows handling of arbitrary
10809 executable file types to be delegated to user space. This requires the
10810 @code{binfmt.ko} kernel module to be loaded.
10811 @end defvr
10812
10813 @defvr {Scheme Variable} %fuse-control-file-system
10814 The @code{fusectl} file system, which allows unprivileged users to mount
10815 and unmount user-space FUSE file systems. This requires the
10816 @code{fuse.ko} kernel module to be loaded.
10817 @end defvr
10818
10819 @node Mapped Devices
10820 @section Mapped Devices
10821
10822 @cindex device mapping
10823 @cindex mapped devices
10824 The Linux kernel has a notion of @dfn{device mapping}: a block device,
10825 such as a hard disk partition, can be @dfn{mapped} into another device,
10826 usually in @code{/dev/mapper/},
10827 with additional processing over the data that flows through
10828 it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
10829 concept of a ``mapped device'' and that of a file system: both boil down
10830 to @emph{translating} input/output operations made on a file to
10831 operations on its backing store. Thus, the Hurd implements mapped
10832 devices, like file systems, using the generic @dfn{translator} mechanism
10833 (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
10834 typical example is encryption device mapping: all writes to the mapped
10835 device are encrypted, and all reads are deciphered, transparently.
10836 Guix extends this notion by considering any device or set of devices that
10837 are @dfn{transformed} in some way to create a new device; for instance,
10838 RAID devices are obtained by @dfn{assembling} several other devices, such
10839 as hard disks or partitions, into a new one that behaves as one partition.
10840 Other examples, not yet implemented, are LVM logical volumes.
10841
10842 Mapped devices are declared using the @code{mapped-device} form,
10843 defined as follows; for examples, see below.
10844
10845 @deftp {Data Type} mapped-device
10846 Objects of this type represent device mappings that will be made when
10847 the system boots up.
10848
10849 @table @code
10850 @item source
10851 This is either a string specifying the name of the block device to be mapped,
10852 such as @code{"/dev/sda3"}, or a list of such strings when several devices
10853 need to be assembled for creating a new one.
10854
10855 @item target
10856 This string specifies the name of the resulting mapped device. For
10857 kernel mappers such as encrypted devices of type @code{luks-device-mapping},
10858 specifying @code{"my-partition"} leads to the creation of
10859 the @code{"/dev/mapper/my-partition"} device.
10860 For RAID devices of type @code{raid-device-mapping}, the full device name
10861 such as @code{"/dev/md0"} needs to be given.
10862
10863 @item type
10864 This must be a @code{mapped-device-kind} object, which specifies how
10865 @var{source} is mapped to @var{target}.
10866 @end table
10867 @end deftp
10868
10869 @defvr {Scheme Variable} luks-device-mapping
10870 This defines LUKS block device encryption using the @command{cryptsetup}
10871 command from the package with the same name. It relies on the
10872 @code{dm-crypt} Linux kernel module.
10873 @end defvr
10874
10875 @defvr {Scheme Variable} raid-device-mapping
10876 This defines a RAID device, which is assembled using the @code{mdadm}
10877 command from the package with the same name. It requires a Linux kernel
10878 module for the appropriate RAID level to be loaded, such as @code{raid456}
10879 for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
10880 @end defvr
10881
10882 @cindex disk encryption
10883 @cindex LUKS
10884 The following example specifies a mapping from @file{/dev/sda3} to
10885 @file{/dev/mapper/home} using LUKS---the
10886 @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
10887 standard mechanism for disk encryption.
10888 The @file{/dev/mapper/home}
10889 device can then be used as the @code{device} of a @code{file-system}
10890 declaration (@pxref{File Systems}).
10891
10892 @example
10893 (mapped-device
10894 (source "/dev/sda3")
10895 (target "home")
10896 (type luks-device-mapping))
10897 @end example
10898
10899 Alternatively, to become independent of device numbering, one may obtain
10900 the LUKS UUID (@dfn{unique identifier}) of the source device by a
10901 command like:
10902
10903 @example
10904 cryptsetup luksUUID /dev/sda3
10905 @end example
10906
10907 and use it as follows:
10908
10909 @example
10910 (mapped-device
10911 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
10912 (target "home")
10913 (type luks-device-mapping))
10914 @end example
10915
10916 @cindex swap encryption
10917 It is also desirable to encrypt swap space, since swap space may contain
10918 sensitive data. One way to accomplish that is to use a swap file in a
10919 file system on a device mapped via LUKS encryption. In this way, the
10920 swap file is encrypted because the entire device is encrypted.
10921 @xref{Preparing for Installation,,Disk Partitioning}, for an example.
10922
10923 A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
10924 may be declared as follows:
10925
10926 @example
10927 (mapped-device
10928 (source (list "/dev/sda1" "/dev/sdb1"))
10929 (target "/dev/md0")
10930 (type raid-device-mapping))
10931 @end example
10932
10933 The @file{/dev/md0} device can then be used as the @code{device} of a
10934 @code{file-system} declaration (@pxref{File Systems}).
10935 Note that the RAID level need not be given; it is chosen during the
10936 initial creation and formatting of the RAID device and is determined
10937 automatically later.
10938
10939
10940 @node User Accounts
10941 @section User Accounts
10942
10943 @cindex users
10944 @cindex accounts
10945 @cindex user accounts
10946 User accounts and groups are entirely managed through the
10947 @code{operating-system} declaration. They are specified with the
10948 @code{user-account} and @code{user-group} forms:
10949
10950 @example
10951 (user-account
10952 (name "alice")
10953 (group "users")
10954 (supplementary-groups '("wheel" ;allow use of sudo, etc.
10955 "audio" ;sound card
10956 "video" ;video devices such as webcams
10957 "cdrom")) ;the good ol' CD-ROM
10958 (comment "Bob's sister")
10959 (home-directory "/home/alice"))
10960 @end example
10961
10962 When booting or upon completion of @command{guix system reconfigure},
10963 the system ensures that only the user accounts and groups specified in
10964 the @code{operating-system} declaration exist, and with the specified
10965 properties. Thus, account or group creations or modifications made by
10966 directly invoking commands such as @command{useradd} are lost upon
10967 reconfiguration or reboot. This ensures that the system remains exactly
10968 as declared.
10969
10970 @deftp {Data Type} user-account
10971 Objects of this type represent user accounts. The following members may
10972 be specified:
10973
10974 @table @asis
10975 @item @code{name}
10976 The name of the user account.
10977
10978 @item @code{group}
10979 @cindex groups
10980 This is the name (a string) or identifier (a number) of the user group
10981 this account belongs to.
10982
10983 @item @code{supplementary-groups} (default: @code{'()})
10984 Optionally, this can be defined as a list of group names that this
10985 account belongs to.
10986
10987 @item @code{uid} (default: @code{#f})
10988 This is the user ID for this account (a number), or @code{#f}. In the
10989 latter case, a number is automatically chosen by the system when the
10990 account is created.
10991
10992 @item @code{comment} (default: @code{""})
10993 A comment about the account, such as the account owner's full name.
10994
10995 @item @code{home-directory}
10996 This is the name of the home directory for the account.
10997
10998 @item @code{create-home-directory?} (default: @code{#t})
10999 Indicates whether the home directory of this account should be created
11000 if it does not exist yet.
11001
11002 @item @code{shell} (default: Bash)
11003 This is a G-expression denoting the file name of a program to be used as
11004 the shell (@pxref{G-Expressions}).
11005
11006 @item @code{system?} (default: @code{#f})
11007 This Boolean value indicates whether the account is a ``system''
11008 account. System accounts are sometimes treated specially; for instance,
11009 graphical login managers do not list them.
11010
11011 @anchor{user-account-password}
11012 @cindex password, for user accounts
11013 @item @code{password} (default: @code{#f})
11014 You would normally leave this field to @code{#f}, initialize user
11015 passwords as @code{root} with the @command{passwd} command, and then let
11016 users change it with @command{passwd}. Passwords set with
11017 @command{passwd} are of course preserved across reboot and
11018 reconfiguration.
11019
11020 If you @emph{do} want to set an initial password for an account, then
11021 this field must contain the encrypted password, as a string. You can use the
11022 @code{crypt} procedure for this purpose:
11023
11024 @example
11025 (user-account
11026 (name "charlie")
11027 (group "users")
11028
11029 ;; Specify a SHA-512-hashed initial password.
11030 (password (crypt "InitialPassword!" "$6$abc")))
11031 @end example
11032
11033 @quotation Note
11034 The hash of this initial password will be available in a file in
11035 @file{/gnu/store}, readable by all the users, so this method must be used with
11036 care.
11037 @end quotation
11038
11039 @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
11040 more information on password encryption, and @ref{Encryption,,, guile, GNU
11041 Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
11042
11043 @end table
11044 @end deftp
11045
11046 @cindex groups
11047 User group declarations are even simpler:
11048
11049 @example
11050 (user-group (name "students"))
11051 @end example
11052
11053 @deftp {Data Type} user-group
11054 This type is for, well, user groups. There are just a few fields:
11055
11056 @table @asis
11057 @item @code{name}
11058 The name of the group.
11059
11060 @item @code{id} (default: @code{#f})
11061 The group identifier (a number). If @code{#f}, a new number is
11062 automatically allocated when the group is created.
11063
11064 @item @code{system?} (default: @code{#f})
11065 This Boolean value indicates whether the group is a ``system'' group.
11066 System groups have low numerical IDs.
11067
11068 @item @code{password} (default: @code{#f})
11069 What, user groups can have a password? Well, apparently yes. Unless
11070 @code{#f}, this field specifies the password of the group.
11071
11072 @end table
11073 @end deftp
11074
11075 For convenience, a variable lists all the basic user groups one may
11076 expect:
11077
11078 @defvr {Scheme Variable} %base-groups
11079 This is the list of basic user groups that users and/or packages expect
11080 to be present on the system. This includes groups such as ``root'',
11081 ``wheel'', and ``users'', as well as groups used to control access to
11082 specific devices such as ``audio'', ``disk'', and ``cdrom''.
11083 @end defvr
11084
11085 @defvr {Scheme Variable} %base-user-accounts
11086 This is the list of basic system accounts that programs may expect to
11087 find on a GNU/Linux system, such as the ``nobody'' account.
11088
11089 Note that the ``root'' account is not included here. It is a
11090 special-case and is automatically added whether or not it is specified.
11091 @end defvr
11092
11093 @node Keyboard Layout
11094 @section Keyboard Layout
11095
11096 @cindex keyboard layout
11097 @cindex keymap
11098 To specify what each key of your keyboard does, you need to tell the operating
11099 system what @dfn{keyboard layout} you want to use. The default, when nothing
11100 is specified, is the US English QWERTY layout for 105-key PC keyboards.
11101 However, German speakers will usually prefer the German QWERTZ layout, French
11102 speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
11103 or bépo, and they might even want to further customize the effect of some of
11104 the keys. This section explains how to get that done.
11105
11106 @cindex keyboard layout, definition
11107 There are three components that will want to know about your keyboard layout:
11108
11109 @itemize
11110 @item
11111 The @emph{bootloader} may want to know what keyboard layout you want to use
11112 (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
11113 you want, for instance, to make sure that you can type the passphrase of your
11114 encrypted root partition using the right layout.
11115
11116 @item
11117 The @emph{operating system kernel}, Linux, will need that so that the console
11118 is properly configured (@pxref{operating-system Reference,
11119 @code{keyboard-layout}}).
11120
11121 @item
11122 The @emph{graphical display server}, usually Xorg, also has its own idea of
11123 the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
11124 @end itemize
11125
11126 Guix allows you to configure all three separately but, fortunately, it allows
11127 you to share the same keyboard layout for all three components.
11128
11129 @cindex XKB, keyboard layouts
11130 Keyboard layouts are represented by records created by the
11131 @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
11132 the X Keyboard extension (XKB), each layout has four attributes: a name (often
11133 a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
11134 optional variant name, an optional keyboard model name, and a possibly empty
11135 list of additional options. In most cases the layout name is all you care
11136 about. Here are a few example:
11137
11138 @example
11139 ;; The German QWERTZ layout. Here we assume a standard
11140 ;; "pc105" keyboard model.
11141 (keyboard-layout "de")
11142
11143 ;; The bépo variant of the French layout.
11144 (keyboard-layout "fr" "bepo")
11145
11146 ;; The Catalan layout.
11147 (keyboard-layout "es" "cat")
11148
11149 ;; The Latin American Spanish layout. In addition, the
11150 ;; "Caps Lock" key is used as an additional "Ctrl" key,
11151 ;; and the "Menu" key is used as a "Compose" key to enter
11152 ;; accented letters.
11153 (keyboard-layout "latam"
11154 #:options '("ctrl:nocaps" "compose:menu"))
11155
11156 ;; The Russian layout for a ThinkPad keyboard.
11157 (keyboard-layout "ru" #:model "thinkpad")
11158
11159 ;; The "US international" layout, which is the US layout plus
11160 ;; dead keys to enter accented characters. This is for an
11161 ;; Apple MacBook keyboard.
11162 (keyboard-layout "us" "intl" #:model "macbook78")
11163 @end example
11164
11165 See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
11166 for a complete list of supported layouts, variants, and models.
11167
11168 @cindex keyboard layout, configuration
11169 Let's say you want your system to use the Turkish keyboard layout throughout
11170 your system---bootloader, console, and Xorg. Here's what your system
11171 configuration would look like:
11172
11173 @findex set-xorg-configuration
11174 @lisp
11175 ;; Using the Turkish layout for the bootloader, the console,
11176 ;; and for Xorg.
11177
11178 (operating-system
11179 ;; ...
11180 (keyboard-layout (keyboard-layout "tr")) ;for the console
11181 (bootloader (bootloader-configuration
11182 (bootloader grub-efi-bootloader)
11183 (target "/boot/efi")
11184 (keyboard-layout keyboard-layout))) ;for GRUB
11185 (services (cons (set-xorg-configuration
11186 (xorg-configuration ;for Xorg
11187 (keyboard-layout keyboard-layout)))
11188 %desktop-services)))
11189 @end lisp
11190
11191 In the example above, for GRUB and for Xorg, we just refer to the
11192 @code{keyboard-layout} field defined above, but we could just as well refer to
11193 a different layout. The @code{set-xorg-configuration} procedure communicates
11194 the desired Xorg configuration to the graphical log-in manager, by default
11195 GDM.
11196
11197 We've discussed how to specify the @emph{default} keyboard layout of your
11198 system when it starts, but you can also adjust it at run time:
11199
11200 @itemize
11201 @item
11202 If you're using GNOME, its settings panel has a ``Region & Language'' entry
11203 where you can select one or more keyboard layouts.
11204
11205 @item
11206 Under Xorg, the @command{setxkbmap} command (from the same-named package)
11207 allows you to change the current layout. For example, this is how you would
11208 change the layout to US Dvorak:
11209
11210 @example
11211 setxkbmap us dvorak
11212 @end example
11213
11214 @item
11215 The @code{loadkeys} command changes the keyboard layout in effect in the Linux
11216 console. However, note that @code{loadkeys} does @emph{not} use the XKB
11217 keyboard layout categorization described above. The command below loads the
11218 French bépo layout:
11219
11220 @example
11221 loadkeys fr-bepo
11222 @end example
11223 @end itemize
11224
11225 @node Locales
11226 @section Locales
11227
11228 @cindex locale
11229 A @dfn{locale} defines cultural conventions for a particular language
11230 and region of the world (@pxref{Locales,,, libc, The GNU C Library
11231 Reference Manual}). Each locale has a name that typically has the form
11232 @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
11233 @code{fr_LU.utf8} designates the locale for the French language, with
11234 cultural conventions from Luxembourg, and using the UTF-8 encoding.
11235
11236 @cindex locale definition
11237 Usually, you will want to specify the default locale for the machine
11238 using the @code{locale} field of the @code{operating-system} declaration
11239 (@pxref{operating-system Reference, @code{locale}}).
11240
11241 The selected locale is automatically added to the @dfn{locale
11242 definitions} known to the system if needed, with its codeset inferred
11243 from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
11244 @code{UTF-8} codeset. Additional locale definitions can be specified in
11245 the @code{locale-definitions} slot of @code{operating-system}---this is
11246 useful, for instance, if the codeset could not be inferred from the
11247 locale name. The default set of locale definitions includes some widely
11248 used locales, but not all the available locales, in order to save space.
11249
11250 For instance, to add the North Frisian locale for Germany, the value of
11251 that field may be:
11252
11253 @example
11254 (cons (locale-definition
11255 (name "fy_DE.utf8") (source "fy_DE"))
11256 %default-locale-definitions)
11257 @end example
11258
11259 Likewise, to save space, one might want @code{locale-definitions} to
11260 list only the locales that are actually used, as in:
11261
11262 @example
11263 (list (locale-definition
11264 (name "ja_JP.eucjp") (source "ja_JP")
11265 (charset "EUC-JP")))
11266 @end example
11267
11268 @vindex LOCPATH
11269 The compiled locale definitions are available at
11270 @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
11271 version, which is the default location where the GNU@tie{}libc provided
11272 by Guix looks for locale data. This can be overridden using the
11273 @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
11274 @code{LOCPATH} and locale packages}).
11275
11276 The @code{locale-definition} form is provided by the @code{(gnu system
11277 locale)} module. Details are given below.
11278
11279 @deftp {Data Type} locale-definition
11280 This is the data type of a locale definition.
11281
11282 @table @asis
11283
11284 @item @code{name}
11285 The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
11286 Reference Manual}, for more information on locale names.
11287
11288 @item @code{source}
11289 The name of the source for that locale. This is typically the
11290 @code{@var{language}_@var{territory}} part of the locale name.
11291
11292 @item @code{charset} (default: @code{"UTF-8"})
11293 The ``character set'' or ``code set'' for that locale,
11294 @uref{http://www.iana.org/assignments/character-sets, as defined by
11295 IANA}.
11296
11297 @end table
11298 @end deftp
11299
11300 @defvr {Scheme Variable} %default-locale-definitions
11301 A list of commonly used UTF-8 locales, used as the default
11302 value of the @code{locale-definitions} field of @code{operating-system}
11303 declarations.
11304
11305 @cindex locale name
11306 @cindex normalized codeset in locale names
11307 These locale definitions use the @dfn{normalized codeset} for the part
11308 that follows the dot in the name (@pxref{Using gettextized software,
11309 normalized codeset,, libc, The GNU C Library Reference Manual}). So for
11310 instance it has @code{uk_UA.utf8} but @emph{not}, say,
11311 @code{uk_UA.UTF-8}.
11312 @end defvr
11313
11314 @subsection Locale Data Compatibility Considerations
11315
11316 @cindex incompatibility, of locale data
11317 @code{operating-system} declarations provide a @code{locale-libcs} field
11318 to specify the GNU@tie{}libc packages that are used to compile locale
11319 declarations (@pxref{operating-system Reference}). ``Why would I
11320 care?'', you may ask. Well, it turns out that the binary format of
11321 locale data is occasionally incompatible from one libc version to
11322 another.
11323
11324 @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
11325 @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
11326 For instance, a program linked against libc version 2.21 is unable to
11327 read locale data produced with libc 2.22; worse, that program
11328 @emph{aborts} instead of simply ignoring the incompatible locale
11329 data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
11330 the incompatible locale data, which is already an improvement.}.
11331 Similarly, a program linked against libc 2.22 can read most, but not
11332 all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
11333 data is incompatible); thus calls to @code{setlocale} may fail, but
11334 programs will not abort.
11335
11336 The ``problem'' with Guix is that users have a lot of freedom: They can
11337 choose whether and when to upgrade software in their profiles, and might
11338 be using a libc version different from the one the system administrator
11339 used to build the system-wide locale data.
11340
11341 Fortunately, unprivileged users can also install their own locale data
11342 and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
11343 @code{GUIX_LOCPATH} and locale packages}).
11344
11345 Still, it is best if the system-wide locale data at
11346 @file{/run/current-system/locale} is built for all the libc versions
11347 actually in use on the system, so that all the programs can access
11348 it---this is especially crucial on a multi-user system. To do that, the
11349 administrator can specify several libc packages in the
11350 @code{locale-libcs} field of @code{operating-system}:
11351
11352 @example
11353 (use-package-modules base)
11354
11355 (operating-system
11356 ;; @dots{}
11357 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
11358 @end example
11359
11360 This example would lead to a system containing locale definitions for
11361 both libc 2.21 and the current version of libc in
11362 @file{/run/current-system/locale}.
11363
11364
11365 @node Services
11366 @section Services
11367
11368 @cindex system services
11369 An important part of preparing an @code{operating-system} declaration is
11370 listing @dfn{system services} and their configuration (@pxref{Using the
11371 Configuration System}). System services are typically daemons launched
11372 when the system boots, or other actions needed at that time---e.g.,
11373 configuring network access.
11374
11375 Guix has a broad definition of ``service'' (@pxref{Service
11376 Composition}), but many services are managed by the GNU@tie{}Shepherd
11377 (@pxref{Shepherd Services}). On a running system, the @command{herd}
11378 command allows you to list the available services, show their status,
11379 start and stop them, or do other specific operations (@pxref{Jump
11380 Start,,, shepherd, The GNU Shepherd Manual}). For example:
11381
11382 @example
11383 # herd status
11384 @end example
11385
11386 The above command, run as @code{root}, lists the currently defined
11387 services. The @command{herd doc} command shows a synopsis of the given
11388 service and its associated actions:
11389
11390 @example
11391 # herd doc nscd
11392 Run libc's name service cache daemon (nscd).
11393
11394 # herd doc nscd action invalidate
11395 invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
11396 @end example
11397
11398 The @command{start}, @command{stop}, and @command{restart} sub-commands
11399 have the effect you would expect. For instance, the commands below stop
11400 the nscd service and restart the Xorg display server:
11401
11402 @example
11403 # herd stop nscd
11404 Service nscd has been stopped.
11405 # herd restart xorg-server
11406 Service xorg-server has been stopped.
11407 Service xorg-server has been started.
11408 @end example
11409
11410 The following sections document the available services, starting with
11411 the core services, that may be used in an @code{operating-system}
11412 declaration.
11413
11414 @menu
11415 * Base Services:: Essential system services.
11416 * Scheduled Job Execution:: The mcron service.
11417 * Log Rotation:: The rottlog service.
11418 * Networking Services:: Network setup, SSH daemon, etc.
11419 * X Window:: Graphical display.
11420 * Printing Services:: Local and remote printer support.
11421 * Desktop Services:: D-Bus and desktop services.
11422 * Sound Services:: ALSA and Pulseaudio services.
11423 * Database Services:: SQL databases, key-value stores, etc.
11424 * Mail Services:: IMAP, POP3, SMTP, and all that.
11425 * Messaging Services:: Messaging services.
11426 * Telephony Services:: Telephony services.
11427 * Monitoring Services:: Monitoring services.
11428 * Kerberos Services:: Kerberos services.
11429 * LDAP Services:: LDAP services.
11430 * Web Services:: Web servers.
11431 * Certificate Services:: TLS certificates via Let's Encrypt.
11432 * DNS Services:: DNS daemons.
11433 * VPN Services:: VPN daemons.
11434 * Network File System:: NFS related services.
11435 * Continuous Integration:: The Cuirass service.
11436 * Power Management Services:: Extending battery life.
11437 * Audio Services:: The MPD.
11438 * Virtualization Services:: Virtualization services.
11439 * Version Control Services:: Providing remote access to Git repositories.
11440 * Game Services:: Game servers.
11441 * Miscellaneous Services:: Other services.
11442 @end menu
11443
11444 @node Base Services
11445 @subsection Base Services
11446
11447 The @code{(gnu services base)} module provides definitions for the basic
11448 services that one expects from the system. The services exported by
11449 this module are listed below.
11450
11451 @defvr {Scheme Variable} %base-services
11452 This variable contains a list of basic services (@pxref{Service Types
11453 and Services}, for more information on service objects) one would
11454 expect from the system: a login service (mingetty) on each tty, syslogd,
11455 the libc name service cache daemon (nscd), the udev device manager, and
11456 more.
11457
11458 This is the default value of the @code{services} field of
11459 @code{operating-system} declarations. Usually, when customizing a
11460 system, you will want to append services to @var{%base-services}, like
11461 this:
11462
11463 @example
11464 (append (list (service avahi-service-type)
11465 (service openssh-service-type))
11466 %base-services)
11467 @end example
11468 @end defvr
11469
11470 @defvr {Scheme Variable} special-files-service-type
11471 This is the service that sets up ``special files'' such as
11472 @file{/bin/sh}; an instance of it is part of @code{%base-services}.
11473
11474 The value associated with @code{special-files-service-type} services
11475 must be a list of tuples where the first element is the ``special file''
11476 and the second element is its target. By default it is:
11477
11478 @cindex @file{/bin/sh}
11479 @cindex @file{sh}, in @file{/bin}
11480 @example
11481 `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
11482 @end example
11483
11484 @cindex @file{/usr/bin/env}
11485 @cindex @file{env}, in @file{/usr/bin}
11486 If you want to add, say, @code{/usr/bin/env} to your system, you can
11487 change it to:
11488
11489 @example
11490 `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
11491 ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
11492 @end example
11493
11494 Since this is part of @code{%base-services}, you can use
11495 @code{modify-services} to customize the set of special files
11496 (@pxref{Service Reference, @code{modify-services}}). But the simple way
11497 to add a special file is @i{via} the @code{extra-special-file} procedure
11498 (see below.)
11499 @end defvr
11500
11501 @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
11502 Use @var{target} as the ``special file'' @var{file}.
11503
11504 For example, adding the following lines to the @code{services} field of
11505 your operating system declaration leads to a @file{/usr/bin/env}
11506 symlink:
11507
11508 @example
11509 (extra-special-file "/usr/bin/env"
11510 (file-append coreutils "/bin/env"))
11511 @end example
11512 @end deffn
11513
11514 @deffn {Scheme Procedure} host-name-service @var{name}
11515 Return a service that sets the host name to @var{name}.
11516 @end deffn
11517
11518 @deffn {Scheme Procedure} login-service @var{config}
11519 Return a service to run login according to @var{config}, a
11520 @code{<login-configuration>} object, which specifies the message of the day,
11521 among other things.
11522 @end deffn
11523
11524 @deftp {Data Type} login-configuration
11525 This is the data type representing the configuration of login.
11526
11527 @table @asis
11528
11529 @item @code{motd}
11530 @cindex message of the day
11531 A file-like object containing the ``message of the day''.
11532
11533 @item @code{allow-empty-passwords?} (default: @code{#t})
11534 Allow empty passwords by default so that first-time users can log in when
11535 the 'root' account has just been created.
11536
11537 @end table
11538 @end deftp
11539
11540 @deffn {Scheme Procedure} mingetty-service @var{config}
11541 Return a service to run mingetty according to @var{config}, a
11542 @code{<mingetty-configuration>} object, which specifies the tty to run, among
11543 other things.
11544 @end deffn
11545
11546 @deftp {Data Type} mingetty-configuration
11547 This is the data type representing the configuration of Mingetty, which
11548 provides the default implementation of virtual console log-in.
11549
11550 @table @asis
11551
11552 @item @code{tty}
11553 The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
11554
11555 @item @code{auto-login} (default: @code{#f})
11556 When true, this field must be a string denoting the user name under
11557 which the system automatically logs in. When it is @code{#f}, a
11558 user name and password must be entered to log in.
11559
11560 @item @code{login-program} (default: @code{#f})
11561 This must be either @code{#f}, in which case the default log-in program
11562 is used (@command{login} from the Shadow tool suite), or a gexp denoting
11563 the name of the log-in program.
11564
11565 @item @code{login-pause?} (default: @code{#f})
11566 When set to @code{#t} in conjunction with @var{auto-login}, the user
11567 will have to press a key before the log-in shell is launched.
11568
11569 @item @code{mingetty} (default: @var{mingetty})
11570 The Mingetty package to use.
11571
11572 @end table
11573 @end deftp
11574
11575 @deffn {Scheme Procedure} agetty-service @var{config}
11576 Return a service to run agetty according to @var{config}, an
11577 @code{<agetty-configuration>} object, which specifies the tty to run,
11578 among other things.
11579 @end deffn
11580
11581 @deftp {Data Type} agetty-configuration
11582 This is the data type representing the configuration of agetty, which
11583 implements virtual and serial console log-in. See the @code{agetty(8)}
11584 man page for more information.
11585
11586 @table @asis
11587
11588 @item @code{tty}
11589 The name of the console this agetty runs on, as a string---e.g.,
11590 @code{"ttyS0"}. This argument is optional, it will default to
11591 a reasonable default serial port used by the kernel Linux.
11592
11593 For this, if there is a value for an option @code{agetty.tty} in the kernel
11594 command line, agetty will extract the device name of the serial port
11595 from it and use that.
11596
11597 If not and if there is a value for an option @code{console} with a tty in
11598 the Linux command line, agetty will extract the device name of the
11599 serial port from it and use that.
11600
11601 In both cases, agetty will leave the other serial device settings
11602 (baud rate etc.)@: alone---in the hope that Linux pinned them to the
11603 correct values.
11604
11605 @item @code{baud-rate} (default: @code{#f})
11606 A string containing a comma-separated list of one or more baud rates, in
11607 descending order.
11608
11609 @item @code{term} (default: @code{#f})
11610 A string containing the value used for the @code{TERM} environment
11611 variable.
11612
11613 @item @code{eight-bits?} (default: @code{#f})
11614 When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
11615 disabled.
11616
11617 @item @code{auto-login} (default: @code{#f})
11618 When passed a login name, as a string, the specified user will be logged
11619 in automatically without prompting for their login name or password.
11620
11621 @item @code{no-reset?} (default: @code{#f})
11622 When @code{#t}, don't reset terminal cflags (control modes).
11623
11624 @item @code{host} (default: @code{#f})
11625 This accepts a string containing the "login_host", which will be written
11626 into the @file{/var/run/utmpx} file.
11627
11628 @item @code{remote?} (default: @code{#f})
11629 When set to @code{#t} in conjunction with @var{host}, this will add an
11630 @code{-r} fakehost option to the command line of the login program
11631 specified in @var{login-program}.
11632
11633 @item @code{flow-control?} (default: @code{#f})
11634 When set to @code{#t}, enable hardware (RTS/CTS) flow control.
11635
11636 @item @code{no-issue?} (default: @code{#f})
11637 When set to @code{#t}, the contents of the @file{/etc/issue} file will
11638 not be displayed before presenting the login prompt.
11639
11640 @item @code{init-string} (default: @code{#f})
11641 This accepts a string that will be sent to the tty or modem before
11642 sending anything else. It can be used to initialize a modem.
11643
11644 @item @code{no-clear?} (default: @code{#f})
11645 When set to @code{#t}, agetty will not clear the screen before showing
11646 the login prompt.
11647
11648 @item @code{login-program} (default: (file-append shadow "/bin/login"))
11649 This must be either a gexp denoting the name of a log-in program, or
11650 unset, in which case the default value is the @command{login} from the
11651 Shadow tool suite.
11652
11653 @item @code{local-line} (default: @code{#f})
11654 Control the CLOCAL line flag. This accepts one of three symbols as
11655 arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
11656 the default value chosen by agetty is @code{'auto}.
11657
11658 @item @code{extract-baud?} (default: @code{#f})
11659 When set to @code{#t}, instruct agetty to try to extract the baud rate
11660 from the status messages produced by certain types of modems.
11661
11662 @item @code{skip-login?} (default: @code{#f})
11663 When set to @code{#t}, do not prompt the user for a login name. This
11664 can be used with @var{login-program} field to use non-standard login
11665 systems.
11666
11667 @item @code{no-newline?} (default: @code{#f})
11668 When set to @code{#t}, do not print a newline before printing the
11669 @file{/etc/issue} file.
11670
11671 @c Is this dangerous only when used with login-program, or always?
11672 @item @code{login-options} (default: @code{#f})
11673 This option accepts a string containing options that are passed to the
11674 login program. When used with the @var{login-program}, be aware that a
11675 malicious user could try to enter a login name containing embedded
11676 options that could be parsed by the login program.
11677
11678 @item @code{login-pause} (default: @code{#f})
11679 When set to @code{#t}, wait for any key before showing the login prompt.
11680 This can be used in conjunction with @var{auto-login} to save memory by
11681 lazily spawning shells.
11682
11683 @item @code{chroot} (default: @code{#f})
11684 Change root to the specified directory. This option accepts a directory
11685 path as a string.
11686
11687 @item @code{hangup?} (default: @code{#f})
11688 Use the Linux system call @code{vhangup} to do a virtual hangup of the
11689 specified terminal.
11690
11691 @item @code{keep-baud?} (default: @code{#f})
11692 When set to @code{#t}, try to keep the existing baud rate. The baud
11693 rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
11694 character.
11695
11696 @item @code{timeout} (default: @code{#f})
11697 When set to an integer value, terminate if no user name could be read
11698 within @var{timeout} seconds.
11699
11700 @item @code{detect-case?} (default: @code{#f})
11701 When set to @code{#t}, turn on support for detecting an uppercase-only
11702 terminal. This setting will detect a login name containing only
11703 uppercase letters as indicating an uppercase-only terminal and turn on
11704 some upper-to-lower case conversions. Note that this will not support
11705 Unicode characters.
11706
11707 @item @code{wait-cr?} (default: @code{#f})
11708 When set to @code{#t}, wait for the user or modem to send a
11709 carriage-return or linefeed character before displaying
11710 @file{/etc/issue} or login prompt. This is typically used with the
11711 @var{init-string} option.
11712
11713 @item @code{no-hints?} (default: @code{#f})
11714 When set to @code{#t}, do not print hints about Num, Caps, and Scroll
11715 locks.
11716
11717 @item @code{no-hostname?} (default: @code{#f})
11718 By default, the hostname is printed. When this option is set to
11719 @code{#t}, no hostname will be shown at all.
11720
11721 @item @code{long-hostname?} (default: @code{#f})
11722 By default, the hostname is only printed until the first dot. When this
11723 option is set to @code{#t}, the fully qualified hostname by
11724 @code{gethostname} or @code{getaddrinfo} is shown.
11725
11726 @item @code{erase-characters} (default: @code{#f})
11727 This option accepts a string of additional characters that should be
11728 interpreted as backspace when the user types their login name.
11729
11730 @item @code{kill-characters} (default: @code{#f})
11731 This option accepts a string that should be interpreted to mean "ignore
11732 all previous characters" (also called a "kill" character) when the types
11733 their login name.
11734
11735 @item @code{chdir} (default: @code{#f})
11736 This option accepts, as a string, a directory path that will be changed
11737 to before login.
11738
11739 @item @code{delay} (default: @code{#f})
11740 This options accepts, as an integer, the number of seconds to sleep
11741 before opening the tty and displaying the login prompt.
11742
11743 @item @code{nice} (default: @code{#f})
11744 This option accepts, as an integer, the nice value with which to run the
11745 @command{login} program.
11746
11747 @item @code{extra-options} (default: @code{'()})
11748 This option provides an "escape hatch" for the user to provide arbitrary
11749 command-line arguments to @command{agetty} as a list of strings.
11750
11751 @end table
11752 @end deftp
11753
11754 @deffn {Scheme Procedure} kmscon-service-type @var{config}
11755 Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
11756 according to @var{config}, a @code{<kmscon-configuration>} object, which
11757 specifies the tty to run, among other things.
11758 @end deffn
11759
11760 @deftp {Data Type} kmscon-configuration
11761 This is the data type representing the configuration of Kmscon, which
11762 implements virtual console log-in.
11763
11764 @table @asis
11765
11766 @item @code{virtual-terminal}
11767 The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
11768
11769 @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
11770 A gexp denoting the name of the log-in program. The default log-in program is
11771 @command{login} from the Shadow tool suite.
11772
11773 @item @code{login-arguments} (default: @code{'("-p")})
11774 A list of arguments to pass to @command{login}.
11775
11776 @item @code{auto-login} (default: @code{#f})
11777 When passed a login name, as a string, the specified user will be logged
11778 in automatically without prompting for their login name or password.
11779
11780 @item @code{hardware-acceleration?} (default: #f)
11781 Whether to use hardware acceleration.
11782
11783 @item @code{kmscon} (default: @var{kmscon})
11784 The Kmscon package to use.
11785
11786 @end table
11787 @end deftp
11788
11789 @cindex name service cache daemon
11790 @cindex nscd
11791 @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
11792 [#:name-services '()]
11793 Return a service that runs the libc name service cache daemon (nscd) with the
11794 given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
11795 Service Switch}, for an example.
11796
11797 For convenience, the Shepherd service for nscd provides the following actions:
11798
11799 @table @code
11800 @item invalidate
11801 @cindex cache invalidation, nscd
11802 @cindex nscd, cache invalidation
11803 This invalidate the given cache. For instance, running:
11804
11805 @example
11806 herd invalidate nscd hosts
11807 @end example
11808
11809 @noindent
11810 invalidates the host name lookup cache of nscd.
11811
11812 @item statistics
11813 Running @command{herd statistics nscd} displays information about nscd usage
11814 and caches.
11815 @end table
11816
11817 @end deffn
11818
11819 @defvr {Scheme Variable} %nscd-default-configuration
11820 This is the default @code{<nscd-configuration>} value (see below) used
11821 by @code{nscd-service}. It uses the caches defined by
11822 @var{%nscd-default-caches}; see below.
11823 @end defvr
11824
11825 @deftp {Data Type} nscd-configuration
11826 This is the data type representing the name service cache daemon (nscd)
11827 configuration.
11828
11829 @table @asis
11830
11831 @item @code{name-services} (default: @code{'()})
11832 List of packages denoting @dfn{name services} that must be visible to
11833 the nscd---e.g., @code{(list @var{nss-mdns})}.
11834
11835 @item @code{glibc} (default: @var{glibc})
11836 Package object denoting the GNU C Library providing the @command{nscd}
11837 command.
11838
11839 @item @code{log-file} (default: @code{"/var/log/nscd.log"})
11840 Name of the nscd log file. This is where debugging output goes when
11841 @code{debug-level} is strictly positive.
11842
11843 @item @code{debug-level} (default: @code{0})
11844 Integer denoting the debugging levels. Higher numbers mean that more
11845 debugging output is logged.
11846
11847 @item @code{caches} (default: @var{%nscd-default-caches})
11848 List of @code{<nscd-cache>} objects denoting things to be cached; see
11849 below.
11850
11851 @end table
11852 @end deftp
11853
11854 @deftp {Data Type} nscd-cache
11855 Data type representing a cache database of nscd and its parameters.
11856
11857 @table @asis
11858
11859 @item @code{database}
11860 This is a symbol representing the name of the database to be cached.
11861 Valid values are @code{passwd}, @code{group}, @code{hosts}, and
11862 @code{services}, which designate the corresponding NSS database
11863 (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
11864
11865 @item @code{positive-time-to-live}
11866 @itemx @code{negative-time-to-live} (default: @code{20})
11867 A number representing the number of seconds during which a positive or
11868 negative lookup result remains in cache.
11869
11870 @item @code{check-files?} (default: @code{#t})
11871 Whether to check for updates of the files corresponding to
11872 @var{database}.
11873
11874 For instance, when @var{database} is @code{hosts}, setting this flag
11875 instructs nscd to check for updates in @file{/etc/hosts} and to take
11876 them into account.
11877
11878 @item @code{persistent?} (default: @code{#t})
11879 Whether the cache should be stored persistently on disk.
11880
11881 @item @code{shared?} (default: @code{#t})
11882 Whether the cache should be shared among users.
11883
11884 @item @code{max-database-size} (default: 32@tie{}MiB)
11885 Maximum size in bytes of the database cache.
11886
11887 @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
11888 @c settings, so leave them out.
11889
11890 @end table
11891 @end deftp
11892
11893 @defvr {Scheme Variable} %nscd-default-caches
11894 List of @code{<nscd-cache>} objects used by default by
11895 @code{nscd-configuration} (see above).
11896
11897 It enables persistent and aggressive caching of service and host name
11898 lookups. The latter provides better host name lookup performance,
11899 resilience in the face of unreliable name servers, and also better
11900 privacy---often the result of host name lookups is in local cache, so
11901 external name servers do not even need to be queried.
11902 @end defvr
11903
11904 @anchor{syslog-configuration-type}
11905 @cindex syslog
11906 @cindex logging
11907 @deftp {Data Type} syslog-configuration
11908 This data type represents the configuration of the syslog daemon.
11909
11910 @table @asis
11911 @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
11912 The syslog daemon to use.
11913
11914 @item @code{config-file} (default: @code{%default-syslog.conf})
11915 The syslog configuration file to use.
11916
11917 @end table
11918 @end deftp
11919
11920 @anchor{syslog-service}
11921 @cindex syslog
11922 @deffn {Scheme Procedure} syslog-service @var{config}
11923 Return a service that runs a syslog daemon according to @var{config}.
11924
11925 @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
11926 information on the configuration file syntax.
11927 @end deffn
11928
11929 @defvr {Scheme Variable} guix-service-type
11930 This is the type of the service that runs the build daemon,
11931 @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
11932 @code{guix-configuration} record as described below.
11933 @end defvr
11934
11935 @anchor{guix-configuration-type}
11936 @deftp {Data Type} guix-configuration
11937 This data type represents the configuration of the Guix build daemon.
11938 @xref{Invoking guix-daemon}, for more information.
11939
11940 @table @asis
11941 @item @code{guix} (default: @var{guix})
11942 The Guix package to use.
11943
11944 @item @code{build-group} (default: @code{"guixbuild"})
11945 Name of the group for build user accounts.
11946
11947 @item @code{build-accounts} (default: @code{10})
11948 Number of build user accounts to create.
11949
11950 @item @code{authorize-key?} (default: @code{#t})
11951 @cindex substitutes, authorization thereof
11952 Whether to authorize the substitute keys listed in
11953 @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
11954 (@pxref{Substitutes}).
11955
11956 @vindex %default-authorized-guix-keys
11957 @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
11958 The list of authorized key files for archive imports, as a list of
11959 string-valued gexps (@pxref{Invoking guix archive}). By default, it
11960 contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
11961
11962 @item @code{use-substitutes?} (default: @code{#t})
11963 Whether to use substitutes.
11964
11965 @item @code{substitute-urls} (default: @var{%default-substitute-urls})
11966 The list of URLs where to look for substitutes by default.
11967
11968 @item @code{max-silent-time} (default: @code{0})
11969 @itemx @code{timeout} (default: @code{0})
11970 The number of seconds of silence and the number of seconds of activity,
11971 respectively, after which a build process times out. A value of zero
11972 disables the timeout.
11973
11974 @item @code{log-compression} (default: @code{'bzip2})
11975 The type of compression used for build logs---one of @code{gzip},
11976 @code{bzip2}, or @code{none}.
11977
11978 @item @code{extra-options} (default: @code{'()})
11979 List of extra command-line options for @command{guix-daemon}.
11980
11981 @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
11982 File where @command{guix-daemon}'s standard output and standard error
11983 are written.
11984
11985 @item @code{http-proxy} (default: @code{#f})
11986 The HTTP proxy used for downloading fixed-output derivations and
11987 substitutes.
11988
11989 @item @code{tmpdir} (default: @code{#f})
11990 A directory path where the @command{guix-daemon} will perform builds.
11991
11992 @end table
11993 @end deftp
11994
11995 @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
11996 Run @var{udev}, which populates the @file{/dev} directory dynamically.
11997 udev rules can be provided as a list of files through the @var{rules}
11998 variable. The procedures @var{udev-rule} and @var{file->udev-rule} from
11999 @code{(gnu services base)} simplify the creation of such rule files.
12000 @end deffn
12001
12002 @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
12003 Return a udev-rule file named @var{file-name} containing the rules
12004 defined by the @var{contents} literal.
12005
12006 In the following example, a rule for a USB device is defined to be
12007 stored in the file @file{90-usb-thing.rules}. The rule runs a script
12008 upon detecting a USB device with a given product identifier.
12009
12010 @example
12011 (define %example-udev-rule
12012 (udev-rule
12013 "90-usb-thing.rules"
12014 (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
12015 "ATTR@{product@}==\"Example\", "
12016 "RUN+=\"/path/to/script\"")))
12017 @end example
12018
12019 The @command{herd rules udev} command, as root, returns the name of the
12020 directory containing all the active udev rules.
12021 @end deffn
12022
12023 Here we show how the default @var{udev-service} can be extended with it.
12024
12025 @example
12026 (operating-system
12027 ;; @dots{}
12028 (services
12029 (modify-services %desktop-services
12030 (udev-service-type config =>
12031 (udev-configuration (inherit config)
12032 (rules (append (udev-configuration-rules config)
12033 (list %example-udev-rule))))))))
12034 @end example
12035
12036 @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
12037 Return a udev file named @var{file-name} containing the rules defined
12038 within @var{file}, a file-like object.
12039
12040 The following example showcases how we can use an existing rule file.
12041
12042 @example
12043 (use-modules (guix download) ;for url-fetch
12044 (guix packages) ;for origin
12045 ;; @dots{})
12046
12047 (define %android-udev-rules
12048 (file->udev-rule
12049 "51-android-udev.rules"
12050 (let ((version "20170910"))
12051 (origin
12052 (method url-fetch)
12053 (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
12054 "android-udev-rules/" version "/51-android.rules"))
12055 (sha256
12056 (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
12057 @end example
12058 @end deffn
12059
12060 Additionally, Guix package definitions can be included in @var{rules} in
12061 order to extend the udev rules with the definitions found under their
12062 @file{lib/udev/rules.d} sub-directory. In lieu of the previous
12063 @var{file->udev-rule} example, we could have used the
12064 @var{android-udev-rules} package which exists in Guix in the @code{(gnu
12065 packages android)} module.
12066
12067 The following example shows how to use the @var{android-udev-rules}
12068 package so that the Android tool @command{adb} can detect devices
12069 without root privileges. It also details how to create the
12070 @code{adbusers} group, which is required for the proper functioning of
12071 the rules defined within the @var{android-udev-rules} package. To
12072 create such a group, we must define it both as part of the
12073 @var{supplementary-groups} of our @var{user-account} declaration, as
12074 well as in the @var{groups} field of the @var{operating-system} record.
12075
12076 @example
12077 (use-modules (gnu packages android) ;for android-udev-rules
12078 (gnu system shadow) ;for user-group
12079 ;; @dots{})
12080
12081 (operating-system
12082 ;; @dots{}
12083 (users (cons (user-acount
12084 ;; @dots{}
12085 (supplementary-groups
12086 '("adbusers" ;for adb
12087 "wheel" "netdev" "audio" "video"))
12088 ;; @dots{})))
12089
12090 (groups (cons (user-group (system? #t) (name "adbusers"))
12091 %base-groups))
12092
12093 ;; @dots{}
12094
12095 (services
12096 (modify-services %desktop-services
12097 (udev-service-type
12098 config =>
12099 (udev-configuration (inherit config)
12100 (rules (cons android-udev-rules
12101 (udev-configuration-rules config))))))))
12102 @end example
12103
12104 @defvr {Scheme Variable} urandom-seed-service-type
12105 Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
12106 when rebooting. It also tries to seed @file{/dev/urandom} from
12107 @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
12108 readable.
12109 @end defvr
12110
12111 @defvr {Scheme Variable} %random-seed-file
12112 This is the name of the file where some random bytes are saved by
12113 @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
12114 It defaults to @file{/var/lib/random-seed}.
12115 @end defvr
12116
12117 @cindex mouse
12118 @cindex gpm
12119 @defvr {Scheme Variable} gpm-service-type
12120 This is the type of the service that runs GPM, the @dfn{general-purpose
12121 mouse daemon}, which provides mouse support to the Linux console. GPM
12122 allows users to use the mouse in the console, notably to select, copy,
12123 and paste text.
12124
12125 The value for services of this type must be a @code{gpm-configuration}
12126 (see below). This service is not part of @var{%base-services}.
12127 @end defvr
12128
12129 @deftp {Data Type} gpm-configuration
12130 Data type representing the configuration of GPM.
12131
12132 @table @asis
12133 @item @code{options} (default: @code{%default-gpm-options})
12134 Command-line options passed to @command{gpm}. The default set of
12135 options instruct @command{gpm} to listen to mouse events on
12136 @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
12137 more information.
12138
12139 @item @code{gpm} (default: @code{gpm})
12140 The GPM package to use.
12141
12142 @end table
12143 @end deftp
12144
12145 @anchor{guix-publish-service-type}
12146 @deffn {Scheme Variable} guix-publish-service-type
12147 This is the service type for @command{guix publish} (@pxref{Invoking
12148 guix publish}). Its value must be a @code{guix-configuration}
12149 object, as described below.
12150
12151 This assumes that @file{/etc/guix} already contains a signing key pair as
12152 created by @command{guix archive --generate-key} (@pxref{Invoking guix
12153 archive}). If that is not the case, the service will fail to start.
12154 @end deffn
12155
12156 @deftp {Data Type} guix-publish-configuration
12157 Data type representing the configuration of the @code{guix publish}
12158 service.
12159
12160 @table @asis
12161 @item @code{guix} (default: @code{guix})
12162 The Guix package to use.
12163
12164 @item @code{port} (default: @code{80})
12165 The TCP port to listen for connections.
12166
12167 @item @code{host} (default: @code{"localhost"})
12168 The host (and thus, network interface) to listen to. Use
12169 @code{"0.0.0.0"} to listen on all the network interfaces.
12170
12171 @item @code{compression-level} (default: @code{3})
12172 The gzip compression level at which substitutes are compressed. Use
12173 @code{0} to disable compression altogether, and @code{9} to get the best
12174 compression ratio at the expense of increased CPU usage.
12175
12176 @item @code{nar-path} (default: @code{"nar"})
12177 The URL path at which ``nars'' can be fetched. @xref{Invoking guix
12178 publish, @code{--nar-path}}, for details.
12179
12180 @item @code{cache} (default: @code{#f})
12181 When it is @code{#f}, disable caching and instead generate archives on
12182 demand. Otherwise, this should be the name of a directory---e.g.,
12183 @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
12184 archives and meta-data ready to be sent. @xref{Invoking guix publish,
12185 @option{--cache}}, for more information on the tradeoffs involved.
12186
12187 @item @code{workers} (default: @code{#f})
12188 When it is an integer, this is the number of worker threads used for
12189 caching; when @code{#f}, the number of processors is used.
12190 @xref{Invoking guix publish, @option{--workers}}, for more information.
12191
12192 @item @code{ttl} (default: @code{#f})
12193 When it is an integer, this denotes the @dfn{time-to-live} in seconds
12194 of the published archives. @xref{Invoking guix publish, @option{--ttl}},
12195 for more information.
12196 @end table
12197 @end deftp
12198
12199 @anchor{rngd-service}
12200 @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
12201 [#:device "/dev/hwrng"]
12202 Return a service that runs the @command{rngd} program from @var{rng-tools}
12203 to add @var{device} to the kernel's entropy pool. The service will fail if
12204 @var{device} does not exist.
12205 @end deffn
12206
12207 @anchor{pam-limits-service}
12208 @cindex session limits
12209 @cindex ulimit
12210 @cindex priority
12211 @cindex realtime
12212 @cindex jackd
12213 @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
12214
12215 Return a service that installs a configuration file for the
12216 @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
12217 @code{pam_limits} module}. The procedure optionally takes a list of
12218 @code{pam-limits-entry} values, which can be used to specify
12219 @code{ulimit} limits and nice priority limits to user sessions.
12220
12221 The following limits definition sets two hard and soft limits for all
12222 login sessions of users in the @code{realtime} group:
12223
12224 @example
12225 (pam-limits-service
12226 (list
12227 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
12228 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
12229 @end example
12230
12231 The first entry increases the maximum realtime priority for
12232 non-privileged processes; the second entry lifts any restriction of the
12233 maximum address space that can be locked in memory. These settings are
12234 commonly used for real-time audio systems.
12235 @end deffn
12236
12237 @node Scheduled Job Execution
12238 @subsection Scheduled Job Execution
12239
12240 @cindex cron
12241 @cindex mcron
12242 @cindex scheduling jobs
12243 The @code{(gnu services mcron)} module provides an interface to
12244 GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
12245 mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
12246 Unix @command{cron} daemon; the main difference is that it is
12247 implemented in Guile Scheme, which provides a lot of flexibility when
12248 specifying the scheduling of jobs and their actions.
12249
12250 The example below defines an operating system that runs the
12251 @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
12252 and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
12253 well as the @command{mkid} command on behalf of an unprivileged user
12254 (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
12255 gexps to introduce job definitions that are passed to mcron
12256 (@pxref{G-Expressions}).
12257
12258 @lisp
12259 (use-modules (guix) (gnu) (gnu services mcron))
12260 (use-package-modules base idutils)
12261
12262 (define updatedb-job
12263 ;; Run 'updatedb' at 3AM every day. Here we write the
12264 ;; job's action as a Scheme procedure.
12265 #~(job '(next-hour '(3))
12266 (lambda ()
12267 (execl (string-append #$findutils "/bin/updatedb")
12268 "updatedb"
12269 "--prunepaths=/tmp /var/tmp /gnu/store"))))
12270
12271 (define garbage-collector-job
12272 ;; Collect garbage 5 minutes after midnight every day.
12273 ;; The job's action is a shell command.
12274 #~(job "5 0 * * *" ;Vixie cron syntax
12275 "guix gc -F 1G"))
12276
12277 (define idutils-job
12278 ;; Update the index database as user "charlie" at 12:15PM
12279 ;; and 19:15PM. This runs from the user's home directory.
12280 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
12281 (string-append #$idutils "/bin/mkid src")
12282 #:user "charlie"))
12283
12284 (operating-system
12285 ;; @dots{}
12286 (services (cons (service mcron-service-type
12287 (mcron-configuration
12288 (jobs (list garbage-collector-job
12289 updatedb-job
12290 idutils-job))))
12291 %base-services)))
12292 @end lisp
12293
12294 @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
12295 for more information on mcron job specifications. Below is the
12296 reference of the mcron service.
12297
12298 On a running system, you can use the @code{schedule} action of the service to
12299 visualize the mcron jobs that will be executed next:
12300
12301 @example
12302 # herd schedule mcron
12303 @end example
12304
12305 @noindent
12306 The example above lists the next five tasks that will be executed, but you can
12307 also specify the number of tasks to display:
12308
12309 @example
12310 # herd schedule mcron 10
12311 @end example
12312
12313 @defvr {Scheme Variable} mcron-service-type
12314 This is the type of the @code{mcron} service, whose value is an
12315 @code{mcron-configuration} object.
12316
12317 This service type can be the target of a service extension that provides
12318 it additional job specifications (@pxref{Service Composition}). In
12319 other words, it is possible to define services that provide additional
12320 mcron jobs to run.
12321 @end defvr
12322
12323 @deftp {Data Type} mcron-configuration
12324 Data type representing the configuration of mcron.
12325
12326 @table @asis
12327 @item @code{mcron} (default: @var{mcron})
12328 The mcron package to use.
12329
12330 @item @code{jobs}
12331 This is a list of gexps (@pxref{G-Expressions}), where each gexp
12332 corresponds to an mcron job specification (@pxref{Syntax, mcron job
12333 specifications,, mcron, GNU@tie{}mcron}).
12334 @end table
12335 @end deftp
12336
12337
12338 @node Log Rotation
12339 @subsection Log Rotation
12340
12341 @cindex rottlog
12342 @cindex log rotation
12343 @cindex logging
12344 Log files such as those found in @file{/var/log} tend to grow endlessly,
12345 so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
12346 their contents in separate files, possibly compressed. The @code{(gnu
12347 services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
12348 log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
12349
12350 The example below defines an operating system that provides log rotation
12351 with the default settings, for commonly encountered log files.
12352
12353 @lisp
12354 (use-modules (guix) (gnu))
12355 (use-service-modules admin mcron)
12356 (use-package-modules base idutils)
12357
12358 (operating-system
12359 ;; @dots{}
12360 (services (cons (service rottlog-service-type)
12361 %base-services)))
12362 @end lisp
12363
12364 @defvr {Scheme Variable} rottlog-service-type
12365 This is the type of the Rottlog service, whose value is a
12366 @code{rottlog-configuration} object.
12367
12368 Other services can extend this one with new @code{log-rotation} objects
12369 (see below), thereby augmenting the set of files to be rotated.
12370
12371 This service type can define mcron jobs (@pxref{Scheduled Job
12372 Execution}) to run the rottlog service.
12373 @end defvr
12374
12375 @deftp {Data Type} rottlog-configuration
12376 Data type representing the configuration of rottlog.
12377
12378 @table @asis
12379 @item @code{rottlog} (default: @code{rottlog})
12380 The Rottlog package to use.
12381
12382 @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
12383 The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
12384 rottlog, GNU Rot[t]log Manual}).
12385
12386 @item @code{rotations} (default: @code{%default-rotations})
12387 A list of @code{log-rotation} objects as defined below.
12388
12389 @item @code{jobs}
12390 This is a list of gexps where each gexp corresponds to an mcron job
12391 specification (@pxref{Scheduled Job Execution}).
12392 @end table
12393 @end deftp
12394
12395 @deftp {Data Type} log-rotation
12396 Data type representing the rotation of a group of log files.
12397
12398 Taking an example from the Rottlog manual (@pxref{Period Related File
12399 Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
12400 defined like this:
12401
12402 @example
12403 (log-rotation
12404 (frequency 'daily)
12405 (files '("/var/log/apache/*"))
12406 (options '("storedir apache-archives"
12407 "rotate 6"
12408 "notifempty"
12409 "nocompress")))
12410 @end example
12411
12412 The list of fields is as follows:
12413
12414 @table @asis
12415 @item @code{frequency} (default: @code{'weekly})
12416 The log rotation frequency, a symbol.
12417
12418 @item @code{files}
12419 The list of files or file glob patterns to rotate.
12420
12421 @item @code{options} (default: @code{'()})
12422 The list of rottlog options for this rotation (@pxref{Configuration
12423 parameters,,, rottlog, GNU Rot[t]lg Manual}).
12424
12425 @item @code{post-rotate} (default: @code{#f})
12426 Either @code{#f} or a gexp to execute once the rotation has completed.
12427 @end table
12428 @end deftp
12429
12430 @defvr {Scheme Variable} %default-rotations
12431 Specifies weekly rotation of @var{%rotated-files} and
12432 a couple of other files.
12433 @end defvr
12434
12435 @defvr {Scheme Variable} %rotated-files
12436 The list of syslog-controlled files to be rotated. By default it is:
12437 @code{'("/var/log/messages" "/var/log/secure")}.
12438 @end defvr
12439
12440 @node Networking Services
12441 @subsection Networking Services
12442
12443 The @code{(gnu services networking)} module provides services to configure
12444 the network interface.
12445
12446 @cindex DHCP, networking service
12447 @defvr {Scheme Variable} dhcp-client-service-type
12448 This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
12449 Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
12450 is the DHCP client package to use, @code{isc-dhcp} by default.
12451 @end defvr
12452
12453 @deffn {Scheme Procedure} dhcpd-service-type
12454 This type defines a service that runs a DHCP daemon. To create a
12455 service of this type, you must supply a @code{<dhcpd-configuration>}.
12456 For example:
12457
12458 @example
12459 (service dhcpd-service-type
12460 (dhcpd-configuration
12461 (config-file (local-file "my-dhcpd.conf"))
12462 (interfaces '("enp0s25"))))
12463 @end example
12464 @end deffn
12465
12466 @deftp {Data Type} dhcpd-configuration
12467 @table @asis
12468 @item @code{package} (default: @code{isc-dhcp})
12469 The package that provides the DHCP daemon. This package is expected to
12470 provide the daemon at @file{sbin/dhcpd} relative to its output
12471 directory. The default package is the
12472 @uref{http://www.isc.org/products/DHCP, ISC's DHCP server}.
12473 @item @code{config-file} (default: @code{#f})
12474 The configuration file to use. This is required. It will be passed to
12475 @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
12476 object (@pxref{G-Expressions, file-like objects}). See @code{man
12477 dhcpd.conf} for details on the configuration file syntax.
12478 @item @code{version} (default: @code{"4"})
12479 The DHCP version to use. The ISC DHCP server supports the values ``4'',
12480 ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
12481 options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
12482 details.
12483 @item @code{run-directory} (default: @code{"/run/dhcpd"})
12484 The run directory to use. At service activation time, this directory
12485 will be created if it does not exist.
12486 @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
12487 The PID file to use. This corresponds to the @code{-pf} option of
12488 @code{dhcpd}. See @code{man dhcpd} for details.
12489 @item @code{interfaces} (default: @code{'()})
12490 The names of the network interfaces on which dhcpd should listen for
12491 broadcasts. If this list is not empty, then its elements (which must be
12492 strings) will be appended to the @code{dhcpd} invocation when starting
12493 the daemon. It may not be necessary to explicitly specify any
12494 interfaces here; see @code{man dhcpd} for details.
12495 @end table
12496 @end deftp
12497
12498 @defvr {Scheme Variable} static-networking-service-type
12499 This is the type for statically-configured network interfaces.
12500 @c TODO Document <static-networking> data structures.
12501 @end defvr
12502
12503 @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
12504 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
12505 [#:requirement @code{'(udev)}]
12506 Return a service that starts @var{interface} with address @var{ip}. If
12507 @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
12508 it must be a string specifying the default network gateway. @var{requirement}
12509 can be used to declare a dependency on another service before configuring the
12510 interface.
12511
12512 This procedure can be called several times, one for each network
12513 interface of interest. Behind the scenes what it does is extend
12514 @code{static-networking-service-type} with additional network interfaces
12515 to handle.
12516
12517 For example:
12518
12519 @example
12520 (static-networking-service "eno1" "192.168.1.82"
12521 #:gateway "192.168.1.2"
12522 #:name-servers '("192.168.1.2"))
12523 @end example
12524 @end deffn
12525
12526 @cindex wicd
12527 @cindex wireless
12528 @cindex WiFi
12529 @cindex network management
12530 @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
12531 Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
12532 management daemon that aims to simplify wired and wireless networking.
12533
12534 This service adds the @var{wicd} package to the global profile, providing
12535 several commands to interact with the daemon and configure networking:
12536 @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
12537 and @command{wicd-curses} user interfaces.
12538 @end deffn
12539
12540 @cindex ModemManager
12541
12542 @defvr {Scheme Variable} modem-manager-service-type
12543 This is the service type for the
12544 @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
12545 service. The value for this service type is a
12546 @code{modem-manager-configuration} record.
12547
12548 This service is part of @code{%desktop-services} (@pxref{Desktop
12549 Services}).
12550 @end defvr
12551
12552 @deftp {Data Type} modem-manager-configuration
12553 Data type representing the configuration of ModemManager.
12554
12555 @table @asis
12556 @item @code{modem-manager} (default: @code{modem-manager})
12557 The ModemManager package to use.
12558
12559 @end table
12560 @end deftp
12561
12562 @cindex NetworkManager
12563
12564 @defvr {Scheme Variable} network-manager-service-type
12565 This is the service type for the
12566 @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
12567 service. The value for this service type is a
12568 @code{network-manager-configuration} record.
12569
12570 This service is part of @code{%desktop-services} (@pxref{Desktop
12571 Services}).
12572 @end defvr
12573
12574 @deftp {Data Type} network-manager-configuration
12575 Data type representing the configuration of NetworkManager.
12576
12577 @table @asis
12578 @item @code{network-manager} (default: @code{network-manager})
12579 The NetworkManager package to use.
12580
12581 @item @code{dns} (default: @code{"default"})
12582 Processing mode for DNS, which affects how NetworkManager uses the
12583 @code{resolv.conf} configuration file.
12584
12585 @table @samp
12586 @item default
12587 NetworkManager will update @code{resolv.conf} to reflect the nameservers
12588 provided by currently active connections.
12589
12590 @item dnsmasq
12591 NetworkManager will run @code{dnsmasq} as a local caching nameserver,
12592 using a "split DNS" configuration if you are connected to a VPN, and
12593 then update @code{resolv.conf} to point to the local nameserver.
12594
12595 @item none
12596 NetworkManager will not modify @code{resolv.conf}.
12597 @end table
12598
12599 @item @code{vpn-plugins} (default: @code{'()})
12600 This is the list of available plugins for virtual private networks
12601 (VPNs). An example of this is the @code{network-manager-openvpn}
12602 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
12603
12604 @end table
12605 @end deftp
12606
12607 @cindex Connman
12608 @deffn {Scheme Variable} connman-service-type
12609 This is the service type to run @url{https://01.org/connman,Connman},
12610 a network connection manager.
12611
12612 Its value must be an
12613 @code{connman-configuration} record as in this example:
12614
12615 @example
12616 (service connman-service-type
12617 (connman-configuration
12618 (disable-vpn? #t)))
12619 @end example
12620
12621 See below for details about @code{connman-configuration}.
12622 @end deffn
12623
12624 @deftp {Data Type} connman-configuration
12625 Data Type representing the configuration of connman.
12626
12627 @table @asis
12628 @item @code{connman} (default: @var{connman})
12629 The connman package to use.
12630
12631 @item @code{disable-vpn?} (default: @code{#f})
12632 When true, disable connman's vpn plugin.
12633 @end table
12634 @end deftp
12635
12636 @cindex WPA Supplicant
12637 @defvr {Scheme Variable} wpa-supplicant-service-type
12638 This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
12639 supplicant}, an authentication daemon required to authenticate against
12640 encrypted WiFi or ethernet networks.
12641 @end defvr
12642
12643 @deftp {Data Type} wpa-supplicant-configuration
12644 Data type representing the configuration of WPA Supplicant.
12645
12646 It takes the following parameters:
12647
12648 @table @asis
12649 @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
12650 The WPA Supplicant package to use.
12651
12652 @item @code{dbus?} (default: @code{#t})
12653 Whether to listen for requests on D-Bus.
12654
12655 @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
12656 Where to store the PID file.
12657
12658 @item @code{interface} (default: @code{#f})
12659 If this is set, it must specify the name of a network interface that
12660 WPA supplicant will control.
12661
12662 @item @code{config-file} (default: @code{#f})
12663 Optional configuration file to use.
12664
12665 @item @code{extra-options} (default: @code{'()})
12666 List of additional command-line arguments to pass to the daemon.
12667 @end table
12668 @end deftp
12669
12670 @cindex iptables
12671 @defvr {Scheme Variable} iptables-service-type
12672 This is the service type to set up an iptables configuration. iptables is a
12673 packet filtering framework supported by the Linux kernel. This service
12674 supports configuring iptables for both IPv4 and IPv6. A simple example
12675 configuration rejecting all incoming connections except those to the ssh port
12676 22 is shown below.
12677
12678 @lisp
12679 (service iptables-service-type
12680 (iptables-configuration
12681 (ipv4-rules (plain-file "iptables.rules" "*filter
12682 :INPUT ACCEPT
12683 :FORWARD ACCEPT
12684 :OUTPUT ACCEPT
12685 -A INPUT -p tcp --dport 22 -j ACCEPT
12686 -A INPUT -j REJECT --reject-with icmp-port-unreachable
12687 COMMIT
12688 "))
12689 (ipv6-rules (plain-file "ip6tables.rules" "*filter
12690 :INPUT ACCEPT
12691 :FORWARD ACCEPT
12692 :OUTPUT ACCEPT
12693 -A INPUT -p tcp --dport 22 -j ACCEPT
12694 -A INPUT -j REJECT --reject-with icmp6-port-unreachable
12695 COMMIT
12696 "))))
12697 @end lisp
12698 @end defvr
12699
12700 @deftp {Data Type} iptables-configuration
12701 The data type representing the configuration of iptables.
12702
12703 @table @asis
12704 @item @code{iptables} (default: @code{iptables})
12705 The iptables package that provides @code{iptables-restore} and
12706 @code{ip6tables-restore}.
12707 @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
12708 The iptables rules to use. It will be passed to @code{iptables-restore}.
12709 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
12710 objects}).
12711 @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
12712 The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
12713 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
12714 objects}).
12715 @end table
12716 @end deftp
12717
12718 @cindex NTP (Network Time Protocol), service
12719 @cindex real time clock
12720 @defvr {Scheme Variable} ntp-service-type
12721 This is the type of the service running the @uref{http://www.ntp.org,
12722 Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
12723 system clock synchronized with that of the specified NTP servers.
12724
12725 The value of this service is an @code{ntpd-configuration} object, as described
12726 below.
12727 @end defvr
12728
12729 @deftp {Data Type} ntp-configuration
12730 This is the data type for the NTP service configuration.
12731
12732 @table @asis
12733 @item @code{servers} (default: @code{%ntp-servers})
12734 This is the list of servers (host names) with which @command{ntpd} will be
12735 synchronized.
12736
12737 @item @code{allow-large-adjustment?} (default: @code{#f})
12738 This determines whether @command{ntpd} is allowed to make an initial
12739 adjustment of more than 1,000 seconds.
12740
12741 @item @code{ntp} (default: @code{ntp})
12742 The NTP package to use.
12743 @end table
12744 @end deftp
12745
12746 @defvr {Scheme Variable} %ntp-servers
12747 List of host names used as the default NTP servers. These are servers of the
12748 @uref{https://www.ntppool.org/en/, NTP Pool Project}.
12749 @end defvr
12750
12751 @cindex OpenNTPD
12752 @deffn {Scheme Procedure} openntpd-service-type
12753 Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
12754 by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
12755 clock synchronized with that of the given servers.
12756
12757 @example
12758 (service
12759 openntpd-service-type
12760 (openntpd-configuration
12761 (listen-on '("127.0.0.1" "::1"))
12762 (sensor '("udcf0 correction 70000"))
12763 (constraint-from '("www.gnu.org"))
12764 (constraints-from '("https://www.google.com/"))
12765 (allow-large-adjustment? #t)))
12766
12767 @end example
12768 @end deffn
12769
12770 @deftp {Data Type} openntpd-configuration
12771 @table @asis
12772 @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
12773 The openntpd executable to use.
12774 @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
12775 A list of local IP addresses or hostnames the ntpd daemon should listen on.
12776 @item @code{query-from} (default: @code{'()})
12777 A list of local IP address the ntpd daemon should use for outgoing queries.
12778 @item @code{sensor} (default: @code{'()})
12779 Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
12780 will listen to each sensor that acutally exists and ignore non-existant ones.
12781 See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
12782 information.
12783 @item @code{server} (default: @var{%ntp-servers})
12784 Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
12785 @item @code{servers} (default: @code{'()})
12786 Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
12787 @item @code{constraint-from} (default: @code{'()})
12788 @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
12789 This time information is not used for precision but acts as an authenticated
12790 constraint, thereby reducing the impact of unauthenticated NTP
12791 man-in-the-middle attacks.
12792 Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
12793 a constraint.
12794 @item @code{constraints-from} (default: @code{'()})
12795 As with constraint from, specify a list of URLs, IP addresses or hostnames of
12796 HTTPS servers to provide a constraint. Should the hostname resolve to multiple
12797 IP addresses, @code{ntpd} will calculate a median constraint from all of them.
12798 @item @code{allow-large-adjustment?} (default: @code{#f})
12799 Determines if @code{ntpd} is allowed to make an initial adjustment of more
12800 than 180 seconds.
12801 @end table
12802 @end deftp
12803
12804 @cindex inetd
12805 @deffn {Scheme variable} inetd-service-type
12806 This service runs the @command{inetd} (@pxref{inetd invocation,,,
12807 inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
12808 connections on internet sockets, and lazily starts the specified server
12809 program when a connection is made on one of these sockets.
12810
12811 The value of this service is an @code{inetd-configuration} object. The
12812 following example configures the @command{inetd} daemon to provide the
12813 built-in @command{echo} service, as well as an smtp service which
12814 forwards smtp traffic over ssh to a server @code{smtp-server} behind a
12815 gateway @code{hostname}:
12816
12817 @example
12818 (service
12819 inetd-service-type
12820 (inetd-configuration
12821 (entries (list
12822 (inetd-entry
12823 (name "echo")
12824 (socket-type 'stream)
12825 (protocol "tcp")
12826 (wait? #f)
12827 (user "root"))
12828 (inetd-entry
12829 (node "127.0.0.1")
12830 (name "smtp")
12831 (socket-type 'stream)
12832 (protocol "tcp")
12833 (wait? #f)
12834 (user "root")
12835 (program (file-append openssh "/bin/ssh"))
12836 (arguments
12837 '("ssh" "-qT" "-i" "/path/to/ssh_key"
12838 "-W" "smtp-server:25" "user@@hostname")))))
12839 @end example
12840
12841 See below for more details about @code{inetd-configuration}.
12842 @end deffn
12843
12844 @deftp {Data Type} inetd-configuration
12845 Data type representing the configuration of @command{inetd}.
12846
12847 @table @asis
12848 @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
12849 The @command{inetd} executable to use.
12850
12851 @item @code{entries} (default: @code{'()})
12852 A list of @command{inetd} service entries. Each entry should be created
12853 by the @code{inetd-entry} constructor.
12854 @end table
12855 @end deftp
12856
12857 @deftp {Data Type} inetd-entry
12858 Data type representing an entry in the @command{inetd} configuration.
12859 Each entry corresponds to a socket where @command{inetd} will listen for
12860 requests.
12861
12862 @table @asis
12863 @item @code{node} (default: @code{#f})
12864 Optional string, a comma-separated list of local addresses
12865 @command{inetd} should use when listening for this service.
12866 @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
12867 description of all options.
12868 @item @code{name}
12869 A string, the name must correspond to an entry in @code{/etc/services}.
12870 @item @code{socket-type}
12871 One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
12872 @code{'seqpacket}.
12873 @item @code{protocol}
12874 A string, must correspond to an entry in @code{/etc/protocols}.
12875 @item @code{wait?} (default: @code{#t})
12876 Whether @command{inetd} should wait for the server to exit before
12877 listening to new service requests.
12878 @item @code{user}
12879 A string containing the user (and, optionally, group) name of the user
12880 as whom the server should run. The group name can be specified in a
12881 suffix, separated by a colon or period, i.e.@: @code{"user"},
12882 @code{"user:group"} or @code{"user.group"}.
12883 @item @code{program} (default: @code{"internal"})
12884 The server program which will serve the requests, or @code{"internal"}
12885 if @command{inetd} should use a built-in service.
12886 @item @code{arguments} (default: @code{'()})
12887 A list strings or file-like objects, which are the server program's
12888 arguments, starting with the zeroth argument, i.e.@: the name of the
12889 program itself. For @command{inetd}'s internal services, this entry
12890 must be @code{'()} or @code{'("internal")}.
12891 @end table
12892
12893 @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
12894 detailed discussion of each configuration field.
12895 @end deftp
12896
12897 @cindex Tor
12898 @defvr {Scheme Variable} tor-service-type
12899 This is the type for a service that runs the @uref{https://torproject.org,
12900 Tor} anonymous networking daemon. The service is configured using a
12901 @code{<tor-configuration>} record. By default, the Tor daemon runs as the
12902 @code{tor} unprivileged user, which is a member of the @code{tor} group.
12903
12904 @end defvr
12905
12906 @deftp {Data Type} tor-configuration
12907 @table @asis
12908 @item @code{tor} (default: @code{tor})
12909 The package that provides the Tor daemon. This package is expected to provide
12910 the daemon at @file{bin/tor} relative to its output directory. The default
12911 package is the @uref{https://www.torproject.org, Tor Project's}
12912 implementation.
12913
12914 @item @code{config-file} (default: @code{(plain-file "empty" "")})
12915 The configuration file to use. It will be appended to a default configuration
12916 file, and the final configuration file will be passed to @code{tor} via its
12917 @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
12918 file-like objects}). See @code{man tor} for details on the configuration file
12919 syntax.
12920
12921 @item @code{hidden-services} (default: @code{'()})
12922 The list of @code{<hidden-service>} records to use. For any hidden service
12923 you include in this list, appropriate configuration to enable the hidden
12924 service will be automatically added to the default configuration file. You
12925 may conveniently create @code{<hidden-service>} records using the
12926 @code{tor-hidden-service} procedure described below.
12927
12928 @item @code{socks-socket-type} (default: @code{'tcp})
12929 The default socket type that Tor should use for its SOCKS socket. This must
12930 be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
12931 Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
12932 If it is @code{'unix}, then Tor will listen on the UNIX domain socket
12933 @file{/var/run/tor/socks-sock}, which will be made writable by members of the
12934 @code{tor} group.
12935
12936 If you want to customize the SOCKS socket in more detail, leave
12937 @code{socks-socket-type} at its default value of @code{'tcp} and use
12938 @code{config-file} to override the default by providing your own
12939 @code{SocksPort} option.
12940 @end table
12941 @end deftp
12942
12943 @cindex hidden service
12944 @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
12945 Define a new Tor @dfn{hidden service} called @var{name} and implementing
12946 @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
12947
12948 @example
12949 '((22 "127.0.0.1:22")
12950 (80 "127.0.0.1:8080"))
12951 @end example
12952
12953 In this example, port 22 of the hidden service is mapped to local port 22, and
12954 port 80 is mapped to local port 8080.
12955
12956 This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
12957 the @file{hostname} file contains the @code{.onion} host name for the hidden
12958 service.
12959
12960 See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
12961 project's documentation} for more information.
12962 @end deffn
12963
12964 The @code{(gnu services rsync)} module provides the following services:
12965
12966 You might want an rsync daemon if you have files that you want available
12967 so anyone (or just yourself) can download existing files or upload new
12968 files.
12969
12970 @deffn {Scheme Variable} rsync-service-type
12971 This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
12972 @command{rsync-configuration} record as in this example:
12973
12974 @example
12975 (service rsync-service-type)
12976 @end example
12977
12978 See below for details about @code{rsync-configuration}.
12979 @end deffn
12980
12981 @deftp {Data Type} rsync-configuration
12982 Data type representing the configuration for @code{rsync-service}.
12983
12984 @table @asis
12985 @item @code{package} (default: @var{rsync})
12986 @code{rsync} package to use.
12987
12988 @item @code{port-number} (default: @code{873})
12989 TCP port on which @command{rsync} listens for incoming connections. If port
12990 is less than @code{1024} @command{rsync} needs to be started as the
12991 @code{root} user and group.
12992
12993 @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
12994 Name of the file where @command{rsync} writes its PID.
12995
12996 @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
12997 Name of the file where @command{rsync} writes its lock file.
12998
12999 @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
13000 Name of the file where @command{rsync} writes its log file.
13001
13002 @item @code{use-chroot?} (default: @var{#t})
13003 Whether to use chroot for @command{rsync} shared directory.
13004
13005 @item @code{share-path} (default: @file{/srv/rsync})
13006 Location of the @command{rsync} shared directory.
13007
13008 @item @code{share-comment} (default: @code{"Rsync share"})
13009 Comment of the @command{rsync} shared directory.
13010
13011 @item @code{read-only?} (default: @var{#f})
13012 Read-write permissions to shared directory.
13013
13014 @item @code{timeout} (default: @code{300})
13015 I/O timeout in seconds.
13016
13017 @item @code{user} (default: @var{"root"})
13018 Owner of the @code{rsync} process.
13019
13020 @item @code{group} (default: @var{"root"})
13021 Group of the @code{rsync} process.
13022
13023 @item @code{uid} (default: @var{"rsyncd"})
13024 User name or user ID that file transfers to and from that module should take
13025 place as when the daemon was run as @code{root}.
13026
13027 @item @code{gid} (default: @var{"rsyncd"})
13028 Group name or group ID that will be used when accessing the module.
13029
13030 @end table
13031 @end deftp
13032
13033 Furthermore, @code{(gnu services ssh)} provides the following services.
13034 @cindex SSH
13035 @cindex SSH server
13036
13037 @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
13038 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
13039 [#:allow-empty-passwords? #f] [#:root-login? #f] @
13040 [#:syslog-output? #t] [#:x11-forwarding? #t] @
13041 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
13042 [#:public-key-authentication? #t] [#:initialize? #t]
13043 Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
13044 @var{host-key} must designate a file containing the host key, and readable
13045 only by root.
13046
13047 When @var{daemonic?} is true, @command{lshd} will detach from the
13048 controlling terminal and log its output to syslogd, unless one sets
13049 @var{syslog-output?} to false. Obviously, it also makes lsh-service
13050 depend on existence of syslogd service. When @var{pid-file?} is true,
13051 @command{lshd} writes its PID to the file called @var{pid-file}.
13052
13053 When @var{initialize?} is true, automatically create the seed and host key
13054 upon service activation if they do not exist yet. This may take long and
13055 require interaction.
13056
13057 When @var{initialize?} is false, it is up to the user to initialize the
13058 randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
13059 a key pair with the private key stored in file @var{host-key} (@pxref{lshd
13060 basics,,, lsh, LSH Manual}).
13061
13062 When @var{interfaces} is empty, lshd listens for connections on all the
13063 network interfaces; otherwise, @var{interfaces} must be a list of host names
13064 or addresses.
13065
13066 @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
13067 passwords, and @var{root-login?} specifies whether to accept log-ins as
13068 root.
13069
13070 The other options should be self-descriptive.
13071 @end deffn
13072
13073 @cindex SSH
13074 @cindex SSH server
13075 @deffn {Scheme Variable} openssh-service-type
13076 This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
13077 shell daemon, @command{sshd}. Its value must be an
13078 @code{openssh-configuration} record as in this example:
13079
13080 @example
13081 (service openssh-service-type
13082 (openssh-configuration
13083 (x11-forwarding? #t)
13084 (permit-root-login 'without-password)
13085 (authorized-keys
13086 `(("alice" ,(local-file "alice.pub"))
13087 ("bob" ,(local-file "bob.pub"))))))
13088 @end example
13089
13090 See below for details about @code{openssh-configuration}.
13091
13092 This service can be extended with extra authorized keys, as in this
13093 example:
13094
13095 @example
13096 (service-extension openssh-service-type
13097 (const `(("charlie"
13098 ,(local-file "charlie.pub")))))
13099 @end example
13100 @end deffn
13101
13102 @deftp {Data Type} openssh-configuration
13103 This is the configuration record for OpenSSH's @command{sshd}.
13104
13105 @table @asis
13106 @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
13107 Name of the file where @command{sshd} writes its PID.
13108
13109 @item @code{port-number} (default: @code{22})
13110 TCP port on which @command{sshd} listens for incoming connections.
13111
13112 @item @code{permit-root-login} (default: @code{#f})
13113 This field determines whether and when to allow logins as root. If
13114 @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
13115 If it's the symbol @code{'without-password}, then root logins are
13116 permitted but not with password-based authentication.
13117
13118 @item @code{allow-empty-passwords?} (default: @code{#f})
13119 When true, users with empty passwords may log in. When false, they may
13120 not.
13121
13122 @item @code{password-authentication?} (default: @code{#t})
13123 When true, users may log in with their password. When false, they have
13124 other authentication methods.
13125
13126 @item @code{public-key-authentication?} (default: @code{#t})
13127 When true, users may log in using public key authentication. When
13128 false, users have to use other authentication method.
13129
13130 Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
13131 This is used only by protocol version 2.
13132
13133 @item @code{x11-forwarding?} (default: @code{#f})
13134 When true, forwarding of X11 graphical client connections is
13135 enabled---in other words, @command{ssh} options @option{-X} and
13136 @option{-Y} will work.
13137
13138 @item @code{allow-agent-forwarding?} (default: @code{#t})
13139 Whether to allow agent forwarding.
13140
13141 @item @code{allow-tcp-forwarding?} (default: @code{#t})
13142 Whether to allow TCP forwarding.
13143
13144 @item @code{gateway-ports?} (default: @code{#f})
13145 Whether to allow gateway ports.
13146
13147 @item @code{challenge-response-authentication?} (default: @code{#f})
13148 Specifies whether challenge response authentication is allowed (e.g.@: via
13149 PAM).
13150
13151 @item @code{use-pam?} (default: @code{#t})
13152 Enables the Pluggable Authentication Module interface. If set to
13153 @code{#t}, this will enable PAM authentication using
13154 @code{challenge-response-authentication?} and
13155 @code{password-authentication?}, in addition to PAM account and session
13156 module processing for all authentication types.
13157
13158 Because PAM challenge response authentication usually serves an
13159 equivalent role to password authentication, you should disable either
13160 @code{challenge-response-authentication?} or
13161 @code{password-authentication?}.
13162
13163 @item @code{print-last-log?} (default: @code{#t})
13164 Specifies whether @command{sshd} should print the date and time of the
13165 last user login when a user logs in interactively.
13166
13167 @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
13168 Configures external subsystems (e.g.@: file transfer daemon).
13169
13170 This is a list of two-element lists, each of which containing the
13171 subsystem name and a command (with optional arguments) to execute upon
13172 subsystem request.
13173
13174 The command @command{internal-sftp} implements an in-process SFTP
13175 server. Alternately, one can specify the @command{sftp-server} command:
13176 @example
13177 (service openssh-service-type
13178 (openssh-configuration
13179 (subsystems
13180 `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
13181 @end example
13182
13183 @item @code{accepted-environment} (default: @code{'()})
13184 List of strings describing which environment variables may be exported.
13185
13186 Each string gets on its own line. See the @code{AcceptEnv} option in
13187 @code{man sshd_config}.
13188
13189 This example allows ssh-clients to export the @code{COLORTERM} variable.
13190 It is set by terminal emulators, which support colors. You can use it in
13191 your shell's ressource file to enable colors for the prompt and commands
13192 if this variable is set.
13193
13194 @example
13195 (service openssh-service-type
13196 (openssh-configuration
13197 (accepted-environment '("COLORTERM"))))
13198 @end example
13199
13200 @item @code{authorized-keys} (default: @code{'()})
13201 @cindex authorized keys, SSH
13202 @cindex SSH authorized keys
13203 This is the list of authorized keys. Each element of the list is a user
13204 name followed by one or more file-like objects that represent SSH public
13205 keys. For example:
13206
13207 @example
13208 (openssh-configuration
13209 (authorized-keys
13210 `(("rekado" ,(local-file "rekado.pub"))
13211 ("chris" ,(local-file "chris.pub"))
13212 ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
13213 @end example
13214
13215 @noindent
13216 registers the specified public keys for user accounts @code{rekado},
13217 @code{chris}, and @code{root}.
13218
13219 Additional authorized keys can be specified @i{via}
13220 @code{service-extension}.
13221
13222 Note that this does @emph{not} interfere with the use of
13223 @file{~/.ssh/authorized_keys}.
13224
13225 @item @code{log-level} (default: @code{'info})
13226 This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
13227 @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
13228 page for @file{sshd_config} for the full list of level names.
13229
13230 @item @code{extra-content} (default: @code{""})
13231 This field can be used to append arbitrary text to the configuration file. It
13232 is especially useful for elaborate configurations that cannot be expressed
13233 otherwise. This configuration, for example, would generally disable root
13234 logins, but permit them from one specific IP address:
13235
13236 @example
13237 (openssh-configuration
13238 (extra-content "\
13239 Match Address 192.168.0.1
13240 PermitRootLogin yes"))
13241 @end example
13242
13243 @end table
13244 @end deftp
13245
13246 @deffn {Scheme Procedure} dropbear-service [@var{config}]
13247 Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
13248 daemon} with the given @var{config}, a @code{<dropbear-configuration>}
13249 object.
13250
13251 For example, to specify a Dropbear service listening on port 1234, add
13252 this call to the operating system's @code{services} field:
13253
13254 @example
13255 (dropbear-service (dropbear-configuration
13256 (port-number 1234)))
13257 @end example
13258 @end deffn
13259
13260 @deftp {Data Type} dropbear-configuration
13261 This data type represents the configuration of a Dropbear SSH daemon.
13262
13263 @table @asis
13264 @item @code{dropbear} (default: @var{dropbear})
13265 The Dropbear package to use.
13266
13267 @item @code{port-number} (default: 22)
13268 The TCP port where the daemon waits for incoming connections.
13269
13270 @item @code{syslog-output?} (default: @code{#t})
13271 Whether to enable syslog output.
13272
13273 @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
13274 File name of the daemon's PID file.
13275
13276 @item @code{root-login?} (default: @code{#f})
13277 Whether to allow @code{root} logins.
13278
13279 @item @code{allow-empty-passwords?} (default: @code{#f})
13280 Whether to allow empty passwords.
13281
13282 @item @code{password-authentication?} (default: @code{#t})
13283 Whether to enable password-based authentication.
13284 @end table
13285 @end deftp
13286
13287 @defvr {Scheme Variable} %facebook-host-aliases
13288 This variable contains a string for use in @file{/etc/hosts}
13289 (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
13290 line contains a entry that maps a known server name of the Facebook
13291 on-line service---e.g., @code{www.facebook.com}---to the local
13292 host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
13293
13294 This variable is typically used in the @code{hosts-file} field of an
13295 @code{operating-system} declaration (@pxref{operating-system Reference,
13296 @file{/etc/hosts}}):
13297
13298 @example
13299 (use-modules (gnu) (guix))
13300
13301 (operating-system
13302 (host-name "mymachine")
13303 ;; ...
13304 (hosts-file
13305 ;; Create a /etc/hosts file with aliases for "localhost"
13306 ;; and "mymachine", as well as for Facebook servers.
13307 (plain-file "hosts"
13308 (string-append (local-host-aliases host-name)
13309 %facebook-host-aliases))))
13310 @end example
13311
13312 This mechanism can prevent programs running locally, such as Web
13313 browsers, from accessing Facebook.
13314 @end defvr
13315
13316 The @code{(gnu services avahi)} provides the following definition.
13317
13318 @defvr {Scheme Variable} avahi-service-type
13319 This is the service that runs @command{avahi-daemon}, a system-wide
13320 mDNS/DNS-SD responder that allows for service discovery and
13321 ``zero-configuration'' host name lookups (see @uref{http://avahi.org/}).
13322 Its value must be a @code{zero-configuration} record---see below.
13323
13324 This service extends the name service cache daemon (nscd) so that it can
13325 resolve @code{.local} host names using
13326 @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
13327 Service Switch}, for information on host name resolution.
13328
13329 Additionally, add the @var{avahi} package to the system profile so that
13330 commands such as @command{avahi-browse} are directly usable.
13331 @end defvr
13332
13333 @deftp {Data Type} avahi-configuration
13334 Data type representation the configuration for Avahi.
13335
13336 @table @asis
13337
13338 @item @code{host-name} (default: @code{#f})
13339 If different from @code{#f}, use that as the host name to
13340 publish for this machine; otherwise, use the machine's actual host name.
13341
13342 @item @code{publish?} (default: @code{#t})
13343 When true, allow host names and services to be published (broadcast) over the
13344 network.
13345
13346 @item @code{publish-workstation?} (default: @code{#t})
13347 When true, @command{avahi-daemon} publishes the machine's host name and IP
13348 address via mDNS on the local network. To view the host names published on
13349 your local network, you can run:
13350
13351 @example
13352 avahi-browse _workstation._tcp
13353 @end example
13354
13355 @item @code{wide-area?} (default: @code{#f})
13356 When true, DNS-SD over unicast DNS is enabled.
13357
13358 @item @code{ipv4?} (default: @code{#t})
13359 @itemx @code{ipv6?} (default: @code{#t})
13360 These fields determine whether to use IPv4/IPv6 sockets.
13361
13362 @item @code{domains-to-browse} (default: @code{'()})
13363 This is a list of domains to browse.
13364 @end table
13365 @end deftp
13366
13367 @deffn {Scheme Variable} openvswitch-service-type
13368 This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
13369 service, whose value should be an @code{openvswitch-configuration}
13370 object.
13371 @end deffn
13372
13373 @deftp {Data Type} openvswitch-configuration
13374 Data type representing the configuration of Open vSwitch, a multilayer
13375 virtual switch which is designed to enable massive network automation
13376 through programmatic extension.
13377
13378 @table @asis
13379 @item @code{package} (default: @var{openvswitch})
13380 Package object of the Open vSwitch.
13381
13382 @end table
13383 @end deftp
13384
13385 @node X Window
13386 @subsection X Window
13387
13388 @cindex X11
13389 @cindex X Window System
13390 @cindex login manager
13391 Support for the X Window graphical display system---specifically
13392 Xorg---is provided by the @code{(gnu services xorg)} module. Note that
13393 there is no @code{xorg-service} procedure. Instead, the X server is
13394 started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
13395
13396 @cindex GDM
13397 @cindex GNOME, login manager
13398 GDM of course allows users to log in into window managers and desktop
13399 environments other than GNOME; for those using GNOME, GDM is required for
13400 features such as automatic screen locking.
13401
13402 @cindex window manager
13403 To use X11, you must install at least one @dfn{window manager}---for
13404 example the @code{windowmaker} or @code{openbox} packages---preferably
13405 by adding it to the @code{packages} field of your operating system
13406 definition (@pxref{operating-system Reference, system-wide packages}).
13407
13408 @defvr {Scheme Variable} gdm-service-type
13409 This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
13410 Desktop Manager} (GDM), a program that manages graphical display servers and
13411 handles graphical user logins. Its value must be a @code{gdm-configuration}
13412 (see below.)
13413
13414 @cindex session types (X11)
13415 @cindex X11 session types
13416 GDM looks for @dfn{session types} described by the @file{.desktop} files in
13417 @file{/run/current-system/profile/share/xsessions} and allows users to choose
13418 a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
13419 and @code{i3} provide @file{.desktop} files; adding them to the system-wide
13420 set of packages automatically makes them available at the log-in screen.
13421
13422 In addition, @file{~/.xsession} files are honored. When available,
13423 @file{~/.xsession} must be an executable that starts a window manager
13424 and/or other X clients.
13425 @end defvr
13426
13427 @deftp {Data Type} gdm-configuration
13428 @table @asis
13429 @item @code{auto-login?} (default: @code{#f})
13430 @itemx @code{default-user} (default: @code{#f})
13431 When @code{auto-login?} is false, GDM presents a log-in screen.
13432
13433 When @code{auto-login?} is true, GDM logs in directly as
13434 @code{default-user}.
13435
13436 @item @code{gnome-shell-assets} (default: ...)
13437 List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
13438
13439 @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
13440 Configuration of the Xorg graphical server.
13441
13442 @item @code{xsession} (default: @code{(xinitrc)})
13443 Script to run before starting a X session.
13444
13445 @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
13446 File name of the @code{dbus-daemon} executable.
13447
13448 @item @code{gdm} (default: @code{gdm})
13449 The GDM package to use.
13450 @end table
13451 @end deftp
13452
13453 @defvr {Scheme Variable} slim-service-type
13454 This is the type for the SLiM graphical login manager for X11.
13455
13456 Like GDM, SLiM looks for session types described by @file{.desktop} files and
13457 allows users to choose a session from the log-in screen using @kbd{F1}. It
13458 also honors @file{~/.xsession} files.
13459 @end defvr
13460
13461 @deftp {Data Type} slim-configuration
13462 Data type representing the configuration of @code{slim-service-type}.
13463
13464 @table @asis
13465 @item @code{allow-empty-passwords?} (default: @code{#t})
13466 Whether to allow logins with empty passwords.
13467
13468 @item @code{auto-login?} (default: @code{#f})
13469 @itemx @code{default-user} (default: @code{""})
13470 When @code{auto-login?} is false, SLiM presents a log-in screen.
13471
13472 When @code{auto-login?} is true, SLiM logs in directly as
13473 @code{default-user}.
13474
13475 @item @code{theme} (default: @code{%default-slim-theme})
13476 @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
13477 The graphical theme to use and its name.
13478
13479 @item @code{auto-login-session} (default: @code{#f})
13480 If true, this must be the name of the executable to start as the default
13481 session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
13482
13483 If false, a session described by one of the available @file{.desktop}
13484 files in @code{/run/current-system/profile} and @code{~/.guix-profile}
13485 will be used.
13486
13487 @quotation Note
13488 You must install at least one window manager in the system profile or in
13489 your user profile. Failing to do that, if @code{auto-login-session} is
13490 false, you will be unable to log in.
13491 @end quotation
13492
13493 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
13494 Configuration of the Xorg graphical server.
13495
13496 @item @code{xauth} (default: @code{xauth})
13497 The XAuth package to use.
13498
13499 @item @code{shepherd} (default: @code{shepherd})
13500 The Shepherd package used when invoking @command{halt} and
13501 @command{reboot}.
13502
13503 @item @code{sessreg} (default: @code{sessreg})
13504 The sessreg package used in order to register the session.
13505
13506 @item @code{slim} (default: @code{slim})
13507 The SLiM package to use.
13508 @end table
13509 @end deftp
13510
13511 @defvr {Scheme Variable} %default-theme
13512 @defvrx {Scheme Variable} %default-theme-name
13513 The default SLiM theme and its name.
13514 @end defvr
13515
13516
13517 @deftp {Data Type} sddm-configuration
13518 This is the data type representing the sddm service configuration.
13519
13520 @table @asis
13521 @item @code{display-server} (default: "x11")
13522 Select display server to use for the greeter. Valid values are "x11"
13523 or "wayland".
13524
13525 @item @code{numlock} (default: "on")
13526 Valid values are "on", "off" or "none".
13527
13528 @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
13529 Command to run when halting.
13530
13531 @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
13532 Command to run when rebooting.
13533
13534 @item @code{theme} (default "maldives")
13535 Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
13536
13537 @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
13538 Directory to look for themes.
13539
13540 @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
13541 Directory to look for faces.
13542
13543 @item @code{default-path} (default "/run/current-system/profile/bin")
13544 Default PATH to use.
13545
13546 @item @code{minimum-uid} (default 1000)
13547 Minimum UID to display in SDDM.
13548
13549 @item @code{maximum-uid} (default 2000)
13550 Maximum UID to display in SDDM
13551
13552 @item @code{remember-last-user?} (default #t)
13553 Remember last user.
13554
13555 @item @code{remember-last-session?} (default #t)
13556 Remember last session.
13557
13558 @item @code{hide-users} (default "")
13559 Usernames to hide from SDDM greeter.
13560
13561 @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
13562 Users with shells listed will be hidden from the SDDM greeter.
13563
13564 @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
13565 Script to run before starting a wayland session.
13566
13567 @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
13568 Directory to look for desktop files starting wayland sessions.
13569
13570 @item @code{xorg-configuration} (default @code{(xorg-configuration)})
13571 Configuration of the Xorg graphical server.
13572
13573 @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
13574 Path to xauth.
13575
13576 @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
13577 Path to Xephyr.
13578
13579 @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
13580 Script to run after starting xorg-server.
13581
13582 @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
13583 Script to run before stopping xorg-server.
13584
13585 @item @code{xsession-command} (default: @code{xinitrc})
13586 Script to run before starting a X session.
13587
13588 @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
13589 Directory to look for desktop files starting X sessions.
13590
13591 @item @code{minimum-vt} (default: 7)
13592 Minimum VT to use.
13593
13594 @item @code{auto-login-user} (default "")
13595 User to use for auto-login.
13596
13597 @item @code{auto-login-session} (default "")
13598 Desktop file to use for auto-login.
13599
13600 @item @code{relogin?} (default #f)
13601 Relogin after logout.
13602
13603 @end table
13604 @end deftp
13605
13606 @cindex login manager
13607 @cindex X11 login
13608 @deffn {Scheme Procedure} sddm-service config
13609 Return a service that spawns the SDDM graphical login manager for config of
13610 type @code{<sddm-configuration>}.
13611
13612 @example
13613 (sddm-service (sddm-configuration
13614 (auto-login-user "Alice")
13615 (auto-login-session "xfce.desktop")))
13616 @end example
13617 @end deffn
13618
13619 @cindex Xorg, configuration
13620 @deftp {Data Type} xorg-configuration
13621 This data type represents the configuration of the Xorg graphical display
13622 server. Note that there is not Xorg service; instead, the X server is started
13623 by a ``display manager'' such as GDM, SDDM, and SLiM. Thus, the configuration
13624 of these display managers aggregates an @code{xorg-configuration} record.
13625
13626 @table @asis
13627 @item @code{modules} (default: @code{%default-xorg-modules})
13628 This is a list of @dfn{module packages} loaded by the Xorg
13629 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
13630
13631 @item @code{fonts} (default: @code{%default-xorg-fonts})
13632 This is a list of font directories to add to the server's @dfn{font path}.
13633
13634 @item @code{drivers} (default: @code{'()})
13635 This must be either the empty list, in which case Xorg chooses a graphics
13636 driver automatically, or a list of driver names that will be tried in this
13637 order---e.g., @code{("modesetting" "vesa")}.
13638
13639 @item @code{resolutions} (default: @code{'()})
13640 When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
13641 resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
13642 768) (640 480))}.
13643
13644 @cindex keyboard layout, for Xorg
13645 @cindex keymap, for Xorg
13646 @item @code{keyboard-layout} (default: @code{#f})
13647 If this is @code{#f}, Xorg uses the default keyboard layout---usually US
13648 English (``qwerty'') for a 105-key PC keyboard.
13649
13650 Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
13651 layout in use when Xorg is running. @xref{Keyboard Layout}, for more
13652 information on how to specify the keyboard layout.
13653
13654 @item @code{extra-config} (default: @code{'()})
13655 This is a list of strings or objects appended to the configuration file. It
13656 is used to pass extra text to be added verbatim to the configuration file.
13657
13658 @item @code{server} (default: @code{xorg-server})
13659 This is the package providing the Xorg server.
13660
13661 @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
13662 This is the list of command-line arguments to pass to the X server. The
13663 default is @code{-nolisten tcp}.
13664 @end table
13665 @end deftp
13666
13667 @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
13668 [@var{login-manager-service-type}]
13669 Tell the log-in manager (of type @var{login-manager-service-type}) to use
13670 @var{config}, an <xorg-configuration> record.
13671
13672 Since the Xorg configuration is embedded in the log-in manager's
13673 configuration---e.g., @code{gdm-configuration}---this procedure provides a
13674 shorthand to set the Xorg configuration.
13675 @end deffn
13676
13677 @deffn {Scheme Procedure} xorg-start-command [@var{config}]
13678 Return a @code{startx} script in which the modules, fonts, etc. specified
13679 in @var{config}, are available. The result should be used in place of
13680 @code{startx}.
13681
13682 Usually the X server is started by a login manager.
13683 @end deffn
13684
13685
13686 @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
13687 Add @var{package}, a package for a screen locker or screen saver whose
13688 command is @var{program}, to the set of setuid programs and add a PAM entry
13689 for it. For example:
13690
13691 @lisp
13692 (screen-locker-service xlockmore "xlock")
13693 @end lisp
13694
13695 makes the good ol' XlockMore usable.
13696 @end deffn
13697
13698
13699 @node Printing Services
13700 @subsection Printing Services
13701
13702 @cindex printer support with CUPS
13703 The @code{(gnu services cups)} module provides a Guix service definition
13704 for the CUPS printing service. To add printer support to a Guix
13705 system, add a @code{cups-service} to the operating system definition:
13706
13707 @deffn {Scheme Variable} cups-service-type
13708 The service type for the CUPS print server. Its value should be a valid
13709 CUPS configuration (see below). To use the default settings, simply
13710 write:
13711 @example
13712 (service cups-service-type)
13713 @end example
13714 @end deffn
13715
13716 The CUPS configuration controls the basic things about your CUPS
13717 installation: what interfaces it listens on, what to do if a print job
13718 fails, how much logging to do, and so on. To actually add a printer,
13719 you have to visit the @url{http://localhost:631} URL, or use a tool such
13720 as GNOME's printer configuration services. By default, configuring a
13721 CUPS service will generate a self-signed certificate if needed, for
13722 secure connections to the print server.
13723
13724 Suppose you want to enable the Web interface of CUPS and also add
13725 support for Epson printers @i{via} the @code{escpr} package and for HP
13726 printers @i{via} the @code{hplip-minimal} package. You can do that directly,
13727 like this (you need to use the @code{(gnu packages cups)} module):
13728
13729 @example
13730 (service cups-service-type
13731 (cups-configuration
13732 (web-interface? #t)
13733 (extensions
13734 (list cups-filters escpr hplip-minimal))))
13735 @end example
13736
13737 Note: If you wish to use the Qt5 based GUI which comes with the hplip
13738 package then it is suggested that you install the @code{hplip} package,
13739 either in your OS configuration file or as your user.
13740
13741 The available configuration parameters follow. Each parameter
13742 definition is preceded by its type; for example, @samp{string-list foo}
13743 indicates that the @code{foo} parameter should be specified as a list of
13744 strings. There is also a way to specify the configuration as a string,
13745 if you have an old @code{cupsd.conf} file that you want to port over
13746 from some other system; see the end for more details.
13747
13748 @c The following documentation was initially generated by
13749 @c (generate-documentation) in (gnu services cups). Manually maintained
13750 @c documentation is better, so we shouldn't hesitate to edit below as
13751 @c needed. However if the change you want to make to this documentation
13752 @c can be done in an automated way, it's probably easier to change
13753 @c (generate-documentation) than to make it below and have to deal with
13754 @c the churn as CUPS updates.
13755
13756
13757 Available @code{cups-configuration} fields are:
13758
13759 @deftypevr {@code{cups-configuration} parameter} package cups
13760 The CUPS package.
13761 @end deftypevr
13762
13763 @deftypevr {@code{cups-configuration} parameter} package-list extensions
13764 Drivers and other extensions to the CUPS package.
13765 @end deftypevr
13766
13767 @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
13768 Configuration of where to write logs, what directories to use for print
13769 spools, and related privileged configuration parameters.
13770
13771 Available @code{files-configuration} fields are:
13772
13773 @deftypevr {@code{files-configuration} parameter} log-location access-log
13774 Defines the access log filename. Specifying a blank filename disables
13775 access log generation. The value @code{stderr} causes log entries to be
13776 sent to the standard error file when the scheduler is running in the
13777 foreground, or to the system log daemon when run in the background. The
13778 value @code{syslog} causes log entries to be sent to the system log
13779 daemon. The server name may be included in filenames using the string
13780 @code{%s}, as in @code{/var/log/cups/%s-access_log}.
13781
13782 Defaults to @samp{"/var/log/cups/access_log"}.
13783 @end deftypevr
13784
13785 @deftypevr {@code{files-configuration} parameter} file-name cache-dir
13786 Where CUPS should cache data.
13787
13788 Defaults to @samp{"/var/cache/cups"}.
13789 @end deftypevr
13790
13791 @deftypevr {@code{files-configuration} parameter} string config-file-perm
13792 Specifies the permissions for all configuration files that the scheduler
13793 writes.
13794
13795 Note that the permissions for the printers.conf file are currently
13796 masked to only allow access from the scheduler user (typically root).
13797 This is done because printer device URIs sometimes contain sensitive
13798 authentication information that should not be generally known on the
13799 system. There is no way to disable this security feature.
13800
13801 Defaults to @samp{"0640"}.
13802 @end deftypevr
13803
13804 @deftypevr {@code{files-configuration} parameter} log-location error-log
13805 Defines the error log filename. Specifying a blank filename disables
13806 access log generation. The value @code{stderr} causes log entries to be
13807 sent to the standard error file when the scheduler is running in the
13808 foreground, or to the system log daemon when run in the background. The
13809 value @code{syslog} causes log entries to be sent to the system log
13810 daemon. The server name may be included in filenames using the string
13811 @code{%s}, as in @code{/var/log/cups/%s-error_log}.
13812
13813 Defaults to @samp{"/var/log/cups/error_log"}.
13814 @end deftypevr
13815
13816 @deftypevr {@code{files-configuration} parameter} string fatal-errors
13817 Specifies which errors are fatal, causing the scheduler to exit. The
13818 kind strings are:
13819
13820 @table @code
13821 @item none
13822 No errors are fatal.
13823
13824 @item all
13825 All of the errors below are fatal.
13826
13827 @item browse
13828 Browsing initialization errors are fatal, for example failed connections
13829 to the DNS-SD daemon.
13830
13831 @item config
13832 Configuration file syntax errors are fatal.
13833
13834 @item listen
13835 Listen or Port errors are fatal, except for IPv6 failures on the
13836 loopback or @code{any} addresses.
13837
13838 @item log
13839 Log file creation or write errors are fatal.
13840
13841 @item permissions
13842 Bad startup file permissions are fatal, for example shared TLS
13843 certificate and key files with world-read permissions.
13844 @end table
13845
13846 Defaults to @samp{"all -browse"}.
13847 @end deftypevr
13848
13849 @deftypevr {@code{files-configuration} parameter} boolean file-device?
13850 Specifies whether the file pseudo-device can be used for new printer
13851 queues. The URI @uref{file:///dev/null} is always allowed.
13852
13853 Defaults to @samp{#f}.
13854 @end deftypevr
13855
13856 @deftypevr {@code{files-configuration} parameter} string group
13857 Specifies the group name or ID that will be used when executing external
13858 programs.
13859
13860 Defaults to @samp{"lp"}.
13861 @end deftypevr
13862
13863 @deftypevr {@code{files-configuration} parameter} string log-file-perm
13864 Specifies the permissions for all log files that the scheduler writes.
13865
13866 Defaults to @samp{"0644"}.
13867 @end deftypevr
13868
13869 @deftypevr {@code{files-configuration} parameter} log-location page-log
13870 Defines the page log filename. Specifying a blank filename disables
13871 access log generation. The value @code{stderr} causes log entries to be
13872 sent to the standard error file when the scheduler is running in the
13873 foreground, or to the system log daemon when run in the background. The
13874 value @code{syslog} causes log entries to be sent to the system log
13875 daemon. The server name may be included in filenames using the string
13876 @code{%s}, as in @code{/var/log/cups/%s-page_log}.
13877
13878 Defaults to @samp{"/var/log/cups/page_log"}.
13879 @end deftypevr
13880
13881 @deftypevr {@code{files-configuration} parameter} string remote-root
13882 Specifies the username that is associated with unauthenticated accesses
13883 by clients claiming to be the root user. The default is @code{remroot}.
13884
13885 Defaults to @samp{"remroot"}.
13886 @end deftypevr
13887
13888 @deftypevr {@code{files-configuration} parameter} file-name request-root
13889 Specifies the directory that contains print jobs and other HTTP request
13890 data.
13891
13892 Defaults to @samp{"/var/spool/cups"}.
13893 @end deftypevr
13894
13895 @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
13896 Specifies the level of security sandboxing that is applied to print
13897 filters, backends, and other child processes of the scheduler; either
13898 @code{relaxed} or @code{strict}. This directive is currently only
13899 used/supported on macOS.
13900
13901 Defaults to @samp{strict}.
13902 @end deftypevr
13903
13904 @deftypevr {@code{files-configuration} parameter} file-name server-keychain
13905 Specifies the location of TLS certificates and private keys. CUPS will
13906 look for public and private keys in this directory: a @code{.crt} files
13907 for PEM-encoded certificates and corresponding @code{.key} files for
13908 PEM-encoded private keys.
13909
13910 Defaults to @samp{"/etc/cups/ssl"}.
13911 @end deftypevr
13912
13913 @deftypevr {@code{files-configuration} parameter} file-name server-root
13914 Specifies the directory containing the server configuration files.
13915
13916 Defaults to @samp{"/etc/cups"}.
13917 @end deftypevr
13918
13919 @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
13920 Specifies whether the scheduler calls fsync(2) after writing
13921 configuration or state files.
13922
13923 Defaults to @samp{#f}.
13924 @end deftypevr
13925
13926 @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
13927 Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
13928 @end deftypevr
13929
13930 @deftypevr {@code{files-configuration} parameter} file-name temp-dir
13931 Specifies the directory where temporary files are stored.
13932
13933 Defaults to @samp{"/var/spool/cups/tmp"}.
13934 @end deftypevr
13935
13936 @deftypevr {@code{files-configuration} parameter} string user
13937 Specifies the user name or ID that is used when running external
13938 programs.
13939
13940 Defaults to @samp{"lp"}.
13941 @end deftypevr
13942 @end deftypevr
13943
13944 @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
13945 Specifies the logging level for the AccessLog file. The @code{config}
13946 level logs when printers and classes are added, deleted, or modified and
13947 when configuration files are accessed or updated. The @code{actions}
13948 level logs when print jobs are submitted, held, released, modified, or
13949 canceled, and any of the conditions for @code{config}. The @code{all}
13950 level logs all requests.
13951
13952 Defaults to @samp{actions}.
13953 @end deftypevr
13954
13955 @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
13956 Specifies whether to purge job history data automatically when it is no
13957 longer required for quotas.
13958
13959 Defaults to @samp{#f}.
13960 @end deftypevr
13961
13962 @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
13963 Specifies which protocols to use for local printer sharing.
13964
13965 Defaults to @samp{dnssd}.
13966 @end deftypevr
13967
13968 @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
13969 Specifies whether the CUPS web interface is advertised.
13970
13971 Defaults to @samp{#f}.
13972 @end deftypevr
13973
13974 @deftypevr {@code{cups-configuration} parameter} boolean browsing?
13975 Specifies whether shared printers are advertised.
13976
13977 Defaults to @samp{#f}.
13978 @end deftypevr
13979
13980 @deftypevr {@code{cups-configuration} parameter} string classification
13981 Specifies the security classification of the server. Any valid banner
13982 name can be used, including "classified", "confidential", "secret",
13983 "topsecret", and "unclassified", or the banner can be omitted to disable
13984 secure printing functions.
13985
13986 Defaults to @samp{""}.
13987 @end deftypevr
13988
13989 @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
13990 Specifies whether users may override the classification (cover page) of
13991 individual print jobs using the @code{job-sheets} option.
13992
13993 Defaults to @samp{#f}.
13994 @end deftypevr
13995
13996 @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
13997 Specifies the default type of authentication to use.
13998
13999 Defaults to @samp{Basic}.
14000 @end deftypevr
14001
14002 @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
14003 Specifies whether encryption will be used for authenticated requests.
14004
14005 Defaults to @samp{Required}.
14006 @end deftypevr
14007
14008 @deftypevr {@code{cups-configuration} parameter} string default-language
14009 Specifies the default language to use for text and web content.
14010
14011 Defaults to @samp{"en"}.
14012 @end deftypevr
14013
14014 @deftypevr {@code{cups-configuration} parameter} string default-paper-size
14015 Specifies the default paper size for new print queues. @samp{"Auto"}
14016 uses a locale-specific default, while @samp{"None"} specifies there is
14017 no default paper size. Specific size names are typically
14018 @samp{"Letter"} or @samp{"A4"}.
14019
14020 Defaults to @samp{"Auto"}.
14021 @end deftypevr
14022
14023 @deftypevr {@code{cups-configuration} parameter} string default-policy
14024 Specifies the default access policy to use.
14025
14026 Defaults to @samp{"default"}.
14027 @end deftypevr
14028
14029 @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
14030 Specifies whether local printers are shared by default.
14031
14032 Defaults to @samp{#t}.
14033 @end deftypevr
14034
14035 @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
14036 Specifies the delay for updating of configuration and state files, in
14037 seconds. A value of 0 causes the update to happen as soon as possible,
14038 typically within a few milliseconds.
14039
14040 Defaults to @samp{30}.
14041 @end deftypevr
14042
14043 @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
14044 Specifies what to do when an error occurs. Possible values are
14045 @code{abort-job}, which will discard the failed print job;
14046 @code{retry-job}, which will retry the job at a later time;
14047 @code{retry-this-job}, which retries the failed job immediately; and
14048 @code{stop-printer}, which stops the printer.
14049
14050 Defaults to @samp{stop-printer}.
14051 @end deftypevr
14052
14053 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
14054 Specifies the maximum cost of filters that are run concurrently, which
14055 can be used to minimize disk, memory, and CPU resource problems. A
14056 limit of 0 disables filter limiting. An average print to a
14057 non-PostScript printer needs a filter limit of about 200. A PostScript
14058 printer needs about half that (100). Setting the limit below these
14059 thresholds will effectively limit the scheduler to printing a single job
14060 at any time.
14061
14062 Defaults to @samp{0}.
14063 @end deftypevr
14064
14065 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
14066 Specifies the scheduling priority of filters that are run to print a
14067 job. The nice value ranges from 0, the highest priority, to 19, the
14068 lowest priority.
14069
14070 Defaults to @samp{0}.
14071 @end deftypevr
14072
14073 @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
14074 Specifies whether to do reverse lookups on connecting clients. The
14075 @code{double} setting causes @code{cupsd} to verify that the hostname
14076 resolved from the address matches one of the addresses returned for that
14077 hostname. Double lookups also prevent clients with unregistered
14078 addresses from connecting to your server. Only set this option to
14079 @code{#t} or @code{double} if absolutely required.
14080
14081 Defaults to @samp{#f}.
14082 @end deftypevr
14083
14084 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
14085 Specifies the number of seconds to wait before killing the filters and
14086 backend associated with a canceled or held job.
14087
14088 Defaults to @samp{30}.
14089 @end deftypevr
14090
14091 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
14092 Specifies the interval between retries of jobs in seconds. This is
14093 typically used for fax queues but can also be used with normal print
14094 queues whose error policy is @code{retry-job} or
14095 @code{retry-current-job}.
14096
14097 Defaults to @samp{30}.
14098 @end deftypevr
14099
14100 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
14101 Specifies the number of retries that are done for jobs. This is
14102 typically used for fax queues but can also be used with normal print
14103 queues whose error policy is @code{retry-job} or
14104 @code{retry-current-job}.
14105
14106 Defaults to @samp{5}.
14107 @end deftypevr
14108
14109 @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
14110 Specifies whether to support HTTP keep-alive connections.
14111
14112 Defaults to @samp{#t}.
14113 @end deftypevr
14114
14115 @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
14116 Specifies how long an idle client connection remains open, in seconds.
14117
14118 Defaults to @samp{30}.
14119 @end deftypevr
14120
14121 @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
14122 Specifies the maximum size of print files, IPP requests, and HTML form
14123 data. A limit of 0 disables the limit check.
14124
14125 Defaults to @samp{0}.
14126 @end deftypevr
14127
14128 @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
14129 Listens on the specified interfaces for connections. Valid values are
14130 of the form @var{address}:@var{port}, where @var{address} is either an
14131 IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
14132 indicate all addresses. Values can also be file names of local UNIX
14133 domain sockets. The Listen directive is similar to the Port directive
14134 but allows you to restrict access to specific interfaces or networks.
14135 @end deftypevr
14136
14137 @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
14138 Specifies the number of pending connections that will be allowed. This
14139 normally only affects very busy servers that have reached the MaxClients
14140 limit, but can also be triggered by large numbers of simultaneous
14141 connections. When the limit is reached, the operating system will
14142 refuse additional connections until the scheduler can accept the pending
14143 ones.
14144
14145 Defaults to @samp{128}.
14146 @end deftypevr
14147
14148 @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
14149 Specifies a set of additional access controls.
14150
14151 Available @code{location-access-controls} fields are:
14152
14153 @deftypevr {@code{location-access-controls} parameter} file-name path
14154 Specifies the URI path to which the access control applies.
14155 @end deftypevr
14156
14157 @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
14158 Access controls for all access to this path, in the same format as the
14159 @code{access-controls} of @code{operation-access-control}.
14160
14161 Defaults to @samp{()}.
14162 @end deftypevr
14163
14164 @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
14165 Access controls for method-specific access to this path.
14166
14167 Defaults to @samp{()}.
14168
14169 Available @code{method-access-controls} fields are:
14170
14171 @deftypevr {@code{method-access-controls} parameter} boolean reverse?
14172 If @code{#t}, apply access controls to all methods except the listed
14173 methods. Otherwise apply to only the listed methods.
14174
14175 Defaults to @samp{#f}.
14176 @end deftypevr
14177
14178 @deftypevr {@code{method-access-controls} parameter} method-list methods
14179 Methods to which this access control applies.
14180
14181 Defaults to @samp{()}.
14182 @end deftypevr
14183
14184 @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
14185 Access control directives, as a list of strings. Each string should be
14186 one directive, such as "Order allow,deny".
14187
14188 Defaults to @samp{()}.
14189 @end deftypevr
14190 @end deftypevr
14191 @end deftypevr
14192
14193 @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
14194 Specifies the number of debugging messages that are retained for logging
14195 if an error occurs in a print job. Debug messages are logged regardless
14196 of the LogLevel setting.
14197
14198 Defaults to @samp{100}.
14199 @end deftypevr
14200
14201 @deftypevr {@code{cups-configuration} parameter} log-level log-level
14202 Specifies the level of logging for the ErrorLog file. The value
14203 @code{none} stops all logging while @code{debug2} logs everything.
14204
14205 Defaults to @samp{info}.
14206 @end deftypevr
14207
14208 @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
14209 Specifies the format of the date and time in the log files. The value
14210 @code{standard} logs whole seconds while @code{usecs} logs microseconds.
14211
14212 Defaults to @samp{standard}.
14213 @end deftypevr
14214
14215 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
14216 Specifies the maximum number of simultaneous clients that are allowed by
14217 the scheduler.
14218
14219 Defaults to @samp{100}.
14220 @end deftypevr
14221
14222 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
14223 Specifies the maximum number of simultaneous clients that are allowed
14224 from a single address.
14225
14226 Defaults to @samp{100}.
14227 @end deftypevr
14228
14229 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
14230 Specifies the maximum number of copies that a user can print of each
14231 job.
14232
14233 Defaults to @samp{9999}.
14234 @end deftypevr
14235
14236 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
14237 Specifies the maximum time a job may remain in the @code{indefinite}
14238 hold state before it is canceled. A value of 0 disables cancellation of
14239 held jobs.
14240
14241 Defaults to @samp{0}.
14242 @end deftypevr
14243
14244 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
14245 Specifies the maximum number of simultaneous jobs that are allowed. Set
14246 to 0 to allow an unlimited number of jobs.
14247
14248 Defaults to @samp{500}.
14249 @end deftypevr
14250
14251 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
14252 Specifies the maximum number of simultaneous jobs that are allowed per
14253 printer. A value of 0 allows up to MaxJobs jobs per printer.
14254
14255 Defaults to @samp{0}.
14256 @end deftypevr
14257
14258 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
14259 Specifies the maximum number of simultaneous jobs that are allowed per
14260 user. A value of 0 allows up to MaxJobs jobs per user.
14261
14262 Defaults to @samp{0}.
14263 @end deftypevr
14264
14265 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
14266 Specifies the maximum time a job may take to print before it is
14267 canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
14268
14269 Defaults to @samp{10800}.
14270 @end deftypevr
14271
14272 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
14273 Specifies the maximum size of the log files before they are rotated, in
14274 bytes. The value 0 disables log rotation.
14275
14276 Defaults to @samp{1048576}.
14277 @end deftypevr
14278
14279 @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
14280 Specifies the maximum amount of time to allow between files in a
14281 multiple file print job, in seconds.
14282
14283 Defaults to @samp{300}.
14284 @end deftypevr
14285
14286 @deftypevr {@code{cups-configuration} parameter} string page-log-format
14287 Specifies the format of PageLog lines. Sequences beginning with percent
14288 (@samp{%}) characters are replaced with the corresponding information,
14289 while all other characters are copied literally. The following percent
14290 sequences are recognized:
14291
14292 @table @samp
14293 @item %%
14294 insert a single percent character
14295
14296 @item %@{name@}
14297 insert the value of the specified IPP attribute
14298
14299 @item %C
14300 insert the number of copies for the current page
14301
14302 @item %P
14303 insert the current page number
14304
14305 @item %T
14306 insert the current date and time in common log format
14307
14308 @item %j
14309 insert the job ID
14310
14311 @item %p
14312 insert the printer name
14313
14314 @item %u
14315 insert the username
14316 @end table
14317
14318 A value of the empty string disables page logging. The string @code{%p
14319 %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
14320 %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
14321 standard items.
14322
14323 Defaults to @samp{""}.
14324 @end deftypevr
14325
14326 @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
14327 Passes the specified environment variable(s) to child processes; a list
14328 of strings.
14329
14330 Defaults to @samp{()}.
14331 @end deftypevr
14332
14333 @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
14334 Specifies named access control policies.
14335
14336 Available @code{policy-configuration} fields are:
14337
14338 @deftypevr {@code{policy-configuration} parameter} string name
14339 Name of the policy.
14340 @end deftypevr
14341
14342 @deftypevr {@code{policy-configuration} parameter} string job-private-access
14343 Specifies an access list for a job's private values. @code{@@ACL} maps
14344 to the printer's requesting-user-name-allowed or
14345 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
14346 owner. @code{@@SYSTEM} maps to the groups listed for the
14347 @code{system-group} field of the @code{files-config} configuration,
14348 which is reified into the @code{cups-files.conf(5)} file. Other
14349 possible elements of the access list include specific user names, and
14350 @code{@@@var{group}} to indicate members of a specific group. The
14351 access list may also be simply @code{all} or @code{default}.
14352
14353 Defaults to @samp{"@@OWNER @@SYSTEM"}.
14354 @end deftypevr
14355
14356 @deftypevr {@code{policy-configuration} parameter} string job-private-values
14357 Specifies the list of job values to make private, or @code{all},
14358 @code{default}, or @code{none}.
14359
14360 Defaults to @samp{"job-name job-originating-host-name
14361 job-originating-user-name phone"}.
14362 @end deftypevr
14363
14364 @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
14365 Specifies an access list for a subscription's private values.
14366 @code{@@ACL} maps to the printer's requesting-user-name-allowed or
14367 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
14368 owner. @code{@@SYSTEM} maps to the groups listed for the
14369 @code{system-group} field of the @code{files-config} configuration,
14370 which is reified into the @code{cups-files.conf(5)} file. Other
14371 possible elements of the access list include specific user names, and
14372 @code{@@@var{group}} to indicate members of a specific group. The
14373 access list may also be simply @code{all} or @code{default}.
14374
14375 Defaults to @samp{"@@OWNER @@SYSTEM"}.
14376 @end deftypevr
14377
14378 @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
14379 Specifies the list of job values to make private, or @code{all},
14380 @code{default}, or @code{none}.
14381
14382 Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
14383 notify-subscriber-user-name notify-user-data"}.
14384 @end deftypevr
14385
14386 @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
14387 Access control by IPP operation.
14388
14389 Defaults to @samp{()}.
14390 @end deftypevr
14391 @end deftypevr
14392
14393 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
14394 Specifies whether job files (documents) are preserved after a job is
14395 printed. If a numeric value is specified, job files are preserved for
14396 the indicated number of seconds after printing. Otherwise a boolean
14397 value applies indefinitely.
14398
14399 Defaults to @samp{86400}.
14400 @end deftypevr
14401
14402 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
14403 Specifies whether the job history is preserved after a job is printed.
14404 If a numeric value is specified, the job history is preserved for the
14405 indicated number of seconds after printing. If @code{#t}, the job
14406 history is preserved until the MaxJobs limit is reached.
14407
14408 Defaults to @samp{#t}.
14409 @end deftypevr
14410
14411 @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
14412 Specifies the amount of time to wait for job completion before
14413 restarting the scheduler.
14414
14415 Defaults to @samp{30}.
14416 @end deftypevr
14417
14418 @deftypevr {@code{cups-configuration} parameter} string rip-cache
14419 Specifies the maximum amount of memory to use when converting documents
14420 into bitmaps for a printer.
14421
14422 Defaults to @samp{"128m"}.
14423 @end deftypevr
14424
14425 @deftypevr {@code{cups-configuration} parameter} string server-admin
14426 Specifies the email address of the server administrator.
14427
14428 Defaults to @samp{"root@@localhost.localdomain"}.
14429 @end deftypevr
14430
14431 @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
14432 The ServerAlias directive is used for HTTP Host header validation when
14433 clients connect to the scheduler from external interfaces. Using the
14434 special name @code{*} can expose your system to known browser-based DNS
14435 rebinding attacks, even when accessing sites through a firewall. If the
14436 auto-discovery of alternate names does not work, we recommend listing
14437 each alternate name with a ServerAlias directive instead of using
14438 @code{*}.
14439
14440 Defaults to @samp{*}.
14441 @end deftypevr
14442
14443 @deftypevr {@code{cups-configuration} parameter} string server-name
14444 Specifies the fully-qualified host name of the server.
14445
14446 Defaults to @samp{"localhost"}.
14447 @end deftypevr
14448
14449 @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
14450 Specifies what information is included in the Server header of HTTP
14451 responses. @code{None} disables the Server header. @code{ProductOnly}
14452 reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
14453 reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
14454 @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
14455 the output of the @code{uname} command. @code{Full} reports @code{CUPS
14456 2.0.0 (@var{uname}) IPP/2.0}.
14457
14458 Defaults to @samp{Minimal}.
14459 @end deftypevr
14460
14461 @deftypevr {@code{cups-configuration} parameter} string set-env
14462 Set the specified environment variable to be passed to child processes.
14463
14464 Defaults to @samp{"variable value"}.
14465 @end deftypevr
14466
14467 @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
14468 Listens on the specified interfaces for encrypted connections. Valid
14469 values are of the form @var{address}:@var{port}, where @var{address} is
14470 either an IPv6 address enclosed in brackets, an IPv4 address, or
14471 @code{*} to indicate all addresses.
14472
14473 Defaults to @samp{()}.
14474 @end deftypevr
14475
14476 @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
14477 Sets encryption options. By default, CUPS only supports encryption
14478 using TLS v1.0 or higher using known secure cipher suites. The
14479 @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
14480 required for some older clients that do not implement newer ones. The
14481 @code{AllowSSL3} option enables SSL v3.0, which is required for some
14482 older clients that do not support TLS v1.0.
14483
14484 Defaults to @samp{()}.
14485 @end deftypevr
14486
14487 @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
14488 Specifies whether the scheduler requires clients to strictly adhere to
14489 the IPP specifications.
14490
14491 Defaults to @samp{#f}.
14492 @end deftypevr
14493
14494 @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
14495 Specifies the HTTP request timeout, in seconds.
14496
14497 Defaults to @samp{300}.
14498
14499 @end deftypevr
14500
14501 @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
14502 Specifies whether the web interface is enabled.
14503
14504 Defaults to @samp{#f}.
14505 @end deftypevr
14506
14507 At this point you're probably thinking ``oh dear, Guix manual, I like
14508 you but you can stop already with the configuration options''. Indeed.
14509 However, one more point: it could be that you have an existing
14510 @code{cupsd.conf} that you want to use. In that case, you can pass an
14511 @code{opaque-cups-configuration} as the configuration of a
14512 @code{cups-service-type}.
14513
14514 Available @code{opaque-cups-configuration} fields are:
14515
14516 @deftypevr {@code{opaque-cups-configuration} parameter} package cups
14517 The CUPS package.
14518 @end deftypevr
14519
14520 @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
14521 The contents of the @code{cupsd.conf}, as a string.
14522 @end deftypevr
14523
14524 @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
14525 The contents of the @code{cups-files.conf} file, as a string.
14526 @end deftypevr
14527
14528 For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
14529 strings of the same name, you could instantiate a CUPS service like
14530 this:
14531
14532 @example
14533 (service cups-service-type
14534 (opaque-cups-configuration
14535 (cupsd.conf cupsd.conf)
14536 (cups-files.conf cups-files.conf)))
14537 @end example
14538
14539
14540 @node Desktop Services
14541 @subsection Desktop Services
14542
14543 The @code{(gnu services desktop)} module provides services that are
14544 usually useful in the context of a ``desktop'' setup---that is, on a
14545 machine running a graphical display server, possibly with graphical user
14546 interfaces, etc. It also defines services that provide specific desktop
14547 environments like GNOME, Xfce or MATE.
14548
14549 To simplify things, the module defines a variable containing the set of
14550 services that users typically expect on a machine with a graphical
14551 environment and networking:
14552
14553 @defvr {Scheme Variable} %desktop-services
14554 This is a list of services that builds upon @var{%base-services} and
14555 adds or adjusts services for a typical ``desktop'' setup.
14556
14557 In particular, it adds a graphical login manager (@pxref{X Window,
14558 @code{gdm-service-type}}), screen lockers, a network management tool
14559 (@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
14560 management services, the @code{elogind} login and seat manager, the
14561 Polkit privilege service, the GeoClue location service, the
14562 AccountsService daemon that allows authorized users change system
14563 passwords, an NTP client (@pxref{Networking Services}), the Avahi
14564 daemon, and has the name service switch service configured to be able to
14565 use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
14566 @end defvr
14567
14568 The @var{%desktop-services} variable can be used as the @code{services}
14569 field of an @code{operating-system} declaration (@pxref{operating-system
14570 Reference, @code{services}}).
14571
14572 Additionally, the @code{gnome-desktop-service-type},
14573 @code{xfce-desktop-service}, @code{mate-desktop-service-type} and
14574 @code{enlightenment-desktop-service-type} procedures can add GNOME, Xfce, MATE
14575 and/or Enlightenment to a system. To ``add GNOME'' means that system-level
14576 services like the backlight adjustment helpers and the power management
14577 utilities are added to the system, extending @code{polkit} and @code{dbus}
14578 appropriately, allowing GNOME to operate with elevated privileges on a
14579 limited number of special-purpose system interfaces. Additionally,
14580 adding a service made by @code{gnome-desktop-service-type} adds the GNOME
14581 metapackage to the system profile. Likewise, adding the Xfce service
14582 not only adds the @code{xfce} metapackage to the system profile, but it
14583 also gives the Thunar file manager the ability to open a ``root-mode''
14584 file management window, if the user authenticates using the
14585 administrator's password via the standard polkit graphical interface.
14586 To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
14587 appropriately, allowing MATE to operate with elevated privileges on a
14588 limited number of special-purpose system interfaces. Additionally,
14589 adding a service of type @code{mate-desktop-service-type} adds the MATE
14590 metapackage to the system profile. ``Adding Enlightenment'' means that
14591 @code{dbus} is extended appropriately, and several of Enlightenment's binaries
14592 are set as setuid, allowing Enlightenment's screen locker and other
14593 functionality to work as expetected.
14594
14595 The desktop environments in Guix use the Xorg display server by
14596 default. If you'd like to use the newer display server protocol
14597 called Wayland, you need to use the @code{sddm-service} instead of
14598 GDM as the graphical login manager. You should then
14599 select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
14600 also try starting GNOME on Wayland manually from a TTY with the
14601 command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
14602 gnome-session``. Currently only GNOME has support for Wayland.
14603
14604 @defvr {Scheme Variable} gnome-desktop-service-type
14605 This is the type of the service that adds the @uref{https://www.gnome.org,
14606 GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
14607 object (see below.)
14608
14609 This service adds the @code{gnome} package to the system profile, and extends
14610 polkit with the actions from @code{gnome-settings-daemon}.
14611 @end defvr
14612
14613 @deftp {Data Type} gnome-desktop-configuration
14614 Configuration record for the GNOME desktop environment.
14615
14616 @table @asis
14617 @item @code{gnome} (default @code{gnome})
14618 The GNOME package to use.
14619 @end table
14620 @end deftp
14621
14622 @defvr {Scheme Variable} xfce-desktop-service-type
14623 This is the type of a service to run the @uref{Xfce, https://xfce.org/}
14624 desktop environment. Its value is an @code{xfce-desktop-configuration} object
14625 (see below.)
14626
14627 This service that adds the @code{xfce} package to the system profile, and
14628 extends polkit with the ability for @code{thunar} to manipulate the file
14629 system as root from within a user session, after the user has authenticated
14630 with the administrator's password.
14631 @end defvr
14632
14633 @deftp {Data Type} xfce-desktop-configuration
14634 Configuration record for the Xfce desktop environment.
14635
14636 @table @asis
14637 @item @code{xfce} (default @code{xfce})
14638 The Xfce package to use.
14639 @end table
14640 @end deftp
14641
14642 @deffn {Scheme Variable} mate-desktop-service-type
14643 This is the type of the service that runs the @uref{https://mate-desktop.org/,
14644 MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
14645 object (see below.)
14646
14647 This service adds the @code{mate} package to the system
14648 profile, and extends polkit with the actions from
14649 @code{mate-settings-daemon}.
14650 @end deffn
14651
14652 @deftp {Data Type} mate-desktop-configuration
14653 Configuration record for the MATE desktop environment.
14654
14655 @table @asis
14656 @item @code{mate} (default @code{mate})
14657 The MATE package to use.
14658 @end table
14659 @end deftp
14660
14661 @deffn {Scheme Variable} enlightenment-desktop-service-type
14662 Return a service that adds the @code{enlightenment} package to the system
14663 profile, and extends dbus with actions from @code{efl}.
14664 @end deffn
14665
14666 @deftp {Data Type} enlightenment-desktop-service-configuration
14667 @table @asis
14668 @item @code{enlightenment} (default @code{enlightenment})
14669 The enlightenment package to use.
14670 @end table
14671 @end deftp
14672
14673 Because the GNOME, Xfce and MATE desktop services pull in so many packages,
14674 the default @code{%desktop-services} variable doesn't include any of
14675 them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
14676 @code{%desktop-services} in the @code{services} field of your
14677 @code{operating-system}:
14678
14679 @example
14680 (use-modules (gnu))
14681 (use-service-modules desktop)
14682 (operating-system
14683 ...
14684 ;; cons* adds items to the list given as its last argument.
14685 (services (cons* (service gnome-desktop-service-type)
14686 (service xfce-desktop-service)
14687 %desktop-services))
14688 ...)
14689 @end example
14690
14691 These desktop environments will then be available as options in the
14692 graphical login window.
14693
14694 The actual service definitions included in @code{%desktop-services} and
14695 provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
14696 are described below.
14697
14698 @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
14699 Return a service that runs the ``system bus'', using @var{dbus}, with
14700 support for @var{services}.
14701
14702 @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
14703 facility. Its system bus is used to allow system services to communicate
14704 and to be notified of system-wide events.
14705
14706 @var{services} must be a list of packages that provide an
14707 @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
14708 and policy files. For example, to allow avahi-daemon to use the system bus,
14709 @var{services} must be equal to @code{(list avahi)}.
14710 @end deffn
14711
14712 @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
14713 Return a service that runs the @code{elogind} login and
14714 seat management daemon. @uref{https://github.com/elogind/elogind,
14715 Elogind} exposes a D-Bus interface that can be used to know which users
14716 are logged in, know what kind of sessions they have open, suspend the
14717 system, inhibit system suspend, reboot the system, and other tasks.
14718
14719 Elogind handles most system-level power events for a computer, for
14720 example suspending the system when a lid is closed, or shutting it down
14721 when the power button is pressed.
14722
14723 The @var{config} keyword argument specifies the configuration for
14724 elogind, and should be the result of an @code{(elogind-configuration
14725 (@var{parameter} @var{value})...)} invocation. Available parameters and
14726 their default values are:
14727
14728 @table @code
14729 @item kill-user-processes?
14730 @code{#f}
14731 @item kill-only-users
14732 @code{()}
14733 @item kill-exclude-users
14734 @code{("root")}
14735 @item inhibit-delay-max-seconds
14736 @code{5}
14737 @item handle-power-key
14738 @code{poweroff}
14739 @item handle-suspend-key
14740 @code{suspend}
14741 @item handle-hibernate-key
14742 @code{hibernate}
14743 @item handle-lid-switch
14744 @code{suspend}
14745 @item handle-lid-switch-docked
14746 @code{ignore}
14747 @item power-key-ignore-inhibited?
14748 @code{#f}
14749 @item suspend-key-ignore-inhibited?
14750 @code{#f}
14751 @item hibernate-key-ignore-inhibited?
14752 @code{#f}
14753 @item lid-switch-ignore-inhibited?
14754 @code{#t}
14755 @item holdoff-timeout-seconds
14756 @code{30}
14757 @item idle-action
14758 @code{ignore}
14759 @item idle-action-seconds
14760 @code{(* 30 60)}
14761 @item runtime-directory-size-percent
14762 @code{10}
14763 @item runtime-directory-size
14764 @code{#f}
14765 @item remove-ipc?
14766 @code{#t}
14767 @item suspend-state
14768 @code{("mem" "standby" "freeze")}
14769 @item suspend-mode
14770 @code{()}
14771 @item hibernate-state
14772 @code{("disk")}
14773 @item hibernate-mode
14774 @code{("platform" "shutdown")}
14775 @item hybrid-sleep-state
14776 @code{("disk")}
14777 @item hybrid-sleep-mode
14778 @code{("suspend" "platform" "shutdown")}
14779 @end table
14780 @end deffn
14781
14782 @deffn {Scheme Procedure} accountsservice-service @
14783 [#:accountsservice @var{accountsservice}]
14784 Return a service that runs AccountsService, a system service that can
14785 list available accounts, change their passwords, and so on.
14786 AccountsService integrates with PolicyKit to enable unprivileged users
14787 to acquire the capability to modify their system configuration.
14788 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
14789 accountsservice web site} for more information.
14790
14791 The @var{accountsservice} keyword argument is the @code{accountsservice}
14792 package to expose as a service.
14793 @end deffn
14794
14795 @deffn {Scheme Procedure} polkit-service @
14796 [#:polkit @var{polkit}]
14797 Return a service that runs the
14798 @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
14799 management service}, which allows system administrators to grant access to
14800 privileged operations in a structured way. By querying the Polkit service, a
14801 privileged system component can know when it should grant additional
14802 capabilities to ordinary users. For example, an ordinary user can be granted
14803 the capability to suspend the system if the user is logged in locally.
14804 @end deffn
14805
14806 @defvr {Scheme Variable} upower-service-type
14807 Service that runs @uref{http://upower.freedesktop.org/, @command{upowerd}}, a
14808 system-wide monitor for power consumption and battery levels, with the given
14809 configuration settings.
14810
14811 It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
14812 notably used by GNOME.
14813 @end defvr
14814
14815 @deftp {Data Type} upower-configuration
14816 Data type representation the configuration for UPower.
14817
14818 @table @asis
14819
14820 @item @code{upower} (default: @var{upower})
14821 Package to use for @code{upower}.
14822
14823 @item @code{watts-up-pro?} (default: @code{#f})
14824 Enable the Watts Up Pro device.
14825
14826 @item @code{poll-batteries?} (default: @code{#t})
14827 Enable polling the kernel for battery level changes.
14828
14829 @item @code{ignore-lid?} (default: @code{#f})
14830 Ignore the lid state, this can be useful if it's incorrect on a device.
14831
14832 @item @code{use-percentage-for-policy?} (default: @code{#f})
14833 Whether battery percentage based policy should be used. The default is to use
14834 the time left, change to @code{#t} to use the percentage.
14835
14836 @item @code{percentage-low} (default: @code{10})
14837 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
14838 at which the battery is considered low.
14839
14840 @item @code{percentage-critical} (default: @code{3})
14841 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
14842 at which the battery is considered critical.
14843
14844 @item @code{percentage-action} (default: @code{2})
14845 When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
14846 at which action will be taken.
14847
14848 @item @code{time-low} (default: @code{1200})
14849 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
14850 seconds at which the battery is considered low.
14851
14852 @item @code{time-critical} (default: @code{300})
14853 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
14854 seconds at which the battery is considered critical.
14855
14856 @item @code{time-action} (default: @code{120})
14857 When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
14858 seconds at which action will be taken.
14859
14860 @item @code{critical-power-action} (default: @code{'hybrid-sleep})
14861 The action taken when @code{percentage-action} or @code{time-action} is
14862 reached (depending on the configuration of @code{use-percentage-for-policy?}).
14863
14864 Possible values are:
14865
14866 @itemize @bullet
14867 @item
14868 @code{'power-off}
14869
14870 @item
14871 @code{'hibernate}
14872
14873 @item
14874 @code{'hybrid-sleep}.
14875 @end itemize
14876
14877 @end table
14878 @end deftp
14879
14880 @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
14881 Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
14882 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
14883 notifications and ways to mount/unmount disks. Programs that talk to UDisks
14884 include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
14885 @end deffn
14886
14887 @deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
14888 Return a service that runs @command{colord}, a system service with a D-Bus
14889 interface to manage the color profiles of input and output devices such as
14890 screens and scanners. It is notably used by the GNOME Color Manager graphical
14891 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
14892 site} for more information.
14893 @end deffn
14894
14895 @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
14896 Return a configuration allowing an application to access GeoClue
14897 location data. @var{name} is the Desktop ID of the application, without
14898 the @code{.desktop} part. If @var{allowed?} is true, the application
14899 will have access to location information by default. The boolean
14900 @var{system?} value indicates whether an application is a system component
14901 or not. Finally @var{users} is a list of UIDs of all users for which
14902 this application is allowed location info access. An empty users list
14903 means that all users are allowed.
14904 @end deffn
14905
14906 @defvr {Scheme Variable} %standard-geoclue-applications
14907 The standard list of well-known GeoClue application configurations,
14908 granting authority to the GNOME date-and-time utility to ask for the
14909 current location in order to set the time zone, and allowing the
14910 IceCat and Epiphany web browsers to request location information.
14911 IceCat and Epiphany both query the user before allowing a web page to
14912 know the user's location.
14913 @end defvr
14914
14915 @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
14916 [#:whitelist '()] @
14917 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
14918 [#:submit-data? #f]
14919 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
14920 [#:submission-nick "geoclue"] @
14921 [#:applications %standard-geoclue-applications]
14922 Return a service that runs the GeoClue location service. This service
14923 provides a D-Bus interface to allow applications to request access to a
14924 user's physical location, and optionally to add information to online
14925 location databases. See
14926 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
14927 web site} for more information.
14928 @end deffn
14929
14930 @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
14931 [@w{#:auto-enable? #f}]
14932 Return a service that runs the @command{bluetoothd} daemon, which
14933 manages all the Bluetooth devices and provides a number of D-Bus
14934 interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
14935 powered automatically at boot, which can be useful when using a
14936 bluetooth keyboard or mouse.
14937
14938 Users need to be in the @code{lp} group to access the D-Bus service.
14939 @end deffn
14940
14941 @node Sound Services
14942 @subsection Sound Services
14943
14944 @cindex sound support
14945 @cindex ALSA
14946 @cindex PulseAudio, sound support
14947
14948 The @code{(gnu services sound)} module provides a service to configure the
14949 Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
14950 preferred ALSA output driver.
14951
14952 @deffn {Scheme Variable} alsa-service-type
14953 This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
14954 Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
14955 configuration file. The value for this type is a @command{alsa-configuration}
14956 record as in this example:
14957
14958 @example
14959 (service alsa-service-type)
14960 @end example
14961
14962 See below for details about @code{alsa-configuration}.
14963 @end deffn
14964
14965 @deftp {Data Type} alsa-configuration
14966 Data type representing the configuration for @code{alsa-service}.
14967
14968 @table @asis
14969 @item @code{alsa-plugins} (default: @var{alsa-plugins})
14970 @code{alsa-plugins} package to use.
14971
14972 @item @code{pulseaudio?} (default: @var{#t})
14973 Whether ALSA applications should transparently be made to use the
14974 @uref{http://www.pulseaudio.org/, PulseAudio} sound server.
14975
14976 Using PulseAudio allows you to run several sound-producing applications
14977 at the same time and to individual control them @i{via}
14978 @command{pavucontrol}, among other things.
14979
14980 @item @code{extra-options} (default: @var{""})
14981 String to append to the @file{/etc/asound.conf} file.
14982
14983 @end table
14984 @end deftp
14985
14986 Individual users who want to override the system configuration of ALSA can do
14987 it with the @file{~/.asoundrc} file:
14988
14989 @example
14990 # In guix, we have to specify the absolute path for plugins.
14991 pcm_type.jack @{
14992 lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
14993 @}
14994
14995 # Routing ALSA to jack:
14996 # <http://jackaudio.org/faq/routing_alsa.html>.
14997 pcm.rawjack @{
14998 type jack
14999 playback_ports @{
15000 0 system:playback_1
15001 1 system:playback_2
15002 @}
15003
15004 capture_ports @{
15005 0 system:capture_1
15006 1 system:capture_2
15007 @}
15008 @}
15009
15010 pcm.!default @{
15011 type plug
15012 slave @{
15013 pcm "rawjack"
15014 @}
15015 @}
15016 @end example
15017
15018 See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
15019 details.
15020
15021
15022 @node Database Services
15023 @subsection Database Services
15024
15025 @cindex database
15026 @cindex SQL
15027 The @code{(gnu services databases)} module provides the following services.
15028
15029 @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
15030 [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
15031 [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
15032 Return a service that runs @var{postgresql}, the PostgreSQL database
15033 server.
15034
15035 The PostgreSQL daemon loads its runtime configuration from @var{config-file},
15036 creates a database cluster with @var{locale} as the default
15037 locale, stored in @var{data-directory}. It then listens on @var{port}.
15038
15039 @cindex postgresql extension-packages
15040 Additional extensions are loaded from packages listed in
15041 @var{extension-packages}. Extensions are available at runtime. For instance,
15042 to create a geographic database using the @code{postgis} extension, a user can
15043 configure the postgresql-service as in this example:
15044
15045 @cindex postgis
15046 @example
15047 (use-package-modules databases geo)
15048
15049 (operating-system
15050 ...
15051 ;; postgresql is required to run `psql' but postgis is not required for
15052 ;; proper operation.
15053 (packages (cons* postgresql %base-packages))
15054 (services
15055 (cons*
15056 (postgresql-service #:extension-packages (list postgis))
15057 %base-services)))
15058 @end example
15059
15060 Then the extension becomes visible and you can initialise an empty geographic
15061 database in this way:
15062
15063 @example
15064 psql -U postgres
15065 > create database postgistest;
15066 > \connect postgistest;
15067 > create extension postgis;
15068 > create extension postgis_topology;
15069 @end example
15070
15071 There is no need to add this field for contrib extensions such as hstore or
15072 dblink as they are already loadable by postgresql. This field is only
15073 required to add extensions provided by other packages.
15074 @end deffn
15075
15076 @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
15077 Return a service that runs @command{mysqld}, the MySQL or MariaDB
15078 database server.
15079
15080 The optional @var{config} argument specifies the configuration for
15081 @command{mysqld}, which should be a @code{<mysql-configuration>} object.
15082 @end deffn
15083
15084 @deftp {Data Type} mysql-configuration
15085 Data type representing the configuration of @var{mysql-service}.
15086
15087 @table @asis
15088 @item @code{mysql} (default: @var{mariadb})
15089 Package object of the MySQL database server, can be either @var{mariadb}
15090 or @var{mysql}.
15091
15092 For MySQL, a temporary root password will be displayed at activation time.
15093 For MariaDB, the root password is empty.
15094
15095 @item @code{port} (default: @code{3306})
15096 TCP port on which the database server listens for incoming connections.
15097 @end table
15098 @end deftp
15099
15100 @defvr {Scheme Variable} memcached-service-type
15101 This is the service type for the @uref{https://memcached.org/,
15102 Memcached} service, which provides a distributed in memory cache. The
15103 value for the service type is a @code{memcached-configuration} object.
15104 @end defvr
15105
15106 @example
15107 (service memcached-service-type)
15108 @end example
15109
15110 @deftp {Data Type} memcached-configuration
15111 Data type representing the configuration of memcached.
15112
15113 @table @asis
15114 @item @code{memcached} (default: @code{memcached})
15115 The Memcached package to use.
15116
15117 @item @code{interfaces} (default: @code{'("0.0.0.0")})
15118 Network interfaces on which to listen.
15119
15120 @item @code{tcp-port} (default: @code{11211})
15121 Port on which to accept connections on,
15122
15123 @item @code{udp-port} (default: @code{11211})
15124 Port on which to accept UDP connections on, a value of 0 will disable
15125 listening on a UDP socket.
15126
15127 @item @code{additional-options} (default: @code{'()})
15128 Additional command line options to pass to @code{memcached}.
15129 @end table
15130 @end deftp
15131
15132 @defvr {Scheme Variable} mongodb-service-type
15133 This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
15134 The value for the service type is a @code{mongodb-configuration} object.
15135 @end defvr
15136
15137 @example
15138 (service mongodb-service-type)
15139 @end example
15140
15141 @deftp {Data Type} mongodb-configuration
15142 Data type representing the configuration of mongodb.
15143
15144 @table @asis
15145 @item @code{mongodb} (default: @code{mongodb})
15146 The MongoDB package to use.
15147
15148 @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
15149 The configuration file for MongoDB.
15150
15151 @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
15152 This value is used to create the directory, so that it exists and is
15153 owned by the mongodb user. It should match the data-directory which
15154 MongoDB is configured to use through the configuration file.
15155 @end table
15156 @end deftp
15157
15158 @defvr {Scheme Variable} redis-service-type
15159 This is the service type for the @uref{https://redis.io/, Redis}
15160 key/value store, whose value is a @code{redis-configuration} object.
15161 @end defvr
15162
15163 @deftp {Data Type} redis-configuration
15164 Data type representing the configuration of redis.
15165
15166 @table @asis
15167 @item @code{redis} (default: @code{redis})
15168 The Redis package to use.
15169
15170 @item @code{bind} (default: @code{"127.0.0.1"})
15171 Network interface on which to listen.
15172
15173 @item @code{port} (default: @code{6379})
15174 Port on which to accept connections on, a value of 0 will disable
15175 listening on a TCP socket.
15176
15177 @item @code{working-directory} (default: @code{"/var/lib/redis"})
15178 Directory in which to store the database and related files.
15179 @end table
15180 @end deftp
15181
15182 @node Mail Services
15183 @subsection Mail Services
15184
15185 @cindex mail
15186 @cindex email
15187 The @code{(gnu services mail)} module provides Guix service definitions
15188 for email services: IMAP, POP3, and LMTP servers, as well as mail
15189 transport agents (MTAs). Lots of acronyms! These services are detailed
15190 in the subsections below.
15191
15192 @subsubheading Dovecot Service
15193
15194 @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
15195 Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
15196 @end deffn
15197
15198 By default, Dovecot does not need much configuration; the default
15199 configuration object created by @code{(dovecot-configuration)} will
15200 suffice if your mail is delivered to @code{~/Maildir}. A self-signed
15201 certificate will be generated for TLS-protected connections, though
15202 Dovecot will also listen on cleartext ports by default. There are a
15203 number of options, though, which mail administrators might need to change,
15204 and as is the case with other services, Guix allows the system
15205 administrator to specify these parameters via a uniform Scheme interface.
15206
15207 For example, to specify that mail is located at @code{maildir~/.mail},
15208 one would instantiate the Dovecot service like this:
15209
15210 @example
15211 (dovecot-service #:config
15212 (dovecot-configuration
15213 (mail-location "maildir:~/.mail")))
15214 @end example
15215
15216 The available configuration parameters follow. Each parameter
15217 definition is preceded by its type; for example, @samp{string-list foo}
15218 indicates that the @code{foo} parameter should be specified as a list of
15219 strings. There is also a way to specify the configuration as a string,
15220 if you have an old @code{dovecot.conf} file that you want to port over
15221 from some other system; see the end for more details.
15222
15223 @c The following documentation was initially generated by
15224 @c (generate-documentation) in (gnu services mail). Manually maintained
15225 @c documentation is better, so we shouldn't hesitate to edit below as
15226 @c needed. However if the change you want to make to this documentation
15227 @c can be done in an automated way, it's probably easier to change
15228 @c (generate-documentation) than to make it below and have to deal with
15229 @c the churn as dovecot updates.
15230
15231 Available @code{dovecot-configuration} fields are:
15232
15233 @deftypevr {@code{dovecot-configuration} parameter} package dovecot
15234 The dovecot package.
15235 @end deftypevr
15236
15237 @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
15238 A list of IPs or hosts where to listen for connections. @samp{*}
15239 listens on all IPv4 interfaces, @samp{::} listens on all IPv6
15240 interfaces. If you want to specify non-default ports or anything more
15241 complex, customize the address and port fields of the
15242 @samp{inet-listener} of the specific services you are interested in.
15243 @end deftypevr
15244
15245 @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
15246 List of protocols we want to serve. Available protocols include
15247 @samp{imap}, @samp{pop3}, and @samp{lmtp}.
15248
15249 Available @code{protocol-configuration} fields are:
15250
15251 @deftypevr {@code{protocol-configuration} parameter} string name
15252 The name of the protocol.
15253 @end deftypevr
15254
15255 @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
15256 UNIX socket path to the master authentication server to find users.
15257 This is used by imap (for shared users) and lda.
15258 It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
15259 @end deftypevr
15260
15261 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
15262 Space separated list of plugins to load.
15263 @end deftypevr
15264
15265 @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
15266 Maximum number of IMAP connections allowed for a user from each IP
15267 address. NOTE: The username is compared case-sensitively.
15268 Defaults to @samp{10}.
15269 @end deftypevr
15270
15271 @end deftypevr
15272
15273 @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
15274 List of services to enable. Available services include @samp{imap},
15275 @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
15276 @samp{lmtp}.
15277
15278 Available @code{service-configuration} fields are:
15279
15280 @deftypevr {@code{service-configuration} parameter} string kind
15281 The service kind. Valid values include @code{director},
15282 @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
15283 @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
15284 @code{tcpwrap}, @code{quota-warning}, or anything else.
15285 @end deftypevr
15286
15287 @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
15288 Listeners for the service. A listener is either a
15289 @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
15290 an @code{inet-listener-configuration}.
15291 Defaults to @samp{()}.
15292
15293 Available @code{unix-listener-configuration} fields are:
15294
15295 @deftypevr {@code{unix-listener-configuration} parameter} string path
15296 Path to the file, relative to @code{base-dir} field. This is also used as
15297 the section name.
15298 @end deftypevr
15299
15300 @deftypevr {@code{unix-listener-configuration} parameter} string mode
15301 The access mode for the socket.
15302 Defaults to @samp{"0600"}.
15303 @end deftypevr
15304
15305 @deftypevr {@code{unix-listener-configuration} parameter} string user
15306 The user to own the socket.
15307 Defaults to @samp{""}.
15308 @end deftypevr
15309
15310 @deftypevr {@code{unix-listener-configuration} parameter} string group
15311 The group to own the socket.
15312 Defaults to @samp{""}.
15313 @end deftypevr
15314
15315
15316 Available @code{fifo-listener-configuration} fields are:
15317
15318 @deftypevr {@code{fifo-listener-configuration} parameter} string path
15319 Path to the file, relative to @code{base-dir} field. This is also used as
15320 the section name.
15321 @end deftypevr
15322
15323 @deftypevr {@code{fifo-listener-configuration} parameter} string mode
15324 The access mode for the socket.
15325 Defaults to @samp{"0600"}.
15326 @end deftypevr
15327
15328 @deftypevr {@code{fifo-listener-configuration} parameter} string user
15329 The user to own the socket.
15330 Defaults to @samp{""}.
15331 @end deftypevr
15332
15333 @deftypevr {@code{fifo-listener-configuration} parameter} string group
15334 The group to own the socket.
15335 Defaults to @samp{""}.
15336 @end deftypevr
15337
15338
15339 Available @code{inet-listener-configuration} fields are:
15340
15341 @deftypevr {@code{inet-listener-configuration} parameter} string protocol
15342 The protocol to listen for.
15343 @end deftypevr
15344
15345 @deftypevr {@code{inet-listener-configuration} parameter} string address
15346 The address on which to listen, or empty for all addresses.
15347 Defaults to @samp{""}.
15348 @end deftypevr
15349
15350 @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
15351 The port on which to listen.
15352 @end deftypevr
15353
15354 @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
15355 Whether to use SSL for this service; @samp{yes}, @samp{no}, or
15356 @samp{required}.
15357 Defaults to @samp{#t}.
15358 @end deftypevr
15359
15360 @end deftypevr
15361
15362 @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
15363 Maximum number of simultaneous client connections per process. Once
15364 this number of connections is received, the next incoming connection
15365 will prompt Dovecot to spawn another process. If set to 0,
15366 @code{default-client-limit} is used instead.
15367
15368 Defaults to @samp{0}.
15369
15370 @end deftypevr
15371
15372 @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
15373 Number of connections to handle before starting a new process.
15374 Typically the only useful values are 0 (unlimited) or 1. 1 is more
15375 secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
15376 Defaults to @samp{1}.
15377
15378 @end deftypevr
15379
15380 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
15381 Maximum number of processes that can exist for this service. If set to
15382 0, @code{default-process-limit} is used instead.
15383
15384 Defaults to @samp{0}.
15385
15386 @end deftypevr
15387
15388 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
15389 Number of processes to always keep waiting for more connections.
15390 Defaults to @samp{0}.
15391 @end deftypevr
15392
15393 @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
15394 If you set @samp{service-count 0}, you probably need to grow
15395 this.
15396 Defaults to @samp{256000000}.
15397 @end deftypevr
15398
15399 @end deftypevr
15400
15401 @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
15402 Dict configuration, as created by the @code{dict-configuration}
15403 constructor.
15404
15405 Available @code{dict-configuration} fields are:
15406
15407 @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
15408 A list of key-value pairs that this dict should hold.
15409 Defaults to @samp{()}.
15410 @end deftypevr
15411
15412 @end deftypevr
15413
15414 @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
15415 A list of passdb configurations, each one created by the
15416 @code{passdb-configuration} constructor.
15417
15418 Available @code{passdb-configuration} fields are:
15419
15420 @deftypevr {@code{passdb-configuration} parameter} string driver
15421 The driver that the passdb should use. Valid values include
15422 @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
15423 @samp{static}.
15424 Defaults to @samp{"pam"}.
15425 @end deftypevr
15426
15427 @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
15428 Space separated list of arguments to the passdb driver.
15429 Defaults to @samp{""}.
15430 @end deftypevr
15431
15432 @end deftypevr
15433
15434 @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
15435 List of userdb configurations, each one created by the
15436 @code{userdb-configuration} constructor.
15437
15438 Available @code{userdb-configuration} fields are:
15439
15440 @deftypevr {@code{userdb-configuration} parameter} string driver
15441 The driver that the userdb should use. Valid values include
15442 @samp{passwd} and @samp{static}.
15443 Defaults to @samp{"passwd"}.
15444 @end deftypevr
15445
15446 @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
15447 Space separated list of arguments to the userdb driver.
15448 Defaults to @samp{""}.
15449 @end deftypevr
15450
15451 @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
15452 Override fields from passwd.
15453 Defaults to @samp{()}.
15454 @end deftypevr
15455
15456 @end deftypevr
15457
15458 @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
15459 Plug-in configuration, created by the @code{plugin-configuration}
15460 constructor.
15461 @end deftypevr
15462
15463 @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
15464 List of namespaces. Each item in the list is created by the
15465 @code{namespace-configuration} constructor.
15466
15467 Available @code{namespace-configuration} fields are:
15468
15469 @deftypevr {@code{namespace-configuration} parameter} string name
15470 Name for this namespace.
15471 @end deftypevr
15472
15473 @deftypevr {@code{namespace-configuration} parameter} string type
15474 Namespace type: @samp{private}, @samp{shared} or @samp{public}.
15475 Defaults to @samp{"private"}.
15476 @end deftypevr
15477
15478 @deftypevr {@code{namespace-configuration} parameter} string separator
15479 Hierarchy separator to use. You should use the same separator for
15480 all namespaces or some clients get confused. @samp{/} is usually a good
15481 one. The default however depends on the underlying mail storage
15482 format.
15483 Defaults to @samp{""}.
15484 @end deftypevr
15485
15486 @deftypevr {@code{namespace-configuration} parameter} string prefix
15487 Prefix required to access this namespace. This needs to be
15488 different for all namespaces. For example @samp{Public/}.
15489 Defaults to @samp{""}.
15490 @end deftypevr
15491
15492 @deftypevr {@code{namespace-configuration} parameter} string location
15493 Physical location of the mailbox. This is in the same format as
15494 mail_location, which is also the default for it.
15495 Defaults to @samp{""}.
15496 @end deftypevr
15497
15498 @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
15499 There can be only one INBOX, and this setting defines which
15500 namespace has it.
15501 Defaults to @samp{#f}.
15502 @end deftypevr
15503
15504 @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
15505 If namespace is hidden, it's not advertised to clients via NAMESPACE
15506 extension. You'll most likely also want to set @samp{list? #f}. This is mostly
15507 useful when converting from another server with different namespaces
15508 which you want to deprecate but still keep working. For example you can
15509 create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
15510 and @samp{mail/}.
15511 Defaults to @samp{#f}.
15512 @end deftypevr
15513
15514 @deftypevr {@code{namespace-configuration} parameter} boolean list?
15515 Show the mailboxes under this namespace with the LIST command. This
15516 makes the namespace visible for clients that do not support the NAMESPACE
15517 extension. The special @code{children} value lists child mailboxes, but
15518 hides the namespace prefix.
15519 Defaults to @samp{#t}.
15520 @end deftypevr
15521
15522 @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
15523 Namespace handles its own subscriptions. If set to @code{#f}, the
15524 parent namespace handles them. The empty prefix should always have this
15525 as @code{#t}).
15526 Defaults to @samp{#t}.
15527 @end deftypevr
15528
15529 @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
15530 List of predefined mailboxes in this namespace.
15531 Defaults to @samp{()}.
15532
15533 Available @code{mailbox-configuration} fields are:
15534
15535 @deftypevr {@code{mailbox-configuration} parameter} string name
15536 Name for this mailbox.
15537 @end deftypevr
15538
15539 @deftypevr {@code{mailbox-configuration} parameter} string auto
15540 @samp{create} will automatically create this mailbox.
15541 @samp{subscribe} will both create and subscribe to the mailbox.
15542 Defaults to @samp{"no"}.
15543 @end deftypevr
15544
15545 @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
15546 List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
15547 Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
15548 @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
15549 Defaults to @samp{()}.
15550 @end deftypevr
15551
15552 @end deftypevr
15553
15554 @end deftypevr
15555
15556 @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
15557 Base directory where to store runtime data.
15558 Defaults to @samp{"/var/run/dovecot/"}.
15559 @end deftypevr
15560
15561 @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
15562 Greeting message for clients.
15563 Defaults to @samp{"Dovecot ready."}.
15564 @end deftypevr
15565
15566 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
15567 List of trusted network ranges. Connections from these IPs are
15568 allowed to override their IP addresses and ports (for logging and for
15569 authentication checks). @samp{disable-plaintext-auth} is also ignored
15570 for these networks. Typically you would specify your IMAP proxy servers
15571 here.
15572 Defaults to @samp{()}.
15573 @end deftypevr
15574
15575 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
15576 List of login access check sockets (e.g.@: tcpwrap).
15577 Defaults to @samp{()}.
15578 @end deftypevr
15579
15580 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
15581 Show more verbose process titles (in ps). Currently shows user name
15582 and IP address. Useful for seeing who is actually using the IMAP
15583 processes (e.g.@: shared mailboxes or if the same uid is used for multiple
15584 accounts).
15585 Defaults to @samp{#f}.
15586 @end deftypevr
15587
15588 @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
15589 Should all processes be killed when Dovecot master process shuts down.
15590 Setting this to @code{#f} means that Dovecot can be upgraded without
15591 forcing existing client connections to close (although that could also
15592 be a problem if the upgrade is e.g.@: due to a security fix).
15593 Defaults to @samp{#t}.
15594 @end deftypevr
15595
15596 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
15597 If non-zero, run mail commands via this many connections to doveadm
15598 server, instead of running them directly in the same process.
15599 Defaults to @samp{0}.
15600 @end deftypevr
15601
15602 @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
15603 UNIX socket or host:port used for connecting to doveadm server.
15604 Defaults to @samp{"doveadm-server"}.
15605 @end deftypevr
15606
15607 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
15608 List of environment variables that are preserved on Dovecot startup
15609 and passed down to all of its child processes. You can also give
15610 key=value pairs to always set specific settings.
15611 @end deftypevr
15612
15613 @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
15614 Disable LOGIN command and all other plaintext authentications unless
15615 SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
15616 matches the local IP (i.e.@: you're connecting from the same computer),
15617 the connection is considered secure and plaintext authentication is
15618 allowed. See also ssl=required setting.
15619 Defaults to @samp{#t}.
15620 @end deftypevr
15621
15622 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
15623 Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
15624 Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
15625 for caching to be used.
15626 Defaults to @samp{0}.
15627 @end deftypevr
15628
15629 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
15630 Time to live for cached data. After TTL expires the cached record
15631 is no longer used, *except* if the main database lookup returns internal
15632 failure. We also try to handle password changes automatically: If
15633 user's previous authentication was successful, but this one wasn't, the
15634 cache isn't used. For now this works only with plaintext
15635 authentication.
15636 Defaults to @samp{"1 hour"}.
15637 @end deftypevr
15638
15639 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
15640 TTL for negative hits (user not found, password mismatch).
15641 0 disables caching them completely.
15642 Defaults to @samp{"1 hour"}.
15643 @end deftypevr
15644
15645 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
15646 List of realms for SASL authentication mechanisms that need them.
15647 You can leave it empty if you don't want to support multiple realms.
15648 Many clients simply use the first one listed here, so keep the default
15649 realm first.
15650 Defaults to @samp{()}.
15651 @end deftypevr
15652
15653 @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
15654 Default realm/domain to use if none was specified. This is used for
15655 both SASL realms and appending @@domain to username in plaintext
15656 logins.
15657 Defaults to @samp{""}.
15658 @end deftypevr
15659
15660 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
15661 List of allowed characters in username. If the user-given username
15662 contains a character not listed in here, the login automatically fails.
15663 This is just an extra check to make sure user can't exploit any
15664 potential quote escaping vulnerabilities with SQL/LDAP databases. If
15665 you want to allow all characters, set this value to empty.
15666 Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
15667 @end deftypevr
15668
15669 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
15670 Username character translations before it's looked up from
15671 databases. The value contains series of from -> to characters. For
15672 example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
15673 translated to @samp{@@}.
15674 Defaults to @samp{""}.
15675 @end deftypevr
15676
15677 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
15678 Username formatting before it's looked up from databases. You can
15679 use the standard variables here, e.g.@: %Lu would lowercase the username,
15680 %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
15681 change the @samp{@@} into @samp{-AT-}. This translation is done after
15682 @samp{auth-username-translation} changes.
15683 Defaults to @samp{"%Lu"}.
15684 @end deftypevr
15685
15686 @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
15687 If you want to allow master users to log in by specifying the master
15688 username within the normal username string (i.e.@: not using SASL
15689 mechanism's support for it), you can specify the separator character
15690 here. The format is then <username><separator><master username>.
15691 UW-IMAP uses @samp{*} as the separator, so that could be a good
15692 choice.
15693 Defaults to @samp{""}.
15694 @end deftypevr
15695
15696 @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
15697 Username to use for users logging in with ANONYMOUS SASL
15698 mechanism.
15699 Defaults to @samp{"anonymous"}.
15700 @end deftypevr
15701
15702 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
15703 Maximum number of dovecot-auth worker processes. They're used to
15704 execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
15705 They're automatically created and destroyed as needed.
15706 Defaults to @samp{30}.
15707 @end deftypevr
15708
15709 @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
15710 Host name to use in GSSAPI principal names. The default is to use
15711 the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
15712 allow all keytab entries.
15713 Defaults to @samp{""}.
15714 @end deftypevr
15715
15716 @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
15717 Kerberos keytab to use for the GSSAPI mechanism. Will use the
15718 system default (usually @file{/etc/krb5.keytab}) if not specified. You may
15719 need to change the auth service to run as root to be able to read this
15720 file.
15721 Defaults to @samp{""}.
15722 @end deftypevr
15723
15724 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
15725 Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
15726 and @samp{ntlm-auth} helper.
15727 <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
15728 Defaults to @samp{#f}.
15729 @end deftypevr
15730
15731 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
15732 Path for Samba's @samp{ntlm-auth} helper binary.
15733 Defaults to @samp{"/usr/bin/ntlm_auth"}.
15734 @end deftypevr
15735
15736 @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
15737 Time to delay before replying to failed authentications.
15738 Defaults to @samp{"2 secs"}.
15739 @end deftypevr
15740
15741 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
15742 Require a valid SSL client certificate or the authentication
15743 fails.
15744 Defaults to @samp{#f}.
15745 @end deftypevr
15746
15747 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
15748 Take the username from client's SSL certificate, using
15749 @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
15750 CommonName.
15751 Defaults to @samp{#f}.
15752 @end deftypevr
15753
15754 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
15755 List of wanted authentication mechanisms. Supported mechanisms are:
15756 @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
15757 @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
15758 @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
15759 @samp{disable-plaintext-auth} setting.
15760 @end deftypevr
15761
15762 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
15763 List of IPs or hostnames to all director servers, including ourself.
15764 Ports can be specified as ip:port. The default port is the same as what
15765 director service's @samp{inet-listener} is using.
15766 Defaults to @samp{()}.
15767 @end deftypevr
15768
15769 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
15770 List of IPs or hostnames to all backend mail servers. Ranges are
15771 allowed too, like 10.0.0.10-10.0.0.30.
15772 Defaults to @samp{()}.
15773 @end deftypevr
15774
15775 @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
15776 How long to redirect users to a specific server after it no longer
15777 has any connections.
15778 Defaults to @samp{"15 min"}.
15779 @end deftypevr
15780
15781 @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
15782 How the username is translated before being hashed. Useful values
15783 include %Ln if user can log in with or without @@domain, %Ld if mailboxes
15784 are shared within domain.
15785 Defaults to @samp{"%Lu"}.
15786 @end deftypevr
15787
15788 @deftypevr {@code{dovecot-configuration} parameter} string log-path
15789 Log file to use for error messages. @samp{syslog} logs to syslog,
15790 @samp{/dev/stderr} logs to stderr.
15791 Defaults to @samp{"syslog"}.
15792 @end deftypevr
15793
15794 @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
15795 Log file to use for informational messages. Defaults to
15796 @samp{log-path}.
15797 Defaults to @samp{""}.
15798 @end deftypevr
15799
15800 @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
15801 Log file to use for debug messages. Defaults to
15802 @samp{info-log-path}.
15803 Defaults to @samp{""}.
15804 @end deftypevr
15805
15806 @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
15807 Syslog facility to use if you're logging to syslog. Usually if you
15808 don't want to use @samp{mail}, you'll use local0..local7. Also other
15809 standard facilities are supported.
15810 Defaults to @samp{"mail"}.
15811 @end deftypevr
15812
15813 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
15814 Log unsuccessful authentication attempts and the reasons why they
15815 failed.
15816 Defaults to @samp{#f}.
15817 @end deftypevr
15818
15819 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
15820 In case of password mismatches, log the attempted password. Valid
15821 values are no, plain and sha1. sha1 can be useful for detecting brute
15822 force password attempts vs. user simply trying the same password over
15823 and over again. You can also truncate the value to n chars by appending
15824 ":n" (e.g.@: sha1:6).
15825 Defaults to @samp{#f}.
15826 @end deftypevr
15827
15828 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
15829 Even more verbose logging for debugging purposes. Shows for example
15830 SQL queries.
15831 Defaults to @samp{#f}.
15832 @end deftypevr
15833
15834 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
15835 In case of password mismatches, log the passwords and used scheme so
15836 the problem can be debugged. Enabling this also enables
15837 @samp{auth-debug}.
15838 Defaults to @samp{#f}.
15839 @end deftypevr
15840
15841 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
15842 Enable mail process debugging. This can help you figure out why
15843 Dovecot isn't finding your mails.
15844 Defaults to @samp{#f}.
15845 @end deftypevr
15846
15847 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
15848 Show protocol level SSL errors.
15849 Defaults to @samp{#f}.
15850 @end deftypevr
15851
15852 @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
15853 Prefix for each line written to log file. % codes are in
15854 strftime(3) format.
15855 Defaults to @samp{"\"%b %d %H:%M:%S \""}.
15856 @end deftypevr
15857
15858 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
15859 List of elements we want to log. The elements which have a
15860 non-empty variable value are joined together to form a comma-separated
15861 string.
15862 @end deftypevr
15863
15864 @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
15865 Login log format. %s contains @samp{login-log-format-elements}
15866 string, %$ contains the data we want to log.
15867 Defaults to @samp{"%$: %s"}.
15868 @end deftypevr
15869
15870 @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
15871 Log prefix for mail processes. See doc/wiki/Variables.txt for list
15872 of possible variables you can use.
15873 Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
15874 @end deftypevr
15875
15876 @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
15877 Format to use for logging mail deliveries. You can use variables:
15878 @table @code
15879 @item %$
15880 Delivery status message (e.g.@: @samp{saved to INBOX})
15881 @item %m
15882 Message-ID
15883 @item %s
15884 Subject
15885 @item %f
15886 From address
15887 @item %p
15888 Physical size
15889 @item %w
15890 Virtual size.
15891 @end table
15892 Defaults to @samp{"msgid=%m: %$"}.
15893 @end deftypevr
15894
15895 @deftypevr {@code{dovecot-configuration} parameter} string mail-location
15896 Location for users' mailboxes. The default is empty, which means
15897 that Dovecot tries to find the mailboxes automatically. This won't work
15898 if the user doesn't yet have any mail, so you should explicitly tell
15899 Dovecot the full location.
15900
15901 If you're using mbox, giving a path to the INBOX
15902 file (e.g.@: /var/mail/%u) isn't enough. You'll also need to tell Dovecot
15903 where the other mailboxes are kept. This is called the "root mail
15904 directory", and it must be the first path given in the
15905 @samp{mail-location} setting.
15906
15907 There are a few special variables you can use, eg.:
15908
15909 @table @samp
15910 @item %u
15911 username
15912 @item %n
15913 user part in user@@domain, same as %u if there's no domain
15914 @item %d
15915 domain part in user@@domain, empty if there's no domain
15916 @item %h
15917 home director
15918 @end table
15919
15920 See doc/wiki/Variables.txt for full list. Some examples:
15921 @table @samp
15922 @item maildir:~/Maildir
15923 @item mbox:~/mail:INBOX=/var/mail/%u
15924 @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
15925 @end table
15926 Defaults to @samp{""}.
15927 @end deftypevr
15928
15929 @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
15930 System user and group used to access mails. If you use multiple,
15931 userdb can override these by returning uid or gid fields. You can use
15932 either numbers or names. <doc/wiki/UserIds.txt>.
15933 Defaults to @samp{""}.
15934 @end deftypevr
15935
15936 @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
15937
15938 Defaults to @samp{""}.
15939 @end deftypevr
15940
15941 @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
15942 Group to enable temporarily for privileged operations. Currently
15943 this is used only with INBOX when either its initial creation or
15944 dotlocking fails. Typically this is set to "mail" to give access to
15945 /var/mail.
15946 Defaults to @samp{""}.
15947 @end deftypevr
15948
15949 @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
15950 Grant access to these supplementary groups for mail processes.
15951 Typically these are used to set up access to shared mailboxes. Note
15952 that it may be dangerous to set these if users can create
15953 symlinks (e.g.@: if "mail" group is set here, ln -s /var/mail ~/mail/var
15954 could allow a user to delete others' mailboxes, or ln -s
15955 /secret/shared/box ~/mail/mybox would allow reading it).
15956 Defaults to @samp{""}.
15957 @end deftypevr
15958
15959 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
15960 Allow full file system access to clients. There's no access checks
15961 other than what the operating system does for the active UID/GID. It
15962 works with both maildir and mboxes, allowing you to prefix mailboxes
15963 names with e.g.@: /path/ or ~user/.
15964 Defaults to @samp{#f}.
15965 @end deftypevr
15966
15967 @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
15968 Don't use mmap() at all. This is required if you store indexes to
15969 shared file systems (NFS or clustered file system).
15970 Defaults to @samp{#f}.
15971 @end deftypevr
15972
15973 @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
15974 Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
15975 supports @samp{O_EXCL} since version 3, so this should be safe to use
15976 nowadays by default.
15977 Defaults to @samp{#t}.
15978 @end deftypevr
15979
15980 @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
15981 When to use fsync() or fdatasync() calls:
15982 @table @code
15983 @item optimized
15984 Whenever necessary to avoid losing important data
15985 @item always
15986 Useful with e.g.@: NFS when write()s are delayed
15987 @item never
15988 Never use it (best performance, but crashes can lose data).
15989 @end table
15990 Defaults to @samp{"optimized"}.
15991 @end deftypevr
15992
15993 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
15994 Mail storage exists in NFS. Set this to yes to make Dovecot flush
15995 NFS caches whenever needed. If you're using only a single mail server
15996 this isn't needed.
15997 Defaults to @samp{#f}.
15998 @end deftypevr
15999
16000 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
16001 Mail index files also exist in NFS. Setting this to yes requires
16002 @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
16003 Defaults to @samp{#f}.
16004 @end deftypevr
16005
16006 @deftypevr {@code{dovecot-configuration} parameter} string lock-method
16007 Locking method for index files. Alternatives are fcntl, flock and
16008 dotlock. Dotlocking uses some tricks which may create more disk I/O
16009 than other locking methods. NFS users: flock doesn't work, remember to
16010 change @samp{mmap-disable}.
16011 Defaults to @samp{"fcntl"}.
16012 @end deftypevr
16013
16014 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
16015 Directory in which LDA/LMTP temporarily stores incoming mails >128
16016 kB.
16017 Defaults to @samp{"/tmp"}.
16018 @end deftypevr
16019
16020 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
16021 Valid UID range for users. This is mostly to make sure that users can't
16022 log in as daemons or other system users. Note that denying root logins is
16023 hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
16024 is set to 0.
16025 Defaults to @samp{500}.
16026 @end deftypevr
16027
16028 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
16029
16030 Defaults to @samp{0}.
16031 @end deftypevr
16032
16033 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
16034 Valid GID range for users. Users having non-valid GID as primary group ID
16035 aren't allowed to log in. If user belongs to supplementary groups with
16036 non-valid GIDs, those groups are not set.
16037 Defaults to @samp{1}.
16038 @end deftypevr
16039
16040 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
16041
16042 Defaults to @samp{0}.
16043 @end deftypevr
16044
16045 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
16046 Maximum allowed length for mail keyword name. It's only forced when
16047 trying to create new keywords.
16048 Defaults to @samp{50}.
16049 @end deftypevr
16050
16051 @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
16052 List of directories under which chrooting is allowed for mail
16053 processes (i.e.@: /var/mail will allow chrooting to /var/mail/foo/bar
16054 too). This setting doesn't affect @samp{login-chroot}
16055 @samp{mail-chroot} or auth chroot settings. If this setting is empty,
16056 "/./" in home dirs are ignored. WARNING: Never add directories here
16057 which local users can modify, that may lead to root exploit. Usually
16058 this should be done only if you don't allow shell access for users.
16059 <doc/wiki/Chrooting.txt>.
16060 Defaults to @samp{()}.
16061 @end deftypevr
16062
16063 @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
16064 Default chroot directory for mail processes. This can be overridden
16065 for specific users in user database by giving /./ in user's home
16066 directory (e.g.@: /home/./user chroots into /home). Note that usually
16067 there is no real need to do chrooting, Dovecot doesn't allow users to
16068 access files outside their mail directory anyway. If your home
16069 directories are prefixed with the chroot directory, append "/."@: to
16070 @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
16071 Defaults to @samp{""}.
16072 @end deftypevr
16073
16074 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
16075 UNIX socket path to master authentication server to find users.
16076 This is used by imap (for shared users) and lda.
16077 Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
16078 @end deftypevr
16079
16080 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
16081 Directory where to look up mail plugins.
16082 Defaults to @samp{"/usr/lib/dovecot"}.
16083 @end deftypevr
16084
16085 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
16086 List of plugins to load for all services. Plugins specific to IMAP,
16087 LDA, etc.@: are added to this list in their own .conf files.
16088 Defaults to @samp{()}.
16089 @end deftypevr
16090
16091 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
16092 The minimum number of mails in a mailbox before updates are done to
16093 cache file. This allows optimizing Dovecot's behavior to do less disk
16094 writes at the cost of more disk reads.
16095 Defaults to @samp{0}.
16096 @end deftypevr
16097
16098 @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
16099 When IDLE command is running, mailbox is checked once in a while to
16100 see if there are any new mails or other changes. This setting defines
16101 the minimum time to wait between those checks. Dovecot can also use
16102 dnotify, inotify and kqueue to find out immediately when changes
16103 occur.
16104 Defaults to @samp{"30 secs"}.
16105 @end deftypevr
16106
16107 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
16108 Save mails with CR+LF instead of plain LF. This makes sending those
16109 mails take less CPU, especially with sendfile() syscall with Linux and
16110 FreeBSD. But it also creates a bit more disk I/O which may just make it
16111 slower. Also note that if other software reads the mboxes/maildirs,
16112 they may handle the extra CRs wrong and cause problems.
16113 Defaults to @samp{#f}.
16114 @end deftypevr
16115
16116 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
16117 By default LIST command returns all entries in maildir beginning
16118 with a dot. Enabling this option makes Dovecot return only entries
16119 which are directories. This is done by stat()ing each entry, so it
16120 causes more disk I/O.
16121 (For systems setting struct @samp{dirent->d_type} this check is free
16122 and it's done always regardless of this setting).
16123 Defaults to @samp{#f}.
16124 @end deftypevr
16125
16126 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
16127 When copying a message, do it with hard links whenever possible.
16128 This makes the performance much better, and it's unlikely to have any
16129 side effects.
16130 Defaults to @samp{#t}.
16131 @end deftypevr
16132
16133 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
16134 Assume Dovecot is the only MUA accessing Maildir: Scan cur/
16135 directory only when its mtime changes unexpectedly or when we can't find
16136 the mail otherwise.
16137 Defaults to @samp{#f}.
16138 @end deftypevr
16139
16140 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
16141 Which locking methods to use for locking mbox. There are four
16142 available:
16143
16144 @table @code
16145 @item dotlock
16146 Create <mailbox>.lock file. This is the oldest and most NFS-safe
16147 solution. If you want to use /var/mail/ like directory, the users will
16148 need write access to that directory.
16149 @item dotlock-try
16150 Same as dotlock, but if it fails because of permissions or because there
16151 isn't enough disk space, just skip it.
16152 @item fcntl
16153 Use this if possible. Works with NFS too if lockd is used.
16154 @item flock
16155 May not exist in all systems. Doesn't work with NFS.
16156 @item lockf
16157 May not exist in all systems. Doesn't work with NFS.
16158 @end table
16159
16160 You can use multiple locking methods; if you do the order they're declared
16161 in is important to avoid deadlocks if other MTAs/MUAs are using multiple
16162 locking methods as well. Some operating systems don't allow using some of
16163 them simultaneously.
16164 @end deftypevr
16165
16166 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
16167
16168 @end deftypevr
16169
16170 @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
16171 Maximum time to wait for lock (all of them) before aborting.
16172 Defaults to @samp{"5 mins"}.
16173 @end deftypevr
16174
16175 @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
16176 If dotlock exists but the mailbox isn't modified in any way,
16177 override the lock file after this much time.
16178 Defaults to @samp{"2 mins"}.
16179 @end deftypevr
16180
16181 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
16182 When mbox changes unexpectedly we have to fully read it to find out
16183 what changed. If the mbox is large this can take a long time. Since
16184 the change is usually just a newly appended mail, it'd be faster to
16185 simply read the new mails. If this setting is enabled, Dovecot does
16186 this but still safely fallbacks to re-reading the whole mbox file
16187 whenever something in mbox isn't how it's expected to be. The only real
16188 downside to this setting is that if some other MUA changes message
16189 flags, Dovecot doesn't notice it immediately. Note that a full sync is
16190 done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
16191 Defaults to @samp{#t}.
16192 @end deftypevr
16193
16194 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
16195 Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
16196 EXAMINE, EXPUNGE or CHECK commands. If this is set,
16197 @samp{mbox-dirty-syncs} is ignored.
16198 Defaults to @samp{#f}.
16199 @end deftypevr
16200
16201 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
16202 Delay writing mbox headers until doing a full write sync (EXPUNGE
16203 and CHECK commands and when closing the mailbox). This is especially
16204 useful for POP3 where clients often delete all mails. The downside is
16205 that our changes aren't immediately visible to other MUAs.
16206 Defaults to @samp{#t}.
16207 @end deftypevr
16208
16209 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
16210 If mbox size is smaller than this (e.g.@: 100k), don't write index
16211 files. If an index file already exists it's still read, just not
16212 updated.
16213 Defaults to @samp{0}.
16214 @end deftypevr
16215
16216 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
16217 Maximum dbox file size until it's rotated.
16218 Defaults to @samp{10000000}.
16219 @end deftypevr
16220
16221 @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
16222 Maximum dbox file age until it's rotated. Typically in days. Day
16223 begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
16224 disabled.
16225 Defaults to @samp{"1d"}.
16226 @end deftypevr
16227
16228 @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
16229 When creating new mdbox files, immediately preallocate their size to
16230 @samp{mdbox-rotate-size}. This setting currently works only in Linux
16231 with some file systems (ext4, xfs).
16232 Defaults to @samp{#f}.
16233 @end deftypevr
16234
16235 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
16236 sdbox and mdbox support saving mail attachments to external files,
16237 which also allows single instance storage for them. Other backends
16238 don't support this for now.
16239
16240 WARNING: This feature hasn't been tested much yet. Use at your own risk.
16241
16242 Directory root where to store mail attachments. Disabled, if empty.
16243 Defaults to @samp{""}.
16244 @end deftypevr
16245
16246 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
16247 Attachments smaller than this aren't saved externally. It's also
16248 possible to write a plugin to disable saving specific attachments
16249 externally.
16250 Defaults to @samp{128000}.
16251 @end deftypevr
16252
16253 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
16254 File system backend to use for saving attachments:
16255 @table @code
16256 @item posix
16257 No SiS done by Dovecot (but this might help FS's own deduplication)
16258 @item sis posix
16259 SiS with immediate byte-by-byte comparison during saving
16260 @item sis-queue posix
16261 SiS with delayed comparison and deduplication.
16262 @end table
16263 Defaults to @samp{"sis posix"}.
16264 @end deftypevr
16265
16266 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
16267 Hash format to use in attachment filenames. You can add any text and
16268 variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
16269 @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
16270 truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
16271 Defaults to @samp{"%@{sha1@}"}.
16272 @end deftypevr
16273
16274 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
16275
16276 Defaults to @samp{100}.
16277 @end deftypevr
16278
16279 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
16280
16281 Defaults to @samp{1000}.
16282 @end deftypevr
16283
16284 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
16285 Default VSZ (virtual memory size) limit for service processes.
16286 This is mainly intended to catch and kill processes that leak memory
16287 before they eat up everything.
16288 Defaults to @samp{256000000}.
16289 @end deftypevr
16290
16291 @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
16292 Login user is internally used by login processes. This is the most
16293 untrusted user in Dovecot system. It shouldn't have access to anything
16294 at all.
16295 Defaults to @samp{"dovenull"}.
16296 @end deftypevr
16297
16298 @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
16299 Internal user is used by unprivileged processes. It should be
16300 separate from login user, so that login processes can't disturb other
16301 processes.
16302 Defaults to @samp{"dovecot"}.
16303 @end deftypevr
16304
16305 @deftypevr {@code{dovecot-configuration} parameter} string ssl?
16306 SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
16307 Defaults to @samp{"required"}.
16308 @end deftypevr
16309
16310 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
16311 PEM encoded X.509 SSL/TLS certificate (public key).
16312 Defaults to @samp{"</etc/dovecot/default.pem"}.
16313 @end deftypevr
16314
16315 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
16316 PEM encoded SSL/TLS private key. The key is opened before
16317 dropping root privileges, so keep the key file unreadable by anyone but
16318 root.
16319 Defaults to @samp{"</etc/dovecot/private/default.pem"}.
16320 @end deftypevr
16321
16322 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
16323 If key file is password protected, give the password here.
16324 Alternatively give it when starting dovecot with -p parameter. Since
16325 this file is often world-readable, you may want to place this setting
16326 instead to a different.
16327 Defaults to @samp{""}.
16328 @end deftypevr
16329
16330 @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
16331 PEM encoded trusted certificate authority. Set this only if you
16332 intend to use @samp{ssl-verify-client-cert? #t}. The file should
16333 contain the CA certificate(s) followed by the matching
16334 CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
16335 Defaults to @samp{""}.
16336 @end deftypevr
16337
16338 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
16339 Require that CRL check succeeds for client certificates.
16340 Defaults to @samp{#t}.
16341 @end deftypevr
16342
16343 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
16344 Request client to send a certificate. If you also want to require
16345 it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
16346 Defaults to @samp{#f}.
16347 @end deftypevr
16348
16349 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
16350 Which field from certificate to use for username. commonName and
16351 x500UniqueIdentifier are the usual choices. You'll also need to set
16352 @samp{auth-ssl-username-from-cert? #t}.
16353 Defaults to @samp{"commonName"}.
16354 @end deftypevr
16355
16356 @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
16357 Minimum SSL protocol version to accept.
16358 Defaults to @samp{"TLSv1"}.
16359 @end deftypevr
16360
16361 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
16362 SSL ciphers to use.
16363 Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
16364 @end deftypevr
16365
16366 @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
16367 SSL crypto device to use, for valid values run "openssl engine".
16368 Defaults to @samp{""}.
16369 @end deftypevr
16370
16371 @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
16372 Address to use when sending rejection mails.
16373 %d expands to recipient domain.
16374 Defaults to @samp{"postmaster@@%d"}.
16375 @end deftypevr
16376
16377 @deftypevr {@code{dovecot-configuration} parameter} string hostname
16378 Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
16379 and in LMTP replies. Default is the system's real hostname@@domain.
16380 Defaults to @samp{""}.
16381 @end deftypevr
16382
16383 @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
16384 If user is over quota, return with temporary failure instead of
16385 bouncing the mail.
16386 Defaults to @samp{#f}.
16387 @end deftypevr
16388
16389 @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
16390 Binary to use for sending mails.
16391 Defaults to @samp{"/usr/sbin/sendmail"}.
16392 @end deftypevr
16393
16394 @deftypevr {@code{dovecot-configuration} parameter} string submission-host
16395 If non-empty, send mails via this SMTP host[:port] instead of
16396 sendmail.
16397 Defaults to @samp{""}.
16398 @end deftypevr
16399
16400 @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
16401 Subject: header to use for rejection mails. You can use the same
16402 variables as for @samp{rejection-reason} below.
16403 Defaults to @samp{"Rejected: %s"}.
16404 @end deftypevr
16405
16406 @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
16407 Human readable error message for rejection mails. You can use
16408 variables:
16409
16410 @table @code
16411 @item %n
16412 CRLF
16413 @item %r
16414 reason
16415 @item %s
16416 original subject
16417 @item %t
16418 recipient
16419 @end table
16420 Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
16421 @end deftypevr
16422
16423 @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
16424 Delimiter character between local-part and detail in email
16425 address.
16426 Defaults to @samp{"+"}.
16427 @end deftypevr
16428
16429 @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
16430 Header where the original recipient address (SMTP's RCPT TO:
16431 address) is taken from if not available elsewhere. With dovecot-lda -a
16432 parameter overrides this. A commonly used header for this is
16433 X-Original-To.
16434 Defaults to @samp{""}.
16435 @end deftypevr
16436
16437 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
16438 Should saving a mail to a nonexistent mailbox automatically create
16439 it?.
16440 Defaults to @samp{#f}.
16441 @end deftypevr
16442
16443 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
16444 Should automatically created mailboxes be also automatically
16445 subscribed?.
16446 Defaults to @samp{#f}.
16447 @end deftypevr
16448
16449 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
16450 Maximum IMAP command line length. Some clients generate very long
16451 command lines with huge mailboxes, so you may need to raise this if you
16452 get "Too long argument" or "IMAP command line too large" errors
16453 often.
16454 Defaults to @samp{64000}.
16455 @end deftypevr
16456
16457 @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
16458 IMAP logout format string:
16459 @table @code
16460 @item %i
16461 total number of bytes read from client
16462 @item %o
16463 total number of bytes sent to client.
16464 @end table
16465 See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
16466 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@}"}.
16467 @end deftypevr
16468
16469 @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
16470 Override the IMAP CAPABILITY response. If the value begins with '+',
16471 add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
16472 Defaults to @samp{""}.
16473 @end deftypevr
16474
16475 @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
16476 How long to wait between "OK Still here" notifications when client
16477 is IDLEing.
16478 Defaults to @samp{"2 mins"}.
16479 @end deftypevr
16480
16481 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
16482 ID field names and values to send to clients. Using * as the value
16483 makes Dovecot use the default value. The following fields have default
16484 values currently: name, version, os, os-version, support-url,
16485 support-email.
16486 Defaults to @samp{""}.
16487 @end deftypevr
16488
16489 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
16490 ID fields sent by client to log. * means everything.
16491 Defaults to @samp{""}.
16492 @end deftypevr
16493
16494 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
16495 Workarounds for various client bugs:
16496
16497 @table @code
16498 @item delay-newmail
16499 Send EXISTS/RECENT new mail notifications only when replying to NOOP and
16500 CHECK commands. Some clients ignore them otherwise, for example OSX
16501 Mail (<v2.1). Outlook Express breaks more badly though, without this it
16502 may show user "Message no longer in server" errors. Note that OE6
16503 still breaks even with this workaround if synchronization is set to
16504 "Headers Only".
16505
16506 @item tb-extra-mailbox-sep
16507 Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
16508 adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
16509 ignore the extra @samp{/} instead of treating it as invalid mailbox name.
16510
16511 @item tb-lsub-flags
16512 Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
16513 This makes Thunderbird realize they aren't selectable and show them
16514 greyed out, instead of only later giving "not selectable" popup error.
16515 @end table
16516 Defaults to @samp{()}.
16517 @end deftypevr
16518
16519 @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
16520 Host allowed in URLAUTH URLs sent by client. "*" allows all.
16521 Defaults to @samp{""}.
16522 @end deftypevr
16523
16524
16525 Whew! Lots of configuration options. The nice thing about it though is
16526 that Guix has a complete interface to Dovecot's configuration
16527 language. This allows not only a nice way to declare configurations,
16528 but also offers reflective capabilities as well: users can write code to
16529 inspect and transform configurations from within Scheme.
16530
16531 However, it could be that you just want to get a @code{dovecot.conf} up
16532 and running. In that case, you can pass an
16533 @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
16534 @code{dovecot-service}. As its name indicates, an opaque configuration
16535 does not have easy reflective capabilities.
16536
16537 Available @code{opaque-dovecot-configuration} fields are:
16538
16539 @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
16540 The dovecot package.
16541 @end deftypevr
16542
16543 @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
16544 The contents of the @code{dovecot.conf}, as a string.
16545 @end deftypevr
16546
16547 For example, if your @code{dovecot.conf} is just the empty string, you
16548 could instantiate a dovecot service like this:
16549
16550 @example
16551 (dovecot-service #:config
16552 (opaque-dovecot-configuration
16553 (string "")))
16554 @end example
16555
16556 @subsubheading OpenSMTPD Service
16557
16558 @deffn {Scheme Variable} opensmtpd-service-type
16559 This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
16560 service, whose value should be an @code{opensmtpd-configuration} object
16561 as in this example:
16562
16563 @example
16564 (service opensmtpd-service-type
16565 (opensmtpd-configuration
16566 (config-file (local-file "./my-smtpd.conf"))))
16567 @end example
16568 @end deffn
16569
16570 @deftp {Data Type} opensmtpd-configuration
16571 Data type representing the configuration of opensmtpd.
16572
16573 @table @asis
16574 @item @code{package} (default: @var{opensmtpd})
16575 Package object of the OpenSMTPD SMTP server.
16576
16577 @item @code{config-file} (default: @var{%default-opensmtpd-file})
16578 File-like object of the OpenSMTPD configuration file to use. By default
16579 it listens on the loopback network interface, and allows for mail from
16580 users and daemons on the local machine, as well as permitting email to
16581 remote servers. Run @command{man smtpd.conf} for more information.
16582
16583 @end table
16584 @end deftp
16585
16586 @subsubheading Exim Service
16587
16588 @cindex mail transfer agent (MTA)
16589 @cindex MTA (mail transfer agent)
16590 @cindex SMTP
16591
16592 @deffn {Scheme Variable} exim-service-type
16593 This is the type of the @uref{https://exim.org, Exim} mail transfer
16594 agent (MTA), whose value should be an @code{exim-configuration} object
16595 as in this example:
16596
16597 @example
16598 (service exim-service-type
16599 (exim-configuration
16600 (config-file (local-file "./my-exim.conf"))))
16601 @end example
16602 @end deffn
16603
16604 In order to use an @code{exim-service-type} service you must also have a
16605 @code{mail-aliases-service-type} service present in your
16606 @code{operating-system} (even if it has no aliases).
16607
16608 @deftp {Data Type} exim-configuration
16609 Data type representing the configuration of exim.
16610
16611 @table @asis
16612 @item @code{package} (default: @var{exim})
16613 Package object of the Exim server.
16614
16615 @item @code{config-file} (default: @code{#f})
16616 File-like object of the Exim configuration file to use. If its value is
16617 @code{#f} then use the default configuration file from the package
16618 provided in @code{package}. The resulting configuration file is loaded
16619 after setting the @code{exim_user} and @code{exim_group} configuration
16620 variables.
16621
16622 @end table
16623 @end deftp
16624
16625 @subsubheading Mail Aliases Service
16626
16627 @cindex email aliases
16628 @cindex aliases, for email addresses
16629
16630 @deffn {Scheme Variable} mail-aliases-service-type
16631 This is the type of the service which provides @code{/etc/aliases},
16632 specifying how to deliver mail to users on this system.
16633
16634 @example
16635 (service mail-aliases-service-type
16636 '(("postmaster" "bob")
16637 ("bob" "bob@@example.com" "bob@@example2.com")))
16638 @end example
16639 @end deffn
16640
16641 The configuration for a @code{mail-aliases-service-type} service is an
16642 association list denoting how to deliver mail that comes to this
16643 system. Each entry is of the form @code{(alias addresses ...)}, with
16644 @code{alias} specifying the local alias and @code{addresses} specifying
16645 where to deliver this user's mail.
16646
16647 The aliases aren't required to exist as users on the local system. In
16648 the above example, there doesn't need to be a @code{postmaster} entry in
16649 the @code{operating-system}'s @code{user-accounts} in order to deliver
16650 the @code{postmaster} mail to @code{bob} (which subsequently would
16651 deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
16652
16653 @subsubheading GNU Mailutils IMAP4 Daemon
16654 @cindex GNU Mailutils IMAP4 Daemon
16655
16656 @deffn {Scheme Variable} imap4d-service-type
16657 This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
16658 mailutils, GNU Mailutils Manual}), whose value should be an
16659 @code{imap4d-configuration} object as in this example:
16660
16661 @example
16662 (service imap4d-service-type
16663 (imap4d-configuration
16664 (config-file (local-file "imap4d.conf"))))
16665 @end example
16666 @end deffn
16667
16668 @deftp {Data Type} imap4d-configuration
16669 Data type representing the configuration of @command{imap4d}.
16670
16671 @table @asis
16672 @item @code{package} (default: @code{mailutils})
16673 The package that provides @command{imap4d}.
16674
16675 @item @code{config-file} (default: @code{%default-imap4d-config-file})
16676 File-like object of the configuration file to use, by default it will listen
16677 on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
16678 Mailutils Manual}, for details.
16679
16680 @end table
16681 @end deftp
16682
16683 @node Messaging Services
16684 @subsection Messaging Services
16685
16686 @cindex messaging
16687 @cindex jabber
16688 @cindex XMPP
16689 The @code{(gnu services messaging)} module provides Guix service
16690 definitions for messaging services: currently only Prosody is supported.
16691
16692 @subsubheading Prosody Service
16693
16694 @deffn {Scheme Variable} prosody-service-type
16695 This is the type for the @uref{https://prosody.im, Prosody XMPP
16696 communication server}. Its value must be a @code{prosody-configuration}
16697 record as in this example:
16698
16699 @example
16700 (service prosody-service-type
16701 (prosody-configuration
16702 (modules-enabled (cons "groups" "mam" %default-modules-enabled))
16703 (int-components
16704 (list
16705 (int-component-configuration
16706 (hostname "conference.example.net")
16707 (plugin "muc")
16708 (mod-muc (mod-muc-configuration)))))
16709 (virtualhosts
16710 (list
16711 (virtualhost-configuration
16712 (domain "example.net"))))))
16713 @end example
16714
16715 See below for details about @code{prosody-configuration}.
16716
16717 @end deffn
16718
16719 By default, Prosody does not need much configuration. Only one
16720 @code{virtualhosts} field is needed: it specifies the domain you wish
16721 Prosody to serve.
16722
16723 You can perform various sanity checks on the generated configuration
16724 with the @code{prosodyctl check} command.
16725
16726 Prosodyctl will also help you to import certificates from the
16727 @code{letsencrypt} directory so that the @code{prosody} user can access
16728 them. See @url{https://prosody.im/doc/letsencrypt}.
16729
16730 @example
16731 prosodyctl --root cert import /etc/letsencrypt/live
16732 @end example
16733
16734 The available configuration parameters follow. Each parameter
16735 definition is preceded by its type; for example, @samp{string-list foo}
16736 indicates that the @code{foo} parameter should be specified as a list of
16737 strings. Types starting with @code{maybe-} denote parameters that won't
16738 show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
16739
16740 There is also a way to specify the configuration as a string, if you
16741 have an old @code{prosody.cfg.lua} file that you want to port over from
16742 some other system; see the end for more details.
16743
16744 The @code{file-object} type designates either a file-like object
16745 (@pxref{G-Expressions, file-like objects}) or a file name.
16746
16747 @c The following documentation was initially generated by
16748 @c (generate-documentation) in (gnu services messaging). Manually maintained
16749 @c documentation is better, so we shouldn't hesitate to edit below as
16750 @c needed. However if the change you want to make to this documentation
16751 @c can be done in an automated way, it's probably easier to change
16752 @c (generate-documentation) than to make it below and have to deal with
16753 @c the churn as Prosody updates.
16754
16755 Available @code{prosody-configuration} fields are:
16756
16757 @deftypevr {@code{prosody-configuration} parameter} package prosody
16758 The Prosody package.
16759 @end deftypevr
16760
16761 @deftypevr {@code{prosody-configuration} parameter} file-name data-path
16762 Location of the Prosody data storage directory. See
16763 @url{https://prosody.im/doc/configure}.
16764 Defaults to @samp{"/var/lib/prosody"}.
16765 @end deftypevr
16766
16767 @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
16768 Additional plugin directories. They are searched in all the specified
16769 paths in order. See @url{https://prosody.im/doc/plugins_directory}.
16770 Defaults to @samp{()}.
16771 @end deftypevr
16772
16773 @deftypevr {@code{prosody-configuration} parameter} file-name certificates
16774 Every virtual host and component needs a certificate so that clients and
16775 servers can securely verify its identity. Prosody will automatically load
16776 certificates/keys from the directory specified here.
16777 Defaults to @samp{"/etc/prosody/certs"}.
16778 @end deftypevr
16779
16780 @deftypevr {@code{prosody-configuration} parameter} string-list admins
16781 This is a list of accounts that are admins for the server. Note that you
16782 must create the accounts separately. See @url{https://prosody.im/doc/admins} and
16783 @url{https://prosody.im/doc/creating_accounts}.
16784 Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
16785 Defaults to @samp{()}.
16786 @end deftypevr
16787
16788 @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
16789 Enable use of libevent for better performance under high load. See
16790 @url{https://prosody.im/doc/libevent}.
16791 Defaults to @samp{#f}.
16792 @end deftypevr
16793
16794 @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
16795 This is the list of modules Prosody will load on startup. It looks for
16796 @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
16797 Documentation on modules can be found at:
16798 @url{https://prosody.im/doc/modules}.
16799 Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
16800 @end deftypevr
16801
16802 @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
16803 @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
16804 should you want to disable them then add them to this list.
16805 Defaults to @samp{()}.
16806 @end deftypevr
16807
16808 @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
16809 Path to a text file where the shared groups are defined. If this path is
16810 empty then @samp{mod_groups} does nothing. See
16811 @url{https://prosody.im/doc/modules/mod_groups}.
16812 Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
16813 @end deftypevr
16814
16815 @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
16816 Disable account creation by default, for security. See
16817 @url{https://prosody.im/doc/creating_accounts}.
16818 Defaults to @samp{#f}.
16819 @end deftypevr
16820
16821 @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
16822 These are the SSL/TLS-related settings. Most of them are disabled so to
16823 use Prosody's defaults. If you do not completely understand these options, do
16824 not add them to your config, it is easy to lower the security of your server
16825 using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
16826
16827 Available @code{ssl-configuration} fields are:
16828
16829 @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
16830 This determines what handshake to use.
16831 @end deftypevr
16832
16833 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
16834 Path to your private key file.
16835 @end deftypevr
16836
16837 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
16838 Path to your certificate file.
16839 @end deftypevr
16840
16841 @deftypevr {@code{ssl-configuration} parameter} file-object capath
16842 Path to directory containing root certificates that you wish Prosody to
16843 trust when verifying the certificates of remote servers.
16844 Defaults to @samp{"/etc/ssl/certs"}.
16845 @end deftypevr
16846
16847 @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
16848 Path to a file containing root certificates that you wish Prosody to trust.
16849 Similar to @code{capath} but with all certificates concatenated together.
16850 @end deftypevr
16851
16852 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
16853 A list of verification options (these mostly map to OpenSSL's
16854 @code{set_verify()} flags).
16855 @end deftypevr
16856
16857 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
16858 A list of general options relating to SSL/TLS. These map to OpenSSL's
16859 @code{set_options()}. For a full list of options available in LuaSec, see the
16860 LuaSec source.
16861 @end deftypevr
16862
16863 @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
16864 How long a chain of certificate authorities to check when looking for a
16865 trusted root certificate.
16866 @end deftypevr
16867
16868 @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
16869 An OpenSSL cipher string. This selects what ciphers Prosody will offer to
16870 clients, and in what order.
16871 @end deftypevr
16872
16873 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
16874 A path to a file containing parameters for Diffie-Hellman key exchange. You
16875 can create such a file with:
16876 @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
16877 @end deftypevr
16878
16879 @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
16880 Curve for Elliptic curve Diffie-Hellman. Prosody's default is
16881 @samp{"secp384r1"}.
16882 @end deftypevr
16883
16884 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
16885 A list of "extra" verification options.
16886 @end deftypevr
16887
16888 @deftypevr {@code{ssl-configuration} parameter} maybe-string password
16889 Password for encrypted private keys.
16890 @end deftypevr
16891
16892 @end deftypevr
16893
16894 @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
16895 Whether to force all client-to-server connections to be encrypted or not.
16896 See @url{https://prosody.im/doc/modules/mod_tls}.
16897 Defaults to @samp{#f}.
16898 @end deftypevr
16899
16900 @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
16901 Set of mechanisms that will never be offered. See
16902 @url{https://prosody.im/doc/modules/mod_saslauth}.
16903 Defaults to @samp{("DIGEST-MD5")}.
16904 @end deftypevr
16905
16906 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
16907 Whether to force all server-to-server connections to be encrypted or not.
16908 See @url{https://prosody.im/doc/modules/mod_tls}.
16909 Defaults to @samp{#f}.
16910 @end deftypevr
16911
16912 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
16913 Whether to require encryption and certificate authentication. This
16914 provides ideal security, but requires servers you communicate with to support
16915 encryption AND present valid, trusted certificates. See
16916 @url{https://prosody.im/doc/s2s#security}.
16917 Defaults to @samp{#f}.
16918 @end deftypevr
16919
16920 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
16921 Many servers don't support encryption or have invalid or self-signed
16922 certificates. You can list domains here that will not be required to
16923 authenticate using certificates. They will be authenticated using DNS. See
16924 @url{https://prosody.im/doc/s2s#security}.
16925 Defaults to @samp{()}.
16926 @end deftypevr
16927
16928 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
16929 Even if you leave @code{s2s-secure-auth?} disabled, you can still require
16930 valid certificates for some domains by specifying a list here. See
16931 @url{https://prosody.im/doc/s2s#security}.
16932 Defaults to @samp{()}.
16933 @end deftypevr
16934
16935 @deftypevr {@code{prosody-configuration} parameter} string authentication
16936 Select the authentication backend to use. The default provider stores
16937 passwords in plaintext and uses Prosody's configured data storage to store the
16938 authentication data. If you do not trust your server please see
16939 @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
16940 about using the hashed backend. See also
16941 @url{https://prosody.im/doc/authentication}
16942 Defaults to @samp{"internal_plain"}.
16943 @end deftypevr
16944
16945 @deftypevr {@code{prosody-configuration} parameter} maybe-string log
16946 Set logging options. Advanced logging configuration is not yet supported
16947 by the Prosody service. See @url{https://prosody.im/doc/logging}.
16948 Defaults to @samp{"*syslog"}.
16949 @end deftypevr
16950
16951 @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
16952 File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
16953 Defaults to @samp{"/var/run/prosody/prosody.pid"}.
16954 @end deftypevr
16955
16956 @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
16957 Maximum allowed size of the HTTP body (in bytes).
16958 @end deftypevr
16959
16960 @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
16961 Some modules expose their own URL in various ways. This URL is built
16962 from the protocol, host and port used. If Prosody sits behind a proxy, the
16963 public URL will be @code{http-external-url} instead. See
16964 @url{https://prosody.im/doc/http#external_url}.
16965 @end deftypevr
16966
16967 @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
16968 A host in Prosody is a domain on which user accounts can be created. For
16969 example if you want your users to have addresses like
16970 @samp{"john.smith@@example.com"} then you need to add a host
16971 @samp{"example.com"}. All options in this list will apply only to this host.
16972
16973 Note: the name "virtual" host is used in configuration to avoid confusion with
16974 the actual physical host that Prosody is installed on. A single Prosody
16975 instance can serve many domains, each one defined as a VirtualHost entry in
16976 Prosody's configuration. Conversely a server that hosts a single domain would
16977 have just one VirtualHost entry.
16978
16979 See @url{https://prosody.im/doc/configure#virtual_host_settings}.
16980
16981 Available @code{virtualhost-configuration} fields are:
16982
16983 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:
16984 @deftypevr {@code{virtualhost-configuration} parameter} string domain
16985 Domain you wish Prosody to serve.
16986 @end deftypevr
16987
16988 @end deftypevr
16989
16990 @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
16991 Components are extra services on a server which are available to clients,
16992 usually on a subdomain of the main server (such as
16993 @samp{"mycomponent.example.com"}). Example components might be chatroom
16994 servers, user directories, or gateways to other protocols.
16995
16996 Internal components are implemented with Prosody-specific plugins. To add an
16997 internal component, you simply fill the hostname field, and the plugin you wish
16998 to use for the component.
16999
17000 See @url{https://prosody.im/doc/components}.
17001 Defaults to @samp{()}.
17002
17003 Available @code{int-component-configuration} fields are:
17004
17005 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:
17006 @deftypevr {@code{int-component-configuration} parameter} string hostname
17007 Hostname of the component.
17008 @end deftypevr
17009
17010 @deftypevr {@code{int-component-configuration} parameter} string plugin
17011 Plugin you wish to use for the component.
17012 @end deftypevr
17013
17014 @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
17015 Multi-user chat (MUC) is Prosody's module for allowing you to create
17016 hosted chatrooms/conferences for XMPP users.
17017
17018 General information on setting up and using multi-user chatrooms can be found
17019 in the "Chatrooms" documentation (@url{https://prosody.im/doc/chatrooms}),
17020 which you should read if you are new to XMPP chatrooms.
17021
17022 See also @url{https://prosody.im/doc/modules/mod_muc}.
17023
17024 Available @code{mod-muc-configuration} fields are:
17025
17026 @deftypevr {@code{mod-muc-configuration} parameter} string name
17027 The name to return in service discovery responses.
17028 Defaults to @samp{"Prosody Chatrooms"}.
17029 @end deftypevr
17030
17031 @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
17032 If @samp{#t}, this will only allow admins to create new chatrooms.
17033 Otherwise anyone can create a room. The value @samp{"local"} restricts room
17034 creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
17035 can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
17036 restricts to service administrators only.
17037 Defaults to @samp{#f}.
17038 @end deftypevr
17039
17040 @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
17041 Maximum number of history messages that will be sent to the member that has
17042 just joined the room.
17043 Defaults to @samp{20}.
17044 @end deftypevr
17045
17046 @end deftypevr
17047
17048 @end deftypevr
17049
17050 @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
17051 External components use XEP-0114, which most standalone components
17052 support. To add an external component, you simply fill the hostname field. See
17053 @url{https://prosody.im/doc/components}.
17054 Defaults to @samp{()}.
17055
17056 Available @code{ext-component-configuration} fields are:
17057
17058 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:
17059 @deftypevr {@code{ext-component-configuration} parameter} string component-secret
17060 Password which the component will use to log in.
17061 @end deftypevr
17062
17063 @deftypevr {@code{ext-component-configuration} parameter} string hostname
17064 Hostname of the component.
17065 @end deftypevr
17066
17067 @end deftypevr
17068
17069 @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
17070 Port(s) Prosody listens on for component connections.
17071 Defaults to @samp{(5347)}.
17072 @end deftypevr
17073
17074 @deftypevr {@code{prosody-configuration} parameter} string component-interface
17075 Interface Prosody listens on for component connections.
17076 Defaults to @samp{"127.0.0.1"}.
17077 @end deftypevr
17078
17079 @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
17080 Raw content that will be added to the configuration file.
17081 @end deftypevr
17082
17083 It could be that you just want to get a @code{prosody.cfg.lua}
17084 up and running. In that case, you can pass an
17085 @code{opaque-prosody-configuration} record as the value of
17086 @code{prosody-service-type}. As its name indicates, an opaque configuration
17087 does not have easy reflective capabilities.
17088 Available @code{opaque-prosody-configuration} fields are:
17089
17090 @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
17091 The prosody package.
17092 @end deftypevr
17093
17094 @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
17095 The contents of the @code{prosody.cfg.lua} to use.
17096 @end deftypevr
17097
17098 For example, if your @code{prosody.cfg.lua} is just the empty
17099 string, you could instantiate a prosody service like this:
17100
17101 @example
17102 (service prosody-service-type
17103 (opaque-prosody-configuration
17104 (prosody.cfg.lua "")))
17105 @end example
17106
17107 @c end of Prosody auto-generated documentation
17108
17109 @subsubheading BitlBee Service
17110
17111 @cindex IRC (Internet Relay Chat)
17112 @cindex IRC gateway
17113 @url{http://bitlbee.org,BitlBee} is a gateway that provides an IRC
17114 interface to a variety of messaging protocols such as XMPP.
17115
17116 @defvr {Scheme Variable} bitlbee-service-type
17117 This is the service type for the @url{http://bitlbee.org,BitlBee} IRC
17118 gateway daemon. Its value is a @code{bitlbee-configuration} (see
17119 below).
17120
17121 To have BitlBee listen on port 6667 on localhost, add this line to your
17122 services:
17123
17124 @example
17125 (service bitlbee-service-type)
17126 @end example
17127 @end defvr
17128
17129 @deftp {Data Type} bitlbee-configuration
17130 This is the configuration for BitlBee, with the following fields:
17131
17132 @table @asis
17133 @item @code{interface} (default: @code{"127.0.0.1"})
17134 @itemx @code{port} (default: @code{6667})
17135 Listen on the network interface corresponding to the IP address
17136 specified in @var{interface}, on @var{port}.
17137
17138 When @var{interface} is @code{127.0.0.1}, only local clients can
17139 connect; when it is @code{0.0.0.0}, connections can come from any
17140 networking interface.
17141
17142 @item @code{package} (default: @code{bitlbee})
17143 The BitlBee package to use.
17144
17145 @item @code{plugins} (default: @code{'()})
17146 List of plugin packages to use---e.g., @code{bitlbee-discord}.
17147
17148 @item @code{extra-settings} (default: @code{""})
17149 Configuration snippet added as-is to the BitlBee configuration file.
17150 @end table
17151 @end deftp
17152
17153 @subsubheading Quassel Service
17154
17155 @cindex IRC (Internet Relay Chat)
17156 @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
17157 meaning that one or more clients can attach to and detach from the
17158 central core.
17159
17160 @defvr {Scheme Variable} quassel-service-type
17161 This is the service type for the @url{https://quassel-irc.org/,Quassel}
17162 IRC backend daemon. Its value is a @code{quassel-configuration}
17163 (see below).
17164 @end defvr
17165
17166 @deftp {Data Type} quassel-configuration
17167 This is the configuration for Quassel, with the following fields:
17168
17169 @table @asis
17170 @item @code{quassel} (default: @code{quassel})
17171 The Quassel package to use.
17172
17173 @item @code{interface} (default: @code{"::,0.0.0.0"})
17174 @item @code{port} (default: @code{4242})
17175 Listen on the network interface(s) corresponding to the IPv4 or IPv6
17176 interfaces specified in the comma delimited @var{interface}, on
17177 @var{port}.
17178
17179 @item @code{loglevel} (default: @code{"Info"})
17180 The level of logging desired. Accepted values are Debug, Info, Warning
17181 and Error.
17182 @end table
17183 @end deftp
17184
17185 @node Telephony Services
17186 @subsection Telephony Services
17187
17188 @cindex Murmur (VoIP server)
17189 @cindex VoIP server
17190 This section describes how to set up and run a Murmur server. Murmur is
17191 the server of the @uref{https://mumble.info, Mumble} voice-over-IP
17192 (VoIP) suite.
17193
17194 @deftp {Data Type} murmur-configuration
17195 The service type for the Murmur server. An example configuration can
17196 look like this:
17197
17198 @example
17199 (service murmur-service-type
17200 (murmur-configuration
17201 (welcome-text
17202 "Welcome to this Mumble server running on Guix!")
17203 (cert-required? #t) ;disallow text password logins
17204 (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
17205 (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
17206 @end example
17207
17208 After reconfiguring your system, you can manually set the murmur @code{SuperUser}
17209 password with the command that is printed during the activation phase.
17210
17211 It is recommended to register a normal Mumble user account
17212 and grant it admin or moderator rights.
17213 You can use the @code{mumble} client to
17214 login as new normal user, register yourself, and log out.
17215 For the next step login with the name @code{SuperUser} use
17216 the @code{SuperUser} password that you set previously,
17217 and grant your newly registered mumble user administrator or moderator
17218 rights and create some channels.
17219
17220 Available @code{murmur-configuration} fields are:
17221
17222 @table @asis
17223 @item @code{package} (default: @code{mumble})
17224 Package that contains @code{bin/murmurd}.
17225
17226 @item @code{user} (default: @code{"murmur"})
17227 User who will run the Murmur server.
17228
17229 @item @code{group} (default: @code{"murmur"})
17230 Group of the user who will run the murmur server.
17231
17232 @item @code{port} (default: @code{64738})
17233 Port on which the server will listen.
17234
17235 @item @code{welcome-text} (default: @code{""})
17236 Welcome text sent to clients when they connect.
17237
17238 @item @code{server-password} (default: @code{""})
17239 Password the clients have to enter in order to connect.
17240
17241 @item @code{max-users} (default: @code{100})
17242 Maximum of users that can be connected to the server at once.
17243
17244 @item @code{max-user-bandwidth} (default: @code{#f})
17245 Maximum voice traffic a user can send per second.
17246
17247 @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
17248 File name of the sqlite database.
17249 The service's user will become the owner of the directory.
17250
17251 @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
17252 File name of the log file.
17253 The service's user will become the owner of the directory.
17254
17255 @item @code{autoban-attempts} (default: @code{10})
17256 Maximum number of logins a user can make in @code{autoban-timeframe}
17257 without getting auto banned for @code{autoban-time}.
17258
17259 @item @code{autoban-timeframe} (default: @code{120})
17260 Timeframe for autoban in seconds.
17261
17262 @item @code{autoban-time} (default: @code{300})
17263 Amount of time in seconds for which a client gets banned
17264 when violating the autoban limits.
17265
17266 @item @code{opus-threshold} (default: @code{100})
17267 Percentage of clients that need to support opus
17268 before switching over to opus audio codec.
17269
17270 @item @code{channel-nesting-limit} (default: @code{10})
17271 How deep channels can be nested at maximum.
17272
17273 @item @code{channelname-regex} (default: @code{#f})
17274 A string in form of a Qt regular expression that channel names must conform to.
17275
17276 @item @code{username-regex} (default: @code{#f})
17277 A string in form of a Qt regular expression that user names must conform to.
17278
17279 @item @code{text-message-length} (default: @code{5000})
17280 Maximum size in bytes that a user can send in one text chat message.
17281
17282 @item @code{image-message-length} (default: @code{(* 128 1024)})
17283 Maximum size in bytes that a user can send in one image message.
17284
17285 @item @code{cert-required?} (default: @code{#f})
17286 If it is set to @code{#t} clients that use weak password authentification
17287 will not be accepted. Users must have completed the certificate wizard to join.
17288
17289 @item @code{remember-channel?} (default: @code{#f})
17290 Should murmur remember the last channel each user was in when they disconnected
17291 and put them into the remembered channel when they rejoin.
17292
17293 @item @code{allow-html?} (default: @code{#f})
17294 Should html be allowed in text messages, user comments, and channel descriptions.
17295
17296 @item @code{allow-ping?} (default: @code{#f})
17297 Setting to true exposes the current user count, the maximum user count, and
17298 the server's maximum bandwidth per client to unauthenticated users. In the
17299 Mumble client, this information is shown in the Connect dialog.
17300
17301 Disabling this setting will prevent public listing of the server.
17302
17303 @item @code{bonjour?} (default: @code{#f})
17304 Should the server advertise itself in the local network through the bonjour protocol.
17305
17306 @item @code{send-version?} (default: @code{#f})
17307 Should the murmur server version be exposed in ping requests.
17308
17309 @item @code{log-days} (default: @code{31})
17310 Murmur also stores logs in the database, which are accessible via RPC.
17311 The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
17312 or -1 to disable logging to the database.
17313
17314 @item @code{obfuscate-ips?} (default: @code{#t})
17315 Should logged ips be obfuscated to protect the privacy of users.
17316
17317 @item @code{ssl-cert} (default: @code{#f})
17318 File name of the SSL/TLS certificate used for encrypted connections.
17319
17320 @example
17321 (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
17322 @end example
17323 @item @code{ssl-key} (default: @code{#f})
17324 Filepath to the ssl private key used for encrypted connections.
17325 @example
17326 (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
17327 @end example
17328
17329 @item @code{ssl-dh-params} (default: @code{#f})
17330 File name of a PEM-encoded file with Diffie-Hellman parameters
17331 for the SSL/TLS encryption. Alternatively you set it to
17332 @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
17333 or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
17334
17335 @item @code{ssl-ciphers} (default: @code{#f})
17336 The @code{ssl-ciphers} option chooses the cipher suites to make available for use
17337 in SSL/TLS.
17338
17339 This option is specified using
17340 @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
17341 OpenSSL cipher list notation}.
17342
17343 It is recommended that you try your cipher string using 'openssl ciphers <string>'
17344 before setting it here, to get a feel for which cipher suites you will get.
17345 After setting this option, it is recommend that you inspect your Murmur log
17346 to ensure that Murmur is using the cipher suites that you expected it to.
17347
17348 Note: Changing this option may impact the backwards compatibility of your
17349 Murmur server, and can remove the ability for older Mumble clients to be able
17350 to connect to it.
17351
17352 @item @code{public-registration} (default: @code{#f})
17353 Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
17354
17355 You can optionally register your server in the public server list that the
17356 @code{mumble} client shows on startup.
17357 You cannot register your server if you have set a @code{server-password},
17358 or set @code{allow-ping} to @code{#f}.
17359
17360 It might take a few hours until it shows up in the public list.
17361
17362 @item @code{file} (default: @code{#f})
17363 Optional alternative override for this configuration.
17364 @end table
17365 @end deftp
17366
17367 @deftp {Data Type} murmur-public-registration-configuration
17368 Configuration for public registration of a murmur service.
17369
17370 @table @asis
17371 @item @code{name}
17372 This is a display name for your server. Not to be confused with the hostname.
17373
17374 @item @code{password}
17375 A password to identify your registration.
17376 Subsequent updates will need the same password. Don't lose your password.
17377
17378 @item @code{url}
17379 This should be a @code{http://} or @code{https://} link to your web
17380 site.
17381
17382 @item @code{hostname} (default: @code{#f})
17383 By default your server will be listed by its IP address.
17384 If it is set your server will be linked by this host name instead.
17385 @end table
17386 @end deftp
17387
17388
17389
17390 @node Monitoring Services
17391 @subsection Monitoring Services
17392
17393 @subsubheading Tailon Service
17394
17395 @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
17396 viewing and searching log files.
17397
17398 The following example will configure the service with default values.
17399 By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
17400
17401 @example
17402 (service tailon-service-type)
17403 @end example
17404
17405 The following example customises more of the Tailon configuration,
17406 adding @command{sed} to the list of allowed commands.
17407
17408 @example
17409 (service tailon-service-type
17410 (tailon-configuration
17411 (config-file
17412 (tailon-configuration-file
17413 (allowed-commands '("tail" "grep" "awk" "sed"))))))
17414 @end example
17415
17416
17417 @deftp {Data Type} tailon-configuration
17418 Data type representing the configuration of Tailon.
17419 This type has the following parameters:
17420
17421 @table @asis
17422 @item @code{config-file} (default: @code{(tailon-configuration-file)})
17423 The configuration file to use for Tailon. This can be set to a
17424 @dfn{tailon-configuration-file} record value, or any gexp
17425 (@pxref{G-Expressions}).
17426
17427 For example, to instead use a local file, the @code{local-file} function
17428 can be used:
17429
17430 @example
17431 (service tailon-service-type
17432 (tailon-configuration
17433 (config-file (local-file "./my-tailon.conf"))))
17434 @end example
17435
17436 @item @code{package} (default: @code{tailon})
17437 The tailon package to use.
17438
17439 @end table
17440 @end deftp
17441
17442 @deftp {Data Type} tailon-configuration-file
17443 Data type representing the configuration options for Tailon.
17444 This type has the following parameters:
17445
17446 @table @asis
17447 @item @code{files} (default: @code{(list "/var/log")})
17448 List of files to display. The list can include strings for a single file
17449 or directory, or a list, where the first item is the name of a
17450 subsection, and the remaining items are the files or directories in that
17451 subsection.
17452
17453 @item @code{bind} (default: @code{"localhost:8080"})
17454 Address and port to which Tailon should bind on.
17455
17456 @item @code{relative-root} (default: @code{#f})
17457 URL path to use for Tailon, set to @code{#f} to not use a path.
17458
17459 @item @code{allow-transfers?} (default: @code{#t})
17460 Allow downloading the log files in the web interface.
17461
17462 @item @code{follow-names?} (default: @code{#t})
17463 Allow tailing of not-yet existent files.
17464
17465 @item @code{tail-lines} (default: @code{200})
17466 Number of lines to read initially from each file.
17467
17468 @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
17469 Commands to allow running. By default, @code{sed} is disabled.
17470
17471 @item @code{debug?} (default: @code{#f})
17472 Set @code{debug?} to @code{#t} to show debug messages.
17473
17474 @item @code{wrap-lines} (default: @code{#t})
17475 Initial line wrapping state in the web interface. Set to @code{#t} to
17476 initially wrap lines (the default), or to @code{#f} to initially not
17477 wrap lines.
17478
17479 @item @code{http-auth} (default: @code{#f})
17480 HTTP authentication type to use. Set to @code{#f} to disable
17481 authentication (the default). Supported values are @code{"digest"} or
17482 @code{"basic"}.
17483
17484 @item @code{users} (default: @code{#f})
17485 If HTTP authentication is enabled (see @code{http-auth}), access will be
17486 restricted to the credentials provided here. To configure users, use a
17487 list of pairs, where the first element of the pair is the username, and
17488 the 2nd element of the pair is the password.
17489
17490 @example
17491 (tailon-configuration-file
17492 (http-auth "basic")
17493 (users '(("user1" . "password1")
17494 ("user2" . "password2"))))
17495 @end example
17496
17497 @end table
17498 @end deftp
17499
17500
17501 @subsubheading Darkstat Service
17502 @cindex darkstat
17503 Darkstat is a packet sniffer that captures network traffic, calculates
17504 statistics about usage, and serves reports over HTTP.
17505
17506 @defvar {Scheme Variable} darkstat-service-type
17507 This is the service type for the
17508 @uref{https://unix4lyfe.org/darkstat/, darkstat}
17509 service, its value must be a @code{darkstat-configuration} record as in
17510 this example:
17511
17512 @example
17513 (service darkstat-service-type
17514 (darkstat-configuration
17515 (interface "eno1")))
17516 @end example
17517 @end defvar
17518
17519 @deftp {Data Type} darkstat-configuration
17520 Data type representing the configuration of @command{darkstat}.
17521
17522 @table @asis
17523 @item @code{package} (default: @code{darkstat})
17524 The darkstat package to use.
17525
17526 @item @code{interface}
17527 Capture traffic on the specified network interface.
17528
17529 @item @code{port} (default: @code{"667"})
17530 Bind the web interface to the specified port.
17531
17532 @item @code{bind-address} (default: @code{"127.0.0.1"})
17533 Bind the web interface to the specified address.
17534
17535 @item @code{base} (default: @code{"/"})
17536 Specify the path of the base URL. This can be useful if
17537 @command{darkstat} is accessed via a reverse proxy.
17538
17539 @end table
17540 @end deftp
17541
17542 @subsubheading Prometheus Node Exporter Service
17543
17544 @cindex prometheus-node-exporter
17545 The Prometheus ``node exporter'' makes hardware and operating system statistics
17546 provided by the Linux kernel available for the Prometheus monitoring system.
17547 This service should be deployed on all physical nodes and virtual machines,
17548 where monitoring these statistics is desirable.
17549
17550 @defvar {Scheme variable} prometheus-node-exporter-service-type
17551 This is the service type for the
17552 @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
17553 service, its value must be a @code{prometheus-node-exporter-configuration}
17554 record as in this example:
17555
17556 @example
17557 (service prometheus-node-exporter-service-type
17558 (prometheus-node-exporter-configuration
17559 (web-listen-address ":9100")))
17560 @end example
17561 @end defvar
17562
17563 @deftp {Data Type} prometheus-node-exporter-configuration
17564 Data type representing the configuration of @command{node_exporter}.
17565
17566 @table @asis
17567 @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
17568 The prometheus-node-exporter package to use.
17569
17570 @item @code{web-listen-address} (default: @code{":9100"})
17571 Bind the web interface to the specified address.
17572
17573 @end table
17574 @end deftp
17575
17576 @subsubheading Zabbix server
17577 @cindex zabbix zabbix-server
17578 Zabbix provides monitoring metrics, among others network utilization, CPU load
17579 and disk space consumption:
17580
17581 @itemize
17582 @item High performance, high capacity (able to monitor hundreds of thousands of devices).
17583 @item Auto-discovery of servers and network devices and interfaces.
17584 @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
17585 @item Distributed monitoring with centralized web administration.
17586 @item Native high performance agents.
17587 @item SLA, and ITIL KPI metrics on reporting.
17588 @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
17589 @item Remote command execution through Zabbix proxies.
17590 @end itemize
17591
17592 @c %start of fragment
17593
17594 Available @code{zabbix-server-configuration} fields are:
17595
17596 @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
17597 The zabbix-server package.
17598
17599 @end deftypevr
17600
17601 @deftypevr {@code{zabbix-server-configuration} parameter} string user
17602 User who will run the Zabbix server.
17603
17604 Defaults to @samp{"zabbix"}.
17605
17606 @end deftypevr
17607
17608 @deftypevr {@code{zabbix-server-configuration} parameter} group group
17609 Group who will run the Zabbix server.
17610
17611 Defaults to @samp{"zabbix"}.
17612
17613 @end deftypevr
17614
17615 @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
17616 Database host name.
17617
17618 Defaults to @samp{"127.0.0.1"}.
17619
17620 @end deftypevr
17621
17622 @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
17623 Database name.
17624
17625 Defaults to @samp{"zabbix"}.
17626
17627 @end deftypevr
17628
17629 @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
17630 Database user.
17631
17632 Defaults to @samp{"zabbix"}.
17633
17634 @end deftypevr
17635
17636 @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
17637 Database password. Please, use @code{include-files} with
17638 @code{DBPassword=SECRET} inside a specified file instead.
17639
17640 Defaults to @samp{""}.
17641
17642 @end deftypevr
17643
17644 @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
17645 Database port.
17646
17647 Defaults to @samp{5432}.
17648
17649 @end deftypevr
17650
17651 @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
17652 Specifies where log messages are written to:
17653
17654 @itemize @bullet
17655 @item
17656 @code{system} - syslog.
17657
17658 @item
17659 @code{file} - file specified with @code{log-file} parameter.
17660
17661 @item
17662 @code{console} - standard output.
17663
17664 @end itemize
17665
17666 Defaults to @samp{""}.
17667
17668 @end deftypevr
17669
17670 @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
17671 Log file name for @code{log-type} @code{file} parameter.
17672
17673 Defaults to @samp{"/var/log/zabbix/server.log"}.
17674
17675 @end deftypevr
17676
17677 @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
17678 Name of PID file.
17679
17680 Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
17681
17682 @end deftypevr
17683
17684 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
17685 The location of certificate authority (CA) files for SSL server
17686 certificate verification.
17687
17688 Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
17689
17690 @end deftypevr
17691
17692 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
17693 Location of SSL client certificates.
17694
17695 Defaults to @samp{"/etc/ssl/certs"}.
17696
17697 @end deftypevr
17698
17699 @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
17700 Extra options will be appended to Zabbix server configuration file.
17701
17702 Defaults to @samp{""}.
17703
17704 @end deftypevr
17705
17706 @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
17707 You may include individual files or all files in a directory in the
17708 configuration file.
17709
17710 Defaults to @samp{()}.
17711
17712 @end deftypevr
17713
17714 @c %end of fragment
17715
17716 @subsubheading Zabbix agent
17717 @cindex zabbix zabbix-agent
17718
17719 Zabbix agent gathers information for Zabbix server.
17720
17721 @c %start of fragment
17722
17723 Available @code{zabbix-agent-configuration} fields are:
17724
17725 @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
17726 The zabbix-agent package.
17727
17728 @end deftypevr
17729
17730 @deftypevr {@code{zabbix-agent-configuration} parameter} string user
17731 User who will run the Zabbix agent.
17732
17733 Defaults to @samp{"zabbix"}.
17734
17735 @end deftypevr
17736
17737 @deftypevr {@code{zabbix-agent-configuration} parameter} group group
17738 Group who will run the Zabbix agent.
17739
17740 Defaults to @samp{"zabbix"}.
17741
17742 @end deftypevr
17743
17744 @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
17745 Unique, case sensitive hostname which is required for active checks and
17746 must match hostname as configured on the server.
17747
17748 Defaults to @samp{"Zabbix server"}.
17749
17750 @end deftypevr
17751
17752 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
17753 Specifies where log messages are written to:
17754
17755 @itemize @bullet
17756 @item
17757 @code{system} - syslog.
17758
17759 @item
17760 @code{file} - file specified with @code{log-file} parameter.
17761
17762 @item
17763 @code{console} - standard output.
17764
17765 @end itemize
17766
17767 Defaults to @samp{""}.
17768
17769 @end deftypevr
17770
17771 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
17772 Log file name for @code{log-type} @code{file} parameter.
17773
17774 Defaults to @samp{"/var/log/zabbix/agent.log"}.
17775
17776 @end deftypevr
17777
17778 @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
17779 Name of PID file.
17780
17781 Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
17782
17783 @end deftypevr
17784
17785 @deftypevr {@code{zabbix-agent-configuration} parameter} list server
17786 List of IP addresses, optionally in CIDR notation, or hostnames of
17787 Zabbix servers and Zabbix proxies. Incoming connections will be
17788 accepted only from the hosts listed here.
17789
17790 Defaults to @samp{("127.0.0.1")}.
17791
17792 @end deftypevr
17793
17794 @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
17795 List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
17796 proxies for active checks. If port is not specified, default port is
17797 used. If this parameter is not specified, active checks are disabled.
17798
17799 Defaults to @samp{("127.0.0.1")}.
17800
17801 @end deftypevr
17802
17803 @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
17804 Extra options will be appended to Zabbix server configuration file.
17805
17806 Defaults to @samp{""}.
17807
17808 @end deftypevr
17809
17810 @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
17811 You may include individual files or all files in a directory in the
17812 configuration file.
17813
17814 Defaults to @samp{()}.
17815
17816 @end deftypevr
17817
17818 @c %end of fragment
17819
17820 @subsubheading Zabbix front-end
17821 @cindex zabbix zabbix-front-end
17822
17823 This service provides a WEB interface to Zabbix server.
17824
17825 @c %start of fragment
17826
17827 Available @code{zabbix-front-end-configuration} fields are:
17828
17829 @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
17830 NGINX configuration.
17831
17832 @end deftypevr
17833
17834 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
17835 Database host name.
17836
17837 Defaults to @samp{"localhost"}.
17838
17839 @end deftypevr
17840
17841 @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
17842 Database port.
17843
17844 Defaults to @samp{5432}.
17845
17846 @end deftypevr
17847
17848 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
17849 Database name.
17850
17851 Defaults to @samp{"zabbix"}.
17852
17853 @end deftypevr
17854
17855 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
17856 Database user.
17857
17858 Defaults to @samp{"zabbix"}.
17859
17860 @end deftypevr
17861
17862 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
17863 Database password. Please, use @code{db-secret-file} instead.
17864
17865 Defaults to @samp{""}.
17866
17867 @end deftypevr
17868
17869 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
17870 Secret file which will be appended to @file{zabbix.conf.php} file. This
17871 file contains credentials for use by Zabbix front-end. You are expected
17872 to create it manually.
17873
17874 Defaults to @samp{""}.
17875
17876 @end deftypevr
17877
17878 @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
17879 Zabbix server hostname.
17880
17881 Defaults to @samp{"localhost"}.
17882
17883 @end deftypevr
17884
17885 @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
17886 Zabbix server port.
17887
17888 Defaults to @samp{10051}.
17889
17890 @end deftypevr
17891
17892
17893 @c %end of fragment
17894
17895 @node Kerberos Services
17896 @subsection Kerberos Services
17897 @cindex Kerberos
17898
17899 The @code{(gnu services kerberos)} module provides services relating to
17900 the authentication protocol @dfn{Kerberos}.
17901
17902 @subsubheading Krb5 Service
17903
17904 Programs using a Kerberos client library normally
17905 expect a configuration file in @file{/etc/krb5.conf}.
17906 This service generates such a file from a definition provided in the
17907 operating system declaration.
17908 It does not cause any daemon to be started.
17909
17910 No ``keytab'' files are provided by this service---you must explicitly create them.
17911 This service is known to work with the MIT client library, @code{mit-krb5}.
17912 Other implementations have not been tested.
17913
17914 @defvr {Scheme Variable} krb5-service-type
17915 A service type for Kerberos 5 clients.
17916 @end defvr
17917
17918 @noindent
17919 Here is an example of its use:
17920 @lisp
17921 (service krb5-service-type
17922 (krb5-configuration
17923 (default-realm "EXAMPLE.COM")
17924 (allow-weak-crypto? #t)
17925 (realms (list
17926 (krb5-realm
17927 (name "EXAMPLE.COM")
17928 (admin-server "groucho.example.com")
17929 (kdc "karl.example.com"))
17930 (krb5-realm
17931 (name "ARGRX.EDU")
17932 (admin-server "kerb-admin.argrx.edu")
17933 (kdc "keys.argrx.edu"))))))
17934 @end lisp
17935
17936 @noindent
17937 This example provides a Kerberos@tie{}5 client configuration which:
17938 @itemize
17939 @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
17940 of which have distinct administration servers and key distribution centers;
17941 @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
17942 specified by clients;
17943 @item Accepts services which only support encryption types known to be weak.
17944 @end itemize
17945
17946 The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
17947 Only the most commonly used ones are described here.
17948 For a full list, and more detailed explanation of each, see the MIT
17949 @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
17950 documentation.
17951
17952
17953 @deftp {Data Type} krb5-realm
17954 @cindex realm, kerberos
17955 @table @asis
17956 @item @code{name}
17957 This field is a string identifying the name of the realm.
17958 A common convention is to use the fully qualified DNS name of your organization,
17959 converted to upper case.
17960
17961 @item @code{admin-server}
17962 This field is a string identifying the host where the administration server is
17963 running.
17964
17965 @item @code{kdc}
17966 This field is a string identifying the key distribution center
17967 for the realm.
17968 @end table
17969 @end deftp
17970
17971 @deftp {Data Type} krb5-configuration
17972
17973 @table @asis
17974 @item @code{allow-weak-crypto?} (default: @code{#f})
17975 If this flag is @code{#t} then services which only offer encryption algorithms
17976 known to be weak will be accepted.
17977
17978 @item @code{default-realm} (default: @code{#f})
17979 This field should be a string identifying the default Kerberos
17980 realm for the client.
17981 You should set this field to the name of your Kerberos realm.
17982 If this value is @code{#f}
17983 then a realm must be specified with every Kerberos principal when invoking programs
17984 such as @command{kinit}.
17985
17986 @item @code{realms}
17987 This should be a non-empty list of @code{krb5-realm} objects, which clients may
17988 access.
17989 Normally, one of them will have a @code{name} field matching the @code{default-realm}
17990 field.
17991 @end table
17992 @end deftp
17993
17994
17995 @subsubheading PAM krb5 Service
17996 @cindex pam-krb5
17997
17998 The @code{pam-krb5} service allows for login authentication and password
17999 management via Kerberos.
18000 You will need this service if you want PAM enabled applications to authenticate
18001 users using Kerberos.
18002
18003 @defvr {Scheme Variable} pam-krb5-service-type
18004 A service type for the Kerberos 5 PAM module.
18005 @end defvr
18006
18007 @deftp {Data Type} pam-krb5-configuration
18008 Data type representing the configuration of the Kerberos 5 PAM module
18009 This type has the following parameters:
18010 @table @asis
18011 @item @code{pam-krb5} (default: @code{pam-krb5})
18012 The pam-krb5 package to use.
18013
18014 @item @code{minimum-uid} (default: @code{1000})
18015 The smallest user ID for which Kerberos authentications should be attempted.
18016 Local accounts with lower values will silently fail to authenticate.
18017 @end table
18018 @end deftp
18019
18020
18021 @node LDAP Services
18022 @subsection LDAP Services
18023 @cindex LDAP
18024 @cindex nslcd, LDAP service
18025
18026 The @code{(gnu services authentication)} module provides the
18027 @code{nslcd-service-type}, which can be used to authenticate against an LDAP
18028 server. In addition to configuring the service itself, you may want to add
18029 @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
18030 Switch} for detailed information.
18031
18032 Here is a simple operating system declaration with a default configuration of
18033 the @code{nslcd-service-type} and a Name Service Switch configuration that
18034 consults the @code{ldap} name service last:
18035
18036 @example
18037 (use-service-modules authentication)
18038 (use-modules (gnu system nss))
18039 ...
18040 (operating-system
18041 ...
18042 (services
18043 (cons*
18044 (service nslcd-service-type)
18045 (service dhcp-client-service-type)
18046 %base-services))
18047 (name-service-switch
18048 (let ((services (list (name-service (name "db"))
18049 (name-service (name "files"))
18050 (name-service (name "ldap")))))
18051 (name-service-switch
18052 (inherit %mdns-host-lookup-nss)
18053 (password services)
18054 (shadow services)
18055 (group services)
18056 (netgroup services)
18057 (gshadow services)))))
18058 @end example
18059
18060 @c %start of generated documentation for nslcd-configuration
18061
18062 Available @code{nslcd-configuration} fields are:
18063
18064 @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
18065 The @code{nss-pam-ldapd} package to use.
18066
18067 @end deftypevr
18068
18069 @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
18070 The number of threads to start that can handle requests and perform LDAP
18071 queries. Each thread opens a separate connection to the LDAP server.
18072 The default is to start 5 threads.
18073
18074 Defaults to @samp{disabled}.
18075
18076 @end deftypevr
18077
18078 @deftypevr {@code{nslcd-configuration} parameter} string uid
18079 This specifies the user id with which the daemon should be run.
18080
18081 Defaults to @samp{"nslcd"}.
18082
18083 @end deftypevr
18084
18085 @deftypevr {@code{nslcd-configuration} parameter} string gid
18086 This specifies the group id with which the daemon should be run.
18087
18088 Defaults to @samp{"nslcd"}.
18089
18090 @end deftypevr
18091
18092 @deftypevr {@code{nslcd-configuration} parameter} log-option log
18093 This option controls the way logging is done via a list containing
18094 SCHEME and LEVEL. The SCHEME argument may either be the symbols "none"
18095 or "syslog", or an absolute file name. The LEVEL argument is optional
18096 and specifies the log level. The log level may be one of the following
18097 symbols: "crit", "error", "warning", "notice", "info" or "debug". All
18098 messages with the specified log level or higher are logged.
18099
18100 Defaults to @samp{("/var/log/nslcd" info)}.
18101
18102 @end deftypevr
18103
18104 @deftypevr {@code{nslcd-configuration} parameter} list uri
18105 The list of LDAP server URIs. Normally, only the first server will be
18106 used with the following servers as fall-back.
18107
18108 Defaults to @samp{("ldap://localhost:389/")}.
18109
18110 @end deftypevr
18111
18112 @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
18113 The version of the LDAP protocol to use. The default is to use the
18114 maximum version supported by the LDAP library.
18115
18116 Defaults to @samp{disabled}.
18117
18118 @end deftypevr
18119
18120 @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
18121 Specifies the distinguished name with which to bind to the directory
18122 server for lookups. The default is to bind anonymously.
18123
18124 Defaults to @samp{disabled}.
18125
18126 @end deftypevr
18127
18128 @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
18129 Specifies the credentials with which to bind. This option is only
18130 applicable when used with binddn.
18131
18132 Defaults to @samp{disabled}.
18133
18134 @end deftypevr
18135
18136 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
18137 Specifies the distinguished name to use when the root user tries to
18138 modify a user's password using the PAM module.
18139
18140 Defaults to @samp{disabled}.
18141
18142 @end deftypevr
18143
18144 @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
18145 Specifies the credentials with which to bind if the root user tries to
18146 change a user's password. This option is only applicable when used with
18147 rootpwmoddn
18148
18149 Defaults to @samp{disabled}.
18150
18151 @end deftypevr
18152
18153 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
18154 Specifies the SASL mechanism to be used when performing SASL
18155 authentication.
18156
18157 Defaults to @samp{disabled}.
18158
18159 @end deftypevr
18160
18161 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
18162 Specifies the SASL realm to be used when performing SASL authentication.
18163
18164 Defaults to @samp{disabled}.
18165
18166 @end deftypevr
18167
18168 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
18169 Specifies the authentication identity to be used when performing SASL
18170 authentication.
18171
18172 Defaults to @samp{disabled}.
18173
18174 @end deftypevr
18175
18176 @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
18177 Specifies the authorization identity to be used when performing SASL
18178 authentication.
18179
18180 Defaults to @samp{disabled}.
18181
18182 @end deftypevr
18183
18184 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
18185 Determines whether the LDAP server host name should be canonicalised. If
18186 this is enabled the LDAP library will do a reverse host name lookup. By
18187 default, it is left up to the LDAP library whether this check is
18188 performed or not.
18189
18190 Defaults to @samp{disabled}.
18191
18192 @end deftypevr
18193
18194 @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
18195 Set the name for the GSS-API Kerberos credentials cache.
18196
18197 Defaults to @samp{disabled}.
18198
18199 @end deftypevr
18200
18201 @deftypevr {@code{nslcd-configuration} parameter} string base
18202 The directory search base.
18203
18204 Defaults to @samp{"dc=example,dc=com"}.
18205
18206 @end deftypevr
18207
18208 @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
18209 Specifies the search scope (subtree, onelevel, base or children). The
18210 default scope is subtree; base scope is almost never useful for name
18211 service lookups; children scope is not supported on all servers.
18212
18213 Defaults to @samp{(subtree)}.
18214
18215 @end deftypevr
18216
18217 @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
18218 Specifies the policy for dereferencing aliases. The default policy is
18219 to never dereference aliases.
18220
18221 Defaults to @samp{disabled}.
18222
18223 @end deftypevr
18224
18225 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
18226 Specifies whether automatic referral chasing should be enabled. The
18227 default behaviour is to chase referrals.
18228
18229 Defaults to @samp{disabled}.
18230
18231 @end deftypevr
18232
18233 @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
18234 This option allows for custom attributes to be looked up instead of the
18235 default RFC 2307 attributes. It is a list of maps, each consisting of
18236 the name of a map, the RFC 2307 attribute to match and the query
18237 expression for the attribute as it is available in the directory.
18238
18239 Defaults to @samp{()}.
18240
18241 @end deftypevr
18242
18243 @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
18244 A list of filters consisting of the name of a map to which the filter
18245 applies and an LDAP search filter expression.
18246
18247 Defaults to @samp{()}.
18248
18249 @end deftypevr
18250
18251 @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
18252 Specifies the time limit in seconds to use when connecting to the
18253 directory server. The default value is 10 seconds.
18254
18255 Defaults to @samp{disabled}.
18256
18257 @end deftypevr
18258
18259 @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
18260 Specifies the time limit (in seconds) to wait for a response from the
18261 LDAP server. A value of zero, which is the default, is to wait
18262 indefinitely for searches to be completed.
18263
18264 Defaults to @samp{disabled}.
18265
18266 @end deftypevr
18267
18268 @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
18269 Specifies the period if inactivity (in seconds) after which the con‐
18270 nection to the LDAP server will be closed. The default is not to time
18271 out connections.
18272
18273 Defaults to @samp{disabled}.
18274
18275 @end deftypevr
18276
18277 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
18278 Specifies the number of seconds to sleep when connecting to all LDAP
18279 servers fails. By default one second is waited between the first
18280 failure and the first retry.
18281
18282 Defaults to @samp{disabled}.
18283
18284 @end deftypevr
18285
18286 @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
18287 Specifies the time after which the LDAP server is considered to be
18288 permanently unavailable. Once this time is reached retries will be done
18289 only once per this time period. The default value is 10 seconds.
18290
18291 Defaults to @samp{disabled}.
18292
18293 @end deftypevr
18294
18295 @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
18296 Specifies whether to use SSL/TLS or not (the default is not to). If
18297 'start-tls is specified then StartTLS is used rather than raw LDAP over
18298 SSL.
18299
18300 Defaults to @samp{disabled}.
18301
18302 @end deftypevr
18303
18304 @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
18305 Specifies what checks to perform on a server-supplied certificate. The
18306 meaning of the values is described in the ldap.conf(5) manual page.
18307
18308 Defaults to @samp{disabled}.
18309
18310 @end deftypevr
18311
18312 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
18313 Specifies the directory containing X.509 certificates for peer authen‐
18314 tication. This parameter is ignored when using GnuTLS.
18315
18316 Defaults to @samp{disabled}.
18317
18318 @end deftypevr
18319
18320 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
18321 Specifies the path to the X.509 certificate for peer authentication.
18322
18323 Defaults to @samp{disabled}.
18324
18325 @end deftypevr
18326
18327 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
18328 Specifies the path to an entropy source. This parameter is ignored when
18329 using GnuTLS.
18330
18331 Defaults to @samp{disabled}.
18332
18333 @end deftypevr
18334
18335 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
18336 Specifies the ciphers to use for TLS as a string.
18337
18338 Defaults to @samp{disabled}.
18339
18340 @end deftypevr
18341
18342 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
18343 Specifies the path to the file containing the local certificate for
18344 client TLS authentication.
18345
18346 Defaults to @samp{disabled}.
18347
18348 @end deftypevr
18349
18350 @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
18351 Specifies the path to the file containing the private key for client TLS
18352 authentication.
18353
18354 Defaults to @samp{disabled}.
18355
18356 @end deftypevr
18357
18358 @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
18359 Set this to a number greater than 0 to request paged results from the
18360 LDAP server in accordance with RFC2696. The default (0) is to not
18361 request paged results.
18362
18363 Defaults to @samp{disabled}.
18364
18365 @end deftypevr
18366
18367 @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
18368 This option prevents group membership lookups through LDAP for the
18369 specified users. Alternatively, the value 'all-local may be used. With
18370 that value nslcd builds a full list of non-LDAP users on startup.
18371
18372 Defaults to @samp{disabled}.
18373
18374 @end deftypevr
18375
18376 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
18377 This option ensures that LDAP users with a numeric user id lower than
18378 the specified value are ignored.
18379
18380 Defaults to @samp{disabled}.
18381
18382 @end deftypevr
18383
18384 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
18385 This option specifies an offset that is added to all LDAP numeric user
18386 ids. This can be used to avoid user id collisions with local users.
18387
18388 Defaults to @samp{disabled}.
18389
18390 @end deftypevr
18391
18392 @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
18393 This option specifies an offset that is added to all LDAP numeric group
18394 ids. This can be used to avoid user id collisions with local groups.
18395
18396 Defaults to @samp{disabled}.
18397
18398 @end deftypevr
18399
18400 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
18401 If this option is set, the member attribute of a group may point to
18402 another group. Members of nested groups are also returned in the higher
18403 level group and parent groups are returned when finding groups for a
18404 specific user. The default is not to perform extra searches for nested
18405 groups.
18406
18407 Defaults to @samp{disabled}.
18408
18409 @end deftypevr
18410
18411 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
18412 If this option is set, the group member list is not retrieved when
18413 looking up groups. Lookups for finding which groups a user belongs to
18414 will remain functional so the user will likely still get the correct
18415 groups assigned on login.
18416
18417 Defaults to @samp{disabled}.
18418
18419 @end deftypevr
18420
18421 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
18422 If this option is set, functions which cause all user/group entries to
18423 be loaded from the directory will not succeed in doing so. This can
18424 dramatically reduce LDAP server load in situations where there are a
18425 great number of users and/or groups. This option is not recommended for
18426 most configurations.
18427
18428 Defaults to @samp{disabled}.
18429
18430 @end deftypevr
18431
18432 @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
18433 This option can be used to specify how user and group names are verified
18434 within the system. This pattern is used to check all user and group
18435 names that are requested and returned from LDAP.
18436
18437 Defaults to @samp{disabled}.
18438
18439 @end deftypevr
18440
18441 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
18442 This specifies whether or not to perform searches using case-insensitive
18443 matching. Enabling this could open up the system to authorization
18444 bypass vulnerabilities and introduce nscd cache poisoning
18445 vulnerabilities which allow denial of service.
18446
18447 Defaults to @samp{disabled}.
18448
18449 @end deftypevr
18450
18451 @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
18452 This option specifies whether password policy controls are requested and
18453 handled from the LDAP server when performing user authentication.
18454
18455 Defaults to @samp{disabled}.
18456
18457 @end deftypevr
18458
18459 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
18460 By default nslcd performs an LDAP search with the user's credentials
18461 after BIND (authentication) to ensure that the BIND operation was
18462 successful. The default search is a simple check to see if the user's
18463 DN exists. A search filter can be specified that will be used instead.
18464 It should return at least one entry.
18465
18466 Defaults to @samp{disabled}.
18467
18468 @end deftypevr
18469
18470 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
18471 This option allows flexible fine tuning of the authorisation check that
18472 should be performed. The search filter specified is executed and if any
18473 entries match, access is granted, otherwise access is denied.
18474
18475 Defaults to @samp{disabled}.
18476
18477 @end deftypevr
18478
18479 @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
18480 If this option is set password modification using pam_ldap will be
18481 denied and the specified message will be presented to the user instead.
18482 The message can be used to direct the user to an alternative means of
18483 changing their password.
18484
18485 Defaults to @samp{disabled}.
18486
18487 @end deftypevr
18488
18489 @deftypevr {@code{nslcd-configuration} parameter} list pam-services
18490 List of pam service names for which LDAP authentication should suffice.
18491
18492 Defaults to @samp{()}.
18493
18494 @end deftypevr
18495
18496 @c %end of generated documentation for nslcd-configuration
18497
18498
18499 @node Web Services
18500 @subsection Web Services
18501
18502 @cindex web
18503 @cindex www
18504 @cindex HTTP
18505 The @code{(gnu services web)} module provides the Apache HTTP Server,
18506 the nginx web server, and also a fastcgi wrapper daemon.
18507
18508 @subsubheading Apache HTTP Server
18509
18510 @deffn {Scheme Variable} httpd-service-type
18511 Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
18512 (@dfn{httpd}). The value for this service type is a
18513 @code{httpd-configuration} record.
18514
18515 A simple example configuration is given below.
18516
18517 @example
18518 (service httpd-service-type
18519 (httpd-configuration
18520 (config
18521 (httpd-config-file
18522 (server-name "www.example.com")
18523 (document-root "/srv/http/www.example.com")))))
18524 @end example
18525
18526 Other services can also extend the @code{httpd-service-type} to add to
18527 the configuration.
18528
18529 @example
18530 (simple-service 'my-extra-server httpd-service-type
18531 (list
18532 (httpd-virtualhost
18533 "*:80"
18534 (list (string-append
18535 "ServerName "www.example.com
18536 DocumentRoot \"/srv/http/www.example.com\"")))))
18537 @end example
18538 @end deffn
18539
18540 The details for the @code{httpd-configuration}, @code{httpd-module},
18541 @code{httpd-config-file} and @code{httpd-virtualhost} record types are
18542 given below.
18543
18544 @deffn {Data Type} httpd-configuration
18545 This data type represents the configuration for the httpd service.
18546
18547 @table @asis
18548 @item @code{package} (default: @code{httpd})
18549 The httpd package to use.
18550
18551 @item @code{pid-file} (default: @code{"/var/run/httpd"})
18552 The pid file used by the shepherd-service.
18553
18554 @item @code{config} (default: @code{(httpd-config-file)})
18555 The configuration file to use with the httpd service. The default value
18556 is a @code{httpd-config-file} record, but this can also be a different
18557 G-expression that generates a file, for example a @code{plain-file}. A
18558 file outside of the store can also be specified through a string.
18559
18560 @end table
18561 @end deffn
18562
18563 @deffn {Data Type} httpd-module
18564 This data type represents a module for the httpd service.
18565
18566 @table @asis
18567 @item @code{name}
18568 The name of the module.
18569
18570 @item @code{file}
18571 The file for the module. This can be relative to the httpd package being
18572 used, the absolute location of a file, or a G-expression for a file
18573 within the store, for example @code{(file-append mod-wsgi
18574 "/modules/mod_wsgi.so")}.
18575
18576 @end table
18577 @end deffn
18578
18579 @defvr {Scheme Variable} %default-httpd-modules
18580 A default list of @code{httpd-module} objects.
18581 @end defvr
18582
18583 @deffn {Data Type} httpd-config-file
18584 This data type represents a configuration file for the httpd service.
18585
18586 @table @asis
18587 @item @code{modules} (default: @code{%default-httpd-modules})
18588 The modules to load. Additional modules can be added here, or loaded by
18589 additional configuration.
18590
18591 For example, in order to handle requests for PHP files, you can use Apache’s
18592 @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
18593
18594 @example
18595 (service httpd-service-type
18596 (httpd-configuration
18597 (config
18598 (httpd-config-file
18599 (modules (cons*
18600 (httpd-module
18601 (name "proxy_module")
18602 (file "modules/mod_proxy.so"))
18603 (httpd-module
18604 (name "proxy_fcgi_module")
18605 (file "modules/mod_proxy_fcgi.so"))
18606 %default-httpd-modules))
18607 (extra-config (list "\
18608 <FilesMatch \\.php$>
18609 SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
18610 </FilesMatch>"))))))
18611 (service php-fpm-service-type
18612 (php-fpm-configuration
18613 (socket "/var/run/php-fpm.sock")
18614 (socket-group "httpd")))
18615 @end example
18616
18617 @item @code{server-root} (default: @code{httpd})
18618 The @code{ServerRoot} in the configuration file, defaults to the httpd
18619 package. Directives including @code{Include} and @code{LoadModule} are
18620 taken as relative to the server root.
18621
18622 @item @code{server-name} (default: @code{#f})
18623 The @code{ServerName} in the configuration file, used to specify the
18624 request scheme, hostname and port that the server uses to identify
18625 itself.
18626
18627 This doesn't need to be set in the server config, and can be specifyed
18628 in virtual hosts. The default is @code{#f} to not specify a
18629 @code{ServerName}.
18630
18631 @item @code{document-root} (default: @code{"/srv/http"})
18632 The @code{DocumentRoot} from which files will be served.
18633
18634 @item @code{listen} (default: @code{'("80")})
18635 The list of values for the @code{Listen} directives in the config
18636 file. The value should be a list of strings, when each string can
18637 specify the port number to listen on, and optionally the IP address and
18638 protocol to use.
18639
18640 @item @code{pid-file} (default: @code{"/var/run/httpd"})
18641 The @code{PidFile} to use. This should match the @code{pid-file} set in
18642 the @code{httpd-configuration} so that the Shepherd service is
18643 configured correctly.
18644
18645 @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
18646 The @code{ErrorLog} to which the server will log errors.
18647
18648 @item @code{user} (default: @code{"httpd"})
18649 The @code{User} which the server will answer requests as.
18650
18651 @item @code{group} (default: @code{"httpd"})
18652 The @code{Group} which the server will answer requests as.
18653
18654 @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
18655 A flat list of strings and G-expressions which will be added to the end
18656 of the configuration file.
18657
18658 Any values which the service is extended with will be appended to this
18659 list.
18660
18661 @end table
18662 @end deffn
18663
18664 @deffn {Data Type} httpd-virtualhost
18665 This data type represents a virtualhost configuration block for the httpd service.
18666
18667 These should be added to the extra-config for the httpd-service.
18668
18669 @example
18670 (simple-service 'my-extra-server httpd-service-type
18671 (list
18672 (httpd-virtualhost
18673 "*:80"
18674 (list (string-append
18675 "ServerName "www.example.com
18676 DocumentRoot \"/srv/http/www.example.com\"")))))
18677 @end example
18678
18679 @table @asis
18680 @item @code{addresses-and-ports}
18681 The addresses and ports for the @code{VirtualHost} directive.
18682
18683 @item @code{contents}
18684 The contents of the @code{VirtualHost} directive, this should be a list
18685 of strings and G-expressions.
18686
18687 @end table
18688 @end deffn
18689
18690 @subsubheading NGINX
18691
18692 @deffn {Scheme Variable} nginx-service-type
18693 Service type for the @uref{https://nginx.org/,NGinx} web server. The
18694 value for this service type is a @code{<nginx-configuration>} record.
18695
18696 A simple example configuration is given below.
18697
18698 @example
18699 (service nginx-service-type
18700 (nginx-configuration
18701 (server-blocks
18702 (list (nginx-server-configuration
18703 (server-name '("www.example.com"))
18704 (root "/srv/http/www.example.com"))))))
18705 @end example
18706
18707 In addition to adding server blocks to the service configuration
18708 directly, this service can be extended by other services to add server
18709 blocks, as in this example:
18710
18711 @example
18712 (simple-service 'my-extra-server nginx-service-type
18713 (list (nginx-server-configuration
18714 (root "/srv/http/extra-website")
18715 (try-files (list "$uri" "$uri/index.html")))))
18716 @end example
18717 @end deffn
18718
18719 At startup, @command{nginx} has not yet read its configuration file, so
18720 it uses a default file to log error messages. If it fails to load its
18721 configuration file, that is where error messages are logged. After the
18722 configuration file is loaded, the default error log file changes as per
18723 configuration. In our case, startup error messages can be found in
18724 @file{/var/run/nginx/logs/error.log}, and after configuration in
18725 @file{/var/log/nginx/error.log}. The second location can be changed
18726 with the @var{log-directory} configuration option.
18727
18728 @deffn {Data Type} nginx-configuration
18729 This data type represents the configuration for NGinx. Some
18730 configuration can be done through this and the other provided record
18731 types, or alternatively, a config file can be provided.
18732
18733 @table @asis
18734 @item @code{nginx} (default: @code{nginx})
18735 The nginx package to use.
18736
18737 @item @code{log-directory} (default: @code{"/var/log/nginx"})
18738 The directory to which NGinx will write log files.
18739
18740 @item @code{run-directory} (default: @code{"/var/run/nginx"})
18741 The directory in which NGinx will create a pid file, and write temporary
18742 files.
18743
18744 @item @code{server-blocks} (default: @code{'()})
18745 A list of @dfn{server blocks} to create in the generated configuration
18746 file, the elements should be of type
18747 @code{<nginx-server-configuration>}.
18748
18749 The following example would setup NGinx to serve @code{www.example.com}
18750 from the @code{/srv/http/www.example.com} directory, without using
18751 HTTPS.
18752 @example
18753 (service nginx-service-type
18754 (nginx-configuration
18755 (server-blocks
18756 (list (nginx-server-configuration
18757 (server-name '("www.example.com"))
18758 (root "/srv/http/www.example.com"))))))
18759 @end example
18760
18761 @item @code{upstream-blocks} (default: @code{'()})
18762 A list of @dfn{upstream blocks} to create in the generated configuration
18763 file, the elements should be of type
18764 @code{<nginx-upstream-configuration>}.
18765
18766 Configuring upstreams through the @code{upstream-blocks} can be useful
18767 when combined with @code{locations} in the
18768 @code{<nginx-server-configuration>} records. The following example
18769 creates a server configuration with one location configuration, that
18770 will proxy requests to a upstream configuration, which will handle
18771 requests with two servers.
18772
18773 @example
18774 (service
18775 nginx-service-type
18776 (nginx-configuration
18777 (server-blocks
18778 (list (nginx-server-configuration
18779 (server-name '("www.example.com"))
18780 (root "/srv/http/www.example.com")
18781 (locations
18782 (list
18783 (nginx-location-configuration
18784 (uri "/path1")
18785 (body '("proxy_pass http://server-proxy;"))))))))
18786 (upstream-blocks
18787 (list (nginx-upstream-configuration
18788 (name "server-proxy")
18789 (servers (list "server1.example.com"
18790 "server2.example.com")))))))
18791 @end example
18792
18793 @item @code{file} (default: @code{#f})
18794 If a configuration @var{file} is provided, this will be used, rather than
18795 generating a configuration file from the provided @code{log-directory},
18796 @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
18797 proper operation, these arguments should match what is in @var{file} to ensure
18798 that the directories are created when the service is activated.
18799
18800 This can be useful if you have an existing configuration file, or it's
18801 not possible to do what is required through the other parts of the
18802 nginx-configuration record.
18803
18804 @item @code{server-names-hash-bucket-size} (default: @code{#f})
18805 Bucket size for the server names hash tables, defaults to @code{#f} to
18806 use the size of the processors cache line.
18807
18808 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
18809 Maximum bucket size for the server names hash tables.
18810
18811 @item @code{extra-content} (default: @code{""})
18812 Extra content for the @code{http} block. Should be string or a string
18813 valued G-expression.
18814
18815 @end table
18816 @end deffn
18817
18818 @deftp {Data Type} nginx-server-configuration
18819 Data type representing the configuration of an nginx server block.
18820 This type has the following parameters:
18821
18822 @table @asis
18823 @item @code{listen} (default: @code{'("80" "443 ssl")})
18824 Each @code{listen} directive sets the address and port for IP, or the
18825 path for a UNIX-domain socket on which the server will accept requests.
18826 Both address and port, or only address or only port can be specified.
18827 An address may also be a hostname, for example:
18828
18829 @example
18830 '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
18831 @end example
18832
18833 @item @code{server-name} (default: @code{(list 'default)})
18834 A list of server names this server represents. @code{'default} represents the
18835 default server for connections matching no other server.
18836
18837 @item @code{root} (default: @code{"/srv/http"})
18838 Root of the website nginx will serve.
18839
18840 @item @code{locations} (default: @code{'()})
18841 A list of @dfn{nginx-location-configuration} or
18842 @dfn{nginx-named-location-configuration} records to use within this
18843 server block.
18844
18845 @item @code{index} (default: @code{(list "index.html")})
18846 Index files to look for when clients ask for a directory. If it cannot be found,
18847 Nginx will send the list of files in the directory.
18848
18849 @item @code{try-files} (default: @code{'()})
18850 A list of files whose existence is checked in the specified order.
18851 @code{nginx} will use the first file it finds to process the request.
18852
18853 @item @code{ssl-certificate} (default: @code{#f})
18854 Where to find the certificate for secure connections. Set it to @code{#f} if
18855 you don't have a certificate or you don't want to use HTTPS.
18856
18857 @item @code{ssl-certificate-key} (default: @code{#f})
18858 Where to find the private key for secure connections. Set it to @code{#f} if
18859 you don't have a key or you don't want to use HTTPS.
18860
18861 @item @code{server-tokens?} (default: @code{#f})
18862 Whether the server should add its configuration to response.
18863
18864 @item @code{raw-content} (default: @code{'()})
18865 A list of raw lines added to the server block.
18866
18867 @end table
18868 @end deftp
18869
18870 @deftp {Data Type} nginx-upstream-configuration
18871 Data type representing the configuration of an nginx @code{upstream}
18872 block. This type has the following parameters:
18873
18874 @table @asis
18875 @item @code{name}
18876 Name for this group of servers.
18877
18878 @item @code{servers}
18879 Specify the addresses of the servers in the group. The address can be
18880 specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
18881 (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
18882 prefix @samp{unix:}. For addresses using an IP address or domain name,
18883 the default port is 80, and a different port can be specified
18884 explicitly.
18885
18886 @end table
18887 @end deftp
18888
18889 @deftp {Data Type} nginx-location-configuration
18890 Data type representing the configuration of an nginx @code{location}
18891 block. This type has the following parameters:
18892
18893 @table @asis
18894 @item @code{uri}
18895 URI which this location block matches.
18896
18897 @anchor{nginx-location-configuration body}
18898 @item @code{body}
18899 Body of the location block, specified as a list of strings. This can contain
18900 many
18901 configuration directives. For example, to pass requests to a upstream
18902 server group defined using an @code{nginx-upstream-configuration} block,
18903 the following directive would be specified in the body @samp{(list "proxy_pass
18904 http://upstream-name;")}.
18905
18906 @end table
18907 @end deftp
18908
18909 @deftp {Data Type} nginx-named-location-configuration
18910 Data type representing the configuration of an nginx named location
18911 block. Named location blocks are used for request redirection, and not
18912 used for regular request processing. This type has the following
18913 parameters:
18914
18915 @table @asis
18916 @item @code{name}
18917 Name to identify this location block.
18918
18919 @item @code{body}
18920 @xref{nginx-location-configuration body}, as the body for named location
18921 blocks can be used in a similar way to the
18922 @code{nginx-location-configuration body}. One restriction is that the
18923 body of a named location block cannot contain location blocks.
18924
18925 @end table
18926 @end deftp
18927
18928 @subsubheading Varnish Cache
18929 @cindex Varnish
18930 Varnish is a fast cache server that sits in between web applications
18931 and end users. It proxies requests from clients and caches the
18932 accessed URLs such that multiple requests for the same resource only
18933 creates one request to the back-end.
18934
18935 @defvr {Scheme Variable} varnish-service-type
18936 Service type for the Varnish daemon.
18937 @end defvr
18938
18939 @deftp {Data Type} varnish-configuration
18940 Data type representing the @code{varnish} service configuration.
18941 This type has the following parameters:
18942
18943 @table @asis
18944 @item @code{package} (default: @code{varnish})
18945 The Varnish package to use.
18946
18947 @item @code{name} (default: @code{"default"})
18948 A name for this Varnish instance. Varnish will create a directory in
18949 @file{/var/varnish/} with this name and keep temporary files there. If
18950 the name starts with a forward slash, it is interpreted as an absolute
18951 directory name.
18952
18953 Pass the @code{-n} argument to other Varnish programs to connect to the
18954 named instance, e.g.@: @command{varnishncsa -n default}.
18955
18956 @item @code{backend} (default: @code{"localhost:8080"})
18957 The backend to use. This option has no effect if @code{vcl} is set.
18958
18959 @item @code{vcl} (default: #f)
18960 The @dfn{VCL} (Varnish Configuration Language) program to run. If this
18961 is @code{#f}, Varnish will proxy @code{backend} using the default
18962 configuration. Otherwise this must be a file-like object with valid
18963 VCL syntax.
18964
18965 @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
18966 For example, to mirror @url{http://www.gnu.org,www.gnu.org} with VCL you
18967 can do something along these lines:
18968
18969 @example
18970 (define %gnu-mirror
18971 (plain-file
18972 "gnu.vcl"
18973 "vcl 4.1;
18974 backend gnu @{ .host = "www.gnu.org"; @}"))
18975
18976 (operating-system
18977 ...
18978 (services (cons (service varnish-service-type
18979 (varnish-configuration
18980 (listen '(":80"))
18981 (vcl %gnu-mirror)))
18982 %base-services)))
18983 @end example
18984
18985 The configuration of an already running Varnish instance can be inspected
18986 and changed using the @command{varnishadm} program.
18987
18988 Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
18989 @url{https://book.varnish-software.com/4.0/,Varnish Book} for
18990 comprehensive documentation on Varnish and its configuration language.
18991
18992 @item @code{listen} (default: @code{'("localhost:80")})
18993 List of addresses Varnish will listen on.
18994
18995 @item @code{storage} (default: @code{'("malloc,128m")})
18996 List of storage backends that will be available in VCL.
18997
18998 @item @code{parameters} (default: @code{'()})
18999 List of run-time parameters in the form @code{'(("parameter" . "value"))}.
19000
19001 @item @code{extra-options} (default: @code{'()})
19002 Additional arguments to pass to the @command{varnishd} process.
19003
19004 @end table
19005 @end deftp
19006
19007 @subsubheading FastCGI
19008 @cindex fastcgi
19009 @cindex fcgiwrap
19010 FastCGI is an interface between the front-end and the back-end of a web
19011 service. It is a somewhat legacy facility; new web services should
19012 generally just talk HTTP between the front-end and the back-end.
19013 However there are a number of back-end services such as PHP or the
19014 optimized HTTP Git repository access that use FastCGI, so we have
19015 support for it in Guix.
19016
19017 To use FastCGI, you configure the front-end web server (e.g., nginx) to
19018 dispatch some subset of its requests to the fastcgi backend, which
19019 listens on a local TCP or UNIX socket. There is an intermediary
19020 @code{fcgiwrap} program that sits between the actual backend process and
19021 the web server. The front-end indicates which backend program to run,
19022 passing that information to the @code{fcgiwrap} process.
19023
19024 @defvr {Scheme Variable} fcgiwrap-service-type
19025 A service type for the @code{fcgiwrap} FastCGI proxy.
19026 @end defvr
19027
19028 @deftp {Data Type} fcgiwrap-configuration
19029 Data type representing the configuration of the @code{fcgiwrap} service.
19030 This type has the following parameters:
19031 @table @asis
19032 @item @code{package} (default: @code{fcgiwrap})
19033 The fcgiwrap package to use.
19034
19035 @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
19036 The socket on which the @code{fcgiwrap} process should listen, as a
19037 string. Valid @var{socket} values include
19038 @code{unix:@var{/path/to/unix/socket}},
19039 @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
19040 @code{tcp6:[@var{ipv6_addr}]:port}.
19041
19042 @item @code{user} (default: @code{fcgiwrap})
19043 @itemx @code{group} (default: @code{fcgiwrap})
19044 The user and group names, as strings, under which to run the
19045 @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
19046 the user asks for the specific user or group names @code{fcgiwrap} that
19047 the corresponding user and/or group is present on the system.
19048
19049 It is possible to configure a FastCGI-backed web service to pass HTTP
19050 authentication information from the front-end to the back-end, and to
19051 allow @code{fcgiwrap} to run the back-end process as a corresponding
19052 local user. To enable this capability on the back-end., run
19053 @code{fcgiwrap} as the @code{root} user and group. Note that this
19054 capability also has to be configured on the front-end as well.
19055 @end table
19056 @end deftp
19057
19058 @cindex php-fpm
19059 PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
19060 with some additional features useful for sites of any size.
19061
19062 These features include:
19063 @itemize @bullet
19064 @item Adaptive process spawning
19065 @item Basic statistics (similar to Apache's mod_status)
19066 @item Advanced process management with graceful stop/start
19067 @item Ability to start workers with different uid/gid/chroot/environment
19068 and different php.ini (replaces safe_mode)
19069 @item Stdout & stderr logging
19070 @item Emergency restart in case of accidental opcode cache destruction
19071 @item Accelerated upload support
19072 @item Support for a "slowlog"
19073 @item Enhancements to FastCGI, such as fastcgi_finish_request() -
19074 a special function to finish request & flush all data while continuing to do
19075 something time-consuming (video converting, stats processing, etc.)
19076 @end itemize
19077 ...@: and much more.
19078
19079 @defvr {Scheme Variable} php-fpm-service-type
19080 A Service type for @code{php-fpm}.
19081 @end defvr
19082
19083 @deftp {Data Type} php-fpm-configuration
19084 Data Type for php-fpm service configuration.
19085 @table @asis
19086 @item @code{php} (default: @code{php})
19087 The php package to use.
19088 @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
19089 The address on which to accept FastCGI requests. Valid syntaxes are:
19090 @table @asis
19091 @item @code{"ip.add.re.ss:port"}
19092 Listen on a TCP socket to a specific address on a specific port.
19093 @item @code{"port"}
19094 Listen on a TCP socket to all addresses on a specific port.
19095 @item @code{"/path/to/unix/socket"}
19096 Listen on a unix socket.
19097 @end table
19098
19099 @item @code{user} (default: @code{php-fpm})
19100 User who will own the php worker processes.
19101 @item @code{group} (default: @code{php-fpm})
19102 Group of the worker processes.
19103 @item @code{socket-user} (default: @code{php-fpm})
19104 User who can speak to the php-fpm socket.
19105 @item @code{socket-group} (default: @code{php-fpm})
19106 Group that can speak to the php-fpm socket.
19107 @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
19108 The process id of the php-fpm process is written to this file
19109 once the service has started.
19110 @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
19111 Log for the php-fpm master process.
19112 @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
19113 Detailed settings for the php-fpm process manager.
19114 Must be either:
19115 @table @asis
19116 @item @code{<php-fpm-dynamic-process-manager-configuration>}
19117 @item @code{<php-fpm-static-process-manager-configuration>}
19118 @item @code{<php-fpm-on-demand-process-manager-configuration>}
19119 @end table
19120 @item @code{display-errors} (default @code{#f})
19121 Determines whether php errors and warning should be sent to clients
19122 and displayed in their browsers.
19123 This is useful for local php development, but a security risk for public sites,
19124 as error messages can reveal passwords and personal data.
19125 @item @code{timezone} (default @code{#f})
19126 Specifies @code{php_admin_value[date.timezone]} parameter.
19127 @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
19128 This file will log the @code{stderr} outputs of php worker processes.
19129 Can be set to @code{#f} to disable logging.
19130 @item @code{file} (default @code{#f})
19131 An optional override of the whole configuration.
19132 You can use the @code{mixed-text-file} function or an absolute filepath for it.
19133 @end table
19134 @end deftp
19135
19136 @deftp {Data type} php-fpm-dynamic-process-manager-configuration
19137 Data Type for the @code{dynamic} php-fpm process manager. With the
19138 @code{dynamic} process manager, spare worker processes are kept around
19139 based on it's configured limits.
19140 @table @asis
19141 @item @code{max-children} (default: @code{5})
19142 Maximum of worker processes.
19143 @item @code{start-servers} (default: @code{2})
19144 How many worker processes should be started on start-up.
19145 @item @code{min-spare-servers} (default: @code{1})
19146 How many spare worker processes should be kept around at minimum.
19147 @item @code{max-spare-servers} (default: @code{3})
19148 How many spare worker processes should be kept around at maximum.
19149 @end table
19150 @end deftp
19151
19152 @deftp {Data type} php-fpm-static-process-manager-configuration
19153 Data Type for the @code{static} php-fpm process manager. With the
19154 @code{static} process manager, an unchanging number of worker processes
19155 are created.
19156 @table @asis
19157 @item @code{max-children} (default: @code{5})
19158 Maximum of worker processes.
19159 @end table
19160 @end deftp
19161
19162 @deftp {Data type} php-fpm-on-demand-process-manager-configuration
19163 Data Type for the @code{on-demand} php-fpm process manager. With the
19164 @code{on-demand} process manager, worker processes are only created as
19165 requests arrive.
19166 @table @asis
19167 @item @code{max-children} (default: @code{5})
19168 Maximum of worker processes.
19169 @item @code{process-idle-timeout} (default: @code{10})
19170 The time in seconds after which a process with no requests is killed.
19171 @end table
19172 @end deftp
19173
19174
19175 @deffn {Scheme Procedure} nginx-php-fpm-location @
19176 [#:nginx-package nginx] @
19177 [socket (string-append "/var/run/php" @
19178 (version-major (package-version php)) @
19179 "-fpm.sock")]
19180 A helper function to quickly add php to an @code{nginx-server-configuration}.
19181 @end deffn
19182
19183 A simple services setup for nginx with php can look like this:
19184 @example
19185 (services (cons* (service dhcp-client-service-type)
19186 (service php-fpm-service-type)
19187 (service nginx-service-type
19188 (nginx-server-configuration
19189 (server-name '("example.com"))
19190 (root "/srv/http/")
19191 (locations
19192 (list (nginx-php-location)))
19193 (listen '("80"))
19194 (ssl-certificate #f)
19195 (ssl-certificate-key #f)))
19196 %base-services))
19197 @end example
19198
19199 @cindex cat-avatar-generator
19200 The cat avatar generator is a simple service to demonstrate the use of php-fpm
19201 in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
19202 the hash of a user's email address.
19203
19204 @deffn {Scheme Procedure} cat-avatar-generator-service @
19205 [#:cache-dir "/var/cache/cat-avatar-generator"] @
19206 [#:package cat-avatar-generator] @
19207 [#:configuration (nginx-server-configuration)]
19208 Returns an nginx-server-configuration that inherits @code{configuration}. It
19209 extends the nginx configuration to add a server block that serves @code{package},
19210 a version of cat-avatar-generator. During execution, cat-avatar-generator will
19211 be able to use @code{cache-dir} as its cache directory.
19212 @end deffn
19213
19214 A simple setup for cat-avatar-generator can look like this:
19215 @example
19216 (services (cons* (cat-avatar-generator-service
19217 #:configuration
19218 (nginx-server-configuration
19219 (server-name '("example.com"))))
19220 ...
19221 %base-services))
19222 @end example
19223
19224 @subsubheading Hpcguix-web
19225
19226 @cindex hpcguix-web
19227 The @uref{hpcguix-web, https://github.com/UMCUGenetics/hpcguix-web/}
19228 program is a customizable web interface to browse Guix packages,
19229 initially designed for users of high-performance computing (HPC)
19230 clusters.
19231
19232 @defvr {Scheme Variable} hpcguix-web-service-type
19233 The service type for @code{hpcguix-web}.
19234 @end defvr
19235
19236 @deftp {Data Type} hpcguix-web-configuration
19237 Data type for the hpcguix-web service configuration.
19238
19239 @table @asis
19240 @item @code{specs}
19241 A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
19242 configuration. The main items available in this spec are:
19243
19244 @table @asis
19245 @item @code{title-prefix} (default: @code{"hpcguix | "})
19246 The page title prefix.
19247
19248 @item @code{guix-command} (default: @code{"guix"})
19249 The @command{guix} command.
19250
19251 @item @code{package-filter-proc} (default: @code{(const #t)})
19252 A procedure specifying how to filter packages that are displayed.
19253
19254 @item @code{package-page-extension-proc} (default: @code{(const '())})
19255 Extension package for @code{hpcguix-web}.
19256
19257 @item @code{menu} (default: @code{'()})
19258 Additional entry in page @code{menu}.
19259
19260 @item @code{channels} (default: @code{%default-channels})
19261 List of channels from which the package list is built (@pxref{Channels}).
19262
19263 @item @code{package-list-expiration} (default: @code{(* 12 3600)})
19264 The expiration time, in seconds, after which the package list is rebuilt from
19265 the latest instances of the given channels.
19266 @end table
19267
19268 See the hpcguix-web repository for a
19269 @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
19270 complete example}.
19271
19272 @item @code{package} (default: @code{hpcguix-web})
19273 The hpcguix-web package to use.
19274 @end table
19275 @end deftp
19276
19277 A typical hpcguix-web service declaration looks like this:
19278
19279 @example
19280 (service hpcguix-web-service-type
19281 (hpcguix-web-configuration
19282 (specs
19283 #~(define site-config
19284 (hpcweb-configuration
19285 (title-prefix "Guix-HPC - ")
19286 (menu '(("/about" "ABOUT"))))))))
19287 @end example
19288
19289 @quotation Note
19290 The hpcguix-web service periodically updates the package list it publishes by
19291 pulling channels from Git. To that end, it needs to access X.509 certificates
19292 so that it can authenticate Git servers when communicating over HTTPS, and it
19293 assumes that @file{/etc/ssl/certs} contains those certificates.
19294
19295 Thus, make sure to add @code{nss-certs} or another certificate package to the
19296 @code{packages} field of your configuration. @ref{X.509 Certificates}, for
19297 more information on X.509 certificates.
19298 @end quotation
19299
19300 @node Certificate Services
19301 @subsection Certificate Services
19302
19303 @cindex Web
19304 @cindex HTTP, HTTPS
19305 @cindex Let's Encrypt
19306 @cindex TLS certificates
19307 The @code{(gnu services certbot)} module provides a service to
19308 automatically obtain a valid TLS certificate from the Let's Encrypt
19309 certificate authority. These certificates can then be used to serve
19310 content securely over HTTPS or other TLS-based protocols, with the
19311 knowledge that the client will be able to verify the server's
19312 authenticity.
19313
19314 @url{https://letsencrypt.org/, Let's Encrypt} provides the
19315 @code{certbot} tool to automate the certification process. This tool
19316 first securely generates a key on the server. It then makes a request
19317 to the Let's Encrypt certificate authority (CA) to sign the key. The CA
19318 checks that the request originates from the host in question by using a
19319 challenge-response protocol, requiring the server to provide its
19320 response over HTTP. If that protocol completes successfully, the CA
19321 signs the key, resulting in a certificate. That certificate is valid
19322 for a limited period of time, and therefore to continue to provide TLS
19323 services, the server needs to periodically ask the CA to renew its
19324 signature.
19325
19326 The certbot service automates this process: the initial key
19327 generation, the initial certification request to the Let's Encrypt
19328 service, the web server challenge/response integration, writing the
19329 certificate to disk, the automated periodic renewals, and the deployment
19330 tasks associated with the renewal (e.g.@: reloading services, copying keys
19331 with different permissions).
19332
19333 Certbot is run twice a day, at a random minute within the hour. It
19334 won't do anything until your certificates are due for renewal or
19335 revoked, but running it regularly would give your service a chance of
19336 staying online in case a Let's Encrypt-initiated revocation happened for
19337 some reason.
19338
19339 By using this service, you agree to the ACME Subscriber Agreement, which
19340 can be found there:
19341 @url{https://acme-v01.api.letsencrypt.org/directory}.
19342
19343 @defvr {Scheme Variable} certbot-service-type
19344 A service type for the @code{certbot} Let's Encrypt client. Its value
19345 must be a @code{certbot-configuration} record as in this example:
19346
19347 @example
19348 (define %nginx-deploy-hook
19349 (program-file
19350 "nginx-deploy-hook"
19351 #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
19352 (kill pid SIGHUP))))
19353
19354 (service certbot-service-type
19355 (certbot-configuration
19356 (email "foo@@example.net")
19357 (certificates
19358 (list
19359 (certificate-configuration
19360 (domains '("example.net" "www.example.net"))
19361 (deploy-hook %nginx-deploy-hook))
19362 (certificate-configuration
19363 (domains '("bar.example.net")))))))
19364 @end example
19365
19366 See below for details about @code{certbot-configuration}.
19367 @end defvr
19368
19369 @deftp {Data Type} certbot-configuration
19370 Data type representing the configuration of the @code{certbot} service.
19371 This type has the following parameters:
19372
19373 @table @asis
19374 @item @code{package} (default: @code{certbot})
19375 The certbot package to use.
19376
19377 @item @code{webroot} (default: @code{/var/www})
19378 The directory from which to serve the Let's Encrypt challenge/response
19379 files.
19380
19381 @item @code{certificates} (default: @code{()})
19382 A list of @code{certificates-configuration}s for which to generate
19383 certificates and request signatures. Each certificate has a @code{name}
19384 and several @code{domains}.
19385
19386 @item @code{email}
19387 Mandatory email used for registration, recovery contact, and important
19388 account notifications.
19389
19390 @item @code{rsa-key-size} (default: @code{2048})
19391 Size of the RSA key.
19392
19393 @item @code{default-location} (default: @i{see below})
19394 The default @code{nginx-location-configuration}. Because @code{certbot}
19395 needs to be able to serve challenges and responses, it needs to be able
19396 to run a web server. It does so by extending the @code{nginx} web
19397 service with an @code{nginx-server-configuration} listening on the
19398 @var{domains} on port 80, and which has a
19399 @code{nginx-location-configuration} for the @code{/.well-known/} URI
19400 path subspace used by Let's Encrypt. @xref{Web Services}, for more on
19401 these nginx configuration data types.
19402
19403 Requests to other URL paths will be matched by the
19404 @code{default-location}, which if present is added to all
19405 @code{nginx-server-configuration}s.
19406
19407 By default, the @code{default-location} will issue a redirect from
19408 @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
19409 you to define what to serve on your site via @code{https}.
19410
19411 Pass @code{#f} to not issue a default location.
19412 @end table
19413 @end deftp
19414
19415 @deftp {Data Type} certificate-configuration
19416 Data type representing the configuration of a certificate.
19417 This type has the following parameters:
19418
19419 @table @asis
19420 @item @code{name} (default: @i{see below})
19421 This name is used by Certbot for housekeeping and in file paths; it
19422 doesn't affect the content of the certificate itself. To see
19423 certificate names, run @code{certbot certificates}.
19424
19425 Its default is the first provided domain.
19426
19427 @item @code{domains} (default: @code{()})
19428 The first domain provided will be the subject CN of the certificate, and
19429 all domains will be Subject Alternative Names on the certificate.
19430
19431 @item @code{challenge} (default: @code{#f})
19432 The challenge type that has to be run by certbot. If @code{#f} is specified,
19433 default to the HTTP challenge. If a value is specified, defaults to the
19434 manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
19435 the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}).
19436
19437 @item @code{authentication-hook} (default: @code{#f})
19438 Command to be run in a shell once for each certificate challenge to be
19439 answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
19440 will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
19441 contains the validation string and @code{$CERTBOT_TOKEN} contains the
19442 file name of the resource requested when performing an HTTP-01 challenge.
19443
19444 @item @code{cleanup-hook} (default: @code{#f})
19445 Command to be run in a shell once for each certificate challenge that
19446 have been answered by the @code{auth-hook}. For this command, the shell
19447 variables available in the @code{auth-hook} script are still available, and
19448 additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
19449 of the @code{auth-hook} script.
19450
19451 @item @code{deploy-hook} (default: @code{#f})
19452 Command to be run in a shell once for each successfully issued
19453 certificate. For this command, the shell variable
19454 @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
19455 example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
19456 certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
19457 contain a space-delimited list of renewed certificate domains (for
19458 example, @samp{"example.com www.example.com"}.
19459
19460 @end table
19461 @end deftp
19462
19463 For each @code{certificate-configuration}, the certificate is saved to
19464 @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
19465 saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
19466 @node DNS Services
19467 @subsection DNS Services
19468 @cindex DNS (domain name system)
19469 @cindex domain name system (DNS)
19470
19471 The @code{(gnu services dns)} module provides services related to the
19472 @dfn{domain name system} (DNS). It provides a server service for hosting
19473 an @emph{authoritative} DNS server for multiple zones, slave or master.
19474 This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
19475 caching and forwarding DNS server for the LAN, which uses
19476 @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
19477
19478 @subsubheading Knot Service
19479
19480 An example configuration of an authoritative server for two zones, one master
19481 and one slave, is:
19482
19483 @lisp
19484 (define-zone-entries example.org.zone
19485 ;; Name TTL Class Type Data
19486 ("@@" "" "IN" "A" "127.0.0.1")
19487 ("@@" "" "IN" "NS" "ns")
19488 ("ns" "" "IN" "A" "127.0.0.1"))
19489
19490 (define master-zone
19491 (knot-zone-configuration
19492 (domain "example.org")
19493 (zone (zone-file
19494 (origin "example.org")
19495 (entries example.org.zone)))))
19496
19497 (define slave-zone
19498 (knot-zone-configuration
19499 (domain "plop.org")
19500 (dnssec-policy "default")
19501 (master (list "plop-master"))))
19502
19503 (define plop-master
19504 (knot-remote-configuration
19505 (id "plop-master")
19506 (address (list "208.76.58.171"))))
19507
19508 (operating-system
19509 ;; ...
19510 (services (cons* (service knot-service-type
19511 (knot-configuration
19512 (remotes (list plop-master))
19513 (zones (list master-zone slave-zone))))
19514 ;; ...
19515 %base-services)))
19516 @end lisp
19517
19518 @deffn {Scheme Variable} knot-service-type
19519 This is the type for the Knot DNS server.
19520
19521 Knot DNS is an authoritative DNS server, meaning that it can serve multiple
19522 zones, that is to say domain names you would buy from a registrar. This server
19523 is not a resolver, meaning that it can only resolve names for which it is
19524 authoritative. This server can be configured to serve zones as a master server
19525 or a slave server as a per-zone basis. Slave zones will get their data from
19526 masters, and will serve it as an authoritative server. From the point of view
19527 of a resolver, there is no difference between master and slave.
19528
19529 The following data types are used to configure the Knot DNS server:
19530 @end deffn
19531
19532 @deftp {Data Type} knot-key-configuration
19533 Data type representing a key.
19534 This type has the following parameters:
19535
19536 @table @asis
19537 @item @code{id} (default: @code{""})
19538 An identifier for other configuration fields to refer to this key. IDs must
19539 be unique and must not be empty.
19540
19541 @item @code{algorithm} (default: @code{#f})
19542 The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
19543 @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
19544 and @code{'hmac-sha512}.
19545
19546 @item @code{secret} (default: @code{""})
19547 The secret key itself.
19548
19549 @end table
19550 @end deftp
19551
19552 @deftp {Data Type} knot-acl-configuration
19553 Data type representing an Access Control List (ACL) configuration.
19554 This type has the following parameters:
19555
19556 @table @asis
19557 @item @code{id} (default: @code{""})
19558 An identifier for ether configuration fields to refer to this key. IDs must be
19559 unique and must not be empty.
19560
19561 @item @code{address} (default: @code{'()})
19562 An ordered list of IP addresses, network subnets, or network ranges represented
19563 with strings. The query must match one of them. Empty value means that
19564 address match is not required.
19565
19566 @item @code{key} (default: @code{'()})
19567 An ordered list of references to keys represented with strings. The string
19568 must match a key ID defined in a @code{knot-key-configuration}. No key means
19569 that a key is not require to match that ACL.
19570
19571 @item @code{action} (default: @code{'()})
19572 An ordered list of actions that are permitted or forbidden by this ACL. Possible
19573 values are lists of zero or more elements from @code{'transfer}, @code{'notify}
19574 and @code{'update}.
19575
19576 @item @code{deny?} (default: @code{#f})
19577 When true, the ACL defines restrictions. Listed actions are forbidden. When
19578 false, listed actions are allowed.
19579
19580 @end table
19581 @end deftp
19582
19583 @deftp {Data Type} zone-entry
19584 Data type represnting a record entry in a zone file.
19585 This type has the following parameters:
19586
19587 @table @asis
19588 @item @code{name} (default: @code{"@@"})
19589 The name of the record. @code{"@@"} refers to the origin of the zone. Names
19590 are relative to the origin of the zone. For example, in the @code{example.org}
19591 zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
19592 Names ending with a dot are absolute, which means that @code{"ns.example.org."}
19593 refers to @code{ns.example.org}.
19594
19595 @item @code{ttl} (default: @code{""})
19596 The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
19597
19598 @item @code{class} (default: @code{"IN"})
19599 The class of the record. Knot currently supports only @code{"IN"} and
19600 partially @code{"CH"}.
19601
19602 @item @code{type} (default: @code{"A"})
19603 The type of the record. Common types include A (IPv4 address), AAAA (IPv6
19604 address), NS (Name Server) and MX (Mail eXchange). Many other types are
19605 defined.
19606
19607 @item @code{data} (default: @code{""})
19608 The data contained in the record. For instance an IP address associated with
19609 an A record, or a domain name associated with an NS record. Remember that
19610 domain names are relative to the origin unless they end with a dot.
19611
19612 @end table
19613 @end deftp
19614
19615 @deftp {Data Type} zone-file
19616 Data type representing the content of a zone file.
19617 This type has the following parameters:
19618
19619 @table @asis
19620 @item @code{entries} (default: @code{'()})
19621 The list of entries. The SOA record is taken care of, so you don't need to
19622 put it in the list of entries. This list should probably contain an entry
19623 for your primary authoritative DNS server. Other than using a list of entries
19624 directly, you can use @code{define-zone-entries} to define a object containing
19625 the list of entries more easily, that you can later pass to the @code{entries}
19626 field of the @code{zone-file}.
19627
19628 @item @code{origin} (default: @code{""})
19629 The name of your zone. This parameter cannot be empty.
19630
19631 @item @code{ns} (default: @code{"ns"})
19632 The domain of your primary authoritative DNS server. The name is relative to
19633 the origin, unless it ends with a dot. It is mandatory that this primary
19634 DNS server corresponds to an NS record in the zone and that it is associated
19635 to an IP address in the list of entries.
19636
19637 @item @code{mail} (default: @code{"hostmaster"})
19638 An email address people can contact you at, as the owner of the zone. This
19639 is translated as @code{<mail>@@<origin>}.
19640
19641 @item @code{serial} (default: @code{1})
19642 The serial number of the zone. As this is used to keep track of changes by
19643 both slaves and resolvers, it is mandatory that it @emph{never} decreases.
19644 Always increment it when you make a change in your zone.
19645
19646 @item @code{refresh} (default: @code{(* 2 24 3600)})
19647 The frequency at which slaves will do a zone transfer. This value is a number
19648 of seconds. It can be computed by multiplications or with
19649 @code{(string->duration)}.
19650
19651 @item @code{retry} (default: @code{(* 15 60)})
19652 The period after which a slave will retry to contact its master when it fails
19653 to do so a first time.
19654
19655 @item @code{expiry} (default: @code{(* 14 24 3600)})
19656 Default TTL of records. Existing records are considered correct for at most
19657 this amount of time. After this period, resolvers will invalidate their cache
19658 and check again that it still exists.
19659
19660 @item @code{nx} (default: @code{3600})
19661 Default TTL of inexistant records. This delay is usually short because you want
19662 your new domains to reach everyone quickly.
19663
19664 @end table
19665 @end deftp
19666
19667 @deftp {Data Type} knot-remote-configuration
19668 Data type representing a remote configuration.
19669 This type has the following parameters:
19670
19671 @table @asis
19672 @item @code{id} (default: @code{""})
19673 An identifier for other configuration fields to refer to this remote. IDs must
19674 be unique and must not be empty.
19675
19676 @item @code{address} (default: @code{'()})
19677 An ordered list of destination IP addresses. Addresses are tried in sequence.
19678 An optional port can be given with the @@ separator. For instance:
19679 @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
19680
19681 @item @code{via} (default: @code{'()})
19682 An ordered list of source IP addresses. An empty list will have Knot choose
19683 an appropriate source IP. An optional port can be given with the @@ separator.
19684 The default is to choose at random.
19685
19686 @item @code{key} (default: @code{#f})
19687 A reference to a key, that is a string containing the identifier of a key
19688 defined in a @code{knot-key-configuration} field.
19689
19690 @end table
19691 @end deftp
19692
19693 @deftp {Data Type} knot-keystore-configuration
19694 Data type representing a keystore to hold dnssec keys.
19695 This type has the following parameters:
19696
19697 @table @asis
19698 @item @code{id} (default: @code{""})
19699 The id of the keystore. It must not be empty.
19700
19701 @item @code{backend} (default: @code{'pem})
19702 The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
19703
19704 @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
19705 The configuration string of the backend. An example for the PKCS#11 is:
19706 @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
19707 For the pem backend, the string reprensents a path in the file system.
19708
19709 @end table
19710 @end deftp
19711
19712 @deftp {Data Type} knot-policy-configuration
19713 Data type representing a dnssec policy. Knot DNS is able to automatically
19714 sign your zones. It can either generate and manage your keys automatically or
19715 use keys that you generate.
19716
19717 Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
19718 used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
19719 zone. In order to be trusted, the KSK needs to be present in the parent zone
19720 (usually a top-level domain). If your registrar supports dnssec, you will
19721 have to send them your KSK's hash so they can add a DS record in their zone.
19722 This is not automated and need to be done each time you change your KSK.
19723
19724 The policy also defines the lifetime of keys. Usually, ZSK can be changed
19725 easily and use weaker cryptographic functions (they use lower parameters) in
19726 order to sign records quickly, so they are changed often. The KSK however
19727 requires manual interaction with the registrar, so they are changed less often
19728 and use stronger parameters because they sign only one record.
19729
19730 This type has the following parameters:
19731
19732 @table @asis
19733 @item @code{id} (default: @code{""})
19734 The id of the policy. It must not be empty.
19735
19736 @item @code{keystore} (default: @code{"default"})
19737 A reference to a keystore, that is a string containing the identifier of a
19738 keystore defined in a @code{knot-keystore-configuration} field. The
19739 @code{"default"} identifier means the default keystore (a kasp database that
19740 was setup by this service).
19741
19742 @item @code{manual?} (default: @code{#f})
19743 Whether the key management is manual or automatic.
19744
19745 @item @code{single-type-signing?} (default: @code{#f})
19746 When @code{#t}, use the Single-Type Signing Scheme.
19747
19748 @item @code{algorithm} (default: @code{"ecdsap256sha256"})
19749 An algorithm of signing keys and issued signatures.
19750
19751 @item @code{ksk-size} (default: @code{256})
19752 The length of the KSK. Note that this value is correct for the default
19753 algorithm, but would be unsecure for other algorithms.
19754
19755 @item @code{zsk-size} (default: @code{256})
19756 The length of the ZSK. Note that this value is correct for the default
19757 algorithm, but would be unsecure for other algorithms.
19758
19759 @item @code{dnskey-ttl} (default: @code{'default})
19760 The TTL value for DNSKEY records added into zone apex. The special
19761 @code{'default} value means same as the zone SOA TTL.
19762
19763 @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
19764 The period between ZSK publication and the next rollover initiation.
19765
19766 @item @code{propagation-delay} (default: @code{(* 24 3600)})
19767 An extra delay added for each key rollover step. This value should be high
19768 enough to cover propagation of data from the master server to all slaves.
19769
19770 @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
19771 A validity period of newly issued signatures.
19772
19773 @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
19774 A period how long before a signature expiration the signature will be refreshed.
19775
19776 @item @code{nsec3?} (default: @code{#f})
19777 When @code{#t}, NSEC3 will be used instead of NSEC.
19778
19779 @item @code{nsec3-iterations} (default: @code{5})
19780 The number of additional times the hashing is performed.
19781
19782 @item @code{nsec3-salt-length} (default: @code{8})
19783 The length of a salt field in octets, which is appended to the original owner
19784 name before hashing.
19785
19786 @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
19787 The validity period of newly issued salt field.
19788
19789 @end table
19790 @end deftp
19791
19792 @deftp {Data Type} knot-zone-configuration
19793 Data type representing a zone served by Knot.
19794 This type has the following parameters:
19795
19796 @table @asis
19797 @item @code{domain} (default: @code{""})
19798 The domain served by this configuration. It must not be empty.
19799
19800 @item @code{file} (default: @code{""})
19801 The file where this zone is saved. This parameter is ignored by master zones.
19802 Empty means default location that depends on the domain name.
19803
19804 @item @code{zone} (default: @code{(zone-file)})
19805 The content of the zone file. This parameter is ignored by slave zones. It
19806 must contain a zone-file record.
19807
19808 @item @code{master} (default: @code{'()})
19809 A list of master remotes. When empty, this zone is a master. When set, this
19810 zone is a slave. This is a list of remotes identifiers.
19811
19812 @item @code{ddns-master} (default: @code{#f})
19813 The main master. When empty, it defaults to the first master in the list of
19814 masters.
19815
19816 @item @code{notify} (default: @code{'()})
19817 A list of slave remote identifiers.
19818
19819 @item @code{acl} (default: @code{'()})
19820 A list of acl identifiers.
19821
19822 @item @code{semantic-checks?} (default: @code{#f})
19823 When set, this adds more semantic checks to the zone.
19824
19825 @item @code{disable-any?} (default: @code{#f})
19826 When set, this forbids queries of the ANY type.
19827
19828 @item @code{zonefile-sync} (default: @code{0})
19829 The delay between a modification in memory and on disk. 0 means immediate
19830 synchronization.
19831
19832 @item @code{zonefile-load} (default: @code{#f})
19833 The way the zone file contents are applied during zone load. Possible values
19834 are:
19835
19836 @itemize
19837 @item @code{#f} for using the default value from Knot,
19838 @item @code{'none} for not using the zone file at all,
19839 @item @code{'difference} for computing the difference between already available
19840 contents and zone contents and applying it to the current zone contents,
19841 @item @code{'difference-no-serial} for the same as @code{'difference}, but
19842 ignoring the SOA serial in the zone file, while the server takes care of it
19843 automatically.
19844 @item @code{'whole} for loading zone contents from the zone file.
19845 @end itemize
19846
19847 @item @code{journal-content} (default: @code{#f})
19848 The way the journal is used to store zone and its changes. Possible values
19849 are @code{'none} to not use it at all, @code{'changes} to store changes and
19850 @code{'all} to store contents. @code{#f} does not set this option, so the
19851 default value from Knot is used.
19852
19853 @item @code{max-journal-usage} (default: @code{#f})
19854 The maximum size for the journal on disk. @code{#f} does not set this option,
19855 so the default value from Knot is used.
19856
19857 @item @code{max-journal-depth} (default: @code{#f})
19858 The maximum size of the history. @code{#f} does not set this option, so the
19859 default value from Knot is used.
19860
19861 @item @code{max-zone-size} (default: @code{#f})
19862 The maximum size of the zone file. This limit is enforced for incoming
19863 transfer and updates. @code{#f} does not set this option, so the default
19864 value from Knot is used.
19865
19866 @item @code{dnssec-policy} (default: @code{#f})
19867 A reference to a @code{knot-policy-configuration} record, or the special
19868 name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
19869 on this zone.
19870
19871 @item @code{serial-policy} (default: @code{'increment})
19872 A policy between @code{'increment} and @code{'unixtime}.
19873
19874 @end table
19875 @end deftp
19876
19877 @deftp {Data Type} knot-configuration
19878 Data type representing the Knot configuration.
19879 This type has the following parameters:
19880
19881 @table @asis
19882 @item @code{knot} (default: @code{knot})
19883 The Knot package.
19884
19885 @item @code{run-directory} (default: @code{"/var/run/knot"})
19886 The run directory. This directory will be used for pid file and sockets.
19887
19888 @item @code{includes} (default: @code{'()})
19889 A list of strings or file-like objects denoting other files that must be
19890 included at the top of the configuration file.
19891
19892 @cindex secrets, Knot service
19893 This can be used to manage secrets out-of-band. For example, secret
19894 keys may be stored in an out-of-band file not managed by Guix, and
19895 thus not visible in @file{/gnu/store}---e.g., you could store secret
19896 key configuration in @file{/etc/knot/secrets.conf} and add this file
19897 to the @code{includes} list.
19898
19899 It can also be used to add configuration not supported by this interface.
19900
19901 @item @code{listen-v4} (default: @code{"0.0.0.0"})
19902 An ip address on which to listen.
19903
19904 @item @code{listen-v6} (default: @code{"::"})
19905 An ip address on which to listen.
19906
19907 @item @code{listen-port} (default: @code{53})
19908 A port on which to listen.
19909
19910 @item @code{keys} (default: @code{'()})
19911 The list of knot-key-configuration used by this configuration.
19912
19913 @item @code{acls} (default: @code{'()})
19914 The list of knot-acl-configuration used by this configuration.
19915
19916 @item @code{remotes} (default: @code{'()})
19917 The list of knot-remote-configuration used by this configuration.
19918
19919 @item @code{zones} (default: @code{'()})
19920 The list of knot-zone-configuration used by this configuration.
19921
19922 @end table
19923 @end deftp
19924
19925 @subsubheading Dnsmasq Service
19926
19927 @deffn {Scheme Variable} dnsmasq-service-type
19928 This is the type of the dnsmasq service, whose value should be an
19929 @code{dnsmasq-configuration} object as in this example:
19930
19931 @example
19932 (service dnsmasq-service-type
19933 (dnsmasq-configuration
19934 (no-resolv? #t)
19935 (servers '("192.168.1.1"))))
19936 @end example
19937 @end deffn
19938
19939 @deftp {Data Type} dnsmasq-configuration
19940 Data type representing the configuration of dnsmasq.
19941
19942 @table @asis
19943 @item @code{package} (default: @var{dnsmasq})
19944 Package object of the dnsmasq server.
19945
19946 @item @code{no-hosts?} (default: @code{#f})
19947 When true, don't read the hostnames in /etc/hosts.
19948
19949 @item @code{port} (default: @code{53})
19950 The port to listen on. Setting this to zero completely disables DNS
19951 responses, leaving only DHCP and/or TFTP functions.
19952
19953 @item @code{local-service?} (default: @code{#t})
19954 Accept DNS queries only from hosts whose address is on a local subnet,
19955 ie a subnet for which an interface exists on the server.
19956
19957 @item @code{listen-addresses} (default: @code{'()})
19958 Listen on the given IP addresses.
19959
19960 @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
19961 The file to read the IP address of the upstream nameservers from.
19962
19963 @item @code{no-resolv?} (default: @code{#f})
19964 When true, don't read @var{resolv-file}.
19965
19966 @item @code{servers} (default: @code{'()})
19967 Specify IP address of upstream servers directly.
19968
19969 @item @code{cache-size} (default: @code{150})
19970 Set the size of dnsmasq's cache. Setting the cache size to zero
19971 disables caching.
19972
19973 @item @code{negative-cache?} (default: @code{#t})
19974 When false, disable negative caching.
19975
19976 @end table
19977 @end deftp
19978
19979 @subsubheading ddclient Service
19980
19981 @cindex ddclient
19982 The ddclient service described below runs the ddclient daemon, which takes
19983 care of automatically updating DNS entries for service providers such as
19984 @uref{https://dyn.com/dns/, Dyn}.
19985
19986 The following example show instantiates the service with its default
19987 configuration:
19988
19989 @example
19990 (service ddclient-service-type)
19991 @end example
19992
19993 Note that ddclient needs to access credentials that are stored in a
19994 @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
19995 @code{secret-file} below.) You are expected to create this file manually, in
19996 an ``out-of-band'' fashion (you @emph{could} make this file part of the
19997 service configuration, for instance by using @code{plain-file}, but it will be
19998 world-readable @i{via} @file{/gnu/store}.) See the examples in the
19999 @file{share/ddclient} directory of the @code{ddclient} package.
20000
20001 @c %start of fragment
20002
20003 Available @code{ddclient-configuration} fields are:
20004
20005 @deftypevr {@code{ddclient-configuration} parameter} package ddclient
20006 The ddclient package.
20007
20008 @end deftypevr
20009
20010 @deftypevr {@code{ddclient-configuration} parameter} integer daemon
20011 The period after which ddclient will retry to check IP and domain name.
20012
20013 Defaults to @samp{300}.
20014
20015 @end deftypevr
20016
20017 @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
20018 Use syslog for the output.
20019
20020 Defaults to @samp{#t}.
20021
20022 @end deftypevr
20023
20024 @deftypevr {@code{ddclient-configuration} parameter} string mail
20025 Mail to user.
20026
20027 Defaults to @samp{"root"}.
20028
20029 @end deftypevr
20030
20031 @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
20032 Mail failed update to user.
20033
20034 Defaults to @samp{"root"}.
20035
20036 @end deftypevr
20037
20038 @deftypevr {@code{ddclient-configuration} parameter} string pid
20039 The ddclient PID file.
20040
20041 Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
20042
20043 @end deftypevr
20044
20045 @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
20046 Enable SSL support.
20047
20048 Defaults to @samp{#t}.
20049
20050 @end deftypevr
20051
20052 @deftypevr {@code{ddclient-configuration} parameter} string user
20053 Specifies the user name or ID that is used when running ddclient
20054 program.
20055
20056 Defaults to @samp{"ddclient"}.
20057
20058 @end deftypevr
20059
20060 @deftypevr {@code{ddclient-configuration} parameter} string group
20061 Group of the user who will run the ddclient program.
20062
20063 Defaults to @samp{"ddclient"}.
20064
20065 @end deftypevr
20066
20067 @deftypevr {@code{ddclient-configuration} parameter} string secret-file
20068 Secret file which will be appended to @file{ddclient.conf} file. This
20069 file contains credentials for use by ddclient. You are expected to
20070 create it manually.
20071
20072 Defaults to @samp{"/etc/ddclient/secrets.conf"}.
20073
20074 @end deftypevr
20075
20076 @deftypevr {@code{ddclient-configuration} parameter} list extra-options
20077 Extra options will be appended to @file{ddclient.conf} file.
20078
20079 Defaults to @samp{()}.
20080
20081 @end deftypevr
20082
20083
20084 @c %end of fragment
20085
20086
20087 @node VPN Services
20088 @subsection VPN Services
20089 @cindex VPN (virtual private network)
20090 @cindex virtual private network (VPN)
20091
20092 The @code{(gnu services vpn)} module provides services related to
20093 @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
20094 your machine to connect to a VPN, and a @emph{servire} service for your machine
20095 to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
20096
20097 @deffn {Scheme Procedure} openvpn-client-service @
20098 [#:config (openvpn-client-configuration)]
20099
20100 Return a service that runs @command{openvpn}, a VPN daemon, as a client.
20101 @end deffn
20102
20103 @deffn {Scheme Procedure} openvpn-server-service @
20104 [#:config (openvpn-server-configuration)]
20105
20106 Return a service that runs @command{openvpn}, a VPN daemon, as a server.
20107
20108 Both can be run simultaneously.
20109 @end deffn
20110
20111 @c %automatically generated documentation
20112
20113 Available @code{openvpn-client-configuration} fields are:
20114
20115 @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
20116 The OpenVPN package.
20117
20118 @end deftypevr
20119
20120 @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
20121 The OpenVPN pid file.
20122
20123 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
20124
20125 @end deftypevr
20126
20127 @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
20128 The protocol (UDP or TCP) used to open a channel between clients and
20129 servers.
20130
20131 Defaults to @samp{udp}.
20132
20133 @end deftypevr
20134
20135 @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
20136 The device type used to represent the VPN connection.
20137
20138 Defaults to @samp{tun}.
20139
20140 @end deftypevr
20141
20142 @deftypevr {@code{openvpn-client-configuration} parameter} string ca
20143 The certificate authority to check connections against.
20144
20145 Defaults to @samp{"/etc/openvpn/ca.crt"}.
20146
20147 @end deftypevr
20148
20149 @deftypevr {@code{openvpn-client-configuration} parameter} string cert
20150 The certificate of the machine the daemon is running on. It should be
20151 signed by the authority given in @code{ca}.
20152
20153 Defaults to @samp{"/etc/openvpn/client.crt"}.
20154
20155 @end deftypevr
20156
20157 @deftypevr {@code{openvpn-client-configuration} parameter} string key
20158 The key of the machine the daemon is running on. It must be the key whose
20159 certificate is @code{cert}.
20160
20161 Defaults to @samp{"/etc/openvpn/client.key"}.
20162
20163 @end deftypevr
20164
20165 @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
20166 Whether to use the lzo compression algorithm.
20167
20168 Defaults to @samp{#t}.
20169
20170 @end deftypevr
20171
20172 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
20173 Don't re-read key files across SIGUSR1 or --ping-restart.
20174
20175 Defaults to @samp{#t}.
20176
20177 @end deftypevr
20178
20179 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
20180 Don't close and reopen TUN/TAP device or run up/down scripts across
20181 SIGUSR1 or --ping-restart restarts.
20182
20183 Defaults to @samp{#t}.
20184
20185 @end deftypevr
20186
20187 @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
20188 Verbosity level.
20189
20190 Defaults to @samp{3}.
20191
20192 @end deftypevr
20193
20194 @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
20195 Add an additional layer of HMAC authentication on top of the TLS control
20196 channel to protect against DoS attacks.
20197
20198 Defaults to @samp{#f}.
20199
20200 @end deftypevr
20201
20202 @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
20203 Whether to check the server certificate has server usage extension.
20204
20205 Defaults to @samp{#t}.
20206
20207 @end deftypevr
20208
20209 @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
20210 Bind to a specific local port number.
20211
20212 Defaults to @samp{#f}.
20213
20214 @end deftypevr
20215
20216 @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
20217 Retry resolving server address.
20218
20219 Defaults to @samp{#t}.
20220
20221 @end deftypevr
20222
20223 @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
20224 A list of remote servers to connect to.
20225
20226 Defaults to @samp{()}.
20227
20228 Available @code{openvpn-remote-configuration} fields are:
20229
20230 @deftypevr {@code{openvpn-remote-configuration} parameter} string name
20231 Server name.
20232
20233 Defaults to @samp{"my-server"}.
20234
20235 @end deftypevr
20236
20237 @deftypevr {@code{openvpn-remote-configuration} parameter} number port
20238 Port number the server listens to.
20239
20240 Defaults to @samp{1194}.
20241
20242 @end deftypevr
20243
20244 @end deftypevr
20245 @c %end of automatic openvpn-client documentation
20246
20247 @c %automatically generated documentation
20248
20249 Available @code{openvpn-server-configuration} fields are:
20250
20251 @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
20252 The OpenVPN package.
20253
20254 @end deftypevr
20255
20256 @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
20257 The OpenVPN pid file.
20258
20259 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
20260
20261 @end deftypevr
20262
20263 @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
20264 The protocol (UDP or TCP) used to open a channel between clients and
20265 servers.
20266
20267 Defaults to @samp{udp}.
20268
20269 @end deftypevr
20270
20271 @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
20272 The device type used to represent the VPN connection.
20273
20274 Defaults to @samp{tun}.
20275
20276 @end deftypevr
20277
20278 @deftypevr {@code{openvpn-server-configuration} parameter} string ca
20279 The certificate authority to check connections against.
20280
20281 Defaults to @samp{"/etc/openvpn/ca.crt"}.
20282
20283 @end deftypevr
20284
20285 @deftypevr {@code{openvpn-server-configuration} parameter} string cert
20286 The certificate of the machine the daemon is running on. It should be
20287 signed by the authority given in @code{ca}.
20288
20289 Defaults to @samp{"/etc/openvpn/client.crt"}.
20290
20291 @end deftypevr
20292
20293 @deftypevr {@code{openvpn-server-configuration} parameter} string key
20294 The key of the machine the daemon is running on. It must be the key whose
20295 certificate is @code{cert}.
20296
20297 Defaults to @samp{"/etc/openvpn/client.key"}.
20298
20299 @end deftypevr
20300
20301 @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
20302 Whether to use the lzo compression algorithm.
20303
20304 Defaults to @samp{#t}.
20305
20306 @end deftypevr
20307
20308 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
20309 Don't re-read key files across SIGUSR1 or --ping-restart.
20310
20311 Defaults to @samp{#t}.
20312
20313 @end deftypevr
20314
20315 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
20316 Don't close and reopen TUN/TAP device or run up/down scripts across
20317 SIGUSR1 or --ping-restart restarts.
20318
20319 Defaults to @samp{#t}.
20320
20321 @end deftypevr
20322
20323 @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
20324 Verbosity level.
20325
20326 Defaults to @samp{3}.
20327
20328 @end deftypevr
20329
20330 @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
20331 Add an additional layer of HMAC authentication on top of the TLS control
20332 channel to protect against DoS attacks.
20333
20334 Defaults to @samp{#f}.
20335
20336 @end deftypevr
20337
20338 @deftypevr {@code{openvpn-server-configuration} parameter} number port
20339 Specifies the port number on which the server listens.
20340
20341 Defaults to @samp{1194}.
20342
20343 @end deftypevr
20344
20345 @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
20346 An ip and mask specifying the subnet inside the virtual network.
20347
20348 Defaults to @samp{"10.8.0.0 255.255.255.0"}.
20349
20350 @end deftypevr
20351
20352 @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
20353 A CIDR notation specifying the IPv6 subnet inside the virtual network.
20354
20355 Defaults to @samp{#f}.
20356
20357 @end deftypevr
20358
20359 @deftypevr {@code{openvpn-server-configuration} parameter} string dh
20360 The Diffie-Hellman parameters file.
20361
20362 Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
20363
20364 @end deftypevr
20365
20366 @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
20367 The file that records client IPs.
20368
20369 Defaults to @samp{"/etc/openvpn/ipp.txt"}.
20370
20371 @end deftypevr
20372
20373 @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
20374 When true, the server will act as a gateway for its clients.
20375
20376 Defaults to @samp{#f}.
20377
20378 @end deftypevr
20379
20380 @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
20381 When true, clients are allowed to talk to each other inside the VPN.
20382
20383 Defaults to @samp{#f}.
20384
20385 @end deftypevr
20386
20387 @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
20388 Causes ping-like messages to be sent back and forth over the link so
20389 that each side knows when the other side has gone down. @code{keepalive}
20390 requires a pair. The first element is the period of the ping sending,
20391 and the second element is the timeout before considering the other side
20392 down.
20393
20394 @end deftypevr
20395
20396 @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
20397 The maximum number of clients.
20398
20399 Defaults to @samp{100}.
20400
20401 @end deftypevr
20402
20403 @deftypevr {@code{openvpn-server-configuration} parameter} string status
20404 The status file. This file shows a small report on current connection.
20405 It is truncated and rewritten every minute.
20406
20407 Defaults to @samp{"/var/run/openvpn/status"}.
20408
20409 @end deftypevr
20410
20411 @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
20412 The list of configuration for some clients.
20413
20414 Defaults to @samp{()}.
20415
20416 Available @code{openvpn-ccd-configuration} fields are:
20417
20418 @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
20419 Client name.
20420
20421 Defaults to @samp{"client"}.
20422
20423 @end deftypevr
20424
20425 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
20426 Client own network
20427
20428 Defaults to @samp{#f}.
20429
20430 @end deftypevr
20431
20432 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
20433 Client VPN IP.
20434
20435 Defaults to @samp{#f}.
20436
20437 @end deftypevr
20438
20439 @end deftypevr
20440
20441
20442 @c %end of automatic openvpn-server documentation
20443
20444
20445 @node Network File System
20446 @subsection Network File System
20447 @cindex NFS
20448
20449 The @code{(gnu services nfs)} module provides the following services,
20450 which are most commonly used in relation to mounting or exporting
20451 directory trees as @dfn{network file systems} (NFS).
20452
20453 @subsubheading RPC Bind Service
20454 @cindex rpcbind
20455
20456 The RPC Bind service provides a facility to map program numbers into
20457 universal addresses.
20458 Many NFS related services use this facility. Hence it is automatically
20459 started when a dependent service starts.
20460
20461 @defvr {Scheme Variable} rpcbind-service-type
20462 A service type for the RPC portmapper daemon.
20463 @end defvr
20464
20465
20466 @deftp {Data Type} rpcbind-configuration
20467 Data type representing the configuration of the RPC Bind Service.
20468 This type has the following parameters:
20469 @table @asis
20470 @item @code{rpcbind} (default: @code{rpcbind})
20471 The rpcbind package to use.
20472
20473 @item @code{warm-start?} (default: @code{#t})
20474 If this parameter is @code{#t}, then the daemon will read a
20475 state file on startup thus reloading state information saved by a previous
20476 instance.
20477 @end table
20478 @end deftp
20479
20480
20481 @subsubheading Pipefs Pseudo File System
20482 @cindex pipefs
20483 @cindex rpc_pipefs
20484
20485 The pipefs file system is used to transfer NFS related data
20486 between the kernel and user space programs.
20487
20488 @defvr {Scheme Variable} pipefs-service-type
20489 A service type for the pipefs pseudo file system.
20490 @end defvr
20491
20492 @deftp {Data Type} pipefs-configuration
20493 Data type representing the configuration of the pipefs pseudo file system service.
20494 This type has the following parameters:
20495 @table @asis
20496 @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
20497 The directory to which the file system is to be attached.
20498 @end table
20499 @end deftp
20500
20501
20502 @subsubheading GSS Daemon Service
20503 @cindex GSSD
20504 @cindex GSS
20505 @cindex global security system
20506
20507 The @dfn{global security system} (GSS) daemon provides strong security for RPC
20508 based protocols.
20509 Before exchanging RPC requests an RPC client must establish a security
20510 context. Typically this is done using the Kerberos command @command{kinit}
20511 or automatically at login time using PAM services (@pxref{Kerberos Services}).
20512
20513 @defvr {Scheme Variable} gss-service-type
20514 A service type for the Global Security System (GSS) daemon.
20515 @end defvr
20516
20517 @deftp {Data Type} gss-configuration
20518 Data type representing the configuration of the GSS daemon service.
20519 This type has the following parameters:
20520 @table @asis
20521 @item @code{nfs-utils} (default: @code{nfs-utils})
20522 The package in which the @command{rpc.gssd} command is to be found.
20523
20524 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
20525 The directory where the pipefs file system is mounted.
20526
20527 @end table
20528 @end deftp
20529
20530
20531 @subsubheading IDMAP Daemon Service
20532 @cindex idmapd
20533 @cindex name mapper
20534
20535 The idmap daemon service provides mapping between user IDs and user names.
20536 Typically it is required in order to access file systems mounted via NFSv4.
20537
20538 @defvr {Scheme Variable} idmap-service-type
20539 A service type for the Identity Mapper (IDMAP) daemon.
20540 @end defvr
20541
20542 @deftp {Data Type} idmap-configuration
20543 Data type representing the configuration of the IDMAP daemon service.
20544 This type has the following parameters:
20545 @table @asis
20546 @item @code{nfs-utils} (default: @code{nfs-utils})
20547 The package in which the @command{rpc.idmapd} command is to be found.
20548
20549 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
20550 The directory where the pipefs file system is mounted.
20551
20552 @item @code{domain} (default: @code{#f})
20553 The local NFSv4 domain name.
20554 This must be a string or @code{#f}.
20555 If it is @code{#f} then the daemon will use the host's fully qualified domain name.
20556
20557 @end table
20558 @end deftp
20559
20560 @node Continuous Integration
20561 @subsection Continuous Integration
20562
20563 @cindex continuous integration
20564 @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
20565 continuous integration tool for Guix. It can be used both for development and
20566 for providing substitutes to others (@pxref{Substitutes}).
20567
20568 The @code{(gnu services cuirass)} module provides the following service.
20569
20570 @defvr {Scheme Procedure} cuirass-service-type
20571 The type of the Cuirass service. Its value must be a
20572 @code{cuirass-configuration} object, as described below.
20573 @end defvr
20574
20575 To add build jobs, you have to set the @code{specifications} field of the
20576 configuration. Here is an example of a service that polls the Guix repository
20577 and builds the packages from a manifest. Some of the packages are defined in
20578 the @code{"custom-packages"} input, which is the equivalent of
20579 @code{GUIX_PACKAGE_PATH}.
20580
20581 @example
20582 (define %cuirass-specs
20583 #~(list
20584 '((#:name . "my-manifest")
20585 (#:load-path-inputs . ("guix"))
20586 (#:package-path-inputs . ("custom-packages"))
20587 (#:proc-input . "guix")
20588 (#:proc-file . "build-aux/cuirass/gnu-system.scm")
20589 (#:proc . cuirass-jobs)
20590 (#:proc-args . ((subset . "manifests")
20591 (systems . ("x86_64-linux"))
20592 (manifests . (("config" . "guix/manifest.scm")))))
20593 (#:inputs . (((#:name . "guix")
20594 (#:url . "git://git.savannah.gnu.org/guix.git")
20595 (#:load-path . ".")
20596 (#:branch . "master")
20597 (#:no-compile? . #t))
20598 ((#:name . "config")
20599 (#:url . "git://git.example.org/config.git")
20600 (#:load-path . ".")
20601 (#:branch . "master")
20602 (#:no-compile? . #t))
20603 ((#:name . "custom-packages")
20604 (#:url . "git://git.example.org/custom-packages.git")
20605 (#:load-path . ".")
20606 (#:branch . "master")
20607 (#:no-compile? . #t)))))))
20608
20609 (service cuirass-service-type
20610 (cuirass-configuration
20611 (specifications %cuirass-specs)))
20612 @end example
20613
20614 While information related to build jobs is located directly in the
20615 specifications, global settings for the @command{cuirass} process are
20616 accessible in other @code{cuirass-configuration} fields.
20617
20618 @deftp {Data Type} cuirass-configuration
20619 Data type representing the configuration of Cuirass.
20620
20621 @table @asis
20622 @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
20623 Location of the log file.
20624
20625 @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
20626 Location of the repository cache.
20627
20628 @item @code{user} (default: @code{"cuirass"})
20629 Owner of the @code{cuirass} process.
20630
20631 @item @code{group} (default: @code{"cuirass"})
20632 Owner's group of the @code{cuirass} process.
20633
20634 @item @code{interval} (default: @code{60})
20635 Number of seconds between the poll of the repositories followed by the
20636 Cuirass jobs.
20637
20638 @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
20639 Location of sqlite database which contains the build results and previously
20640 added specifications.
20641
20642 @item @code{ttl} (default: @code{(* 30 24 3600)})
20643 Specifies the time-to-live (TTL) in seconds of garbage collector roots that
20644 are registered for build results. This means that build results are protected
20645 from garbage collection for at least @var{ttl} seconds.
20646
20647 @item @code{port} (default: @code{8081})
20648 Port number used by the HTTP server.
20649
20650 @item --listen=@var{host}
20651 Listen on the network interface for @var{host}. The default is to
20652 accept connections from localhost.
20653
20654 @item @code{specifications} (default: @code{#~'()})
20655 A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
20656 where a specification is an association list
20657 (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
20658 keys are keywords (@code{#:keyword-example}) as shown in the example
20659 above.
20660
20661 @item @code{use-substitutes?} (default: @code{#f})
20662 This allows using substitutes to avoid building every dependencies of a job
20663 from source.
20664
20665 @item @code{one-shot?} (default: @code{#f})
20666 Only evaluate specifications and build derivations once.
20667
20668 @item @code{fallback?} (default: @code{#f})
20669 When substituting a pre-built binary fails, fall back to building
20670 packages locally.
20671
20672 @item @code{cuirass} (default: @code{cuirass})
20673 The Cuirass package to use.
20674 @end table
20675 @end deftp
20676
20677 @node Power Management Services
20678 @subsection Power Management Services
20679
20680 @cindex tlp
20681 @cindex power management with TLP
20682 @subsubheading TLP daemon
20683
20684 The @code{(gnu services pm)} module provides a Guix service definition
20685 for the Linux power management tool TLP.
20686
20687 TLP enables various powersaving modes in userspace and kernel.
20688 Contrary to @code{upower-service}, it is not a passive,
20689 monitoring tool, as it will apply custom settings each time a new power
20690 source is detected. More information can be found at
20691 @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
20692
20693 @deffn {Scheme Variable} tlp-service-type
20694 The service type for the TLP tool. Its value should be a valid
20695 TLP configuration (see below). To use the default settings, simply
20696 write:
20697 @example
20698 (service tlp-service-type)
20699 @end example
20700 @end deffn
20701
20702 By default TLP does not need much configuration but most TLP parameters
20703 can be tweaked using @code{tlp-configuration}.
20704
20705 Each parameter definition is preceded by its type; for example,
20706 @samp{boolean foo} indicates that the @code{foo} parameter
20707 should be specified as a boolean. Types starting with
20708 @code{maybe-} denote parameters that won't show up in TLP config file
20709 when their value is @code{'disabled}.
20710
20711 @c The following documentation was initially generated by
20712 @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
20713 @c documentation is better, so we shouldn't hesitate to edit below as
20714 @c needed. However if the change you want to make to this documentation
20715 @c can be done in an automated way, it's probably easier to change
20716 @c (generate-documentation) than to make it below and have to deal with
20717 @c the churn as TLP updates.
20718
20719 Available @code{tlp-configuration} fields are:
20720
20721 @deftypevr {@code{tlp-configuration} parameter} package tlp
20722 The TLP package.
20723
20724 @end deftypevr
20725
20726 @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
20727 Set to true if you wish to enable TLP.
20728
20729 Defaults to @samp{#t}.
20730
20731 @end deftypevr
20732
20733 @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
20734 Default mode when no power supply can be detected. Alternatives are AC
20735 and BAT.
20736
20737 Defaults to @samp{"AC"}.
20738
20739 @end deftypevr
20740
20741 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
20742 Number of seconds Linux kernel has to wait after the disk goes idle,
20743 before syncing on AC.
20744
20745 Defaults to @samp{0}.
20746
20747 @end deftypevr
20748
20749 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
20750 Same as @code{disk-idle-ac} but on BAT mode.
20751
20752 Defaults to @samp{2}.
20753
20754 @end deftypevr
20755
20756 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
20757 Dirty pages flushing periodicity, expressed in seconds.
20758
20759 Defaults to @samp{15}.
20760
20761 @end deftypevr
20762
20763 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
20764 Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
20765
20766 Defaults to @samp{60}.
20767
20768 @end deftypevr
20769
20770 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
20771 CPU frequency scaling governor on AC mode. With intel_pstate driver,
20772 alternatives are powersave and performance. With acpi-cpufreq driver,
20773 alternatives are ondemand, powersave, performance and conservative.
20774
20775 Defaults to @samp{disabled}.
20776
20777 @end deftypevr
20778
20779 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
20780 Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
20781
20782 Defaults to @samp{disabled}.
20783
20784 @end deftypevr
20785
20786 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
20787 Set the min available frequency for the scaling governor on AC.
20788
20789 Defaults to @samp{disabled}.
20790
20791 @end deftypevr
20792
20793 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
20794 Set the max available frequency for the scaling governor on AC.
20795
20796 Defaults to @samp{disabled}.
20797
20798 @end deftypevr
20799
20800 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
20801 Set the min available frequency for the scaling governor on BAT.
20802
20803 Defaults to @samp{disabled}.
20804
20805 @end deftypevr
20806
20807 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
20808 Set the max available frequency for the scaling governor on BAT.
20809
20810 Defaults to @samp{disabled}.
20811
20812 @end deftypevr
20813
20814 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
20815 Limit the min P-state to control the power dissipation of the CPU, in AC
20816 mode. Values are stated as a percentage of the available performance.
20817
20818 Defaults to @samp{disabled}.
20819
20820 @end deftypevr
20821
20822 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
20823 Limit the max P-state to control the power dissipation of the CPU, in AC
20824 mode. Values are stated as a percentage of the available performance.
20825
20826 Defaults to @samp{disabled}.
20827
20828 @end deftypevr
20829
20830 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
20831 Same as @code{cpu-min-perf-on-ac} on BAT mode.
20832
20833 Defaults to @samp{disabled}.
20834
20835 @end deftypevr
20836
20837 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
20838 Same as @code{cpu-max-perf-on-ac} on BAT mode.
20839
20840 Defaults to @samp{disabled}.
20841
20842 @end deftypevr
20843
20844 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
20845 Enable CPU turbo boost feature on AC mode.
20846
20847 Defaults to @samp{disabled}.
20848
20849 @end deftypevr
20850
20851 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
20852 Same as @code{cpu-boost-on-ac?} on BAT mode.
20853
20854 Defaults to @samp{disabled}.
20855
20856 @end deftypevr
20857
20858 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
20859 Allow Linux kernel to minimize the number of CPU cores/hyper-threads
20860 used under light load conditions.
20861
20862 Defaults to @samp{#f}.
20863
20864 @end deftypevr
20865
20866 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
20867 Same as @code{sched-powersave-on-ac?} but on BAT mode.
20868
20869 Defaults to @samp{#t}.
20870
20871 @end deftypevr
20872
20873 @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
20874 Enable Linux kernel NMI watchdog.
20875
20876 Defaults to @samp{#f}.
20877
20878 @end deftypevr
20879
20880 @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
20881 For Linux kernels with PHC patch applied, change CPU voltages. An
20882 example value would be @samp{"F:V F:V F:V F:V"}.
20883
20884 Defaults to @samp{disabled}.
20885
20886 @end deftypevr
20887
20888 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
20889 Set CPU performance versus energy saving policy on AC. Alternatives are
20890 performance, normal, powersave.
20891
20892 Defaults to @samp{"performance"}.
20893
20894 @end deftypevr
20895
20896 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
20897 Same as @code{energy-perf-policy-ac} but on BAT mode.
20898
20899 Defaults to @samp{"powersave"}.
20900
20901 @end deftypevr
20902
20903 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
20904 Hard disk devices.
20905
20906 @end deftypevr
20907
20908 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
20909 Hard disk advanced power management level.
20910
20911 @end deftypevr
20912
20913 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
20914 Same as @code{disk-apm-bat} but on BAT mode.
20915
20916 @end deftypevr
20917
20918 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
20919 Hard disk spin down timeout. One value has to be specified for each
20920 declared hard disk.
20921
20922 Defaults to @samp{disabled}.
20923
20924 @end deftypevr
20925
20926 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
20927 Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
20928
20929 Defaults to @samp{disabled}.
20930
20931 @end deftypevr
20932
20933 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
20934 Select IO scheduler for disk devices. One value has to be specified for
20935 each declared hard disk. Example alternatives are cfq, deadline and
20936 noop.
20937
20938 Defaults to @samp{disabled}.
20939
20940 @end deftypevr
20941
20942 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
20943 SATA aggressive link power management (ALPM) level. Alternatives are
20944 min_power, medium_power, max_performance.
20945
20946 Defaults to @samp{"max_performance"}.
20947
20948 @end deftypevr
20949
20950 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
20951 Same as @code{sata-linkpwr-ac} but on BAT mode.
20952
20953 Defaults to @samp{"min_power"}.
20954
20955 @end deftypevr
20956
20957 @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
20958 Exclude specified SATA host devices for link power management.
20959
20960 Defaults to @samp{disabled}.
20961
20962 @end deftypevr
20963
20964 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
20965 Enable Runtime Power Management for AHCI controller and disks on AC
20966 mode.
20967
20968 Defaults to @samp{disabled}.
20969
20970 @end deftypevr
20971
20972 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
20973 Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
20974
20975 Defaults to @samp{disabled}.
20976
20977 @end deftypevr
20978
20979 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
20980 Seconds of inactivity before disk is suspended.
20981
20982 Defaults to @samp{15}.
20983
20984 @end deftypevr
20985
20986 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
20987 PCI Express Active State Power Management level. Alternatives are
20988 default, performance, powersave.
20989
20990 Defaults to @samp{"performance"}.
20991
20992 @end deftypevr
20993
20994 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
20995 Same as @code{pcie-aspm-ac} but on BAT mode.
20996
20997 Defaults to @samp{"powersave"}.
20998
20999 @end deftypevr
21000
21001 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
21002 Radeon graphics clock speed level. Alternatives are low, mid, high,
21003 auto, default.
21004
21005 Defaults to @samp{"high"}.
21006
21007 @end deftypevr
21008
21009 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
21010 Same as @code{radeon-power-ac} but on BAT mode.
21011
21012 Defaults to @samp{"low"}.
21013
21014 @end deftypevr
21015
21016 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
21017 Radeon dynamic power management method (DPM). Alternatives are battery,
21018 performance.
21019
21020 Defaults to @samp{"performance"}.
21021
21022 @end deftypevr
21023
21024 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
21025 Same as @code{radeon-dpm-state-ac} but on BAT mode.
21026
21027 Defaults to @samp{"battery"}.
21028
21029 @end deftypevr
21030
21031 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
21032 Radeon DPM performance level. Alternatives are auto, low, high.
21033
21034 Defaults to @samp{"auto"}.
21035
21036 @end deftypevr
21037
21038 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
21039 Same as @code{radeon-dpm-perf-ac} but on BAT mode.
21040
21041 Defaults to @samp{"auto"}.
21042
21043 @end deftypevr
21044
21045 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
21046 Wifi power saving mode.
21047
21048 Defaults to @samp{#f}.
21049
21050 @end deftypevr
21051
21052 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
21053 Same as @code{wifi-power-ac?} but on BAT mode.
21054
21055 Defaults to @samp{#t}.
21056
21057 @end deftypevr
21058
21059 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
21060 Disable wake on LAN.
21061
21062 Defaults to @samp{#t}.
21063
21064 @end deftypevr
21065
21066 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
21067 Timeout duration in seconds before activating audio power saving on
21068 Intel HDA and AC97 devices. A value of 0 disables power saving.
21069
21070 Defaults to @samp{0}.
21071
21072 @end deftypevr
21073
21074 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
21075 Same as @code{sound-powersave-ac} but on BAT mode.
21076
21077 Defaults to @samp{1}.
21078
21079 @end deftypevr
21080
21081 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
21082 Disable controller in powersaving mode on Intel HDA devices.
21083
21084 Defaults to @samp{#t}.
21085
21086 @end deftypevr
21087
21088 @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
21089 Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
21090 powered on again by releasing (and reinserting) the eject lever or by
21091 pressing the disc eject button on newer models.
21092
21093 Defaults to @samp{#f}.
21094
21095 @end deftypevr
21096
21097 @deftypevr {@code{tlp-configuration} parameter} string bay-device
21098 Name of the optical drive device to power off.
21099
21100 Defaults to @samp{"sr0"}.
21101
21102 @end deftypevr
21103
21104 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
21105 Runtime Power Management for PCI(e) bus devices. Alternatives are on
21106 and auto.
21107
21108 Defaults to @samp{"on"}.
21109
21110 @end deftypevr
21111
21112 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
21113 Same as @code{runtime-pm-ac} but on BAT mode.
21114
21115 Defaults to @samp{"auto"}.
21116
21117 @end deftypevr
21118
21119 @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
21120 Runtime Power Management for all PCI(e) bus devices, except blacklisted
21121 ones.
21122
21123 Defaults to @samp{#t}.
21124
21125 @end deftypevr
21126
21127 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
21128 Exclude specified PCI(e) device addresses from Runtime Power Management.
21129
21130 Defaults to @samp{disabled}.
21131
21132 @end deftypevr
21133
21134 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
21135 Exclude PCI(e) devices assigned to the specified drivers from Runtime
21136 Power Management.
21137
21138 @end deftypevr
21139
21140 @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
21141 Enable USB autosuspend feature.
21142
21143 Defaults to @samp{#t}.
21144
21145 @end deftypevr
21146
21147 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
21148 Exclude specified devices from USB autosuspend.
21149
21150 Defaults to @samp{disabled}.
21151
21152 @end deftypevr
21153
21154 @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
21155 Exclude WWAN devices from USB autosuspend.
21156
21157 Defaults to @samp{#t}.
21158
21159 @end deftypevr
21160
21161 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
21162 Include specified devices into USB autosuspend, even if they are already
21163 excluded by the driver or via @code{usb-blacklist-wwan?}.
21164
21165 Defaults to @samp{disabled}.
21166
21167 @end deftypevr
21168
21169 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
21170 Enable USB autosuspend before shutdown.
21171
21172 Defaults to @samp{disabled}.
21173
21174 @end deftypevr
21175
21176 @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
21177 Restore radio device state (bluetooth, wifi, wwan) from previous
21178 shutdown on system startup.
21179
21180 Defaults to @samp{#f}.
21181
21182 @end deftypevr
21183
21184 @cindex thermald
21185 @cindex CPU frequency scaling with thermald
21186 @subsubheading Thermald daemon
21187
21188 The @code{(gnu services pm)} module provides an interface to
21189 thermald, a CPU frequency scaling service which helps prevent overheating.
21190
21191 @defvr {Scheme Variable} thermald-service-type
21192 This is the service type for
21193 @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
21194 Thermal Daemon, which is responsible for controlling the thermal state
21195 of processors and preventing overheating.
21196 @end defvr
21197
21198 @deftp {Data Type} thermald-configuration
21199 Data type representing the configuration of @code{thermald-service-type}.
21200
21201 @table @asis
21202 @item @code{ignore-cpuid-check?} (default: @code{#f})
21203 Ignore cpuid check for supported CPU models.
21204
21205 @item @code{thermald} (default: @var{thermald})
21206 Package object of thermald.
21207
21208 @end table
21209 @end deftp
21210
21211 @node Audio Services
21212 @subsection Audio Services
21213
21214 The @code{(gnu services audio)} module provides a service to start MPD
21215 (the Music Player Daemon).
21216
21217 @cindex mpd
21218 @subsubheading Music Player Daemon
21219
21220 The Music Player Daemon (MPD) is a service that can play music while
21221 being controlled from the local machine or over the network by a variety
21222 of clients.
21223
21224 The following example shows how one might run @code{mpd} as user
21225 @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
21226
21227 @example
21228 (service mpd-service-type
21229 (mpd-configuration
21230 (user "bob")
21231 (port "6666")))
21232 @end example
21233
21234 @defvr {Scheme Variable} mpd-service-type
21235 The service type for @command{mpd}
21236 @end defvr
21237
21238 @deftp {Data Type} mpd-configuration
21239 Data type representing the configuration of @command{mpd}.
21240
21241 @table @asis
21242 @item @code{user} (default: @code{"mpd"})
21243 The user to run mpd as.
21244
21245 @item @code{music-dir} (default: @code{"~/Music"})
21246 The directory to scan for music files.
21247
21248 @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
21249 The directory to store playlists.
21250
21251 @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
21252 The location of the music database.
21253
21254 @item @code{state-file} (default: @code{"~/.mpd/state"})
21255 The location of the file that stores current MPD's state.
21256
21257 @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
21258 The location of the sticker database.
21259
21260 @item @code{port} (default: @code{"6600"})
21261 The port to run mpd on.
21262
21263 @item @code{address} (default: @code{"any"})
21264 The address that mpd will bind to. To use a Unix domain socket,
21265 an absolute path can be specified here.
21266
21267 @end table
21268 @end deftp
21269
21270 @node Virtualization Services
21271 @subsection Virtualization services
21272
21273 The @code{(gnu services virtualization)} module provides services for
21274 the libvirt and virtlog daemons, as well as other virtualization-related
21275 services.
21276
21277 @subsubheading Libvirt daemon
21278 @code{libvirtd} is the server side daemon component of the libvirt
21279 virtualization management system. This daemon runs on host servers
21280 and performs required management tasks for virtualized guests.
21281
21282 @deffn {Scheme Variable} libvirt-service-type
21283 This is the type of the @uref{https://libvirt.org, libvirt daemon}.
21284 Its value must be a @code{libvirt-configuration}.
21285
21286 @example
21287 (service libvirt-service-type
21288 (libvirt-configuration
21289 (unix-sock-group "libvirt")
21290 (tls-port "16555")))
21291 @end example
21292 @end deffn
21293
21294 @c Auto-generated with (generate-libvirt-documentation)
21295 Available @code{libvirt-configuration} fields are:
21296
21297 @deftypevr {@code{libvirt-configuration} parameter} package libvirt
21298 Libvirt package.
21299
21300 @end deftypevr
21301
21302 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
21303 Flag listening for secure TLS connections on the public TCP/IP port.
21304 must set @code{listen} for this to have any effect.
21305
21306 It is necessary to setup a CA and issue server certificates before using
21307 this capability.
21308
21309 Defaults to @samp{#t}.
21310
21311 @end deftypevr
21312
21313 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
21314 Listen for unencrypted TCP connections on the public TCP/IP port. must
21315 set @code{listen} for this to have any effect.
21316
21317 Using the TCP socket requires SASL authentication by default. Only SASL
21318 mechanisms which support data encryption are allowed. This is
21319 DIGEST_MD5 and GSSAPI (Kerberos5)
21320
21321 Defaults to @samp{#f}.
21322
21323 @end deftypevr
21324
21325 @deftypevr {@code{libvirt-configuration} parameter} string tls-port
21326 Port for accepting secure TLS connections This can be a port number, or
21327 service name
21328
21329 Defaults to @samp{"16514"}.
21330
21331 @end deftypevr
21332
21333 @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
21334 Port for accepting insecure TCP connections This can be a port number,
21335 or service name
21336
21337 Defaults to @samp{"16509"}.
21338
21339 @end deftypevr
21340
21341 @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
21342 IP address or hostname used for client connections.
21343
21344 Defaults to @samp{"0.0.0.0"}.
21345
21346 @end deftypevr
21347
21348 @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
21349 Flag toggling mDNS advertisement of the libvirt service.
21350
21351 Alternatively can disable for all services on a host by stopping the
21352 Avahi daemon.
21353
21354 Defaults to @samp{#f}.
21355
21356 @end deftypevr
21357
21358 @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
21359 Default mDNS advertisement name. This must be unique on the immediate
21360 broadcast network.
21361
21362 Defaults to @samp{"Virtualization Host <hostname>"}.
21363
21364 @end deftypevr
21365
21366 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
21367 UNIX domain socket group ownership. This can be used to allow a
21368 'trusted' set of users access to management capabilities without
21369 becoming root.
21370
21371 Defaults to @samp{"root"}.
21372
21373 @end deftypevr
21374
21375 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
21376 UNIX socket permissions for the R/O socket. This is used for monitoring
21377 VM status only.
21378
21379 Defaults to @samp{"0777"}.
21380
21381 @end deftypevr
21382
21383 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
21384 UNIX socket permissions for the R/W socket. Default allows only root.
21385 If PolicyKit is enabled on the socket, the default will change to allow
21386 everyone (eg, 0777)
21387
21388 Defaults to @samp{"0770"}.
21389
21390 @end deftypevr
21391
21392 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
21393 UNIX socket permissions for the admin socket. Default allows only owner
21394 (root), do not change it unless you are sure to whom you are exposing
21395 the access to.
21396
21397 Defaults to @samp{"0777"}.
21398
21399 @end deftypevr
21400
21401 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
21402 The directory in which sockets will be found/created.
21403
21404 Defaults to @samp{"/var/run/libvirt"}.
21405
21406 @end deftypevr
21407
21408 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
21409 Authentication scheme for UNIX read-only sockets. By default socket
21410 permissions allow anyone to connect
21411
21412 Defaults to @samp{"polkit"}.
21413
21414 @end deftypevr
21415
21416 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
21417 Authentication scheme for UNIX read-write sockets. By default socket
21418 permissions only allow root. If PolicyKit support was compiled into
21419 libvirt, the default will be to use 'polkit' auth.
21420
21421 Defaults to @samp{"polkit"}.
21422
21423 @end deftypevr
21424
21425 @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
21426 Authentication scheme for TCP sockets. If you don't enable SASL, then
21427 all TCP traffic is cleartext. Don't do this outside of a dev/test
21428 scenario.
21429
21430 Defaults to @samp{"sasl"}.
21431
21432 @end deftypevr
21433
21434 @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
21435 Authentication scheme for TLS sockets. TLS sockets already have
21436 encryption provided by the TLS layer, and limited authentication is done
21437 by certificates.
21438
21439 It is possible to make use of any SASL authentication mechanism as well,
21440 by using 'sasl' for this option
21441
21442 Defaults to @samp{"none"}.
21443
21444 @end deftypevr
21445
21446 @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
21447 API access control scheme.
21448
21449 By default an authenticated user is allowed access to all APIs. Access
21450 drivers can place restrictions on this.
21451
21452 Defaults to @samp{()}.
21453
21454 @end deftypevr
21455
21456 @deftypevr {@code{libvirt-configuration} parameter} string key-file
21457 Server key file path. If set to an empty string, then no private key is
21458 loaded.
21459
21460 Defaults to @samp{""}.
21461
21462 @end deftypevr
21463
21464 @deftypevr {@code{libvirt-configuration} parameter} string cert-file
21465 Server key file path. If set to an empty string, then no certificate is
21466 loaded.
21467
21468 Defaults to @samp{""}.
21469
21470 @end deftypevr
21471
21472 @deftypevr {@code{libvirt-configuration} parameter} string ca-file
21473 Server key file path. If set to an empty string, then no CA certificate
21474 is loaded.
21475
21476 Defaults to @samp{""}.
21477
21478 @end deftypevr
21479
21480 @deftypevr {@code{libvirt-configuration} parameter} string crl-file
21481 Certificate revocation list path. If set to an empty string, then no
21482 CRL is loaded.
21483
21484 Defaults to @samp{""}.
21485
21486 @end deftypevr
21487
21488 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
21489 Disable verification of our own server certificates.
21490
21491 When libvirtd starts it performs some sanity checks against its own
21492 certificates.
21493
21494 Defaults to @samp{#f}.
21495
21496 @end deftypevr
21497
21498 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
21499 Disable verification of client certificates.
21500
21501 Client certificate verification is the primary authentication mechanism.
21502 Any client which does not present a certificate signed by the CA will be
21503 rejected.
21504
21505 Defaults to @samp{#f}.
21506
21507 @end deftypevr
21508
21509 @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
21510 Whitelist of allowed x509 Distinguished Name.
21511
21512 Defaults to @samp{()}.
21513
21514 @end deftypevr
21515
21516 @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
21517 Whitelist of allowed SASL usernames. The format for username depends on
21518 the SASL authentication mechanism.
21519
21520 Defaults to @samp{()}.
21521
21522 @end deftypevr
21523
21524 @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
21525 Override the compile time default TLS priority string. The default is
21526 usually "NORMAL" unless overridden at build time. Only set this is it
21527 is desired for libvirt to deviate from the global default settings.
21528
21529 Defaults to @samp{"NORMAL"}.
21530
21531 @end deftypevr
21532
21533 @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
21534 Maximum number of concurrent client connections to allow over all
21535 sockets combined.
21536
21537 Defaults to @samp{5000}.
21538
21539 @end deftypevr
21540
21541 @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
21542 Maximum length of queue of connections waiting to be accepted by the
21543 daemon. Note, that some protocols supporting retransmission may obey
21544 this so that a later reattempt at connection succeeds.
21545
21546 Defaults to @samp{1000}.
21547
21548 @end deftypevr
21549
21550 @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
21551 Maximum length of queue of accepted but not yet authenticated clients.
21552 Set this to zero to turn this feature off
21553
21554 Defaults to @samp{20}.
21555
21556 @end deftypevr
21557
21558 @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
21559 Number of workers to start up initially.
21560
21561 Defaults to @samp{5}.
21562
21563 @end deftypevr
21564
21565 @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
21566 Maximum number of worker threads.
21567
21568 If the number of active clients exceeds @code{min-workers}, then more
21569 threads are spawned, up to max_workers limit. Typically you'd want
21570 max_workers to equal maximum number of clients allowed.
21571
21572 Defaults to @samp{20}.
21573
21574 @end deftypevr
21575
21576 @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
21577 Number of priority workers. If all workers from above pool are stuck,
21578 some calls marked as high priority (notably domainDestroy) can be
21579 executed in this pool.
21580
21581 Defaults to @samp{5}.
21582
21583 @end deftypevr
21584
21585 @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
21586 Total global limit on concurrent RPC calls.
21587
21588 Defaults to @samp{20}.
21589
21590 @end deftypevr
21591
21592 @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
21593 Limit on concurrent requests from a single client connection. To avoid
21594 one client monopolizing the server this should be a small fraction of
21595 the global max_requests and max_workers parameter.
21596
21597 Defaults to @samp{5}.
21598
21599 @end deftypevr
21600
21601 @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
21602 Same as @code{min-workers} but for the admin interface.
21603
21604 Defaults to @samp{1}.
21605
21606 @end deftypevr
21607
21608 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
21609 Same as @code{max-workers} but for the admin interface.
21610
21611 Defaults to @samp{5}.
21612
21613 @end deftypevr
21614
21615 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
21616 Same as @code{max-clients} but for the admin interface.
21617
21618 Defaults to @samp{5}.
21619
21620 @end deftypevr
21621
21622 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
21623 Same as @code{max-queued-clients} but for the admin interface.
21624
21625 Defaults to @samp{5}.
21626
21627 @end deftypevr
21628
21629 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
21630 Same as @code{max-client-requests} but for the admin interface.
21631
21632 Defaults to @samp{5}.
21633
21634 @end deftypevr
21635
21636 @deftypevr {@code{libvirt-configuration} parameter} integer log-level
21637 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
21638
21639 Defaults to @samp{3}.
21640
21641 @end deftypevr
21642
21643 @deftypevr {@code{libvirt-configuration} parameter} string log-filters
21644 Logging filters.
21645
21646 A filter allows to select a different logging level for a given category
21647 of logs The format for a filter is one of:
21648
21649 @itemize @bullet
21650 @item
21651 x:name
21652
21653 @item
21654 x:+name
21655
21656 @end itemize
21657
21658 where @code{name} is a string which is matched against the category
21659 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
21660 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
21661 be a substring of the full category name, in order to match multiple
21662 similar categories), the optional "+" prefix tells libvirt to log stack
21663 trace for each message matching name, and @code{x} is the minimal level
21664 where matching messages should be logged:
21665
21666 @itemize @bullet
21667 @item
21668 1: DEBUG
21669
21670 @item
21671 2: INFO
21672
21673 @item
21674 3: WARNING
21675
21676 @item
21677 4: ERROR
21678
21679 @end itemize
21680
21681 Multiple filters can be defined in a single filters statement, they just
21682 need to be separated by spaces.
21683
21684 Defaults to @samp{"3:remote 4:event"}.
21685
21686 @end deftypevr
21687
21688 @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
21689 Logging outputs.
21690
21691 An output is one of the places to save logging information The format
21692 for an output can be:
21693
21694 @table @code
21695 @item x:stderr
21696 output goes to stderr
21697
21698 @item x:syslog:name
21699 use syslog for the output and use the given name as the ident
21700
21701 @item x:file:file_path
21702 output to a file, with the given filepath
21703
21704 @item x:journald
21705 output to journald logging system
21706
21707 @end table
21708
21709 In all case the x prefix is the minimal level, acting as a filter
21710
21711 @itemize @bullet
21712 @item
21713 1: DEBUG
21714
21715 @item
21716 2: INFO
21717
21718 @item
21719 3: WARNING
21720
21721 @item
21722 4: ERROR
21723
21724 @end itemize
21725
21726 Multiple outputs can be defined, they just need to be separated by
21727 spaces.
21728
21729 Defaults to @samp{"3:stderr"}.
21730
21731 @end deftypevr
21732
21733 @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
21734 Allows usage of the auditing subsystem to be altered
21735
21736 @itemize @bullet
21737 @item
21738 0: disable all auditing
21739
21740 @item
21741 1: enable auditing, only if enabled on host
21742
21743 @item
21744 2: enable auditing, and exit if disabled on host.
21745
21746 @end itemize
21747
21748 Defaults to @samp{1}.
21749
21750 @end deftypevr
21751
21752 @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
21753 Send audit messages via libvirt logging infrastructure.
21754
21755 Defaults to @samp{#f}.
21756
21757 @end deftypevr
21758
21759 @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
21760 Host UUID. UUID must not have all digits be the same.
21761
21762 Defaults to @samp{""}.
21763
21764 @end deftypevr
21765
21766 @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
21767 Source to read host UUID.
21768
21769 @itemize @bullet
21770 @item
21771 @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
21772
21773 @item
21774 @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
21775
21776 @end itemize
21777
21778 If @code{dmidecode} does not provide a valid UUID a temporary UUID will
21779 be generated.
21780
21781 Defaults to @samp{"smbios"}.
21782
21783 @end deftypevr
21784
21785 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
21786 A keepalive message is sent to a client after @code{keepalive_interval}
21787 seconds of inactivity to check if the client is still responding. If
21788 set to -1, libvirtd will never send keepalive requests; however clients
21789 can still send them and the daemon will send responses.
21790
21791 Defaults to @samp{5}.
21792
21793 @end deftypevr
21794
21795 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
21796 Maximum number of keepalive messages that are allowed to be sent to the
21797 client without getting any response before the connection is considered
21798 broken.
21799
21800 In other words, the connection is automatically closed approximately
21801 after @code{keepalive_interval * (keepalive_count + 1)} seconds since
21802 the last message received from the client. When @code{keepalive-count}
21803 is set to 0, connections will be automatically closed after
21804 @code{keepalive-interval} seconds of inactivity without sending any
21805 keepalive messages.
21806
21807 Defaults to @samp{5}.
21808
21809 @end deftypevr
21810
21811 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
21812 Same as above but for admin interface.
21813
21814 Defaults to @samp{5}.
21815
21816 @end deftypevr
21817
21818 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
21819 Same as above but for admin interface.
21820
21821 Defaults to @samp{5}.
21822
21823 @end deftypevr
21824
21825 @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
21826 Timeout for Open vSwitch calls.
21827
21828 The @code{ovs-vsctl} utility is used for the configuration and its
21829 timeout option is set by default to 5 seconds to avoid potential
21830 infinite waits blocking libvirt.
21831
21832 Defaults to @samp{5}.
21833
21834 @end deftypevr
21835
21836 @c %end of autogenerated docs
21837
21838 @subsubheading Virtlog daemon
21839 The virtlogd service is a server side daemon component of libvirt that is
21840 used to manage logs from virtual machine consoles.
21841
21842 This daemon is not used directly by libvirt client applications, rather it
21843 is called on their behalf by @code{libvirtd}. By maintaining the logs in a
21844 standalone daemon, the main @code{libvirtd} daemon can be restarted without
21845 risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
21846 itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
21847
21848 @deffn {Scheme Variable} virtlog-service-type
21849 This is the type of the virtlog daemon.
21850 Its value must be a @code{virtlog-configuration}.
21851
21852 @example
21853 (service virtlog-service-type
21854 (virtlog-configuration
21855 (max-clients 1000)))
21856 @end example
21857 @end deffn
21858
21859 @deftypevr {@code{virtlog-configuration} parameter} integer log-level
21860 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
21861
21862 Defaults to @samp{3}.
21863
21864 @end deftypevr
21865
21866 @deftypevr {@code{virtlog-configuration} parameter} string log-filters
21867 Logging filters.
21868
21869 A filter allows to select a different logging level for a given category
21870 of logs The format for a filter is one of:
21871
21872 @itemize @bullet
21873 @item
21874 x:name
21875
21876 @item
21877 x:+name
21878
21879 @end itemize
21880
21881 where @code{name} is a string which is matched against the category
21882 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
21883 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
21884 be a substring of the full category name, in order to match multiple
21885 similar categories), the optional "+" prefix tells libvirt to log stack
21886 trace for each message matching name, and @code{x} is the minimal level
21887 where matching messages should be logged:
21888
21889 @itemize @bullet
21890 @item
21891 1: DEBUG
21892
21893 @item
21894 2: INFO
21895
21896 @item
21897 3: WARNING
21898
21899 @item
21900 4: ERROR
21901
21902 @end itemize
21903
21904 Multiple filters can be defined in a single filters statement, they just
21905 need to be separated by spaces.
21906
21907 Defaults to @samp{"3:remote 4:event"}.
21908
21909 @end deftypevr
21910
21911 @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
21912 Logging outputs.
21913
21914 An output is one of the places to save logging information The format
21915 for an output can be:
21916
21917 @table @code
21918 @item x:stderr
21919 output goes to stderr
21920
21921 @item x:syslog:name
21922 use syslog for the output and use the given name as the ident
21923
21924 @item x:file:file_path
21925 output to a file, with the given filepath
21926
21927 @item x:journald
21928 output to journald logging system
21929
21930 @end table
21931
21932 In all case the x prefix is the minimal level, acting as a filter
21933
21934 @itemize @bullet
21935 @item
21936 1: DEBUG
21937
21938 @item
21939 2: INFO
21940
21941 @item
21942 3: WARNING
21943
21944 @item
21945 4: ERROR
21946
21947 @end itemize
21948
21949 Multiple outputs can be defined, they just need to be separated by
21950 spaces.
21951
21952 Defaults to @samp{"3:stderr"}.
21953
21954 @end deftypevr
21955
21956 @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
21957 Maximum number of concurrent client connections to allow over all
21958 sockets combined.
21959
21960 Defaults to @samp{1024}.
21961
21962 @end deftypevr
21963
21964 @deftypevr {@code{virtlog-configuration} parameter} integer max-size
21965 Maximum file size before rolling over.
21966
21967 Defaults to @samp{2MB}
21968
21969 @end deftypevr
21970
21971 @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
21972 Maximum number of backup files to keep.
21973
21974 Defaults to @samp{3}
21975
21976 @end deftypevr
21977
21978 @subsubheading Transparent Emulation with QEMU
21979
21980 @cindex emulation
21981 @cindex @code{binfmt_misc}
21982 @code{qemu-binfmt-service-type} provides support for transparent
21983 emulation of program binaries built for different architectures---e.g.,
21984 it allows you to transparently execute an ARMv7 program on an x86_64
21985 machine. It achieves this by combining the @uref{https://www.qemu.org,
21986 QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
21987
21988 @defvr {Scheme Variable} qemu-binfmt-service-type
21989 This is the type of the QEMU/binfmt service for transparent emulation.
21990 Its value must be a @code{qemu-binfmt-configuration} object, which
21991 specifies the QEMU package to use as well as the architecture we want to
21992 emulated:
21993
21994 @example
21995 (service qemu-binfmt-service-type
21996 (qemu-binfmt-configuration
21997 (platforms (lookup-qemu-platforms "arm" "aarch64" "mips64el"))))
21998 @end example
21999
22000 In this example, we enable transparent emulation for the ARM and aarch64
22001 platforms. Running @code{herd stop qemu-binfmt} turns it off, and
22002 running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
22003 herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
22004 @end defvr
22005
22006 @deftp {Data Type} qemu-binfmt-configuration
22007 This is the configuration for the @code{qemu-binfmt} service.
22008
22009 @table @asis
22010 @item @code{platforms} (default: @code{'()})
22011 The list of emulated QEMU platforms. Each item must be a @dfn{platform
22012 object} as returned by @code{lookup-qemu-platforms} (see below).
22013
22014 @item @code{guix-support?} (default: @code{#f})
22015 When it is true, QEMU and all its dependencies are added to the build
22016 environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
22017 @code{--chroot-directory} option}). This allows the @code{binfmt_misc}
22018 handlers to be used within the build environment, which in turn means
22019 that you can transparently build programs for another architecture.
22020
22021 For example, let's suppose you're on an x86_64 machine and you have this
22022 service:
22023
22024 @example
22025 (service qemu-binfmt-service-type
22026 (qemu-binfmt-configuration
22027 (platforms (lookup-qemu-platforms "arm"))
22028 (guix-support? #t)))
22029 @end example
22030
22031 You can run:
22032
22033 @example
22034 guix build -s armhf-linux inkscape
22035 @end example
22036
22037 @noindent
22038 and it will build Inkscape for ARMv7 @emph{as if it were a native
22039 build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
22040 if you'd like to test a package build for an architecture you don't have
22041 access to!
22042
22043 @item @code{qemu} (default: @code{qemu})
22044 The QEMU package to use.
22045 @end table
22046 @end deftp
22047
22048 @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
22049 Return the list of QEMU platform objects corresponding to
22050 @var{platforms}@dots{}. @var{platforms} must be a list of strings
22051 corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
22052 @code{"mips64el"}, and so on.
22053 @end deffn
22054
22055 @deffn {Scheme Procedure} qemu-platform? @var{obj}
22056 Return true if @var{obj} is a platform object.
22057 @end deffn
22058
22059 @deffn {Scheme Procedure} qemu-platform-name @var{platform}
22060 Return the name of @var{platform}---a string such as @code{"arm"}.
22061 @end deffn
22062
22063 @node Version Control Services
22064 @subsection Version Control Services
22065
22066 The @code{(gnu services version-control)} module provides a service to
22067 allow remote access to local Git repositories. There are three options:
22068 the @code{git-daemon-service}, which provides access to repositories via
22069 the @code{git://} unsecured TCP-based protocol, extending the
22070 @code{nginx} web server to proxy some requests to
22071 @code{git-http-backend}, or providing a web interface with
22072 @code{cgit-service-type}.
22073
22074 @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
22075
22076 Return a service that runs @command{git daemon}, a simple TCP server to
22077 expose repositories over the Git protocol for anonymous access.
22078
22079 The optional @var{config} argument should be a
22080 @code{<git-daemon-configuration>} object, by default it allows read-only
22081 access to exported@footnote{By creating the magic file
22082 "git-daemon-export-ok" in the repository directory.} repositories under
22083 @file{/srv/git}.
22084
22085 @end deffn
22086
22087 @deftp {Data Type} git-daemon-configuration
22088 Data type representing the configuration for @code{git-daemon-service}.
22089
22090 @table @asis
22091 @item @code{package} (default: @var{git})
22092 Package object of the Git distributed version control system.
22093
22094 @item @code{export-all?} (default: @var{#f})
22095 Whether to allow access for all Git repositories, even if they do not
22096 have the @file{git-daemon-export-ok} file.
22097
22098 @item @code{base-path} (default: @file{/srv/git})
22099 Whether to remap all the path requests as relative to the given path.
22100 If you run git daemon with @var{(base-path "/srv/git")} on example.com,
22101 then if you later try to pull @code{git://example.com/hello.git}, git
22102 daemon will interpret the path as @code{/srv/git/hello.git}.
22103
22104 @item @code{user-path} (default: @var{#f})
22105 Whether to allow @code{~user} notation to be used in requests. When
22106 specified with empty string, requests to @code{git://host/~alice/foo} is
22107 taken as a request to access @code{foo} repository in the home directory
22108 of user @code{alice}. If @var{(user-path "path")} is specified, the
22109 same request is taken as a request to access @code{path/foo} repository
22110 in the home directory of user @code{alice}.
22111
22112 @item @code{listen} (default: @var{'()})
22113 Whether to listen on specific IP addresses or hostnames, defaults to
22114 all.
22115
22116 @item @code{port} (default: @var{#f})
22117 Whether to listen on an alternative port, which defaults to 9418.
22118
22119 @item @code{whitelist} (default: @var{'()})
22120 If not empty, only allow access to this list of directories.
22121
22122 @item @code{extra-options} (default: @var{'()})
22123 Extra options will be passed to @code{git daemon}, please run
22124 @command{man git-daemon} for more information.
22125
22126 @end table
22127 @end deftp
22128
22129 The @code{git://} protocol lacks authentication. When you pull from a
22130 repository fetched via @code{git://}, you don't know that the data you
22131 receive was modified is really coming from the specified host, and you
22132 have your connection is subject to eavesdropping. It's better to use an
22133 authenticated and encrypted transport, such as @code{https}. Although Git allows you
22134 to serve repositories using unsophisticated file-based web servers,
22135 there is a faster protocol implemented by the @code{git-http-backend}
22136 program. This program is the back-end of a proper Git web service. It
22137 is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
22138 on running the necessary @code{fcgiwrap} daemon.
22139
22140 Guix has a separate configuration data type for serving Git repositories
22141 over HTTP.
22142
22143 @deftp {Data Type} git-http-configuration
22144 Data type representing the configuration for @code{git-http-service}.
22145
22146 @table @asis
22147 @item @code{package} (default: @var{git})
22148 Package object of the Git distributed version control system.
22149
22150 @item @code{git-root} (default: @file{/srv/git})
22151 Directory containing the Git repositories to expose to the world.
22152
22153 @item @code{export-all?} (default: @var{#f})
22154 Whether to expose access for all Git repositories in @var{git-root},
22155 even if they do not have the @file{git-daemon-export-ok} file.
22156
22157 @item @code{uri-path} (default: @file{/git/})
22158 Path prefix for Git access. With the default @code{/git/} prefix, this
22159 will map @code{http://@var{server}/git/@var{repo}.git} to
22160 @code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
22161 with this prefix are not passed on to this Git instance.
22162
22163 @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
22164 The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
22165 Services}.
22166 @end table
22167 @end deftp
22168
22169 There is no @code{git-http-service-type}, currently; instead you can
22170 create an @code{nginx-location-configuration} from a
22171 @code{git-http-configuration} and then add that location to a web
22172 server.
22173
22174 @deffn {Scheme Procedure} git-http-nginx-location-configuration @
22175 [config=(git-http-configuration)]
22176 Compute an @code{nginx-location-configuration} that corresponds to the
22177 given Git http configuration. An example nginx service definition to
22178 serve the default @file{/srv/git} over HTTPS might be:
22179
22180 @example
22181 (service nginx-service-type
22182 (nginx-configuration
22183 (server-blocks
22184 (list
22185 (nginx-server-configuration
22186 (listen '("443 ssl"))
22187 (server-name "git.my-host.org")
22188 (ssl-certificate
22189 "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
22190 (ssl-certificate-key
22191 "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
22192 (locations
22193 (list
22194 (git-http-nginx-location-configuration
22195 (git-http-configuration (uri-path "/"))))))))))
22196 @end example
22197
22198 This example assumes that you are using Let's Encrypt to get your TLS
22199 certificate. @xref{Certificate Services}. The default @code{certbot}
22200 service will redirect all HTTP traffic on @code{git.my-host.org} to
22201 HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
22202 system services. @xref{Web Services}.
22203 @end deffn
22204
22205 @subsubheading Cgit Service
22206
22207 @cindex Cgit service
22208 @cindex Git, web interface
22209 @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
22210 repositories written in C.
22211
22212 The following example will configure the service with default values.
22213 By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
22214
22215 @example
22216 (service cgit-service-type)
22217 @end example
22218
22219 The @code{file-object} type designates either a file-like object
22220 (@pxref{G-Expressions, file-like objects}) or a string.
22221
22222 @c %start of fragment
22223
22224 Available @code{cgit-configuration} fields are:
22225
22226 @deftypevr {@code{cgit-configuration} parameter} package package
22227 The CGIT package.
22228
22229 @end deftypevr
22230
22231 @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
22232 NGINX configuration.
22233
22234 @end deftypevr
22235
22236 @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
22237 Specifies a command which will be invoked to format the content of about
22238 pages (both top-level and for each repository).
22239
22240 Defaults to @samp{""}.
22241
22242 @end deftypevr
22243
22244 @deftypevr {@code{cgit-configuration} parameter} string agefile
22245 Specifies a path, relative to each repository path, which can be used to
22246 specify the date and time of the youngest commit in the repository.
22247
22248 Defaults to @samp{""}.
22249
22250 @end deftypevr
22251
22252 @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
22253 Specifies a command that will be invoked for authenticating repository
22254 access.
22255
22256 Defaults to @samp{""}.
22257
22258 @end deftypevr
22259
22260 @deftypevr {@code{cgit-configuration} parameter} string branch-sort
22261 Flag which, when set to @samp{age}, enables date ordering in the branch
22262 ref list, and when set @samp{name} enables ordering by branch name.
22263
22264 Defaults to @samp{"name"}.
22265
22266 @end deftypevr
22267
22268 @deftypevr {@code{cgit-configuration} parameter} string cache-root
22269 Path used to store the cgit cache entries.
22270
22271 Defaults to @samp{"/var/cache/cgit"}.
22272
22273 @end deftypevr
22274
22275 @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
22276 Number which specifies the time-to-live, in minutes, for the cached
22277 version of repository pages accessed with a fixed SHA1.
22278
22279 Defaults to @samp{-1}.
22280
22281 @end deftypevr
22282
22283 @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
22284 Number which specifies the time-to-live, in minutes, for the cached
22285 version of repository pages accessed without a fixed SHA1.
22286
22287 Defaults to @samp{5}.
22288
22289 @end deftypevr
22290
22291 @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
22292 Number which specifies the time-to-live, in minutes, for the cached
22293 version of the repository summary page.
22294
22295 Defaults to @samp{5}.
22296
22297 @end deftypevr
22298
22299 @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
22300 Number which specifies the time-to-live, in minutes, for the cached
22301 version of the repository index page.
22302
22303 Defaults to @samp{5}.
22304
22305 @end deftypevr
22306
22307 @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
22308 Number which specifies the time-to-live, in minutes, for the result of
22309 scanning a path for Git repositories.
22310
22311 Defaults to @samp{15}.
22312
22313 @end deftypevr
22314
22315 @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
22316 Number which specifies the time-to-live, in minutes, for the cached
22317 version of the repository about page.
22318
22319 Defaults to @samp{15}.
22320
22321 @end deftypevr
22322
22323 @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
22324 Number which specifies the time-to-live, in minutes, for the cached
22325 version of snapshots.
22326
22327 Defaults to @samp{5}.
22328
22329 @end deftypevr
22330
22331 @deftypevr {@code{cgit-configuration} parameter} integer cache-size
22332 The maximum number of entries in the cgit cache. When set to @samp{0},
22333 caching is disabled.
22334
22335 Defaults to @samp{0}.
22336
22337 @end deftypevr
22338
22339 @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
22340 Sort items in the repo list case sensitively.
22341
22342 Defaults to @samp{#t}.
22343
22344 @end deftypevr
22345
22346 @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
22347 List of common prefixes which, when combined with a repository URL,
22348 generates valid clone URLs for the repository.
22349
22350 Defaults to @samp{()}.
22351
22352 @end deftypevr
22353
22354 @deftypevr {@code{cgit-configuration} parameter} list clone-url
22355 List of @code{clone-url} templates.
22356
22357 Defaults to @samp{()}.
22358
22359 @end deftypevr
22360
22361 @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
22362 Command which will be invoked to format commit messages.
22363
22364 Defaults to @samp{""}.
22365
22366 @end deftypevr
22367
22368 @deftypevr {@code{cgit-configuration} parameter} string commit-sort
22369 Flag which, when set to @samp{date}, enables strict date ordering in the
22370 commit log, and when set to @samp{topo} enables strict topological
22371 ordering.
22372
22373 Defaults to @samp{"git log"}.
22374
22375 @end deftypevr
22376
22377 @deftypevr {@code{cgit-configuration} parameter} file-object css
22378 URL which specifies the css document to include in all cgit pages.
22379
22380 Defaults to @samp{"/share/cgit/cgit.css"}.
22381
22382 @end deftypevr
22383
22384 @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
22385 Specifies a command which will be invoked to format names and email
22386 address of committers, authors, and taggers, as represented in various
22387 places throughout the cgit interface.
22388
22389 Defaults to @samp{""}.
22390
22391 @end deftypevr
22392
22393 @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
22394 Flag which, when set to @samp{#t}, will make cgit generate a HTML
22395 fragment suitable for embedding in other HTML pages.
22396
22397 Defaults to @samp{#f}.
22398
22399 @end deftypevr
22400
22401 @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
22402 Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
22403 commit history graph to the left of the commit messages in the
22404 repository log page.
22405
22406 Defaults to @samp{#f}.
22407
22408 @end deftypevr
22409
22410 @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
22411 Flag which, when set to @samp{#t}, allows all filter settings to be
22412 overridden in repository-specific cgitrc files.
22413
22414 Defaults to @samp{#f}.
22415
22416 @end deftypevr
22417
22418 @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
22419 Flag which, when set to @samp{#t}, allows users to follow a file in the
22420 log view.
22421
22422 Defaults to @samp{#f}.
22423
22424 @end deftypevr
22425
22426 @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
22427 If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
22428 clones.
22429
22430 Defaults to @samp{#t}.
22431
22432 @end deftypevr
22433
22434 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
22435 Flag which, when set to @samp{#t}, will make cgit generate extra links
22436 "summary", "commit", "tree" for each repo in the repository index.
22437
22438 Defaults to @samp{#f}.
22439
22440 @end deftypevr
22441
22442 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
22443 Flag which, when set to @samp{#t}, will make cgit display the owner of
22444 each repo in the repository index.
22445
22446 Defaults to @samp{#t}.
22447
22448 @end deftypevr
22449
22450 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
22451 Flag which, when set to @samp{#t}, will make cgit print the number of
22452 modified files for each commit on the repository log page.
22453
22454 Defaults to @samp{#f}.
22455
22456 @end deftypevr
22457
22458 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
22459 Flag which, when set to @samp{#t}, will make cgit print the number of
22460 added and removed lines for each commit on the repository log page.
22461
22462 Defaults to @samp{#f}.
22463
22464 @end deftypevr
22465
22466 @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
22467 Flag which, when set to @code{#t}, will make cgit display remote
22468 branches in the summary and refs views.
22469
22470 Defaults to @samp{#f}.
22471
22472 @end deftypevr
22473
22474 @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
22475 Flag which, when set to @code{1}, will make cgit use the subject of the
22476 parent commit as link text when generating links to parent commits in
22477 commit view.
22478
22479 Defaults to @samp{#f}.
22480
22481 @end deftypevr
22482
22483 @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
22484 Flag which, when set to @samp{#t}, will make cgit use the subject of the
22485 parent commit as link text when generating links to parent commits in
22486 commit view.
22487
22488 Defaults to @samp{#f}.
22489
22490 @end deftypevr
22491
22492 @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
22493 Flag which, when set to @samp{#t}, will make cgit generate linenumber
22494 links for plaintext blobs printed in the tree view.
22495
22496 Defaults to @samp{#t}.
22497
22498 @end deftypevr
22499
22500 @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
22501 Flag which, when set to @samp{#f}, will allow cgit to use Git config to
22502 set any repo specific settings.
22503
22504 Defaults to @samp{#f}.
22505
22506 @end deftypevr
22507
22508 @deftypevr {@code{cgit-configuration} parameter} file-object favicon
22509 URL used as link to a shortcut icon for cgit.
22510
22511 Defaults to @samp{"/favicon.ico"}.
22512
22513 @end deftypevr
22514
22515 @deftypevr {@code{cgit-configuration} parameter} string footer
22516 The content of the file specified with this option will be included
22517 verbatim at the bottom of all pages (i.e.@: it replaces the standard
22518 "generated by..."@: message).
22519
22520 Defaults to @samp{""}.
22521
22522 @end deftypevr
22523
22524 @deftypevr {@code{cgit-configuration} parameter} string head-include
22525 The content of the file specified with this option will be included
22526 verbatim in the HTML HEAD section on all pages.
22527
22528 Defaults to @samp{""}.
22529
22530 @end deftypevr
22531
22532 @deftypevr {@code{cgit-configuration} parameter} string header
22533 The content of the file specified with this option will be included
22534 verbatim at the top of all pages.
22535
22536 Defaults to @samp{""}.
22537
22538 @end deftypevr
22539
22540 @deftypevr {@code{cgit-configuration} parameter} file-object include
22541 Name of a configfile to include before the rest of the current config-
22542 file is parsed.
22543
22544 Defaults to @samp{""}.
22545
22546 @end deftypevr
22547
22548 @deftypevr {@code{cgit-configuration} parameter} string index-header
22549 The content of the file specified with this option will be included
22550 verbatim above the repository index.
22551
22552 Defaults to @samp{""}.
22553
22554 @end deftypevr
22555
22556 @deftypevr {@code{cgit-configuration} parameter} string index-info
22557 The content of the file specified with this option will be included
22558 verbatim below the heading on the repository index page.
22559
22560 Defaults to @samp{""}.
22561
22562 @end deftypevr
22563
22564 @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
22565 Flag which, if set to @samp{#t}, makes cgit print commit and tag times
22566 in the servers timezone.
22567
22568 Defaults to @samp{#f}.
22569
22570 @end deftypevr
22571
22572 @deftypevr {@code{cgit-configuration} parameter} file-object logo
22573 URL which specifies the source of an image which will be used as a logo
22574 on all cgit pages.
22575
22576 Defaults to @samp{"/share/cgit/cgit.png"}.
22577
22578 @end deftypevr
22579
22580 @deftypevr {@code{cgit-configuration} parameter} string logo-link
22581 URL loaded when clicking on the cgit logo image.
22582
22583 Defaults to @samp{""}.
22584
22585 @end deftypevr
22586
22587 @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
22588 Command which will be invoked to format the Owner column of the main
22589 page.
22590
22591 Defaults to @samp{""}.
22592
22593 @end deftypevr
22594
22595 @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
22596 Number of items to display in atom feeds view.
22597
22598 Defaults to @samp{10}.
22599
22600 @end deftypevr
22601
22602 @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
22603 Number of entries to list per page in "log" view.
22604
22605 Defaults to @samp{50}.
22606
22607 @end deftypevr
22608
22609 @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
22610 Number of commit message characters to display in "log" view.
22611
22612 Defaults to @samp{80}.
22613
22614 @end deftypevr
22615
22616 @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
22617 Specifies the number of entries to list per page on the repository index
22618 page.
22619
22620 Defaults to @samp{50}.
22621
22622 @end deftypevr
22623
22624 @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
22625 Specifies the maximum number of repo description characters to display
22626 on the repository index page.
22627
22628 Defaults to @samp{80}.
22629
22630 @end deftypevr
22631
22632 @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
22633 Specifies the maximum size of a blob to display HTML for in KBytes.
22634
22635 Defaults to @samp{0}.
22636
22637 @end deftypevr
22638
22639 @deftypevr {@code{cgit-configuration} parameter} string max-stats
22640 Maximum statistics period. Valid values are @samp{week},@samp{month},
22641 @samp{quarter} and @samp{year}.
22642
22643 Defaults to @samp{""}.
22644
22645 @end deftypevr
22646
22647 @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
22648 Mimetype for the specified filename extension.
22649
22650 Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
22651 "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
22652 "image/png") (svg "image/svg+xml"))}.
22653
22654 @end deftypevr
22655
22656 @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
22657 Specifies the file to use for automatic mimetype lookup.
22658
22659 Defaults to @samp{""}.
22660
22661 @end deftypevr
22662
22663 @deftypevr {@code{cgit-configuration} parameter} string module-link
22664 Text which will be used as the formatstring for a hyperlink when a
22665 submodule is printed in a directory listing.
22666
22667 Defaults to @samp{""}.
22668
22669 @end deftypevr
22670
22671 @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
22672 If set to the value @samp{#t} caching will be disabled.
22673
22674 Defaults to @samp{#f}.
22675
22676 @end deftypevr
22677
22678 @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
22679 If set to @samp{#t} showing full author email addresses will be
22680 disabled.
22681
22682 Defaults to @samp{#f}.
22683
22684 @end deftypevr
22685
22686 @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
22687 Flag which, when set to @samp{#t}, will make cgit omit the standard
22688 header on all pages.
22689
22690 Defaults to @samp{#f}.
22691
22692 @end deftypevr
22693
22694 @deftypevr {@code{cgit-configuration} parameter} project-list project-list
22695 A list of subdirectories inside of @code{repository-directory}, relative
22696 to it, that should loaded as Git repositories. An empty list means that
22697 all subdirectories will be loaded.
22698
22699 Defaults to @samp{()}.
22700
22701 @end deftypevr
22702
22703 @deftypevr {@code{cgit-configuration} parameter} file-object readme
22704 Text which will be used as default value for @code{cgit-repo-readme}.
22705
22706 Defaults to @samp{""}.
22707
22708 @end deftypevr
22709
22710 @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
22711 If set to @code{#t} and @code{repository-directory} is enabled, if any
22712 repositories are found with a suffix of @code{.git}, this suffix will be
22713 removed for the URL and name.
22714
22715 Defaults to @samp{#f}.
22716
22717 @end deftypevr
22718
22719 @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
22720 Maximum number of files to consider when detecting renames.
22721
22722 Defaults to @samp{-1}.
22723
22724 @end deftypevr
22725
22726 @deftypevr {@code{cgit-configuration} parameter} string repository-sort
22727 The way in which repositories in each section are sorted.
22728
22729 Defaults to @samp{""}.
22730
22731 @end deftypevr
22732
22733 @deftypevr {@code{cgit-configuration} parameter} robots-list robots
22734 Text used as content for the @code{robots} meta-tag.
22735
22736 Defaults to @samp{("noindex" "nofollow")}.
22737
22738 @end deftypevr
22739
22740 @deftypevr {@code{cgit-configuration} parameter} string root-desc
22741 Text printed below the heading on the repository index page.
22742
22743 Defaults to @samp{"a fast webinterface for the git dscm"}.
22744
22745 @end deftypevr
22746
22747 @deftypevr {@code{cgit-configuration} parameter} string root-readme
22748 The content of the file specified with this option will be included
22749 verbatim below thef "about" link on the repository index page.
22750
22751 Defaults to @samp{""}.
22752
22753 @end deftypevr
22754
22755 @deftypevr {@code{cgit-configuration} parameter} string root-title
22756 Text printed as heading on the repository index page.
22757
22758 Defaults to @samp{""}.
22759
22760 @end deftypevr
22761
22762 @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
22763 If set to @samp{#t} and repository-directory is enabled,
22764 repository-directory will recurse into directories whose name starts
22765 with a period. Otherwise, repository-directory will stay away from such
22766 directories, considered as "hidden". Note that this does not apply to
22767 the ".git" directory in non-bare repos.
22768
22769 Defaults to @samp{#f}.
22770
22771 @end deftypevr
22772
22773 @deftypevr {@code{cgit-configuration} parameter} list snapshots
22774 Text which specifies the default set of snapshot formats that cgit
22775 generates links for.
22776
22777 Defaults to @samp{()}.
22778
22779 @end deftypevr
22780
22781 @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
22782 Name of the directory to scan for repositories (represents
22783 @code{scan-path}).
22784
22785 Defaults to @samp{"/srv/git"}.
22786
22787 @end deftypevr
22788
22789 @deftypevr {@code{cgit-configuration} parameter} string section
22790 The name of the current repository section - all repositories defined
22791 after this option will inherit the current section name.
22792
22793 Defaults to @samp{""}.
22794
22795 @end deftypevr
22796
22797 @deftypevr {@code{cgit-configuration} parameter} string section-sort
22798 Flag which, when set to @samp{1}, will sort the sections on the
22799 repository listing by name.
22800
22801 Defaults to @samp{""}.
22802
22803 @end deftypevr
22804
22805 @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
22806 A number which, if defined prior to repository-directory, specifies how
22807 many path elements from each repo path to use as a default section name.
22808
22809 Defaults to @samp{0}.
22810
22811 @end deftypevr
22812
22813 @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
22814 If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
22815 default.
22816
22817 Defaults to @samp{#f}.
22818
22819 @end deftypevr
22820
22821 @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
22822 Specifies a command which will be invoked to format plaintext blobs in
22823 the tree view.
22824
22825 Defaults to @samp{""}.
22826
22827 @end deftypevr
22828
22829 @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
22830 Specifies the number of branches to display in the repository "summary"
22831 view.
22832
22833 Defaults to @samp{10}.
22834
22835 @end deftypevr
22836
22837 @deftypevr {@code{cgit-configuration} parameter} integer summary-log
22838 Specifies the number of log entries to display in the repository
22839 "summary" view.
22840
22841 Defaults to @samp{10}.
22842
22843 @end deftypevr
22844
22845 @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
22846 Specifies the number of tags to display in the repository "summary"
22847 view.
22848
22849 Defaults to @samp{10}.
22850
22851 @end deftypevr
22852
22853 @deftypevr {@code{cgit-configuration} parameter} string strict-export
22854 Filename which, if specified, needs to be present within the repository
22855 for cgit to allow access to that repository.
22856
22857 Defaults to @samp{""}.
22858
22859 @end deftypevr
22860
22861 @deftypevr {@code{cgit-configuration} parameter} string virtual-root
22862 URL which, if specified, will be used as root for all cgit links.
22863
22864 Defaults to @samp{"/"}.
22865
22866 @end deftypevr
22867
22868 @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
22869 A list of @dfn{cgit-repo} records to use with config.
22870
22871 Defaults to @samp{()}.
22872
22873 Available @code{repository-cgit-configuration} fields are:
22874
22875 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
22876 A mask of snapshot formats for this repo that cgit generates links for,
22877 restricted by the global @code{snapshots} setting.
22878
22879 Defaults to @samp{()}.
22880
22881 @end deftypevr
22882
22883 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
22884 Override the default @code{source-filter}.
22885
22886 Defaults to @samp{""}.
22887
22888 @end deftypevr
22889
22890 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
22891 The relative URL used to access the repository.
22892
22893 Defaults to @samp{""}.
22894
22895 @end deftypevr
22896
22897 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
22898 Override the default @code{about-filter}.
22899
22900 Defaults to @samp{""}.
22901
22902 @end deftypevr
22903
22904 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
22905 Flag which, when set to @samp{age}, enables date ordering in the branch
22906 ref list, and when set to @samp{name} enables ordering by branch name.
22907
22908 Defaults to @samp{""}.
22909
22910 @end deftypevr
22911
22912 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
22913 A list of URLs which can be used to clone repo.
22914
22915 Defaults to @samp{()}.
22916
22917 @end deftypevr
22918
22919 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
22920 Override the default @code{commit-filter}.
22921
22922 Defaults to @samp{""}.
22923
22924 @end deftypevr
22925
22926 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
22927 Flag which, when set to @samp{date}, enables strict date ordering in the
22928 commit log, and when set to @samp{topo} enables strict topological
22929 ordering.
22930
22931 Defaults to @samp{""}.
22932
22933 @end deftypevr
22934
22935 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
22936 The name of the default branch for this repository. If no such branch
22937 exists in the repository, the first branch name (when sorted) is used as
22938 default instead. By default branch pointed to by HEAD, or "master" if
22939 there is no suitable HEAD.
22940
22941 Defaults to @samp{""}.
22942
22943 @end deftypevr
22944
22945 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
22946 The value to show as repository description.
22947
22948 Defaults to @samp{""}.
22949
22950 @end deftypevr
22951
22952 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
22953 The value to show as repository homepage.
22954
22955 Defaults to @samp{""}.
22956
22957 @end deftypevr
22958
22959 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
22960 Override the default @code{email-filter}.
22961
22962 Defaults to @samp{""}.
22963
22964 @end deftypevr
22965
22966 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
22967 A flag which can be used to disable the global setting
22968 @code{enable-commit-graph?}.
22969
22970 Defaults to @samp{disabled}.
22971
22972 @end deftypevr
22973
22974 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
22975 A flag which can be used to disable the global setting
22976 @code{enable-log-filecount?}.
22977
22978 Defaults to @samp{disabled}.
22979
22980 @end deftypevr
22981
22982 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
22983 A flag which can be used to disable the global setting
22984 @code{enable-log-linecount?}.
22985
22986 Defaults to @samp{disabled}.
22987
22988 @end deftypevr
22989
22990 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
22991 Flag which, when set to @code{#t}, will make cgit display remote
22992 branches in the summary and refs views.
22993
22994 Defaults to @samp{disabled}.
22995
22996 @end deftypevr
22997
22998 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
22999 A flag which can be used to override the global setting
23000 @code{enable-subject-links?}.
23001
23002 Defaults to @samp{disabled}.
23003
23004 @end deftypevr
23005
23006 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
23007 A flag which can be used to override the global setting
23008 @code{enable-html-serving?}.
23009
23010 Defaults to @samp{disabled}.
23011
23012 @end deftypevr
23013
23014 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
23015 Flag which, when set to @code{#t}, hides the repository from the
23016 repository index.
23017
23018 Defaults to @samp{#f}.
23019
23020 @end deftypevr
23021
23022 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
23023 Flag which, when set to @samp{#t}, ignores the repository.
23024
23025 Defaults to @samp{#f}.
23026
23027 @end deftypevr
23028
23029 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
23030 URL which specifies the source of an image which will be used as a logo
23031 on this repo’s pages.
23032
23033 Defaults to @samp{""}.
23034
23035 @end deftypevr
23036
23037 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
23038 URL loaded when clicking on the cgit logo image.
23039
23040 Defaults to @samp{""}.
23041
23042 @end deftypevr
23043
23044 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
23045 Override the default @code{owner-filter}.
23046
23047 Defaults to @samp{""}.
23048
23049 @end deftypevr
23050
23051 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
23052 Text which will be used as the formatstring for a hyperlink when a
23053 submodule is printed in a directory listing. The arguments for the
23054 formatstring are the path and SHA1 of the submodule commit.
23055
23056 Defaults to @samp{""}.
23057
23058 @end deftypevr
23059
23060 @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
23061 Text which will be used as the formatstring for a hyperlink when a
23062 submodule with the specified subdirectory path is printed in a directory
23063 listing.
23064
23065 Defaults to @samp{()}.
23066
23067 @end deftypevr
23068
23069 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
23070 Override the default maximum statistics period.
23071
23072 Defaults to @samp{""}.
23073
23074 @end deftypevr
23075
23076 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
23077 The value to show as repository name.
23078
23079 Defaults to @samp{""}.
23080
23081 @end deftypevr
23082
23083 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
23084 A value used to identify the owner of the repository.
23085
23086 Defaults to @samp{""}.
23087
23088 @end deftypevr
23089
23090 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
23091 An absolute path to the repository directory.
23092
23093 Defaults to @samp{""}.
23094
23095 @end deftypevr
23096
23097 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
23098 A path (relative to repo) which specifies a file to include verbatim as
23099 the "About" page for this repo.
23100
23101 Defaults to @samp{""}.
23102
23103 @end deftypevr
23104
23105 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
23106 The name of the current repository section - all repositories defined
23107 after this option will inherit the current section name.
23108
23109 Defaults to @samp{""}.
23110
23111 @end deftypevr
23112
23113 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
23114 Extra options will be appended to cgitrc file.
23115
23116 Defaults to @samp{()}.
23117
23118 @end deftypevr
23119
23120 @end deftypevr
23121
23122 @deftypevr {@code{cgit-configuration} parameter} list extra-options
23123 Extra options will be appended to cgitrc file.
23124
23125 Defaults to @samp{()}.
23126
23127 @end deftypevr
23128
23129
23130 @c %end of fragment
23131
23132 However, it could be that you just want to get a @code{cgitrc} up and
23133 running. In that case, you can pass an @code{opaque-cgit-configuration}
23134 as a record to @code{cgit-service-type}. As its name indicates, an
23135 opaque configuration does not have easy reflective capabilities.
23136
23137 Available @code{opaque-cgit-configuration} fields are:
23138
23139 @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
23140 The cgit package.
23141 @end deftypevr
23142
23143 @deftypevr {@code{opaque-cgit-configuration} parameter} string string
23144 The contents of the @code{cgitrc}, as a string.
23145 @end deftypevr
23146
23147 For example, if your @code{cgitrc} is just the empty string, you
23148 could instantiate a cgit service like this:
23149
23150 @example
23151 (service cgit-service-type
23152 (opaque-cgit-configuration
23153 (cgitrc "")))
23154 @end example
23155
23156 @subsubheading Gitolite Service
23157
23158 @cindex Gitolite service
23159 @cindex Git, hosting
23160 @uref{http://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
23161 repositories on a central server.
23162
23163 Gitolite can handle multiple repositories and users, and supports flexible
23164 configuration of the permissions for the users on the repositories.
23165
23166 The following example will configure Gitolite using the default @code{git}
23167 user, and the provided SSH public key.
23168
23169 @example
23170 (service gitolite-service-type
23171 (gitolite-configuration
23172 (admin-pubkey (plain-file
23173 "yourname.pub"
23174 "ssh-rsa AAAA... guix@@example.com"))))
23175 @end example
23176
23177 Gitolite is configured through a special admin repository which you can clone,
23178 for example, if you setup Gitolite on @code{example.com}, you would run the
23179 following command to clone the admin repository.
23180
23181 @example
23182 git clone git@@example.com:gitolite-admin
23183 @end example
23184
23185 When the Gitolite service is activated, the provided @code{admin-pubkey} will
23186 be inserted in to the @file{keydir} directory in the gitolite-admin
23187 repository. If this results in a change in the repository, it will be
23188 committed using the message ``gitolite setup by GNU Guix''.
23189
23190 @deftp {Data Type} gitolite-configuration
23191 Data type representing the configuration for @code{gitolite-service-type}.
23192
23193 @table @asis
23194 @item @code{package} (default: @var{gitolite})
23195 Gitolite package to use.
23196
23197 @item @code{user} (default: @var{git})
23198 User to use for Gitolite. This will be user that you use when accessing
23199 Gitolite over SSH.
23200
23201 @item @code{group} (default: @var{git})
23202 Group to use for Gitolite.
23203
23204 @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
23205 Directory in which to store the Gitolite configuration and repositories.
23206
23207 @item @code{rc-file} (default: @var{(gitolite-rc-file)})
23208 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
23209 representing the configuration for Gitolite.
23210
23211 @item @code{admin-pubkey} (default: @var{#f})
23212 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
23213 setup Gitolite. This will be inserted in to the @file{keydir} directory
23214 within the gitolite-admin repository.
23215
23216 To specify the SSH key as a string, use the @code{plain-file} function.
23217
23218 @example
23219 (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
23220 @end example
23221
23222 @end table
23223 @end deftp
23224
23225 @deftp {Data Type} gitolite-rc-file
23226 Data type representing the Gitolite RC file.
23227
23228 @table @asis
23229 @item @code{umask} (default: @code{#o0077})
23230 This controls the permissions Gitolite sets on the repositories and their
23231 contents.
23232
23233 A value like @code{#o0027} will give read access to the group used by Gitolite
23234 (by default: @code{git}). This is necessary when using Gitolite with software
23235 like cgit or gitweb.
23236
23237 @item @code{git-config-keys} (default: @code{""})
23238 Gitolite allows you to set git config values using the "config" keyword. This
23239 setting allows control over the config keys to accept.
23240
23241 @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
23242 Set the role names allowed to be used by users running the perms command.
23243
23244 @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
23245 This setting controls the commands and features to enable within Gitolite.
23246
23247 @end table
23248 @end deftp
23249
23250
23251 @node Game Services
23252 @subsection Game Services
23253
23254 @subsubheading The Battle for Wesnoth Service
23255 @cindex wesnothd
23256 @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
23257 based tactical strategy game, with several single player campaigns, and
23258 multiplayer games (both networked and local).
23259
23260 @defvar {Scheme Variable} wesnothd-service-type
23261 Service type for the wesnothd service. Its value must be a
23262 @code{wesnothd-configuration} object. To run wesnothd in the default
23263 configuration, instantiate it as:
23264
23265 @example
23266 (service wesnothd-service-type)
23267 @end example
23268 @end defvar
23269
23270 @deftp {Data Type} wesnothd-configuration
23271 Data type representing the configuration of @command{wesnothd}.
23272
23273 @table @asis
23274 @item @code{package} (default: @code{wesnoth-server})
23275 The wesnoth server package to use.
23276
23277 @item @code{port} (default: @code{15000})
23278 The port to bind the server to.
23279 @end table
23280 @end deftp
23281
23282 @node Miscellaneous Services
23283 @subsection Miscellaneous Services
23284
23285 @cindex fingerprint
23286 @subsubheading Fingerprint Service
23287
23288 The @code{(gnu services authentication)} module provides a DBus service to
23289 read and identify fingerprints via a fingerprint sensor.
23290
23291 @defvr {Scheme Variable} fprintd-service-type
23292 The service type for @command{fprintd}, which provides the fingerprint
23293 reading capability.
23294
23295 @example
23296 (service fprintd-service-type)
23297 @end example
23298 @end defvr
23299
23300 @cindex sysctl
23301 @subsubheading System Control Service
23302
23303 The @code{(gnu services sysctl)} provides a service to configure kernel
23304 parameters at boot.
23305
23306 @defvr {Scheme Variable} sysctl-service-type
23307 The service type for @command{sysctl}, which modifies kernel parameters
23308 under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
23309 instantiated as:
23310
23311 @example
23312 (service sysctl-service-type
23313 (sysctl-configuration
23314 (settings '(("net.ipv4.ip_forward" . "1")))))
23315 @end example
23316 @end defvr
23317
23318 @deftp {Data Type} sysctl-configuration
23319 The data type representing the configuration of @command{sysctl}.
23320
23321 @table @asis
23322 @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
23323 The @command{sysctl} executable to use.
23324
23325 @item @code{settings} (default: @code{'()})
23326 An association list specifies kernel parameters and their values.
23327 @end table
23328 @end deftp
23329
23330 @cindex pcscd
23331 @subsubheading PC/SC Smart Card Daemon Service
23332
23333 The @code{(gnu services security-token)} module provides the following service
23334 to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
23335 daemon program for pcsc-lite and the MuscleCard framework. It is a resource
23336 manager that coordinates communications with smart card readers, smart cards
23337 and cryptographic tokens that are connected to the system.
23338
23339 @defvr {Scheme Variable} pcscd-service-type
23340 Service type for the @command{pcscd} service. Its value must be a
23341 @code{pcscd-configuration} object. To run pcscd in the default
23342 configuration, instantiate it as:
23343
23344 @example
23345 (service pcscd-service-type)
23346 @end example
23347 @end defvr
23348
23349 @deftp {Data Type} pcscd-configuration
23350 The data type representing the configuration of @command{pcscd}.
23351
23352 @table @asis
23353 @item @code{pcsc-lite} (default: @code{pcsc-lite})
23354 The pcsc-lite package that provides pcscd.
23355 @item @code{usb-drivers} (default: @code{(list ccid)})
23356 List of packages that provide USB drivers to pcscd. Drivers are expected to be
23357 under @file{pcsc/drivers} in the store directory of the package.
23358 @end table
23359 @end deftp
23360
23361 @cindex lirc
23362 @subsubheading Lirc Service
23363
23364 The @code{(gnu services lirc)} module provides the following service.
23365
23366 @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
23367 [#:device #f] [#:driver #f] [#:config-file #f] @
23368 [#:extra-options '()]
23369 Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
23370 decodes infrared signals from remote controls.
23371
23372 Optionally, @var{device}, @var{driver} and @var{config-file}
23373 (configuration file name) may be specified. See @command{lircd} manual
23374 for details.
23375
23376 Finally, @var{extra-options} is a list of additional command-line options
23377 passed to @command{lircd}.
23378 @end deffn
23379
23380 @cindex spice
23381 @subsubheading Spice Service
23382
23383 The @code{(gnu services spice)} module provides the following service.
23384
23385 @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
23386 Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
23387 that enables sharing the clipboard with a vm and setting the guest display
23388 resolution when the graphical console window resizes.
23389 @end deffn
23390
23391 @cindex inputattach
23392 @subsubheading inputattach Service
23393
23394 @cindex tablet input, for Xorg
23395 @cindex touchscreen input, for Xorg
23396 The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
23397 use input devices such as Wacom tablets, touchscreens, or joysticks with the
23398 Xorg display server.
23399
23400 @deffn {Scheme Variable} inputattach-service-type
23401 Type of a service that runs @command{inputattach} on a device and
23402 dispatches events from it.
23403 @end deffn
23404
23405 @deftp {Data Type} inputattach-configuration
23406 @table @asis
23407 @item @code{device-type} (default: @code{"wacom"})
23408 The type of device to connect to. Run @command{inputattach --help}, from the
23409 @code{inputattach} package, to see the list of supported device types.
23410
23411 @item @code{device} (default: @code{"/dev/ttyS0"})
23412 The device file to connect to the device.
23413
23414 @item @code{log-file} (default: @code{#f})
23415 If true, this must be the name of a file to log messages to.
23416 @end table
23417 @end deftp
23418
23419 @subsection Dictionary Services
23420 @cindex dictionary
23421 The @code{(gnu services dict)} module provides the following service:
23422
23423 @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
23424 Return a service that runs the @command{dicod} daemon, an implementation
23425 of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
23426
23427 The optional @var{config} argument specifies the configuration for
23428 @command{dicod}, which should be a @code{<dicod-configuration>} object, by
23429 default it serves the GNU Collaborative International Dictonary of English.
23430
23431 You can add @command{open localhost} to your @file{~/.dico} file to make
23432 @code{localhost} the default server for @command{dico} client
23433 (@pxref{Initialization File,,, dico, GNU Dico Manual}).
23434 @end deffn
23435
23436 @deftp {Data Type} dicod-configuration
23437 Data type representing the configuration of dicod.
23438
23439 @table @asis
23440 @item @code{dico} (default: @var{dico})
23441 Package object of the GNU Dico dictionary server.
23442
23443 @item @code{interfaces} (default: @var{'("localhost")})
23444 This is the list of IP addresses and ports and possibly socket file
23445 names to listen to (@pxref{Server Settings, @code{listen} directive,,
23446 dico, GNU Dico Manual}).
23447
23448 @item @code{handlers} (default: @var{'()})
23449 List of @code{<dicod-handler>} objects denoting handlers (module instances).
23450
23451 @item @code{databases} (default: @var{(list %dicod-database:gcide)})
23452 List of @code{<dicod-database>} objects denoting dictionaries to be served.
23453 @end table
23454 @end deftp
23455
23456 @deftp {Data Type} dicod-handler
23457 Data type representing a dictionary handler (module instance).
23458
23459 @table @asis
23460 @item @code{name}
23461 Name of the handler (module instance).
23462
23463 @item @code{module} (default: @var{#f})
23464 Name of the dicod module of the handler (instance). If it is @code{#f},
23465 the module has the same name as the handler.
23466 (@pxref{Modules,,, dico, GNU Dico Manual}).
23467
23468 @item @code{options}
23469 List of strings or gexps representing the arguments for the module handler
23470 @end table
23471 @end deftp
23472
23473 @deftp {Data Type} dicod-database
23474 Data type representing a dictionary database.
23475
23476 @table @asis
23477 @item @code{name}
23478 Name of the database, will be used in DICT commands.
23479
23480 @item @code{handler}
23481 Name of the dicod handler (module instance) used by this database
23482 (@pxref{Handlers,,, dico, GNU Dico Manual}).
23483
23484 @item @code{complex?} (default: @var{#f})
23485 Whether the database configuration complex. The complex configuration
23486 will need a corresponding @code{<dicod-handler>} object, otherwise not.
23487
23488 @item @code{options}
23489 List of strings or gexps representing the arguments for the database
23490 (@pxref{Databases,,, dico, GNU Dico Manual}).
23491 @end table
23492 @end deftp
23493
23494 @defvr {Scheme Variable} %dicod-database:gcide
23495 A @code{<dicod-database>} object serving the GNU Collaborative International
23496 Dictionary of English using the @code{gcide} package.
23497 @end defvr
23498
23499 The following is an example @code{dicod-service} configuration.
23500
23501 @example
23502 (dicod-service #:config
23503 (dicod-configuration
23504 (handlers (list (dicod-handler
23505 (name "wordnet")
23506 (module "dictorg")
23507 (options
23508 (list #~(string-append "dbdir=" #$wordnet))))))
23509 (databases (list (dicod-database
23510 (name "wordnet")
23511 (complex? #t)
23512 (handler "wordnet")
23513 (options '("database=wn")))
23514 %dicod-database:gcide))))
23515 @end example
23516
23517 @cindex Docker
23518 @subsubheading Docker Service
23519
23520 The @code{(gnu services docker)} module provides the following service.
23521
23522 @defvr {Scheme Variable} docker-service-type
23523
23524 This is the type of the service that runs @url{http://www.docker.com,Docker},
23525 a daemon that can execute application bundles (sometimes referred to as
23526 ``containers'') in isolated environments.
23527
23528 @end defvr
23529
23530 @deftp {Data Type} docker-configuration
23531 This is the data type representing the configuration of Docker and Containerd.
23532
23533 @table @asis
23534
23535 @item @code{package} (default: @code{docker})
23536 The Docker package to use.
23537
23538 @item @code{containerd} (default: @var{containerd})
23539 The Containerd package to use.
23540
23541 @end table
23542 @end deftp
23543
23544 @node Setuid Programs
23545 @section Setuid Programs
23546
23547 @cindex setuid programs
23548 Some programs need to run with ``root'' privileges, even when they are
23549 launched by unprivileged users. A notorious example is the
23550 @command{passwd} program, which users can run to change their
23551 password, and which needs to access the @file{/etc/passwd} and
23552 @file{/etc/shadow} files---something normally restricted to root, for
23553 obvious security reasons. To address that, these executables are
23554 @dfn{setuid-root}, meaning that they always run with root privileges
23555 (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
23556 for more info about the setuid mechanism.)
23557
23558 The store itself @emph{cannot} contain setuid programs: that would be a
23559 security issue since any user on the system can write derivations that
23560 populate the store (@pxref{The Store}). Thus, a different mechanism is
23561 used: instead of changing the setuid bit directly on files that are in
23562 the store, we let the system administrator @emph{declare} which programs
23563 should be setuid root.
23564
23565 The @code{setuid-programs} field of an @code{operating-system}
23566 declaration contains a list of G-expressions denoting the names of
23567 programs to be setuid-root (@pxref{Using the Configuration System}).
23568 For instance, the @command{passwd} program, which is part of the Shadow
23569 package, can be designated by this G-expression (@pxref{G-Expressions}):
23570
23571 @example
23572 #~(string-append #$shadow "/bin/passwd")
23573 @end example
23574
23575 A default set of setuid programs is defined by the
23576 @code{%setuid-programs} variable of the @code{(gnu system)} module.
23577
23578 @defvr {Scheme Variable} %setuid-programs
23579 A list of G-expressions denoting common programs that are setuid-root.
23580
23581 The list includes commands such as @command{passwd}, @command{ping},
23582 @command{su}, and @command{sudo}.
23583 @end defvr
23584
23585 Under the hood, the actual setuid programs are created in the
23586 @file{/run/setuid-programs} directory at system activation time. The
23587 files in this directory refer to the ``real'' binaries, which are in the
23588 store.
23589
23590 @node X.509 Certificates
23591 @section X.509 Certificates
23592
23593 @cindex HTTPS, certificates
23594 @cindex X.509 certificates
23595 @cindex TLS
23596 Web servers available over HTTPS (that is, HTTP over the transport-layer
23597 security mechanism, TLS) send client programs an @dfn{X.509 certificate}
23598 that the client can then use to @emph{authenticate} the server. To do
23599 that, clients verify that the server's certificate is signed by a
23600 so-called @dfn{certificate authority} (CA). But to verify the CA's
23601 signature, clients must have first acquired the CA's certificate.
23602
23603 Web browsers such as GNU@tie{}IceCat include their own set of CA
23604 certificates, such that they are able to verify CA signatures
23605 out-of-the-box.
23606
23607 However, most other programs that can talk HTTPS---@command{wget},
23608 @command{git}, @command{w3m}, etc.---need to be told where CA
23609 certificates can be found.
23610
23611 @cindex @code{nss-certs}
23612 In Guix, this is done by adding a package that provides certificates
23613 to the @code{packages} field of the @code{operating-system} declaration
23614 (@pxref{operating-system Reference}). Guix includes one such package,
23615 @code{nss-certs}, which is a set of CA certificates provided as part of
23616 Mozilla's Network Security Services.
23617
23618 Note that it is @emph{not} part of @var{%base-packages}, so you need to
23619 explicitly add it. The @file{/etc/ssl/certs} directory, which is where
23620 most applications and libraries look for certificates by default, points
23621 to the certificates installed globally.
23622
23623 Unprivileged users, including users of Guix on a foreign distro,
23624 can also install their own certificate package in
23625 their profile. A number of environment variables need to be defined so
23626 that applications and libraries know where to find them. Namely, the
23627 OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
23628 variables. Some applications add their own environment variables; for
23629 instance, the Git version control system honors the certificate bundle
23630 pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
23631 would typically run something like:
23632
23633 @example
23634 $ guix package -i nss-certs
23635 $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
23636 $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
23637 $ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
23638 @end example
23639
23640 As another example, R requires the @code{CURL_CA_BUNDLE} environment
23641 variable to point to a certificate bundle, so you would have to run
23642 something like this:
23643
23644 @example
23645 $ guix package -i nss-certs
23646 $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
23647 @end example
23648
23649 For other applications you may want to look up the required environment
23650 variable in the relevant documentation.
23651
23652
23653 @node Name Service Switch
23654 @section Name Service Switch
23655
23656 @cindex name service switch
23657 @cindex NSS
23658 The @code{(gnu system nss)} module provides bindings to the
23659 configuration file of the libc @dfn{name service switch} or @dfn{NSS}
23660 (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
23661 Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
23662 extended with new ``name'' lookup methods for system databases, which
23663 includes host names, service names, user accounts, and more (@pxref{Name
23664 Service Switch, System Databases and Name Service Switch,, libc, The GNU
23665 C Library Reference Manual}).
23666
23667 The NSS configuration specifies, for each system database, which lookup
23668 method is to be used, and how the various methods are chained
23669 together---for instance, under which circumstances NSS should try the
23670 next method in the list. The NSS configuration is given in the
23671 @code{name-service-switch} field of @code{operating-system} declarations
23672 (@pxref{operating-system Reference, @code{name-service-switch}}).
23673
23674 @cindex nss-mdns
23675 @cindex .local, host name lookup
23676 As an example, the declaration below configures the NSS to use the
23677 @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
23678 back-end}, which supports host name lookups over multicast DNS (mDNS)
23679 for host names ending in @code{.local}:
23680
23681 @example
23682 (name-service-switch
23683 (hosts (list %files ;first, check /etc/hosts
23684
23685 ;; If the above did not succeed, try
23686 ;; with 'mdns_minimal'.
23687 (name-service
23688 (name "mdns_minimal")
23689
23690 ;; 'mdns_minimal' is authoritative for
23691 ;; '.local'. When it returns "not found",
23692 ;; no need to try the next methods.
23693 (reaction (lookup-specification
23694 (not-found => return))))
23695
23696 ;; Then fall back to DNS.
23697 (name-service
23698 (name "dns"))
23699
23700 ;; Finally, try with the "full" 'mdns'.
23701 (name-service
23702 (name "mdns")))))
23703 @end example
23704
23705 Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
23706 contains this configuration, so you will not have to type it if all you
23707 want is to have @code{.local} host lookup working.
23708
23709 Note that, in this case, in addition to setting the
23710 @code{name-service-switch} of the @code{operating-system} declaration,
23711 you also need to use @code{avahi-service-type} (@pxref{Networking Services,
23712 @code{avahi-service-type}}), or @var{%desktop-services}, which includes it
23713 (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
23714 to the name service cache daemon (@pxref{Base Services,
23715 @code{nscd-service}}).
23716
23717 For convenience, the following variables provide typical NSS
23718 configurations.
23719
23720 @defvr {Scheme Variable} %default-nss
23721 This is the default name service switch configuration, a
23722 @code{name-service-switch} object.
23723 @end defvr
23724
23725 @defvr {Scheme Variable} %mdns-host-lookup-nss
23726 This is the name service switch configuration with support for host name
23727 lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
23728 @end defvr
23729
23730 The reference for name service switch configuration is given below. It
23731 is a direct mapping of the configuration file format of the C library , so
23732 please refer to the C library manual for more information (@pxref{NSS
23733 Configuration File,,, libc, The GNU C Library Reference Manual}).
23734 Compared to the configuration file format of libc NSS, it has the advantage
23735 not only of adding this warm parenthetic feel that we like, but also
23736 static checks: you will know about syntax errors and typos as soon as you
23737 run @command{guix system}.
23738
23739 @deftp {Data Type} name-service-switch
23740
23741 This is the data type representation the configuration of libc's name
23742 service switch (NSS). Each field below represents one of the supported
23743 system databases.
23744
23745 @table @code
23746 @item aliases
23747 @itemx ethers
23748 @itemx group
23749 @itemx gshadow
23750 @itemx hosts
23751 @itemx initgroups
23752 @itemx netgroup
23753 @itemx networks
23754 @itemx password
23755 @itemx public-key
23756 @itemx rpc
23757 @itemx services
23758 @itemx shadow
23759 The system databases handled by the NSS. Each of these fields must be a
23760 list of @code{<name-service>} objects (see below).
23761 @end table
23762 @end deftp
23763
23764 @deftp {Data Type} name-service
23765
23766 This is the data type representing an actual name service and the
23767 associated lookup action.
23768
23769 @table @code
23770 @item name
23771 A string denoting the name service (@pxref{Services in the NSS
23772 configuration,,, libc, The GNU C Library Reference Manual}).
23773
23774 Note that name services listed here must be visible to nscd. This is
23775 achieved by passing the @code{#:name-services} argument to
23776 @code{nscd-service} the list of packages providing the needed name
23777 services (@pxref{Base Services, @code{nscd-service}}).
23778
23779 @item reaction
23780 An action specified using the @code{lookup-specification} macro
23781 (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
23782 Reference Manual}). For example:
23783
23784 @example
23785 (lookup-specification (unavailable => continue)
23786 (success => return))
23787 @end example
23788 @end table
23789 @end deftp
23790
23791 @node Initial RAM Disk
23792 @section Initial RAM Disk
23793
23794 @cindex initrd
23795 @cindex initial RAM disk
23796 For bootstrapping purposes, the Linux-Libre kernel is passed an
23797 @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
23798 root file system as well as an initialization script. The latter is
23799 responsible for mounting the real root file system, and for loading any
23800 kernel modules that may be needed to achieve that.
23801
23802 The @code{initrd-modules} field of an @code{operating-system}
23803 declaration allows you to specify Linux-libre kernel modules that must
23804 be available in the initrd. In particular, this is where you would list
23805 modules needed to actually drive the hard disk where your root partition
23806 is---although the default value of @code{initrd-modules} should cover
23807 most use cases. For example, assuming you need the @code{megaraid_sas}
23808 module in addition to the default modules to be able to access your root
23809 file system, you would write:
23810
23811 @example
23812 (operating-system
23813 ;; @dots{}
23814 (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
23815 @end example
23816
23817 @defvr {Scheme Variable} %base-initrd-modules
23818 This is the list of kernel modules included in the initrd by default.
23819 @end defvr
23820
23821 Furthermore, if you need lower-level customization, the @code{initrd}
23822 field of an @code{operating-system} declaration allows
23823 you to specify which initrd you would like to use. The @code{(gnu
23824 system linux-initrd)} module provides three ways to build an initrd: the
23825 high-level @code{base-initrd} procedure and the low-level
23826 @code{raw-initrd} and @code{expression->initrd} procedures.
23827
23828 The @code{base-initrd} procedure is intended to cover most common uses.
23829 For example, if you want to add a bunch of kernel modules to be loaded
23830 at boot time, you can define the @code{initrd} field of the operating
23831 system declaration like this:
23832
23833 @example
23834 (initrd (lambda (file-systems . rest)
23835 ;; Create a standard initrd but set up networking
23836 ;; with the parameters QEMU expects by default.
23837 (apply base-initrd file-systems
23838 #:qemu-networking? #t
23839 rest)))
23840 @end example
23841
23842 The @code{base-initrd} procedure also handles common use cases that
23843 involves using the system as a QEMU guest, or as a ``live'' system with
23844 volatile root file system.
23845
23846 The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
23847 Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
23848 such as trying to guess which kernel modules and packages should be included
23849 to the initrd. An example use of @code{raw-initrd} is when a user has
23850 a custom Linux kernel configuration and default kernel modules included by
23851 @code{base-initrd} are not available.
23852
23853 The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
23854 honors several options passed on the Linux kernel command line
23855 (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
23856 @code{-append} option of QEMU), notably:
23857
23858 @table @code
23859 @item --load=@var{boot}
23860 Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
23861 program, once it has mounted the root file system.
23862
23863 Guix uses this option to yield control to a boot program that runs the
23864 service activation programs and then spawns the GNU@tie{}Shepherd, the
23865 initialization system.
23866
23867 @item --root=@var{root}
23868 Mount @var{root} as the root file system. @var{root} can be a
23869 device name like @code{/dev/sda1}, a file system label, or a file system
23870 UUID.
23871
23872 @item --system=@var{system}
23873 Have @file{/run/booted-system} and @file{/run/current-system} point to
23874 @var{system}.
23875
23876 @item modprobe.blacklist=@var{modules}@dots{}
23877 @cindex module, black-listing
23878 @cindex black list, of kernel modules
23879 Instruct the initial RAM disk as well as the @command{modprobe} command
23880 (from the kmod package) to refuse to load @var{modules}. @var{modules}
23881 must be a comma-separated list of module names---e.g.,
23882 @code{usbkbd,9pnet}.
23883
23884 @item --repl
23885 Start a read-eval-print loop (REPL) from the initial RAM disk before it
23886 tries to load kernel modules and to mount the root file system. Our
23887 marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
23888 love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
23889 Manual}, for more information on Guile's REPL.
23890
23891 @end table
23892
23893 Now that you know all the features that initial RAM disks produced by
23894 @code{base-initrd} and @code{raw-initrd} provide,
23895 here is how to use it and customize it further.
23896
23897 @cindex initrd
23898 @cindex initial RAM disk
23899 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
23900 [#:linux-modules '()] [#:mapped-devices '()] @
23901 [#:keyboard-layout #f] @
23902 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
23903 Return a derivation that builds a raw initrd. @var{file-systems} is
23904 a list of file systems to be mounted by the initrd, possibly in addition to
23905 the root file system specified on the kernel command line via @code{--root}.
23906 @var{linux-modules} is a list of kernel modules to be loaded at boot time.
23907 @var{mapped-devices} is a list of device mappings to realize before
23908 @var{file-systems} are mounted (@pxref{Mapped Devices}).
23909 @var{helper-packages} is a list of packages to be copied in the initrd. It may
23910 include @code{e2fsck/static} or other packages needed by the initrd to check
23911 the root file system.
23912
23913 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
23914 the desired console keyboard layout. This is done before @var{mapped-devices}
23915 are set up and before @var{file-systems} are mounted such that, should the
23916 user need to enter a passphrase or use the REPL, this happens using the
23917 intended keyboard layout.
23918
23919 When @var{qemu-networking?} is true, set up networking with the standard QEMU
23920 parameters. When @var{virtio?} is true, load additional modules so that the
23921 initrd can be used as a QEMU guest with para-virtualized I/O drivers.
23922
23923 When @var{volatile-root?} is true, the root file system is writable but any changes
23924 to it are lost.
23925 @end deffn
23926
23927 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
23928 [#:mapped-devices '()] [#:keyboard-layout #f] @
23929 [#:qemu-networking? #f] [#:volatile-root? #f] @
23930 [#:linux-modules '()]
23931 Return as a file-like object a generic initrd, with kernel
23932 modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
23933 mounted by the initrd, possibly in addition to the root file system specified
23934 on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device
23935 mappings to realize before @var{file-systems} are mounted.
23936
23937 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
23938 the desired console keyboard layout. This is done before @var{mapped-devices}
23939 are set up and before @var{file-systems} are mounted such that, should the
23940 user need to enter a passphrase or use the REPL, this happens using the
23941 intended keyboard layout.
23942
23943 @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
23944
23945 The initrd is automatically populated with all the kernel modules necessary
23946 for @var{file-systems} and for the given options. Additional kernel
23947 modules can be listed in @var{linux-modules}. They will be added to the initrd, and
23948 loaded at boot time in the order in which they appear.
23949 @end deffn
23950
23951 Needless to say, the initrds we produce and use embed a
23952 statically-linked Guile, and the initialization program is a Guile
23953 program. That gives a lot of flexibility. The
23954 @code{expression->initrd} procedure builds such an initrd, given the
23955 program to run in that initrd.
23956
23957 @deffn {Scheme Procedure} expression->initrd @var{exp} @
23958 [#:guile %guile-static-stripped] [#:name "guile-initrd"]
23959 Return as a file-like object a Linux initrd (a gzipped cpio archive)
23960 containing @var{guile} and that evaluates @var{exp}, a G-expression,
23961 upon booting. All the derivations referenced by @var{exp} are
23962 automatically copied to the initrd.
23963 @end deffn
23964
23965 @node Bootloader Configuration
23966 @section Bootloader Configuration
23967
23968 @cindex bootloader
23969 @cindex boot loader
23970
23971 The operating system supports multiple bootloaders. The bootloader is
23972 configured using @code{bootloader-configuration} declaration. All the
23973 fields of this structure are bootloader agnostic except for one field,
23974 @code{bootloader} that indicates the bootloader to be configured and
23975 installed.
23976
23977 Some of the bootloaders do not honor every field of
23978 @code{bootloader-configuration}. For instance, the extlinux
23979 bootloader does not support themes and thus ignores the @code{theme}
23980 field.
23981
23982 @deftp {Data Type} bootloader-configuration
23983 The type of a bootloader configuration declaration.
23984
23985 @table @asis
23986
23987 @item @code{bootloader}
23988 @cindex EFI, bootloader
23989 @cindex UEFI, bootloader
23990 @cindex BIOS, bootloader
23991 The bootloader to use, as a @code{bootloader} object. For now
23992 @code{grub-bootloader}, @code{grub-efi-bootloader},
23993 @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
23994
23995 @vindex grub-efi-bootloader
23996 @code{grub-efi-bootloader} allows to boot on modern systems using the
23997 @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
23998 use if the installation image contains a @file{/sys/firmware/efi} directory
23999 when you boot it on your system.
24000
24001 @vindex grub-bootloader
24002 @code{grub-bootloader} allows you to boot in particular Intel-based machines
24003 in ``legacy'' BIOS mode.
24004
24005 @cindex ARM, bootloaders
24006 @cindex AArch64, bootloaders
24007 Available bootloaders are described in @code{(gnu bootloader @dots{})}
24008 modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
24009 of bootloaders for a wide range of ARM and AArch64 systems, using the
24010 @uref{http://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
24011
24012 @item @code{target}
24013 This is a string denoting the target onto which to install the
24014 bootloader.
24015
24016 The interpretation depends on the bootloader in question. For
24017 @code{grub-bootloader}, for example, it should be a device name understood by
24018 the bootloader @command{installer} command, such as @code{/dev/sda} or
24019 @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
24020 @code{grub-efi-bootloader}, it should be the mount point of the EFI file
24021 system, usually @file{/boot/efi}.
24022
24023 @item @code{menu-entries} (default: @code{()})
24024 A possibly empty list of @code{menu-entry} objects (see below), denoting
24025 entries to appear in the bootloader menu, in addition to the current
24026 system entry and the entry pointing to previous system generations.
24027
24028 @item @code{default-entry} (default: @code{0})
24029 The index of the default boot menu entry. Index 0 is for the entry of the
24030 current system.
24031
24032 @item @code{timeout} (default: @code{5})
24033 The number of seconds to wait for keyboard input before booting. Set to
24034 0 to boot immediately, and to -1 to wait indefinitely.
24035
24036 @cindex keyboard layout, for the bootloader
24037 @item @code{keyboard-layout} (default: @code{#f})
24038 If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
24039 layout, usually US@tie{}English (``qwerty'').
24040
24041 Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
24042 Layout}).
24043
24044 @quotation Note
24045 This option is currently ignored by bootloaders other than @code{grub} and
24046 @code{grub-efi}.
24047 @end quotation
24048
24049 @item @code{theme} (default: @var{#f})
24050 The bootloader theme object describing the theme to use. If no theme
24051 is provided, some bootloaders might use a default theme, that's true
24052 for GRUB.
24053
24054 @item @code{terminal-outputs} (default: @code{'gfxterm})
24055 The output terminals used for the bootloader boot menu, as a list of
24056 symbols. GRUB accepts the values: @code{console}, @code{serial},
24057 @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
24058 @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
24059 corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
24060 configuration,,, grub,GNU GRUB manual}).
24061
24062 @item @code{terminal-inputs} (default: @code{'()})
24063 The input terminals used for the bootloader boot menu, as a list of
24064 symbols. For GRUB, the default is the native platform terminal as
24065 determined at run-time. GRUB accepts the values: @code{console},
24066 @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
24067 @code{usb_keyboard}. This field corresponds to the GRUB variable
24068 @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
24069 manual}).
24070
24071 @item @code{serial-unit} (default: @code{#f})
24072 The serial unit used by the bootloader, as an integer from 0 to 3.
24073 For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
24074 corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
24075
24076 @item @code{serial-speed} (default: @code{#f})
24077 The speed of the serial interface, as an integer. For GRUB, the
24078 default value is chosen at run-time; currently GRUB chooses
24079 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
24080 @end table
24081
24082 @end deftp
24083
24084 @cindex dual boot
24085 @cindex boot menu
24086 Should you want to list additional boot menu entries @i{via} the
24087 @code{menu-entries} field above, you will need to create them with the
24088 @code{menu-entry} form. For example, imagine you want to be able to
24089 boot another distro (hard to imagine!), you can define a menu entry
24090 along these lines:
24091
24092 @example
24093 (menu-entry
24094 (label "The Other Distro")
24095 (linux "/boot/old/vmlinux-2.6.32")
24096 (linux-arguments '("root=/dev/sda2"))
24097 (initrd "/boot/old/initrd"))
24098 @end example
24099
24100 Details below.
24101
24102 @deftp {Data Type} menu-entry
24103 The type of an entry in the bootloader menu.
24104
24105 @table @asis
24106
24107 @item @code{label}
24108 The label to show in the menu---e.g., @code{"GNU"}.
24109
24110 @item @code{linux}
24111 The Linux kernel image to boot, for example:
24112
24113 @example
24114 (file-append linux-libre "/bzImage")
24115 @end example
24116
24117 For GRUB, it is also possible to specify a device explicitly in the
24118 file path using GRUB's device naming convention (@pxref{Naming
24119 convention,,, grub, GNU GRUB manual}), for example:
24120
24121 @example
24122 "(hd0,msdos1)/boot/vmlinuz"
24123 @end example
24124
24125 If the device is specified explicitly as above, then the @code{device}
24126 field is ignored entirely.
24127
24128 @item @code{linux-arguments} (default: @code{()})
24129 The list of extra Linux kernel command-line arguments---e.g.,
24130 @code{("console=ttyS0")}.
24131
24132 @item @code{initrd}
24133 A G-Expression or string denoting the file name of the initial RAM disk
24134 to use (@pxref{G-Expressions}).
24135 @item @code{device} (default: @code{#f})
24136 The device where the kernel and initrd are to be found---i.e., for GRUB,
24137 @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
24138
24139 This may be a file system label (a string), a file system UUID (a
24140 bytevector, @pxref{File Systems}), or @code{#f}, in which case
24141 the bootloader will search the device containing the file specified by
24142 the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
24143 must @emph{not} be an OS device name such as @file{/dev/sda1}.
24144
24145 @end table
24146 @end deftp
24147
24148 @c FIXME: Write documentation once it's stable.
24149 For now only GRUB has theme support. GRUB themes are created using
24150 the @code{grub-theme} form, which is not documented yet.
24151
24152 @defvr {Scheme Variable} %default-theme
24153 This is the default GRUB theme used by the operating system if no
24154 @code{theme} field is specified in @code{bootloader-configuration}
24155 record.
24156
24157 It comes with a fancy background image displaying the GNU and Guix
24158 logos.
24159 @end defvr
24160
24161
24162 @node Invoking guix system
24163 @section Invoking @code{guix system}
24164
24165 Once you have written an operating system declaration as seen in the
24166 previous section, it can be @dfn{instantiated} using the @command{guix
24167 system} command. The synopsis is:
24168
24169 @example
24170 guix system @var{options}@dots{} @var{action} @var{file}
24171 @end example
24172
24173 @var{file} must be the name of a file containing an
24174 @code{operating-system} declaration. @var{action} specifies how the
24175 operating system is instantiated. Currently the following values are
24176 supported:
24177
24178 @table @code
24179 @item search
24180 Display available service type definitions that match the given regular
24181 expressions, sorted by relevance:
24182
24183 @example
24184 $ guix system search console font
24185 name: console-fonts
24186 location: gnu/services/base.scm:729:2
24187 extends: shepherd-root
24188 description: Install the given fonts on the specified ttys (fonts are
24189 + per virtual console on GNU/Linux). The value of this service is a list
24190 + of tty/font pairs like:
24191 +
24192 + '(("tty1" . "LatGrkCyr-8x16"))
24193 relevance: 20
24194
24195 name: mingetty
24196 location: gnu/services/base.scm:1048:2
24197 extends: shepherd-root
24198 description: Provide console login using the `mingetty' program.
24199 relevance: 2
24200
24201 name: login
24202 location: gnu/services/base.scm:775:2
24203 extends: pam
24204 description: Provide a console log-in service as specified by its
24205 + configuration value, a `login-configuration' object.
24206 relevance: 2
24207
24208 @dots{}
24209 @end example
24210
24211 As for @command{guix package --search}, the result is written in
24212 @code{recutils} format, which makes it easy to filter the output
24213 (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
24214
24215 @item reconfigure
24216 Build the operating system described in @var{file}, activate it, and
24217 switch to it@footnote{This action (and the related actions
24218 @code{switch-generation} and @code{roll-back}) are usable only on
24219 systems already running Guix System.}.
24220
24221 This effects all the configuration specified in @var{file}: user
24222 accounts, system services, global package list, setuid programs, etc.
24223 The command starts system services specified in @var{file} that are not
24224 currently running; if a service is currently running this command will
24225 arrange for it to be upgraded the next time it is stopped (e.g.@: by
24226 @code{herd stop X} or @code{herd restart X}).
24227
24228 This command creates a new generation whose number is one greater than
24229 the current generation (as reported by @command{guix system
24230 list-generations}). If that generation already exists, it will be
24231 overwritten. This behavior mirrors that of @command{guix package}
24232 (@pxref{Invoking guix package}).
24233
24234 It also adds a bootloader menu entry for the new OS configuration,
24235 ---unless @option{--no-bootloader} is passed. For GRUB, it moves
24236 entries for older configurations to a submenu, allowing you to choose
24237 an older system generation at boot time should you need it.
24238
24239 @quotation Note
24240 @c The paragraph below refers to the problem discussed at
24241 @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
24242 It is highly recommended to run @command{guix pull} once before you run
24243 @command{guix system reconfigure} for the first time (@pxref{Invoking
24244 guix pull}). Failing to do that you would see an older version of Guix
24245 once @command{reconfigure} has completed.
24246 @end quotation
24247
24248 @item switch-generation
24249 @cindex generations
24250 Switch to an existing system generation. This action atomically
24251 switches the system profile to the specified system generation. It
24252 also rearranges the system's existing bootloader menu entries. It
24253 makes the menu entry for the specified system generation the default,
24254 and it moves the entries for the other generatiors to a submenu, if
24255 supported by the bootloader being used. The next time the system
24256 boots, it will use the specified system generation.
24257
24258 The bootloader itself is not being reinstalled when using this
24259 command. Thus, the installed bootloader is used with an updated
24260 configuration file.
24261
24262 The target generation can be specified explicitly by its generation
24263 number. For example, the following invocation would switch to system
24264 generation 7:
24265
24266 @example
24267 guix system switch-generation 7
24268 @end example
24269
24270 The target generation can also be specified relative to the current
24271 generation with the form @code{+N} or @code{-N}, where @code{+3} means
24272 ``3 generations ahead of the current generation,'' and @code{-1} means
24273 ``1 generation prior to the current generation.'' When specifying a
24274 negative value such as @code{-1}, you must precede it with @code{--} to
24275 prevent it from being parsed as an option. For example:
24276
24277 @example
24278 guix system switch-generation -- -1
24279 @end example
24280
24281 Currently, the effect of invoking this action is @emph{only} to switch
24282 the system profile to an existing generation and rearrange the
24283 bootloader menu entries. To actually start using the target system
24284 generation, you must reboot after running this action. In the future,
24285 it will be updated to do the same things as @command{reconfigure},
24286 like activating and deactivating services.
24287
24288 This action will fail if the specified generation does not exist.
24289
24290 @item roll-back
24291 @cindex rolling back
24292 Switch to the preceding system generation. The next time the system
24293 boots, it will use the preceding system generation. This is the inverse
24294 of @command{reconfigure}, and it is exactly the same as invoking
24295 @command{switch-generation} with an argument of @code{-1}.
24296
24297 Currently, as with @command{switch-generation}, you must reboot after
24298 running this action to actually start using the preceding system
24299 generation.
24300
24301 @item delete-generations
24302 @cindex deleting system generations
24303 @cindex saving space
24304 Delete system generations, making them candidates for garbage collection
24305 (@pxref{Invoking guix gc}, for information on how to run the ``garbage
24306 collector'').
24307
24308 This works in the same way as @command{guix package --delete-generations}
24309 (@pxref{Invoking guix package, @code{--delete-generations}}). With no
24310 arguments, all system generations but the current one are deleted:
24311
24312 @example
24313 guix system delete-generations
24314 @end example
24315
24316 You can also select the generations you want to delete. The example below
24317 deletes all the system generations that are more than two month old:
24318
24319 @example
24320 guix system delete-generations 2m
24321 @end example
24322
24323 Running this command automatically reinstalls the bootloader with an updated
24324 list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
24325 longer lists the generations that have been deleted.
24326
24327 @item build
24328 Build the derivation of the operating system, which includes all the
24329 configuration files and programs needed to boot and run the system.
24330 This action does not actually install anything.
24331
24332 @item init
24333 Populate the given directory with all the files necessary to run the
24334 operating system specified in @var{file}. This is useful for first-time
24335 installations of Guix System. For instance:
24336
24337 @example
24338 guix system init my-os-config.scm /mnt
24339 @end example
24340
24341 copies to @file{/mnt} all the store items required by the configuration
24342 specified in @file{my-os-config.scm}. This includes configuration
24343 files, packages, and so on. It also creates other essential files
24344 needed for the system to operate correctly---e.g., the @file{/etc},
24345 @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
24346
24347 This command also installs bootloader on the target specified in
24348 @file{my-os-config}, unless the @option{--no-bootloader} option was
24349 passed.
24350
24351 @item vm
24352 @cindex virtual machine
24353 @cindex VM
24354 @anchor{guix system vm}
24355 Build a virtual machine that contains the operating system declared in
24356 @var{file}, and return a script to run that virtual machine (VM).
24357
24358 @quotation Note
24359 The @code{vm} action and others below
24360 can use KVM support in the Linux-libre kernel. Specifically, if the
24361 machine has hardware virtualization support, the corresponding
24362 KVM kernel module should be loaded, and the @file{/dev/kvm} device node
24363 must exist and be readable and writable by the user and by the
24364 build users of the daemon (@pxref{Build Environment Setup}).
24365 @end quotation
24366
24367 Arguments given to the script are passed to QEMU as in the example
24368 below, which enables networking and requests 1@tie{}GiB of RAM for the
24369 emulated machine:
24370
24371 @example
24372 $ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
24373 @end example
24374
24375 The VM shares its store with the host system.
24376
24377 Additional file systems can be shared between the host and the VM using
24378 the @code{--share} and @code{--expose} command-line options: the former
24379 specifies a directory to be shared with write access, while the latter
24380 provides read-only access to the shared directory.
24381
24382 The example below creates a VM in which the user's home directory is
24383 accessible read-only, and where the @file{/exchange} directory is a
24384 read-write mapping of @file{$HOME/tmp} on the host:
24385
24386 @example
24387 guix system vm my-config.scm \
24388 --expose=$HOME --share=$HOME/tmp=/exchange
24389 @end example
24390
24391 On GNU/Linux, the default is to boot directly to the kernel; this has
24392 the advantage of requiring only a very tiny root disk image since the
24393 store of the host can then be mounted.
24394
24395 The @code{--full-boot} option forces a complete boot sequence, starting
24396 with the bootloader. This requires more disk space since a root image
24397 containing at least the kernel, initrd, and bootloader data files must
24398 be created. The @code{--image-size} option can be used to specify the
24399 size of the image.
24400
24401 @cindex System images, creation in various formats
24402 @cindex Creating system images in various formats
24403 @item vm-image
24404 @itemx disk-image
24405 @itemx docker-image
24406 Return a virtual machine, disk image, or Docker image of the operating
24407 system declared in @var{file} that stands alone. By default,
24408 @command{guix system} estimates the size of the image needed to store
24409 the system, but you can use the @option{--image-size} option to specify
24410 a value. Docker images are built to contain exactly what they need, so
24411 the @option{--image-size} option is ignored in the case of
24412 @code{docker-image}.
24413
24414 You can specify the root file system type by using the
24415 @option{--file-system-type} option. It defaults to @code{ext4}.
24416
24417 When using @code{vm-image}, the returned image is in qcow2 format, which
24418 the QEMU emulator can efficiently use. @xref{Running Guix in a VM},
24419 for more information on how to run the image in a virtual machine.
24420
24421 When using @code{disk-image}, a raw disk image is produced; it can be
24422 copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
24423 the device corresponding to a USB stick, one can copy the image to it
24424 using the following command:
24425
24426 @example
24427 # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
24428 @end example
24429
24430 When using @code{docker-image}, a Docker image is produced. Guix builds
24431 the image from scratch, not from a pre-existing Docker base image. As a
24432 result, it contains @emph{exactly} what you define in the operating
24433 system configuration file. You can then load the image and launch a
24434 Docker container using commands like the following:
24435
24436 @example
24437 image_id="$(docker load < guix-system-docker-image.tar.gz)"
24438 docker run -e GUIX_NEW_SYSTEM=/var/guix/profiles/system \\
24439 --entrypoint /var/guix/profiles/system/profile/bin/guile \\
24440 $image_id /var/guix/profiles/system/boot
24441 @end example
24442
24443 This command starts a new Docker container from the specified image. It
24444 will boot the Guix system in the usual manner, which means it will
24445 start any services you have defined in the operating system
24446 configuration. Depending on what you run in the Docker container, it
24447 may be necessary to give the container additional permissions. For
24448 example, if you intend to build software using Guix inside of the Docker
24449 container, you may need to pass the @option{--privileged} option to
24450 @code{docker run}.
24451
24452 @item container
24453 Return a script to run the operating system declared in @var{file}
24454 within a container. Containers are a set of lightweight isolation
24455 mechanisms provided by the kernel Linux-libre. Containers are
24456 substantially less resource-demanding than full virtual machines since
24457 the kernel, shared objects, and other resources can be shared with the
24458 host system; this also means they provide thinner isolation.
24459
24460 Currently, the script must be run as root in order to support more than
24461 a single user and group. The container shares its store with the host
24462 system.
24463
24464 As with the @code{vm} action (@pxref{guix system vm}), additional file
24465 systems to be shared between the host and container can be specified
24466 using the @option{--share} and @option{--expose} options:
24467
24468 @example
24469 guix system container my-config.scm \
24470 --expose=$HOME --share=$HOME/tmp=/exchange
24471 @end example
24472
24473 @quotation Note
24474 This option requires Linux-libre 3.19 or newer.
24475 @end quotation
24476
24477 @end table
24478
24479 @var{options} can contain any of the common build options (@pxref{Common
24480 Build Options}). In addition, @var{options} can contain one of the
24481 following:
24482
24483 @table @option
24484 @item --expression=@var{expr}
24485 @itemx -e @var{expr}
24486 Consider the operating-system @var{expr} evaluates to.
24487 This is an alternative to specifying a file which evaluates to an
24488 operating system.
24489 This is used to generate the Guix system installer @pxref{Building the
24490 Installation Image}).
24491
24492 @item --system=@var{system}
24493 @itemx -s @var{system}
24494 Attempt to build for @var{system} instead of the host system type.
24495 This works as per @command{guix build} (@pxref{Invoking guix build}).
24496
24497 @item --derivation
24498 @itemx -d
24499 Return the derivation file name of the given operating system without
24500 building anything.
24501
24502 @item --file-system-type=@var{type}
24503 @itemx -t @var{type}
24504 For the @code{disk-image} action, create a file system of the given
24505 @var{type} on the image.
24506
24507 When this option is omitted, @command{guix system} uses @code{ext4}.
24508
24509 @cindex ISO-9660 format
24510 @cindex CD image format
24511 @cindex DVD image format
24512 @code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
24513 for burning on CDs and DVDs.
24514
24515 @item --image-size=@var{size}
24516 For the @code{vm-image} and @code{disk-image} actions, create an image
24517 of the given @var{size}. @var{size} may be a number of bytes, or it may
24518 include a unit as a suffix (@pxref{Block size, size specifications,,
24519 coreutils, GNU Coreutils}).
24520
24521 When this option is omitted, @command{guix system} computes an estimate
24522 of the image size as a function of the size of the system declared in
24523 @var{file}.
24524
24525 @item --root=@var{file}
24526 @itemx -r @var{file}
24527 Make @var{file} a symlink to the result, and register it as a garbage
24528 collector root.
24529
24530 @item --skip-checks
24531 Skip pre-installation safety checks.
24532
24533 By default, @command{guix system init} and @command{guix system
24534 reconfigure} perform safety checks: they make sure the file systems that
24535 appear in the @code{operating-system} declaration actually exist
24536 (@pxref{File Systems}), and that any Linux kernel modules that may be
24537 needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
24538 RAM Disk}). Passing this option skips these tests altogether.
24539
24540 @cindex on-error
24541 @cindex on-error strategy
24542 @cindex error strategy
24543 @item --on-error=@var{strategy}
24544 Apply @var{strategy} when an error occurs when reading @var{file}.
24545 @var{strategy} may be one of the following:
24546
24547 @table @code
24548 @item nothing-special
24549 Report the error concisely and exit. This is the default strategy.
24550
24551 @item backtrace
24552 Likewise, but also display a backtrace.
24553
24554 @item debug
24555 Report the error and enter Guile's debugger. From there, you can run
24556 commands such as @code{,bt} to get a backtrace, @code{,locals} to
24557 display local variable values, and more generally inspect the state of the
24558 program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
24559 a list of available debugging commands.
24560 @end table
24561 @end table
24562
24563 Once you have built, configured, re-configured, and re-re-configured
24564 your Guix installation, you may find it useful to list the operating
24565 system generations available on disk---and that you can choose from the
24566 bootloader boot menu:
24567
24568 @table @code
24569
24570 @item list-generations
24571 List a summary of each generation of the operating system available on
24572 disk, in a human-readable way. This is similar to the
24573 @option{--list-generations} option of @command{guix package}
24574 (@pxref{Invoking guix package}).
24575
24576 Optionally, one can specify a pattern, with the same syntax that is used
24577 in @command{guix package --list-generations}, to restrict the list of
24578 generations displayed. For instance, the following command displays
24579 generations that are up to 10 days old:
24580
24581 @example
24582 $ guix system list-generations 10d
24583 @end example
24584
24585 @end table
24586
24587 The @command{guix system} command has even more to offer! The following
24588 sub-commands allow you to visualize how your system services relate to
24589 each other:
24590
24591 @anchor{system-extension-graph}
24592 @table @code
24593
24594 @item extension-graph
24595 Emit in Dot/Graphviz format to standard output the @dfn{service
24596 extension graph} of the operating system defined in @var{file}
24597 (@pxref{Service Composition}, for more information on service
24598 extensions.)
24599
24600 The command:
24601
24602 @example
24603 $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
24604 @end example
24605
24606 produces a PDF file showing the extension relations among services.
24607
24608 @anchor{system-shepherd-graph}
24609 @item shepherd-graph
24610 Emit in Dot/Graphviz format to standard output the @dfn{dependency
24611 graph} of shepherd services of the operating system defined in
24612 @var{file}. @xref{Shepherd Services}, for more information and for an
24613 example graph.
24614
24615 @end table
24616
24617 @node Running Guix in a VM
24618 @section Running Guix in a Virtual Machine
24619
24620 @cindex virtual machine
24621 To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
24622 distributed at
24623 @indicateurl{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.@var{system}.xz}
24624 This image is a compressed image in QCOW format. You will first need to
24625 decompress with @command{xz -d}, and then you can pass it to an emulator such
24626 as QEMU (see below for details).
24627
24628 This image boots the Xfce graphical environment and it contains some
24629 commonly-used tools. You can install more software in the image by running
24630 @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
24631 also reconfigure the system based on its initial configuration file available
24632 as @file{/etc/config.scm} (@pxref{Using the Configuration System}).
24633
24634 Instead of using this pre-built image, one can also build their own virtual
24635 machine image using @command{guix system vm-image} (@pxref{Invoking guix
24636 system}). The returned image is in qcow2 format, which the
24637 @uref{http://qemu.org/, QEMU emulator} can efficiently use.
24638
24639 @cindex QEMU
24640 If you built your own image, you must copy it out of the store
24641 (@pxref{The Store}) and give yourself permission to write to the copy
24642 before you can use it. When invoking QEMU, you must choose a system
24643 emulator that is suitable for your hardware platform. Here is a minimal
24644 QEMU invocation that will boot the result of @command{guix system
24645 vm-image} on x86_64 hardware:
24646
24647 @example
24648 $ qemu-system-x86_64 \
24649 -net user -net nic,model=virtio \
24650 -enable-kvm -m 512 \
24651 -device virtio-blk,drive=myhd \
24652 -drive if=none,file=/tmp/qemu-image,id=myhd
24653 @end example
24654
24655 Here is what each of these options means:
24656
24657 @table @code
24658 @item qemu-system-x86_64
24659 This specifies the hardware platform to emulate. This should match the
24660 host.
24661
24662 @item -net user
24663 Enable the unprivileged user-mode network stack. The guest OS can
24664 access the host but not vice versa. This is the simplest way to get the
24665 guest OS online.
24666
24667 @item -net nic,model=virtio
24668 You must create a network interface of a given model. If you do not
24669 create a NIC, the boot will fail. Assuming your hardware platform is
24670 x86_64, you can get a list of available NIC models by running
24671 @command{qemu-system-x86_64 -net nic,model=help}.
24672
24673 @item -enable-kvm
24674 If your system has hardware virtualization extensions, enabling the
24675 virtual machine support (KVM) of the Linux kernel will make things run
24676 faster.
24677
24678 @c To run Xfce + 'guix pull', we need at least 1G of RAM.
24679 @item -m 1024
24680 RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
24681 which may be insufficient for some operations.
24682
24683 @item -device virtio-blk,drive=myhd
24684 Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
24685 ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
24686 better performance than if it were emulating a complete disk drive. See the
24687 QEMU and KVM documentation for more info.
24688
24689 @item -drive if=none,file=/tmp/qemu-image,id=myhd
24690 Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing store the
24691 the ``myhd'' drive.
24692 @end table
24693
24694 The default @command{run-vm.sh} script that is returned by an invocation of
24695 @command{guix system vm} does not add a @command{-net user} flag by default.
24696 To get network access from within the vm add the @code{(dhcp-client-service)}
24697 to your system definition and start the VM using
24698 @command{`guix system vm config.scm` -net user}. An important caveat of using
24699 @command{-net user} for networking is that @command{ping} will not work, because
24700 it uses the ICMP protocol. You'll have to use a different command to check for
24701 network connectivity, for example @command{guix download}.
24702
24703 @subsection Connecting Through SSH
24704
24705 @cindex SSH
24706 @cindex SSH server
24707 To enable SSH inside a VM you need to add an SSH server like
24708 @code{openssh-service-type} to your VM (@pxref{Networking Services,
24709 @code{openssh-service-type}}). In addition you need to forward the SSH port,
24710 22 by default, to the host. You can do this with
24711
24712 @example
24713 `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
24714 @end example
24715
24716 To connect to the VM you can run
24717
24718 @example
24719 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
24720 @end example
24721
24722 The @command{-p} tells @command{ssh} the port you want to connect to.
24723 @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
24724 every time you modify your @command{config.scm} file and the
24725 @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
24726 connection to an unknown host every time you connect.
24727
24728 @subsection Using @command{virt-viewer} with Spice
24729
24730 As an alternative to the default @command{qemu} graphical client you can
24731 use the @command{remote-viewer} from the @command{virt-viewer} package. To
24732 connect pass the @command{-spice port=5930,disable-ticketing} flag to
24733 @command{qemu}. See previous section for further information on how to do this.
24734
24735 Spice also allows you to do some nice stuff like share your clipboard with your
24736 VM. To enable that you'll also have to pass the following flags to @command{qemu}:
24737
24738 @example
24739 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
24740 -chardev spicevmc,name=vdagent,id=vdagent
24741 -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
24742 name=com.redhat.spice.0
24743 @end example
24744
24745 You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
24746
24747 @node Defining Services
24748 @section Defining Services
24749
24750 The previous sections show the available services and how one can combine
24751 them in an @code{operating-system} declaration. But how do we define
24752 them in the first place? And what is a service anyway?
24753
24754 @menu
24755 * Service Composition:: The model for composing services.
24756 * Service Types and Services:: Types and services.
24757 * Service Reference:: API reference.
24758 * Shepherd Services:: A particular type of service.
24759 @end menu
24760
24761 @node Service Composition
24762 @subsection Service Composition
24763
24764 @cindex services
24765 @cindex daemons
24766 Here we define a @dfn{service} as, broadly, something that extends the
24767 functionality of the operating system. Often a service is a process---a
24768 @dfn{daemon}---started when the system boots: a secure shell server, a
24769 Web server, the Guix build daemon, etc. Sometimes a service is a daemon
24770 whose execution can be triggered by another daemon---e.g., an FTP server
24771 started by @command{inetd} or a D-Bus service activated by
24772 @command{dbus-daemon}. Occasionally, a service does not map to a
24773 daemon. For instance, the ``account'' service collects user accounts
24774 and makes sure they exist when the system runs; the ``udev'' service
24775 collects device management rules and makes them available to the eudev
24776 daemon; the @file{/etc} service populates the @file{/etc} directory
24777 of the system.
24778
24779 @cindex service extensions
24780 Guix system services are connected by @dfn{extensions}. For instance, the
24781 secure shell service @emph{extends} the Shepherd---the
24782 initialization system, running as PID@tie{}1---by giving it the command
24783 lines to start and stop the secure shell daemon (@pxref{Networking
24784 Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
24785 service by passing it its @file{.service} specification, and extends the
24786 udev service by passing it device management rules (@pxref{Desktop
24787 Services, @code{upower-service}}); the Guix daemon service extends the
24788 Shepherd by passing it the command lines to start and stop the daemon,
24789 and extends the account service by passing it a list of required build
24790 user accounts (@pxref{Base Services}).
24791
24792 All in all, services and their ``extends'' relations form a directed
24793 acyclic graph (DAG). If we represent services as boxes and extensions
24794 as arrows, a typical system might provide something like this:
24795
24796 @image{images/service-graph,,5in,Typical service extension graph.}
24797
24798 @cindex system service
24799 At the bottom, we see the @dfn{system service}, which produces the
24800 directory containing everything to run and boot the system, as returned
24801 by the @command{guix system build} command. @xref{Service Reference},
24802 to learn about the other service types shown here.
24803 @xref{system-extension-graph, the @command{guix system extension-graph}
24804 command}, for information on how to generate this representation for a
24805 particular operating system definition.
24806
24807 @cindex service types
24808 Technically, developers can define @dfn{service types} to express these
24809 relations. There can be any number of services of a given type on the
24810 system---for instance, a system running two instances of the GNU secure
24811 shell server (lsh) has two instances of @code{lsh-service-type}, with
24812 different parameters.
24813
24814 The following section describes the programming interface for service
24815 types and services.
24816
24817 @node Service Types and Services
24818 @subsection Service Types and Services
24819
24820 A @dfn{service type} is a node in the DAG described above. Let us start
24821 with a simple example, the service type for the Guix build daemon
24822 (@pxref{Invoking guix-daemon}):
24823
24824 @example
24825 (define guix-service-type
24826 (service-type
24827 (name 'guix)
24828 (extensions
24829 (list (service-extension shepherd-root-service-type guix-shepherd-service)
24830 (service-extension account-service-type guix-accounts)
24831 (service-extension activation-service-type guix-activation)))
24832 (default-value (guix-configuration))))
24833 @end example
24834
24835 @noindent
24836 It defines three things:
24837
24838 @enumerate
24839 @item
24840 A name, whose sole purpose is to make inspection and debugging easier.
24841
24842 @item
24843 A list of @dfn{service extensions}, where each extension designates the
24844 target service type and a procedure that, given the parameters of the
24845 service, returns a list of objects to extend the service of that type.
24846
24847 Every service type has at least one service extension. The only
24848 exception is the @dfn{boot service type}, which is the ultimate service.
24849
24850 @item
24851 Optionally, a default value for instances of this type.
24852 @end enumerate
24853
24854 In this example, @code{guix-service-type} extends three services:
24855
24856 @table @code
24857 @item shepherd-root-service-type
24858 The @code{guix-shepherd-service} procedure defines how the Shepherd
24859 service is extended. Namely, it returns a @code{<shepherd-service>}
24860 object that defines how @command{guix-daemon} is started and stopped
24861 (@pxref{Shepherd Services}).
24862
24863 @item account-service-type
24864 This extension for this service is computed by @code{guix-accounts},
24865 which returns a list of @code{user-group} and @code{user-account}
24866 objects representing the build user accounts (@pxref{Invoking
24867 guix-daemon}).
24868
24869 @item activation-service-type
24870 Here @code{guix-activation} is a procedure that returns a gexp, which is
24871 a code snippet to run at ``activation time''---e.g., when the service is
24872 booted.
24873 @end table
24874
24875 A service of this type is instantiated like this:
24876
24877 @example
24878 (service guix-service-type
24879 (guix-configuration
24880 (build-accounts 5)
24881 (use-substitutes? #f)))
24882 @end example
24883
24884 The second argument to the @code{service} form is a value representing
24885 the parameters of this specific service instance.
24886 @xref{guix-configuration-type, @code{guix-configuration}}, for
24887 information about the @code{guix-configuration} data type. When the
24888 value is omitted, the default value specified by
24889 @code{guix-service-type} is used:
24890
24891 @example
24892 (service guix-service-type)
24893 @end example
24894
24895 @code{guix-service-type} is quite simple because it extends other
24896 services but is not extensible itself.
24897
24898 @c @subsubsubsection Extensible Service Types
24899
24900 The service type for an @emph{extensible} service looks like this:
24901
24902 @example
24903 (define udev-service-type
24904 (service-type (name 'udev)
24905 (extensions
24906 (list (service-extension shepherd-root-service-type
24907 udev-shepherd-service)))
24908
24909 (compose concatenate) ;concatenate the list of rules
24910 (extend (lambda (config rules)
24911 (match config
24912 (($ <udev-configuration> udev initial-rules)
24913 (udev-configuration
24914 (udev udev) ;the udev package to use
24915 (rules (append initial-rules rules)))))))))
24916 @end example
24917
24918 This is the service type for the
24919 @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
24920 management daemon}. Compared to the previous example, in addition to an
24921 extension of @code{shepherd-root-service-type}, we see two new fields:
24922
24923 @table @code
24924 @item compose
24925 This is the procedure to @dfn{compose} the list of extensions to
24926 services of this type.
24927
24928 Services can extend the udev service by passing it lists of rules; we
24929 compose those extensions simply by concatenating them.
24930
24931 @item extend
24932 This procedure defines how the value of the service is @dfn{extended} with
24933 the composition of the extensions.
24934
24935 Udev extensions are composed into a list of rules, but the udev service
24936 value is itself a @code{<udev-configuration>} record. So here, we
24937 extend that record by appending the list of rules it contains to the
24938 list of contributed rules.
24939
24940 @item description
24941 This is a string giving an overview of the service type. The string can
24942 contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
24943 @command{guix system search} command searches these strings and displays
24944 them (@pxref{Invoking guix system}).
24945 @end table
24946
24947 There can be only one instance of an extensible service type such as
24948 @code{udev-service-type}. If there were more, the
24949 @code{service-extension} specifications would be ambiguous.
24950
24951 Still here? The next section provides a reference of the programming
24952 interface for services.
24953
24954 @node Service Reference
24955 @subsection Service Reference
24956
24957 We have seen an overview of service types (@pxref{Service Types and
24958 Services}). This section provides a reference on how to manipulate
24959 services and service types. This interface is provided by the
24960 @code{(gnu services)} module.
24961
24962 @deffn {Scheme Procedure} service @var{type} [@var{value}]
24963 Return a new service of @var{type}, a @code{<service-type>} object (see
24964 below.) @var{value} can be any object; it represents the parameters of
24965 this particular service instance.
24966
24967 When @var{value} is omitted, the default value specified by @var{type}
24968 is used; if @var{type} does not specify a default value, an error is
24969 raised.
24970
24971 For instance, this:
24972
24973 @example
24974 (service openssh-service-type)
24975 @end example
24976
24977 @noindent
24978 is equivalent to this:
24979
24980 @example
24981 (service openssh-service-type
24982 (openssh-configuration))
24983 @end example
24984
24985 In both cases the result is an instance of @code{openssh-service-type}
24986 with the default configuration.
24987 @end deffn
24988
24989 @deffn {Scheme Procedure} service? @var{obj}
24990 Return true if @var{obj} is a service.
24991 @end deffn
24992
24993 @deffn {Scheme Procedure} service-kind @var{service}
24994 Return the type of @var{service}---i.e., a @code{<service-type>} object.
24995 @end deffn
24996
24997 @deffn {Scheme Procedure} service-value @var{service}
24998 Return the value associated with @var{service}. It represents its
24999 parameters.
25000 @end deffn
25001
25002 Here is an example of how a service is created and manipulated:
25003
25004 @example
25005 (define s
25006 (service nginx-service-type
25007 (nginx-configuration
25008 (nginx nginx)
25009 (log-directory log-directory)
25010 (run-directory run-directory)
25011 (file config-file))))
25012
25013 (service? s)
25014 @result{} #t
25015
25016 (eq? (service-kind s) nginx-service-type)
25017 @result{} #t
25018 @end example
25019
25020 The @code{modify-services} form provides a handy way to change the
25021 parameters of some of the services of a list such as
25022 @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
25023 evaluates to a list of services. Of course, you could always use
25024 standard list combinators such as @code{map} and @code{fold} to do that
25025 (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
25026 @code{modify-services} simply provides a more concise form for this
25027 common pattern.
25028
25029 @deffn {Scheme Syntax} modify-services @var{services} @
25030 (@var{type} @var{variable} => @var{body}) @dots{}
25031
25032 Modify the services listed in @var{services} according to the given
25033 clauses. Each clause has the form:
25034
25035 @example
25036 (@var{type} @var{variable} => @var{body})
25037 @end example
25038
25039 where @var{type} is a service type---e.g.,
25040 @code{guix-service-type}---and @var{variable} is an identifier that is
25041 bound within the @var{body} to the service parameters---e.g., a
25042 @code{guix-configuration} instance---of the original service of that
25043 @var{type}.
25044
25045 The @var{body} should evaluate to the new service parameters, which will
25046 be used to configure the new service. This new service will replace the
25047 original in the resulting list. Because a service's service parameters
25048 are created using @code{define-record-type*}, you can write a succinct
25049 @var{body} that evaluates to the new service parameters by using the
25050 @code{inherit} feature that @code{define-record-type*} provides.
25051
25052 @xref{Using the Configuration System}, for example usage.
25053
25054 @end deffn
25055
25056 Next comes the programming interface for service types. This is
25057 something you want to know when writing new service definitions, but not
25058 necessarily when simply looking for ways to customize your
25059 @code{operating-system} declaration.
25060
25061 @deftp {Data Type} service-type
25062 @cindex service type
25063 This is the representation of a @dfn{service type} (@pxref{Service Types
25064 and Services}).
25065
25066 @table @asis
25067 @item @code{name}
25068 This is a symbol, used only to simplify inspection and debugging.
25069
25070 @item @code{extensions}
25071 A non-empty list of @code{<service-extension>} objects (see below).
25072
25073 @item @code{compose} (default: @code{#f})
25074 If this is @code{#f}, then the service type denotes services that cannot
25075 be extended---i.e., services that do not receive ``values'' from other
25076 services.
25077
25078 Otherwise, it must be a one-argument procedure. The procedure is called
25079 by @code{fold-services} and is passed a list of values collected from
25080 extensions. It may return any single value.
25081
25082 @item @code{extend} (default: @code{#f})
25083 If this is @code{#f}, services of this type cannot be extended.
25084
25085 Otherwise, it must be a two-argument procedure: @code{fold-services}
25086 calls it, passing it the initial value of the service as the first
25087 argument and the result of applying @code{compose} to the extension
25088 values as the second argument. It must return a value that is a valid
25089 parameter value for the service instance.
25090 @end table
25091
25092 @xref{Service Types and Services}, for examples.
25093 @end deftp
25094
25095 @deffn {Scheme Procedure} service-extension @var{target-type} @
25096 @var{compute}
25097 Return a new extension for services of type @var{target-type}.
25098 @var{compute} must be a one-argument procedure: @code{fold-services}
25099 calls it, passing it the value associated with the service that provides
25100 the extension; it must return a valid value for the target service.
25101 @end deffn
25102
25103 @deffn {Scheme Procedure} service-extension? @var{obj}
25104 Return true if @var{obj} is a service extension.
25105 @end deffn
25106
25107 Occasionally, you might want to simply extend an existing service. This
25108 involves creating a new service type and specifying the extension of
25109 interest, which can be verbose; the @code{simple-service} procedure
25110 provides a shorthand for this.
25111
25112 @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
25113 Return a service that extends @var{target} with @var{value}. This works
25114 by creating a singleton service type @var{name}, of which the returned
25115 service is an instance.
25116
25117 For example, this extends mcron (@pxref{Scheduled Job Execution}) with
25118 an additional job:
25119
25120 @example
25121 (simple-service 'my-mcron-job mcron-service-type
25122 #~(job '(next-hour (3)) "guix gc -F 2G"))
25123 @end example
25124 @end deffn
25125
25126 At the core of the service abstraction lies the @code{fold-services}
25127 procedure, which is responsible for ``compiling'' a list of services
25128 down to a single directory that contains everything needed to boot and
25129 run the system---the directory shown by the @command{guix system build}
25130 command (@pxref{Invoking guix system}). In essence, it propagates
25131 service extensions down the service graph, updating each node parameters
25132 on the way, until it reaches the root node.
25133
25134 @deffn {Scheme Procedure} fold-services @var{services} @
25135 [#:target-type @var{system-service-type}]
25136 Fold @var{services} by propagating their extensions down to the root of
25137 type @var{target-type}; return the root service adjusted accordingly.
25138 @end deffn
25139
25140 Lastly, the @code{(gnu services)} module also defines several essential
25141 service types, some of which are listed below.
25142
25143 @defvr {Scheme Variable} system-service-type
25144 This is the root of the service graph. It produces the system directory
25145 as returned by the @command{guix system build} command.
25146 @end defvr
25147
25148 @defvr {Scheme Variable} boot-service-type
25149 The type of the ``boot service'', which produces the @dfn{boot script}.
25150 The boot script is what the initial RAM disk runs when booting.
25151 @end defvr
25152
25153 @defvr {Scheme Variable} etc-service-type
25154 The type of the @file{/etc} service. This service is used to create
25155 files under @file{/etc} and can be extended by
25156 passing it name/file tuples such as:
25157
25158 @example
25159 (list `("issue" ,(plain-file "issue" "Welcome!\n")))
25160 @end example
25161
25162 In this example, the effect would be to add an @file{/etc/issue} file
25163 pointing to the given file.
25164 @end defvr
25165
25166 @defvr {Scheme Variable} setuid-program-service-type
25167 Type for the ``setuid-program service''. This service collects lists of
25168 executable file names, passed as gexps, and adds them to the set of
25169 setuid-root programs on the system (@pxref{Setuid Programs}).
25170 @end defvr
25171
25172 @defvr {Scheme Variable} profile-service-type
25173 Type of the service that populates the @dfn{system profile}---i.e., the
25174 programs under @file{/run/current-system/profile}. Other services can
25175 extend it by passing it lists of packages to add to the system profile.
25176 @end defvr
25177
25178
25179 @node Shepherd Services
25180 @subsection Shepherd Services
25181
25182 @cindex shepherd services
25183 @cindex PID 1
25184 @cindex init system
25185 The @code{(gnu services shepherd)} module provides a way to define
25186 services managed by the GNU@tie{}Shepherd, which is the
25187 initialization system---the first process that is started when the
25188 system boots, also known as PID@tie{}1
25189 (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
25190
25191 Services in the Shepherd can depend on each other. For instance, the
25192 SSH daemon may need to be started after the syslog daemon has been
25193 started, which in turn can only happen once all the file systems have
25194 been mounted. The simple operating system defined earlier (@pxref{Using
25195 the Configuration System}) results in a service graph like this:
25196
25197 @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
25198
25199 You can actually generate such a graph for any operating system
25200 definition using the @command{guix system shepherd-graph} command
25201 (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
25202
25203 The @code{%shepherd-root-service} is a service object representing
25204 PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
25205 by passing it lists of @code{<shepherd-service>} objects.
25206
25207 @deftp {Data Type} shepherd-service
25208 The data type representing a service managed by the Shepherd.
25209
25210 @table @asis
25211 @item @code{provision}
25212 This is a list of symbols denoting what the service provides.
25213
25214 These are the names that may be passed to @command{herd start},
25215 @command{herd status}, and similar commands (@pxref{Invoking herd,,,
25216 shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
25217 @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
25218
25219 @item @code{requirements} (default: @code{'()})
25220 List of symbols denoting the Shepherd services this one depends on.
25221
25222 @cindex one-shot services, for the Shepherd
25223 @item @code{one-shot?} (default: @code{#f})
25224 Whether this service is @dfn{one-shot}. One-shot services stop immediately
25225 after their @code{start} action has completed. @xref{Slots of services,,,
25226 shepherd, The GNU Shepherd Manual}, for more info.
25227
25228 @item @code{respawn?} (default: @code{#t})
25229 Whether to restart the service when it stops, for instance when the
25230 underlying process dies.
25231
25232 @item @code{start}
25233 @itemx @code{stop} (default: @code{#~(const #f)})
25234 The @code{start} and @code{stop} fields refer to the Shepherd's
25235 facilities to start and stop processes (@pxref{Service De- and
25236 Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
25237 G-expressions that get expanded in the Shepherd configuration file
25238 (@pxref{G-Expressions}).
25239
25240 @item @code{actions} (default: @code{'()})
25241 @cindex actions, of Shepherd services
25242 This is a list of @code{shepherd-action} objects (see below) defining
25243 @dfn{actions} supported by the service, in addition to the standard
25244 @code{start} and @code{stop} actions. Actions listed here become available as
25245 @command{herd} sub-commands:
25246
25247 @example
25248 herd @var{action} @var{service} [@var{arguments}@dots{}]
25249 @end example
25250
25251 @item @code{documentation}
25252 A documentation string, as shown when running:
25253
25254 @example
25255 herd doc @var{service-name}
25256 @end example
25257
25258 where @var{service-name} is one of the symbols in @code{provision}
25259 (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
25260
25261 @item @code{modules} (default: @code{%default-modules})
25262 This is the list of modules that must be in scope when @code{start} and
25263 @code{stop} are evaluated.
25264
25265 @end table
25266 @end deftp
25267
25268 @deftp {Data Type} shepherd-action
25269 This is the data type that defines additional actions implemented by a
25270 Shepherd service (see above).
25271
25272 @table @code
25273 @item name
25274 Symbol naming the action.
25275
25276 @item documentation
25277 This is a documentation string for the action. It can be viewed by running:
25278
25279 @example
25280 herd doc @var{service} action @var{action}
25281 @end example
25282
25283 @item procedure
25284 This should be a gexp that evaluates to a procedure of at least one argument,
25285 which is the ``running value'' of the service (@pxref{Slots of services,,,
25286 shepherd, The GNU Shepherd Manual}).
25287 @end table
25288
25289 The following example defines an action called @code{say-hello} that kindly
25290 greets the user:
25291
25292 @example
25293 (shepherd-action
25294 (name 'say-hello)
25295 (documentation "Say hi!")
25296 (procedure #~(lambda (running . args)
25297 (format #t "Hello, friend! arguments: ~s\n"
25298 args)
25299 #t)))
25300 @end example
25301
25302 Assuming this action is added to the @code{example} service, then you can do:
25303
25304 @example
25305 # herd say-hello example
25306 Hello, friend! arguments: ()
25307 # herd say-hello example a b c
25308 Hello, friend! arguments: ("a" "b" "c")
25309 @end example
25310
25311 This, as you can see, is a fairly sophisticated way to say hello.
25312 @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
25313 info on actions.
25314 @end deftp
25315
25316 @defvr {Scheme Variable} shepherd-root-service-type
25317 The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
25318
25319 This is the service type that extensions target when they want to create
25320 shepherd services (@pxref{Service Types and Services}, for an example).
25321 Each extension must pass a list of @code{<shepherd-service>}.
25322 @end defvr
25323
25324 @defvr {Scheme Variable} %shepherd-root-service
25325 This service represents PID@tie{}1.
25326 @end defvr
25327
25328
25329 @node Documentation
25330 @chapter Documentation
25331
25332 @cindex documentation, searching for
25333 @cindex searching for documentation
25334 @cindex Info, documentation format
25335 @cindex man pages
25336 @cindex manual pages
25337 In most cases packages installed with Guix come with documentation.
25338 There are two main documentation formats: ``Info'', a browseable
25339 hypertext format used for GNU software, and ``manual pages'' (or ``man
25340 pages''), the linear documentation format traditionally found on Unix.
25341 Info manuals are accessed with the @command{info} command or with Emacs,
25342 and man pages are accessed using @command{man}.
25343
25344 You can look for documentation of software installed on your system by
25345 keyword. For example, the following command searches for information
25346 about ``TLS'' in Info manuals:
25347
25348 @example
25349 $ info -k TLS
25350 "(emacs)Network Security" -- STARTTLS
25351 "(emacs)Network Security" -- TLS
25352 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
25353 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
25354 @dots{}
25355 @end example
25356
25357 @noindent
25358 The command below searches for the same keyword in man pages:
25359
25360 @example
25361 $ man -k TLS
25362 SSL (7) - OpenSSL SSL/TLS library
25363 certtool (1) - GnuTLS certificate tool
25364 @dots {}
25365 @end example
25366
25367 These searches are purely local to your computer so you have the
25368 guarantee that documentation you find corresponds to what you have
25369 actually installed, you can access it off-line, and your privacy is
25370 respected.
25371
25372 Once you have these results, you can view the relevant documentation by
25373 running, say:
25374
25375 @example
25376 $ info "(gnutls)Core TLS API"
25377 @end example
25378
25379 @noindent
25380 or:
25381
25382 @example
25383 $ man certtool
25384 @end example
25385
25386 Info manuals contain sections and indices as well as hyperlinks like
25387 those found in Web pages. The @command{info} reader (@pxref{Top, Info
25388 reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
25389 (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
25390 bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
25391 Introduction}, for an introduction to Info navigation.
25392
25393 @node Installing Debugging Files
25394 @chapter Installing Debugging Files
25395
25396 @cindex debugging files
25397 Program binaries, as produced by the GCC compilers for instance, are
25398 typically written in the ELF format, with a section containing
25399 @dfn{debugging information}. Debugging information is what allows the
25400 debugger, GDB, to map binary code to source code; it is required to
25401 debug a compiled program in good conditions.
25402
25403 The problem with debugging information is that is takes up a fair amount
25404 of disk space. For example, debugging information for the GNU C Library
25405 weighs in at more than 60 MiB. Thus, as a user, keeping all the
25406 debugging info of all the installed programs is usually not an option.
25407 Yet, space savings should not come at the cost of an impediment to
25408 debugging---especially in the GNU system, which should make it easier
25409 for users to exert their computing freedom (@pxref{GNU Distribution}).
25410
25411 Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
25412 mechanism that allows users to get the best of both worlds: debugging
25413 information can be stripped from the binaries and stored in separate
25414 files. GDB is then able to load debugging information from those files,
25415 when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
25416 with GDB}).
25417
25418 The GNU distribution takes advantage of this by storing debugging
25419 information in the @code{lib/debug} sub-directory of a separate package
25420 output unimaginatively called @code{debug} (@pxref{Packages with
25421 Multiple Outputs}). Users can choose to install the @code{debug} output
25422 of a package when they need it. For instance, the following command
25423 installs the debugging information for the GNU C Library and for GNU
25424 Guile:
25425
25426 @example
25427 guix package -i glibc:debug guile:debug
25428 @end example
25429
25430 GDB must then be told to look for debug files in the user's profile, by
25431 setting the @code{debug-file-directory} variable (consider setting it
25432 from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
25433 GDB}):
25434
25435 @example
25436 (gdb) set debug-file-directory ~/.guix-profile/lib/debug
25437 @end example
25438
25439 From there on, GDB will pick up debugging information from the
25440 @code{.debug} files under @file{~/.guix-profile/lib/debug}.
25441
25442 In addition, you will most likely want GDB to be able to show the source
25443 code being debugged. To do that, you will have to unpack the source
25444 code of the package of interest (obtained with @code{guix build
25445 --source}, @pxref{Invoking guix build}), and to point GDB to that source
25446 directory using the @code{directory} command (@pxref{Source Path,
25447 @code{directory},, gdb, Debugging with GDB}).
25448
25449 @c XXX: keep me up-to-date
25450 The @code{debug} output mechanism in Guix is implemented by the
25451 @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
25452 opt-in---debugging information is available only for the packages
25453 with definitions explicitly declaring a @code{debug} output. This may be
25454 changed to opt-out in the future if our build farm servers can handle
25455 the load. To check whether a package has a @code{debug} output, use
25456 @command{guix package --list-available} (@pxref{Invoking guix package}).
25457
25458
25459 @node Security Updates
25460 @chapter Security Updates
25461
25462 @cindex security updates
25463 @cindex security vulnerabilities
25464 Occasionally, important security vulnerabilities are discovered in software
25465 packages and must be patched. Guix developers try hard to keep track of
25466 known vulnerabilities and to apply fixes as soon as possible in the
25467 @code{master} branch of Guix (we do not yet provide a ``stable'' branch
25468 containing only security updates.) The @command{guix lint} tool helps
25469 developers find out about vulnerable versions of software packages in the
25470 distribution:
25471
25472 @smallexample
25473 $ guix lint -c cve
25474 gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
25475 gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
25476 gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
25477 @dots{}
25478 @end smallexample
25479
25480 @xref{Invoking guix lint}, for more information.
25481
25482 @quotation Note
25483 As of version @value{VERSION}, the feature described below is considered
25484 ``beta''.
25485 @end quotation
25486
25487 Guix follows a functional
25488 package management discipline (@pxref{Introduction}), which implies
25489 that, when a package is changed, @emph{every package that depends on it}
25490 must be rebuilt. This can significantly slow down the deployment of
25491 fixes in core packages such as libc or Bash, since basically the whole
25492 distribution would need to be rebuilt. Using pre-built binaries helps
25493 (@pxref{Substitutes}), but deployment may still take more time than
25494 desired.
25495
25496 @cindex grafts
25497 To address this, Guix implements @dfn{grafts}, a mechanism that allows
25498 for fast deployment of critical updates without the costs associated
25499 with a whole-distribution rebuild. The idea is to rebuild only the
25500 package that needs to be patched, and then to ``graft'' it onto packages
25501 explicitly installed by the user and that were previously referring to
25502 the original package. The cost of grafting is typically very low, and
25503 order of magnitudes lower than a full rebuild of the dependency chain.
25504
25505 @cindex replacements of packages, for grafts
25506 For instance, suppose a security update needs to be applied to Bash.
25507 Guix developers will provide a package definition for the ``fixed''
25508 Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
25509 Packages}). Then, the original package definition is augmented with a
25510 @code{replacement} field pointing to the package containing the bug fix:
25511
25512 @example
25513 (define bash
25514 (package
25515 (name "bash")
25516 ;; @dots{}
25517 (replacement bash-fixed)))
25518 @end example
25519
25520 From there on, any package depending directly or indirectly on Bash---as
25521 reported by @command{guix gc --requisites} (@pxref{Invoking guix
25522 gc})---that is installed is automatically ``rewritten'' to refer to
25523 @code{bash-fixed} instead of @code{bash}. This grafting process takes
25524 time proportional to the size of the package, usually less than a
25525 minute for an ``average'' package on a recent machine. Grafting is
25526 recursive: when an indirect dependency requires grafting, then grafting
25527 ``propagates'' up to the package that the user is installing.
25528
25529 Currently, the length of the name and version of the graft and that of
25530 the package it replaces (@code{bash-fixed} and @code{bash} in the example
25531 above) must be equal. This restriction mostly comes from the fact that
25532 grafting works by patching files, including binary files, directly.
25533 Other restrictions may apply: for instance, when adding a graft to a
25534 package providing a shared library, the original shared library and its
25535 replacement must have the same @code{SONAME} and be binary-compatible.
25536
25537 The @option{--no-grafts} command-line option allows you to forcefully
25538 avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
25539 Thus, the command:
25540
25541 @example
25542 guix build bash --no-grafts
25543 @end example
25544
25545 @noindent
25546 returns the store file name of the original Bash, whereas:
25547
25548 @example
25549 guix build bash
25550 @end example
25551
25552 @noindent
25553 returns the store file name of the ``fixed'', replacement Bash. This
25554 allows you to distinguish between the two variants of Bash.
25555
25556 To verify which Bash your whole profile refers to, you can run
25557 (@pxref{Invoking guix gc}):
25558
25559 @example
25560 guix gc -R `readlink -f ~/.guix-profile` | grep bash
25561 @end example
25562
25563 @noindent
25564 @dots{} and compare the store file names that you get with those above.
25565 Likewise for a complete Guix system generation:
25566
25567 @example
25568 guix gc -R `guix system build my-config.scm` | grep bash
25569 @end example
25570
25571 Lastly, to check which Bash running processes are using, you can use the
25572 @command{lsof} command:
25573
25574 @example
25575 lsof | grep /gnu/store/.*bash
25576 @end example
25577
25578
25579 @node Bootstrapping
25580 @chapter Bootstrapping
25581
25582 @c Adapted from the ELS 2013 paper.
25583
25584 @cindex bootstrapping
25585
25586 Bootstrapping in our context refers to how the distribution gets built
25587 ``from nothing''. Remember that the build environment of a derivation
25588 contains nothing but its declared inputs (@pxref{Introduction}). So
25589 there's an obvious chicken-and-egg problem: how does the first package
25590 get built? How does the first compiler get compiled? Note that this is
25591 a question of interest only to the curious hacker, not to the regular
25592 user, so you can shamelessly skip this section if you consider yourself
25593 a ``regular user''.
25594
25595 @cindex bootstrap binaries
25596 The GNU system is primarily made of C code, with libc at its core. The
25597 GNU build system itself assumes the availability of a Bourne shell and
25598 command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
25599 `grep'. Furthermore, build programs---programs that run
25600 @code{./configure}, @code{make}, etc.---are written in Guile Scheme
25601 (@pxref{Derivations}). Consequently, to be able to build anything at
25602 all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
25603 Binutils, libc, and the other packages mentioned above---the
25604 @dfn{bootstrap binaries}.
25605
25606 These bootstrap binaries are ``taken for granted'', though we can also
25607 re-create them if needed (more on that later).
25608
25609 @unnumberedsec Preparing to Use the Bootstrap Binaries
25610
25611 @c As of Emacs 24.3, Info-mode displays the image, but since it's a
25612 @c large image, it's hard to scroll. Oh well.
25613 @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
25614
25615 The figure above shows the very beginning of the dependency graph of the
25616 distribution, corresponding to the package definitions of the @code{(gnu
25617 packages bootstrap)} module. A similar figure can be generated with
25618 @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
25619
25620 @example
25621 guix graph -t derivation \
25622 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
25623 | dot -Tps > t.ps
25624 @end example
25625
25626 At this level of detail, things are
25627 slightly complex. First, Guile itself consists of an ELF executable,
25628 along with many source and compiled Scheme files that are dynamically
25629 loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
25630 tarball shown in this graph. This tarball is part of Guix's ``source''
25631 distribution, and gets inserted into the store with @code{add-to-store}
25632 (@pxref{The Store}).
25633
25634 But how do we write a derivation that unpacks this tarball and adds it
25635 to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
25636 derivation---the first one that gets built---uses @code{bash} as its
25637 builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
25638 @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
25639 @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
25640 the Guix source distribution, whose sole purpose is to allow the Guile
25641 tarball to be unpacked.
25642
25643 Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
25644 Guile that can be used to run subsequent build programs. Its first task
25645 is to download tarballs containing the other pre-built binaries---this
25646 is what the @code{.tar.xz.drv} derivations do. Guix modules such as
25647 @code{ftp-client.scm} are used for this purpose. The
25648 @code{module-import.drv} derivations import those modules in a directory
25649 in the store, using the original layout. The
25650 @code{module-import-compiled.drv} derivations compile those modules, and
25651 write them in an output directory with the right layout. This
25652 corresponds to the @code{#:modules} argument of
25653 @code{build-expression->derivation} (@pxref{Derivations}).
25654
25655 Finally, the various tarballs are unpacked by the
25656 derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
25657 etc., at which point we have a working C tool chain.
25658
25659
25660 @unnumberedsec Building the Build Tools
25661
25662 Bootstrapping is complete when we have a full tool chain that does not
25663 depend on the pre-built bootstrap tools discussed above. This
25664 no-dependency requirement is verified by checking whether the files of
25665 the final tool chain contain references to the @file{/gnu/store}
25666 directories of the bootstrap inputs. The process that leads to this
25667 ``final'' tool chain is described by the package definitions found in
25668 the @code{(gnu packages commencement)} module.
25669
25670 The @command{guix graph} command allows us to ``zoom out'' compared to
25671 the graph above, by looking at the level of package objects instead of
25672 individual derivations---remember that a package may translate to
25673 several derivations, typically one derivation to download its source,
25674 one to build the Guile modules it needs, and one to actually build the
25675 package from source. The command:
25676
25677 @example
25678 guix graph -t bag \
25679 -e '(@@@@ (gnu packages commencement)
25680 glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
25681 @end example
25682
25683 @noindent
25684 produces the dependency graph leading to the ``final'' C
25685 library@footnote{You may notice the @code{glibc-intermediate} label,
25686 suggesting that it is not @emph{quite} final, but as a good
25687 approximation, we will consider it final.}, depicted below.
25688
25689 @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
25690
25691 @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
25692 The first tool that gets built with the bootstrap binaries is
25693 GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
25694 for all the following packages. From there Findutils and Diffutils get
25695 built.
25696
25697 Then come the first-stage Binutils and GCC, built as pseudo cross
25698 tools---i.e., with @code{--target} equal to @code{--host}. They are
25699 used to build libc. Thanks to this cross-build trick, this libc is
25700 guaranteed not to hold any reference to the initial tool chain.
25701
25702 From there the final Binutils and GCC (not shown above) are built.
25703 GCC uses @code{ld}
25704 from the final Binutils, and links programs against the just-built libc.
25705 This tool chain is used to build the other packages used by Guix and by
25706 the GNU Build System: Guile, Bash, Coreutils, etc.
25707
25708 And voilà! At this point we have the complete set of build tools that
25709 the GNU Build System expects. These are in the @code{%final-inputs}
25710 variable of the @code{(gnu packages commencement)} module, and are
25711 implicitly used by any package that uses @code{gnu-build-system}
25712 (@pxref{Build Systems, @code{gnu-build-system}}).
25713
25714
25715 @unnumberedsec Building the Bootstrap Binaries
25716
25717 @cindex bootstrap binaries
25718 Because the final tool chain does not depend on the bootstrap binaries,
25719 those rarely need to be updated. Nevertheless, it is useful to have an
25720 automated way to produce them, should an update occur, and this is what
25721 the @code{(gnu packages make-bootstrap)} module provides.
25722
25723 The following command builds the tarballs containing the bootstrap
25724 binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
25725 of Coreutils and other basic command-line tools):
25726
25727 @example
25728 guix build bootstrap-tarballs
25729 @end example
25730
25731 The generated tarballs are those that should be referred to in the
25732 @code{(gnu packages bootstrap)} module mentioned at the beginning of
25733 this section.
25734
25735 Still here? Then perhaps by now you've started to wonder: when do we
25736 reach a fixed point? That is an interesting question! The answer is
25737 unknown, but if you would like to investigate further (and have
25738 significant computational and storage resources to do so), then let us
25739 know.
25740
25741 @unnumberedsec Reducing the Set of Bootstrap Binaries
25742
25743 Our bootstrap binaries currently include GCC, Guile, etc. That's a lot
25744 of binary code! Why is that a problem? It's a problem because these
25745 big chunks of binary code are practically non-auditable, which makes it
25746 hard to establish what source code produced them. Every unauditable
25747 binary also leaves us vulnerable to compiler backdoors as described by
25748 Ken Thompson in the 1984 paper @emph{Reflections on Trusting Trust}.
25749
25750 This is mitigated by the fact that our bootstrap binaries were generated
25751 from an earlier Guix revision. Nevertheless it lacks the level of
25752 transparency that we get in the rest of the package dependency graph,
25753 where Guix always gives us a source-to-binary mapping. Thus, our goal
25754 is to reduce the set of bootstrap binaries to the bare minimum.
25755
25756 The @uref{http://bootstrappable.org, Bootstrappable.org web site} lists
25757 on-going projects to do that. One of these is about replacing the
25758 bootstrap GCC with a sequence of assemblers, interpreters, and compilers
25759 of increasing complexity, which could be built from source starting from
25760 a simple and auditable assembler. Your help is welcome!
25761
25762
25763 @node Porting
25764 @chapter Porting to a New Platform
25765
25766 As discussed above, the GNU distribution is self-contained, and
25767 self-containment is achieved by relying on pre-built ``bootstrap
25768 binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
25769 operating system kernel, CPU architecture, and application binary
25770 interface (ABI). Thus, to port the distribution to a platform that is
25771 not yet supported, one must build those bootstrap binaries, and update
25772 the @code{(gnu packages bootstrap)} module to use them on that platform.
25773
25774 Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
25775 When everything goes well, and assuming the GNU tool chain supports the
25776 target platform, this can be as simple as running a command like this
25777 one:
25778
25779 @example
25780 guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
25781 @end example
25782
25783 For this to work, the @code{glibc-dynamic-linker} procedure in
25784 @code{(gnu packages bootstrap)} must be augmented to return the right
25785 file name for libc's dynamic linker on that platform; likewise,
25786 @code{system->linux-architecture} in @code{(gnu packages linux)} must be
25787 taught about the new platform.
25788
25789 Once these are built, the @code{(gnu packages bootstrap)} module needs
25790 to be updated to refer to these binaries on the target platform. That
25791 is, the hashes and URLs of the bootstrap tarballs for the new platform
25792 must be added alongside those of the currently supported platforms. The
25793 bootstrap Guile tarball is treated specially: it is expected to be
25794 available locally, and @file{gnu/local.mk} has rules to download it for
25795 the supported architectures; a rule for the new platform must be added
25796 as well.
25797
25798 In practice, there may be some complications. First, it may be that the
25799 extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
25800 above) is not recognized by all the GNU tools. Typically, glibc
25801 recognizes some of these, whereas GCC uses an extra @code{--with-abi}
25802 configure flag (see @code{gcc.scm} for examples of how to handle this).
25803 Second, some of the required packages could fail to build for that
25804 platform. Lastly, the generated binaries could be broken for some
25805 reason.
25806
25807 @c *********************************************************************
25808 @include contributing.texi
25809
25810 @c *********************************************************************
25811 @node Acknowledgments
25812 @chapter Acknowledgments
25813
25814 Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
25815 which was designed and
25816 implemented by Eelco Dolstra, with contributions from other people (see
25817 the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
25818 management, and promoted unprecedented features, such as transactional
25819 package upgrades and rollbacks, per-user profiles, and referentially
25820 transparent build processes. Without this work, Guix would not exist.
25821
25822 The Nix-based software distributions, Nixpkgs and NixOS, have also been
25823 an inspiration for Guix.
25824
25825 GNU@tie{}Guix itself is a collective work with contributions from a
25826 number of people. See the @file{AUTHORS} file in Guix for more
25827 information on these fine people. The @file{THANKS} file lists people
25828 who have helped by reporting bugs, taking care of the infrastructure,
25829 providing artwork and themes, making suggestions, and more---thank you!
25830
25831
25832 @c *********************************************************************
25833 @node GNU Free Documentation License
25834 @appendix GNU Free Documentation License
25835 @cindex license, GNU Free Documentation License
25836 @include fdl-1.3.texi
25837
25838 @c *********************************************************************
25839 @node Concept Index
25840 @unnumbered Concept Index
25841 @printindex cp
25842
25843 @node Programming Index
25844 @unnumbered Programming Index
25845 @syncodeindex tp fn
25846 @syncodeindex vr fn
25847 @printindex fn
25848
25849 @bye
25850
25851 @c Local Variables:
25852 @c ispell-local-dictionary: "american";
25853 @c End: